Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable new reactor in the e2e test #1657

Open
wants to merge 15 commits into
base: feature/recovery
Choose a base branch
from
Prev Previous commit
Next Next commit
fix: catchup for now still need proofs
evan-forbes committed Mar 17, 2025

Verified

This commit was signed with the committer’s verified signature.
evan-forbes Evan Forbes
commit 56e66d3dde686e941d414561deade15f20f57c5d
1 change: 1 addition & 0 deletions consensus/propagation/catchup.go
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ func (blockProp *Reactor) retryWants(currentHeight int64, currentRound int32) {
continue
}

// only re-request original parts that are missing, not parity parts.
missing := prop.block.BitArray().Not()
if missing.IsEmpty() {
// this should never be hit due to the check above.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe log something here since it's never supposed to happen

3 changes: 3 additions & 0 deletions consensus/propagation/commitment.go
Original file line number Diff line number Diff line change
@@ -136,6 +136,9 @@ func (blockProp *Reactor) handleCompactBlock(cb *proptypes.CompactBlock, peer p2
return
}

// run the catchup routine to recover any missing parts for past heights.
blockProp.retryWants(cb.Proposal.Height, cb.Proposal.Round)

blockProp.broadcastCompactBlock(cb, peer)

// check if we have any transactions that are in the compact block
18 changes: 17 additions & 1 deletion consensus/propagation/have_wants.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package propagation

import (
proptypes "github.com/tendermint/tendermint/consensus/propagation/types"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/pkg/trace/schema"
propproto "github.com/tendermint/tendermint/proto/tendermint/propagation"
@@ -259,9 +260,24 @@ func (blockProp *Reactor) handleRecoveryPart(peer p2p.ID, part *proptypes.Recove
return
}

// todo: add these defensive checks in a better way
if cb == nil {
return
}
if parts == nil {
return
}

// todo: we need to figure out a way to get the proof for a part that was
// sent during catchup.
proof := cb.GetProof(part.Index)
if proof == nil {
proof = &merkle.Proof{}
}

// TODO: to verify, compare the hash with that of the have that was sent for
// this part and verified.
added, err := parts.AddPart(part, *cb.GetProof(part.Index))
added, err := parts.AddPart(part, *proof)
if err != nil {
blockProp.Logger.Error("failed to add part to part set", "peer", peer, "height", part.Height, "round", part.Round, "part", part.Index, "error", err)
return
9 changes: 4 additions & 5 deletions consensus/propagation/types/combined_partset.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package types

import (
"bytes"
"fmt"
"sync"

"github.com/tendermint/tendermint/crypto/merkle"
@@ -107,9 +105,10 @@ func (cps *CombinedPartSet) Decode() error {
// AddPart adds a part to the combined part set. It assumes that the parts being
// added have already been verified.
func (cps *CombinedPartSet) AddPart(part *RecoveryPart, proof merkle.Proof) (bool, error) {
if !bytes.Equal(merkle.LeafHash(part.Data), proof.LeafHash) {
return false, fmt.Errorf("part data does not match proof: part index %d leaf hash %v", part.Index, proof.LeafHash)
}
// Todo: figure out a way to send the proof during catchup
// if !bytes.Equal(merkle.LeafHash(part.Data), proof.LeafHash) {
// return false, fmt.Errorf("part data does not match proof: part index %d leaf hash %v", part.Index, proof.LeafHash)
// }

p := &types.Part{
Index: part.Index,
Loading