From 39114d67d91e0b37898cbc04aeaf95c26039410f Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Wed, 31 Jul 2024 13:01:11 +0200 Subject: [PATCH 1/4] Increase authoring duration to 2s --- client/service-container-chain/src/service.rs | 3 +-- node/src/service.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/client/service-container-chain/src/service.rs b/client/service-container-chain/src/service.rs index d60edfd6b..17cbac417 100644 --- a/client/service-container-chain/src/service.rs +++ b/client/service-container-chain/src/service.rs @@ -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. diff --git a/node/src/service.rs b/node/src/service.rs index 2905d4d9f..d3cfb181b 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -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(), From 447123f5d55e30af5650e7dbed4a9406f32baca8 Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Thu, 1 Aug 2024 10:08:13 +0200 Subject: [PATCH 2/4] Increase block weight to 2s (x4 from 0.5s) --- container-chains/runtime-templates/frontier/src/lib.rs | 8 ++++---- container-chains/runtime-templates/simple/src/lib.rs | 4 ++-- runtime/dancebox/src/lib.rs | 4 ++-- runtime/flashbox/src/lib.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/container-chains/runtime-templates/frontier/src/lib.rs b/container-chains/runtime-templates/frontier/src/lib.rs index 2a03e4b80..546505a78 100644 --- a/container-chains/runtime-templates/frontier/src/lib.rs +++ b/container-chains/runtime-templates/frontier/src/lib.rs @@ -372,14 +372,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")] diff --git a/container-chains/runtime-templates/simple/src/lib.rs b/container-chains/runtime-templates/simple/src/lib.rs index c472530f4..ab3d03e29 100644 --- a/container-chains/runtime-templates/simple/src/lib.rs +++ b/container-chains/runtime-templates/simple/src/lib.rs @@ -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, ); diff --git a/runtime/dancebox/src/lib.rs b/runtime/dancebox/src/lib.rs index a22105959..d50be43b5 100644 --- a/runtime/dancebox/src/lib.rs +++ b/runtime/dancebox/src/lib.rs @@ -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, ); diff --git a/runtime/flashbox/src/lib.rs b/runtime/flashbox/src/lib.rs index 381d099f0..6adcf3650 100644 --- a/runtime/flashbox/src/lib.rs +++ b/runtime/flashbox/src/lib.rs @@ -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, ); From 304e868646034af99f4c847dfc258746eb9027f2 Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Thu, 1 Aug 2024 11:00:54 +0200 Subject: [PATCH 3/4] Make frontier template gas limit parametric instead of hardcoded Results in 60M, a 4x increase from the previous 15M --- .../runtime-templates/frontier/src/lib.rs | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/container-chains/runtime-templates/frontier/src/lib.rs b/container-chains/runtime-templates/frontier/src/lib.rs index 546505a78..e06803d2a 100644 --- a/container-chains/runtime-templates/frontier/src/lib.rs +++ b/container-chains/runtime-templates/frontier/src/lib.rs @@ -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, @@ -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; @@ -831,10 +827,28 @@ impl FindAuthor 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 = 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); + /// The amount of gas per pov. A ratio of 4 if we convert ref_time to gas and we compare + /// it with the pov_size for a block. E.g. + /// ceil( + /// (max_extrinsic.ref_time() / max_extrinsic.proof_size()) / WEIGHT_PER_GAS + /// ) + /// We should re-check `xcm_config::Erc20XcmBridgeTransferGasLimit` when changing this value + pub const GasLimitPovSizeRatio: u64 = 8; pub SuicideQuickClearLimit: u32 = 0; } @@ -863,8 +877,7 @@ impl pallet_evm::Config for Runtime { type OnChargeTransaction = OnChargeEVMTransaction<()>; type OnCreate = (); type FindAuthor = FindAuthorAdapter; - // TODO: update in the future - type GasLimitPovSizeRatio = (); + type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type SuicideQuickClearLimit = SuicideQuickClearLimit; type Timestamp = Timestamp; type WeightInfo = (); From e1c617310f58f6d7cf0665694d6b9d7291f035eb Mon Sep 17 00:00:00 2001 From: Tomasz Polaczyk Date: Thu, 1 Aug 2024 11:15:05 +0200 Subject: [PATCH 4/4] Undo GasLimitPovSizeRatio, breaks tests --- container-chains/runtime-templates/frontier/src/lib.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/container-chains/runtime-templates/frontier/src/lib.rs b/container-chains/runtime-templates/frontier/src/lib.rs index e06803d2a..8e7de63b7 100644 --- a/container-chains/runtime-templates/frontier/src/lib.rs +++ b/container-chains/runtime-templates/frontier/src/lib.rs @@ -842,13 +842,6 @@ parameter_types! { = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); pub PrecompilesValue: TemplatePrecompiles = TemplatePrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); - /// The amount of gas per pov. A ratio of 4 if we convert ref_time to gas and we compare - /// it with the pov_size for a block. E.g. - /// ceil( - /// (max_extrinsic.ref_time() / max_extrinsic.proof_size()) / WEIGHT_PER_GAS - /// ) - /// We should re-check `xcm_config::Erc20XcmBridgeTransferGasLimit` when changing this value - pub const GasLimitPovSizeRatio: u64 = 8; pub SuicideQuickClearLimit: u32 = 0; } @@ -877,7 +870,8 @@ impl pallet_evm::Config for Runtime { type OnChargeTransaction = OnChargeEVMTransaction<()>; type OnCreate = (); type FindAuthor = FindAuthorAdapter; - type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + // TODO: update in the future + type GasLimitPovSizeRatio = (); type SuicideQuickClearLimit = SuicideQuickClearLimit; type Timestamp = Timestamp; type WeightInfo = ();