-
Notifications
You must be signed in to change notification settings - Fork 475
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
Fix reorg on init flags #2538
Changes from 1 commit
5520c13
1262672
ac6ea21
ebb7848
b50b326
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,9 +30,11 @@ type InitConfig struct { | |
PruneBloomSize uint64 `koanf:"prune-bloom-size"` | ||
PruneThreads int `koanf:"prune-threads"` | ||
PruneTrieCleanCache int `koanf:"prune-trie-clean-cache"` | ||
ResetToMessage int64 `koanf:"reset-to-message"` | ||
RecreateMissingStateFrom uint64 `koanf:"recreate-missing-state-from"` | ||
RebuildLocalWasm bool `koanf:"rebuild-local-wasm"` | ||
ReorgToBatch int64 `koanf:"reorg-to-batch"` | ||
ReorgToMessageBatch int64 `koanf:"reorg-to-message-batch"` | ||
ReorgToBlockBatch int64 `koanf:"reorg-to-block-batch"` | ||
} | ||
|
||
var InitConfigDefault = InitConfig{ | ||
|
@@ -54,9 +56,11 @@ var InitConfigDefault = InitConfig{ | |
PruneBloomSize: 2048, | ||
PruneThreads: runtime.NumCPU(), | ||
PruneTrieCleanCache: gethexec.DefaultCachingConfig.TrieCleanCache, | ||
ResetToMessage: -1, | ||
RecreateMissingStateFrom: 0, // 0 = disabled | ||
RebuildLocalWasm: true, | ||
ReorgToBatch: -1, | ||
ReorgToMessageBatch: -1, | ||
ReorgToBlockBatch: -1, | ||
} | ||
|
||
func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { | ||
|
@@ -78,9 +82,11 @@ func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { | |
f.Uint64(prefix+".prune-bloom-size", InitConfigDefault.PruneBloomSize, "the amount of memory in megabytes to use for the pruning bloom filter (higher values prune better)") | ||
f.Int(prefix+".prune-threads", InitConfigDefault.PruneThreads, "the number of threads to use when pruning") | ||
f.Int(prefix+".prune-trie-clean-cache", InitConfigDefault.PruneTrieCleanCache, "amount of memory in megabytes to cache unchanged state trie nodes with when traversing state database during pruning") | ||
f.Int64(prefix+".reset-to-message", InitConfigDefault.ResetToMessage, "forces a reset to an old message height. Also set max-reorg-resequence-depth=0 to force re-reading messages") | ||
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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
|
||
func (c *InitConfig) Validate() error { | ||
|
@@ -99,6 +105,10 @@ func (c *InitConfig) Validate() error { | |
return nil | ||
} | ||
|
||
func (c *InitConfig) IsReorgRequested() bool { | ||
return c.ReorgToBatch >= 0 || c.ReorgToBlockBatch >= 0 || c.ReorgToMessageBatch >= 0 | ||
} | ||
|
||
var ( | ||
acceptedSnapshotKinds = []string{"archive", "pruned", "genesis"} | ||
acceptedSnapshotKindsStr = "(accepted values: \"" + strings.Join(acceptedSnapshotKinds, "\" | \"") + "\")" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ type FullExecutionClient interface { | |
Maintenance() error | ||
|
||
ArbOSVersionForMessageNumber(messageNum arbutil.MessageIndex) (uint64, error) | ||
BlockNumberToMessageIndex(blockNum uint64) (arbutil.MessageIndex, error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
|
||
// not implemented in execution, used as input | ||
|
There was a problem hiding this comment.
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