Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow changing L1 synced height via admin RPC/CLI #1044

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
40 changes: 40 additions & 0 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,3 +833,43 @@ func (api *ScrollAPI) CalculateRowConsumptionByBlockNumber(ctx context.Context,
asyncChecker.Wait()
return rawdb.ReadBlockRowConsumption(api.eth.ChainDb(), block.Hash()), checkErr
}

// SetRollupEventSyncedL1Height sets the synced L1 height for rollup event synchronization
func (api *ScrollAPI) SetRollupEventSyncedL1Height(height uint64) error {
prevHeightPtr := rawdb.ReadRollupEventSyncedL1BlockNumber(api.eth.ChainDb())

if prevHeightPtr == nil {
log.Warn("No previous rollup event synced L1 height found in database")
return fmt.Errorf("no previous rollup event synced L1 height found in database")
}

prevHeight := *prevHeightPtr
if height >= prevHeight {
log.Warn("New rollup event synced L1 height is not lower than previous height", "newHeight", height, "prevHeight", prevHeight)
return fmt.Errorf("new rollup event synced L1 height (%d) is not lower than previous height (%d)", height, prevHeight)
}

log.Info("Setting rollup event synced L1 height", "height", height)
rawdb.WriteRollupEventSyncedL1BlockNumber(api.eth.ChainDb(), height)
Thegaram marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

// SetL1MessageSyncedL1Height sets the synced L1 height for L1 message synchronization
func (api *ScrollAPI) SetL1MessageSyncedL1Height(height uint64) error {
prevHeightPtr := rawdb.ReadSyncedL1BlockNumber(api.eth.ChainDb())

if prevHeightPtr == nil {
log.Warn("No previous L1 message synced L1 height found in database")
return fmt.Errorf("no previous L1 message synced L1 height found in database")
}

prevHeight := *prevHeightPtr
if height >= prevHeight {
log.Warn("New L1 message synced L1 height is not lower than previous height", "newHeight", height, "prevHeight", prevHeight)
return fmt.Errorf("new L1 message synced L1 height (%d) is not lower than previous height (%d)", height, prevHeight)
}

log.Info("Setting L1 message synced L1 height", "height", height)
rawdb.WriteSyncedL1BlockNumber(api.eth.ChainDb(), height)
return nil
}
10 changes: 10 additions & 0 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,16 @@ web3._extend({
params: 1,
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
}),
new web3._extend.Method({
name: 'setRollupEventSyncedL1Height',
Thegaram marked this conversation as resolved.
Show resolved Hide resolved
call: 'scroll_setRollupEventSyncedL1Height',
params: 1
}),
new web3._extend.Method({
name: 'setL1MessageSyncedL1Height',
call: 'scroll_setL1MessageSyncedL1Height',
params: 1
}),
],
properties:
[
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 7 // Minor version component of the current release
VersionPatch = 17 // Patch version component of the current release
VersionPatch = 18 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

Expand Down
Loading