From 8fead4470fe44ca447b35967a3e9f14de9b916b2 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Wed, 21 Aug 2024 17:39:36 +0800 Subject: [PATCH] use DarwinV2 --- common/forks/forks.go | 10 ++++------ rollup/conf/config.json | 1 - rollup/go.mod | 4 ++-- rollup/go.sum | 8 ++++---- .../controller/watcher/batch_proposer.go | 20 +++++-------------- .../controller/watcher/bundle_proposer.go | 7 +++---- .../controller/watcher/chunk_proposer.go | 5 +---- 7 files changed, 19 insertions(+), 36 deletions(-) diff --git a/common/forks/forks.go b/common/forks/forks.go index 9be2afdf4..514982b1d 100644 --- a/common/forks/forks.go +++ b/common/forks/forks.go @@ -23,19 +23,17 @@ func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uin // GetCodecVersion returns the encoding codec version for the given block height and timestamp. // It determines the appropriate codec version based on the active hardfork. -func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uint64, enableConditionalCompress bool) encoding.CodecVersion { +func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uint64) encoding.CodecVersion { if !config.IsBernoulli(new(big.Int).SetUint64(blockHeight)) { return encoding.CodecV0 } else if !config.IsCurie(new(big.Int).SetUint64(blockHeight)) { return encoding.CodecV1 } else if !config.IsDarwin(blockTimestamp) { return encoding.CodecV2 + } else if !config.IsDarwinV2(blockTimestamp) { + return encoding.CodecV3 } else { - if !enableConditionalCompress { - return encoding.CodecV3 - } else { - return encoding.CodecV4 - } + return encoding.CodecV4 } } diff --git a/rollup/conf/config.json b/rollup/conf/config.json index 834372131..457e42fe5 100644 --- a/rollup/conf/config.json +++ b/rollup/conf/config.json @@ -66,7 +66,6 @@ "l1_commit_gas_limit_multiplier": 1.2 }, "chunk_proposer_config": { - "enable_conditional_compress": false, "propose_interval_milliseconds": 100, "max_block_num_per_chunk": 100, "max_tx_num_per_chunk": 100, diff --git a/rollup/go.mod b/rollup/go.mod index fd13e07fb..34fd1af16 100644 --- a/rollup/go.mod +++ b/rollup/go.mod @@ -10,8 +10,8 @@ require ( github.com/go-resty/resty/v2 v2.7.0 github.com/holiman/uint256 v1.2.4 github.com/prometheus/client_golang v1.16.0 - github.com/scroll-tech/da-codec v0.0.0-20240819100936-c6af3bbe7068 - github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6 + github.com/scroll-tech/da-codec v0.1.1-0.20240819100936-c6af3bbe7068 + github.com/scroll-tech/go-ethereum v1.10.14-0.20240821075135-bdd1b005d40f github.com/smartystreets/goconvey v1.8.0 github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.25.7 diff --git a/rollup/go.sum b/rollup/go.sum index 58c0b5be9..826819749 100644 --- a/rollup/go.sum +++ b/rollup/go.sum @@ -236,10 +236,10 @@ 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.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scroll-tech/da-codec v0.0.0-20240819100936-c6af3bbe7068 h1:oVGwhg4cCq35B04eG/S4OBXDwXiFH7+LezuH2ZTRBPs= -github.com/scroll-tech/da-codec v0.0.0-20240819100936-c6af3bbe7068/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs= -github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6 h1:Q8YyvrcPIcXQwE4ucm4bqmPh6TP6IB1GUTXripf2WyQ= -github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6/go.mod h1:byf/mZ8jLYUCnUePTicjJWn+RvKdxDn7buS6glTnMwQ= +github.com/scroll-tech/da-codec v0.1.1-0.20240819100936-c6af3bbe7068 h1:KyTp4aedcpjr/rbntrmlhUxjrDYu1Q02QDLaF5vqpxs= +github.com/scroll-tech/da-codec v0.1.1-0.20240819100936-c6af3bbe7068/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs= +github.com/scroll-tech/go-ethereum v1.10.14-0.20240821075135-bdd1b005d40f h1:0XhY20/Sh2UCroZqD4orK7eDElQD2XK4GLrTbPmUBpw= +github.com/scroll-tech/go-ethereum v1.10.14-0.20240821075135-bdd1b005d40f/go.mod h1:jLTGZ5iL5T7g1BEWrQXVIR+wutJFDTVs/mCfjAlrhrA= 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/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= diff --git a/rollup/internal/controller/watcher/batch_proposer.go b/rollup/internal/controller/watcher/batch_proposer.go index 9aa1bbf16..721223935 100644 --- a/rollup/internal/controller/watcher/batch_proposer.go +++ b/rollup/internal/controller/watcher/batch_proposer.go @@ -235,14 +235,12 @@ func (p *BatchProposer) proposeBatch() error { return nil } - // Ensure all chunks in the same batch use the same hardfork name and same codec version - // If a different hardfork name or codec version are found, truncate the chunks slice at that point + // Ensure all blocks in the same chunk use the same hardfork name + // If a different hardfork name is found, truncate the blocks slice at that point hardforkName := forks.GetHardforkName(p.chainCfg, dbChunks[0].StartBlockNumber, dbChunks[0].StartBlockTime) - codecVersion := p.getChunkCodecVersion(firstUnbatchedChunk) for i := 1; i < len(dbChunks); i++ { currentHardfork := forks.GetHardforkName(p.chainCfg, dbChunks[i].StartBlockNumber, dbChunks[i].StartBlockTime) - currentCodecVersion := p.getChunkCodecVersion(dbChunks[i]) - if currentHardfork != hardforkName || currentCodecVersion != codecVersion { + if currentHardfork != hardforkName { dbChunks = dbChunks[:i] maxChunksThisBatch = uint64(len(dbChunks)) // update maxChunksThisBatch to trigger batching, because these chunks are the last chunks before the hardfork break @@ -259,6 +257,8 @@ func (p *BatchProposer) proposeBatch() error { return err } + codecVersion := forks.GetCodecVersion(p.chainCfg, firstUnbatchedChunk.StartBlockNumber, firstUnbatchedChunk.StartBlockTime) + var batch encoding.Batch batch.Index = dbParentBatch.Index + 1 batch.ParentBatchHash = common.HexToHash(dbParentBatch.Hash) @@ -358,13 +358,3 @@ func (p *BatchProposer) recordTimerBatchMetrics(metrics *utils.BatchMetrics) { p.batchEstimateCalldataSizeTime.Set(float64(metrics.EstimateCalldataSizeTime)) p.batchEstimateBlobSizeTime.Set(float64(metrics.EstimateBlobSizeTime)) } - -// getChunkCodecVersion returns the codec version for a given chunk. -// For backward compatibility, it handles cases where some chunks may not have -// codec version stored in the database. -func (p *BatchProposer) getChunkCodecVersion(firstUnbatchedChunk *orm.Chunk) encoding.CodecVersion { - if firstUnbatchedChunk.CodecVersion == -1 { - return forks.GetCodecVersion(p.chainCfg, firstUnbatchedChunk.StartBlockNumber, firstUnbatchedChunk.StartBlockTime, false) - } - return encoding.CodecVersion(firstUnbatchedChunk.CodecVersion) -} diff --git a/rollup/internal/controller/watcher/bundle_proposer.go b/rollup/internal/controller/watcher/bundle_proposer.go index 145372727..6b67347b2 100644 --- a/rollup/internal/controller/watcher/bundle_proposer.go +++ b/rollup/internal/controller/watcher/bundle_proposer.go @@ -140,8 +140,8 @@ func (p *BundleProposer) proposeBundle() error { return nil } - // Ensure all blocks in the same chunk use the same hardfork name and same codec version - // If a different hardfork name or codec version are found, truncate the batches slice at that point + // Ensure all blocks in the same chunk use the same hardfork name + // If a different hardfork name is found, truncate the blocks slice at that point firstChunk, err := p.chunkOrm.GetChunkByIndex(p.ctx, batches[0].StartChunkIndex) if err != nil { return err @@ -154,8 +154,7 @@ func (p *BundleProposer) proposeBundle() error { return err } currentHardfork := forks.GetHardforkName(p.chainCfg, chunk.StartBlockNumber, chunk.StartBlockTime) - currentCodecVersion := encoding.CodecVersion(batches[i].CodecVersion) - if currentHardfork != hardforkName || currentCodecVersion != codecVersion { + if currentHardfork != hardforkName { batches = batches[:i] maxBatchesThisBundle = uint64(i) // update maxBlocksThisChunk to trigger chunking, because these blocks are the last blocks before the hardfork break diff --git a/rollup/internal/controller/watcher/chunk_proposer.go b/rollup/internal/controller/watcher/chunk_proposer.go index 73db21564..f16ce50ac 100644 --- a/rollup/internal/controller/watcher/chunk_proposer.go +++ b/rollup/internal/controller/watcher/chunk_proposer.go @@ -36,8 +36,6 @@ type ChunkProposer struct { gasCostIncreaseMultiplier float64 maxUncompressedBatchBytesSize uint64 - enableConditionalCompress bool - chainCfg *params.ChainConfig chunkProposerCircleTotal prometheus.Counter @@ -86,7 +84,6 @@ func NewChunkProposer(ctx context.Context, cfg *config.ChunkProposerConfig, chai chunkTimeoutSec: cfg.ChunkTimeoutSec, gasCostIncreaseMultiplier: cfg.GasCostIncreaseMultiplier, maxUncompressedBatchBytesSize: cfg.MaxUncompressedBatchBytesSize, - enableConditionalCompress: cfg.EnableConditionalCompress, chainCfg: chainCfg, chunkProposerCircleTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{ @@ -265,7 +262,7 @@ func (p *ChunkProposer) proposeChunk() error { } } - codecVersion := forks.GetCodecVersion(p.chainCfg, blocks[0].Header.Number.Uint64(), blocks[0].Header.Time, p.enableConditionalCompress) + codecVersion := forks.GetCodecVersion(p.chainCfg, blocks[0].Header.Number.Uint64(), blocks[0].Header.Time) // Including Curie block in a sole chunk. if p.chainCfg.CurieBlock != nil && blocks[0].Header.Number.Cmp(p.chainCfg.CurieBlock) == 0 {