From bf561f3a2ee751126b1fbcac1a16fd42bf31e436 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 27 Jun 2024 18:13:13 +0800 Subject: [PATCH 1/4] feat: add codecv3 for darwin batches --- go.mod | 2 +- go.sum | 2 ++ .../rollup_sync_service.go | 30 +++++++++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 92ffd5b23362..eebd8e78e372 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/prometheus/tsdb v0.7.1 github.com/rjeczalik/notify v0.9.1 github.com/rs/cors v1.7.0 - github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7 + github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3 github.com/scroll-tech/zktrie v0.8.4 github.com/shirou/gopsutil v3.21.11+incompatible github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 diff --git a/go.sum b/go.sum index a6255b577a02..0a4141b3d8d2 100644 --- a/go.sum +++ b/go.sum @@ -394,6 +394,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7 h1:CDrPMqifvAVyYqu0x1J5qickVV0b51tApPnOwDYLESI= github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7/go.mod h1:1wWYii0OPwd5kw+xrz0PFgS420xNadrNF1x/ELJT+TM= +github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3 h1:wNB6k9oO1gejiPpvUPxnQ94l6THILiMX713zEOJAyes= +github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs= github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE= github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= diff --git a/rollup/rollup_sync_service/rollup_sync_service.go b/rollup/rollup_sync_service/rollup_sync_service.go index e74e41e9bc73..4c4a21f08761 100644 --- a/rollup/rollup_sync_service/rollup_sync_service.go +++ b/rollup/rollup_sync_service/rollup_sync_service.go @@ -12,6 +12,7 @@ import ( "github.com/scroll-tech/da-codec/encoding/codecv0" "github.com/scroll-tech/da-codec/encoding/codecv1" "github.com/scroll-tech/da-codec/encoding/codecv2" + "github.com/scroll-tech/da-codec/encoding/codecv3" "github.com/scroll-tech/go-ethereum/accounts/abi" "github.com/scroll-tech/go-ethereum/common" @@ -433,10 +434,16 @@ func validateBatch(event *L1FinalizeBatchEvent, parentBatchMeta *rawdb.Finalized return 0, nil, fmt.Errorf("failed to create codecv1 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err) } localBatchHash = daBatch.Hash() - } else { // codecv2: batches after Curie + } else if !chainCfg.IsDarwin(startBlock.Header.Time) { // codecv2: batches after Curie and before Darwin daBatch, err := codecv2.NewDABatch(batch) if err != nil { - return 0, nil, fmt.Errorf("failed to create codecv1 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err) + return 0, nil, fmt.Errorf("failed to create codecv2 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err) + } + localBatchHash = daBatch.Hash() + } else { // codecv3: batches after Darwin + daBatch, err := codecv3.NewDABatch(batch) + if err != nil { + return 0, nil, fmt.Errorf("failed to create codecv3 DA batch, batch index: %v, err: %w", event.BatchIndex.Uint64(), err) } localBatchHash = daBatch.Hash() } @@ -532,6 +539,25 @@ func decodeBlockRangesFromEncodedChunks(codecVersion encoding.CodecVersion, chun StartBlockNumber: daBlocks[0].BlockNumber, EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber, }) + case encoding.CodecV3: + if len(chunk) != 1+numBlocks*60 { + return nil, fmt.Errorf("invalid chunk byte length, expected: %v, got: %v", 1+numBlocks*60, len(chunk)) + } + daBlocks := make([]*codecv3.DABlock, numBlocks) + for i := 0; i < numBlocks; i++ { + startIdx := 1 + i*60 // add 1 to skip numBlocks byte + endIdx := startIdx + 60 + daBlocks[i] = &codecv3.DABlock{} + if err := daBlocks[i].Decode(chunk[startIdx:endIdx]); err != nil { + return nil, err + } + } + + chunkBlockRanges = append(chunkBlockRanges, &rawdb.ChunkBlockRange{ + StartBlockNumber: daBlocks[0].BlockNumber, + EndBlockNumber: daBlocks[len(daBlocks)-1].BlockNumber, + }) + default: return nil, fmt.Errorf("unexpected batch version %v", codecVersion) } From a15f57d3f3d48413b00c185a016d6034e66eee20 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 27 Jun 2024 18:18:43 +0800 Subject: [PATCH 2/4] fix lint issue --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 0a4141b3d8d2..5b8e87be8a5b 100644 --- a/go.sum +++ b/go.sum @@ -392,8 +392,6 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7 h1:CDrPMqifvAVyYqu0x1J5qickVV0b51tApPnOwDYLESI= -github.com/scroll-tech/da-codec v0.0.0-20240605080813-32bfc9fccde7/go.mod h1:1wWYii0OPwd5kw+xrz0PFgS420xNadrNF1x/ELJT+TM= github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3 h1:wNB6k9oO1gejiPpvUPxnQ94l6THILiMX713zEOJAyes= github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs= github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE= From 202a1c4826be12709f43f8779326f5fee4820426 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 8 Jul 2024 08:43:28 +0000 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20auto=20version=20bump=E2=80=89[bot?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index 3b8eb6c1779d..20548857f702 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 5 // Minor version component of the current release - VersionPatch = 4 // Patch version component of the current release + VersionPatch = 5 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) From eda23b19c5e2cc3bd1e727c3d563109f2203a8d6 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 8 Jul 2024 16:53:18 +0800 Subject: [PATCH 4/4] update da-codec dependency --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index eebd8e78e372..c37ecdda836a 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/prometheus/tsdb v0.7.1 github.com/rjeczalik/notify v0.9.1 github.com/rs/cors v1.7.0 - github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3 + github.com/scroll-tech/da-codec v0.1.1-0.20240703091800-5b6cded48ab7 github.com/scroll-tech/zktrie v0.8.4 github.com/shirou/gopsutil v3.21.11+incompatible github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 diff --git a/go.sum b/go.sum index 5b8e87be8a5b..00258e3e5bbc 100644 --- a/go.sum +++ b/go.sum @@ -392,8 +392,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3 h1:wNB6k9oO1gejiPpvUPxnQ94l6THILiMX713zEOJAyes= -github.com/scroll-tech/da-codec v0.1.1-0.20240626090813-e197995302f3/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs= +github.com/scroll-tech/da-codec v0.1.1-0.20240703091800-5b6cded48ab7 h1:UfiLBLCAMBk9bsTP3fc1fETpNVFSQapQVdLcZveyV0M= +github.com/scroll-tech/da-codec v0.1.1-0.20240703091800-5b6cded48ab7/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs= github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE= github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=