Skip to content

Commit

Permalink
Merge branch 'main' into vincent/token-bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeddes committed Dec 5, 2024
2 parents e153114 + c7ae26f commit b250f88
Show file tree
Hide file tree
Showing 46 changed files with 596 additions and 432 deletions.
23 changes: 23 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"Component: Docs":
- changed-files:
- any-glob-to-any-file: docs/**

"Component: Relayer":
- changed-files:
- any-glob-to-any-file: relayer/**

"Component: Web":
- changed-files:
- any-glob-to-any-file: web/**

"Component: Smoke Tests":
- changed-files:
- any-glob-to-any-file: smoketest/**

"Component: Control Tool":
- changed-files:
- any-glob-to-any-file: control/**

"Component: Ethereum":
- changed-files:
- any-glob-to-any-file: contracts/**
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'
15 changes: 15 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: label PRs

on:
pull_request:

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
sync-labels: true
12 changes: 11 additions & 1 deletion .github/workflows/release-relayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: >
go install github.com/magefile/[email protected] &&
go install github.com/ferranbt/fastssz/[email protected] &&
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.13.15
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.14.8
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down Expand Up @@ -95,6 +95,16 @@ jobs:
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configurationJson: |
{
"template": "#{{CHANGELOG}}\n\n<details>\n</details>",
"categories": [
{
"title": "## Relayer Changes",
"labels": ["Component: Relayer"]
}
]
}
fromTag: ${{ steps.new_version.outputs.from_tag }}
toTag: ${{ steps.create_tag.outputs.tag }}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Integration tests for our local testnet. See [smoketest/README.md](https://githu

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

After [installing nix](https://nixos.org/download.html) Nix, enable [flakes](https://wiki.nixos.org/wiki/Flakes):
After [installing Nix](https://nixos.org/download.html), enable [flakes](https://wiki.nixos.org/wiki/Flakes):

```sh
mkdir -p ~/.config/nix
Expand Down
8 changes: 4 additions & 4 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ The gateway is defined by the following contracts

The gateway is modular in design, being composed of libraries implementing specific functionality:

* [Verification.sol](src/Verification.sol): Verification of inbound messages from Polakdot
* [Assets.sol](src/Assets.sol): ERC20 token transfers to Polkadot
* [Verification.sol](src/Verification.sol): Verification of inbound messages from Polkadot
* [Assets.sol](src/Assets.sol): ERC-20 token transfers to Polkadot

#### Governance

Using cross-chain messaging, the gateway is governed remotely by the governance of the Polkadot relay chain.

#### Upgrades

The gateway consists of an upgradable proxy, and an implementation contract, loosely following the [ERC1967](https://eips.ethereum.org/EIPS/eip-1967) standard.
The gateway consists of an upgradable proxy, and an implementation contract, loosely following the [ERC-1967](https://eips.ethereum.org/EIPS/eip-1967) standard.

### Agents

Agents are proxy contracts for arbitrary consensus systems on Polkadot. Logically, one can think of them as the sovereign accounts of remote consensus systems.

They have a number of uses:
* When an Ethereum user sends ERC20 tokens to Polkadot (Specifically the AssetHub parachain), these tokens are actually locked into the agent contract corresponding to the AssetHub parachain. Then finally, on the AssetHub parachain, wrapped tokens are minted into an account controlled by the sender.
* When an Ethereum user sends ERC-20 tokens to Polkadot (Specifically the AssetHub parachain), these tokens are actually locked into the agent contract corresponding to the AssetHub parachain. Then finally, on the AssetHub parachain, wrapped tokens are minted into an account controlled by the sender.
* When a Polkadot parachain wishes to call a function on an Ethereum contract, it will appear to the destination contract that the message sender is the agent contract for the origin parachain.
* Agents control the funds for receiving fees from users and disbursing rewards to message relayers

Expand Down
14 changes: 10 additions & 4 deletions control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ 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
subxt metadata --url ws://127.0.0.1:8000 -f bytes -o runtimes/polkadot/polkadot-metadata.bin
subxt metadata --url ws://127.0.0.1:8001 -f bytes -o runtimes/bridge-hub-polkadot/bridge-hub-metadata.bin
subxt metadata --url ws://127.0.0.1:8002 -f bytes -o runtimes/asset-hub-polkadot/asset-hub-metadata.bin
./update-runtimes.sh
```

To update Westend/Paseo bindings, replace the chain name in the command, e.g. replace `runtimes/polkadot/polkadot-metadata.bin`
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
subxt metadata --url wss://asset-hub-polkadot-rpc.dwellir.com -f bytes -o runtimes/asset-hub-polkadot/asset-hub-metadata.bin
```

To update Westend/Paseo bindings, replace the chain name in the command, e.g. replace `runtimes/polkadot/polkadot-metadata.bin`
with `runtimes/westend/polkadot-metadata.bin`.
46 changes: 30 additions & 16 deletions control/preimage/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,25 @@ 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::{
junction::Junction::AccountKey20, junction::Junction::GlobalConsensus, junction::NetworkId,
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 }),
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,
Expand All @@ -39,32 +56,25 @@ pub mod asset_hub_polkadot_types {
return MultiLocation {
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 = "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
10 changes: 7 additions & 3 deletions control/preimage/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use crate::Context;

use crate::bridge_hub_runtime::{self, RuntimeCall as BridgeHubRuntimeCall};

#[cfg(feature = "polkadot")]
use crate::relay_runtime::runtime_types::xcm::v2::OriginKind;
#[cfg(any(feature = "westend", feature = "paseo"))]
use crate::relay_runtime::runtime_types::xcm::v3::OriginKind;

use crate::relay_runtime::runtime_types::{
Expand Down Expand Up @@ -177,17 +174,24 @@ pub fn utility_force_batch(calls: Vec<RelayRuntimeCall>) -> RelayRuntimeCall {
)
}

#[cfg(any(feature = "westend", feature = "paseo"))]
pub fn sudo(call: Box<RelayRuntimeCall>) -> RelayRuntimeCall {
return RelayRuntimeCall::Sudo(
crate::relay_runtime::runtime_types::pallet_sudo::pallet::Call::sudo { call },
);
}

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
23 changes: 13 additions & 10 deletions control/preimage/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use helpers::{force_xcm_version, send_xcm_asset_hub, send_xcm_bridge_hub, utilit
use sp_crypto_hashing::blake2_256;
use std::{io::Write, path::PathBuf};
use subxt::{OnlineClient, PolkadotConfig};

#[cfg(any(feature = "westend", feature = "paseo"))]
use crate::helpers::sudo;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -324,11 +326,11 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
.await?;
let call2 =
send_xcm_asset_hub(&context, vec![force_xcm_version(), set_ethereum_fee]).await?;
if cfg!(any(feature = "paseo", feature = "westend")) {
sudo(Box::new(utility_force_batch(vec![call1, call2])))
} else {
utility_force_batch(vec![call1, call2])
}
#[cfg(any(feature = "westend", feature = "paseo"))]
let final_call = sudo(Box::new(utility_force_batch(vec![call1, call2])));
#[cfg(not(any(feature = "westend", feature = "paseo")))]
let final_call = utility_force_batch(vec![call1, call2]);
final_call
}
Command::UpdateAsset(params) => {
let call = send_xcm_asset_hub(
Expand All @@ -339,11 +341,12 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
],
)
.await?;
if cfg!(any(feature = "paseo", feature = "westend")) {
sudo(Box::new(call))
} else {
call
}

#[cfg(any(feature = "westend", feature = "paseo"))]
let final_call = sudo(Box::new(call));
#[cfg(not(any(feature = "westend", feature = "paseo")))]
let final_call = call;
final_call
}
Command::GatewayOperatingMode(params) => {
let call = commands::gateway_operating_mode(&params.gateway_operating_mode);
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-polkadot/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-polkadot/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/polkadot/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

Loading

0 comments on commit b250f88

Please sign in to comment.