Skip to content

Commit

Permalink
fix(block_time): block time can no longer be less than pending block …
Browse files Browse the repository at this point in the history
…update time
  • Loading branch information
Trantorian1 authored and jbcaron committed Jan 5, 2025
1 parent 922d7a8 commit a6a87ad
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## Next release

- chore: Move crates under a madara subdir
- chore(nix): resolve flake and direnv compatibility issues
- fix(block_time): block time can no longer be less than pending block update time
- fix: Gateway path fix
- fix: instrumentation code
- feat: block resource cap removed from the pending tick
Expand Down
4 changes: 4 additions & 0 deletions crates/madara/node/src/cli/chain_config_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ use url::Url;
/// Format: "--chain-config-override chain_id=SN_MADARA,chain_name=MADARA,block_time=1500ms,bouncer_config.block_max_capacity.n_steps=100000000"
#[derive(Parser, Clone, Debug)]
pub struct ChainConfigOverrideParams {
/// Overrides parameters from the chain config.
///
/// Use the following syntax:
/// --chain-config-override=block_time=30s,pending_block_update_time=2s...
#[clap(env = "MADARA_CHAIN_CONFIG_OVERRIDE", long = "chain-config-override", value_parser = parse_key_value_yaml, use_value_delimiter = true, value_delimiter = ',')]
pub overrides: Vec<(String, Value)>,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/madara/node/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub struct RunCmd {
#[clap(env = "MADARA_PRESET", long, value_name = "PRESET NAME", group = "chain_config")]
pub preset: Option<ChainPreset>,

/// Overrides parameters from the Chain Config.
#[allow(missing_docs)]
#[clap(flatten)]
pub chain_config_override: ChainConfigOverrideParams,
}
Expand Down
23 changes: 20 additions & 3 deletions crates/madara/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,32 @@ async fn main() -> anyhow::Result<()> {
run_cmd.chain_config()?
};

// If block time is inferior to the tick time, then only empty blocks will
// be produced as we will never update the pending block before storing it.
if run_cmd.is_sequencer() && chain_config.block_time < chain_config.pending_block_update_time {
tracing::error!(
"Block time ({}s) cannot be less than the pending block update time ({}s), as this will yield only empty blocks",
chain_config.block_time.as_secs(),
chain_config.pending_block_update_time.as_secs()
);
anyhow::bail!("Block time");
}

// Check if the devnet is running with the correct chain id.
if run_cmd.devnet && chain_config.chain_id != NetworkType::Devnet.chain_id() {
if !run_cmd.block_production_params.override_devnet_chain_id {
tracing::error!("You're running a devnet with the network config of {:?}. This means that devnet transactions can be replayed on the actual network. Use `--network=devnet` instead. Or if this is the expected behavior please pass `--override-devnet-chain-id`", chain_config.chain_name);
panic!();
tracing::error!(
"You're running a devnet with the network config of {:?}. This means that devnet transactions can be replayed on the actual network. Use `--network=devnet` instead. Or if this is the expected behavior please pass `--override-devnet-chain-id`",
chain_config.chain_name
);
anyhow::bail!("devnet");
} else {
// This log is immediately flooded with devnet accounts and so this can be missed.
// Should we add a delay here to make this clearly visisble?
tracing::warn!("You're running a devnet with the network config of {:?}. This means that devnet transactions can be replayed on the actual network.", run_cmd.network);
tracing::warn!(
"You're running a devnet with the network config of {:?}. This means that devnet transactions can be replayed on the actual network.",
run_cmd.network
);
}
}

Expand Down

0 comments on commit a6a87ad

Please sign in to comment.