Skip to content

Commit

Permalink
change to l1 info tree log event ordering (erigontech#755)
Browse files Browse the repository at this point in the history
* change to l1 info tree log event ordering

* promote info tree updates to debug level log

* additional check on log index for l1 info root
  • Loading branch information
hexoscott authored Jul 10, 2024
1 parent 05af01e commit 20a9440
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions zk/stages/stage_l1_info_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ LOOP:
sort.Slice(allLogs, func(i, j int) bool {
l1 := allLogs[i]
l2 := allLogs[j]
if l1.BlockNumber == l2.BlockNumber {
// sort by index in the case of a matching block number
// first sort by block number and if equal then by tx index
if l1.BlockNumber != l2.BlockNumber {
return l1.BlockNumber < l2.BlockNumber
}
if l1.TxIndex != l2.TxIndex {
return l1.TxIndex < l2.TxIndex
}
// otherwise sort by block number
return l1.BlockNumber < l2.BlockNumber
return l1.Index < l2.Index
})

// chunk the logs into batches, so we don't overload the RPC endpoints too much at once
Expand Down Expand Up @@ -155,7 +157,14 @@ LOOP:
if err != nil {
return err
}
log.Trace("New L1 Index", "index", latestUpdate.Index, "root", newRoot.String())
log.Debug("New L1 Index",
"index", latestUpdate.Index,
"root", newRoot.String(),
"mainnet", latestUpdate.MainnetExitRoot.String(),
"rollup", latestUpdate.RollupExitRoot.String(),
"ger", latestUpdate.GER.String(),
"parent", latestUpdate.ParentHash.String(),
)

err = hermezDb.WriteL1InfoTreeRoot(common.BytesToHash(newRoot[:]), latestUpdate.Index)
if err != nil {
Expand Down

0 comments on commit 20a9440

Please sign in to comment.