Skip to content

Commit

Permalink
Merge branch 'main' into electra
Browse files Browse the repository at this point in the history
# Conflicts:
#	relayer/contracts/gateway.go
#	relayer/relays/beacon/header/syncer/syncer_test.go
#	relayer/relays/beacon/store/datastore_test.go
  • Loading branch information
claravanstaden committed Dec 19, 2024
2 parents c1b3e9c + 9723143 commit 3b5d3ca
Show file tree
Hide file tree
Showing 160 changed files with 5,052 additions and 1,593 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
33 changes: 21 additions & 12 deletions .github/workflows/release-relayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: release-relayer

on:
push:
paths:
- "relayer/**"
branches:
- main
- release-v1.0.0
workflow_dispatch:

env:
Expand Down Expand Up @@ -34,7 +35,7 @@ jobs:
run: >
go install github.com/magefile/mage@v1.15.0 &&
go install github.com/ferranbt/fastssz/sszgen@v0.1.3 &&
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 All @@ -59,18 +60,12 @@ jobs:
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
- name: Determine branch name
id: branch_name
run: |
branch_name=${GITHUB_REF#refs/heads/}
echo "Branch name: $branch_name"
echo "branch=$branch_name" >> $GITHUB_OUTPUT
- name: Determine new version
id: new_version
run: |
# Get the most recent tag in the format relayer-<branchname>-<version>
current_version=$(git tag --list "relayer-${{ steps.branch_name.outputs.branch }}-*" --sort=-v:refname | head -n 1 | sed -E 's/relayer-${{ steps.branch_name.outputs.branch }}-//')
# Get the most recent tag in the format relayer-v<version>
current_tag=$(git tag --list "relayer-v*" --sort=-v:refname | head -n 1)
current_version=$(git tag --list "relayer-v*" --sort=-v:refname | head -n 1 | sed -E 's/relayer-v//')
echo "Current version: $current_version"
# If there is no current version, set it to 1.0.0
Expand All @@ -82,11 +77,12 @@ jobs:
echo "New version: $new_version"
echo "version=$new_version" >> $GITHUB_OUTPUT
echo "from_tag=$current_tag" >> $GITHUB_OUTPUT
- name: Create new tag
id: create_tag
run: |
tag_name="relayer-${{ steps.branch_name.outputs.branch }}-${{ steps.new_version.outputs.version }}"
tag_name="relayer-v${{ steps.new_version.outputs.version }}"
echo "Tag name: $tag_name"
echo "tag=$tag_name" >> $GITHUB_OUTPUT
git tag $tag_name
Expand All @@ -98,6 +94,19 @@ jobs:
- name: "Build Changelog"
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 }}

- name: Create a GitHub Release
id: create_release
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: smoke-tests

on:
push:
branches:
- main
workflow_dispatch:
schedule:
# Runs at 8:00 AM every day
- cron: '0 8 * * *'

jobs:
smoketests:
runs-on: snowbridge-runner
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
RUSTFLAGS: -C debuginfo=1
outputs:
success: ${{ steps.run_e2e_stack.outcome == 'success' }}
steps:
- uses: actions/checkout@v2
with:
repository: snowfork/snowbridge
ref: main
- run: rm -rf polkadot-sdk
- uses: actions/checkout@v2
with:
repository: paritytech/polkadot-sdk
ref: stable2409
path: ./polkadot-sdk
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set build directory environment variable
run: echo "OUTPUT_DIR=${GITHUB_WORKSPACE}/tmp" >> $GITHUB_ENV
- name: Set log directory environment variable
run: echo "LOG_DIR=${GITHUB_WORKSPACE}/log-tmp" >> $GITHUB_ENV
- name: polkadot-sdk dir
run: echo "POLKADOT_SDK_DIR=./polkadot-sdk" >> $GITHUB_ENV
- name: Create directories
run: mkdir -p $OUTPUT_DIR && mkdir -p $LOG_DIR
- 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: run E2E stack
id: run_e2e_stack
run: |
nix develop -c sh -c '
./scripts/init-smoketests.sh &&
cd web/packages/test &&
(./scripts/start-services.sh > "${{ env.LOG_DIR }}/start-services.log" 2>&1 &) &&
sleep 10 &&
./scripts/check-relayer.sh &&
./scripts/run-smoketests.sh'
continue-on-error: true
- name: Save start-services log file
uses: actions/upload-artifact@v3
with:
name: start-services.log
path: "${{ env.LOG_DIR }}/start-services.log"
- name: Save beacon-relay log file
uses: actions/upload-artifact@v3
with:
name: beacon-relay.log
path: "${{ env.OUTPUT_DIR }}/beacon-relay.log"
- run: ls
- name: check E2E test outcome
if: ${{ steps.run_e2e_stack.outcome != 'success' }}
run: |
echo "E2E tests failed"
exit 1
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
13 changes: 9 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 Expand Up @@ -69,3 +69,8 @@ BEEFY commitments & proofs extracted from `/tmp/snowbridge/beefy-relay.log`.
1. Search for `Sent SubmitFinal transaction` in relayer log file
2. Copy into `test/data/beefy-commitment.json`
```

## Deploy to Testnet

To deploy to a testnet, run script `deploy-test.sh`. Replace `--with-gas-price` with standard gas value (found at https://sepolia.beaconcha.in/gasnow). Make sure to add all the necessary envs in .envrc.
15 changes: 15 additions & 0 deletions contracts/scripts/deploy-testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -eux

export FOUNDRY_PROFILE=production

forge script \
--rpc-url "${ETH_WS_ENDPOINT}" \
--broadcast \
--legacy \
--with-gas-price 110000000000 \
--verify \
--etherscan-api-key "${ETHERSCAN_API_KEY}" \
-vvvvv \
scripts/DeployLocal.sol:DeployLocal
Loading

0 comments on commit 3b5d3ca

Please sign in to comment.