From 07992dd895a7f378498dfb7b4a2744d7aa1aa336 Mon Sep 17 00:00:00 2001 From: abhijeetbhagat Date: Thu, 14 Jul 2022 18:44:43 +0530 Subject: [PATCH] disable xcm filter, add xcm safe version & cargo fmt --- Cargo.lock | 1 + node/Cargo.toml | 2 +- node/src/chain_spec/arctic.rs | 11 ++- node/src/chain_spec/snow.rs | 121 ++++++++++++++++++------------- pallets/airdrop/src/transfer.rs | 4 +- runtime/arctic/src/lib.rs | 11 ++- runtime/arctic/src/xcm_config.rs | 2 +- runtime/frost/src/lib.rs | 11 ++- runtime/snow/src/lib.rs | 11 ++- runtime/snow/src/xcm_config.rs | 2 +- 10 files changed, 99 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dedb1b5e..580a302a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3752,6 +3752,7 @@ dependencies = [ "substrate-prometheus-endpoint", "tracing-core", "try-runtime-cli", + "xcm", ] [[package]] diff --git a/node/Cargo.toml b/node/Cargo.toml index 6de21754..e0c2fbf4 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -104,7 +104,7 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24" } polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24" } polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", optional = true } - +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.24" } # These dependencies are used for runtime benchmarking frame-benchmarking = { branch = "polkadot-v0.9.24", git = "https://github.com/paritytech/substrate" } diff --git a/node/src/chain_spec/arctic.rs b/node/src/chain_spec/arctic.rs index 3ed7b998..6e3c807d 100644 --- a/node/src/chain_spec/arctic.rs +++ b/node/src/chain_spec/arctic.rs @@ -3,9 +3,9 @@ use arctic_runtime::currency::ICY; use arctic_runtime::{ wasm_binary_unwrap, AccountId, AirdropConfig, AuraConfig, AuraId, BalancesConfig, CollatorSelectionConfig, CouncilConfig, CouncilMembershipConfig, DemocracyConfig, EVMConfig, - GenesisConfig, IndicesConfig, ParachainInfoConfig, SS58Prefix, SessionConfig, SessionKeys, - Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TechnicalMembershipConfig, - VestingConfig, + GenesisConfig, IndicesConfig, ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, + SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, + TechnicalMembershipConfig, VestingConfig, }; use cumulus_primitives_core::ParaId; use hex_literal::hex; @@ -22,6 +22,7 @@ const AIRDROP_MERKLE_ROOT: [u8; 32] = hex!("b654eac2f99abbe8e847a2079a2018bcf09989c00a3e0dd0114a335c4d97ef32"); const PARA_ID: u32 = 2000; +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; fn arctic_properties() -> Properties { let mut properties = Properties::new(); @@ -215,7 +216,9 @@ fn make_genesis( }, ethereum: Default::default(), treasury: Default::default(), - polkadot_xcm: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, parachain_system: Default::default(), simple_inflation: Default::default(), fees_split: Default::default(), diff --git a/node/src/chain_spec/snow.rs b/node/src/chain_spec/snow.rs index 95559e63..d14ccf44 100644 --- a/node/src/chain_spec/snow.rs +++ b/node/src/chain_spec/snow.rs @@ -1,15 +1,15 @@ -use snow_runtime::{ - wasm_binary_unwrap, AccountId, Balance, AirdropConfig, AuraConfig, AuraId, BalancesConfig, - CollatorSelectionConfig, CouncilConfig, CouncilMembershipConfig, DemocracyConfig, EVMConfig, - GenesisConfig, IndicesConfig, ParachainInfoConfig, SS58Prefix, SessionConfig, SessionKeys, - Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TechnicalMembershipConfig, - VestingConfig, TreasuryPalletId, -}; -use snow_runtime::currency::ICY; use cumulus_primitives_core::ParaId; use hex_literal::hex; use sc_chain_spec::Properties; use sc_service::ChainType; +use snow_runtime::currency::ICY; +use snow_runtime::{ + wasm_binary_unwrap, AccountId, AirdropConfig, AuraConfig, AuraId, Balance, BalancesConfig, + CollatorSelectionConfig, CouncilConfig, CouncilMembershipConfig, DemocracyConfig, EVMConfig, + GenesisConfig, IndicesConfig, ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, + SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, + TechnicalMembershipConfig, TreasuryPalletId, VestingConfig, +}; use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public}; use sp_runtime::traits::{AccountIdConversion, IdentifyAccount, Verify}; use std::collections::BTreeMap; @@ -20,6 +20,7 @@ use super::{get_from_seed, Extensions}; pub type SnowChainSpec = sc_service::GenericChainSpec; const PARA_ID: u32 = 2000; +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; //const TOTAL_SUPPLY: Balance = ICY * 1800000000; //const TOTAL_AIR_DROP: Balance = 1 * ICY; @@ -58,12 +59,14 @@ pub fn get_dev_chain_spec() -> SnowChainSpec { ]; let endowed_accounts = vec![ - ( - (get_account_id_from_seed::("Alice"), ICY * 300_000_000) - ), - ( - (get_account_id_from_seed::("Bob"), ICY * 300_000_000) - ), + (( + get_account_id_from_seed::("Alice"), + ICY * 300_000_000, + )), + (( + get_account_id_from_seed::("Bob"), + ICY * 300_000_000, + )), ]; let council_members = vec![get_account_id_from_seed::("Alice")]; @@ -103,46 +106,63 @@ pub fn get_dev_chain_spec() -> SnowChainSpec { } pub fn testnet_spec() -> SnowChainSpec { - let root_key: AccountId = hex!["6f38cb15a6ec17a68f2aec60d2cd8cd15e58b4e33ee7f705d1cbcde07009d33f"].into(); - - let invulnerables = vec![ + + let invulnerables = vec![( + hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), + hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"].unchecked_into(), + )]; + let authorities = vec![( + hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), + hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"].unchecked_into(), + )]; + + let airdrop_creditor_account: AccountId = + hex!["1d94604ab70381bc1ea9e14854b939f4c651d2259aa0f7eb193971d526f64a45"].into(); + + let endowed_accounts = vec![ ( - hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), - hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"] - .unchecked_into(), + hex!["10b3ae7ebb7d722c8e8d0d6bf421f6d5dbde8d329f7c905a201539c635d61872"].into(), + ICY * 630000000, + ), + ( + TreasuryPalletId::get().into_account_truncating(), + ICY * 1170000000, + ), + ( + hex!["6f38cb15a6ec17a68f2aec60d2cd8cd15e58b4e33ee7f705d1cbcde07009d33f"].into(), + ICY * 2000, ), - ]; - let authorities = vec![ ( hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), - hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"] - .unchecked_into(), + ICY * 5100, + ), + ( + hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"].into(), + ICY * 2000, + ), + ( + hex!["328d54003810edf7cef62d1374032333ade2fdb2756138fc43f6b4c1918bef7c"].into(), + ICY * 2000, + ), + ( + hex!["f057f9fbec27bb5b92c5f30e89cae9826f5b86cae8380aa383c079939b3e0a55"].into(), + ICY * 2000, + ), + ( + hex!["6adaa753d9c17d9280d2469acdac1aa9b7f01be3d4149f667b9be7c7fbad1319"].into(), + ICY * 2000, ), ]; - let airdrop_creditor_account: AccountId = - hex!["1d94604ab70381bc1ea9e14854b939f4c651d2259aa0f7eb193971d526f64a45"].into(); + let council_members = vec![]; - let endowed_accounts = vec![ - (hex!["10b3ae7ebb7d722c8e8d0d6bf421f6d5dbde8d329f7c905a201539c635d61872"].into(), ICY * 630000000), - (TreasuryPalletId::get().into_account_truncating(), ICY * 1170000000), - (hex!["6f38cb15a6ec17a68f2aec60d2cd8cd15e58b4e33ee7f705d1cbcde07009d33f"].into(), ICY * 2000), - (hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), ICY * 5100), - (hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"].into(), ICY * 2000), - (hex!["328d54003810edf7cef62d1374032333ade2fdb2756138fc43f6b4c1918bef7c"].into(), ICY * 2000), - (hex!["f057f9fbec27bb5b92c5f30e89cae9826f5b86cae8380aa383c079939b3e0a55"].into(), ICY * 2000), - (hex!["6adaa753d9c17d9280d2469acdac1aa9b7f01be3d4149f667b9be7c7fbad1319"].into(), ICY * 2000), + let technical_committee = vec![ + hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), + hex!["f057f9fbec27bb5b92c5f30e89cae9826f5b86cae8380aa383c079939b3e0a55"].into(), + hex!["70d8131ab823528226296bbfbb5827a5ae84beda0edf73f0cbc95057ef43be6a"].into(), ]; - - let council_members = vec![]; - - let technical_committee = vec![ - hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), - hex!["f057f9fbec27bb5b92c5f30e89cae9826f5b86cae8380aa383c079939b3e0a55"].into(), - hex!["70d8131ab823528226296bbfbb5827a5ae84beda0edf73f0cbc95057ef43be6a"].into(), - ]; SnowChainSpec::from_genesis( "Snow Local Tesnet", @@ -171,7 +191,6 @@ pub fn testnet_spec() -> SnowChainSpec { para_id: PARA_ID, }, ) - } /// Helper function to create GenesisConfig. @@ -194,7 +213,7 @@ fn make_genesis( }, parachain_info: ParachainInfoConfig { parachain_id }, balances: BalancesConfig { - balances: endowed_accounts, + balances: endowed_accounts, }, vesting: VestingConfig { vesting: vec![] }, aura: AuraConfig { @@ -246,7 +265,9 @@ fn make_genesis( phragmen_election: Default::default(), indices: IndicesConfig { indices: vec![] }, democracy: DemocracyConfig::default(), - polkadot_xcm: Default::default(), + polkadot_xcm: PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, // Default::default(), } } @@ -262,10 +283,10 @@ where /// Generate an Aura authority key pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AuraId) { - ( - get_account_id_from_seed::(seed), - get_from_seed::(seed), - ) + ( + get_account_id_from_seed::(seed), + get_from_seed::(seed), + ) } /// Helper for session keys to map aura id diff --git a/pallets/airdrop/src/transfer.rs b/pallets/airdrop/src/transfer.rs index 359de3ca..fb54aa8e 100644 --- a/pallets/airdrop/src/transfer.rs +++ b/pallets/airdrop/src/transfer.rs @@ -12,12 +12,12 @@ pub fn do_transfer(snapshot: &mut types::SnapshotInfo) -> let vesting_should_end_in = ::VESTING_TERMS.vesting_period; let creditor = AirdropModule::::get_creditor_account()?; - let defi_user = snapshot.defi_user; + let defi_user = snapshot.defi_user; let total_amount = snapshot.amount; let claimer = &snapshot.ice_address; let instant_percentage = utils::get_instant_percentage::(defi_user); - let (mut instant_amount, vesting_amount) = + let (mut instant_amount, vesting_amount) = utils::get_split_amounts::(total_amount, instant_percentage).map_err(|e |{ error!("At: get_split_amount. amount: {total_amount:?}. Instant percentage: {instant_percentage}. Reason: {e:?}"); e diff --git a/runtime/arctic/src/lib.rs b/runtime/arctic/src/lib.rs index b9ec2f95..d49c56f3 100644 --- a/runtime/arctic/src/lib.rs +++ b/runtime/arctic/src/lib.rs @@ -1067,12 +1067,11 @@ impl pallet_base_fee::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} -const AIRDROP_VESTING_TERMS: pallet_airdrop::VestingTerms = - pallet_airdrop::VestingTerms { - defi_instant_percentage: 100, - non_defi_instant_percentage: 100, - vesting_period: 7776000, - }; +const AIRDROP_VESTING_TERMS: pallet_airdrop::VestingTerms = pallet_airdrop::VestingTerms { + defi_instant_percentage: 100, + non_defi_instant_percentage: 100, + vesting_period: 7776000, +}; impl pallet_airdrop::Config for Runtime { type Event = Event; diff --git a/runtime/arctic/src/xcm_config.rs b/runtime/arctic/src/xcm_config.rs index b6f9f141..f36f8b05 100644 --- a/runtime/arctic/src/xcm_config.rs +++ b/runtime/arctic/src/xcm_config.rs @@ -160,7 +160,7 @@ impl xcm_executor::Config for XcmConfig { // How to withdraw and deposit an asset. type AssetTransactor = AssetTransactors; type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = ReserveAssetFilter; //NativeAsset; + type IsReserve = (); // ReserveAssetFilter; //NativeAsset; type IsTeleporter = (); // Teleporting is disabled. type LocationInverter = LocationInverter; type Barrier = XcmBarrier; diff --git a/runtime/frost/src/lib.rs b/runtime/frost/src/lib.rs index 7226f76a..72b6f226 100644 --- a/runtime/frost/src/lib.rs +++ b/runtime/frost/src/lib.rs @@ -572,12 +572,11 @@ impl pallet_simple_inflation::Config for Runtime { impl pallet_fees_split::Config for Runtime {} -const AIRDROP_VESTING_TERMS: pallet_airdrop::VestingTerms = - pallet_airdrop::VestingTerms { - defi_instant_percentage: 30, - non_defi_instant_percentage: 20, - vesting_period: 7776000, - }; +const AIRDROP_VESTING_TERMS: pallet_airdrop::VestingTerms = pallet_airdrop::VestingTerms { + defi_instant_percentage: 30, + non_defi_instant_percentage: 20, + vesting_period: 7776000, +}; impl pallet_airdrop::Config for Runtime { type Event = Event; type Currency = Balances; diff --git a/runtime/snow/src/lib.rs b/runtime/snow/src/lib.rs index 3f1044e1..82ba47b6 100644 --- a/runtime/snow/src/lib.rs +++ b/runtime/snow/src/lib.rs @@ -1067,12 +1067,11 @@ impl pallet_base_fee::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} -const AIRDROP_VESTING_TERMS: pallet_airdrop::VestingTerms = - pallet_airdrop::VestingTerms { - defi_instant_percentage: 100, - non_defi_instant_percentage: 100, - vesting_period: 7776000, - }; +const AIRDROP_VESTING_TERMS: pallet_airdrop::VestingTerms = pallet_airdrop::VestingTerms { + defi_instant_percentage: 100, + non_defi_instant_percentage: 100, + vesting_period: 7776000, +}; impl pallet_airdrop::Config for Runtime { type Event = Event; diff --git a/runtime/snow/src/xcm_config.rs b/runtime/snow/src/xcm_config.rs index b6f9f141..f36f8b05 100644 --- a/runtime/snow/src/xcm_config.rs +++ b/runtime/snow/src/xcm_config.rs @@ -160,7 +160,7 @@ impl xcm_executor::Config for XcmConfig { // How to withdraw and deposit an asset. type AssetTransactor = AssetTransactors; type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = ReserveAssetFilter; //NativeAsset; + type IsReserve = (); // ReserveAssetFilter; //NativeAsset; type IsTeleporter = (); // Teleporting is disabled. type LocationInverter = LocationInverter; type Barrier = XcmBarrier;