Skip to content

Commit f950c0e

Browse files
authored
chore: correctly validate the proposal when proposing (#2764)
This fixes proposal validation in the case of a sentry setup.
1 parent 35ce111 commit f950c0e

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

consensus/state.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,28 +1401,31 @@ func (cs *State) defaultDecideProposal(height int64, round int32) {
14011401

14021402
// Verify whether this proposal corresponds to the returned signature.
14031403
// This fixes the edge case where a KMS, in a sentry setup, returns the signature of a different proposal
1404-
if cs.rs.Validators.GetProposer().PubKey.VerifySignature(
1405-
types.ProposalSignBytes(cs.state.ChainID, p), proposal.Signature,
1404+
if !cs.privValidatorPubKey.VerifySignature(
1405+
types.ProposalSignBytes(cs.state.ChainID, proposal.ToProto()), proposal.Signature,
14061406
) {
1407-
metaData := make([]proptypes.TxMetaData, len(block.Txs))
1408-
hashes := block.CachedHashes()
1409-
for i, pos := range blockParts.TxPos {
1410-
metaData[i] = proptypes.TxMetaData{
1411-
Start: pos.Start,
1412-
End: pos.End,
1413-
Hash: hashes[i],
1414-
}
1415-
}
1407+
cs.Logger.Debug("propose step; couldn't verify signature. ignore if this is sentry setup as one of the sentries should have the correct proposal", "height", height, "round", round)
1408+
return
1409+
}
14161410

1417-
err = cs.propagator.ProposeBlock(proposal, blockParts, metaData)
1418-
if err != nil {
1419-
cs.Logger.Error("propagation reactor failed to propose the block", "err", err)
1420-
if !cs.gossipDataEnabled.Load() {
1421-
return
1422-
}
1411+
cs.Logger.Debug("verified proposal signature", "proposal", proposal)
1412+
metaData := make([]proptypes.TxMetaData, len(block.Txs))
1413+
hashes := block.CachedHashes()
1414+
for i, pos := range blockParts.TxPos {
1415+
metaData[i] = proptypes.TxMetaData{
1416+
Start: pos.Start,
1417+
End: pos.End,
1418+
Hash: hashes[i],
14231419
}
14241420
}
14251421

1422+
err = cs.propagator.ProposeBlock(proposal, blockParts, metaData)
1423+
if err != nil {
1424+
cs.Logger.Error("propagation reactor failed to propose the block", "err", err)
1425+
if !cs.gossipDataEnabled.Load() {
1426+
return
1427+
}
1428+
}
14261429
// send proposal and block parts on internal msg queue
14271430
cs.sendInternalMessage(msgInfo{&ProposalMessage{proposal}, ""})
14281431

@@ -1437,7 +1440,7 @@ func (cs *State) defaultDecideProposal(height int64, round int32) {
14371440
}()
14381441
wg.Wait()
14391442

1440-
cs.Logger.Debug("signed proposal", "height", height, "round", round, "proposal", proposal)
1443+
cs.Logger.Debug("propagated proposal", "height", height, "round", round, "proposal", proposal)
14411444
} else if !cs.replayMode {
14421445
cs.Logger.Error("propose step; failed signing proposal", "height", height, "round", round, "err", err)
14431446
}

0 commit comments

Comments
 (0)