Skip to content

Commit

Permalink
Merge pull request #111 from web3labs/update-xcm-spec
Browse files Browse the repository at this point in the history
disable xcm filter, add xcm safe version & cargo fmt
  • Loading branch information
mohamedelshami authored Jul 14, 2022
2 parents d3fa17c + 07992dd commit eba9da6
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 77 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
11 changes: 7 additions & 4 deletions node/src/chain_spec/arctic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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(),
Expand Down
121 changes: 71 additions & 50 deletions node/src/chain_spec/snow.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,6 +20,7 @@ use super::{get_from_seed, Extensions};
pub type SnowChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;

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;
Expand Down Expand Up @@ -58,12 +59,14 @@ pub fn get_dev_chain_spec() -> SnowChainSpec {
];

let endowed_accounts = vec![
(
(get_account_id_from_seed::<sr25519::Public>("Alice"), ICY * 300_000_000)
),
(
(get_account_id_from_seed::<sr25519::Public>("Bob"), ICY * 300_000_000)
),
((
get_account_id_from_seed::<sr25519::Public>("Alice"),
ICY * 300_000_000,
)),
((
get_account_id_from_seed::<sr25519::Public>("Bob"),
ICY * 300_000_000,
)),
];

let council_members = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -171,7 +191,6 @@ pub fn testnet_spec() -> SnowChainSpec {
para_id: PARA_ID,
},
)

}

/// Helper function to create GenesisConfig.
Expand All @@ -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 {
Expand Down Expand Up @@ -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(),
}
}

Expand All @@ -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::<sr25519::Public>(seed),
get_from_seed::<AuraId>(seed),
)
(
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<AuraId>(seed),
)
}

/// Helper for session keys to map aura id
Expand Down
4 changes: 2 additions & 2 deletions pallets/airdrop/src/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ pub fn do_transfer<T: airdrop::Config>(snapshot: &mut types::SnapshotInfo<T>) ->
let vesting_should_end_in = <T as airdrop::Config>::VESTING_TERMS.vesting_period;
let creditor = AirdropModule::<T>::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::<T>(defi_user);

let (mut instant_amount, vesting_amount) =
let (mut instant_amount, vesting_amount) =
utils::get_split_amounts::<T>(total_amount, instant_percentage).map_err(|e |{
error!("At: get_split_amount. amount: {total_amount:?}. Instant percentage: {instant_percentage}. Reason: {e:?}");
e
Expand Down
11 changes: 5 additions & 6 deletions runtime/arctic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion runtime/arctic/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ancestry>;
type Barrier = XcmBarrier;
Expand Down
11 changes: 5 additions & 6 deletions runtime/frost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions runtime/snow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion runtime/snow/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ancestry>;
type Barrier = XcmBarrier;
Expand Down

0 comments on commit eba9da6

Please sign in to comment.