Skip to content

Commit afa161a

Browse files
authored
feat: add codecv10 for GalileoV2 (#69)
1 parent 7a92e85 commit afa161a

File tree

6 files changed

+52
-9
lines changed

6 files changed

+52
-9
lines changed

encoding/codecv10.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package encoding
2+
3+
type DACodecV10 struct {
4+
DACodecV9
5+
}
6+
7+
func NewDACodecV10() *DACodecV10 {
8+
v := CodecV10
9+
return &DACodecV10{
10+
DACodecV9: DACodecV9{
11+
DACodecV8: DACodecV8{
12+
DACodecV7: DACodecV7{forcedVersion: &v},
13+
},
14+
},
15+
}
16+
}

encoding/da.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,10 @@ func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uin
825825
return "euclidV2"
826826
} else if !config.IsGalileo(blockTimestamp) {
827827
return "feynman"
828-
} else {
828+
} else if !config.IsGalileoV2(blockTimestamp) {
829829
return "galileo"
830+
} else {
831+
return "galileoV2"
830832
}
831833
}
832834

@@ -850,8 +852,10 @@ func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uin
850852
return CodecV7
851853
} else if !config.IsGalileo(blockTimestamp) {
852854
return CodecV8
853-
} else {
855+
} else if !config.IsGalileoV2(blockTimestamp) {
854856
return CodecV9
857+
} else {
858+
return CodecV10
855859
}
856860
}
857861

@@ -880,7 +884,7 @@ func GetChunkEnableCompression(codecVersion CodecVersion, chunk *Chunk) (bool, e
880884
return false, nil
881885
case CodecV2, CodecV3:
882886
return true, nil
883-
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9:
887+
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9, CodecV10:
884888
return CheckChunkCompressedDataCompatibility(chunk, codecVersion)
885889
default:
886890
return false, fmt.Errorf("unsupported codec version: %v", codecVersion)
@@ -894,7 +898,7 @@ func GetBatchEnableCompression(codecVersion CodecVersion, batch *Batch) (bool, e
894898
return false, nil
895899
case CodecV2, CodecV3:
896900
return true, nil
897-
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9:
901+
case CodecV4, CodecV5, CodecV6, CodecV7, CodecV8, CodecV9, CodecV10:
898902
return CheckBatchCompressedDataCompatibility(batch, codecVersion)
899903
default:
900904
return false, fmt.Errorf("unsupported codec version: %v", codecVersion)

encoding/interfaces.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const (
9595
CodecV7
9696
CodecV8
9797
CodecV9
98+
CodecV10
9899
)
99100

100101
// CodecFromVersion returns the appropriate codec for the given version.
@@ -120,14 +121,18 @@ func CodecFromVersion(version CodecVersion) (Codec, error) {
120121
return NewDACodecV8(), nil
121122
case CodecV9:
122123
return NewDACodecV9(), nil
124+
case CodecV10:
125+
return NewDACodecV10(), nil
123126
default:
124127
return nil, fmt.Errorf("unsupported codec version: %v", version)
125128
}
126129
}
127130

128131
// CodecFromConfig determines and returns the appropriate codec based on chain configuration, block number, and timestamp.
129132
func CodecFromConfig(chainCfg *params.ChainConfig, startBlockNumber *big.Int, startBlockTimestamp uint64) Codec {
130-
if chainCfg.IsGalileo(startBlockTimestamp) {
133+
if chainCfg.IsGalileoV2(startBlockTimestamp) {
134+
return NewDACodecV10()
135+
} else if chainCfg.IsGalileo(startBlockTimestamp) {
131136
return NewDACodecV9()
132137
} else if chainCfg.IsFeynman(startBlockTimestamp) {
133138
return NewDACodecV8()

encoding/interfaces_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ func TestCodecFromVersion(t *testing.T) {
2626
{"CodecV7", CodecV7, &DACodecV7{}, false},
2727
{"CodecV8", CodecV8, &DACodecV8{}, false},
2828
{"CodecV9", CodecV9, &DACodecV9{}, false},
29-
{"CodecV10", CodecVersion(10), nil, true}, // not defined yet
29+
{"CodecV10", CodecV10, &DACodecV10{}, false},
30+
{"CodecV11", CodecVersion(11), nil, true}, // not defined yet
3031
{"InvalidCodec", CodecVersion(99), nil, true},
3132
}
3233

@@ -52,6 +53,23 @@ func TestCodecFromConfig(t *testing.T) {
5253
want Codec
5354
}{
5455
{
56+
name: "GalileoV2 active",
57+
config: &params.ChainConfig{
58+
LondonBlock: big.NewInt(0),
59+
BernoulliBlock: big.NewInt(0),
60+
CurieBlock: big.NewInt(0),
61+
DarwinTime: new(uint64),
62+
DarwinV2Time: new(uint64),
63+
EuclidTime: new(uint64),
64+
EuclidV2Time: new(uint64),
65+
FeynmanTime: new(uint64),
66+
GalileoTime: new(uint64),
67+
GalileoV2Time: new(uint64),
68+
},
69+
blockNum: big.NewInt(0),
70+
timestamp: 0,
71+
want: &DACodecV10{},
72+
}, {
5573
name: "Galileo active",
5674
config: &params.ChainConfig{
5775
LondonBlock: big.NewInt(0),

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22
44

55
require (
66
github.com/agiledragon/gomonkey/v2 v2.12.0
7-
github.com/scroll-tech/go-ethereum v1.10.14-0.20251113125950-906b730d541d
7+
github.com/scroll-tech/go-ethereum v1.10.14-0.20251127071535-dd8541508584
88
github.com/stretchr/testify v1.10.0
99
)
1010

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
7777
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
7878
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
7979
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
80-
github.com/scroll-tech/go-ethereum v1.10.14-0.20251113125950-906b730d541d h1:ESTxtuPQN8tKsXnhAyMDmJtW70j4oLxSJ8JVu4wW0S8=
81-
github.com/scroll-tech/go-ethereum v1.10.14-0.20251113125950-906b730d541d/go.mod h1:zRa7CnS75mFdgp8IeMtZV/wCAlxPRT33Ek3+fFbBJVQ=
80+
github.com/scroll-tech/go-ethereum v1.10.14-0.20251127071535-dd8541508584 h1:jitztva61hrf1ASM5kKaugYuakHKrXkIMCnBtP/Kr3s=
81+
github.com/scroll-tech/go-ethereum v1.10.14-0.20251127071535-dd8541508584/go.mod h1:6BVek7YliYh+YeHOSjguPw9GT9BhVBfThArxzVlpqdQ=
8282
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
8383
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
8484
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=

0 commit comments

Comments
 (0)