contracts: Move Schedule from Storage to Config (#8773)

* Move `Schedule` from Storage to Config

* Updated CHANGELOG

* Fix nits from review

* Fix migration

* Print the debug buffer as tracing message

* Use `debug` instead of `trace` and update README

* Add additional assert to test

* Rename `schedule_version` to `instruction_weights_version`

* Fixed typo

* Added more comments to wat fixtures

* Add clarification for the `debug_message` field
This commit is contained in:
Alexander Theißen
2021-05-13 21:56:11 +02:00
committed by GitHub
parent 3c0270fe57
commit 1ac95b6ba6
23 changed files with 1465 additions and 1056 deletions
+2 -11
View File
@@ -22,7 +22,7 @@ use sc_chain_spec::ChainSpecExtension;
use sp_core::{Pair, Public, crypto::UncheckedInto, sr25519};
use serde::{Serialize, Deserialize};
use node_runtime::{
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig,
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, CouncilConfig,
DemocracyConfig, GrandpaConfig, ImOnlineConfig, SessionConfig, SessionKeys, StakerStatus,
StakingConfig, ElectionsConfig, IndicesConfig, SocietyConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, wasm_binary_unwrap, MAX_NOMINATIONS,
@@ -146,7 +146,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
let endowed_accounts: Vec<AccountId> = vec![root_key.clone()];
testnet_genesis(initial_authorities, vec![], root_key, Some(endowed_accounts), false)
testnet_genesis(initial_authorities, vec![], root_key, Some(endowed_accounts))
}
/// Staging testnet config.
@@ -212,7 +212,6 @@ pub fn testnet_genesis(
initial_nominators: Vec<AccountId>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
enable_println: bool,
) -> GenesisConfig {
let mut endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
vec![
@@ -308,11 +307,6 @@ pub fn testnet_genesis(
.collect(),
phantom: Default::default(),
},
pallet_contracts: ContractsConfig {
// println should only be enabled on development chains
current_schedule: pallet_contracts::Schedule::default()
.enable_println(enable_println),
},
pallet_sudo: SudoConfig {
key: root_key,
},
@@ -352,7 +346,6 @@ fn development_config_genesis() -> GenesisConfig {
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
true,
)
}
@@ -380,7 +373,6 @@ fn local_testnet_genesis() -> GenesisConfig {
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
false,
)
}
@@ -414,7 +406,6 @@ pub(crate) mod tests {
vec![],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
false,
)
}
+5 -6
View File
@@ -793,7 +793,7 @@ parameter_types! {
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
)) / 5) as u32;
pub MaxCodeSize: u32 = 128 * 1024;
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
}
impl pallet_contracts::Config for Runtime {
@@ -810,13 +810,12 @@ impl pallet_contracts::Config for Runtime {
type RentFraction = RentFraction;
type SurchargeReward = SurchargeReward;
type CallStack = [pallet_contracts::Frame<Self>; 31];
type MaxValueSize = MaxValueSize;
type WeightPrice = pallet_transaction_payment::Module<Self>;
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
type ChainExtension = ();
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionWeightLimit = DeletionWeightLimit;
type MaxCodeSize = MaxCodeSize;
type Schedule = Schedule;
}
impl pallet_sudo::Config for Runtime {
@@ -1114,7 +1113,7 @@ construct_runtime!(
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},
Contracts: pallet_contracts::{Pallet, Call, Config<T>, Storage, Event<T>},
Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
@@ -1354,7 +1353,7 @@ impl_runtime_apis! {
gas_limit: u64,
input_data: Vec<u8>,
) -> pallet_contracts_primitives::ContractExecResult {
Contracts::bare_call(origin, dest, value, gas_limit, input_data)
Contracts::bare_call(origin, dest, value, gas_limit, input_data, true)
}
fn instantiate(
@@ -1366,7 +1365,7 @@ impl_runtime_apis! {
salt: Vec<u8>,
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
{
Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true)
Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, true)
}
fn get_storage(
+1 -4
View File
@@ -22,7 +22,7 @@ use crate::keyring::*;
use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
use node_runtime::{
GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, SystemConfig,
GrandpaConfig, IndicesConfig, ContractsConfig, SocietyConfig, wasm_binary_unwrap,
GrandpaConfig, IndicesConfig, SocietyConfig, wasm_binary_unwrap,
AccountId, StakerStatus, BabeConfig, BABE_GENESIS_EPOCH_CONFIG,
};
use node_runtime::constants::currency::*;
@@ -97,9 +97,6 @@ pub fn config_endowed(
invulnerables: vec![alice(), bob(), charlie()],
.. Default::default()
},
pallet_contracts: ContractsConfig {
current_schedule: Default::default(),
},
pallet_babe: BabeConfig {
authorities: vec![],
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG),