1. Apr 24, 2024
  2. Apr 17, 2024
    • PG Herveou's avatar
      Contracts: Refactor test builder (#4158) · aa78fe21
      PG Herveou authored
      - Moved `substrate/frame/contracts/src/tests/builder.rs` into a pub
      test_utils module, so we can use that in the
      `pallet-contracts-mock-network` tests
      - Refactor xcm tests to use XCM builders, and simplify the use case for
      xcm-send
      aa78fe21
  3. Mar 27, 2024
  4. Feb 19, 2024
    • PG Herveou's avatar
      Contracts: xcm host fn fixes (#3086) · ca382f32
      PG Herveou authored
      ## 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 <>
      ca382f32
  5. Jan 16, 2024
    • Francisco Aguirre's avatar
      XCMv4 (#1230) · 8428f678
      Francisco Aguirre authored
      
      
      # Note for reviewer
      
      Most changes are just syntax changes necessary for the new version.
      Most important files should be the ones under the `xcm` folder.
      
      # Description 
      
      Added XCMv4.
      
      ## Removed `Multi` prefix
      The following types have been renamed:
      - MultiLocation -> Location
      - MultiAsset -> Asset
      - MultiAssets -> Assets
      - InteriorMultiLocation -> InteriorLocation
      - MultiAssetFilter -> AssetFilter
      - VersionedMultiAsset -> VersionedAsset
      - WildMultiAsset -> WildAsset
      - VersionedMultiLocation -> VersionedLocation
      
      In order to fix a name conflict, the `Assets` in `xcm-executor` were
      renamed to `HoldingAssets`, as they represent assets in holding.
      
      ## Removed `Abstract` asset id
      
      It was not being used anywhere and this simplifies the code.
      
      Now assets are just constructed as follows:
      
      ```rust
      let asset: Asset = (AssetId(Location::new(1, Here)), 100u128).into();
      ```
      
      No need for specifying `Concrete` anymore.
      
      ## Outcome is now a named fields struct
      
      Instead of
      
      ```rust
      pub enum Outcome {
        Complete(Weight),
        Incomplete(Weight, Error),
        Error(Error),
      }
      ```
      
      we now have
      
      ```rust
      pub enum Outcome {
        Complete { used: Weight },
        Incomplete { used: Weight, error: Error },
        Error { error: Error },
      }
      ```
      
      ## Added Reanchorable trait
      
      Now both locations and assets implement this trait, making it easier to
      reanchor both.
      
      ## New syntax for building locations and junctions
      
      Now junctions are built using the following methods:
      
      ```rust
      let location = Location {
          parents: 1,
          interior: [Parachain(1000), PalletInstance(50), GeneralIndex(1984)].into()
      };
      ```
      
      or
      
      ```rust
      let location = Location::new(1, [Parachain(1000), PalletInstance(50), GeneralIndex(1984)]);
      ```
      
      And they are matched like so:
      
      ```rust
      match location.unpack() {
        (1, [Parachain(id)]) => ...
        (0, Here) => ...,
        (1, [_]) => ...,
      }
      ```
      
      This syntax is mandatory in v4, and has been also implemented for v2 and
      v3 for easier migration.
      
      This was needed to make all sizes smaller.
      
      # TODO
      - [x] Scaffold v4
      - [x] Port github.com/paritytech/polkadot/pull/7236
      - [x] Remove `Multi` prefix
      - [x] Remove `Abstract` asset id
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      8428f678
  6. Nov 29, 2023
    • PG Herveou's avatar
      Contracts: use compiled rust tests (#2347) · 2135fa87
      PG Herveou authored
      see #2189
      
      This PR does the following:
      - Bring the user api functions into a new pallet-contracts-uapi (They
      are currently defined in ink!
      [here])(https://github.com/paritytech/ink/blob/master/crates/env/src/engine/on_chain/ext.rs
      
      )
      - Add older api versions and unstable to the user api trait.
      - Remove pallet-contracts-primitives and bring the types it defined in
      uapi / pallet-contracts
      - Add the infrastructure to build fixtures from Rust files and test it
      works by replacing `dummy.wat` and `call.wat`
      - Move all the doc from wasm/runtime.rs to pallet-contracts-uapi.
      
      This will be done in a follow up:
      - convert the rest of the test from .wat to rust
      - bring risc-v uapi up to date with wasm
      - finalize the uapi host fns, making sure everything is codegen from the
      source host fns in pallet-contracts
      
      ---------
      
      Co-authored-by: default avatarAlexander Theißen <[email protected]>
      2135fa87
  7. Nov 14, 2023