Skip to content

Commit

Permalink
Ignore genesis batch (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
curryxbo authored Jun 20, 2024
1 parent 67bf51b commit d6be9d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 4 additions & 7 deletions node/derivation/derivation.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,7 @@ func (d *Derivation) derivationBlock(ctx context.Context) {
for _, lg := range logs {
batchInfo, err := d.fetchRollupDataByTxHash(lg.TxHash, lg.BlockNumber)
if err != nil {
rollupCommitBatch, parseErr := d.rollup.ParseCommitBatch(lg)
if parseErr != nil {
d.logger.Error("parse commit batch failed", "err", err)
return
}
// ignore genesis batch
if rollupCommitBatch.BatchIndex.Uint64() == 0 {
if errors.Is(err, types.ErrNotCommitBatchTx) {
continue
}
d.logger.Error("fetch batch info failed", "txHash", lg.TxHash, "blockNumber", lg.BlockNumber, "error", err)
Expand Down Expand Up @@ -269,6 +263,9 @@ func (d *Derivation) fetchRollupDataByTxHash(txHash common.Hash, blockNumber uin
if err != nil {
return nil, err
}
if !bytes.Equal(abi.Methods["commitBatch"].ID, tx.Data()[:4]) {
return nil, types.ErrNotCommitBatchTx
}
args, err := abi.Methods["commitBatch"].Inputs.Unpack(tx.Data()[4:])
if err != nil {
return nil, fmt.Errorf("submitBatches Unpack error:%v", err)
Expand Down
2 changes: 2 additions & 0 deletions node/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ var (

ErrMemoryDBNotFound = errors.New("not found")

ErrNotCommitBatchTx = errors.New("not commit batch tx")

ErrNotFromCrossDomainMessenger = errors.New("the cross message is not sent by L1CrossDomainMessenger")
)

0 comments on commit d6be9d0

Please sign in to comment.