Skip to content
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
562feda
Add nix env
vgeddes Jan 17, 2023
0a8a921
foo
vgeddes Jan 17, 2023
e4b9d62
cowsay
vgeddes Jan 17, 2023
4276f97
Get working on MacOs
vgeddes Jan 19, 2023
a36cf88
Get working on MacOs
vgeddes Jan 19, 2023
dcfc9b7
fix
vgeddes Jan 19, 2023
2a0d1da
Merge branch 'main' into nix
vgeddes Jan 20, 2023
45d87f6
change
vgeddes Jan 26, 2023
e66bcab
foo
vgeddes Jan 27, 2023
de2a956
Apply suggestions from code review
vgeddes Jan 27, 2023
e25ae6c
Preserve local shell in nix-shell instructions
doubledup Feb 3, 2023
42713ab
Set clang path for rocksdb
doubledup Feb 6, 2023
d6fa775
Set POLKADOT_DIR in envrc template
doubledup Feb 6, 2023
e24ce83
Use direnv to automatically enter nix-shell
doubledup Feb 6, 2023
7ad5921
Explain use of LIBCLANG_PATH
doubledup Feb 6, 2023
a227015
Lock nixpkgs hash
doubledup Feb 6, 2023
51ee780
Avoid impure overlays & config on import
doubledup Feb 6, 2023
5776367
Remove redundant pkgs
doubledup Feb 7, 2023
700b44d
Add initial flake definition
doubledup Feb 7, 2023
b1f8237
Add export to commented env vars
doubledup Feb 7, 2023
6a914e3
Source root envrc in subdirectories
doubledup Feb 7, 2023
238c0c2
Tweak README
doubledup Feb 7, 2023
1f92058
Move root envrc to an example file
doubledup Feb 7, 2023
2e47c8a
Don't require .envrc in project root
doubledup Feb 7, 2023
8943e1d
Set up Rust and system compatibility
doubledup Feb 7, 2023
2b56287
List supported systems explicitly
doubledup Feb 7, 2023
1b9a4df
Remove clang package & comment out other unused dependencies
doubledup Feb 7, 2023
6d50dcf
Suppress successful pre-commit hook output
doubledup Feb 7, 2023
0859dff
Whitespace
doubledup Feb 7, 2023
a57966a
added cacert and LD_PATH to flake.nix
alistair-singh Feb 8, 2023
89d2cb1
Switch local eth env to ipv6
doubledup Feb 8, 2023
f9f566a
Mark commands as shell in markdown
doubledup Feb 8, 2023
992052f
Use source_up_if_exists in envrc templates
doubledup Feb 8, 2023
04685ce
Re-add some dependencies needed by a pure shell
doubledup Feb 8, 2023
4af86c3
Update packages & set HOME
doubledup Feb 8, 2023
f69b2b5
REVERTME Use cargo install for polkadot binary
doubledup Feb 8, 2023
d1c6286
Remove commented exports
doubledup Feb 9, 2023
c970e1b
Default to locally installed polkadot binary
doubledup Feb 9, 2023
798a46f
Add rust-toolchain.toml
doubledup Feb 9, 2023
df5e2ac
Move polkadot install to parachain directory
doubledup Feb 9, 2023
f746590
Match Rust nightly used for polkadot 0.9.30
doubledup Feb 9, 2023
f47f9f3
Changed parachain build dir
alistair-singh Feb 9, 2023
691a0df
Wrap all builds in single cd call
doubledup Feb 9, 2023
03b43e9
Fix path to polkadot binary
doubledup Feb 9, 2023
ade3a86
Add note for stable channel
doubledup Feb 9, 2023
c39efe7
Fix relay chain bin in zombienet config
doubledup Feb 9, 2023
5d0503a
Point lodestar directly to geth's ipv6 addresses
doubledup Feb 9, 2023
6c7a8dd
Whitespace & sorting
doubledup Feb 10, 2023
1002491
Switch eth services to ipv4
doubledup Feb 10, 2023
066c2c9
s/localhost/127.0.0.1/g, except hardhat's localhost
doubledup Feb 10, 2023
be7e32e
Move `cargo install polkadot` into build script
doubledup Feb 10, 2023
6233306
Indent launch-config like example config files
doubledup Feb 10, 2023
568a72f
Create polkadot version directories when absent
doubledup Feb 10, 2023
3c984de
added ps to nix env for zombienet on linux
alistair-singh Feb 10, 2023
04ac710
Add explanation for ps nix package
doubledup Feb 10, 2023
8a45fb3
Add explanation for LIBCLANG_PATH
doubledup Feb 10, 2023
3f3e388
Remove unused packages
doubledup Feb 10, 2023
908d5b8
Remove redundant trues
doubledup Feb 10, 2023
b758d00
Switch to nix-direnv
doubledup Feb 13, 2023
e5e9305
Merge branch 'main' into nix
doubledup Feb 13, 2023
9a109b0
Add foundry overlay
doubledup Feb 13, 2023
6c47c4d
Bump lockfiles
doubledup Feb 13, 2023
f436fd4
Bump workflow node version
doubledup Feb 13, 2023
3b5eff7
Sync node versions to 18.13.0
doubledup Feb 13, 2023
2386abc
Merge branch 'main' into nix
doubledup Feb 14, 2023
79edef0
Bump node lockfile after merge
doubledup Feb 14, 2023
fac9e47
Use @zombienet/cli package
doubledup Feb 14, 2023
9b42c33
Increase logging in zombienet config
doubledup Feb 14, 2023
dd56a49
Add gpg for commit signing during foundry install
doubledup Feb 15, 2023
8716978
Track forge dependencies
doubledup Feb 15, 2023
33bb2c4
Manual forge init
doubledup Feb 15, 2023
4856332
forge install: ds-test
doubledup Feb 15, 2023
6d3ee12
Remove shell.nix
doubledup Feb 15, 2023
8bef816
Remove foundry Makefile
doubledup Feb 15, 2023
ea7abab
Ensure forge dependencies are available
doubledup Feb 15, 2023
ab1158b
Use debug instead of release where possible
doubledup Feb 16, 2023
d5fc39b
Run Rust builds for host CPU only
doubledup Feb 16, 2023
d9f1bfe
Update all READMEs
doubledup Feb 16, 2023
c51a4ea
Update test envrc template
doubledup Feb 16, 2023
69586f6
Use debug builds of polkadot locally
doubledup Feb 16, 2023
9938245
Revert "Use debug builds of polkadot locally"
doubledup Feb 16, 2023
7758931
Revert "Run Rust builds for host CPU only"
doubledup Feb 16, 2023
f5cdad2
Revert "Use debug instead of release where possible"
doubledup Feb 16, 2023
ba7b20a
Clarify explanations in flake
doubledup Feb 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

use flake
2 changes: 1 addition & 1 deletion .github/workflows/ethereum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16.18.1
node-version: 18.12.1
cache: 'pnpm'
cache-dependency-path: core/pnpm-lock.yaml
- name: Install dependencies
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ node_modules/

relaychain/
.vscode

.rustup
.cargo

.DS_Store

Comment thread
vgeddes marked this conversation as resolved.
.direnv
.envrc
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "core/packages/contracts/lib/forge-std"]
path = core/packages/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.4.0
[submodule "core/packages/contracts/lib/ds-test"]
path = core/packages/contracts/lib/ds-test
url = https://github.com/dapphub/ds-test
11 changes: 8 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

set -e

echo 'Running pre-commit hook...'

# check typos
typos .
chronic typos .

# lint and format for core contracts and typescript codes
cd core && pnpm lint && pnpm format && cd ..
cd core && chronic pnpm lint && chronic pnpm format && cd ..

# lint and format for relayer codes
cd relayer && mage lint && go fmt ./...
cd relayer && chronic mage lint && chronic go fmt ./...

echo 'Pre-commit hook successful!'
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,50 @@ Ethereum contracts and unit tests. See [core/packages/contracts/README.md](core/

This component includes our end to end tests, that pull together all the above services and set them up easily through scripts for automated E2E tests. See [core/packages/test/README.md](core/packages/test/README.md).

## Development

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://nixos.wiki/wiki/Flakes):

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

(if you don't want to use flakes, you can instead pass the flag `--experimental-features nix-command flakes` to nix, eg.
`nix --experimental-features 'nix-command flakes' develop`)

Then activate a developer shell in the root of our repo, where [`flake.nix`](./flake.nix) is located:

```sh
nix develop
```

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:

```sh
nix develop
code .
```

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

```sh
nix develop --command $SHELL
```

To automatically enter the developer shell whenever you open the project, install
[`direnv`](https://direnv.net/docs/installation.html) and use the template `.envrc`:

```sh
cp .envrc.example .envrc
direnv allow
````

## Security

The security policy and procedures can be found in SECURITY.md.
28 changes: 5 additions & 23 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,13 @@

Packages:

- Solidity Contracts
- API client
- Integration tests
- [Solidity Contracts](packages/contracts/README.md)
- [API Client](packages/api/README.md)
- [Integration tests](packages/test/README.md)

## Getting Started

Install [nvm](https://github.com/nvm-sh/) and activate nodejs:
See the [main README's Development section](../README.md#Development) for setup instructions.

```bash
nvm use
```

Install [pnpm](https://pnpm.io/):

```bash
corepack enable
corepack prepare pnpm@7.14.2 --activate
```

Install [foundry](https://book.getfoundry.sh/getting-started/installation):

```bash
curl -L https://foundry.paradigm.xyz | bash
foundryup
```
## Getting Started

Install all dependencies:

Expand Down
5 changes: 3 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@snowbridge/core",
"private": true,
"engines": {
"node": "16.18.1",
"node": "v18.13.0",
"pnpm": "7.14.2"
},
"scripts": {
Expand All @@ -16,7 +16,8 @@
"coverage": "turbo run coverage"
},
"devDependencies": {
"husky": "^8.0.1",
"turbo": "^1.6.3",
"husky": "^8.0.1"
"pnpm-deduplicate": "^0.4.1"
}
}
2 changes: 1 addition & 1 deletion core/packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "eslint ."
},
"devDependencies": {
"@types/node": "^18.11.9",
"@types/node": "^18.13.0",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"eslint": "^8.26.0",
Expand Down
2 changes: 2 additions & 0 deletions core/packages/contracts/.envrc-example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source_up_if_exists

export PRIVATE_KEY=0x4e9444a6efd6d42725a250b650a781da2737ea308c839eaccb0f7f3dbd2fea77
export RANDAO_COMMIT_DELAY=3
export RANDAO_COMMIT_EXP=8
Expand Down
1 change: 0 additions & 1 deletion core/packages/contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ coverage/
src/
.vscode/
deployments/
lib/
out/
cache/
broadcast/
Expand Down
11 changes: 0 additions & 11 deletions core/packages/contracts/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions core/packages/contracts/lib/ds-test
Submodule ds-test added at cd98ef
1 change: 1 addition & 0 deletions core/packages/contracts/lib/forge-std
Submodule forge-std added at a2edd3
8 changes: 4 additions & 4 deletions core/packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@
"@types/keccak": "^3.0.1",
"@types/lodash": "^4.14.186",
"@types/mocha": "^10.0.0",
"@types/node": "^16.3.3",
"@types/node": "^18.13.0",
"@types/secp256k1": "^4.0.3",
"@types/seedrandom": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"@types/seedrandom": "^3.0.2",
"bitfield": "^4.1.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^3.0.0",
"esbuild": "^0.17.4",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"ethereumjs-abi": "^0.6.8",
Expand Down Expand Up @@ -78,8 +79,7 @@
"tsconfig-paths": "^4.1.0",
"typechain": "^8.1.0",
"typescript": "^4.3.2",
"unique-filename": "^1.1.1",
"esbuild": "^0.17.4"
"unique-filename": "^1.1.1"
},
"dependencies": {
"@ethersproject/bytes": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion core/packages/contracts/scripts/configure-beefy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
import fs from "fs"
import path from "path"

let endpoint = process.env.RELAYCHAIN_ENDPOINT || "ws://localhost:9944"
let endpoint = process.env.RELAYCHAIN_ENDPOINT || "ws://127.0.0.1:9944"
const beefyStartBlock = process.env.BEEFY_START_BLOCK ? parseInt(process.env.BEEFY_START_BLOCK) : 15
const BeefyStateFile =
process.env.BEEFY_STATE_FILE || path.join(process.env.output_dir!, "beefy-state.json")
Expand Down
17 changes: 6 additions & 11 deletions core/packages/test/.envrc-example
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
source_up_if_exists

## Config for E2E stack

export POLKADOT_BIN=/path/to/polkadot/target/release/polkadot
# export POLKADOT_VER= # Relaychain version, default value: v0.9.30
# export POLKADOT_BIN= # Relaychain binary, default value: $POLKADOT_DIR/target/release/polkadot
# export BEEFY_START_BLOCK= # Start block to configure beefy client, default value: 15
# export RELAYCHAIN_ENDPOINT= # Relaychain endpoint, default value: ws://localhost:9944

## Run E2E on Ropsten

Expand All @@ -17,13 +22,3 @@ export POLKADOT_BIN=/path/to/polkadot/target/release/polkadot
# export BEEFY_RELAY_ETH_KEY= # Your Beefy relayer account private key
# export PARACHAIN_RELAY_ETH_KEY= # Your Parachain relayer account private key
# export E2E_TEST_ETH_KEY= # Your E2E test account private key

# BEEFY_START_BLOCK= # Start block to configure beefy client, default value: 15

# RELAYCHAIN_ENDPOINT= # Relaychain endpoint, default value: ws://localhost:9944

# POLKADOT_DIR= # Relaychain dir, default value: $root_dir/relaychain

# POLKADOT_BIN= # Relaychain binary, default value: $POLKADOT_DIR/target/release/polkadot

# POLKADOT_VER= # Relaychain version, default value: v0.9.30
46 changes: 11 additions & 35 deletions core/packages/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,16 @@ The E2E tests run against local deployments of the parachain, relayer, the ether

## Requirements

* Ubuntu 20.04 or later. MacOS may work, but it's not currently a supported configuration.
* Development environment for Rust and Substrate. See parachain [requirements](../../../parachain/README.md#requirements).
* Development environment for the relay services. See setup [instructions](../../../relayer/README.md#Development).
* `jq` - https://stedolan.github.io/jq/download/
* geth - https://geth.ethereum.org/docs/install-and-build/installing-geth `go install github.com/ethereum/go-ethereum/cmd/geth@v1.10.23`
* g++ (required for lodestar) is available in the `build-essential` package: `apt install build-essential`
* sponge - Is available in the `moreutils` package.

```bash
apt install moreutils
```

* direnv - https://direnv.net/

* zombienet - Just download binary from [latest release](https://github.com/paritytech/zombienet/releases/), rename to `zombienet` and copy to $PATH

The E2E stack can be run on any system that supports the [Nix](https://nixos.org/explore.html) package manager. This
includes Linux, MacOS, and Windows (WSL2). See the [main README's Development section](../../../README.md#Development) for
setup instructions. Ensure that you are in a Nix development shell for the remaining instructions.

## Setup

### Install NPM dependencies

Make sure to install dependencies for all packages (contracts, api, test):

```bash
cd ../.. && pnpm install
```

### Configure testnet

All required environment variables have reasonable defaults so normally there is no need to configure them. If necessary, you can override them with an `.envrc` file, using [.envrc-example](.envrc-example) as a template.

e.g: if a `polkadot` binary already built and exist in your local host, override the `POLKADOT_BIN` variable in `.envrc` to the location of the binary:

```
POLKADOT_BIN=/home/sally/code/polkadot/target/release/polkadot
```

Once the `.envrc` has been created, let `direnv` load it automatically:

```bash
Expand All @@ -49,19 +22,21 @@ direnv allow

## Launch the testnet

Run the following script
Run the following script:

```bash
scripts/start-services.sh
```

Wait until the "Testnet has been initialized" message
Wait until the "Testnet has been initialized" message.

Go to polkadot-js and wait until the parachain has started producing blocks:
https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A11144#/explorer

You can see the relay chain by connecting to https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer
You can see the relay chain here:
https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer

Confirm the block number is > 2
Confirm the block number is > 2.

## E2E tests

Expand All @@ -76,6 +51,7 @@ pnpm test:bootstrap
```

Now individual tests can be run, like the following:

```bash
pnpm test:integration --grep 'should transfer ETH from Ethereum to Substrate \(basic channel\)'
```
Expand Down Expand Up @@ -103,7 +79,7 @@ The `start-services.sh` script writes the following logs:

Sometimes during development tests will fail for transfers in the substrate->ethereum direction. If you see this, look in `parachain-relay.log` for the following error:
```
{"@timestamp":"2022-08-26T15:10:50.263740077+02:00","args":"[--api ws://localhost:11144 --block 0xe2e21a61b017699961b6d87c6aecbae18f2ce0c89bd87e0e8b0d808c26e2aad3]","level":"error","message":"Failed to query events.","name":"snowbridge-query-events","stdErr":"Error: Metadata(IncompatibleMetadata)\n","stdOut":""}
{"@timestamp":"2022-08-26T15:10:50.263740077+02:00","args":"[--api ws://127.0.0.1:11144 --block 0xe2e21a61b017699961b6d87c6aecbae18f2ce0c89bd87e0e8b0d808c26e2aad3]","level":"error","message":"Failed to query events.","name":"snowbridge-query-events","stdErr":"Error: Metadata(IncompatibleMetadata)\n","stdOut":""}
```

That means a dependency of the relayer has obsolete parachain metadata and needs to be refreshed. Please refer [here](../../../parachain/README.md#Chain_metadata) for steps to fix.
Expand Down
4 changes: 2 additions & 2 deletions core/packages/test/config/beacon-relay.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"source": {
"beacon": {
"endpoint": "http://localhost:9596",
"endpoint": "http://127.0.0.1:9596",
"spec": {
"minimal": {
"slotsInEpoch": 4,
Expand All @@ -17,7 +17,7 @@
},
"sink": {
"parachain": {
"endpoint": "ws://localhost:11144",
"endpoint": "ws://127.0.0.1:11144",
"maxWatchedExtrinsics": 32
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/packages/test/config/beefy-relay.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"source": {
"polkadot": {
"endpoint": "ws://localhost:9944"
"endpoint": "ws://127.0.0.1:9944"
},
"beefy-activation-block": 0,
"fast-forward-depth": 20
},
"sink": {
"ethereum": {
"endpoint": "ws://localhost:8546",
"endpoint": "ws://127.0.0.1:8546",
"gas-limit": 5000000
},
"start-block": 0,
Expand Down
Loading