Skip to content

Commit 3811629

Browse files
Snowbridge Rococo deployment updates (#2792)
- Includes the introduction of the `fast-runtime` feature, which cleans up our features - Updates beacon client fork versions config to Sepolia's versions - Cleanup of AgentIdOf --------- Co-authored-by: Ron <[email protected]> Co-authored-by: claravanstaden <Cats 4 life!>
1 parent 69e2ae6 commit 3811629

File tree

26 files changed

+3544
-1527
lines changed

26 files changed

+3544
-1527
lines changed
Lines changed: 82 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,127 @@
1-
# Parachain modules
1+
# Snowbridge &middot;
2+
[![codecov](https://codecov.io/gh/Snowfork/snowbridge/branch/main/graph/badge.svg?token=9hvgSws4rN)]
3+
(https://codecov.io/gh/Snowfork/snowbridge)
4+
![GitHub](https://img.shields.io/github/license/Snowfork/snowbridge)
25

3-
## Configuration
6+
Snowbridge is a trustless bridge between Polkadot and Ethereum. For documentation, visit https://docs.snowbridge.network.
47

5-
Note: This section is not necessary for local development, as there are scripts to auto-configure the parachain in the
6-
[test directory](https://github.com/Snowfork/snowbridge/blob/main/web/packages/test).
8+
## Components
79

8-
For a fully operational chain, further configuration of the initial chain spec is required. The specific configuration will
9-
depend heavily on your environment, so this guide will remain high-level.
10+
### Parachain
1011

11-
After completing a release build of the parachain, build an initial spec for the snowbase runtime:
12+
Polkadot parachain and our pallets. See [parachain/README.md](https://github.com/Snowfork/snowbridge/blob/main/parachain/README.md).
1213

13-
```bash
14-
target/release/snowbridge build-spec --chain snowbase --disable-default-bootnode > spec.json
15-
```
14+
### Contracts
1615

17-
Now edit the spec and configure the following:
18-
1. Recently finalized ethereum header and difficulty for the ethereum light client
19-
2. Contract addresses for the Ether, Erc20, and Dot apps.
20-
3. Authorized principal for the basic channel
16+
Ethereum contracts and unit tests. See [contracts/README.md](https://github.com/Snowfork/snowbridge/blob/main/contracts/README.md)
2117

22-
For an example configuration, consult the [setup script](https://github.com/Snowfork/snowbridge/blob/main/web/packages/test/scripts/start-services.sh)
23-
for our local development stack. Specifically the `start_polkadot_launch` bash function.
18+
### Relayer
2419

25-
## Tests
20+
Off-chain relayer services for relaying messages between Polkadot and Ethereum. See
21+
[relayer/README.md](https://github.com/Snowfork/snowbridge/blob/main/relayer/README.md)
2622

27-
To run the parachain tests locally, use `cargo test --workspace`. For the full suite of tests, use
28-
`cargo test --workspace --features runtime-benchmarks`.
23+
### Local Testnet
2924

30-
Optionally exclude the top-level and runtime crates:
25+
Scripts to provision a local testnet, running the above services to bridge between local deployments of Polkadot and
26+
Ethereum. See [web/packages/test/README.md](https://github.com/Snowfork/snowbridge/blob/main/web/packages/test/README.md).
3127

32-
```bash
33-
cargo test --workspace \
34-
--features runtime-benchmarks \
35-
--exclude snowbridge \
36-
--exclude snowbridge-runtime \
37-
--exclude snowblink-runtime \
38-
--exclude snowbase-runtime
39-
```
28+
### Smoke Tests
4029

41-
### Updating test data for inbound channel unit tests
30+
Integration tests for our local testnet. See [smoketest/README.md](https://github.com/Snowfork/snowbridge/blob/main/smoketest/README.md).
4231

43-
To regenerate the test data, use a test with multiple `submit` calls in `ethereum/test/test_basic_outbound_channel.js`, eg.
44-
"should increment nonces correctly".
32+
## Development
4533

46-
Add the following preamble:
34+
We use the Nix package manager to provide a reproducible and maintainable developer environment.
4735

48-
```javascript
49-
const rlp = require("rlp");
50-
const contract = BasicOutboundChannel;
51-
const signature = 'Message(address,address,uint64,uint64,bytes)';
52-
```
36+
After [installing nix](https://nixos.org/download.html) Nix, enable [flakes](https://nixos.wiki/wiki/Flakes):
5337

54-
For each encoded log you want to create, find a transaction object `tx` returned from a `submit` call and run this:
55-
56-
```javascript
57-
const rawLog = tx.receipt.rawLogs[0];
58-
const encodedLog = rlp.encode([rawLog.address, rawLog.topics, rawLog.data]).toString("hex");
59-
console.log(`encodedLog: ${encodedLog}`);
60-
const iface = new ethers.utils.Interface(contract.abi);
61-
const decodedEventLog = iface.decodeEventLog(
62-
signature,
63-
rawLog.data,
64-
rawLog.topics,
65-
);
66-
console.log(`decoded rawLog.data: ${JSON.stringify(decodedEventLog)}`);
38+
```sh
39+
mkdir -p ~/.config/nix
40+
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
6741
```
6842

69-
Place the `encodedLog` string in the `message.data` field in the test data. Use the `decoded rawLog.data` field to
70-
update the comments with the decoded log data.
71-
72-
## Generating pallet weights from benchmarks
43+
Then activate a developer shell in the root of our repo, where
44+
[`flake.nix`](https://github.com/Snowfork/snowbridge/blob/main/flake.nix) is located:
7345

74-
Build the parachain with the runtime benchmark flags for the chosen runtime:
46+
```sh
47+
nix develop
48+
```
7549

76-
```bash
77-
runtime=snowbase
78-
cargo build \
79-
--release \
80-
--no-default-features \
81-
--features "$runtime-native,rococo-native,runtime-benchmarks,$runtime-runtime-benchmarks" \
82-
--bin snowbridge
50+
Also make sure to run this initialization script once:
51+
```sh
52+
scripts/init.sh
8353
```
8454

85-
List available pallets and their benchmarks:
55+
### Support for code editors
8656

87-
```bash
88-
./target/release/snowbridge benchmark pallet --chain $runtime --list
89-
```
57+
To ensure your code editor (such as VS Code) can execute tools in the nix shell, startup your editor within the
58+
interactive shell.
9059

91-
Run a benchmark for a pallet, generating weights:
92-
93-
```bash
94-
target/release/snowbridge benchmark pallet \
95-
--chain=$runtime \
96-
--execution=wasm \
97-
--wasm-execution=compiled \
98-
--pallet=basic_channel_inbound \
99-
--extra \
100-
--extrinsic=* \
101-
--repeat=20 \
102-
--steps=50 \
103-
--output=pallets/basic-channel/src/inbound/weights.rs \
104-
--template=templates/module-weight-template.hbs
105-
```
60+
Example for VS Code:
10661

107-
## Generating beacon test fixtures and benchmarking data
62+
```sh
63+
nix develop
64+
code .
65+
```
10866

109-
### Minimal Spec
67+
### Custom shells
11068

111-
To generate `minimal` test data and benchmarking data, make sure to start the local E2E setup to spin up a local beacon
112-
node instance to connect to:
69+
The developer shell is bash by default. To preserve your existing shell:
11370

114-
```bash
115-
cd web/packages/test
116-
./scripts/start-services.sh
71+
```sh
72+
nix develop --command $SHELL
11773
```
11874

119-
Wait for output `Testnet has been initialized`.
75+
### Automatic developer shells
12076

121-
In a separate terminal, from the `snowbridge` directory, run:
77+
To automatically enter the developer shell whenever you open the project, install
78+
[`direnv`](https://direnv.net/docs/installation.html) and use the template `.envrc`:
12279

123-
```bash
124-
mage -d relayer build && relayer/build/snowbridge-relay generate-beacon-data --spec "minimal" && cd parachain &&
125-
cargo +nightly fmt -- --config-path rustfmt.toml && cd -
80+
```sh
81+
cp .envrc.example .envrc
82+
direnv allow
12683
```
12784

128-
### Mainnet Spec
85+
### Upgrading the Rust toolchain
86+
87+
Sometimes we would like to upgrade rust toolchain. First update `parachain/rust-toolchain.toml` as required and then
88+
update `flake.lock` running
89+
```sh
90+
nix flake lock --update-input rust-overlay
91+
```
12992

130-
We only use the mainnet spec for generating fixtures for pallet weight benchmarks.
93+
## Troubleshooting
13194

132-
To generate the data we can connect to the Lodestar Goerli public node. The script already connects to the Lodestar node,
133-
so no need to start up additional services. In the event of the Lodestar node not being available, you can start up your
134-
own stack with these commands:
95+
Check the contents of all `.envrc` files.
13596

136-
```bash
137-
cd web/packages/test
138-
./scripts/start-goerli.sh
97+
Remove untracked files:
98+
```sh
99+
git clean -idx
139100
```
140101

141-
From the `snowbridge` directory, run:
102+
Ensure that the current Rust toolchain is the one selected in `scripts/init.sh`.
142103

143-
```bash
144-
mage -d relayer build && relayer/build/snowbridge-relay generate-beacon-data --spec "mainnet" && cd parachain &&
145-
cargo +nightly fmt -- --config-path rustfmt.toml && cd -
104+
Ensure submodules are up-to-date:
105+
```sh
106+
git submodule update
146107
```
147108

148-
### Benchmarking tests
109+
Check untracked files & directories:
110+
```sh
111+
git clean -ndx | awk '{print $3}'
112+
```
113+
After removing `node_modules` directories (eg. with `git clean above`), clear the pnpm cache:
114+
```sh
115+
pnpm store prune
116+
```
149117

150-
To run the benchmark tests
118+
Check Nix config in `~/.config/nix/nix.conf`.
151119

152-
```bash
153-
cd parachain/pallets/ethereum-beacon-client
154-
cargo test --release --features runtime-benchmarks
120+
Run a pure developer shell (note that this removes access to your local tools):
121+
```sh
122+
nix develop -i --pure-eval
155123
```
124+
125+
## Security
126+
127+
The security policy and procedures can be found in SECURITY.md.

bridges/snowbridge/parachain/pallets/ethereum-beacon-client/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ std = [
7777
'frame-benchmarking/std',
7878
]
7979
runtime-benchmarks = [
80-
"beacon-spec-mainnet",
8180
"frame-benchmarking/runtime-benchmarks",
8281
"frame-support/runtime-benchmarks",
8382
"frame-system/runtime-benchmarks",
@@ -92,4 +91,5 @@ try-runtime = [
9291
"pallet-timestamp?/try-runtime",
9392
"sp-runtime/try-runtime",
9493
]
95-
beacon-spec-mainnet = []
94+
beacon-spec-minimal = []
95+
fast-runtime = ["beacon-spec-minimal"]

0 commit comments

Comments
 (0)