Skip to content

Commit

Permalink
Fix Control Tool for Paseo and Westend (#1340)
Browse files Browse the repository at this point in the history
* update runtimes and fix pre-image

* add workflow to check build

* remove id

* install nix

* install rust step

* ws

* update urls

* fix scripts

* ws
  • Loading branch information
alistair-singh authored Dec 3, 2024
1 parent 2d2ac78 commit c7ae26f
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 22 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/control.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: control

on:
push:
paths:
- "control/**"
branches:
- main
pull_request:
paths:
- "control/**"

jobs:
control:
runs-on: snowbridge-runner
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
RUSTFLAGS: -C debuginfo=1
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 2

- uses: actions/cache@v1
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Rust
run: |
nix develop -c sh -c '
echo "Installing Rust nightly toolchain"
rustup default stable
rustup target add wasm32-unknown-unknown
rustup component add rust-src
rustup install --profile minimal $RUST_NIGHTLY_VERSION
rustup component add --toolchain $RUST_NIGHTLY_VERSION rustfmt
rustup show
'
- name: Build Paseo
run: |
nix develop -c sh -c 'cd control && cargo build --features paseo'
- name: Build Polkadot
run: |
nix develop -c sh -c 'cd control && cargo build --features polkadot'
- name: Build Westend
run: |
nix develop -c sh -c 'cd control && cargo build --features westend'
6 changes: 6 additions & 0 deletions control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ NOTE: To test an upgrade that has not executed yet on the relevant environment,

To update the runtime code binding, run the following commands:

```shell
./update-runtimes.sh
```

You can update runtimes manually with the following commands:

```shell
subxt metadata --url wss://polkadot-rpc.dwellir.com -f bytes -o runtimes/polkadot/polkadot-metadata.bin
subxt metadata --url wss://bridge-hub-polkadot-rpc.dwellir.com -f bytes -o runtimes/bridge-hub-polkadot/bridge-hub-metadata.bin
Expand Down
50 changes: 32 additions & 18 deletions control/preimage/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,53 @@ use crate::bridge_hub_runtime::runtime_types::{
};
use crate::bridge_hub_runtime::RuntimeCall as BridgeHubRuntimeCall;

#[cfg(any(feature = "polkadot", feature = "paseo"))]
#[cfg(feature = "polkadot")]
pub mod asset_hub_polkadot_types {
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v4::location::Location;
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v4::{
junction::Junction::AccountKey20, junction::Junction::GlobalConsensus, junction::NetworkId,
junctions::Junctions::X2,
junctions::Junctions::X2, location::Location,
};
pub fn get_asset_id(chain_id: u64, key: [u8; 20]) -> Location {
return Location {
parents: 2,
interior: X2([
GlobalConsensus(NetworkId::Ethereum { chain_id: chain_id }),
AccountKey20 {
network: None,
key: key,
},
GlobalConsensus(NetworkId::Ethereum { chain_id }),
AccountKey20 { network: None, key },
]),
};
}
}

#[cfg(feature = "paseo")]
pub mod asset_hub_paseo_types {
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v3::multilocation::MultiLocation;
pub use crate::asset_hub_runtime::runtime_types::xcm::v3::{
junction::Junction::AccountKey20, junction::Junction::GlobalConsensus, junction::NetworkId,
junctions::Junctions::X2,
};
pub fn get_asset_id(chain_id: u64, key: [u8; 20]) -> MultiLocation {
return MultiLocation {
parents: 2,
interior: X2(
GlobalConsensus(NetworkId::Ethereum { chain_id }),
AccountKey20 { network: None, key },
),
};
}
}

#[cfg(feature = "westend")]
pub mod asset_hub_westend_types {
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v4::location::Location;
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v4::{
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v5::{
junction::Junction::AccountKey20, junction::Junction::GlobalConsensus, junction::NetworkId,
junctions::Junctions::X2,
junctions::Junctions::X2, location::Location,
};
pub fn get_asset_id(chain_id: u64, key: [u8; 20]) -> Location {
return Location {
parents: 2,
interior: X2([
GlobalConsensus(NetworkId::Ethereum { chain_id: chain_id }),
AccountKey20 {
network: None,
key: key,
},
GlobalConsensus(NetworkId::Ethereum { chain_id }),
AccountKey20 { network: None, key },
]),
};
}
Expand Down Expand Up @@ -262,7 +272,9 @@ pub fn set_gateway_address(params: &GatewayAddressArgs) -> BridgeHubRuntimeCall
pub fn make_asset_sufficient(params: &UpdateAssetArgs) -> AssetHubRuntimeCall {
use subxt::utils::AccountId32;
let chain_id = crate::bridge_hub_runtime::CHAIN_ID;
#[cfg(any(feature = "polkadot", feature = "paseo"))]
#[cfg(feature = "paseo")]
use asset_hub_paseo_types::*;
#[cfg(feature = "polkadot")]
use asset_hub_polkadot_types::*;
#[cfg(feature = "westend")]
use asset_hub_westend_types::*;
Expand All @@ -282,7 +294,9 @@ pub fn make_asset_sufficient(params: &UpdateAssetArgs) -> AssetHubRuntimeCall {

pub fn force_set_metadata(params: &UpdateAssetArgs) -> AssetHubRuntimeCall {
let chain_id = crate::bridge_hub_runtime::CHAIN_ID;
#[cfg(any(feature = "polkadot", feature = "paseo"))]
#[cfg(feature = "paseo")]
use asset_hub_paseo_types::*;
#[cfg(feature = "polkadot")]
use asset_hub_polkadot_types::*;
#[cfg(feature = "westend")]
use asset_hub_westend_types::*;
Expand Down
8 changes: 4 additions & 4 deletions control/preimage/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ mod westend {
pub const POLKADOT_SYMBOL: &str = "WND";
pub const POLKADOT_DECIMALS: u8 = 12;
pub const ASSET_HUB_ID: u32 = 1000;
pub const ASSET_HUB_API: &str = "wss://westend-asset-hub-rpc.polkadot.io";
pub const ASSET_HUB_API: &str = "wss://asset-hub-westend-rpc.dwellir.com";
pub const BRIDGE_HUB_ID: u32 = 1002;
pub const BRIDGE_HUB_API: &str = "wss://westend-bridge-hub-rpc.polkadot.io";
pub const RELAY_API: &str = "wss://westend-rpc.polkadot.io";
pub const BRIDGE_HUB_API: &str = "wss://bridge-hub-westend-rpc.dwellir.com";
pub const RELAY_API: &str = "wss://westend-rpc.dwellir.com";
}

#[cfg(feature = "westend")]
Expand All @@ -46,7 +46,7 @@ mod paseo {
pub const ASSET_HUB_ID: u32 = 1000;
pub const ASSET_HUB_API: &str = "wss://asset-hub-paseo-rpc.dwellir.com";
pub const BRIDGE_HUB_ID: u32 = 1002;
pub const BRIDGE_HUB_API: &str = "wss://sys.ibp.network/bridge-hub-paseo";
pub const BRIDGE_HUB_API: &str = "wss://bridge-hub-paseo.dotters.network";
pub const RELAY_API: &str = "wss://paseo-rpc.dwellir.com";
}

Expand Down
6 changes: 6 additions & 0 deletions control/preimage/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,16 @@ pub fn sudo(call: Box<RelayRuntimeCall>) -> RelayRuntimeCall {
}

pub fn force_xcm_version() -> AssetHubRuntimeCall {
#[cfg(any(feature = "paseo", feature = "polkadot"))]
use crate::asset_hub_runtime::runtime_types::staging_xcm::v4::{
junction::Junction::GlobalConsensus, junction::NetworkId, junctions::Junctions::X1,
location::Location,
};
#[cfg(feature = "westend")]
use crate::asset_hub_runtime::runtime_types::staging_xcm::v5::{
junction::Junction::GlobalConsensus, junction::NetworkId, junctions::Junctions::X1,
location::Location,
};
let chain_id = crate::bridge_hub_runtime::CHAIN_ID;
let location = Box::new(Location {
parents: 2,
Expand Down
Binary file modified control/runtimes/asset-hub-paseo/asset-hub-metadata.bin
Binary file not shown.
Binary file modified control/runtimes/asset-hub-westend/asset-hub-metadata.bin
Binary file not shown.
Binary file modified control/runtimes/bridge-hub-paseo/bridge-hub-metadata.bin
Binary file not shown.
Binary file modified control/runtimes/bridge-hub-westend/bridge-hub-metadata.bin
Binary file not shown.
Binary file modified control/runtimes/paseo/polkadot-metadata.bin
Binary file not shown.
Binary file modified control/runtimes/westend/polkadot-metadata.bin
Binary file not shown.
21 changes: 21 additions & 0 deletions control/update-runtimes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

networks=(
polkadot
westend
paseo
)

for network in ${networks[@]}; do
echo "Updating network $network"
subxt metadata --url wss://$network-rpc.dwellir.com -f bytes -o runtimes/$network/polkadot-metadata.bin
subxt metadata --url wss://asset-hub-$network-rpc.dwellir.com -f bytes -o runtimes/asset-hub-$network/asset-hub-metadata.bin

bh_metadata=runtimes/bridge-hub-$network/bridge-hub-metadata.bin
bh_url=wss://bridge-hub-$network-rpc.dwellir.com
if [ "$network" = "paseo" ]; then
bh_url=wss://bridge-hub-paseo.dotters.network
fi

subxt metadata --url $bh_url -f bytes -o $bh_metadata
done

0 comments on commit c7ae26f

Please sign in to comment.