From adab78a7014f64e71c7743b3e99e3fd1b722edeb Mon Sep 17 00:00:00 2001 From: curryxbo Date: Tue, 29 Apr 2025 14:26:41 +0800 Subject: [PATCH 1/2] fix deocde batch --- node/derivation/batch_info.go | 12 ++++++------ node/go.mod | 2 +- node/go.sum | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/node/derivation/batch_info.go b/node/derivation/batch_info.go index 01044232..35a7a6d4 100644 --- a/node/derivation/batch_info.go +++ b/node/derivation/batch_info.go @@ -42,10 +42,12 @@ func (b *BlockContext) Decode(bc []byte) error { if err != nil { return err } + b.Number = wb.Number b.BaseFee = wb.BaseFee b.GasLimit = wb.GasLimit b.txsNum = txsNum b.l1MsgNum = l1MsgNum + b.Timestamp = wb.Timestamp b.coinbase = wb.Miner return nil } @@ -168,7 +170,6 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch, morph204Time uint64) if err := block.Decode(bcBytes); err != nil { return fmt.Errorf("decode number and timestamp error: %v", err) } - var coinbase common.Address // handle coinbase if morph204Time == 0 || block.Timestamp >= morph204Time { coinbaseBytes := make([]byte, common.AddressLength) @@ -177,10 +178,11 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch, morph204Time uint64) return fmt.Errorf("read skipped block context error:%s", err.Error()) } - coinbase, err = decodeCoinbase(coinbaseBytes) + coinbase, err := decodeCoinbase(coinbaseBytes) if err != nil { return err } + block.coinbase = coinbase } // Set boundary block numbers @@ -197,8 +199,8 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch, morph204Time uint64) safeL2Data.GasLimit = block.GasLimit safeL2Data.BaseFee = block.BaseFee safeL2Data.Timestamp = block.Timestamp - // TODO coinbase - fmt.Println(coinbase) + // Separate parse + safeL2Data.Miner = block.coinbase // Handle zero BaseFee case if block.BaseFee != nil && block.BaseFee.Cmp(big.NewInt(0)) == 0 { @@ -214,7 +216,6 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch, morph204Time uint64) block.SafeL2Data = &safeL2Data blockContexts[i] = &block } - // Read transaction data txsData, err := io.ReadAll(reader) if err != nil { @@ -229,7 +230,6 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch, morph204Time uint64) // Process transactions tq.enqueue(data) - for i := 0; i < int(blockCount); i++ { // Skip if index is out of bounds if i >= len(blockContexts) { diff --git a/node/go.mod b/node/go.mod index 1505f4d9..ba0a3753 100644 --- a/node/go.mod +++ b/node/go.mod @@ -10,7 +10,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/golang-lru v1.0.2 github.com/klauspost/compress v1.17.9 - github.com/morph-l2/go-ethereum v1.10.14-0.20250425070859-09af684fe1f3 + github.com/morph-l2/go-ethereum v1.10.14-0.20250428081328-6f1d6b6d7fbc github.com/prometheus/client_golang v1.17.0 github.com/spf13/viper v1.13.0 github.com/stretchr/testify v1.9.0 diff --git a/node/go.sum b/node/go.sum index c222808a..7f552fa9 100644 --- a/node/go.sum +++ b/node/go.sum @@ -360,8 +360,8 @@ github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqky github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/morph-l2/go-ethereum v1.10.14-0.20250425070859-09af684fe1f3 h1:JKzLjIra43KfRXDDZEcypcFOZixWMnXtFmLaxUOStYY= -github.com/morph-l2/go-ethereum v1.10.14-0.20250425070859-09af684fe1f3/go.mod h1:sMJCfHOBzVRDkM2yF/Hy+oUk2rgC0CQZHTLs0cyzhhk= +github.com/morph-l2/go-ethereum v1.10.14-0.20250428081328-6f1d6b6d7fbc h1:6/PIvEm6SV4ilM19vo1LiMtRS/ARRJpbdivWMr+C0Vk= +github.com/morph-l2/go-ethereum v1.10.14-0.20250428081328-6f1d6b6d7fbc/go.mod h1:sMJCfHOBzVRDkM2yF/Hy+oUk2rgC0CQZHTLs0cyzhhk= github.com/morph-l2/tendermint v0.3.2-0.20250115141431-c84dfe5c8533 h1:qhBMCyTQ/ezOpeqHGKjr4qSN/B/bGFByuYjQqDt5wiw= github.com/morph-l2/tendermint v0.3.2-0.20250115141431-c84dfe5c8533/go.mod h1:TtCzp9l6Z6yDUiwv3TbqKqw8Q8RKp3fSz5+adO1/Y8w= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= From 39c87330fd2ca750fcc4916c9a555923b0f27a55 Mon Sep 17 00:00:00 2001 From: curryxbo Date: Tue, 29 Apr 2025 14:28:33 +0800 Subject: [PATCH 2/2] clean --- node/derivation/batch_info.go | 1 - 1 file changed, 1 deletion(-) diff --git a/node/derivation/batch_info.go b/node/derivation/batch_info.go index 35a7a6d4..6c0c9a93 100644 --- a/node/derivation/batch_info.go +++ b/node/derivation/batch_info.go @@ -199,7 +199,6 @@ func (bi *BatchInfo) ParseBatch(batch geth.RPCRollupBatch, morph204Time uint64) safeL2Data.GasLimit = block.GasLimit safeL2Data.BaseFee = block.BaseFee safeL2Data.Timestamp = block.Timestamp - // Separate parse safeL2Data.Miner = block.coinbase // Handle zero BaseFee case