diff --git a/runtime/common/src/constants.rs b/runtime/common/src/constants.rs index 135e5bad62db4acbad6a182b07e128ca31d5aa24..77de932695ffab296c72b9370b92ff4f2bda96ed 100644 --- a/runtime/common/src/constants.rs +++ b/runtime/common/src/constants.rs @@ -15,7 +15,6 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use crate::{Balance, BlockNumber}; -use frame_support::weights::Weight; use sp_runtime::Perbill; pub use crate::weights::paritydb_weights::constants::ParityDbWeight as DbWeight; @@ -61,32 +60,3 @@ pub const fn deposit(items: u32, bytes: u32) -> Balance { // Maximal weight proportion of normal extrinsics per block pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - -// WEIGHTS CONSTANTS // - -// Block weights limits -pub fn block_weights( - expected_block_weight: Weight, - normal_ratio: sp_arithmetic::Perbill, -) -> frame_system::limits::BlockWeights { - let base_weight = crate::weights::extrinsic_weights::ExtrinsicBaseWeight::get(); - let normal_weight = normal_ratio * expected_block_weight; - frame_system::limits::BlockWeights::builder() - .base_block(crate::weights::block_weights::BlockExecutionWeight::get()) - .for_class(frame_support::dispatch::DispatchClass::all(), |weights| { - weights.base_extrinsic = base_weight; - }) - .for_class(frame_support::dispatch::DispatchClass::Normal, |weights| { - weights.max_total = normal_weight.into(); - }) - .for_class( - frame_support::dispatch::DispatchClass::Operational, - |weights| { - weights.max_total = expected_block_weight.into(); - weights.reserved = (expected_block_weight - normal_weight).into(); - }, - ) - .avg_block_initialization(sp_arithmetic::Perbill::from_percent(10)) - .build() - .expect("Fatal error: invalid BlockWeights configuration") -} diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs index 280a9f728368e0720ab660e7907f7d031d9c1b71..4be9a23615cb9dd9a6e504f5a959c3127ff079e1 100644 --- a/runtime/g1/src/parameters.rs +++ b/runtime/g1/src/parameters.rs @@ -22,8 +22,7 @@ use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { pub const BlockHashCount: BlockNumber = 2400; /// We allow for 2 seconds of compute with a 6 second average block time. - pub BlockWeights: frame_system::limits::BlockWeights = block_weights((Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND, 0) * 2) - .set_proof_size(5 * 1024 * 1024), NORMAL_DISPATCH_RATIO); + pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::with_sensible_defaults(Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND * 2u64, u64::MAX), NORMAL_DISPATCH_RATIO); pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub const SS58Prefix: u16 = 4450; diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs index 6ff9b244d0b3e8fcee6b9c10fe5ccda747044fa7..1d95aeb66ebad8ace544571dd47d90f4d0a03122 100644 --- a/runtime/gdev/src/parameters.rs +++ b/runtime/gdev/src/parameters.rs @@ -24,8 +24,7 @@ use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { pub const BlockHashCount: BlockNumber = 2400; /// We allow for 2 seconds of compute with a 6 second average block time. - pub BlockWeights: frame_system::limits::BlockWeights = block_weights((Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND, 0) * 2) - .set_proof_size(5 * 1024 * 1024), NORMAL_DISPATCH_RATIO); + pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::with_sensible_defaults(Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND * 2u64, u64::MAX), NORMAL_DISPATCH_RATIO); pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub const SS58Prefix: u16 = 42; diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs index c32a78c250b3942c16c0e8627e24d2477f7d24b7..6539fa51d5b8b7708a5e329c2682df51eeed9fc0 100644 --- a/runtime/gtest/src/parameters.rs +++ b/runtime/gtest/src/parameters.rs @@ -22,8 +22,7 @@ use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { pub const BlockHashCount: BlockNumber = 2400; /// We allow for 2 seconds of compute with a 6 second average block time. - pub BlockWeights: frame_system::limits::BlockWeights = block_weights((Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND, 0) * 2) - .set_proof_size(5 * 1024 * 1024), NORMAL_DISPATCH_RATIO); + pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::with_sensible_defaults(Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND * 2u64, u64::MAX), NORMAL_DISPATCH_RATIO); pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub const SS58Prefix: u16 = 42;