PrepareProposal-VoteExtension integration (#6915)

This commit is contained in:
mconcat
2022-02-02 11:51:13 +01:00
committed by Sergio Mena
parent d2afb91e99
commit 39ffa80ae7
8 changed files with 281 additions and 188 deletions
+3 -1
View File
@@ -180,6 +180,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
require.NotNil(t, lazyNodeState.privValidator)
var commit *types.Commit
var votes []*types.Vote
switch {
case lazyNodeState.Height == lazyNodeState.state.InitialHeight:
// We're creating a proposal for the first block.
@@ -188,6 +189,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
case lazyNodeState.LastCommit.HasTwoThirdsMajority():
// Make the commit from LastCommit
commit = lazyNodeState.LastCommit.MakeCommit()
votes = lazyNodeState.LastCommit.GetVotes()
default: // This shouldn't happen.
lazyNodeState.logger.Error("enterPropose: Cannot propose anything: No commit for the previous block")
return
@@ -205,7 +207,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
proposerAddr := lazyNodeState.privValidatorPubKey.Address()
block, blockParts, err := lazyNodeState.blockExec.CreateProposalBlock(
lazyNodeState.Height, lazyNodeState.state, commit, proposerAddr,
lazyNodeState.Height, lazyNodeState.state, commit, proposerAddr, votes,
)
require.NoError(t, err)
+3 -1
View File
@@ -1334,6 +1334,7 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa
}
var commit *types.Commit
var votes []*types.Vote
switch {
case cs.Height == cs.state.InitialHeight:
// We're creating a proposal for the first block.
@@ -1343,6 +1344,7 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa
case cs.LastCommit.HasTwoThirdsMajority():
// Make the commit from LastCommit
commit = cs.LastCommit.MakeCommit()
votes = cs.LastCommit.GetVotes()
default: // This shouldn't happen.
cs.logger.Error("propose step; cannot propose anything without commit for the previous block")
@@ -1358,7 +1360,7 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa
proposerAddr := cs.privValidatorPubKey.Address()
return cs.blockExec.CreateProposalBlock(cs.Height, cs.state, commit, proposerAddr)
return cs.blockExec.CreateProposalBlock(cs.Height, cs.state, commit, proposerAddr, votes)
}
// Enter: `timeoutPropose` after entering Propose.
+6 -2
View File
@@ -105,6 +105,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
height int64,
state State, commit *types.Commit,
proposerAddr []byte,
votes []*types.Vote,
) (*types.Block, *types.PartSet, error) {
maxBytes := state.ConsensusParams.Block.MaxBytes
@@ -119,7 +120,11 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
preparedProposal, err := blockExec.proxyApp.PrepareProposal(
context.Background(),
abci.RequestPrepareProposal{BlockData: txs.ToSliceOfBytes(), BlockDataSize: maxDataBytes},
abci.RequestPrepareProposal{
BlockData: txs.ToSliceOfBytes(),
BlockDataSize: maxDataBytes,
Votes: types.VotesToProto(votes),
},
)
if err != nil {
// The App MUST ensure that only valid (and hence 'processable') transactions
@@ -270,7 +275,6 @@ func (blockExec *BlockExecutor) ExtendVote(vote *types.Vote) (types.VoteExtensio
if err != nil {
return types.VoteExtension{}, err
}
return types.VoteExtensionFromProto(resp.VoteExtension), nil
}