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
@@ -36,8 +36,7 @@ use std::{borrow::Cow, u64};
use std::time::Duration;
use futures::channel::mpsc;
use polkadot_node_primitives::MAX_POV_SIZE;
use polkadot_primitives::v1::MAX_CODE_SIZE;
use polkadot_primitives::v1::{MAX_CODE_SIZE, MAX_POV_SIZE};
use strum::EnumIter;
pub use sc_network::config as network;
+3 -6
View File
@@ -41,7 +41,7 @@ use polkadot_primitives::v1::{
CompactStatement, EncodeAs, Hash, HashT, HeadData, Id as ParaId, OutboundHrmpMessage,
PersistedValidationData, Signed, UncheckedSigned, UpwardMessage, ValidationCode,
ValidatorIndex, ValidatorSignature, ValidDisputeStatementKind, InvalidDisputeStatementKind,
CandidateReceipt, ValidatorId, SessionIndex, DisputeStatement,
CandidateReceipt, ValidatorId, SessionIndex, DisputeStatement, MAX_CODE_SIZE, MAX_POV_SIZE,
};
pub use polkadot_parachain::primitives::BlockData;
@@ -49,13 +49,10 @@ pub use polkadot_parachain::primitives::BlockData;
pub mod approval;
/// The bomb limit for decompressing code blobs.
pub const VALIDATION_CODE_BOMB_LIMIT: usize = 16 * 1024 * 1024;
/// Maximum PoV size we support right now.
pub const MAX_POV_SIZE: u32 = 20 * 1024 * 1024;
pub const VALIDATION_CODE_BOMB_LIMIT: usize = (MAX_CODE_SIZE * 4u32) as usize;
/// The bomb limit for decompressing PoV blobs.
pub const POV_BOMB_LIMIT: usize = MAX_POV_SIZE as usize;
pub const POV_BOMB_LIMIT: usize = (MAX_POV_SIZE * 4u32) as usize;
/// The cumulative weight of a block in a fork-choice rule.
pub type BlockWeight = u32;
+1 -2
View File
@@ -149,8 +149,7 @@ pub fn wococo_config() -> Result<RococoChainSpec, String> {
fn default_parachains_host_configuration() ->
polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::v1::BlockNumber>
{
use polkadot_node_primitives::MAX_POV_SIZE;
use polkadot_primitives::v1::MAX_CODE_SIZE;
use polkadot_primitives::v1::{MAX_CODE_SIZE, MAX_POV_SIZE};
polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_frequency: 1u32,
+3 -3
View File
@@ -20,7 +20,7 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use babe_primitives::AuthorityId as BabeId;
use grandpa::AuthorityId as GrandpaId;
use pallet_staking::Forcing;
use polkadot_primitives::v1::{ValidatorId, AccountId, AssignmentId};
use polkadot_primitives::v1::{ValidatorId, AccountId, AssignmentId, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions};
use polkadot_test_runtime::{constants::currency::DOTS, BABE_GENESIS_EPOCH_CONFIG};
use sc_chain_spec::{ChainSpec, ChainType};
@@ -179,8 +179,8 @@ fn polkadot_testnet_genesis(
validation_upgrade_frequency: 10u32,
validation_upgrade_delay: 5,
code_retention_period: 1200,
max_code_size: 5 * 1024 * 1024,
max_pov_size: 50 * 1024 * 1024,
max_code_size: MAX_CODE_SIZE,
max_pov_size: MAX_POV_SIZE,
max_head_data_size: 32 * 1024,
group_rotation_frequency: 20,
chain_availability_period: 4,