Skip to content

Commit 06b1812

Browse files
thanethomsonsergio-menaM. J. Fromberger
authored
abci++: Propagate vote extensions (RFC 017) (tendermint#8433)
* Add protos for ExtendedCommit Cherry-pick from e73f017 just the changes to the .proto files, since we have deleted the .intermediate files. Signed-off-by: Thane Thomson <[email protected]> * make proto-gen Signed-off-by: Thane Thomson <[email protected]> * BlockStore holds extended commit Cherry-pick 8d504d4 and fix conflicts. Signed-off-by: Thane Thomson <[email protected]> * Reshuffle ExtendedCommit and ExtendedCommitSig Separate the data structures and functions from their Commit-oriented counterparts to adhere to the current coding style. Signed-off-by: Thane Thomson <[email protected]> * Fix exit condition in blocksync * Add note to remove TxResult proto As Sergio pointed out in 3e31aa6, this proto message can probably be removed. We should do this in a separate PR. Signed-off-by: Thane Thomson <[email protected]> * Lift termination condition into for loop Signed-off-by: Thane Thomson <[email protected]> * Enforce vote extension signature requirement Signed-off-by: Thane Thomson <[email protected]> * Expand on comment for PeekTwoBlocks for posterity Signed-off-by: Thane Thomson <[email protected]> * Isolate TODO more clearly Signed-off-by: Thane Thomson <[email protected]> * make mockery Signed-off-by: Thane Thomson <[email protected]> * Fix comment Signed-off-by: Thane Thomson <[email protected]> * Make panic output from BlockStore.SaveBlock more readable Signed-off-by: Thane Thomson <[email protected]> * Add helper methods to ExtendedCommitSig and ExtendedCommit Signed-off-by: Thane Thomson <[email protected]> * Fix most tests except TestHandshake* Signed-off-by: Thane Thomson <[email protected]> * Fix store prefix collision Signed-off-by: Thane Thomson <[email protected]> * Fix TestBlockFetchAtHeight Signed-off-by: Thane Thomson <[email protected]> * Remove global state from store tests Signed-off-by: Thane Thomson <[email protected]> * Apply suggestions from code review Co-authored-by: M. J. Fromberger <[email protected]> Co-authored-by: Sergio Mena <[email protected]> * blocksync: Just return error Signed-off-by: Thane Thomson <[email protected]> * make format Signed-off-by: Thane Thomson <[email protected]> * types: Remove unused/commented-out code Signed-off-by: Thane Thomson <[email protected]> * blocksync: Change pool AddBlock function signature to return errors Signed-off-by: Thane Thomson <[email protected]> * types: Improve legibility of switch statements Signed-off-by: Thane Thomson <[email protected]> * blocksync: Expand on extended commit requirement in AddBlock description Signed-off-by: Thane Thomson <[email protected]> * blocksync: Return error without also logging it Signed-off-by: Thane Thomson <[email protected]> * consensus: Rename short-lived local variable Signed-off-by: Thane Thomson <[email protected]> * consensus: Allocate TODO to Sergio Signed-off-by: Thane Thomson <[email protected]> * evidence/pool_test: Inline slice construction Signed-off-by: Thane Thomson <[email protected]> * state: Rename LoadBlockExtCommit to LoadBlockExtendedCommit Signed-off-by: Thane Thomson <[email protected]> * proto: Remove TODO on TxResult Signed-off-by: Thane Thomson <[email protected]> * types: Minor format Signed-off-by: Thane Thomson <[email protected]> * types: Reformat ExtendedCommitSig.BlockID Signed-off-by: Thane Thomson <[email protected]> * types: Remove NewExtendedCommit constructor Signed-off-by: Thane Thomson <[email protected]> * types: Remove NewCommit constructor Signed-off-by: Thane Thomson <[email protected]> * types: Shorten receiver names for ExtendedCommit Signed-off-by: Thane Thomson <[email protected]> * types: Convert ExtendedCommit.Copy to a deep clone Signed-off-by: Thane Thomson <[email protected]> * types: Assign TODO to Sergio Signed-off-by: Thane Thomson <[email protected]> * types: Fix legibility nits Signed-off-by: Thane Thomson <[email protected]> * types: Improve legibility Signed-off-by: Thane Thomson <[email protected]> * store/state: Add TODO to move prefixes to common package Signed-off-by: Thane Thomson <[email protected]> * Propagate validator info to PrepareProposal In order to propagate validator voting power through to PrepareProposal, we need to load the validator set info from the height corresponding to the extended commit that we're passing through to PrepareProposal as the "LocalLastCommit". Signed-off-by: Thane Thomson <[email protected]> * Rename local var for clarity Signed-off-by: Thane Thomson <[email protected]> * Fix TestMaxProposalBlockSize Signed-off-by: Thane Thomson <[email protected]> * Rename local var for clarity Signed-off-by: Thane Thomson <[email protected]> * Remove debug log Signed-off-by: Thane Thomson <[email protected]> * Remove CommigSig.ForBlock helper Signed-off-by: Thane Thomson <[email protected]> * Remove CommigSig.Absent helper Signed-off-by: Thane Thomson <[email protected]> * Remove ExtendedCommitSig.ForBlock helper Signed-off-by: Thane Thomson <[email protected]> * Remove ExtendedCommitSig.Absent helper Signed-off-by: Thane Thomson <[email protected]> * There are no extended commits below the initial height Signed-off-by: Thane Thomson <[email protected]> * Fix comment grammar Signed-off-by: Thane Thomson <[email protected]> * Remove JSON encoding from ExtendedCommit Signed-off-by: Thane Thomson <[email protected]> * Embed CommitSig into ExtendedCommitSig instead of duplicating fields Signed-off-by: Thane Thomson <[email protected]> * Rename ExtendedCommit vote_extension field to extension for consistency with domain types Signed-off-by: Thane Thomson <[email protected]> * blocksync: Panic if we peek a block without an extended commit Signed-off-by: Thane Thomson <[email protected]> * Apply suggestions from code review Co-authored-by: M. J. Fromberger <[email protected]> * Remove Sergio from TODO Signed-off-by: Thane Thomson <[email protected]> * Increase hard-coded vote extension max size to 1MB Signed-off-by: Thane Thomson <[email protected]> * state: Remove unnecessary comment Signed-off-by: Thane Thomson <[email protected]> * state: Ensure no of commit sigs equals validator set length Signed-off-by: Thane Thomson <[email protected]> * make format Signed-off-by: Thane Thomson <[email protected]> * types: Minor legibility improvements Signed-off-by: Thane Thomson <[email protected]> * Improve legibility Signed-off-by: Thane Thomson <[email protected]> * types: Remove unused GetVotes function on VoteSet Signed-off-by: Thane Thomson <[email protected]> * Refactor TestMaxProposalBlockSize to construct more realistic extended commit Signed-off-by: Thane Thomson <[email protected]> * Refactor buildExtendedCommitInfo to resemble buildLastCommitInfo Signed-off-by: Thane Thomson <[email protected]> * Apply suggestions from code review Co-authored-by: M. J. Fromberger <[email protected]> * abci++: Disable VerifyVoteExtension call on nil precommits (tendermint#8491) Signed-off-by: Thane Thomson <[email protected]> * types: Require vote extensions on non-nil precommits and not otherwise Signed-off-by: Thane Thomson <[email protected]> * Disable lint Signed-off-by: Thane Thomson <[email protected]> * Increase timeout for TestReactorVotingPowerChange to counter flakiness Signed-off-by: Thane Thomson <[email protected]> * Only sign and verify vote extensions in non-nil precommits Signed-off-by: Thane Thomson <[email protected]> * Revert "Disable lint" This reverts commit 6fffbf9. Signed-off-by: Thane Thomson <[email protected]> * Add missing non-nil check uncovered non-deterministically in TestHandshakeReplayAll Signed-off-by: Thane Thomson <[email protected]> * Expand error message for accuracy Signed-off-by: Thane Thomson <[email protected]> * Only call ExtendVote when we make non-nil precommits Signed-off-by: Thane Thomson <[email protected]> * Revert "Increase timeout for TestReactorVotingPowerChange to counter flakiness" This reverts commit af51493. Signed-off-by: Thane Thomson <[email protected]> * Refactor ValidateBasic for ExtendedCommitSig for legibility Signed-off-by: Thane Thomson <[email protected]> Co-authored-by: Sergio Mena <[email protected]> Co-authored-by: M. J. Fromberger <[email protected]>
1 parent 735a1a5 commit 06b1812

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1952
-716
lines changed

internal/blocksync/pool.go

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,20 @@ func (pool *BlockPool) IsCaughtUp() bool {
200200
return pool.height >= (pool.maxPeerHeight - 1)
201201
}
202202

203-
// PeekTwoBlocks returns blocks at pool.height and pool.height+1.
204-
// We need to see the second block's Commit to validate the first block.
205-
// So we peek two blocks at a time.
203+
// PeekTwoBlocks returns blocks at pool.height and pool.height+1. We need to
204+
// see the second block's Commit to validate the first block. So we peek two
205+
// blocks at a time. We return an extended commit, containing vote extensions
206+
// and their associated signatures, as this is critical to consensus in ABCI++
207+
// as we switch from block sync to consensus mode.
208+
//
206209
// The caller will verify the commit.
207-
func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block) {
210+
func (pool *BlockPool) PeekTwoBlocks() (first, second *types.Block, firstExtCommit *types.ExtendedCommit) {
208211
pool.mtx.RLock()
209212
defer pool.mtx.RUnlock()
210213

211214
if r := pool.requesters[pool.height]; r != nil {
212215
first = r.getBlock()
216+
firstExtCommit = r.getExtendedCommit()
213217
}
214218
if r := pool.requesters[pool.height+1]; r != nil {
215219
second = r.getBlock()
@@ -218,7 +222,8 @@ func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block)
218222
}
219223

220224
// PopRequest pops the first block at pool.height.
221-
// It must have been validated by 'second'.Commit from PeekTwoBlocks().
225+
// It must have been validated by the second Commit from PeekTwoBlocks.
226+
// TODO(thane): (?) and its corresponding ExtendedCommit.
222227
func (pool *BlockPool) PopRequest() {
223228
pool.mtx.Lock()
224229
defer pool.mtx.Unlock()
@@ -262,37 +267,48 @@ func (pool *BlockPool) RedoRequest(height int64) types.NodeID {
262267
return peerID
263268
}
264269

265-
// AddBlock validates that the block comes from the peer it was expected from and calls the requester to store it.
270+
// AddBlock validates that the block comes from the peer it was expected from
271+
// and calls the requester to store it.
272+
//
273+
// This requires an extended commit at the same height as the supplied block -
274+
// the block contains the last commit, but we need the latest commit in case we
275+
// need to switch over from block sync to consensus at this height. If the
276+
// height of the extended commit and the height of the block do not match, we
277+
// do not add the block and return an error.
266278
// TODO: ensure that blocks come in order for each peer.
267-
func (pool *BlockPool) AddBlock(peerID types.NodeID, block *types.Block, blockSize int) {
279+
func (pool *BlockPool) AddBlock(peerID types.NodeID, block *types.Block, extCommit *types.ExtendedCommit, blockSize int) error {
268280
pool.mtx.Lock()
269281
defer pool.mtx.Unlock()
270282

283+
if block.Height != extCommit.Height {
284+
return fmt.Errorf("heights don't match, not adding block (block height: %d, commit height: %d)", block.Height, extCommit.Height)
285+
}
286+
271287
requester := pool.requesters[block.Height]
272288
if requester == nil {
273-
pool.logger.Error("peer sent us a block we didn't expect",
274-
"peer", peerID, "curHeight", pool.height, "blockHeight", block.Height)
275289
diff := pool.height - block.Height
276290
if diff < 0 {
277291
diff *= -1
278292
}
279293
if diff > maxDiffBetweenCurrentAndReceivedBlockHeight {
280294
pool.sendError(errors.New("peer sent us a block we didn't expect with a height too far ahead/behind"), peerID)
281295
}
282-
return
296+
return fmt.Errorf("peer sent us a block we didn't expect (peer: %s, current height: %d, block height: %d)", peerID, pool.height, block.Height)
283297
}
284298

285-
if requester.setBlock(block, peerID) {
299+
if requester.setBlock(block, extCommit, peerID) {
286300
atomic.AddInt32(&pool.numPending, -1)
287301
peer := pool.peers[peerID]
288302
if peer != nil {
289303
peer.decrPending(blockSize)
290304
}
291305
} else {
292306
err := errors.New("requester is different or block already exists")
293-
pool.logger.Error(err.Error(), "peer", peerID, "requester", requester.getPeerID(), "blockHeight", block.Height)
294307
pool.sendError(err, peerID)
308+
return fmt.Errorf("%w (peer: %s, requester: %s, block height: %d)", err, peerID, requester.getPeerID(), block.Height)
295309
}
310+
311+
return nil
296312
}
297313

298314
// MaxPeerHeight returns the highest reported height.
@@ -456,6 +472,7 @@ func (pool *BlockPool) debug() string {
456472
} else {
457473
str += fmt.Sprintf("H(%v):", h)
458474
str += fmt.Sprintf("B?(%v) ", pool.requesters[h].block != nil)
475+
str += fmt.Sprintf("C?(%v) ", pool.requesters[h].extCommit != nil)
459476
}
460477
}
461478
return str
@@ -544,9 +561,10 @@ type bpRequester struct {
544561
gotBlockCh chan struct{}
545562
redoCh chan types.NodeID // redo may send multitime, add peerId to identify repeat
546563

547-
mtx sync.Mutex
548-
peerID types.NodeID
549-
block *types.Block
564+
mtx sync.Mutex
565+
peerID types.NodeID
566+
block *types.Block
567+
extCommit *types.ExtendedCommit
550568
}
551569

552570
func newBPRequester(logger log.Logger, pool *BlockPool, height int64) *bpRequester {
@@ -572,13 +590,14 @@ func (bpr *bpRequester) OnStart(ctx context.Context) error {
572590
func (*bpRequester) OnStop() {}
573591

574592
// Returns true if the peer matches and block doesn't already exist.
575-
func (bpr *bpRequester) setBlock(block *types.Block, peerID types.NodeID) bool {
593+
func (bpr *bpRequester) setBlock(block *types.Block, extCommit *types.ExtendedCommit, peerID types.NodeID) bool {
576594
bpr.mtx.Lock()
577595
if bpr.block != nil || bpr.peerID != peerID {
578596
bpr.mtx.Unlock()
579597
return false
580598
}
581599
bpr.block = block
600+
bpr.extCommit = extCommit
582601
bpr.mtx.Unlock()
583602

584603
select {
@@ -594,6 +613,12 @@ func (bpr *bpRequester) getBlock() *types.Block {
594613
return bpr.block
595614
}
596615

616+
func (bpr *bpRequester) getExtendedCommit() *types.ExtendedCommit {
617+
bpr.mtx.Lock()
618+
defer bpr.mtx.Unlock()
619+
return bpr.extCommit
620+
}
621+
597622
func (bpr *bpRequester) getPeerID() types.NodeID {
598623
bpr.mtx.Lock()
599624
defer bpr.mtx.Unlock()
@@ -611,6 +636,7 @@ func (bpr *bpRequester) reset() {
611636

612637
bpr.peerID = ""
613638
bpr.block = nil
639+
bpr.extCommit = nil
614640
}
615641

616642
// Tells bpRequester to pick another peer and try again.

internal/blocksync/pool_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ func (p testPeer) runInputRoutine() {
4343
// Request desired, pretend like we got the block immediately.
4444
func (p testPeer) simulateInput(input inputData) {
4545
block := &types.Block{Header: types.Header{Height: input.request.Height}}
46-
input.pool.AddBlock(input.request.PeerID, block, 123)
46+
extCommit := &types.ExtendedCommit{
47+
Height: input.request.Height,
48+
}
49+
_ = input.pool.AddBlock(input.request.PeerID, block, extCommit, 123)
4750
// TODO: uncommenting this creates a race which is detected by:
4851
// https://github.com/golang/go/blob/2bd767b1022dd3254bcec469f0ee164024726486/src/testing/testing.go#L854-L856
4952
// see: https://github.com/tendermint/tendermint/issues/3390#issue-418379890
@@ -110,7 +113,7 @@ func TestBlockPoolBasic(t *testing.T) {
110113
if !pool.IsRunning() {
111114
return
112115
}
113-
first, second := pool.PeekTwoBlocks()
116+
first, second, _ := pool.PeekTwoBlocks()
114117
if first != nil && second != nil {
115118
pool.PopRequest()
116119
} else {
@@ -164,7 +167,7 @@ func TestBlockPoolTimeout(t *testing.T) {
164167
if !pool.IsRunning() {
165168
return
166169
}
167-
first, second := pool.PeekTwoBlocks()
170+
first, second, _ := pool.PeekTwoBlocks()
168171
if first != nil && second != nil {
169172
pool.PopRequest()
170173
} else {

internal/blocksync/reactor.go

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type Reactor struct {
7676
stateStore sm.Store
7777

7878
blockExec *sm.BlockExecutor
79-
store *store.BlockStore
79+
store sm.BlockStore
8080
pool *BlockPool
8181
consReactor consensusReactor
8282
blockSync *atomicBool
@@ -186,15 +186,21 @@ func (r *Reactor) OnStop() {
186186
func (r *Reactor) respondToPeer(ctx context.Context, msg *bcproto.BlockRequest, peerID types.NodeID, blockSyncCh *p2p.Channel) error {
187187
block := r.store.LoadBlock(msg.Height)
188188
if block != nil {
189+
extCommit := r.store.LoadBlockExtendedCommit(msg.Height)
190+
if extCommit == nil {
191+
return fmt.Errorf("found block in store without extended commit: %v", block)
192+
}
189193
blockProto, err := block.ToProto()
190194
if err != nil {
191-
r.logger.Error("failed to convert msg to protobuf", "err", err)
192-
return err
195+
return fmt.Errorf("failed to convert block to protobuf: %w", err)
193196
}
194197

195198
return blockSyncCh.Send(ctx, p2p.Envelope{
196-
To: peerID,
197-
Message: &bcproto.BlockResponse{Block: blockProto},
199+
To: peerID,
200+
Message: &bcproto.BlockResponse{
201+
Block: blockProto,
202+
ExtCommit: extCommit.ToProto(),
203+
},
198204
})
199205
}
200206

@@ -236,8 +242,17 @@ func (r *Reactor) handleMessage(ctx context.Context, envelope *p2p.Envelope, blo
236242
"err", err)
237243
return err
238244
}
245+
extCommit, err := types.ExtendedCommitFromProto(msg.ExtCommit)
246+
if err != nil {
247+
r.logger.Error("failed to convert extended commit from proto",
248+
"peer", envelope.From,
249+
"err", err)
250+
return err
251+
}
239252

240-
r.pool.AddBlock(envelope.From, block, block.Size())
253+
if err := r.pool.AddBlock(envelope.From, block, extCommit, block.Size()); err != nil {
254+
r.logger.Error("failed to add block", "err", err)
255+
}
241256

242257
case *bcproto.StatusRequest:
243258
return blockSyncCh.Send(ctx, p2p.Envelope{
@@ -448,6 +463,20 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh
448463
)
449464

450465
switch {
466+
// TODO(sergio) Might be needed for implementing the upgrading solution. Remove after that
467+
//case state.LastBlockHeight > 0 && r.store.LoadBlockExtCommit(state.LastBlockHeight) == nil:
468+
case state.LastBlockHeight > 0 && blocksSynced == 0:
469+
// Having state-synced, we need to blocksync at least one block
470+
r.logger.Info(
471+
"no seen commit yet",
472+
"height", height,
473+
"last_block_height", state.LastBlockHeight,
474+
"initial_height", state.InitialHeight,
475+
"max_peer_height", r.pool.MaxPeerHeight(),
476+
"timeout_in", syncTimeout-time.Since(lastAdvance),
477+
)
478+
continue
479+
451480
case r.pool.IsCaughtUp():
452481
r.logger.Info("switching to consensus reactor", "height", height)
453482

@@ -490,9 +519,13 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh
490519
// TODO: Uncouple from request routine.
491520

492521
// see if there are any blocks to sync
493-
first, second := r.pool.PeekTwoBlocks()
494-
if first == nil || second == nil {
495-
// we need both to sync the first block
522+
first, second, extCommit := r.pool.PeekTwoBlocks()
523+
if first == nil || second == nil || extCommit == nil {
524+
if first != nil && extCommit == nil {
525+
// See https://github.com/tendermint/tendermint/pull/8433#discussion_r866790631
526+
panic(fmt.Errorf("peeked first block without extended commit at height %d - possible node store corruption", first.Height))
527+
}
528+
// we need all to sync the first block
496529
continue
497530
} else {
498531
// try again quickly next loop
@@ -517,6 +550,7 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh
517550
// NOTE: We can probably make this more efficient, but note that calling
518551
// first.Hash() doesn't verify the tx contents, so MakePartSet() is
519552
// currently necessary.
553+
// TODO(sergio): Should we also validate against the extended commit?
520554
err = state.Validators.VerifyCommitLight(chainID, firstID, first.Height, second.LastCommit)
521555

522556
if err == nil {
@@ -559,7 +593,7 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh
559593
r.pool.PopRequest()
560594

561595
// TODO: batch saves so we do not persist to disk every block
562-
r.store.SaveBlock(first, firstParts, second.LastCommit)
596+
r.store.SaveBlock(first, firstParts, extCommit)
563597

564598
// TODO: Same thing for app - but we would need a way to get the hash
565599
// without persisting the state.

internal/blocksync/reactor_test.go

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,39 +147,43 @@ func (rts *reactorTestSuite) addNode(
147147
sm.NopMetrics(),
148148
)
149149

150+
var lastExtCommit *types.ExtendedCommit
151+
152+
// The commit we are building for the current height.
153+
seenExtCommit := &types.ExtendedCommit{}
154+
150155
for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ {
151-
lastCommit := types.NewCommit(blockHeight-1, 0, types.BlockID{}, nil)
152-
153-
if blockHeight > 1 {
154-
lastBlockMeta := blockStore.LoadBlockMeta(blockHeight - 1)
155-
lastBlock := blockStore.LoadBlock(blockHeight - 1)
156-
157-
vote, err := factory.MakeVote(
158-
ctx,
159-
privVal,
160-
lastBlock.Header.ChainID, 0,
161-
lastBlock.Header.Height, 0, 2,
162-
lastBlockMeta.BlockID,
163-
time.Now(),
164-
)
165-
require.NoError(t, err)
166-
lastCommit = types.NewCommit(
167-
vote.Height,
168-
vote.Round,
169-
lastBlockMeta.BlockID,
170-
[]types.CommitSig{vote.CommitSig()},
171-
)
172-
}
156+
lastExtCommit = seenExtCommit.Clone()
173157

174-
thisBlock := sf.MakeBlock(state, blockHeight, lastCommit)
158+
thisBlock := sf.MakeBlock(state, blockHeight, lastExtCommit.StripExtensions())
175159
thisParts, err := thisBlock.MakePartSet(types.BlockPartSizeBytes)
176160
require.NoError(t, err)
177161
blockID := types.BlockID{Hash: thisBlock.Hash(), PartSetHeader: thisParts.Header()}
178162

163+
// Simulate a commit for the current height
164+
vote, err := factory.MakeVote(
165+
ctx,
166+
privVal,
167+
thisBlock.Header.ChainID,
168+
0,
169+
thisBlock.Header.Height,
170+
0,
171+
2,
172+
blockID,
173+
time.Now(),
174+
)
175+
require.NoError(t, err)
176+
seenExtCommit = &types.ExtendedCommit{
177+
Height: vote.Height,
178+
Round: vote.Round,
179+
BlockID: blockID,
180+
ExtendedSignatures: []types.ExtendedCommitSig{vote.ExtendedCommitSig()},
181+
}
182+
179183
state, err = blockExec.ApplyBlock(ctx, state, blockID, thisBlock)
180184
require.NoError(t, err)
181185

182-
blockStore.SaveBlock(thisBlock, thisParts, lastCommit)
186+
blockStore.SaveBlock(thisBlock, thisParts, seenExtCommit)
183187
}
184188

185189
rts.peerChans[nodeID] = make(chan p2p.PeerUpdate)

internal/consensus/byzantine_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,22 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
178178
lazyNodeState.decideProposal = func(ctx context.Context, height int64, round int32) {
179179
require.NotNil(t, lazyNodeState.privValidator)
180180

181-
var commit *types.Commit
181+
var extCommit *types.ExtendedCommit
182182
switch {
183183
case lazyNodeState.Height == lazyNodeState.state.InitialHeight:
184184
// We're creating a proposal for the first block.
185185
// The commit is empty, but not nil.
186-
commit = types.NewCommit(0, 0, types.BlockID{}, nil)
186+
extCommit = &types.ExtendedCommit{}
187187
case lazyNodeState.LastCommit.HasTwoThirdsMajority():
188188
// Make the commit from LastCommit
189-
commit = lazyNodeState.LastCommit.MakeCommit()
189+
extCommit = lazyNodeState.LastCommit.MakeExtendedCommit()
190190
default: // This shouldn't happen.
191191
lazyNodeState.logger.Error("enterPropose: Cannot propose anything: No commit for the previous block")
192192
return
193193
}
194194

195195
// omit the last signature in the commit
196-
commit.Signatures[len(commit.Signatures)-1] = types.NewCommitSigAbsent()
196+
extCommit.ExtendedSignatures[len(extCommit.ExtendedSignatures)-1] = types.NewExtendedCommitSigAbsent()
197197

198198
if lazyNodeState.privValidatorPubKey == nil {
199199
// If this node is a validator & proposer in the current round, it will
@@ -204,7 +204,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
204204
proposerAddr := lazyNodeState.privValidatorPubKey.Address()
205205

206206
block, err := lazyNodeState.blockExec.CreateProposalBlock(
207-
ctx, lazyNodeState.Height, lazyNodeState.state, commit, proposerAddr, lazyNodeState.LastCommit.GetVotes())
207+
ctx, lazyNodeState.Height, lazyNodeState.state, extCommit, proposerAddr)
208208
require.NoError(t, err)
209209
blockParts, err := block.MakePartSet(types.BlockPartSizeBytes)
210210
require.NoError(t, err)

0 commit comments

Comments
 (0)