diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 447c60400..2d24ca35c 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -83,3 +83,4 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi ### BUG FIXES: - [consensus] [\#4895](https://github.com/tendermint/tendermint/pull/4895) Cache the address of the validator to reduce querying a remote KMS (@joe-bowman) +- [blockchain/v2] Correctly set block store base in status responses (@erikgrinaker) diff --git a/blockchain/v2/io.go b/blockchain/v2/io.go index 70240aed6..54e8c1518 100644 --- a/blockchain/v2/io.go +++ b/blockchain/v2/io.go @@ -12,7 +12,7 @@ type iIO interface { sendBlockRequest(peerID p2p.ID, height int64) error sendBlockToPeer(block *types.Block, peerID p2p.ID) error sendBlockNotFound(height int64, peerID p2p.ID) error - sendStatusResponse(height int64, peerID p2p.ID) error + sendStatusResponse(base int64, height int64, peerID p2p.ID) error broadcastStatusRequest(base int64, height int64) @@ -54,12 +54,12 @@ func (sio *switchIO) sendBlockRequest(peerID p2p.ID, height int64) error { return nil } -func (sio *switchIO) sendStatusResponse(height int64, peerID p2p.ID) error { +func (sio *switchIO) sendStatusResponse(base int64, height int64, peerID p2p.ID) error { peer := sio.sw.Peers().Get(peerID) if peer == nil { return fmt.Errorf("peer not found") } - msgBytes := cdc.MustMarshalBinaryBare(&bcStatusResponseMessage{Height: height}) + msgBytes := cdc.MustMarshalBinaryBare(&bcStatusResponseMessage{Base: base, Height: height}) if queued := peer.TrySend(BlockchainChannel, msgBytes); !queued { return fmt.Errorf("peer queue full") diff --git a/blockchain/v2/reactor.go b/blockchain/v2/reactor.go index 98ea58306..8a7019b55 100644 --- a/blockchain/v2/reactor.go +++ b/blockchain/v2/reactor.go @@ -561,7 +561,7 @@ func (r *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { switch msg := msg.(type) { case *bcStatusRequestMessage: - if err := r.io.sendStatusResponse(r.store.Height(), src.ID()); err != nil { + if err := r.io.sendStatusResponse(r.store.Base(), r.store.Height(), src.ID()); err != nil { r.logger.Error("Could not send status message to peer", "src", src) } @@ -609,7 +609,7 @@ func (r *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { // AddPeer implements Reactor interface func (r *BlockchainReactor) AddPeer(peer p2p.Peer) { - err := r.io.sendStatusResponse(r.store.Height(), peer.ID()) + err := r.io.sendStatusResponse(r.store.Base(), r.store.Height(), peer.ID()) if err != nil { r.logger.Error("Could not send status message to peer new", "src", peer.ID, "height", r.SyncHeight()) } diff --git a/blockchain/v2/reactor_test.go b/blockchain/v2/reactor_test.go index b1dc21f49..ef6cb20f9 100644 --- a/blockchain/v2/reactor_test.go +++ b/blockchain/v2/reactor_test.go @@ -96,7 +96,7 @@ func (sio *mockSwitchIo) sendBlockRequest(peerID p2p.ID, height int64) error { return nil } -func (sio *mockSwitchIo) sendStatusResponse(height int64, peerID p2p.ID) error { +func (sio *mockSwitchIo) sendStatusResponse(base int64, height int64, peerID p2p.ID) error { sio.mtx.Lock() defer sio.mtx.Unlock() sio.numStatusResponse++