diff --git a/encoding/codecv10.go b/encoding/codecv10.go new file mode 100644 index 0000000..981fa92 --- /dev/null +++ b/encoding/codecv10.go @@ -0,0 +1,16 @@ +package encoding + +type DACodecV10 struct { + DACodecV9 +} + +func NewDACodecV10() *DACodecV10 { + v := CodecV10 + return &DACodecV10{ + DACodecV9: DACodecV9{ + DACodecV8: DACodecV8{ + DACodecV7: DACodecV7{forcedVersion: &v}, + }, + }, + } +} diff --git a/encoding/da.go b/encoding/da.go index 6d82447..9029247 100644 --- a/encoding/da.go +++ b/encoding/da.go @@ -825,8 +825,10 @@ func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uin return "euclidV2" } else if !config.IsGalileo(blockTimestamp) { return "feynman" - } else { + } else if !config.IsGalileoV2(blockTimestamp) { return "galileo" + } else { + return "galileoV2" } } @@ -850,8 +852,10 @@ func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uin return CodecV7 } else if !config.IsGalileo(blockTimestamp) { return CodecV8 - } else { + } else if !config.IsGalileoV2(blockTimestamp) { return CodecV9 + } else { + return CodecV10 } } @@ -880,7 +884,7 @@ func GetChunkEnableCompression(codecVersion CodecVersion, chunk *Chunk) (bool, e return false, nil case CodecV2, CodecV3: return true, nil - case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9: + case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9, CodecV10: return CheckChunkCompressedDataCompatibility(chunk, codecVersion) default: return false, fmt.Errorf("unsupported codec version: %v", codecVersion) @@ -894,7 +898,7 @@ func GetBatchEnableCompression(codecVersion CodecVersion, batch *Batch) (bool, e return false, nil case CodecV2, CodecV3: return true, nil - case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9: + case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9, CodecV10: return CheckBatchCompressedDataCompatibility(batch, codecVersion) default: return false, fmt.Errorf("unsupported codec version: %v", codecVersion) diff --git a/encoding/interfaces.go b/encoding/interfaces.go index efda868..16d51f5 100644 --- a/encoding/interfaces.go +++ b/encoding/interfaces.go @@ -95,6 +95,7 @@ const ( CodecV7 CodecV8 CodecV9 + CodecV10 ) // CodecFromVersion returns the appropriate codec for the given version. @@ -120,6 +121,8 @@ func CodecFromVersion(version CodecVersion) (Codec, error) { return NewDACodecV8(), nil case CodecV9: return NewDACodecV9(), nil + case CodecV10: + return NewDACodecV10(), nil default: return nil, fmt.Errorf("unsupported codec version: %v", version) } @@ -127,7 +130,9 @@ func CodecFromVersion(version CodecVersion) (Codec, error) { // CodecFromConfig determines and returns the appropriate codec based on chain configuration, block number, and timestamp. func CodecFromConfig(chainCfg *params.ChainConfig, startBlockNumber *big.Int, startBlockTimestamp uint64) Codec { - if chainCfg.IsGalileo(startBlockTimestamp) { + if chainCfg.IsGalileoV2(startBlockTimestamp) { + return NewDACodecV10() + } else if chainCfg.IsGalileo(startBlockTimestamp) { return NewDACodecV9() } else if chainCfg.IsFeynman(startBlockTimestamp) { return NewDACodecV8() diff --git a/encoding/interfaces_test.go b/encoding/interfaces_test.go index 6122506..c4f913f 100644 --- a/encoding/interfaces_test.go +++ b/encoding/interfaces_test.go @@ -26,7 +26,8 @@ func TestCodecFromVersion(t *testing.T) { {"CodecV7", CodecV7, &DACodecV7{}, false}, {"CodecV8", CodecV8, &DACodecV8{}, false}, {"CodecV9", CodecV9, &DACodecV9{}, false}, - {"CodecV10", CodecVersion(10), nil, true}, // not defined yet + {"CodecV10", CodecV10, &DACodecV10{}, false}, + {"CodecV11", CodecVersion(11), nil, true}, // not defined yet {"InvalidCodec", CodecVersion(99), nil, true}, } @@ -52,6 +53,23 @@ func TestCodecFromConfig(t *testing.T) { want Codec }{ { + name: "GalileoV2 active", + config: ¶ms.ChainConfig{ + LondonBlock: big.NewInt(0), + BernoulliBlock: big.NewInt(0), + CurieBlock: big.NewInt(0), + DarwinTime: new(uint64), + DarwinV2Time: new(uint64), + EuclidTime: new(uint64), + EuclidV2Time: new(uint64), + FeynmanTime: new(uint64), + GalileoTime: new(uint64), + GalileoV2Time: new(uint64), + }, + blockNum: big.NewInt(0), + timestamp: 0, + want: &DACodecV10{}, + }, { name: "Galileo active", config: ¶ms.ChainConfig{ LondonBlock: big.NewInt(0), diff --git a/go.mod b/go.mod index 6f7ed1c..3877b6c 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/agiledragon/gomonkey/v2 v2.12.0 - github.com/scroll-tech/go-ethereum v1.10.14-0.20251113125950-906b730d541d + github.com/scroll-tech/go-ethereum v1.10.14-0.20251127071535-dd8541508584 github.com/stretchr/testify v1.10.0 ) diff --git a/go.sum b/go.sum index fad6ba2..9d3df2a 100644 --- a/go.sum +++ b/go.sum @@ -77,8 +77,8 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/scroll-tech/go-ethereum v1.10.14-0.20251113125950-906b730d541d h1:ESTxtuPQN8tKsXnhAyMDmJtW70j4oLxSJ8JVu4wW0S8= -github.com/scroll-tech/go-ethereum v1.10.14-0.20251113125950-906b730d541d/go.mod h1:zRa7CnS75mFdgp8IeMtZV/wCAlxPRT33Ek3+fFbBJVQ= +github.com/scroll-tech/go-ethereum v1.10.14-0.20251127071535-dd8541508584 h1:jitztva61hrf1ASM5kKaugYuakHKrXkIMCnBtP/Kr3s= +github.com/scroll-tech/go-ethereum v1.10.14-0.20251127071535-dd8541508584/go.mod h1:6BVek7YliYh+YeHOSjguPw9GT9BhVBfThArxzVlpqdQ= 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=