Contracts: xcm host fn fixes (#3086)
## Xcm changes: - Fix `pallet_xcm::execute`, move the logic into The `ExecuteController` so it can be shared with anything that implement that trait. - Make `ExecuteController::execute` retursn `DispatchErrorWithPostInfo` instead of `DispatchError`, so that we don't charge the full `max_weight` provided if the execution is incomplete (useful for force_batch or contracts calls) - Fix docstring for `pallet_xcm::execute`, to reflect the changes from #2405 - Update the signature for `ExecuteController::execute`, we don't need to return the `Outcome` anymore since we only care about `Outcome::Complete` ## Contracts changes: - Update host fn `xcm_exexute`, we don't need to write the `Outcome` to the sandbox memory anymore. This was also not charged as well before so it if fixes this too. - One of the issue was that the dry_run of a contract that call `xcm_execute` would exhaust the `gas_limit`. This is because `XcmExecuteController::execute` takes a `max_weight` argument, and since we don't want the user to specify it manually we were passing everything left by pre-charghing `ctx.ext.gas_meter().gas_left()` - To fix it I added a `fn influence_lowest_limit` on the `Token` trait and make it return false for `RuntimeCost::XcmExecute`. - Got rid of the `RuntimeToken` indirection, we can just use `RuntimeCost` directly. --------- Co-authored-by: command-bot <>
Showing
- polkadot/xcm/pallet-xcm/src/lib.rs 34 additions, 26 deletionspolkadot/xcm/pallet-xcm/src/lib.rs
- polkadot/xcm/pallet-xcm/src/tests/mod.rs 21 additions, 17 deletionspolkadot/xcm/pallet-xcm/src/tests/mod.rs
- polkadot/xcm/xcm-builder/src/controller.rs 10 additions, 5 deletionspolkadot/xcm/xcm-builder/src/controller.rs
- substrate/frame/contracts/fixtures/contracts/xcm_execute.rs 6 additions, 5 deletionssubstrate/frame/contracts/fixtures/contracts/xcm_execute.rs
- substrate/frame/contracts/mock-network/src/lib.rs 2 additions, 1 deletionsubstrate/frame/contracts/mock-network/src/lib.rs
- substrate/frame/contracts/mock-network/src/tests.rs 54 additions, 17 deletionssubstrate/frame/contracts/mock-network/src/tests.rs
- substrate/frame/contracts/src/exec.rs 7 additions, 0 deletionssubstrate/frame/contracts/src/exec.rs
- substrate/frame/contracts/src/gas.rs 8 additions, 1 deletionsubstrate/frame/contracts/src/gas.rs
- substrate/frame/contracts/src/wasm/mod.rs 4 additions, 0 deletionssubstrate/frame/contracts/src/wasm/mod.rs
- substrate/frame/contracts/src/wasm/runtime.rs 41 additions, 54 deletionssubstrate/frame/contracts/src/wasm/runtime.rs
- substrate/frame/contracts/uapi/src/host.rs 1 addition, 2 deletionssubstrate/frame/contracts/uapi/src/host.rs
- substrate/frame/contracts/uapi/src/host/riscv32.rs 1 addition, 1 deletionsubstrate/frame/contracts/uapi/src/host/riscv32.rs
- substrate/frame/contracts/uapi/src/host/wasm32.rs 3 additions, 4 deletionssubstrate/frame/contracts/uapi/src/host/wasm32.rs
Please register or sign in to comment