Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ node_modules/

relaychain/
.vscode

.rustup
.cargo

.DS_Store
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ 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 repeatable and maintainable developer environment.

After [installing](https://nixos.org/download.html) Nix, activate a developer shell here in the root of our repo, where `shell.nix` is located:

```
nix-shell
Comment thread
doubledup marked this conversation as resolved.
Resolved
```

To ensure your code editor (such as VS code) can execute tools in the nix env, startup your editor within the interactive shell.

Example for VS Code:

```
nix-shell
Comment thread
doubledup marked this conversation as resolved.
Resolved
code .
```

## Security

The security policy and procedures can be found in SECURITY.md.
11 changes: 3 additions & 8 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.12.1",
"pnpm": "7.14.2"
},
"scripts": {
Expand All @@ -16,13 +16,8 @@
"coverage": "turbo run coverage"
},
"devDependencies": {
"husky": "^8.0.1",
"turbo": "^1.6.3",
"husky": "^8.0.1"
},
"overrides": {
"@polkadot-api@9.6.2>@polkadot/util": "10.1.11",
"@polkadot-api@9.6.2>@polkadot/util-crypto": "10.1.11",
"@polkadot-types@9.6.2>@polkadot/util": "10.1.11",
"@polkadot-types@9.6.2>@polkadot/util-crypto": "10.1.11"
"pnpm-deduplicate": "^0.4.1"
}
}
21 changes: 8 additions & 13 deletions core/packages/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@ 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.
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).

```bash
apt install moreutils
```
Make sure to [download](https://nixos.org/download.html) and install the nix package manager.

* direnv - https://direnv.net/
## Setup

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

In the root directory of our repository, where `shell.nix` is located, activate a developer shell:

## Setup
```
nix-shell
Comment thread
doubledup marked this conversation as resolved.
Resolved
```

### Install NPM dependencies

Expand Down
11 changes: 4 additions & 7 deletions core/packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
"test:bootstrap": "mocha --timeout 600000 --parallel --grep Bootstrap --exit"
},
"devDependencies": {
"@polkadot/api": "9.11.1",
"@polkadot/types": "9.11.1",
"@polkadot/util": "10.2.3",
"@polkadot/util-crypto": "10.2.3",
"@chainsafe/lodestar": "1.3.0",
"@polkadot/api": "^9.12.1",
"@polkadot/types": "9.11.1",
"@types/keccak": "^3.0.1",
"@types/node": "^16.4.2",
"@types/yargs": "^17.0.2",
"@zombienet/cli": "^1.3.29",
"bignumber.js": "^9.0.0",
"bn.js": "^5.2.0",
"c-kzg": "^1.0.7",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^3.0.0",
Expand All @@ -32,12 +32,9 @@
"keccak": "^3.0.2",
"mocha": "^8.1.3",
"node-fetch": "^3.3.0",
"polkadot-launch": "2.3.0",
"rlp": "^2.2.6",
"ts-node": "^10.1.0",
"typescript": "^4.3.5",
"web3": "^1.8.0",
"web3-utils": "^1.8.0",
"ws": "^7.4.6",
"yargs": "^17.0.1"
}
Expand Down
7 changes: 1 addition & 6 deletions core/packages/test/scripts/deploy-ethereum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ start_lodestar() {
-H 'Content-Type: application/json' \
-d '{"jsonrpc": "2.0", "id": "1", "method": "eth_getBlockByNumber","params": ["0x0", false]}' | jq -r '.result.hash')

if [[ "$OSTYPE" =~ ^darwin ]]
then
timestamp=$(gdate -d'+10second' +%s)
else
timestamp=$(date -d'+10second' +%s)
fi
timestamp=$(date -d'+10second' +%s)

npx lodestar dev \
--genesisValidators 8 \
Expand Down
32 changes: 4 additions & 28 deletions core/packages/test/scripts/deploy-polkadot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ source scripts/set-env.sh

generate_chain_spec() {
echo "Generating chain specification"
"$parachain_bin" build-spec --chain "$parachain_runtime" --disable-default-bootnode > "$output_dir/spec.json"
"$parachain_bin" build-spec --chain "$parachain_runtime" --disable-default-bootnode > "$output_dir/spec.json"

initial_beacon_block=""
while [ -z "$initial_beacon_block" ] || [ "$initial_beacon_block" == "0x0000000000000000000000000000000000000000000000000000000000000000" ]
do
Expand Down Expand Up @@ -57,32 +57,8 @@ wait_start() {
scripts/wait-for-it.sh -t 120 localhost:13144
}

polkadot_launch() {
generate_chain_spec
jq \
--arg polkadot "$(realpath $relaychain_bin)" \
--arg bin "$parachain_bin" \
--arg spec "$output_dir/spec.json" \
--arg test_collator "$(realpath $test_collator_bin)" \
--arg test_spec "$output_dir/test_spec.json" \
' .relaychain.bin = $polkadot
| .parachains[0].bin = $bin
| .parachains[0].chain = $spec
| .parachains[1].bin = $test_collator
| .parachains[1].chain = $test_spec
' \
config/launch-config.json \
> "$output_dir/launch-config.json"
npx polkadot-launch "$output_dir/launch-config.json" 2>&1 &
wait_start
}

zombienet_launch() {
deploy_polkadot() {
generate_chain_spec
zombienet spawn config/launch-config.toml --provider=native 2>&1 &
node_modules/.bin/zombienet spawn config/launch-config.toml --provider=native 2>&1 &
wait_start
}

deploy_polkadot() {
zombienet_launch
}
8 changes: 1 addition & 7 deletions core/packages/test/scripts/hack-ethereum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ source scripts/set-env.sh

hack_lodestar() {
preset_minimal_phase0_file="$core_dir/node_modules/.pnpm/@lodestar+params@$lodestar_version/node_modules/@lodestar/params/lib/presets/minimal.js"
if [[ "$OSTYPE" =~ ^darwin ]]
then
sed_cmd=gsed
else
sed_cmd=sed
fi
echo "change variable SLOTS_PER_EPOCH from 8 to 4."
$sed_cmd -i "s/SLOTS_PER_EPOCH: 8/SLOTS_PER_EPOCH: 4/g" $preset_minimal_phase0_file
sed -i "s/SLOTS_PER_EPOCH: 8/SLOTS_PER_EPOCH: 4/g" $preset_minimal_phase0_file
}

hack_lodestar
51 changes: 2 additions & 49 deletions core/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,9 @@ address_for()
jq -r ".contracts.${1}.address" "$output_dir/contracts.json"
}

kill_trap() {
trap - SIGTERM
pkill -P $$
}

kill_all() {
kill_trap
kill_chains
kill_relayer
}

kill_chains() {
echo "Killing chains"
kill_polkadot
kill_ethereum
}

kill_ethereum() {
pkill -9 -f lodestar
pkill -9 geth
}

kill_polkadot() {
pkill -9 polkadot
pkill -9 snowbridge-test-node
pkill -9 snowbridge
pkill -9 -f polkadot-launch
pkill -9 zombienet
}

kill_relayer() {
echo "Killing relayer"
kill_trap
sleep 3
pkill -9 snowbridge-relay
sleep 1
Comment thread
doubledup marked this conversation as resolved.
Resolved
trap - SIGTERM
kill 0
Comment thread
doubledup marked this conversation as resolved.
Resolved
}

cleanup() {
Expand Down Expand Up @@ -117,19 +84,5 @@ check_tool() {
echo 'Error: pnpm is not installed.'
exit
fi
if ! [ -x "$(command -v zombienet)" ]; then
echo 'Error: zombienet is not installed.'
exit
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
if ! [ -x "$(command -v gdate)" ]; then
echo 'Error: gdate is not installed.'
exit
fi
if ! [ -x "$(command -v gsed)" ]; then
echo 'Error: gsed is not installed.'
exit
fi
fi
}

2 changes: 1 addition & 1 deletion core/packages/test/scripts/start-ethereum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ start_chains()

if [ -z "${from_start_services:-}" ]; then
echo "start ethereum only!"
trap kill_ethereum SIGINT SIGTERM EXIT
trap kill_all SIGINT SIGTERM EXIT
check_tool && cleanup && start_chains
wait
fi
Expand Down
4 changes: 2 additions & 2 deletions core/packages/test/scripts/start-polkadot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source scripts/deploy-polkadot.sh
source scripts/configure-contracts.sh

start_chains()
{
{
#1 start polkadot relaychain and snowbridge parachain
echo "Starting relaychain and snowbridge parachain"
deploy_polkadot
Expand All @@ -19,7 +19,7 @@ start_chains()

if [ -z "${from_start_services:-}" ]; then
echo "start polkadot only!"
trap kill_polkadot SIGINT SIGTERM EXIT
trap kill_all SIGINT SIGTERM EXIT
check_tool && build_relaychain && build_parachain && start_chains
wait
fi
Expand Down
2 changes: 1 addition & 1 deletion core/packages/test/scripts/start-relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ start_relayer()

if [ -z "${from_start_services:-}" ]; then
echo "start relayers only!"
trap kill_relayer SIGINT SIGTERM EXIT
trap kill_all SIGINT SIGTERM EXIT
check_tool && build_relayer && kill_relayer && rm -rf *relay.log && start_relayer
wait
fi
Expand Down
2 changes: 1 addition & 1 deletion core/packages/test/scripts/start-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source scripts/build-binary.sh
from_start_services=true

trap kill_all SIGINT SIGTERM EXIT
kill_all && cleanup
cleanup
# 0. check required tools
echo "Check building tools"
check_tool
Expand Down
Loading