Skip to content

Commit

Permalink
Fix justification voters log
Browse files Browse the repository at this point in the history
  • Loading branch information
dimartiro committed Nov 10, 2024
1 parent 90472f2 commit e1990f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dot/sync/block_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (b *blockImporter) processBlockData(blockData types.BlockData, origin Block
round, setID, err = b.finalityGadget.VerifyBlockJustification(
blockData.Header.Hash(), blockData.Header.Number, *blockData.Justification)
if err != nil {
return fmt.Errorf("verifying justification for block %s justification %v: %w", blockData.Header.Hash().String(), *&blockData.Justification, err)
return fmt.Errorf("verifying justification for block %s: %w", blockData.Header.Hash().String(), err)
}
}

Expand Down
9 changes: 7 additions & 2 deletions internal/client/consensus/grandpa/justification.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import (
"io"
"reflect"

"github.com/ChainSafe/gossamer/internal/log"
primitives "github.com/ChainSafe/gossamer/internal/primitives/consensus/grandpa"
"github.com/ChainSafe/gossamer/internal/primitives/runtime"
"github.com/ChainSafe/gossamer/internal/primitives/runtime/generic"
grandpa "github.com/ChainSafe/gossamer/pkg/finality-grandpa"
"github.com/ChainSafe/gossamer/pkg/scale"
)

var logger = log.NewFromGlobal(log.AddContext("pkg", "grandpa"))

var (
errInvalidAuthoritiesSet = errors.New("current state of blockchain has invalid authorities set")
errBadJustification = errors.New("bad justification for header")
Expand Down Expand Up @@ -160,12 +163,14 @@ func (j *GrandpaJustification[Hash, N]) verifyWithVoterSet(
ancestryChain,
)
if err != nil {
fmt.Printf("setId: %d voters %v \n", setID, voters)
return fmt.Errorf("%w: invalid commit in grandpa justification: %s", errBadJustification, err)
}

if !commitValidationResult.Valid() {
fmt.Printf("setId: %d voters %v \n", setID, voters)
for _, voter := range voters.Iter() {
pk := []byte(voter.ID)
logger.Infof("Voter pk: %v, info: %v", pk, voter.VoterInfo)
}
return fmt.Errorf("%w: invalid commit in grandpa justification", errBadJustification)
}

Expand Down

0 comments on commit e1990f2

Please sign in to comment.