Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions encoding/codecv10.go
Original file line number Diff line number Diff line change
@@ -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},
},
},
}
}
12 changes: 8 additions & 4 deletions encoding/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand All @@ -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
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion encoding/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const (
CodecV7
CodecV8
CodecV9
CodecV10
)

// CodecFromVersion returns the appropriate codec for the given version.
Expand All @@ -120,14 +121,18 @@ 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)
}
}

// 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()
Expand Down
20 changes: 19 additions & 1 deletion encoding/interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}

Expand All @@ -52,6 +53,23 @@ func TestCodecFromConfig(t *testing.T) {
want Codec
}{
{
name: "GalileoV2 active",
config: &params.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: &params.ChainConfig{
LondonBlock: big.NewInt(0),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down