Skip to content

Commit

Permalink
fix in FinalizeAndAssemble
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 committed Dec 9, 2024
1 parent 04b4f16 commit d3a114c
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,76 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ
return nil, consensus.ErrUnexpectedWithdrawals
}

foo := func() {
newValidators, err := c.spanner.GetCurrentValidatorsByHash(context.Background(), header.ParentHash, headerNumber+1)
if err != nil {
log.Error("[debugging] error fetching vals from contract", "err", err)
return
}
sort.Sort(valset.ValidatorsByAddress(newValidators))
headerVals, err := valset.ParseValidators(header.GetValidatorBytes(c.chainConfig))
if err != nil {
log.Error("[debugging] error parsing vals", "err", err)
return
}

if len(newValidators) != len(headerVals) {
log.Warn("[debugging] length mismatch")
return
}

for i, val := range newValidators {
if !bytes.Equal(val.HeaderBytes(), headerVals[i].HeaderBytes()) {
log.Info("[debugging] bytes mismatch")
return
}
}

log.Info("[debugging] all clear")
}

bar := func() {
log.Info("[debugging] calling with state")
newValidators, err := c.spanner.GetCurrentValidatorsByState(
context.Background(),
rpc.BlockNumberOrHashWithHash(header.ParentHash, false),
state.Copy(),
headerNumber+1,
)
if err != nil {
log.Error("[debugging] error fetching vals from contract", "err", err)
return
}
sort.Sort(valset.ValidatorsByAddress(newValidators))
headerVals, err := valset.ParseValidators(header.GetValidatorBytes(c.chainConfig))
if err != nil {
log.Error("[debugging] error parsing vals", "err", err)
return
}

if len(newValidators) != len(headerVals) {
log.Warn("[debugging] length mismatch")
return
}

for i, val := range newValidators {
if !bytes.Equal(val.HeaderBytes(), headerVals[i].HeaderBytes()) {
log.Info("[debugging] bytes mismatch")
return
}
}

log.Info("[debugging] all clear")
}

if headerNumber == 15251455 {
log.Info("[debugging] FinalizeAndAssemble for block #15251455")
foo()
log.Info("[debugging] foo done")
bar()
log.Info("[debugging] bar done")
}

stateSyncData := []*types.StateSyncData{}

var err error
Expand Down

0 comments on commit d3a114c

Please sign in to comment.