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(block_time): block time can no longer be less than pending block update time #447

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions crates/madara/node/src/cli/chain_config_overrides.rs
Trantorian1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -24,6 +24,61 @@ 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...
Trantorian1 marked this conversation as resolved.
Show resolved Hide resolved
///
/// Parameters:
///
/// * chain_name: the name of the chain.
///
/// * chain_id: unique identifier for the chain, for example 'SN_MAIN'.
///
/// * feeder_gateway_url: default fgw for this chain.
///
/// * gateway url: default gw for this chain.
///
/// * native_fee_token_address: on-chain address of this chain's native
/// token
///
/// * parent_fee_token_address: on-chain address of the native token of
/// this chain's settlement layer.
///
/// * latest_protocol_version: latest version of the chain, update on new
/// method release, consensus change, etc...
///
/// * block_time: time it takes to close a block.
///
/// * pending_block_update_time: time interval at which the pending block
/// is updated. This is also referred to internally as a 'tick'. The
/// block update time should always be inferior to the block time.
///
/// * execution_batch_size: number of transaction to process in a single
/// tick.
///
/// * bouncer_config: execution limits per block. This has to be
/// yaml-encoded following the format in yaml chain config files.
///
/// * sequencer_address: the address of this chain's sequencer.
///
/// * eth_core_contract_address: address of the core contract on the
/// settlement layer.
///
/// * eth_gps_statement_verifier: address of the verifier contract on the
/// settlement layer.
///
/// * private_key: private key used by the node in sequencer mode to sign
/// the blocks it provides. This is zeroed.
///
/// * mempool_tx_limit: max number of transactions allowed in the mempool
/// in sequencer mode.
///
/// * mempool_declare_tx_limit: max number of declare transactions allowed
/// in sequencer mode.
///
/// * mempool_tx_max_age: max age of transactions in the mempool.
/// Transactions which are too old will be removed.
#[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)>,
}
1 change: 1 addition & 0 deletions crates/madara/node/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -204,6 +204,7 @@ pub struct RunCmd {
pub preset: Option<ChainPreset>,

/// Overrides parameters from the Chain Config.
#[allow(missing_docs)]
Trantorian1 marked this conversation as resolved.
Show resolved Hide resolved
#[clap(flatten)]
pub chain_config_override: ChainConfigOverrideParams,
}
10 changes: 10 additions & 0 deletions crates/madara/node/src/main.rs
Original file line number Diff line number Diff line change
@@ -51,6 +51,16 @@ 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 {
anyhow::bail!(
"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()
);
}

// Check if the devnet is running with the correct chain id. This is purely
// to avoid accidental setups which would allow for replay attacks. This is
// possible if the devnet has the same chain id as another popular chain,