Files
pezkuwi-subxt/bridges/snowbridge/parachain
Francisco Aguirre 8428f678fe XCMv4 (#1230)
# 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: Keith Yeung <kungfukeith11@gmail.com>
2024-01-16 18:18:04 +00:00
..
2024-01-16 18:18:04 +00:00
2024-01-16 18:18:04 +00:00
2024-01-16 18:18:04 +00:00

Snowbridge ·

[codecov] (https://codecov.io/gh/Snowfork/snowbridge) GitHub

Snowbridge is a trustless bridge between Polkadot and Ethereum. For documentation, visit https://docs.snowbridge.network.

Components

Parachain

Polkadot parachain and our pallets. See parachain/README.md.

Contracts

Ethereum contracts and unit tests. See contracts/README.md

Relayer

Off-chain relayer services for relaying messages between Polkadot and Ethereum. See relayer/README.md

Local Testnet

Scripts to provision a local testnet, running the above services to bridge between local deployments of Polkadot and Ethereum. See web/packages/test/README.md.

Smoke Tests

Integration tests for our local testnet. See smoketest/README.md.

Development

We use the Nix package manager to provide a reproducible and maintainable developer environment.

After installing nix Nix, enable flakes:

mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf

Then activate a developer shell in the root of our repo, where flake.nix is located:

nix develop

Also make sure to run this initialization script once:

scripts/init.sh

Support for code editors

To ensure your code editor (such as VS Code) can execute tools in the nix shell, startup your editor within the interactive shell.

Example for VS Code:

nix develop
code .

Custom shells

The developer shell is bash by default. To preserve your existing shell:

nix develop --command $SHELL

Automatic developer shells

To automatically enter the developer shell whenever you open the project, install direnv and use the template .envrc:

cp .envrc.example .envrc
direnv allow

Upgrading the Rust toolchain

Sometimes we would like to upgrade rust toolchain. First update parachain/rust-toolchain.toml as required and then update flake.lock running

nix flake lock --update-input rust-overlay

Troubleshooting

Check the contents of all .envrc files.

Remove untracked files:

git clean -idx

Ensure that the current Rust toolchain is the one selected in scripts/init.sh.

Ensure submodules are up-to-date:

git submodule update

Check untracked files & directories:

git clean -ndx | awk '{print $3}'

After removing node_modules directories (eg. with git clean above), clear the pnpm cache:

pnpm store prune

Check Nix config in ~/.config/nix/nix.conf.

Run a pure developer shell (note that this removes access to your local tools):

nix develop -i --pure-eval

Security

The security policy and procedures can be found in SECURITY.md.