Skip to content

Commit 9b2b5e0

Browse files
authored
feat: adjustments for launching Cloak with GalileoV2 (#1793)
1 parent 788f6b9 commit 9b2b5e0

5 files changed

Lines changed: 12 additions & 24 deletions

File tree

coordinator/internal/utils/codec_validium.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (c CodecVersion) DABatchForTaskFromBytes(b []byte) (DABatch, error) {
5656

5757
func decodeDABatchV1(data []byte) (*daBatchValidiumV1, error) {
5858
if len(data) != daBatchValidiumEncodedLength {
59-
return nil, fmt.Errorf("invalid data length for DABatchV7, expected %d bytes but got %d", daBatchValidiumEncodedLength, len(data))
59+
return nil, fmt.Errorf("invalid data length for ValidiumDABatchV1, expected %d bytes but got %d", daBatchValidiumEncodedLength, len(data))
6060
}
6161

6262
const (

coordinator/internal/utils/version.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ func Version(hardForkName string, ValidiumMode bool) (uint8, error) {
1919

2020
if ValidiumMode {
2121
domain = 1
22-
stfVersion = 1
22+
switch canonicalName := strings.ToLower(hardForkName); canonicalName {
23+
case "galileov2":
24+
stfVersion = 1
25+
default:
26+
return 0, errors.New("unsupported fork in validium mode " + canonicalName)
27+
}
2328
} else {
2429
domain = 0
2530
switch canonicalName := strings.ToLower(hardForkName); canonicalName {

rollup/cmd/rollup_relayer/app/app.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ func action(ctx *cli.Context) error {
111111
if minCodecVersion < encoding.CodecV7 {
112112
log.Crit("min codec version must be greater than or equal to CodecV7", "minCodecVersion", minCodecVersion)
113113
}
114+
if cfg.L2Config.RelayerConfig.ValidiumMode && minCodecVersion < encoding.CodecV10 {
115+
log.Crit("min codec version must be greater than or equal to CodecV10 in validium mode", "minCodecVersion", minCodecVersion)
116+
}
114117

115118
chunkProposer := watcher.NewChunkProposer(subCtx, cfg.L2Config.ChunkProposerConfig, minCodecVersion, genesis.Config, db, registry)
116119
batchProposer := watcher.NewBatchProposer(subCtx, cfg.L2Config.BatchProposerConfig, minCodecVersion, genesis.Config, db, cfg.L2Config.RelayerConfig.ValidiumMode, registry)

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ func (r *Layer2Relayer) constructCommitBatchPayloadValidium(batch *dbBatchWithCh
10531053
var version uint8
10541054
if encoding.CodecVersion(batch.Batch.CodecVersion) == encoding.CodecV8 || encoding.CodecVersion(batch.Batch.CodecVersion) == encoding.CodecV9 || encoding.CodecVersion(batch.Batch.CodecVersion) == encoding.CodecV10 {
10551055
// Validium version line starts with v1,
1056-
// but rollup-relayer behavior follows v8.
1056+
// but rollup-relayer behavior follows v10.
10571057
version = 1
10581058
} else {
10591059
return nil, 0, 0, fmt.Errorf("unexpected codec version %d for validium mode", batch.Batch.CodecVersion)

rollup/internal/utils/utils.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/scroll-tech/da-codec/encoding"
99
"github.com/scroll-tech/go-ethereum/common"
1010
"github.com/scroll-tech/go-ethereum/crypto"
11-
"github.com/scroll-tech/go-ethereum/log"
1211
)
1312

1413
// ChunkMetrics indicates the metrics for proposing a chunk.
@@ -141,25 +140,6 @@ func encodeBatchHeaderValidium(b *encoding.Batch, codecVersion encoding.CodecVer
141140
commitment := lastBlock.Header.Hash()
142141
stateRoot := b.StateRoot()
143142

144-
// Temporary workaround for the wrong genesis state root configuration issue.
145-
if lastBlock.Header.Number.Uint64() == 0 {
146-
if commitment == common.HexToHash("0x76a8e1359fe1a51ec3917ca98dec95ba005f1a73bcdbc2c7f87c7683e828fbb1") && stateRoot == common.HexToHash("0x08d535cc60f40af5dd3b31e0998d7567c2d568b224bed2ba26070aeb078d1339") {
147-
// cloak-xen/sepolia
148-
stateRoot = common.HexToHash("0x0711f02d6f85b0597c4705298e01ee27159fdd8bd8bdeda670ae8b9073091246")
149-
} else if commitment == common.HexToHash("0x8005a02271085eaded2565f3e252013cd9d3cd0a4775d89f9ba4224289671276") && stateRoot == common.HexToHash("0x08d535cc60f40af5dd3b31e0998d7567c2d568b224bed2ba26070aeb078d1339") {
150-
// cloak-xen/mainnet
151-
stateRoot = common.HexToHash("0x8da1aaf41660ddf7870ab5ff4f6a3ab4b2e652568d341ede87ada56aad5fb097")
152-
} else if commitment == common.HexToHash("0xa7e50dfc812039410c2009c74cdcb0c0797aa5485dec062985eaa43b17d333ea") && stateRoot == common.HexToHash("0x08d535cc60f40af5dd3b31e0998d7567c2d568b224bed2ba26070aeb078d1339") {
153-
// cloak-etherfi/sepolia
154-
stateRoot = common.HexToHash("0x7b44ea23770dda8810801779eb6847d56be0399e35de7c56465ccf8b7578ddf6")
155-
} else if commitment == common.HexToHash("0xeccf4fab24f8b5dd3b72667c6bf5e28b17ccffdea01e3e5c08f393edaa9e7657") && stateRoot == common.HexToHash("0x08d535cc60f40af5dd3b31e0998d7567c2d568b224bed2ba26070aeb078d1339") {
156-
// cloak-shiga/sepolia
157-
stateRoot = common.HexToHash("0x05973227854ac82c22f164ed3d4510b7df516a0eecdfd9bed5f2446efc9994b9")
158-
}
159-
160-
log.Warn("Using genesis state root", "stateRoot", stateRoot.Hex())
161-
}
162-
163143
// Batch header field sizes
164144
const (
165145
versionSize = 1
@@ -188,7 +168,7 @@ func encodeBatchHeaderValidium(b *encoding.Batch, codecVersion encoding.CodecVer
188168
var version uint8
189169
if codecVersion == encoding.CodecV8 || codecVersion == encoding.CodecV9 || codecVersion == encoding.CodecV10 {
190170
// Validium version line starts with v1,
191-
// but rollup-relayer behavior follows v8.
171+
// but rollup-relayer behavior follows v10.
192172
version = 1
193173
} else if codecVersion == encoding.CodecV0 {
194174
// Special case for genesis batch

0 commit comments

Comments
 (0)