diff --git a/Cargo.lock b/Cargo.lock index c02246eb..5a144e8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5318,6 +5318,7 @@ dependencies = [ "staging-xcm-executor", "substrate-wasm-builder", "test-utils", + "xcm-runtime-apis", ] [[package]] @@ -9654,6 +9655,7 @@ dependencies = [ "async-trait", "frame-benchmarking", "frame-benchmarking-cli", + "frame-metadata-hash-extension", "frame-system", "frame-system-rpc-runtime-api", "futures", @@ -9702,6 +9704,7 @@ dependencies = [ "polkadot-runtime-parachains", "polkadot-statement-distribution", "rococo-runtime", + "rococo-runtime-constants", "sc-authority-discovery", "sc-basic-authorship", "sc-chain-spec", diff --git a/Cargo.toml b/Cargo.toml index dbc32c7b..5c526dfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -220,6 +220,7 @@ xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-s xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } +xcm-runtime-apis = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false } # (native) polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409" } diff --git a/node/Cargo.toml b/node/Cargo.toml index 9312cba5..2988e461 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -54,8 +54,8 @@ substrate-frame-rpc-system = { workspace = true } substrate-prometheus-endpoint = { workspace = true } # Polkadot -polkadot-cli = { workspace = true } -polkadot-service = { workspace = true } +polkadot-cli = { workspace = true, features = ["rococo-native"] } +polkadot-service = { workspace = true, features = ["rococo-native"] } polkadot-primitives = { workspace = true } xcm = { workspace = true } laos-primitives = { workspace = true } diff --git a/runtime/laos/Cargo.toml b/runtime/laos/Cargo.toml index 70d218b8..93c539bd 100644 --- a/runtime/laos/Cargo.toml +++ b/runtime/laos/Cargo.toml @@ -82,6 +82,7 @@ polkadot-parachain-primitives = { workspace = true } xcm = { workspace = true } xcm-builder = { workspace = true } xcm-executor = { workspace = true } +xcm-runtime-apis = { workspace = true } # Cumulus cumulus-pallet-aura-ext = { workspace = true } @@ -188,6 +189,7 @@ std = [ "sp-genesis-builder/std", "xcm-builder/std", "xcm-executor/std", + "xcm-runtime-apis/std", "xcm/std", "substrate-wasm-builder", # Frontier diff --git a/runtime/laos/src/lib.rs b/runtime/laos/src/lib.rs index c92dd39e..bd6a2879 100644 --- a/runtime/laos/src/lib.rs +++ b/runtime/laos/src/lib.rs @@ -29,6 +29,7 @@ pub mod types; mod weights; pub use configs::laos_evolution::REVERT_BYTECODE; +use configs::xcm_config; use core::marker::PhantomData; use fp_rpc::TransactionStatus; use frame_support::{ @@ -58,6 +59,8 @@ use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; +use xcm::{VersionedLocation, VersionedXcm}; +use xcm_runtime_apis::dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}; /// Block type as expected by this runtime. pub type Block = generic::Block; @@ -635,4 +638,14 @@ impl_runtime_apis! { Default::default() } } + + impl xcm_runtime_apis::dry_run::DryRunApi for Runtime { + fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_call::(origin, call) + } + + fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_xcm::(origin_location, xcm) + } + } } diff --git a/runtime/laos/src/tests/metadata15.golden b/runtime/laos/src/tests/metadata15.golden index 6f816168..8fb325b4 100644 --- a/runtime/laos/src/tests/metadata15.golden +++ b/runtime/laos/src/tests/metadata15.golden @@ -37750,6 +37750,366 @@ }, { "id": 653, + "type": { + "path": [ + "Result" + ], + "params": [ + { + "name": "T", + "type": 654 + }, + { + "name": "E", + "type": 663 + } + ], + "def": { + "variant": { + "variants": [ + { + "name": "Ok", + "fields": [ + { + "type": 654 + } + ], + "index": 0 + }, + { + "name": "Err", + "fields": [ + { + "type": 663 + } + ], + "index": 1 + } + ] + } + } + } + }, + { + "id": 654, + "type": { + "path": [ + "xcm_runtime_apis", + "dry_run", + "CallDryRunEffects" + ], + "params": [ + { + "name": "Event", + "type": 22 + } + ], + "def": { + "composite": { + "fields": [ + { + "name": "execution_result", + "type": 655, + "typeName": "DispatchResultWithPostInfo" + }, + { + "name": "emitted_events", + "type": 658, + "typeName": "Vec" + }, + { + "name": "local_xcm", + "type": 659, + "typeName": "Option>" + }, + { + "name": "forwarded_xcms", + "type": 660, + "typeName": "Vec<(VersionedLocation, Vec>)>" + } + ] + } + } + } + }, + { + "id": 655, + "type": { + "path": [ + "Result" + ], + "params": [ + { + "name": "T", + "type": 656 + }, + { + "name": "E", + "type": 657 + } + ], + "def": { + "variant": { + "variants": [ + { + "name": "Ok", + "fields": [ + { + "type": 656 + } + ], + "index": 0 + }, + { + "name": "Err", + "fields": [ + { + "type": 657 + } + ], + "index": 1 + } + ] + } + } + } + }, + { + "id": 656, + "type": { + "path": [ + "frame_support", + "dispatch", + "PostDispatchInfo" + ], + "def": { + "composite": { + "fields": [ + { + "name": "actual_weight", + "type": 188, + "typeName": "Option" + }, + { + "name": "pays_fee", + "type": 26, + "typeName": "Pays" + } + ] + } + } + } + }, + { + "id": 657, + "type": { + "path": [ + "sp_runtime", + "DispatchErrorWithPostInfo" + ], + "params": [ + { + "name": "Info", + "type": 656 + } + ], + "def": { + "composite": { + "fields": [ + { + "name": "post_info", + "type": 656, + "typeName": "Info" + }, + { + "name": "error", + "type": 27, + "typeName": "DispatchError" + } + ] + } + } + } + }, + { + "id": 658, + "type": { + "def": { + "sequence": { + "type": 22 + } + } + } + }, + { + "id": 659, + "type": { + "path": [ + "Option" + ], + "params": [ + { + "name": "T", + "type": 310 + } + ], + "def": { + "variant": { + "variants": [ + { + "name": "None", + "index": 0 + }, + { + "name": "Some", + "fields": [ + { + "type": 310 + } + ], + "index": 1 + } + ] + } + } + } + }, + { + "id": 660, + "type": { + "def": { + "sequence": { + "type": 661 + } + } + } + }, + { + "id": 661, + "type": { + "def": { + "tuple": [ + 131, + 662 + ] + } + } + }, + { + "id": 662, + "type": { + "def": { + "sequence": { + "type": 310 + } + } + } + }, + { + "id": 663, + "type": { + "path": [ + "xcm_runtime_apis", + "dry_run", + "Error" + ], + "def": { + "variant": { + "variants": [ + { + "name": "Unimplemented", + "index": 0 + }, + { + "name": "VersionedConversionFailed", + "index": 1 + } + ] + } + } + } + }, + { + "id": 664, + "type": { + "path": [ + "Result" + ], + "params": [ + { + "name": "T", + "type": 665 + }, + { + "name": "E", + "type": 663 + } + ], + "def": { + "variant": { + "variants": [ + { + "name": "Ok", + "fields": [ + { + "type": 665 + } + ], + "index": 0 + }, + { + "name": "Err", + "fields": [ + { + "type": 663 + } + ], + "index": 1 + } + ] + } + } + } + }, + { + "id": 665, + "type": { + "path": [ + "xcm_runtime_apis", + "dry_run", + "XcmDryRunEffects" + ], + "params": [ + { + "name": "Event", + "type": 22 + } + ], + "def": { + "composite": { + "fields": [ + { + "name": "execution_result", + "type": 59, + "typeName": "Outcome" + }, + { + "name": "emitted_events", + "type": 658, + "typeName": "Vec" + }, + { + "name": "forwarded_xcms", + "type": 660, + "typeName": "Vec<(VersionedLocation, Vec>)>" + } + ] + } + } + } + }, + { + "id": 666, "type": { "path": [ "laos_runtime", @@ -38661,7 +39021,7 @@ 0, 0, 0, - 56, + 60, 221, 113, 141, @@ -38830,6 +39190,18 @@ 0, 0, 0, + 145, + 177, + 200, + 177, + 99, + 40, + 235, + 146, + 1, + 0, + 0, + 0, 1, 0, 0, @@ -45576,12 +45948,62 @@ "docs": [ " API to interact with RuntimeGenesisConfig for the runtime" ] + }, + { + "name": "DryRunApi", + "methods": [ + { + "name": "dry_run_call", + "inputs": [ + { + "name": "origin", + "ty": 245 + }, + { + "name": "call", + "ty": 242 + } + ], + "output": 653, + "docs": [ + " Dry run call." + ] + }, + { + "name": "dry_run_xcm", + "inputs": [ + { + "name": "origin_location", + "ty": 131 + }, + { + "name": "xcm", + "ty": 336 + } + ], + "output": 664, + "docs": [ + " Dry run XCM program" + ] + } + ], + "docs": [ + " API for dry-running extrinsics and XCM programs to get the programs that need to be passed to the fees API.", + "", + " All calls return a vector of tuples (location, xcm) where each \"xcm\" is executed in \"location\".", + " If there's local execution, the location will be \"Here\".", + " This vector can be used to calculate both execution and delivery fees.", + "", + " Calls or XCMs might fail when executed, this doesn't mean the result of these calls will be an `Err`.", + " In those cases, there might still be a valid result, with the execution error inside it.", + " The only reasons why these calls might return an error are listed in the [`Error`] enum." + ] } ], "outer_enums": { "call_enum_ty": 242, "event_enum_ty": 22, - "error_enum_ty": 653 + "error_enum_ty": 666 }, "custom": { "map": {}