Skip to content

Commit

Permalink
Decreased block computation capacity (#510)
Browse files Browse the repository at this point in the history
* Decreased the block computation capacity to 2 seconds

* bumped spec_version to 26

* 100x base_weight to increase min tx cost
  • Loading branch information
ToufeeqP authored Mar 28, 2024
1 parent 1920fae commit afb3b55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pallets/system/src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl BlockWeights {
Some(Weight::zero())
};
WeightsPerClass {
base_extrinsic: constants::ExtrinsicBaseWeight::get(),
base_extrinsic: constants::ExtrinsicBaseWeight::get().saturating_mul(100),
max_extrinsic: None,
max_total: initial,
reserved: initial,
Expand Down
7 changes: 4 additions & 3 deletions runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,17 @@ pub mod system {
const MAXIMUM_BLOCK_WEIGHT: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX);

/// We allow for 5 seconds of compute with a 20 second average block time, with maximum proof size.
/// We allow for 2 (temporary) seconds of compute with a 20 second average block time, with maximum proof size.
#[cfg(not(feature = "fast-runtime"))]
const MAXIMUM_BLOCK_WEIGHT: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(5), u64::MAX);
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX);

parameter_types! {
pub RuntimeBlockWeights: SystemBlockWeights = SystemBlockWeights::builder()
.base_block(BlockExecutionWeight::get())
.for_class(DispatchClass::all(), |weights| {
weights.base_extrinsic = ExtrinsicBaseWeight::get();
// Note: To make min tx cost at least 0.1 AVAIL, BaseWeight has been increased by 100x
weights.base_extrinsic = ExtrinsicBaseWeight::get().saturating_mul(100);
})
.for_class(DispatchClass::Normal, |weights| {
weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// Per convention: if the runtime behavior changes, increment spec_version
// and set impl_version to 0. This paramenter is typically incremented when
// there's an update to the transaction_version.
spec_version: 25,
spec_version: 26,
// The version of the implementation of the specification. Nodes can ignore this. It is only
// used to indicate that the code is different. As long as the authoring_version and the
// spec_version are the same, the code itself might have changed, but the native and Wasm
Expand Down

2 comments on commit afb3b55

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: afb3b55 Previous: 33f7951 Ratio
commitment_builder/64 4198383267 ns/iter (± 167595327) 4343451680 ns/iter (± 92231152) 0.97
commitment_builder/128 4439061799 ns/iter (± 108225737) 4647446215 ns/iter (± 137494514) 0.96
commitment_builder/256 2163008265 ns/iter (± 166737475) 2367397557 ns/iter (± 42776582) 0.91

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: afb3b55 Previous: 909af7f Ratio
commitment_builder_64 Instructions 41959095454 ops (± 0) 41972869826 ops (± 0) 1.00
commitment_builder_64 L1 Accesses 51409154539 ops (± 0) 51407870438 ops (± 0) 1.00
commitment_builder_64 L2 Accesses 896874 ops (± 0) 893120 ops (± 0) 1.00
commitment_builder_64 RAM Accesses 167207 ops (± 0) 191298 ops (± 0) 0.87
commitment_builder_64 Estimated Cycles 51419491154 ops (± 0) 51419031468 ops (± 0) 1.00
commitment_builder_128 Instructions 54189539730 ops (± 0) 54204175550 ops (± 0) 1.00
commitment_builder_128 L1 Accesses 68302776842 ops (± 0) 68301951624 ops (± 0) 1.00
commitment_builder_128 L2 Accesses 1192623 ops (± 0) 1258510 ops (± 0) 0.95
commitment_builder_128 RAM Accesses 276615 ops (± 0) 242507 ops (± 0) 1.14
commitment_builder_128 Estimated Cycles 68318421482 ops (± 0) 68316731919 ops (± 0) 1.00
commitment_builder_256 Instructions 31749494478 ops (± 0) 31758548180 ops (± 0) 1.00
commitment_builder_256 L1 Accesses 40828518416 ops (± 0) 40833274463 ops (± 0) 1.00
commitment_builder_256 L2 Accesses 6712804 ops (± 0) 6788005 ops (± 0) 0.99
commitment_builder_256 RAM Accesses 268943 ops (± 0) 239352 ops (± 0) 1.12
commitment_builder_256 Estimated Cycles 40871495441 ops (± 0) 40875591808 ops (± 0) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.