Use max_code_size and max_wasm_data_size from Parachains Configuration (#3329)

* use `configuration::config()` for max bytes

* Update integration_tests.rs

* Update paras_registrar.rs

* remove consts

* add asserts for non-zero

* more const clean up

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::paras_registrar --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_paras_registrar.rs

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::paras_registrar --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_paras_registrar.rs

* add checks to `MAX_CODE_SIZE`

* re-pot MAX_POV_SIZE

* check pov limit in runtime

* POV_BOMB_LIMIT multiplier

* fix compile

* Update configuration.rs

* Update node/primitives/src/lib.rs

* fix test

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Shawn Tabrizi
2021-06-21 18:24:49 +01:00
committed by GitHub
parent 45ed52a273
commit 6b1baba490
15 changed files with 131 additions and 126 deletions
@@ -19,7 +19,7 @@
//! Configuration can change only at session boundaries and is buffered until then.
use sp_std::prelude::*;
use primitives::v1::{Balance, SessionIndex};
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_POV_SIZE};
use frame_support::{
decl_storage, decl_module, decl_error,
ensure,
@@ -243,6 +243,18 @@ impl<BlockNumber: Zero> HostConfiguration<BlockNumber> {
if self.no_show_slots.is_zero() {
panic!("`no_show_slots` must be at least 1!")
}
if self.max_code_size > MAX_CODE_SIZE {
panic!(
"`max_code_size` ({}) is bigger than allowed by the client ({})",
self.max_code_size,
MAX_CODE_SIZE,
)
}
if self.max_pov_size > MAX_POV_SIZE {
panic!("`max_pov_size` is bigger than allowed by the client")
}
}
}
@@ -308,6 +320,7 @@ decl_module! {
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_code_size(origin, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_CODE_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_code_size, new) != new
});
@@ -318,6 +331,7 @@ decl_module! {
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_pov_size(origin, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_POV_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_pov_size, new) != new
});