From a8adf6328734983af57bcb5dc37ecfc3fe4ca25e Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Wed, 4 May 2022 13:45:08 -0400 Subject: [PATCH] blocksync: Expand on extended commit requirement in AddBlock description Signed-off-by: Thane Thomson --- internal/blocksync/pool.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/blocksync/pool.go b/internal/blocksync/pool.go index bcbe142c5..30bb6962e 100644 --- a/internal/blocksync/pool.go +++ b/internal/blocksync/pool.go @@ -267,7 +267,14 @@ func (pool *BlockPool) RedoRequest(height int64) types.NodeID { return peerID } -// AddBlock validates that the block comes from the peer it was expected from and calls the requester to store it. +// AddBlock validates that the block comes from the peer it was expected from +// and calls the requester to store it. +// +// This requires an extended commit at the same height as the supplied block - +// the block contains the last commit, but we need the latest commit in case we +// need to switch over from block sync to consensus at this height. If the +// height of the extended commit and the height of the block do not match, we +// do not add the block and return an error. // TODO: ensure that blocks come in order for each peer. func (pool *BlockPool) AddBlock(peerID types.NodeID, block *types.Block, extCommit *types.ExtendedCommit, blockSize int) error { pool.mtx.Lock()