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

Fix reorg on init flags #2538

Merged
merged 5 commits into from
Aug 2, 2024
Merged

Fix reorg on init flags #2538

merged 5 commits into from
Aug 2, 2024

Conversation

PlasmaPower
Copy link
Collaborator

@PlasmaPower PlasmaPower commented Jul 30, 2024

This is a successor to #2036 which only reorgs to batch boundaries, as suggested there.

NIT-2710

@PlasmaPower PlasmaPower requested a review from tsahee July 30, 2024 23:14
@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Jul 30, 2024
@PlasmaPower PlasmaPower changed the title Fix reorg on init flags [NIT-2710] Fix reorg on init flags Jul 30, 2024
@PlasmaPower PlasmaPower changed the title [NIT-2710] Fix reorg on init flags Fix reorg on init flags Jul 30, 2024
f.Uint64(prefix+".recreate-missing-state-from", InitConfigDefault.RecreateMissingStateFrom, "block number to start recreating missing states from (0 = disabled)")
f.Bool(prefix+".rebuild-local-wasm", InitConfigDefault.RebuildLocalWasm, "rebuild local wasm database on boot if needed (otherwise-will be done lazily)")
f.Int64(prefix+".reorg-to-batch", InitConfigDefault.ReorgToBatch, "rolls back the blockchain to a specified batch number")
f.Int64(prefix+".reorg-to-message-batch", InitConfigDefault.ReorgToMessageBatch, "rolls back the blockchain to the first batch at or before a given message index")
f.Int64(prefix+".reorg-to-block-batch", InitConfigDefault.ReorgToBlockBatch, "rolls back the blockchain to the first batch at or before a given block number")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to Validate() a test that at most one of those is >= 0

@@ -70,6 +70,7 @@ type FullExecutionClient interface {
Maintenance() error

ArbOSVersionForMessageNumber(messageNum arbutil.MessageIndex) (uint64, error)
BlockNumberToMessageIndex(blockNum uint64) (arbutil.MessageIndex, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that reorg is a good enough reason to add it to the API.
reorg-to-*batch will always be an advanced functionality, that should only be used by those who know what they are doing. I don't mind making it a little harder.

We should make genesis-block-number be easy to find. It's in chain-config which sounds reasonable.. maybe we should print chain config on init so it'll be even easier to find?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most 3rd party providers only really know block numbers. Is there a significant downside to adding this interface? It seems generally useful to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this a bit more, we have access to the chain config directly here, so I switched to using that instead and removed this interface


// If not started, use a background context.
// This can happening when reorging on startup using the init flag.
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should no longer be necessary, since now reorg happends after Start

Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PlasmaPower PlasmaPower enabled auto-merge August 2, 2024 18:05
@PlasmaPower PlasmaPower merged commit 77cd88d into master Aug 2, 2024
13 checks passed
@PlasmaPower PlasmaPower deleted the fix-init-reorg branch August 2, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-approved s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants