Skip to content

Commit b30006f

Browse files
committed
port changes from #1068
1 parent ea5a603 commit b30006f

File tree

13 files changed

+211
-439
lines changed

13 files changed

+211
-439
lines changed

cmd/utils/flags.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ import (
7474
"github.com/scroll-tech/go-ethereum/p2p/nat"
7575
"github.com/scroll-tech/go-ethereum/p2p/netutil"
7676
"github.com/scroll-tech/go-ethereum/params"
77-
"github.com/scroll-tech/go-ethereum/rollup/da_syncer"
7877
"github.com/scroll-tech/go-ethereum/rollup/tracing"
7978
"github.com/scroll-tech/go-ethereum/rpc"
8079
)
@@ -1627,12 +1626,6 @@ func setEnableRollupVerify(ctx *cli.Context, cfg *ethconfig.Config) {
16271626
func setDA(ctx *cli.Context, cfg *ethconfig.Config) {
16281627
if ctx.IsSet(DASyncEnabledFlag.Name) {
16291628
cfg.EnableDASyncing = ctx.Bool(DASyncEnabledFlag.Name)
1630-
if ctx.IsSet(DAModeFlag.Name) {
1631-
cfg.DA.FetcherMode = *flags.GlobalTextMarshaler(ctx, DAModeFlag.Name).(*da_syncer.FetcherMode)
1632-
}
1633-
if ctx.IsSet(DASnapshotFileFlag.Name) {
1634-
cfg.DA.SnapshotFilePath = ctx.String(DASnapshotFileFlag.Name)
1635-
}
16361629
if ctx.IsSet(DABlobScanAPIEndpointFlag.Name) {
16371630
cfg.DA.BlobScanAPIEndpoint = ctx.String(DABlobScanAPIEndpointFlag.Name)
16381631
}

core/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ func (bc *BlockChain) BuildAndWriteBlock(parentBlock *types.Block, header *types
18501850
l.BlockHash = blockHash
18511851
}
18521852

1853-
return bc.writeBlockAndSetHead(fullBlock, receipts, logs, statedb, false)
1853+
return bc.writeBlockWithState(fullBlock, receipts, logs, statedb, false)
18541854
}
18551855

18561856
// insertSideChain is called when an import batch hits upon a pruned ancestor

core/rawdb/accessors_rollup_event.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,47 +58,6 @@ func ReadRollupEventSyncedL1BlockNumber(db ethdb.Reader) *uint64 {
5858
return &rollupEventSyncedL1BlockNumber
5959
}
6060

61-
// WriteBatchChunkRanges writes the block ranges for each chunk within a batch to the database.
62-
// It serializes the chunk ranges using RLP and stores them under a key derived from the batch index.
63-
// for backward compatibility, new info is also stored in CommittedBatchMeta.
64-
func WriteBatchChunkRanges(db ethdb.KeyValueWriter, batchIndex uint64, chunkBlockRanges []*ChunkBlockRange) {
65-
value, err := rlp.EncodeToBytes(chunkBlockRanges)
66-
if err != nil {
67-
log.Crit("failed to RLP encode batch chunk ranges", "batch index", batchIndex, "err", err)
68-
}
69-
if err := db.Put(batchChunkRangesKey(batchIndex), value); err != nil {
70-
log.Crit("failed to store batch chunk ranges", "batch index", batchIndex, "value", value, "err", err)
71-
}
72-
}
73-
74-
// DeleteBatchChunkRanges removes the block ranges of all chunks associated with a specific batch from the database.
75-
// Note: Only non-finalized batches can be reverted.
76-
// for backward compatibility, new info is also stored in CommittedBatchMeta.
77-
func DeleteBatchChunkRanges(db ethdb.KeyValueWriter, batchIndex uint64) {
78-
if err := db.Delete(batchChunkRangesKey(batchIndex)); err != nil {
79-
log.Crit("failed to delete batch chunk ranges", "batch index", batchIndex, "err", err)
80-
}
81-
}
82-
83-
// ReadBatchChunkRanges retrieves the block ranges of all chunks associated with a specific batch from the database.
84-
// It returns a list of ChunkBlockRange pointers, or nil if no chunk ranges are found for the given batch index.
85-
// for backward compatibility, new info is also stored in CommittedBatchMeta.
86-
func ReadBatchChunkRanges(db ethdb.Reader, batchIndex uint64) []*ChunkBlockRange {
87-
data, err := db.Get(batchChunkRangesKey(batchIndex))
88-
if err != nil && isNotFoundErr(err) {
89-
return nil
90-
}
91-
if err != nil {
92-
log.Crit("failed to read batch chunk ranges from database", "err", err)
93-
}
94-
95-
cr := new([]*ChunkBlockRange)
96-
if err := rlp.Decode(bytes.NewReader(data), cr); err != nil {
97-
log.Crit("Invalid ChunkBlockRange RLP", "batch index", batchIndex, "data", data, "err", err)
98-
}
99-
return *cr
100-
}
101-
10261
// WriteFinalizedBatchMeta stores the metadata of a finalized batch in the database.
10362
func WriteFinalizedBatchMeta(db ethdb.KeyValueWriter, batchIndex uint64, finalizedBatchMeta *FinalizedBatchMeta) {
10463
value, err := rlp.EncodeToBytes(finalizedBatchMeta)

core/rawdb/accessors_rollup_event_test.go

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -147,70 +147,6 @@ func TestFinalizedBatchMeta(t *testing.T) {
147147
}
148148
}
149149

150-
func TestBatchChunkRanges(t *testing.T) {
151-
chunks := [][]*ChunkBlockRange{
152-
{
153-
{StartBlockNumber: 1, EndBlockNumber: 100},
154-
{StartBlockNumber: 101, EndBlockNumber: 200},
155-
},
156-
{
157-
{StartBlockNumber: 201, EndBlockNumber: 300},
158-
{StartBlockNumber: 301, EndBlockNumber: 400},
159-
},
160-
{
161-
{StartBlockNumber: 401, EndBlockNumber: 500},
162-
},
163-
}
164-
165-
db := NewMemoryDatabase()
166-
167-
for i, chunkRange := range chunks {
168-
batchIndex := uint64(i)
169-
WriteBatchChunkRanges(db, batchIndex, chunkRange)
170-
}
171-
172-
for i, chunkRange := range chunks {
173-
batchIndex := uint64(i)
174-
readChunkRange := ReadBatchChunkRanges(db, batchIndex)
175-
if len(readChunkRange) != len(chunkRange) {
176-
t.Fatal("Mismatch in number of chunk ranges", "expected", len(chunkRange), "got", len(readChunkRange))
177-
}
178-
179-
for j, cr := range readChunkRange {
180-
if cr.StartBlockNumber != chunkRange[j].StartBlockNumber || cr.EndBlockNumber != chunkRange[j].EndBlockNumber {
181-
t.Fatal("Mismatch in chunk range", "batch index", batchIndex, "expected", chunkRange[j], "got", cr)
182-
}
183-
}
184-
}
185-
186-
// over-write
187-
newRange := []*ChunkBlockRange{{StartBlockNumber: 1001, EndBlockNumber: 1100}}
188-
WriteBatchChunkRanges(db, 0, newRange)
189-
readChunkRange := ReadBatchChunkRanges(db, 0)
190-
if len(readChunkRange) != 1 || readChunkRange[0].StartBlockNumber != 1001 || readChunkRange[0].EndBlockNumber != 1100 {
191-
t.Fatal("Over-write failed for chunk range", "expected", newRange, "got", readChunkRange)
192-
}
193-
194-
// read non-existing value
195-
if readChunkRange = ReadBatchChunkRanges(db, uint64(len(chunks)+1)); readChunkRange != nil {
196-
t.Fatal("Expected nil for non-existing value", "got", readChunkRange)
197-
}
198-
199-
// delete: revert batch
200-
for i := range chunks {
201-
batchIndex := uint64(i)
202-
DeleteBatchChunkRanges(db, batchIndex)
203-
204-
readChunkRange := ReadBatchChunkRanges(db, batchIndex)
205-
if readChunkRange != nil {
206-
t.Fatal("Chunk range was not deleted", "batch index", batchIndex)
207-
}
208-
}
209-
210-
// delete non-existing value: ensure the delete operation handles non-existing values without errors.
211-
DeleteBatchChunkRanges(db, uint64(len(chunks)+1))
212-
}
213-
214150
func TestWriteReadDeleteCommittedBatchMeta(t *testing.T) {
215151
db := NewMemoryDatabase()
216152

core/rawdb/schema.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ var (
112112

113113
// Scroll rollup event store
114114
rollupEventSyncedL1BlockNumberKey = []byte("R-LastRollupEventSyncedL1BlockNumber")
115-
batchChunkRangesPrefix = []byte("R-bcr")
116115
batchMetaPrefix = []byte("R-bm")
117116
finalizedL2BlockNumberKey = []byte("R-finalized")
118117
lastFinalizedBatchIndexKey = []byte("R-finalizedBatchIndex")
@@ -304,11 +303,6 @@ func SkippedTransactionHashKey(index uint64) []byte {
304303
return append(skippedTransactionHashPrefix, encodeBigEndian(index)...)
305304
}
306305

307-
// batchChunkRangesKey = batchChunkRangesPrefix + batch index (uint64 big endian)
308-
func batchChunkRangesKey(batchIndex uint64) []byte {
309-
return append(batchChunkRangesPrefix, encodeBigEndian(batchIndex)...)
310-
}
311-
312306
// batchMetaKey = batchMetaPrefix + batch index (uint64 big endian)
313307
func batchMetaKey(batchIndex uint64) []byte {
314308
return append(batchMetaPrefix, encodeBigEndian(batchIndex)...)

eth/ethconfig/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ var Defaults = Config{
9494
GPO: FullNodeGPO,
9595
RPCTxFeeCap: 1, // 1 ether
9696
MaxBlockRange: -1, // Default unconfigured value: no block range limit for backward compatibility
97-
DA: da_syncer.Config{
98-
FetcherMode: da_syncer.L1RPC,
99-
},
10097
}
10198

10299
func init() {

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
github.com/Azure/azure-storage-blob-go v0.7.0
7-
github.com/VictoriaMetrics/fastcache v1.12.1
7+
github.com/VictoriaMetrics/fastcache v1.12.2
88
github.com/aws/aws-sdk-go-v2 v1.2.0
99
github.com/aws/aws-sdk-go-v2/config v1.1.1
1010
github.com/aws/aws-sdk-go-v2/credentials v1.1.1
@@ -50,7 +50,7 @@ require (
5050
github.com/prometheus/tsdb v0.7.1
5151
github.com/rjeczalik/notify v0.9.1
5252
github.com/rs/cors v1.7.0
53-
github.com/scroll-tech/da-codec v0.1.2
53+
github.com/scroll-tech/da-codec v0.1.3-0.20241210035500-70810faccc35
5454
github.com/scroll-tech/zktrie v0.8.4
5555
github.com/shirou/gopsutil v3.21.11+incompatible
5656
github.com/sourcegraph/conc v0.3.0
@@ -85,6 +85,7 @@ require (
8585
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
8686
github.com/gotestyourself/gotestyourself v1.4.0 // indirect
8787
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
88+
github.com/klauspost/compress v1.17.9 // indirect
8889
github.com/kylelemons/godebug v1.1.0 // indirect
8990
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d // indirect
9091
github.com/mattn/go-runewidth v0.0.15 // indirect

go.sum

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
3838
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
3939
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
4040
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
41-
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
42-
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
41+
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
42+
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
4343
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
44+
github.com/agiledragon/gomonkey/v2 v2.12.0 h1:ek0dYu9K1rSV+TgkW5LvNNPRWyDZVIxGMCFI6Pz9o38=
45+
github.com/agiledragon/gomonkey/v2 v2.12.0/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY=
4446
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
4547
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
4648
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@@ -278,6 +280,8 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL
278280
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
279281
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
280282
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
283+
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
284+
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
281285
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
282286
github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg=
283287
github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
@@ -387,15 +391,15 @@ github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
387391
github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE=
388392
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
389393
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
390-
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
391-
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
394+
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
395+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
392396
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
393397
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
394398
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
395-
github.com/scroll-tech/da-codec v0.1.1-0.20240822151711-9e32313056ac h1:DjLrqjoOLVFug9ZkAbJYwjtYW51YZE0Num3p4cZXaZs=
396-
github.com/scroll-tech/da-codec v0.1.1-0.20240822151711-9e32313056ac/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs=
397399
github.com/scroll-tech/da-codec v0.1.2 h1:QyJ+dQ4zWVVJwuqxNt4MiKyrymVc6rHe4YPtURkjiRc=
398400
github.com/scroll-tech/da-codec v0.1.2/go.mod h1:odz1ck3umvYccCG03osaQBISAYGinZktZYbpk94fYRE=
401+
github.com/scroll-tech/da-codec v0.1.3-0.20241210035500-70810faccc35 h1:sytWSptYjLWiVE4/GiGYUCXa9VBxfM9UpNpF5BSalI4=
402+
github.com/scroll-tech/da-codec v0.1.3-0.20241210035500-70810faccc35/go.mod h1:vHY7S9ivJ7wlusDBrCh6Lq7k5qNFkTWP4TRDKx35yck=
399403
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
400404
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
401405
github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
@@ -430,8 +434,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
430434
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
431435
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
432436
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
433-
github.com/supranational/blst v0.3.11-0.20230124161941-ca03e11a3ff2 h1:wh1wzwAhZBNiZO37uWS/nDaKiIwHz4mDo4pnA+fqTO0=
434-
github.com/supranational/blst v0.3.11-0.20230124161941-ca03e11a3ff2/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
437+
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
435438
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
436439
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
437440
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
@@ -580,6 +583,7 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
580583
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
581584
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
582585
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
586+
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
583587
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
584588
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
585589
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=

rollup/da_syncer/da_syncer.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ func (s *DASyncer) SyncOneBlock(block *da.PartialBlock) error {
2828
currentBlock := s.blockchain.CurrentBlock()
2929

3030
// we expect blocks to be consecutive. block.PartialHeader.Number == parentBlock.Number+1.
31-
if block.PartialHeader.Number <= currentBlock.Number.Uint64() {
32-
log.Debug("block number is too low", "block number", block.PartialHeader.Number, "parent block number", currentBlock.Number.Uint64())
31+
if block.PartialHeader.Number <= currentBlock.Number().Uint64() {
32+
log.Debug("block number is too low", "block number", block.PartialHeader.Number, "parent block number", currentBlock.Number().Uint64())
3333
return ErrBlockTooLow
34-
} else if block.PartialHeader.Number > currentBlock.Number.Uint64()+1 {
35-
log.Debug("block number is too high", "block number", block.PartialHeader.Number, "parent block number", currentBlock.Number.Uint64())
34+
} else if block.PartialHeader.Number > currentBlock.Number().Uint64()+1 {
35+
log.Debug("block number is too high", "block number", block.PartialHeader.Number, "parent block number", currentBlock.Number().Uint64())
3636
return ErrBlockTooHigh
3737
}
3838

39-
parentBlock := s.blockchain.GetBlockByNumber(currentBlock.Number.Uint64())
39+
parentBlock := s.blockchain.GetBlockByNumber(currentBlock.Number().Uint64())
4040
if _, err := s.blockchain.BuildAndWriteBlock(parentBlock, block.PartialHeader.ToHeader(), block.Transactions); err != nil {
4141
return fmt.Errorf("failed building and writing block, number: %d, error: %v", block.PartialHeader.Number, err)
4242
}
4343

44-
if s.blockchain.CurrentBlock().Number.Uint64()%1000 == 0 {
45-
log.Info("L1 sync progress", "blockhain height", s.blockchain.CurrentBlock().Number.Uint64(), "block hash", s.blockchain.CurrentBlock().Hash(), "root", s.blockchain.CurrentBlock().Root)
44+
if s.blockchain.CurrentBlock().Number().Uint64()%1000 == 0 {
45+
log.Info("L1 sync progress", "blockhain height", s.blockchain.CurrentBlock().Number().Uint64(), "block hash", s.blockchain.CurrentBlock().Hash(), "root", s.blockchain.CurrentBlock().Root)
4646
}
4747

4848
return nil

rollup/da_syncer/data_source.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package da_syncer
22

33
import (
44
"context"
5-
"errors"
65

76
"github.com/scroll-tech/go-ethereum/core"
87
"github.com/scroll-tech/go-ethereum/ethdb"
@@ -36,9 +35,5 @@ func NewDataSourceFactory(blockchain *core.BlockChain, genesisConfig *params.Cha
3635
}
3736

3837
func (ds *DataSourceFactory) OpenDataSource(ctx context.Context, l1height uint64) (DataSource, error) {
39-
if ds.config.FetcherMode == L1RPC {
40-
return da.NewCalldataBlobSource(ctx, l1height, ds.l1Client, ds.blobClient, ds.db)
41-
} else {
42-
return nil, errors.New("snapshot_data_source: not implemented")
43-
}
38+
return da.NewCalldataBlobSource(ctx, l1height, ds.l1Client, ds.blobClient, ds.db)
4439
}

rollup/da_syncer/syncing_pipeline.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ import (
2121

2222
// Config is the configuration parameters of data availability syncing.
2323
type Config struct {
24-
FetcherMode FetcherMode // mode of fetcher
25-
SnapshotFilePath string // path to snapshot file
26-
BlobScanAPIEndpoint string // BlobScan blob api endpoint
27-
BlockNativeAPIEndpoint string // BlockNative blob api endpoint
28-
BeaconNodeAPIEndpoint string // Beacon node api endpoint
24+
BlobScanAPIEndpoint string // BlobScan blob api endpoint
25+
BlockNativeAPIEndpoint string // BlockNative blob api endpoint
26+
BeaconNodeAPIEndpoint string // Beacon node api endpoint
2927
}
3028

3129
// SyncingPipeline is a derivation pipeline for syncing data from L1 and DA and transform it into

0 commit comments

Comments
 (0)