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

added case when incrementing hashes from 0 #87

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions zk/stages/stage_interhashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ func SpawnZkIntermediateHashesStage(s *stagedsync.StageState, u stagedsync.Unwin
if cfg.hd != nil {
cfg.hd.ReportBadHeaderPoS(headerHash, syncHeadHeader.ParentHash)
}
if to > s.BlockNumber {
//unwindTo := (to + s.BlockNumber) / 2 // Binary search for the correct block, biased to the lower numbers
//log.Warn("Unwinding due to incorrect root hash", "to", unwindTo)
//u.UnwindTo(unwindTo, headerHash)
}
// if to > s.BlockNumber {
//unwindTo := (to + s.BlockNumber) / 2 // Binary search for the correct block, biased to the lower numbers
//log.Warn("Unwinding due to incorrect root hash", "to", unwindTo)
//u.UnwindTo(unwindTo, headerHash)
// }
} else if err = s.Update(tx, to); err != nil {
return trie.EmptyRoot, err
}
Expand Down Expand Up @@ -341,9 +341,16 @@ func zkIncrementIntermediateHashes(logPrefix string, s *stagedsync.StageState, d
codeChanges := make(map[libcommon.Address]string)
storageChanges := make(map[libcommon.Address]map[string]string)

// case when we are incrementing from block 1
// we chould include the 0 block which is the genesis data
from := s.BlockNumber
if from != 0 {
from += 1
}

// NB: changeset tables are zero indexed
// changeset tables contain historical value at N-1, so we look up values from plainstate
for i := s.BlockNumber + 1; i <= to; i++ {
for i := from; i <= to; i++ {
dupSortKey := dbutils.EncodeBlockNumber(i)

// i+1 to get state at the beginning of the next batch
Expand Down