Skip to content

Commit

Permalink
Increase test coverage & Fix for goerli setup (paritytech#853)
Browse files Browse the repository at this point in the history
* Fix nix setup

* Generate fixtures for next sync period & adding tests accordingly

* More cleanup

* Fix ci

* More tests

* Remove install foundry

* Fix&Refactoring for goerli main spec

* Resolve comments

* Resolve comments

* For comment

* Running beacon node with explicit node option

* Bug fix for withdrawalCredentials

* Use Box Type for storing prepared pubkeys

* More refactoring

* More cleanup

* More cleanup

* Fix benchmark fixture

* Update benchmark

* Update weights

* Resolve comments

* Ignore code path for coverage

* Update cumulus

* Speed up E2E

* Fix ci adding feature release back for benchmark
  • Loading branch information
yrong authored Jun 9, 2023
1 parent 118b614 commit cd9e049
Show file tree
Hide file tree
Showing 34 changed files with 1,771 additions and 1,499 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ethereum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ jobs:
node-version: v18.16.0
cache: "pnpm"
cache-dependency-path: core/pnpm-lock.yaml
- name: Install dependencies
working-directory: core
run: pnpm install --frozen-lockfile
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Build
working-directory: core/packages/contracts
run: pnpm build
- name: Install dependencies and Build all
working-directory: core
run: pnpm install --frozen-lockfile && pnpm build
- name: Test
working-directory: core/packages/contracts
run: forge test
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/parachain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
args: >-
--manifest-path parachain/Cargo.toml
--workspace
--release
--features runtime-benchmarks
--exclude snowbridge-query-events
--exclude snowbridge-ethereum-beacon-client
Expand All @@ -97,7 +96,6 @@ jobs:
command: test
args: >-
--manifest-path parachain/Cargo.toml
--release
--package snowbridge-ethereum-beacon-client
toolchain: nightly-2023-04-22
# Run benchmark tests for beacon light client
Expand Down Expand Up @@ -132,7 +130,6 @@ jobs:
- run: >-
cargo tarpaulin
--manifest-path parachain/Cargo.toml
--release
--workspace
--engine llvm
--out Xml
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ ignore:
- "core/packages/contracts/src/ScaleCodec.sol"
- "core/packages/contracts/src/SubstrateTypes.sol"
- "parachain/tools"
- "parachain/pallets/ethereum-beacon-client/src/benchmarking"
- "parachain/pallets/ethereum-beacon-client/src/weights.rs"
7 changes: 5 additions & 2 deletions core/init.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

echo "Update submodules"
(cd .. && (git submodule update --init --recursive||true))

echo "Install husky hook"
(cd .. && ./core/node_modules/.bin/husky install)

echo "Installing sszgen"
go install github.com/ferranbt/fastssz/sszgen@latest

echo "Initialize foundry libraries"
(cd packages/contracts && (forge install||true))
(cd packages/contracts && forge install)

2 changes: 0 additions & 2 deletions core/packages/test/scripts/configure-beacon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ config_beacon_checkpoint()
check_point_call=$($relay_bin generate-beacon-checkpoint --spec $active_spec --url $beacon_endpoint_http)
popd
send_governance_transact_from_relaychain $bridgehub_para_id "$check_point_call" 180000000000 900000
# waiting for xcm to be executed on parachain
sleep 12
}

wait_beacon_chain_ready()
Expand Down
2 changes: 1 addition & 1 deletion core/packages/test/scripts/deploy-ethereum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ start_lodestar() {
--enr.ip6 "127.0.0.1" \
--eth1.providerUrls "http://127.0.0.1:8545" \
--execution.urls "http://127.0.0.1:8551" \
--dataDir "$output_dir/beacon-$timestamp" \
--dataDir "$ethereum_data_dir" \
--reset \
--terminal-total-difficulty-override 0 \
--genesisEth1Hash $genesisHash \
Expand Down
3 changes: 1 addition & 2 deletions core/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ cumulus_bin="${CUMULUS_BIN:-$cumulus_dir/bin/polkadot-parachain}"
core_dir="$root_dir/core"
lodestar_version="${LODESTAR_VER:-1.8.0}"
geth_version="${GETH_VER:-v1.11.2}"
geth_dir="$root_dir/../go-ethereum/$geth_version"
contract_dir="$core_dir/packages/contracts"
relay_dir="$root_dir/relayer"
relay_bin="$relay_dir/build/snowbridge-relay"
export output_dir="${OUTPUT_DIR:-/tmp/snowbridge}"
export output_bin_dir="$output_dir/bin"
ethereum_data_dir="$output_dir/geth"
ethereum_data_dir="$output_dir/ethereum"
zombienet_data_dir="$output_dir/zombienet"
export PATH="$output_bin_dir:$PATH"

Expand Down
2 changes: 1 addition & 1 deletion core/packages/test/scripts/start-chains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source scripts/deploy-polkadot.sh
start_chains()
{ #1 start ethereum and deploy contracts
echo "start ethereum and deploy bridge contrancts"
deploy_ethereum
deploy_ethereum &
#2 start polkadot relaychain and snowbridge parachain
echo "Starting Polkadot, BridgeHub, and Snowbridge"
deploy_polkadot
Expand Down
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 @@ -14,6 +14,6 @@ start_chains()
if [ -z "${from_start_services:-}" ]; then
echo "start ethereum only!"
trap kill_all SIGINT SIGTERM EXIT
check_tool && cleanup && start_chains
check_tool && rm -rf "$ethereum_data_dir" && start_chains
wait
fi
15 changes: 11 additions & 4 deletions core/packages/test/scripts/start-goerli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ set -eu

source scripts/set-env.sh


start_chains()
{
npx lodestar beacon --dataDir="./ethereum-goerli" --network="goerli" --rest.namespace="*" --jwt-secret="./config/jwtsecret" --checkpointSyncUrl="https://sync-goerli.beaconcha.in" 2>&1 &
geth --goerli --override.shanghai=0 --datadir="./ethereum-goerli" --authrpc.addr="127.0.0.1" --http.addr="0.0.0.0" --http.corsdomain '*' --http --http.api eth,net,engine,admin --authrpc.jwtsecret config/jwtsecret 2>&1 &
echo "Starting execution node"
geth --goerli --override.shanghai=0 --datadir="$ethereum_data_dir" --authrpc.addr="127.0.0.1" --http.addr="0.0.0.0" --http.corsdomain '*' --http --http.api eth,net,engine,admin --authrpc.jwtsecret config/jwtsecret > "$output_dir/geth.log" 2>&1 &
echo "Waiting for geth API to be ready"
sleep 3
echo "Starting beacon node"
# explicit config max-old-space-size or will be oom
node --max-old-space-size=4096 ../../node_modules/.pnpm/@chainsafe+lodestar@1.8.0_c-kzg@1.1.3_fastify@3.15.1/node_modules/@chainsafe/lodestar/lib/index.js beacon --dataDir="$ethereum_data_dir" --network=goerli --rest.namespace=* --jwt-secret=./config/jwtsecret --checkpointSyncUrl=https://sync-goerli.beaconcha.in > "$output_dir/lodestar.log" 2>&1 &
echo "Waiting for beacon node to sync from checkpoint"
sleep 10
echo "Ethereum started!"
}

if [ -z "${from_start_services:-}" ]; then
echo "start goerli locally!"
trap kill_all SIGINT SIGTERM EXIT
start_chains
check_tool && rm -rf "$ethereum_data_dir" && start_chains
wait
fi
2 changes: 1 addition & 1 deletion core/packages/test/scripts/start-polkadot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ start_chains()
if [ -z "${from_start_services:-}" ]; then
echo "start polkadot only!"
trap kill_all SIGINT SIGTERM EXIT
check_tool && build_relaychain && build_cumulus_from_source && start_chains
check_tool && build_relaychain && build_cumulus_from_source && rm -rf $zombienet_data_dir && start_chains
wait
fi

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 @@ -128,6 +128,6 @@ build_relayer()
if [ -z "${from_start_services:-}" ]; then
echo "start relayers only!"
trap kill_all SIGINT SIGTERM EXIT
check_tool && build_relayer && start_relayer
check_tool && build_relayer && config_relayer && start_relayer
wait
fi
22 changes: 9 additions & 13 deletions core/packages/test/scripts/start-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,21 @@ start_chains

# 3. config beefy client
source scripts/configure-beefy.sh
configure_beefy
configure_beefy &

# 4. config beacon client
source scripts/configure-beacon.sh
configure_beacon

# 5. Configure bridgehub exporter on statemine
# 4. Configure bridgehub exporter on statemine
source scripts/configure-statemine.sh
configure_statemine
configure_statemine &

# 6. Configure relayers
source scripts/start-relayer.sh
echo "Config relayers"
config_relayer
# 5. config beacon client
source scripts/configure-beacon.sh
configure_beacon

if [ "$skip_relayer" == "false" ]; then
# 7. start relayer
# 6. start relayer
source scripts/start-relayer.sh
echo "Starting relayers"
start_relayer
config_relayer && start_relayer
fi

echo "Testnet has been initialized"
Expand Down
2 changes: 2 additions & 0 deletions parachain/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ rococo-local.json

# coverage reports
cobertura.xml

pallets/ethereum-beacon-client/tests/fixtures/*.mainnet.json
Loading

0 comments on commit cd9e049

Please sign in to comment.