From 334d42fd86cd747b4214617dafd96a47f63835e4 Mon Sep 17 00:00:00 2001 From: Gabriel Facco de Arruda Date: Mon, 8 Jan 2024 14:25:14 +0800 Subject: [PATCH] Now we're thinking with portals! --- Cargo.lock | 73 +++++++++++++++++++++++++++++---------- Cargo.toml | 2 ++ node/Cargo.toml | 3 ++ runtime/Cargo.toml | 2 ++ runtime/src/lib.rs | 2 +- runtime/src/xcm_config.rs | 21 ++++++++--- rust-toolchain.toml | 2 +- 7 files changed, 80 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f822e33..fb64d39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,7 +323,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -524,21 +524,45 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.59.2" +version = "0.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722" dependencies = [ "bitflags", "cexpr", "clang-sys", "lazy_static", "lazycell", + "log", "peeking_take_while", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", + "syn 1.0.109", + "which", +] + +[[package]] +name = "bindgen" +version = "0.65.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.16", ] [[package]] @@ -1830,7 +1854,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -1847,7 +1871,7 @@ checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -2116,7 +2140,7 @@ checksum = "9d2c772ccdbdfd1967b4f5d79d17c98ebf92009fdcc838db7aa434462f600c26" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -2127,7 +2151,7 @@ checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -2751,7 +2775,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -2926,6 +2950,7 @@ name = "gm-chain-node" version = "0.1.0" dependencies = [ "async-trait", + "bindgen 0.62.0", "clap", "cumulus-client-cli", "cumulus-client-collator", @@ -4441,11 +4466,11 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "0.6.1+6.28.2" +version = "0.6.2+6.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc587013734dadb7cf23468e531aa120788b87243648be42e2d3a072186291" +checksum = "0e2b9e6ebab00f474f490cd4b8676e4b2c045708f705f053107e3adc464057e8" dependencies = [ - "bindgen", + "bindgen 0.65.1", "bzip2-sys", "cc", "glob", @@ -6416,7 +6441,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -7659,6 +7684,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" +dependencies = [ + "proc-macro2", + "syn 2.0.16", +] + [[package]] name = "primitive-types" version = "0.11.1" @@ -8063,7 +8098,7 @@ checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -9662,7 +9697,7 @@ checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -10816,9 +10851,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" dependencies = [ "proc-macro2", "quote", @@ -10915,7 +10950,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -11039,7 +11074,7 @@ checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] @@ -12238,7 +12273,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.16", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ccc9189..3ce7c8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,5 +8,7 @@ members = [ "runtime", ] +resolver = "2" + [patch.crates-io] ss58-registry = { git = "https://github.com/paritytech/ss58-registry" } diff --git a/node/Cargo.toml b/node/Cargo.toml index bb27599..89e2be3 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -25,6 +25,9 @@ async-trait = { version = "0.1.48" } jsonrpc-core = "18.0.0" hex = "0.4.0" +#librocksdb-sys = "=0.6.2+6.28.2" +bindgen = "0.62" + # Local gm-chain-runtime = { path = "../runtime" } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index deaeeb2..eb6003f 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -22,6 +22,8 @@ scale-info = { version = "2.1", default-features = false, features = ["derive"] serde = { version = "1.0.137", optional = true, features = ["derive"] } smallvec = "1.6.1" +#librocksdb-sys = "=0.6.2+6.28.2" + # Chess pallet-chess = { git = "https://github.com/SubstrateChess/pallet-chess.git", default-features = false, branch = "gmordie" } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index bd14e5d..5aca519 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -179,7 +179,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("gm_parachain"), impl_name: create_runtime_str!("gm_parachain"), authoring_version: 1, - spec_version: 9, + spec_version: 10, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/src/xcm_config.rs b/runtime/src/xcm_config.rs index f6d0282..edbc7fb 100644 --- a/runtime/src/xcm_config.rs +++ b/runtime/src/xcm_config.rs @@ -26,6 +26,11 @@ parameter_types! { pub const RelayNetwork: NetworkId = NetworkId::Any; pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + + /// The check account, which holds any native assets that have been teleported out and not back in (yet). + pub CheckAccount: AccountId = PolkadotXcm::check_account(); + + pub const FrenLocation: MultiLocation = MultiLocation { parents: 0, interior: Here }; } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -45,13 +50,13 @@ pub type LocalAssetTransactor = CurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: LocationToAccountId, // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, - // We don't track any teleports. - (), + // We track our teleports in/out to keep total issuance correct. + CheckAccount, >; /// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, @@ -180,6 +185,14 @@ pub type Barrier = DenyThenTry< ), >; +parameter_types! { + pub const AssetHub: MultiLocation = MultiLocation { parents: 1, interior: X1(Parachain(1000)) }; + pub const FrenFilter: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(FrenLocation::get()) }); + pub const FrenForAssetHub: (MultiAssetFilter, MultiLocation) = (FrenFilter::get(), AssetHub::get()); +} + +pub type TrustedTeleporters = (xcm_builder::Case,); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type Call = Call; @@ -188,7 +201,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; - type IsTeleporter = (); // Teleporting is disabled. + type IsTeleporter = TrustedTeleporters; type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b6a80df..e400939 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] channel = "nightly-2022-11-01" targets = ["wasm32-unknown-unknown"] -components = [ "rustfmt", "rustc", "rust-std", "cargo", "clippy", "llvm-tools-preview"] +components = [ "rustfmt", "rustc", "rust-std", "cargo", "clippy", "llvm-tools-preview", "rust-analyzer"]