Skip to content

Commit 68697b0

Browse files
authored
fix: use non-overlapping DB prefix for L1 messages (#532)
* fix: use non-overlapping db prefix for L1 messages * bump version
1 parent fea7d94 commit 68697b0

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

cmd/utils/flags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18281828
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
18291829
}
18301830
}
1831+
1832+
// set db prefix for backward-compatibility
1833+
if cfg.NetworkId == 534351 {
1834+
log.Warn("Using legacy db prefix for L1 messages")
1835+
rawdb.SetL1MessageLegacyPrefix()
1836+
}
18311837
}
18321838

18331839
// SetDNSDiscoveryDefaults configures DNS discovery with the given URL if

core/rawdb/database.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
324324
bloomBits stat
325325
cliqueSnaps stat
326326
l1Messages stat
327+
l1MessagesOld stat
327328
lastL1Message stat
328329

329330
// Ancient store statistics
@@ -386,6 +387,8 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
386387
cliqueSnaps.Add(size)
387388
case bytes.HasPrefix(key, l1MessagePrefix) && len(key) == len(l1MessagePrefix)+8:
388389
l1Messages.Add(size)
390+
case bytes.HasPrefix(key, l1MessageLegacyPrefix) && len(key) == len(l1MessageLegacyPrefix)+8:
391+
l1MessagesOld.Add(size)
389392
case bytes.HasPrefix(key, firstQueueIndexNotInL2BlockPrefix) && len(key) == len(firstQueueIndexNotInL2BlockPrefix)+common.HashLength:
390393
lastL1Message.Add(size)
391394
case bytes.HasPrefix(key, []byte("cht-")) ||
@@ -451,6 +454,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
451454
{"Key-Value store", "Clique snapshots", cliqueSnaps.Size(), cliqueSnaps.Count()},
452455
{"Key-Value store", "Singleton metadata", metadata.Size(), metadata.Count()},
453456
{"Key-Value store", "L1 messages", l1Messages.Size(), l1Messages.Count()},
457+
{"Key-Value store", "L1 messages (legacy prefix)", l1MessagesOld.Size(), l1MessagesOld.Count()},
454458
{"Key-Value store", "Last L1 message", lastL1Message.Size(), lastL1Message.Count()},
455459
{"Ancient store", "Headers", ancientHeadersSize.String(), ancients.String()},
456460
{"Ancient store", "Bodies", ancientBodiesSize.String(), ancients.String()},

core/rawdb/schema.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ var (
105105

106106
// Scroll L1 message store
107107
syncedL1BlockNumberKey = []byte("LastSyncedL1BlockNumber")
108-
l1MessagePrefix = []byte("l1") // l1MessagePrefix + queueIndex (uint64 big endian) -> L1MessageTx
108+
l1MessageLegacyPrefix = []byte("l1")
109+
l1MessagePrefix = []byte("L1") // l1MessagePrefix + queueIndex (uint64 big endian) -> L1MessageTx
109110
firstQueueIndexNotInL2BlockPrefix = []byte("q") // firstQueueIndexNotInL2BlockPrefix + L2 block hash -> enqueue index
110111
highestSyncedQueueIndexKey = []byte("HighestSyncedQueueIndex")
111112

@@ -118,6 +119,13 @@ var (
118119
skippedTransactionHashPrefix = []byte("sh") // skippedTransactionHashPrefix + index -> tx hash
119120
)
120121

122+
// Use the updated "L1" prefix on all new networks
123+
// to avoid overlap with txLookupPrefix.
124+
// Use the legacy "l1" prefix on Scroll Sepolia.
125+
func SetL1MessageLegacyPrefix() {
126+
l1MessagePrefix = l1MessageLegacyPrefix
127+
}
128+
121129
const (
122130
// freezerHeaderTable indicates the name of the freezer header table.
123131
freezerHeaderTable = "headers"

params/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323

2424
const (
2525
VersionMajor = 4 // Major version component of the current release
26-
VersionMinor = 4 // Minor version component of the current release
27-
VersionPatch = 19 // Patch version component of the current release
26+
VersionMinor = 5 // Minor version component of the current release
27+
VersionPatch = 0 // Patch version component of the current release
2828
VersionMeta = "sepolia" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)