Contracts: Add contract's GenesisConfig in demo-runtime (#712)

* Add contracts to GenesisConfig in demo-runtime

* Update roots.
This commit is contained in:
Sergey Pepyakin
2018-09-11 19:10:24 +03:00
committed by Gav Wood
parent e8f4b85029
commit 7520d601e3
4 changed files with 37 additions and 4 deletions
+4 -3
View File
@@ -237,6 +237,7 @@ mod tests {
council: Some(Default::default()),
timestamp: Some(Default::default()),
treasury: Some(Default::default()),
contract: Some(Default::default()),
}.build_storage().unwrap().into()
}
@@ -262,7 +263,7 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
hex!("c2fcc528c92b3c958b0e0914f26e05f151903ed43c87f29b20f9c8f0450d7484").into(),
hex!("1f058f699ad3187bcf7e9ed8e44464d7a5added0cd912d2679b9dab2e7a04053").into(),
vec![
CheckedExtrinsic {
signed: None,
@@ -282,7 +283,7 @@ mod tests {
construct_block(
2,
block1().1,
hex!("62e5879f10338fa6136161c60ae0ffc35936f7b8c3fdb38095ddd0e044309762").into(),
hex!("29fa1d0aa83662c571315af54b106c73823a31f759793803bf8929960b67b138").into(),
vec![
CheckedExtrinsic {
signed: None,
@@ -307,7 +308,7 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
hex!("789b19bc7beaa83ae70412f65ad0ac02435fd79e0226ba3394865a052e56fbd8").into(),
hex!("fe0e07c7b054fe186387461d455d536860e9c71d6979fd9dbf755e96ce070d04").into(),
vec![
CheckedExtrinsic {
signed: None,
+1
View File
@@ -278,6 +278,7 @@ impl_outer_config! {
pub struct GenesisConfig for Runtime {
SystemConfig => system,
ConsensusConfig => consensus,
ContractConfig => contract,
BalancesConfig => balances,
TimestampConfig => timestamp,
SessionConfig => session,
+18 -1
View File
@@ -19,7 +19,8 @@
use ed25519;
use primitives::AuthorityId;
use demo_runtime::{GenesisConfig, ConsensusConfig, CouncilConfig, DemocracyConfig,
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, TreasuryConfig, Permill};
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, TreasuryConfig,
ContractConfig, Permill};
use service::ChainSpec;
const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
@@ -98,6 +99,14 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
spend_period: 12 * 60 * 24,
burn: Permill::from_percent(50),
}),
contract: Some(ContractConfig {
contract_fee: 21,
call_base_fee: 135,
create_base_fee: 175,
gas_price: 1,
max_depth: 1024,
block_gas_limit: 10_000_000,
}),
}
}
@@ -183,6 +192,14 @@ fn testnet_genesis(initial_authorities: Vec<AuthorityId>) -> GenesisConfig {
spend_period: 12 * 60 * 24,
burn: Permill::from_percent(50),
}),
contract: Some(ContractConfig {
contract_fee: 21,
call_base_fee: 135,
create_base_fee: 175,
gas_price: 1,
max_depth: 1024,
block_gas_limit: 10_000_000,
}),
}
}
@@ -21,6 +21,7 @@
use {Trait, ContractFee, CallBaseFee, CreateBaseFee, GasPrice, MaxDepth, BlockGasLimit};
use runtime_primitives;
use runtime_primitives::traits::As;
use runtime_io::{self, twox_128};
use runtime_support::StorageValue;
use codec::Encode;
@@ -39,6 +40,19 @@ pub struct GenesisConfig<T: Trait> {
pub block_gas_limit: T::Gas,
}
impl<T: Trait> Default for GenesisConfig<T> {
fn default() -> Self {
GenesisConfig {
contract_fee: T::Balance::sa(21),
call_base_fee: T::Gas::sa(135),
create_base_fee: T::Gas::sa(175),
gas_price: T::Balance::sa(1),
max_depth: 100,
block_gas_limit: T::Gas::sa(1_000_000),
}
}
}
impl<T: Trait> runtime_primitives::BuildStorage for GenesisConfig<T> {
fn build_storage(self) -> ::std::result::Result<HashMap<Vec<u8>, Vec<u8>>, String> {
let r: runtime_io::TestExternalities<Blake2Hasher> = map![