diff --git a/cumulus b/cumulus index 825df85462..9b83c7325d 160000 --- a/cumulus +++ b/cumulus @@ -1 +1 @@ -Subproject commit 825df854624bdca89ae7cd47c0d77892a502f96b +Subproject commit 9b83c7325df5ec50fec2571f8ff304d40a7e88fe diff --git a/parachain/Cargo.lock b/parachain/Cargo.lock index 0bb6b50fcf..a446032731 100644 --- a/parachain/Cargo.lock +++ b/parachain/Cargo.lock @@ -274,9 +274,9 @@ dependencies = [ [[package]] name = "bounded-collections" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07fbd1d11282a1eb134d3c3b7cf8ce213b5161c6e5f73fb1b98618482c606b64" +checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" dependencies = [ "log", "parity-scale-codec", @@ -1889,6 +1889,22 @@ dependencies = [ "sp-timestamp", ] +[[package]] +name = "pallet-transaction-payment" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=master#e976964644d951a1eefaaa85f1d7c7d58211ddf7" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "parity-bytes" version = "0.1.2" @@ -1897,9 +1913,9 @@ checksum = "16b56e3a2420138bdb970f84dfb9c774aea80fa0e7371549eedec0d80c209c67" [[package]] name = "parity-scale-codec" -version = "3.4.0" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +checksum = "756d439303e94fae44f288ba881ad29670c65b0c4b0e05674ca81061bb65f2c5" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -1912,9 +1928,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.4" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +checksum = "9d884d78fcf214d70b1e239fcd1c6e5e95aa3be1881918da2e488cc946c7a476" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2075,9 +2091,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -2093,9 +2109,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" dependencies = [ "proc-macro2", ] @@ -2801,6 +2817,7 @@ dependencies = [ "sp-runtime", "sp-std", "xcm", + "xcm-builder", "xcm-executor", ] @@ -4119,12 +4136,35 @@ dependencies = [ "xcm-procedural", ] +[[package]] +name = "xcm-builder" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=master#b6b74fdf546c14bf9ac93c03916abda9ee33a52f" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-transaction-payment", + "parity-scale-codec", + "polkadot-parachain", + "scale-info", + "sp-arithmetic", + "sp-io", + "sp-runtime", + "sp-std", + "sp-weights", + "xcm", + "xcm-executor", +] + [[package]] name = "xcm-executor" version = "0.9.43" source = "git+https://github.com/paritytech/polkadot?branch=master#b6b74fdf546c14bf9ac93c03916abda9ee33a52f" dependencies = [ "environmental", + "frame-benchmarking", "frame-support", "impl-trait-for-tuples", "log", diff --git a/parachain/primitives/router/Cargo.toml b/parachain/primitives/router/Cargo.toml index 6d54a747df..33b0b99e18 100644 --- a/parachain/primitives/router/Cargo.toml +++ b/parachain/primitives/router/Cargo.toml @@ -18,6 +18,7 @@ sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "master xcm = { git = "https://github.com/paritytech/polkadot.git", branch = "master", default-features = false } xcm-executor = { git = "https://github.com/paritytech/polkadot.git", branch = "master", default-features = false } +xcm-builder = { git = "https://github.com/paritytech/polkadot.git", branch = "master", default-features = false } snowbridge-core = { path = "../../primitives/core", default-features = false } @@ -42,9 +43,11 @@ std = [ "sp-std/std", "xcm/std", "xcm-executor/std", + "xcm-builder/std", "snowbridge-core/std", "ethabi/std", ] runtime-benchmarks = [ "snowbridge-core/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", ] diff --git a/parachain/primitives/router/src/inbound/mod.rs b/parachain/primitives/router/src/inbound/mod.rs index c653859488..17bac19694 100644 --- a/parachain/primitives/router/src/inbound/mod.rs +++ b/parachain/primitives/router/src/inbound/mod.rs @@ -4,10 +4,10 @@ use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_support::{traits::ContainsPair, weights::Weight}; use sp_core::{Get, RuntimeDebug, H160}; -use sp_io::hashing::blake2_256; use sp_runtime::MultiAddress; use sp_std::prelude::*; use xcm::v3::{prelude::*, Junction::AccountKey20}; +use xcm_builder::{DescribeLocation, HashedDescription}; use xcm_executor::traits::ConvertLocation; const MINIMUM_DEPOSIT: u128 = 1; @@ -62,6 +62,8 @@ pub enum NativeTokensMessage { pub enum ConvertError { /// Message is in the wrong format BadFormat, + // Origin conversion failed. + BadOrigin, } impl TryInto> for MessageV1 { @@ -101,10 +103,17 @@ impl NativeTokensMessage { create_call_index, set_metadata_call_index, } => { - let owner = GlobalConsensusEthereumAccountConvertsFor::<[u8; 32]>::from_params( - &chain_id, - origin.as_fixed_bytes(), - ); + let owner = + GlobalConsensusEthereumAccountConvertsFor::<[u8; 32]>::convert_location( + &MultiLocation::new( + 2, + ( + GlobalConsensus(network), + AccountKey20 { network: None, key: *origin.as_fixed_bytes() }, + ), + ), + ) + .ok_or(ConvertError::BadOrigin)?; let origin_location = Junction::AccountKey20 { network: None, key: origin.into() }; @@ -224,6 +233,21 @@ impl NativeTokensMessage { } } +pub struct DescribeEthereumAccountKey20Terminal; +impl DescribeLocation for DescribeEthereumAccountKey20Terminal { + fn describe_location(l: &MultiLocation) -> Option> { + match (l.parents, &l.interior) { + (_, X2(GlobalConsensus(Ethereum { chain_id }), AccountKey20 { key, .. })) => { + Some((b"ethereum", chain_id, key).encode()) + }, + _ => return None, + } + } +} + +pub type GlobalConsensusEthereumAccountConvertsFor = + HashedDescription; + pub struct FromEthereumGlobalConsensus(PhantomData); impl ContainsPair for FromEthereumGlobalConsensus @@ -235,30 +259,6 @@ where } } -pub struct GlobalConsensusEthereumAccountConvertsFor(PhantomData); -impl ConvertLocation for GlobalConsensusEthereumAccountConvertsFor -where - AccountId: From<[u8; 32]> + Clone, -{ - fn convert_location(location: &MultiLocation) -> Option { - if let MultiLocation { - interior: X2(GlobalConsensus(Ethereum { chain_id }), AccountKey20 { key, .. }), - .. - } = location - { - Some(Self::from_params(chain_id, key).into()) - } else { - None - } - } -} - -impl GlobalConsensusEthereumAccountConvertsFor { - fn from_params(chain_id: &u64, key: &[u8; 20]) -> [u8; 32] { - (b"ethereum", chain_id, key).using_encoded(blake2_256) - } -} - #[cfg(test)] mod tests { use super::{FromEthereumGlobalConsensus, GlobalConsensusEthereumAccountConvertsFor}; diff --git a/smoketest/tests/create_token.rs b/smoketest/tests/create_token.rs index 0873ac77e0..a22e37abf8 100644 --- a/smoketest/tests/create_token.rs +++ b/smoketest/tests/create_token.rs @@ -13,8 +13,8 @@ use ethers::{ // contracts are deployed in DeployScript.sol. const ETHEREUM_API: &str = "http://localhost:8545"; const ETHEREUM_KEY: &str = "0x5e002a1af63fd31f1c25258f3082dc889762664cb8f218d86da85dff8b07b342"; -const NATIVE_TOKENS_CONTRACT: &str = "0x8cF6147918A5CBb672703F879f385036f8793a24"; -const WETH_CONTRACT: &str = "0x440eDFFA1352B13227e8eE646f3Ea37456deC701"; +const NATIVE_TOKENS_CONTRACT: &str = "0xB8EA8cB425d85536b158d661da1ef0895Bb92F1D"; +const WETH_CONTRACT: &str = "0x3f0839385DB9cBEa8E73AdA6fa0CFe07E321F61d"; #[tokio::test] async fn create_tokens() { diff --git a/smoketest/tests/lock_tokens.rs b/smoketest/tests/lock_tokens.rs index 9c27df0582..cb5908a076 100644 --- a/smoketest/tests/lock_tokens.rs +++ b/smoketest/tests/lock_tokens.rs @@ -18,9 +18,9 @@ use xcm::v3::{MultiLocation, Junction, Junctions::X1}; // contracts are deployed in DeployScript.sol. const ETHEREUM_API: &str = "http://localhost:8545"; const ETHEREUM_KEY: &str = "0x5e002a1af63fd31f1c25258f3082dc889762664cb8f218d86da85dff8b07b342"; -const TOKEN_VAULT_CONTRACT: &str = "0xB8EA8cB425d85536b158d661da1ef0895Bb92F1D"; -const NATIVE_TOKENS_CONTRACT: &str = "0x8cF6147918A5CBb672703F879f385036f8793a24"; -const WETH_CONTRACT: &str = "0x440eDFFA1352B13227e8eE646f3Ea37456deC701"; +const TOKEN_VAULT_CONTRACT: &str = "0xB1185EDE04202fE62D38F5db72F71e38Ff3E8305"; +const NATIVE_TOKENS_CONTRACT: &str = "0xB8EA8cB425d85536b158d661da1ef0895Bb92F1D"; +const WETH_CONTRACT: &str = "0x3f0839385DB9cBEa8E73AdA6fa0CFe07E321F61d"; // SS58: DE14BzQ1bDXWPKeLoAqdLAm1GpyAWaWF1knF74cEZeomTBM const FERDIE: [u8; 32] = hex!("1cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c");