From 9e96c40f23b4f002434d64bdf2e19c74de5618e0 Mon Sep 17 00:00:00 2001 From: vasylenko-yevhen Date: Fri, 18 Nov 2022 15:05:57 +0200 Subject: [PATCH] Update subzero runtime to be used for kusama. Remove GameDAO pallets. --- bin/subzero/node/Cargo.toml | 3 - bin/subzero/node/src/chain_spec.rs | 357 +------------------------- bin/subzero/node/src/command.rs | 2 - bin/subzero/runtime/Cargo.toml | 43 +--- bin/subzero/runtime/src/lib.rs | 197 ++++---------- bin/subzero/runtime/src/xcm_config.rs | 21 +- 6 files changed, 78 insertions(+), 545 deletions(-) diff --git a/bin/subzero/node/Cargo.toml b/bin/subzero/node/Cargo.toml index bb58b038ea..ba8c8f5f52 100644 --- a/bin/subzero/node/Cargo.toml +++ b/bin/subzero/node/Cargo.toml @@ -59,7 +59,6 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkad sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } @@ -90,8 +89,6 @@ cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28" } primitives = { version = "2.0.0", package = "zero-primitives", default-features = false, path = "../../../modules/primitives" } -gamedao-control = { path = "../../../modules/gamedao-protocol/control", default-features = false } -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch= "polkadot-v0.9.28", default-features = false } [build-dependencies] substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } diff --git a/bin/subzero/node/src/chain_spec.rs b/bin/subzero/node/src/chain_spec.rs index 7603bb7398..c904950025 100644 --- a/bin/subzero/node/src/chain_spec.rs +++ b/bin/subzero/node/src/chain_spec.rs @@ -3,17 +3,12 @@ use subzero_runtime::{AccountId, AuraId, SS58Prefix, Signature, SudoConfig}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup, Properties}; use sc_service::ChainType; use serde::{Deserialize, Serialize}; -use sp_core::{sr25519, Pair, Public, crypto::UncheckedInto}; -use sp_runtime::{BoundedVec, traits::{IdentifyAccount, Verify, Zero}}; -use sp_std::collections::btree_map::BTreeMap; -use hex_literal::hex; - -use gamedao_control::types::{OrgType, AccessModel, FeeModel}; -use orml_tokens; +use sp_core::{sr25519, Pair, Public}; +use sp_runtime::traits::{IdentifyAccount, Verify}; use primitives::{ - currency::{ZERO, PLAY, GAME, DOT, TokenInfo, CurrencyId}, - cent, dollar, Balance + currency::{ZERO, PLAY, GAME, DOT, TokenInfo}, + cent }; /// Specialized `ChainSpec` for the normal parachain runtime. @@ -246,350 +241,6 @@ fn testnet_genesis( technical_committee: Default::default(), elections: Default::default(), technical_membership: Default::default(), - control: Default::default(), - asset_registry: Default::default(), - } -} - -pub fn development_subzero_config() -> ChainSpec { - let properties = get_properties(); - - ChainSpec::from_genesis( - // Name - "Subzero Development", - // ID - "subzero-dev", - ChainType::Local, - // SECRET="..." - // docker run --rm parity/subkey inspect "$SECRET//subzero//root" - // docker run --rm parity/subkey inspect "$SECRET//subzero//1//collator" - // docker run --rm parity/subkey inspect "$SECRET//subzero//1//aura" - // docker run --rm parity/subkey inspect "$SECRET//subzero//2//collator" - // docker run --rm parity/subkey inspect "$SECRET//subzero//2//aura" - // docker run --rm parity/subkey inspect "$SECRET//subzero//zero-treasury" - // docker run --rm parity/subkey inspect "$SECRET//subzero//gamedao-treasury" - // docker run --rm parity/subkey inspect "$SECRET//subzero//game3-treasury" - // docker run --rm parity/subkey inspect "$SECRET//subzero//prime" - move || { - subzero_genesis( - // Initial collators - vec![ - ( - // 5FyCQF345qawarNwSoUgg5ankQt1g4J4wHwryMsEiUHi592W - hex!["acbd8ce2c37263c4964f4babcc6eaedd5276006c448e046290d366318c3b0016"].into(), - hex!["d081d0b6ee6fe89fca7ed9ee7a927da7462389798a2ed1a62caa456de487f574"].unchecked_into(), - ), - ( - // 5FP7zjy4uZ46uGSTrXBhkk6L7RkKtS8emD9BLAFAXBDS5nD2 - hex!["92c0609c5bc85053246436c99e5474163e2f73f59adef926bc0897502eca1945"].into(), - hex!["d008cd73618b8bce15531f693516635800ec1ee69f19e43f25f32129c5d5fd39"].unchecked_into(), - ), - ], - vec![ - // Faucet Bot - // 5Ef24TjfGNPnxrALTsPN3wJ9XoTTY4coMvryNed4MkZmqKaL - hex!["72a416a9270487e9fa301883780fe22edfac394bcf018b5da4444dff38937574"].into(), - // Org Prime - // 5GWchgf4qbaJZTBbmKTGWDCVPJt1XPLQfxaKsDe3Y3LqyHbT - hex!["c4b3f61d4f896a660d35bdf6a78c54cf2aa2af48ba0945f568dc67674247e136"].into(), - // Root - // 5CwWu8QwK8hdHcC5JHWWVSbxAFcLD4eUPsWY1BEy48LxjjMf - hex!["26c0a10c263cf2583936ff9714a645de855e39090765a0a23fe8a2001ab83016"].into(), - ], - // Root - // 5CwWu8QwK8hdHcC5JHWWVSbxAFcLD4eUPsWY1BEy48LxjjMf - hex!["26c0a10c263cf2583936ff9714a645de855e39090765a0a23fe8a2001ab83016"].into(), - // Zero treasury account - // 5EeG87W6f5X39SUeTLM6oBT8M5BZ4ApQbncKw78QFvgkGnqd - hex!["72102ee7e9bd0170c9829054bf8aaab65ea2555b1c30b04747160fe4a86d5b47"].into(), - // Gamedao treasury account - // 5EnLtQYf87Kab8vR8CyGmFXjo1HjYLUbFAdCsK5rFMAhfT4R - hex!["783a2eb5d5b4f1f3a7b49bea0c82119cccb366fd7b05d4c44b21ea160b52b160"].into(), - // Game3 treasury account - // 5DtGqwDh1rgcGYX2QxqxBs5S7VsNFbowX7cUiGiLEQ2aP9UV - hex!["5083d014500f360fa17ec74d50f0b8336e205f11d7a9e4cfc4bb42a7a3da4c6d"].into(), - // Org Prime - // 5GWchgf4qbaJZTBbmKTGWDCVPJt1XPLQfxaKsDe3Y3LqyHbT - hex!["c4b3f61d4f896a660d35bdf6a78c54cf2aa2af48ba0945f568dc67674247e136"].into(), - DEFAULT_PARA_ID.into(), - ) - }, - vec![ - "/dns/collator-1/tcp/30333/p2p/12D3KooWBQB9MUka9nMcqXi3ANLUdu4FweQpMvw9VHpHveiYhsPx" - .parse() - .unwrap(), - ], - // Telemetry - None, - // Protocol ID - Some("subzero-dev"), - // Fork ID - None, - Some(properties), - Extensions { - relay_chain: "rococo-local".into(), // You MUST set this to the correct network! - para_id: DEFAULT_PARA_ID, - }, - ) -} - -pub fn staging_subzero_config() -> ChainSpec { - let properties = get_properties(); - - ChainSpec::from_genesis( - // Name - "Subzero Staging", - // ID - "subzero-stage", - ChainType::Local, - // SECRET="..." - // docker run --rm parity/subkey inspect "$SECRET//subzero//root" - // docker run --rm parity/subkey inspect "$SECRET//subzero//1//collator" - // docker run --rm parity/subkey inspect "$SECRET//subzero//1//aura" - // docker run --rm parity/subkey inspect "$SECRET//subzero//2//collator" - // docker run --rm parity/subkey inspect "$SECRET//subzero//2//aura" - // docker run --rm parity/subkey inspect "$SECRET//subzero//3//collator" - // docker run --rm parity/subkey inspect "$SECRET//subzero//3//aura" - // docker run --rm parity/subkey inspect "$SECRET//subzero//4//collator" - // docker run --rm parity/subkey inspect "$SECRET//subzero//4//aura" - // docker run --rm parity/subkey inspect "$SECRET//subzero//zero-treasury" - // docker run --rm parity/subkey inspect "$SECRET//subzero//gamedao-treasury" - // docker run --rm parity/subkey inspect "$SECRET//subzero//game3-treasury" - // docker run --rm parity/subkey inspect "$SECRET//subzero//prime" - move || { - subzero_genesis( - // Initial collators - vec![ - ( - // 5EJVzfYgcPEncpwNoQp7ryzfJRjNfxQs4b4gUUdT7ya2Hg16 - hex!["62fdf8994e59cf79ef96338ccf1fa6fffd37c1a843841db0d3963efef0e4d31d"].into(), - hex!["90bf7542167747bcceb0614d4e461df631a8557cf9a7009899bacb203479f642"].unchecked_into(), - ), - ( - // 5GH83LCgSC6Kp5WZtF7pvaBiyqY22ZeH2gr1vCAh3TxpM83i - hex!["ba6949eb864d92d360bf997043b4229b7f54a6df5136af5b4f885a1ce89fd462"].into(), - hex!["eab75e30bd998c79befb81938daf6189f983273b0aeb292b15667d01245bfa6c"].unchecked_into(), - ), - ( - // 5EZZFSPHc2myoFFPFoM7k7Cy1p3niGoXCP8iG4qAKWcDMVVM - hex!["6e799bc5437690e6bd86aa0df8451eaf605ae7b2ec0266f9899905265572b018"].into(), - hex!["a2d2896c87b1db42b952835a775ff7418375ef4dc171b92640b4c11c22a2250f"].unchecked_into(), - ), - ( - // 5FKnYx26KziwtQeXmR6gaD1LwgMUUjCFjG5YAQQES1RfHFbV - hex!["90352f3b6f33a62c3f43cfe08726724d48cbc4919e27a5d1e55efa6881bad229"].into(), - hex!["96750acce3e01bedb5b2ffd7706f2e7b4a83c5e2f8714257d9d2ab95fb61da0d"].unchecked_into(), - ), - ], - vec![ - // Faucet Bot - // 5Ef24TjfGNPnxrALTsPN3wJ9XoTTY4coMvryNed4MkZmqKaL - hex!["72a416a9270487e9fa301883780fe22edfac394bcf018b5da4444dff38937574"].into(), - // Org Prime - // 5GeBJnjVxueXj5PsTFLTBoPQzt5scehWkKL84JLJ8hXWexaP - hex!["ca7870338715348c17ffb5a299c4ae9e2ceec0726d8d72a2f502060942af045d"].into(), - // Root - // 5HdZAx6ieBdLPdeQjj778ST7oq6poUkhr7nZ32mWzEjWGwQa - hex!["f63b07ad8610dcbdff485d2497fb359077ec8bfef9d9ffdb38022d7cdc986318"].into(), - ], - // Root - // 5HdZAx6ieBdLPdeQjj778ST7oq6poUkhr7nZ32mWzEjWGwQa - hex!["f63b07ad8610dcbdff485d2497fb359077ec8bfef9d9ffdb38022d7cdc986318"].into(), - // Zero treasury account - // 5EXAdVUvu3dyDb4Wn55XUdxWBv3fPhvf9Vzf76LsFBe72WA4 - hex!["6ca6f9057fa6374afd5c0b92a40905340f56e96f4905b36a0526917016f48667"].into(), - // Gamedao treasury account - // 5CSM7WW5icde1aqCK4xfbhBXCVqE76dZX2tvMtntaVvEBuFv - hex!["10819164c87b9f4dc70e64879d170d52378358b538b80fdabc0e90028a66f570"].into(), - // Game3 treasury account - // 5GNFNuNAJbD4ECDVHjYKHZibPUfGXHdFqKRoqVDbopsSGAim - hex!["be52373f74b5fa074de8edaa76e288305f200a6831d3550c0ebe4e02da9fa52d"].into(), - // Org Prime - // 5GeBJnjVxueXj5PsTFLTBoPQzt5scehWkKL84JLJ8hXWexaP - hex!["ca7870338715348c17ffb5a299c4ae9e2ceec0726d8d72a2f502060942af045d"].into(), - DEFAULT_PARA_ID.into(), - ) - }, - vec![ - "/dns/collator-1/tcp/30333/p2p/12D3KooWBQB9MUka9nMcqXi3ANLUdu4FweQpMvw9VHpHveiYhsPx" - .parse() - .unwrap(), - ], - // Telemetry - None, - // Protocol ID - Some("subzero-stage"), - // Fork ID - None, - Some(properties), - Extensions { - relay_chain: "rococo-local".into(), // You MUST set this to the correct network! - para_id: DEFAULT_PARA_ID, - }, - ) -} - -fn subzero_genesis( - invulnerables: Vec<(AccountId, AuraId)>, - endowed_accounts: Vec, - root_key: AccountId, - zero_treasury: AccountId, - gamedao_treasury: AccountId, - game3_treasury: AccountId, - org_prime: AccountId, - id: ParaId, -) -> subzero_runtime::GenesisConfig { - subzero_runtime::GenesisConfig { - system: subzero_runtime::SystemConfig { - code: subzero_runtime::WASM_BINARY - .expect("WASM binary was not build, please build it!") - .to_vec(), - }, - sudo: SudoConfig { key: Some(root_key) }, - balances: subzero_runtime::BalancesConfig { - balances: balances_config(endowed_accounts.clone(), zero_treasury.clone(), game3_treasury.clone(), gamedao_treasury.clone()), - }, - parachain_info: subzero_runtime::ParachainInfoConfig { parachain_id: id }, - collator_selection: subzero_runtime::CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: cent(ZERO) * 16, - ..Default::default() - }, - session: subzero_runtime::SessionConfig { - keys: invulnerables - .into_iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc, // validator id - subzero_session_keys(aura), // session keys - ) - }) - .collect(), - }, - // no need to pass anything to aura, in fact it will panic if we do. Session will take care - // of this. - aura: Default::default(), - aura_ext: Default::default(), - parachain_system: Default::default(), - polkadot_xcm: subzero_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - }, - council: Default::default(), - treasury: Default::default(), - tokens: orml_tokens::GenesisConfig { - balances: tokens_config(endowed_accounts.clone(), zero_treasury.clone(), game3_treasury.clone(), gamedao_treasury.clone()), - }, - democracy: Default::default(), - technical_committee: Default::default(), - elections: Default::default(), - technical_membership: Default::default(), - control: gamedao_control::GenesisConfig { - orgs: vec![ - // Zero Network - (org_prime.clone(), org_prime.clone(), zero_treasury, BoundedVec::truncate_from(b"Zero Network".to_vec()), - BoundedVec::truncate_from(b"QmUWu6zoFM4j1fwT6fHGEjiuCSft2sNcbmJtT23R9su3Bk".to_vec()), - OrgType::Individual, AccessModel::Open, FeeModel::NoFees, Zero::zero(), - GAME, PLAY, 1000, 1 * dollar(GAME) - ), - // GameDao - (org_prime.clone(), org_prime.clone(), gamedao_treasury, BoundedVec::truncate_from(b"GameDao".to_vec()), - BoundedVec::truncate_from(b"QmcNp8hsRaxVDhKgbgo6Jtcb8papyPnKbqjzFtqzqxDE7j".to_vec()), - OrgType::Individual, AccessModel::Open, FeeModel::NoFees, Zero::zero(), - GAME, PLAY, 1000, 1 * dollar(GAME) - ), - // Game3 Foundation - (org_prime.clone(), org_prime.clone(), game3_treasury, BoundedVec::truncate_from(b"Game3 Foundation".to_vec()), - BoundedVec::truncate_from(b"QmNYVx6bhRUGbMp6UEPHKhaLRwFfpsbsP4sFT9XCvMxgfz".to_vec()), - OrgType::Individual, AccessModel::Open, FeeModel::NoFees, Zero::zero(), - GAME, PLAY, 1000, 1 * dollar(GAME) - ), - ] - }, asset_registry: Default::default(), } } - -fn balances_config(accounts: Vec, zero_treasury: AccountId, - game3_treasury: AccountId, gamedao_treasury: AccountId) -> Vec<(AccountId, Balance)> { - // Zero Network Treasury owns ZERO issuance: - let mut zero_issuance = 1_000_000_000 * dollar(ZERO); - // Game3 Foundation Treasury: - let game3_zero = 1_000_000 * dollar(ZERO); - // GameDAO Treasury: - let gamedao_zero = 1_000_000 * dollar(ZERO); - - let account_balances = accounts.iter().cloned().map(|x| (x, 1_000_000 * dollar(ZERO))) - .fold( - BTreeMap::::new(), - |mut acc, (account_id, amount)| { - if let Some(balance) = acc.get_mut(&account_id) { - *balance = balance - .checked_add(amount) - .expect("balance overflow"); - } else { - zero_issuance = zero_issuance.saturating_sub(amount); - acc.insert(account_id.clone(), amount); - } - acc - }, - ) - .into_iter() - .collect::>(); - - zero_issuance = zero_issuance.saturating_sub(game3_zero).saturating_sub(gamedao_zero); - let mut balances = vec![ - (zero_treasury, zero_issuance), - (gamedao_treasury, gamedao_zero), - (game3_treasury, game3_zero), - ]; - balances.extend(account_balances); - balances -} - -fn tokens_config(accounts: Vec, zero_treasury: AccountId, - game3_treasury: AccountId, gamedao_treasury: AccountId) -> Vec<(AccountId, CurrencyId, Balance)> { - // Game3 Foundation Treasury owns GAME & PLAY issuance: - let mut game_issuance = 100_000_000 * dollar(GAME); - let mut play_issuance = 10_000_000 * dollar(PLAY); - - // Zero Network Treasury: - let zeronet_game = 100_000 * dollar(GAME); - let zeronet_play = 1_000_000 * dollar(PLAY); - - // GameDAO: - let gamedao_game = 100_000 * dollar(GAME); - let gamedao_play = 1_000_000 * dollar(PLAY); - - let account_balances = accounts - .iter().cloned() - .flat_map(|x| vec![(x.clone(), GAME, 1_000_000 * dollar(GAME)), (x.clone(), PLAY, 1_000_000 * dollar(PLAY))]) - .fold( - Vec::new(), - |mut vec, (account_id, currency_id, amount)| { - match currency_id { - GAME => { game_issuance = game_issuance.saturating_sub(amount); }, - PLAY => { play_issuance = play_issuance.saturating_sub(amount); }, - _ => () - }; - vec.push((account_id.clone(), currency_id, amount)); - vec - }, - ) - .into_iter() - .collect::>(); - - game_issuance = game_issuance.saturating_sub(zeronet_game).saturating_sub(gamedao_game); - play_issuance = play_issuance.saturating_sub(zeronet_play).saturating_sub(gamedao_play); - - let mut token_balances = vec![ - (zero_treasury.clone(), GAME, zeronet_game), - (zero_treasury, PLAY, zeronet_play), - (game3_treasury.clone(), GAME, game_issuance), - (game3_treasury, PLAY, play_issuance), - (gamedao_treasury.clone(), GAME, gamedao_game), - (gamedao_treasury, PLAY, gamedao_play), - ]; - token_balances.extend(account_balances); - token_balances -} diff --git a/bin/subzero/node/src/command.rs b/bin/subzero/node/src/command.rs index ebb62fa5a9..22b9af09e2 100644 --- a/bin/subzero/node/src/command.rs +++ b/bin/subzero/node/src/command.rs @@ -26,8 +26,6 @@ use crate::{ fn load_spec(id: &str) -> std::result::Result, String> { Ok(match id { "dev" => Box::new(chain_spec::development_config()), - "subzero-dev" => Box::new(chain_spec::development_subzero_config()), - "subzero-stage" => Box::new(chain_spec::staging_subzero_config()), "template-rococo" => Box::new(chain_spec::local_testnet_config()), "" | "local" => Box::new(chain_spec::local_testnet_config()), path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), diff --git a/bin/subzero/runtime/Cargo.toml b/bin/subzero/runtime/Cargo.toml index 7d96a75722..ddb2f5adf7 100644 --- a/bin/subzero/runtime/Cargo.toml +++ b/bin/subzero/runtime/Cargo.toml @@ -75,20 +75,21 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.28" } # Cumulus -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false} -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } -parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.28", default-features = false } +cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28", version = "3.0.0"} +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } +parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.28" } primitives = { version = "2.0.0", package = "zero-primitives", default-features = false, path = "../../../modules/primitives" } +# ORML orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch= "polkadot-v0.9.28", default-features = false } orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch= "polkadot-v0.9.28", default-features = false } orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch= "polkadot-v0.9.28", default-features = false } @@ -98,18 +99,13 @@ orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-libra orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch= "polkadot-v0.9.28", default-features = false } orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch= "polkadot-v0.9.28", default-features = false } +# RMRK pallet-rmrk-core = { git = "https://github.com/rmrk-team/rmrk-substrate", default-features = false, branch = "polkadot-v0.9.28" } pallet-rmrk-equip = { git = "https://github.com/rmrk-team/rmrk-substrate", default-features = false, branch = "polkadot-v0.9.28" } pallet-rmrk-market = { git = "https://github.com/rmrk-team/rmrk-substrate", default-features = false, branch = "polkadot-v0.9.28" } rmrk-traits = { git = "https://github.com/rmrk-team/rmrk-substrate", default-features = false, branch = "polkadot-v0.9.28" } pallet-rmrk-rpc-runtime-api = { git = "https://github.com/rmrk-team/rmrk-substrate", default-features = false, branch = "polkadot-v0.9.28" } -gamedao-traits = { path = "../../../modules/gamedao-protocol/traits", default-features = false } -gamedao-flow = { path = "../../../modules/gamedao-protocol/flow", default-features = false } -gamedao-control = { path = "../../../modules/gamedao-protocol/control", default-features = false } -gamedao-signal = { path = "../../../modules/gamedao-protocol/signal", default-features = false } -gamedao-sense = { path = "../../../modules/gamedao-protocol/sense", default-features = false } - [features] default = [ "std", @@ -191,12 +187,6 @@ std = [ "pallet-rmrk-equip/std", "rmrk-traits/std", "pallet-rmrk-rpc-runtime-api/std", - - "gamedao-sense/std", - "gamedao-traits/std", - "gamedao-flow/std", - "gamedao-control/std", - "gamedao-signal/std", ] runtime-benchmarks = [ @@ -210,7 +200,6 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-child-bounties/runtime-benchmarks", - "pallet-democracy/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", @@ -219,12 +208,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", - - "gamedao-traits/runtime-benchmarks", - "gamedao-sense/runtime-benchmarks", - "gamedao-control/runtime-benchmarks", - "gamedao-flow/runtime-benchmarks", - "gamedao-signal/runtime-benchmarks", ] try-runtime = [ diff --git a/bin/subzero/runtime/src/lib.rs b/bin/subzero/runtime/src/lib.rs index ecf9c35a8f..9ac2d32d55 100644 --- a/bin/subzero/runtime/src/lib.rs +++ b/bin/subzero/runtime/src/lib.rs @@ -6,9 +6,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); -pub mod constants; mod weights; pub mod xcm_config; +pub mod constants; use codec::{Decode, Encode, MaxEncodedLen}; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; @@ -39,11 +39,12 @@ use frame_support::{ weights::{ constants::WEIGHT_PER_SECOND, ConstantMultiplier, DispatchClass, Weight, }, - BoundedVec, PalletId, + BoundedVec, + PalletId, }; use frame_system::{ limits::{BlockLength, BlockWeights}, - EnsureRoot, EnsureSigned, + EnsureRoot, EnsureSigned }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{DispatchError, MultiAddress, Perbill, Permill}; @@ -61,11 +62,9 @@ use xcm::latest::prelude::BodyId; pub use constants::{fee::*, time::*}; pub use primitives::{ - cent, - currency::{ - AssetIdMapping, AssetIds, CurrencyId, CustomMetadata, ForeignAssetId, TokenSymbol, DOT, GAME, PLAY, ZERO, - }, - dollar, millicent, Amount, ReserveIdentifier, + currency::{ZERO, PLAY, GAME, DOT, AssetIds, CurrencyId, CustomMetadata, ForeignAssetId, TokenSymbol}, + dollar, cent, millicent, + Amount, ReserveIdentifier }; use orml_asset_registry::SequentialId; @@ -129,8 +128,13 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = - frame_executive::Executive, Runtime, AllPalletsWithSystem>; +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, +>; /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats @@ -158,7 +162,7 @@ impl_opaque_keys! { #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("subzero"), - impl_name: create_runtime_str!("dev"), + impl_name: create_runtime_str!("live"), authoring_version: 75, spec_version: 63, impl_version: 0, @@ -189,10 +193,7 @@ const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2; /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { - NativeVersion { - runtime_version: VERSION, - can_author_with: Default::default(), - } + NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } parameter_types! { @@ -231,22 +232,22 @@ impl Contains for BaseFilter { // Disable direct calls to pallet_uniques !matches!( call, - Call::Uniques(pallet_uniques::Call::approve_transfer { .. }) - | Call::Uniques(pallet_uniques::Call::burn { .. }) - | Call::Uniques(pallet_uniques::Call::cancel_approval { .. }) - | Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::create { .. }) - | Call::Uniques(pallet_uniques::Call::destroy { .. }) - | Call::Uniques(pallet_uniques::Call::force_item_status { .. }) - | Call::Uniques(pallet_uniques::Call::force_create { .. }) - | Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | Call::Uniques(pallet_uniques::Call::mint { .. }) - | Call::Uniques(pallet_uniques::Call::redeposit { .. }) - | Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | Call::Uniques(pallet_uniques::Call::transfer { .. }) - | Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + Call::Uniques(pallet_uniques::Call::approve_transfer { .. }) | + Call::Uniques(pallet_uniques::Call::burn { .. }) | + Call::Uniques(pallet_uniques::Call::cancel_approval { .. }) | + Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::create { .. }) | + Call::Uniques(pallet_uniques::Call::destroy { .. }) | + Call::Uniques(pallet_uniques::Call::force_item_status { .. }) | + Call::Uniques(pallet_uniques::Call::force_create { .. }) | + Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + Call::Uniques(pallet_uniques::Call::mint { .. }) | + Call::Uniques(pallet_uniques::Call::redeposit { .. }) | + Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + Call::Uniques(pallet_uniques::Call::transfer { .. }) | + Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) ) } } @@ -552,7 +553,6 @@ impl pallet_sudo::Config for Runtime { } parameter_types! { - pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); pub BountyValueMinimum: Balance = 5 * dollar(ZERO); pub BountyDepositBase: Balance = 1 * dollar(ZERO); pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50); @@ -766,9 +766,6 @@ parameter_types! { pub ProposalBondMinimum: Balance = 1 * dollar(ZERO); pub const SpendPeriod: BlockNumber = 1 * DAYS; pub const Burn: Permill = Permill::from_percent(50); - // pub const TipCountdown: BlockNumber = 1 * DAYS; - // pub const TipFindersFee: Percent = Percent::from_percent(20); - // pub TipReportDepositBase: Balance = 1 * dollar(ZERO); pub DataDepositPerByte: Balance = 1 * cent(ZERO); pub const MaximumReasonLength: u32 = 300; } @@ -799,9 +796,9 @@ impl pallet_treasury::Config for Runtime { } parameter_types! { - pub BasicDeposit: Balance = 10 * dollar(ZERO); // 258 bytes on-chain - pub FieldDeposit: Balance = 250 * cent(ZERO); // 66 bytes on-chain - pub SubAccountDeposit: Balance = 2 * dollar(ZERO); // 53 bytes on-chain + pub BasicDeposit: Balance = 10 * dollar(ZERO); // 258 bytes on-chain + pub FieldDeposit: Balance = 250 * cent(ZERO); // 66 bytes on-chain + pub SubAccountDeposit: Balance = 2 * dollar(ZERO); // 53 bytes on-chain } impl pallet_identity::Config for Runtime { @@ -876,8 +873,6 @@ parameter_types! { } // We allow root only to execute privileged collator selection operations. -// SBP-M2 review: you should have an entity like a council -// instead of providing the whole power to the single user (Root account) pub type CollatorSelectionUpdateOrigin = EnsureRoot; impl pallet_collator_selection::Config for Runtime { @@ -932,8 +927,6 @@ parameter_type_with_key! { } /// Allow asset registration only from root origin -// SBP-M2 review: root account has too much power -// Need for a council pub struct AssetAuthority; impl EnsureOriginWithArg> for AssetAuthority { type Success = (); @@ -995,86 +988,6 @@ impl orml_currencies::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub MinProposalDeposit: Balance = 100 * dollar(GAME); - pub SlashingMajority: Permill = Permill::from_rational(2u32, 3u32); - pub GameDAOGetsFromSlashing: Permill = Permill::from_rational(1u32, 10u32); - pub const MaxMembersPerOrg: u32 = 1000; - pub const ProposalDurationLimits: (BlockNumber, BlockNumber) = (100, 864000); -} - -impl gamedao_signal::Config for Runtime { - type WeightInfo = gamedao_signal::weights::SubstrateWeight; - type Event = Event; - type Currency = Currencies; - type CurrencyId = CurrencyId; - type PaymentTokenId = GetStableCurrencyId; - type ProtocolTokenId = GetProtocolCurrencyId; - type Balance = Balance; - type Flow = Flow; - type Control = Control; - type MinProposalDeposit = MinProposalDeposit; - type GameDAOTreasury = GameDAOTreasuryAccountId; - type SlashingMajority = SlashingMajority; - type GameDAOGetsFromSlashing = GameDAOGetsFromSlashing; - type MaxMembers = MaxMembersPerOrg; - type ProposalDurationLimits = ProposalDurationLimits; - type MaxProposalsPerBlock = ConstU32<100>; - type StringLimit = StringLimit; -} - -parameter_types! { - pub OrgMinimumDeposit: Balance = 1 * dollar(GAME); -} - -impl gamedao_control::Config for Runtime { - type Balance = Balance; - type CurrencyId = CurrencyId; - type WeightInfo = gamedao_control::weights::SubstrateWeight; - type Event = Event; - type Currency = Currencies; - type MaxMembers = MaxMembersPerOrg; - type ProtocolTokenId = GetProtocolCurrencyId; - type PaymentTokenId = GetStableCurrencyId; - type MinimumDeposit = OrgMinimumDeposit; - type PalletId = ControlPalletId; - type StringLimit = StringLimit; -} - -parameter_types! { - pub MinContribution: Balance = 1 * dollar(PLAY); - pub CampaignFee: Permill = Permill::from_rational(3u32, 1000u32); // 0.3% - pub MinCampaignDeposit: Permill = Permill::from_rational(1u32, 10u32); // 10% - pub const CampaignDurationLimits: (BlockNumber, BlockNumber) = (24 * HOURS, 60 * DAYS); -} - -impl gamedao_flow::Config for Runtime { - type Event = Event; - type Balance = Balance; - type CurrencyId = CurrencyId; - type WeightInfo = gamedao_flow::weights::SubstrateWeight; - type Currency = Currencies; - type Control = Control; - type GameDAOTreasury = GameDAOTreasuryAccountId; - type MinNameLength = ConstU32<4>; - type MaxCampaignsPerBlock = ConstU32<10>; - type MaxCampaignContributors = ConstU32<10000>; - type MaxContributorsProcessing = ConstU32<100>; - type MinContribution = MinContribution; - type MinCampaignDeposit = MinCampaignDeposit; - type ProtocolTokenId = GetProtocolCurrencyId; - type PaymentTokenId = GetStableCurrencyId; - type CampaignFee = CampaignFee; - type StringLimit = StringLimit; - type CampaignDurationLimits = CampaignDurationLimits; -} - -impl gamedao_sense::Config for Runtime { - type Event = Event; - type WeightInfo = gamedao_sense::weights::SubstrateWeight; - type StringLimit = StringLimit; -} - // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -1084,6 +997,9 @@ construct_runtime!( { // System support stuff. System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, + ParachainSystem: cumulus_pallet_parachain_system::{ + Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned, + } = 1, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, Utility: pallet_utility::{Pallet, Call, Storage, Event} = 3, Multisig: pallet_multisig = 4, @@ -1126,10 +1042,6 @@ construct_runtime!( CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 52, DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 53, - ParachainSystem: cumulus_pallet_parachain_system::{ - Pallet, Call, Config, Storage, Inherent, Event, - } = 1, - // ORML: AssetRegistry: orml_asset_registry::{Pallet, Storage, Call, Event, Config} = 60, Currencies: orml_currencies::{Pallet, Call} = 61, @@ -1137,12 +1049,6 @@ construct_runtime!( Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config} = 63, UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 64, XTokens: orml_xtokens::{Pallet, Storage, Call, Event} = 65, - - // GameDAO protocol: - Flow: gamedao_flow = 70, - Sense: gamedao_sense = 71, - Control: gamedao_control = 72, - Signal: gamedao_signal = 73, } ); @@ -1169,16 +1075,14 @@ fn option_filter_keys_to_set>( Some(filter_keys) => { let tree = filter_keys .into_iter() - .map( - |filter_keys| -> pallet_rmrk_rpc_runtime_api::Result> { - filter_keys - .try_into() - .map_err(|_| DispatchError::Other("Can't read filter key")) - }, - ) + .map(|filter_keys| -> pallet_rmrk_rpc_runtime_api::Result> { + filter_keys + .try_into() + .map_err(|_| DispatchError::Other("Can't read filter key")) + }) .collect::>>()?; Ok(Some(tree)) - } + }, None => Ok(None), } } @@ -1470,12 +1374,13 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { .read_slot() .expect("Could not read the relay chain slot from the proof"); - let inherent_data = cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); + let inherent_data = + cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( + relay_chain_slot, + sp_std::time::Duration::from_secs(6), + ) + .create_inherent_data() + .expect("Could not create the timestamp inherent data"); inherent_data.check_extrinsics(block) } diff --git a/bin/subzero/runtime/src/xcm_config.rs b/bin/subzero/runtime/src/xcm_config.rs index a7e373b320..00b738e4f9 100644 --- a/bin/subzero/runtime/src/xcm_config.rs +++ b/bin/subzero/runtime/src/xcm_config.rs @@ -16,8 +16,8 @@ use frame_support::{ weights::Weight, }; use sp_runtime::{ - traits::ConstU32, - WeakBoundedVec + traits::ConstU32, + WeakBoundedVec }; use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; @@ -97,7 +97,6 @@ pub type Barrier = ( AllowSubscriptionsFrom ); -// todo: move this to common runtimes module pub fn local_currency_location(key: CurrencyId) -> MultiLocation { MultiLocation::new( 0, @@ -247,12 +246,12 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< pub fn native_currency_location(para_id: u32, id: CurrencyId) -> MultiLocation { MultiLocation::new( - 1, - X2( - Parachain(para_id), GeneralKey( - WeakBoundedVec::>::force_from(id.encode(), None) - ) - ) + 1, + X2( + Parachain(para_id), GeneralKey( + WeakBoundedVec::>::force_from(id.encode(), None) + ) + ) ) } @@ -272,8 +271,8 @@ impl Convert> for CurrencyIdConvert { fn convert(location: MultiLocation) -> Option { fn decode_currency_id(key: WeakBoundedVec::>) -> Option { - let key = &key.into_inner()[..]; - if let Ok(currency_id) = CurrencyId::decode(&mut &*key) { + let key = &key.into_inner()[..]; + if let Ok(currency_id) = CurrencyId::decode(&mut &*key) { // check `currency_id` is cross-chain asset match currency_id { ZERO | GAME | PLAY => Some(currency_id),