Skip to content

Commit

Permalink
Log info about mismatched valset (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
cffls authored Sep 6, 2024
1 parent 94ead5e commit 44d0938
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head
}

if isSprintEnd && signersBytes%validatorHeaderBytesLength != 0 {
log.Warn("Invalid validator set", "number", number, "signersBytes", signersBytes)
return errInvalidSpanValidators
}

Expand Down Expand Up @@ -478,11 +479,13 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t
}

if len(newValidators) != len(headerVals) {
log.Warn("Invalid validator set", "block number", number, "newValidators", newValidators, "headerVals", headerVals)
return errInvalidSpanValidators
}

for i, val := range newValidators {
if !bytes.Equal(val.HeaderBytes(), headerVals[i].HeaderBytes()) {
log.Warn("Invalid validator set", "block number", number, "index", i, "local validator", val, "header validator", headerVals[i])
return errInvalidSpanValidators
}
}
Expand Down Expand Up @@ -1416,6 +1419,11 @@ func getUpdatedValidatorSet(oldValidatorSet *valset.ValidatorSet, newVals []*val
}

if err := v.UpdateWithChangeSet(changes); err != nil {
changesStr := ""
for _, change := range changes {
changesStr += fmt.Sprintf("Address: %s, VotingPower: %d\n", change.Address, change.VotingPower)
}
log.Warn("Changes in validator set", "changes", changesStr)
log.Error("Error while updating change set", "error", err)
}

Expand Down

0 comments on commit 44d0938

Please sign in to comment.