-
Notifications
You must be signed in to change notification settings - Fork 76
Feature/add no reorg #822
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
Feature/add no reorg #822
Changes from 5 commits
b68e1de
b2dd06c
aebf02b
39e853b
41e5537
3bba436
653362f
2376c1c
f28e7a6
e09ca63
e642f23
37ed3d2
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 |
|---|---|---|
|
|
@@ -27,9 +27,10 @@ pub fn block_with_state_update_pipeline( | |
| batch_size: usize, | ||
| keep_pre_v0_13_2_hashes: bool, | ||
| sync_bouncer_config: bool, | ||
| no_reorg: bool, | ||
| ) -> GatewayBlockSync { | ||
| PipelineController::new( | ||
| GatewaySyncSteps { _backend: backend, importer, client, keep_pre_v0_13_2_hashes, sync_bouncer_config }, | ||
| GatewaySyncSteps { _backend: backend, importer, client, keep_pre_v0_13_2_hashes, sync_bouncer_config, no_reorg }, | ||
| parallelization, | ||
| batch_size, | ||
| starting_block_n, | ||
|
|
@@ -43,6 +44,7 @@ pub struct GatewaySyncSteps { | |
| client: Arc<GatewayProvider>, | ||
| keep_pre_v0_13_2_hashes: bool, | ||
| sync_bouncer_config: bool, | ||
| no_reorg: bool, | ||
| } | ||
|
|
||
| impl GatewaySyncSteps { | ||
|
|
@@ -290,6 +292,25 @@ impl PipelineSteps for GatewaySyncSteps { | |
| block_n, incoming_parent_hash, local_parent_hash | ||
| ); | ||
|
|
||
| // Check if reorg is disabled | ||
| if self.no_reorg { | ||
| tracing::error!("❌ REORG DETECTED but --no-reorg flag is enabled!"); | ||
| tracing::error!(" Block number: {}", block_n); | ||
| tracing::error!(" Expected parent hash: {:#x}", local_parent_hash); | ||
| tracing::error!(" Incoming parent hash: {:#x}", incoming_parent_hash); | ||
| tracing::error!(""); | ||
| tracing::error!("⚠️ Divergent state detected - the local chain has diverged from the upstream chain."); | ||
| tracing::error!("⚠️ Blockchain reorganization is required but disabled by --no-reorg flag."); | ||
|
||
| tracing::error!(""); | ||
| tracing::error!("To resolve this issue, you can:"); | ||
| tracing::error!(" 1. Remove the --no-reorg flag to allow automatic reorganization"); | ||
| tracing::error!(" 2. Manually investigate the divergence and wipe the database if needed"); | ||
| anyhow::bail!( | ||
| "Reorg required but disabled by --no-reorg flag. Parent hash mismatch at block {}: expected {:#x}, got {:#x}", | ||
| block_n, local_parent_hash, incoming_parent_hash | ||
| ); | ||
| } | ||
|
|
||
| // Try to find common ancestor | ||
| match self.find_common_ancestor(block_n - 1).await { | ||
| Ok(common_ancestor_hash) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -74,6 +74,12 @@ pub struct L2SyncParams { | |||||
| /// Enable bouncer config syncing. | ||||||
| #[arg(env = "MADARA_ENABLE_BOUNCER_CONFIG_SYNCING", long, default_value_t = false)] | ||||||
| pub bouncer_config_sync_enable: bool, | ||||||
|
|
||||||
| /// Disable blockchain reorganization. When enabled, if a divergent state is discovered, | ||||||
| /// the node will stop with an error instead of performing a reorg. This is useful for | ||||||
| /// operators who want to manually handle chain divergences. | ||||||
| #[clap(env = "MADARA_NO_REORG", long, default_value_t = true)] | ||||||
| pub no_reorg: bool, | ||||||
|
||||||
| pub no_reorg: bool, | |
| pub disable_reorg: bool, |
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.
nitpick : Let's re-write ->
--no-reorg flagto
Reorganisation is explicitly denied by configor something that suite you better maybeThere 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.
disagree! previous message was more specific,
--no-reorgflag disabled reorging