Skip to content
Snippets Groups Projects
  1. Mar 14, 2025
  2. Mar 10, 2025
  3. Feb 24, 2025
    • Daniel Shiposha's avatar
      Fix DryRunApi client-facing XCM versions (#7438) · 963f0d73
      Daniel Shiposha authored
      
      # Description
      
      Fixes #7413
      
      ## Integration
      
      This PR updates the `DryRunApi`. The signature of the `dry_run_call` is
      changed, and the XCM version of the return values of `dry_run_xcm` now
      follows the version of the input XCM program.
      
      ## Review Notes
      
      * **The `DryRunApi` is modified**
      * **Added the `Router::clear_messages` to `dry_run_xcm` common
      implementation**
      * **Fixed the xcmp-queue's Router's clear_messages: channels details'
      first_index and last_index are reset when clearing**
      * **The MIN_XCM_VERSION is added**
      * The common implementation in the `pallet-xcm` is modified accordingly
      * The `DryRunApi` tests are modified to account for testing old XCM
      versions
      * The implementation from the `pallet-xcm` is used where it was not used
      (including the `DryRunApi` tests)
      * All the runtime implementations are modified according to the Runtime
      API change
      
      ---------
      
      Co-authored-by: default avatarAdrian Catangiu <adrian@parity.io>
  4. Feb 07, 2025
    • Przemek Rzad's avatar
      Ensure license headers match the Cargo manifest licenses (#5776) · 3726493d
      Przemek Rzad authored
      
      - Closes https://github.com/paritytech/license-scanner/issues/44
      - Silent because only comments are changed in the crates.
      
      ## What's inside
      
      First, we change the file traversal mechanism from shell globbing to
      walking through files which happens inside the `license-scanner` - so it
      has knowledge about directory structure and can correlate files with
      corresponding Cargo manifest.
      
      Next, added `MIT-0` and `Unlicense` to the allowed list of licenses.
      `Unlicense` appears only once across {Substrate,Cumulus,Polkadot} - in
      `penpal-runtime`.
      
      Finally, updated headers in files that do not match the corresponding
      manifest license.
      
      ---------
      
      Co-authored-by: Yuri Volkov's avatarcornholio <0@mcornholio.ru>
  5. Nov 26, 2024
  6. Sep 26, 2024
  7. Sep 16, 2024
  8. Aug 01, 2024
  9. Jun 26, 2024
    • Branislav Kontur's avatar
      [xcm] runtime api for LocationToAccount conversions (#4857) · 75069569
      Branislav Kontur authored
      
      Closes: https://github.com/paritytech/polkadot-sdk/issues/4298
      
      This PR also merges `xcm-fee-payment-runtime-api` module to the
      `xcm-runtime-api`.
      
      
      ## TODO
      
      - [x] rename `convert` to `convert_location` and add new one
      `convert_account` (opposite direction)
      - [x] add to the all testnet runtimes
      - [x] check polkadot-js if supports that automatically or if needs to be
      added manually https://github.com/polkadot-js/api/pull/5917
      - [ ] backport/patch for fellows and release (asap)
      
      ## Open questions
      - [x] should we merge `xcm-runtime-api` and
      `xcm-fee-payment-runtime-api` to the one module `xcm-runtime-api` ?
      
      ## Usage
      Input:
       - `location:  VersionedLocation`
       
      Output:
       - account_id bytes
      
      
      ![image](https://github.com/paritytech/polkadot-sdk/assets/8159517/4607b15a-77d2-462b-806c-606107776c0d)
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
  10. May 29, 2024
    • Francisco Aguirre's avatar
      Change `XcmDryRunApi::dry_run_extrinsic` to take a call instead (#4621) · d5053ac4
      Francisco Aguirre authored
      
      Follow-up to the new `XcmDryRunApi` runtime API introduced in
      https://github.com/paritytech/polkadot-sdk/pull/3872.
      
      Taking an extrinsic means the frontend has to sign first to dry-run and
      once again to submit.
      This is bad UX which is solved by taking an `origin` and a `call`.
      This also has the benefit of being able to dry-run as any account, since
      it needs no signature.
      
      This is a breaking change since I changed `dry_run_extrinsic` to
      `dry_run_call`, however, this API is still only on testnets.
      The crates are bumped accordingly.
      
      As a part of this PR, I changed the name of the API from `XcmDryRunApi`
      to just `DryRunApi`, since it can be used for general dry-running :)
      
      Step towards https://github.com/paritytech/polkadot-sdk/issues/690.
      
      Example of calling the API with PAPI, not the best code, just testing :)
      
      ```ts
      // We just build a call, the arguments make it look very big though.
      const call = localApi.tx.XcmPallet.transfer_assets({
        dest: XcmVersionedLocation.V4({ parents: 0, interior: XcmV4Junctions.X1(XcmV4Junction.Parachain(1000)) }),
        beneficiary: XcmVersionedLocation.V4({ parents: 0, interior: XcmV4Junctions.X1(XcmV4Junction.AccountId32({ network: undefined, id: Binary.fromBytes(encodeAccount(account.address)) })) }),
        weight_limit: XcmV3WeightLimit.Unlimited(),
        assets: XcmVersionedAssets.V4([{
          id: { parents: 0, interior: XcmV4Junctions.Here() },
          fun: XcmV3MultiassetFungibility.Fungible(1_000_000_000_000n) }
        ]),
        fee_asset_item: 0,
      });
      // We call the API passing in a signed origin 
      const result = await localApi.apis.XcmDryRunApi.dry_run_call(
        WestendRuntimeOriginCaller.system(DispatchRawOrigin.Signed(account.address)),
        call.decodedCall
      );
      if (result.success && result.value.execution_result.success) {
        // We find the forwarded XCM we want. The first one going to AssetHub in this case.
        const xcmsToAssetHub = result.value.forwarded_xcms.find(([location, _]) => (
          location.type === "V4" &&
            location.value.parents === 0 &&
            location.value.interior.type === "X1"
            && location.value.interior.value.type === "Parachain"
            && location.value.interior.value.value === 1000
        ))!;
      
        // We can even find the delivery fees for that forwarded XCM.
        const deliveryFeesQuery = await localApi.apis.XcmPaymentApi.query_delivery_fees(xcmsToAssetHub[0], xcmsToAssetHub[1][0]);
      
        if (deliveryFeesQuery.success) {
          const amount = deliveryFeesQuery.value.type === "V4" && deliveryFeesQuery.value.value[0].fun.type === "Fungible" && deliveryFeesQuery.value.value[0].fun.value.valueOf() || 0n;
          // We store them in state somewhere.
          setDeliveryFees(formatAmount(BigInt(amount)));
        }
      }
      ```
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
  11. May 21, 2024
  12. May 08, 2024
    • Francisco Aguirre's avatar
      XcmDryRunApi - Dry-running extrinsics to get their XCM effects (#3872) · 7213e363
      Francisco Aguirre authored
      
      # Context
      
      Estimating fees for XCM execution and sending has been an area with bad
      UX.
      The addition of the
      [XcmPaymentApi](https://github.com/paritytech/polkadot-sdk/pull/3607)
      exposed the necessary components to be able to estimate XCM fees
      correctly, however, that was not the full story.
      The `XcmPaymentApi` works for estimating fees only if you know the
      specific XCM you want to execute or send.
      This is necessary but most UIs want to estimate the fees for extrinsics,
      they don't necessarily know the XCM program that's executed by them.
      
      # Main addition
      
      A new runtime API is introduced, the `XcmDryRunApi`, that given an
      extrinsic, or an XCM program, returns its effects:
      - Execution result
      - Local XCM (in the case of an extrinsic)
      - Forwarded XCMs
      - List of events
      
      This API can be used on its own for dry-running purposes, for
      double-checking or testing, but it mainly shines when used in
      conjunction with the `XcmPaymentApi`.
      UIs can use these two APIs to estimate transfers.
      
      # How it works
      
      New tests are added to exemplify how to incorporate both APIs.
      There's a mock test just to make sure everything works under
      `xcm-fee-payment-runtime-api`.
      There's a real-world test using Westend and AssetHubWestend under
      `cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs`.
      Added both a test for a simple teleport between chains and a reserve
      transfer asset between two parachains going through a reserve.
      
      The steps to follow:
      - Use `XcmDryRunApi::dry_run_extrinsic` to get local XCM program and
      forwarded messages
      - For each forwarded message
      - Use `XcmPaymentApi::query_delivery_fee` LOCALLY to get the delivery
      fees
      - Use `XcmPaymentApi::query_xcm_weight` ON THE DESTINATION to get the
      remote execution weight
      - (optional) Use `XcmPaymentApi::query_acceptable_payment_assets` ON THE
      DESTINATION to know on which assets the execution fees can be paid
      - Use `XcmPaymentApi::query_weight_to_asset_fee` ON THE DESTINATION to
      convert weight to the actual remote execution fees
      - Use `XcmDryRunApi::dry_run_xcm` ON THE DESTINATION to know if a new
      message will be forwarded, if so, continue
      
      # Dear reviewer
      
      The changes in this PR are grouped as follows, and in order of
      importance:
      - Addition of new runtime API
      - Definition, mock and simple tests:
      polkadot/xcm/xcm-fee-payment-runtime-api/*
      - Implemented on Westend, Asset Hub Westend and Penpal, will implement
      on every runtime in a following PR
      - Addition of a new config item to the XCM executor for recording xcms
      about to be executed
        - Definition: polkadot/xcm/xcm-executor/*
        - Implementation: polkadot/xcm/pallet-xcm/*
      - had to update all runtime xcm_config.rs files with `type XcmRecorder =
      XcmPallet;`
      - Addition of a new trait for inspecting the messages in queues
        - Definition: polkadot/xcm/xcm-builder/src/routing.rs
        - Implemented it on all routers:
          - ChildParachainRouter: polkadot/runtime/common/src/xcm_sender.rs
      - ParentAsUmp: cumulus/primitives/utility/src/lib.rs (piggybacked on
      implementation in cumulus/pallets/parachain-system/src/lib.rs)
          - XcmpQueue: cumulus/pallets/xcmp-queue/src/lib.rs
          - Bridge: bridges/modules/xcm-bridge-hub-router/src/lib.rs
      - More complicated and useful tests:
      -
      cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs
      
      ## Next steps
      
      With this PR, Westend, AssetHubWestend, Rococo and AssetHubRococo have
      the new API.
      UIs can test on these runtimes to create better experiences around
      cross-chain operations.
      
      Next:
      - Add XcmDryRunApi to all system parachains
      - Integrate xcm fee estimation in all emulated tests
      - Get this on the fellowship runtimes
      
      ---------
      
      Co-authored-by: default avatarAdrian Catangiu <adrian@parity.io>