diff --git a/internal/blocksync/pool_test.go b/internal/blocksync/pool_test.go index fed86e520..3c47b4a64 100644 --- a/internal/blocksync/pool_test.go +++ b/internal/blocksync/pool_test.go @@ -43,9 +43,9 @@ func (p testPeer) runInputRoutine() { // Request desired, pretend like we got the block immediately. func (p testPeer) simulateInput(input inputData) { block := &types.Block{Header: types.Header{Height: input.request.Height}} - var blockID types.BlockID - var extCommitSigs []types.ExtendedCommitSig - extCommit := types.NewExtendedCommit(input.request.Height, 0, blockID, extCommitSigs) + extCommit := &types.ExtendedCommit{ + Height: input.request.Height, + } _ = input.pool.AddBlock(input.request.PeerID, block, extCommit, 123) // TODO: uncommenting this creates a race which is detected by: // https://github.com/golang/go/blob/2bd767b1022dd3254bcec469f0ee164024726486/src/testing/testing.go#L854-L856 diff --git a/internal/blocksync/reactor_test.go b/internal/blocksync/reactor_test.go index c22558096..c8a8c79b8 100644 --- a/internal/blocksync/reactor_test.go +++ b/internal/blocksync/reactor_test.go @@ -150,7 +150,7 @@ func (rts *reactorTestSuite) addNode( var lastExtCommit *types.ExtendedCommit // The commit we are building for the current height. - seenExtCommit := types.NewExtendedCommit(0, 0, types.BlockID{}, nil) + seenExtCommit := &types.ExtendedCommit{} for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ { lastExtCommit = seenExtCommit.Copy() @@ -173,12 +173,12 @@ func (rts *reactorTestSuite) addNode( time.Now(), ) require.NoError(t, err) - seenExtCommit = types.NewExtendedCommit( - vote.Height, - vote.Round, - blockID, - []types.ExtendedCommitSig{vote.ExtendedCommitSig()}, - ) + seenExtCommit = &types.ExtendedCommit{ + Height: vote.Height, + Round: vote.Round, + BlockID: blockID, + ExtendedSignatures: []types.ExtendedCommitSig{vote.ExtendedCommitSig()}, + } state, err = blockExec.ApplyBlock(ctx, state, blockID, thisBlock) require.NoError(t, err) diff --git a/internal/consensus/byzantine_test.go b/internal/consensus/byzantine_test.go index 5a75d3fb2..a66d0e51a 100644 --- a/internal/consensus/byzantine_test.go +++ b/internal/consensus/byzantine_test.go @@ -183,7 +183,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { case lazyNodeState.Height == lazyNodeState.state.InitialHeight: // We're creating a proposal for the first block. // The commit is empty, but not nil. - commit = types.NewExtendedCommit(0, 0, types.BlockID{}, nil) + commit = &types.ExtendedCommit{} case lazyNodeState.LastCommit.HasTwoThirdsMajority(): // Make the commit from LastCommit commit = lazyNodeState.LastCommit.MakeExtendedCommit() diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go index e31ffe250..c8f04655b 100644 --- a/internal/consensus/replay_test.go +++ b/internal/consensus/replay_test.go @@ -1097,8 +1097,12 @@ func makeBlockchainFromWAL(t *testing.T, wal WAL) ([]*types.Block, []*types.Exte require.NoError(t, err) case *types.Vote: if p.Type == tmproto.PrecommitType { - thisBlockExtCommit = types.NewExtendedCommit(p.Height, p.Round, - p.BlockID, []types.ExtendedCommitSig{p.ExtendedCommitSig()}) + thisBlockExtCommit = &types.ExtendedCommit{ + Height: p.Height, + Round: p.Round, + BlockID: p.BlockID, + ExtendedSignatures: []types.ExtendedCommitSig{p.ExtendedCommitSig()}, + } } } } diff --git a/internal/consensus/state.go b/internal/consensus/state.go index bdeab411f..4e9469209 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -1402,7 +1402,7 @@ func (cs *State) createProposalBlock(ctx context.Context) (*types.Block, error) case cs.Height == cs.state.InitialHeight: // We're creating a proposal for the first block. // The commit is empty, but not nil. - extCommit = types.NewExtendedCommit(0, 0, types.BlockID{}, nil) + extCommit = &types.ExtendedCommit{} case cs.LastCommit.HasTwoThirdsMajority(): // Make the commit from LastCommit diff --git a/internal/evidence/pool_test.go b/internal/evidence/pool_test.go index 8cbbb613d..df92d0468 100644 --- a/internal/evidence/pool_test.go +++ b/internal/evidence/pool_test.go @@ -587,12 +587,16 @@ func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) (*store.Blo } func makeExtCommit(height int64, valAddr []byte) *types.ExtendedCommit { - return types.NewExtendedCommit(height, 0, types.BlockID{}, []types.ExtendedCommitSig{{ - BlockIDFlag: types.BlockIDFlagCommit, - ValidatorAddress: valAddr, - Timestamp: defaultEvidenceTime, - Signature: []byte("Signature"), - }}) + return &types.ExtendedCommit{ + Height: height, + BlockID: types.BlockID{}, + ExtendedSignatures: []types.ExtendedCommitSig{{ + BlockIDFlag: types.BlockIDFlagCommit, + ValidatorAddress: valAddr, + Timestamp: defaultEvidenceTime, + Signature: []byte("Signature"), + }}, + } } func defaultTestPool(ctx context.Context, t *testing.T, height int64) (*evidence.Pool, types.MockPV, *eventbus.EventBus) { diff --git a/internal/state/helpers_test.go b/internal/state/helpers_test.go index 464df86d4..dec5afc66 100644 --- a/internal/state/helpers_test.go +++ b/internal/state/helpers_test.go @@ -94,7 +94,11 @@ func makeValidCommit( votes[i] = vote } - return types.NewExtendedCommit(height, 0, blockID, sigs), votes + return &types.ExtendedCommit{ + Height: height, + BlockID: blockID, + ExtendedSignatures: sigs, + }, votes } func makeState(t *testing.T, nVals, height int) (sm.State, dbm.DB, map[string]types.PrivValidator) { diff --git a/internal/store/store_test.go b/internal/store/store_test.go index f30a70e91..7ea88e980 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -35,15 +35,14 @@ func makeTestExtCommit(height int64, timestamp time.Time) *types.ExtendedCommit Timestamp: timestamp, Signature: []byte("Signature"), }} - return types.NewExtendedCommit( - height, - 0, - types.BlockID{ + return &types.ExtendedCommit{ + Height: height, + BlockID: types.BlockID{ Hash: crypto.CRandBytes(32), PartSetHeader: types.PartSetHeader{Hash: crypto.CRandBytes(32), Total: 2}, }, - extCommitSigs, - ) + ExtendedSignatures: extCommitSigs, + } } func makeStateAndBlockStore(dir string) (sm.State, *BlockStore, cleanupFunc, error) { diff --git a/node/node_test.go b/node/node_test.go index b563331b6..9cdd3a19c 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -339,7 +339,7 @@ func TestCreateProposalBlock(t *testing.T) { sm.NopMetrics(), ) - extCommit := types.NewExtendedCommit(height-1, 0, types.BlockID{}, nil) + extCommit := &types.ExtendedCommit{Height: height - 1} block, err := blockExec.CreateProposalBlock( ctx, height, @@ -419,7 +419,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) { sm.NopMetrics(), ) - extCommit := types.NewExtendedCommit(height-1, 0, types.BlockID{}, nil) + extCommit := &types.ExtendedCommit{Height: height - 1} block, err := blockExec.CreateProposalBlock( ctx, height, diff --git a/types/block.go b/types/block.go index 13b99c643..19c23e64f 100644 --- a/types/block.go +++ b/types/block.go @@ -1083,16 +1083,6 @@ type ExtendedCommit struct { bitArray *bits.BitArray } -// NewExtendedCommit constructs an ExtendedCommit from the given parameters. -func NewExtendedCommit(height int64, round int32, blockID BlockID, extCommitSigs []ExtendedCommitSig) *ExtendedCommit { - return &ExtendedCommit{ - Height: height, - Round: round, - BlockID: blockID, - ExtendedSignatures: extCommitSigs, - } -} - // Copy creates a copy of this extended commit. func (extCommit *ExtendedCommit) Copy() *ExtendedCommit { ec := *extCommit diff --git a/types/vote_set.go b/types/vote_set.go index 3e9e53b59..f83c1bce1 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -635,7 +635,12 @@ func (voteSet *VoteSet) MakeExtendedCommit() *ExtendedCommit { extCommitSigs[i] = extCommitSig } - return NewExtendedCommit(voteSet.GetHeight(), voteSet.GetRound(), *voteSet.maj23, extCommitSigs) + return &ExtendedCommit{ + Height: voteSet.GetHeight(), + Round: voteSet.GetRound(), + BlockID: *voteSet.maj23, + ExtendedSignatures: extCommitSigs, + } } //--------------------------------------------------------------------------------