Browse Source

thread vote information through for future use by vote extensions

wb/txrset
William Banfield 3 years ago
parent
commit
dd98161894
No known key found for this signature in database GPG Key ID: EFAD3442BF29E3AC
5 changed files with 12 additions and 5 deletions
  1. +1
    -1
      internal/consensus/byzantine_test.go
  2. +1
    -1
      internal/consensus/state.go
  3. +4
    -3
      internal/state/execution.go
  4. +3
    -0
      node/node_test.go
  5. +3
    -0
      types/vote_set.go

+ 1
- 1
internal/consensus/byzantine_test.go View File

@ -201,7 +201,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
proposerAddr := lazyNodeState.privValidatorPubKey.Address() proposerAddr := lazyNodeState.privValidatorPubKey.Address()
block, err := lazyNodeState.blockExec.CreateProposalBlock( block, err := lazyNodeState.blockExec.CreateProposalBlock(
ctx, lazyNodeState.Height, lazyNodeState.state, commit, proposerAddr)
ctx, lazyNodeState.Height, lazyNodeState.state, commit, proposerAddr, nil)
require.NoError(t, err) require.NoError(t, err)
blockParts, err := block.MakePartSet(types.BlockPartSizeBytes) blockParts, err := block.MakePartSet(types.BlockPartSizeBytes)
require.NoError(t, err) require.NoError(t, err)


+ 1
- 1
internal/consensus/state.go View File

@ -1391,7 +1391,7 @@ func (cs *State) createProposalBlock(ctx context.Context) (block *types.Block, e
proposerAddr := cs.privValidatorPubKey.Address() proposerAddr := cs.privValidatorPubKey.Address()
return cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, commit, proposerAddr)
return cs.blockExec.CreateProposalBlock(ctx, cs.Height, cs.state, commit, proposerAddr, cs.LastCommit.GetVotes())
} }
// Enter: `timeoutPropose` after entering Propose. // Enter: `timeoutPropose` after entering Propose.


+ 4
- 3
internal/state/execution.go View File

@ -103,6 +103,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
state State, state State,
commit *types.Commit, commit *types.Commit,
proposerAddr []byte, proposerAddr []byte,
votes []*types.Vote,
) (*types.Block, error) { ) (*types.Block, error) {
maxBytes := state.ConsensusParams.Block.MaxBytes maxBytes := state.ConsensusParams.Block.MaxBytes
@ -123,7 +124,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
Hash: block.Hash(), Hash: block.Hash(),
Header: *block.Header.ToProto(), Header: *block.Header.ToProto(),
Txs: block.Txs.ToSliceOfBytes(), Txs: block.Txs.ToSliceOfBytes(),
LocalLastCommit: extendedCommitInfo(localLastCommit),
LocalLastCommit: extendedCommitInfo(localLastCommit, votes),
ByzantineValidators: block.Evidence.ToABCI(), ByzantineValidators: block.Evidence.ToABCI(),
MaxTxBytes: maxDataBytes, MaxTxBytes: maxDataBytes,
}, },
@ -428,14 +429,14 @@ func buildLastCommitInfo(block *types.Block, store Store, initialHeight int64) a
} }
} }
func extendedCommitInfo(c abci.CommitInfo) abci.ExtendedCommitInfo {
func extendedCommitInfo(c abci.CommitInfo, votes []*types.Vote) abci.ExtendedCommitInfo {
vs := make([]abci.ExtendedVoteInfo, len(c.Votes)) vs := make([]abci.ExtendedVoteInfo, len(c.Votes))
for i := range vs { for i := range vs {
vs[i] = abci.ExtendedVoteInfo{ vs[i] = abci.ExtendedVoteInfo{
Validator: c.Votes[i].Validator, Validator: c.Votes[i].Validator,
SignedLastBlock: c.Votes[i].SignedLastBlock, SignedLastBlock: c.Votes[i].SignedLastBlock,
/* /*
TODO: Include vote extensions information when implementing vote extension is complete.
TODO: Include vote extensions information when implementing vote extensions.
VoteExtension: []byte{}, VoteExtension: []byte{},
*/ */
} }


+ 3
- 0
node/node_test.go View File

@ -341,6 +341,7 @@ func TestCreateProposalBlock(t *testing.T) {
height, height,
state, commit, state, commit,
proposerAddr, proposerAddr,
nil,
) )
require.NoError(t, err) require.NoError(t, err)
@ -419,6 +420,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) {
height, height,
state, commit, state, commit,
proposerAddr, proposerAddr,
nil,
) )
require.NoError(t, err) require.NoError(t, err)
@ -533,6 +535,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
math.MaxInt64, math.MaxInt64,
state, commit, state, commit,
proposerAddr, proposerAddr,
nil,
) )
require.NoError(t, err) require.NoError(t, err)
partSet, err := block.MakePartSet(types.BlockPartSizeBytes) partSet, err := block.MakePartSet(types.BlockPartSizeBytes)


+ 3
- 0
types/vote_set.go View File

@ -227,6 +227,9 @@ func (voteSet *VoteSet) getVote(valIndex int32, blockKey string) (vote *Vote, ok
} }
func (voteSet *VoteSet) GetVotes() []*Vote { func (voteSet *VoteSet) GetVotes() []*Vote {
if voteSet == nil {
return nil
}
return voteSet.votes return voteSet.votes
} }


Loading…
Cancel
Save