Skip to content

Commit 332c4af

Browse files
committed
add proposal block for prevote
1 parent 5a0ca32 commit 332c4af

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

internal/consensus/reactor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ OUTER_LOOP:
540540
rs := r.getRoundState()
541541
prs := ps.GetRoundState()
542542
// Send Proposal && ProposalPOL BitArray?
543-
logger.Info("PSULOG - OUTERLOOP - checking if we should send proposal", "height", prs.Height, "round", prs.Round, "rs proposal", rs.Proposal, "prs proposal", prs.Proposal, "cs.Proposal", r.state.Proposal)
543+
logger.Info("PSULOG - OUTERLOOP - checking if we should send proposal", "height", prs.Height, "round", prs.Round, "rs proposal", rs.Proposal, "prs proposal", prs.Proposal, "cs.ProposalBlock", r.state.ProposalBlock)
544544
if rs.Proposal != nil && !prs.Proposal {
545545
// Proposal: share the proposal metadata with peer.
546546
{

internal/consensus/state.go

+32
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,38 @@ func (cs *State) proposalIsTimely() bool {
16181618
func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32) {
16191619
logger := cs.logger.With("height", height, "round", round)
16201620

1621+
if cs.config.GossipTransactionHashOnly && cs.ProposalBlock == nil {
1622+
logger.Info("prevote step: Creating proposal block from txs", "proposal", cs.Proposal, "proposal block parts", cs.ProposalBlockParts)
1623+
txKeys := cs.Proposal.TxKeys
1624+
if len(cs.blockExec.GetMissingTxs(txKeys)) != 0 {
1625+
logger.Info("PSULOG - prevote step: populating txs has missing txs", "keys", cs.blockExec.GetMissingTxs(txKeys))
1626+
} else {
1627+
bz, err := io.ReadAll(cs.ProposalBlockParts.GetReader())
1628+
if err != nil {
1629+
logger.Error("Encountered error reading block parts", err)
1630+
return
1631+
}
1632+
1633+
var pbb = new(tmproto.Block)
1634+
err = proto.Unmarshal(bz, pbb)
1635+
if err != nil {
1636+
logger.Error("Encountered error unmarshaling block", err)
1637+
return
1638+
}
1639+
1640+
block, err := types.BlockFromProto(pbb)
1641+
if err != nil {
1642+
logger.Error("Encountered error converting block from proto", err)
1643+
return
1644+
}
1645+
// We have full proposal block. Set txs in proposal block from mempool
1646+
txs := cs.blockExec.GetTxsForKeys(txKeys)
1647+
block.Data.Txs = txs
1648+
block.DataHash = block.Data.Hash()
1649+
cs.ProposalBlock = block
1650+
logger.Info("PSULOG - setting proposal block", "block", block)
1651+
}
1652+
}
16211653
// Check that a proposed block was not received within this round (and thus executing this from a timeout).
16221654
if cs.ProposalBlock == nil {
16231655
logger.Info("prevote step: ProposalBlock is nil; prevoting nil")

0 commit comments

Comments
 (0)