Skip to content

Commit

Permalink
tweak(l1sync): discard pre-etrog verifications for rollupid > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
revitteth committed Aug 29, 2024
1 parent 4409b4f commit 2acac0d
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions zk/stages/stage_l1syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,9 @@ Loop:
for {
select {
case logs := <-logsChan:
infos := make([]*types.L1BatchInfo, 0, len(logs))
batchLogTypes := make([]BatchLogType, 0, len(logs))
for _, l := range logs {
l := l
info, batchLogType := parseLogType(cfg.zkCfg.L1RollupId, &l)
infos = append(infos, &info)
batchLogTypes = append(batchLogTypes, batchLogType)
}

for i, l := range logs {
info := *infos[i]
batchLogType := batchLogTypes[i]
switch batchLogType {
case logSequence:
if err := hermezDb.WriteSequence(info.L1BlockNo, info.BatchNo, info.L1TxHash, info.StateRoot); err != nil {
Expand All @@ -145,6 +136,11 @@ Loop:
}
newSequencesCount++
case logVerify:
case logVerifyEtrog:
// prevent storing pre-etrog verifications for etrog rollups
if batchLogType == logVerify && cfg.zkCfg.L1RollupId > 1 {
continue
}
if info.BatchNo > highestVerification.BatchNo {
highestVerification = info
}
Expand Down Expand Up @@ -213,6 +209,7 @@ var (
logUnknown BatchLogType = 0
logSequence BatchLogType = 1
logVerify BatchLogType = 2
logVerifyEtrog BatchLogType = 3
logL1InfoTreeUpdate BatchLogType = 4

logIncompatible BatchLogType = 100
Expand Down Expand Up @@ -245,15 +242,15 @@ func parseLogType(l1RollupId uint64, log *ethTypes.Log) (l1BatchInfo types.L1Bat
stateRoot = common.BytesToHash(log.Data[:32])
case contracts.VerificationValidiumTopicEtrog:
if isRollupIdMatching {
batchLogType = logVerify
batchLogType = logVerifyEtrog
batchNum = new(big.Int).SetBytes(log.Topics[1].Bytes()).Uint64()
stateRoot = common.BytesToHash(log.Data[:32])
} else {
batchLogType = logIncompatible
}
case contracts.VerificationTopicEtrog:
if isRollupIdMatching {
batchLogType = logVerify
batchLogType = logVerifyEtrog
batchNum = common.BytesToHash(log.Data[:32]).Big().Uint64()
stateRoot = common.BytesToHash(log.Data[32:64])
} else {
Expand Down

0 comments on commit 2acac0d

Please sign in to comment.