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

Increase authoring duration to 2s and block weight limit x4 #640

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions client/service-container-chain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ fn start_consensus_container(
relay_chain_slot_duration,
proposer,
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(500),
authoring_duration: Duration::from_millis(2000),
para_backend: backend,
code_hash_provider,
// This cancellation token is no-op as it is not shared outside.
Expand Down
27 changes: 17 additions & 10 deletions container-chains/runtime-templates/frontier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use {
cumulus_primitives_core::AggregateMessageOrigin,
dp_impl_tanssi_pallets_config::impl_tanssi_pallets_config,
fp_account::EthereumSignature,
fp_evm::weight_per_gas,
fp_rpc::TransactionStatus,
frame_support::{
construct_runtime,
Expand Down Expand Up @@ -372,14 +371,14 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
/// `Operational` extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// We allow for 0.5 of a second of compute with a 12 second average block time.
/// We allow for 2 seconds of compute with a 6 second average block time
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

/// We allow for 500ms of compute with a 12 second average block time.
pub const WEIGHT_MILLISECS_PER_BLOCK: u64 = 500;
/// We allow for 2 seconds of compute with a 6 second average block time
pub const WEIGHT_MILLISECS_PER_BLOCK: u64 = 2000;

/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
Expand Down Expand Up @@ -813,9 +812,6 @@ where
}
}

// To match ethereum expectations
const BLOCK_GAS_LIMIT: u64 = 15_000_000;

impl pallet_evm_chain_id::Config for Runtime {}

pub struct FindAuthorAdapter;
Expand All @@ -831,10 +827,21 @@ impl FindAuthor<H160> for FindAuthorAdapter {
}
}

/// Current approximation of the gas/s consumption considering
/// EVM execution over compiled WASM (on 4.4Ghz CPU).
/// Given the 1000ms Weight, from which 75% only are used for transactions,
/// the total EVM execution gas limit is: GAS_PER_SECOND * 1 * 0.75 ~= 30_000_000.
pub const GAS_PER_SECOND: u64 = 40_000_000;

/// Approximate ratio of the amount of Weight per Gas.
/// u64 works for approximations because Weight is a very small unit compared to gas.
pub const WEIGHT_PER_GAS: u64 = WEIGHT_REF_TIME_PER_SECOND / GAS_PER_SECOND;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT);
pub BlockGasLimit: U256
= U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS);
pub PrecompilesValue: TemplatePrecompiles<Runtime> = TemplatePrecompiles::<_>::new();
pub WeightPerGas: Weight = Weight::from_parts(weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK), 0);
pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0);
pub SuicideQuickClearLimit: u32 = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions container-chains/runtime-templates/simple/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
/// `Operational` extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// We allow for 0.5 of a second of compute with a 12 second average block time.
/// We allow for 2 seconds of compute with a 6 second average block time
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

Expand Down
3 changes: 1 addition & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,7 @@ fn start_consensus_orchestrator(
force_authoring,
proposer,
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(500),
authoring_duration: Duration::from_millis(2000),
code_hash_provider,
para_backend: backend,
cancellation_token: cancellation_token.clone(),
Expand Down
4 changes: 2 additions & 2 deletions runtime/dancebox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
/// `Operational` extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// We allow for 0.5 of a second of compute with a 12 second average block time.
/// We allow for 2 seconds of compute with a 6 second average block time
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

Expand Down
4 changes: 2 additions & 2 deletions runtime/flashbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
/// `Operational` extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// We allow for 0.5 of a second of compute with a 12 second average block time.
/// We allow for 2 seconds of compute with a 6 second average block time
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

Expand Down
Loading