Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Swap verifier impl to the beacon light client (paritytech#665)
Browse files Browse the repository at this point in the history
* Swap verifier impl to the beacon light client.

* Remove starting eth1 relayer. Makes beacon syncing mandatory. Updates readme.

* Remove reference to sync-beacon and commit metadata.

Co-authored-by: claravanstaden <Cats 4 life!>
  • Loading branch information
claravanstaden authored Aug 24, 2022
1 parent 0d641d1 commit 69fdd4b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 124 deletions.
4 changes: 2 additions & 2 deletions parachain/runtime/snowbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ use incentivized_channel::{

impl basic_channel_inbound::Config for Runtime {
type Event = Event;
type Verifier = ethereum_light_client::Pallet<Runtime>;
type Verifier = ethereum_beacon_client::Pallet<Runtime>;
type MessageDispatch = dispatch::Pallet<Runtime>;
type WeightInfo = ();
}
Expand Down Expand Up @@ -591,7 +591,7 @@ impl Convert<U256, Option<Balance>> for FeeConverter {

impl incentivized_channel_inbound::Config for Runtime {
type Event = Event;
type Verifier = ethereum_light_client::Pallet<Runtime>;
type Verifier = ethereum_beacon_client::Pallet<Runtime>;
type MessageDispatch = dispatch::Pallet<Runtime>;
type Currency = Balances;
type SourceAccount = SourceAccount;
Expand Down
4 changes: 2 additions & 2 deletions parachain/runtime/snowblink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ use incentivized_channel::{

impl basic_channel_inbound::Config for Runtime {
type Event = Event;
type Verifier = ethereum_light_client::Pallet<Runtime>;
type Verifier = ethereum_beacon_client::Pallet<Runtime>;
type MessageDispatch = dispatch::Pallet<Runtime>;
type WeightInfo = ();
}
Expand Down Expand Up @@ -591,7 +591,7 @@ impl Convert<U256, Option<Balance>> for FeeConverter {

impl incentivized_channel_inbound::Config for Runtime {
type Event = Event;
type Verifier = ethereum_light_client::Pallet<Runtime>;
type Verifier = ethereum_beacon_client::Pallet<Runtime>;
type MessageDispatch = dispatch::Pallet<Runtime>;
type Currency = Balances;
type SourceAccount = SourceAccount;
Expand Down
4 changes: 2 additions & 2 deletions parachain/runtime/snowbridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ use incentivized_channel::{

impl basic_channel_inbound::Config for Runtime {
type Event = Event;
type Verifier = ethereum_light_client::Pallet<Runtime>;
type Verifier = ethereum_beacon_client::Pallet<Runtime>;
type MessageDispatch = dispatch::Pallet<Runtime>;
type WeightInfo = ();
}
Expand Down Expand Up @@ -591,7 +591,7 @@ impl Convert<U256, Option<Balance>> for FeeConverter {

impl incentivized_channel_inbound::Config for Runtime {
type Event = Event;
type Verifier = ethereum_light_client::Pallet<Runtime>;
type Verifier = ethereum_beacon_client::Pallet<Runtime>;
type MessageDispatch = dispatch::Pallet<Runtime>;
type Currency = Balances;
type SourceAccount = SourceAccount;
Expand Down
Binary file modified parachain/tools/query-events/metadata.scale
Binary file not shown.
2 changes: 0 additions & 2 deletions test/.envrc-example
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ export PARACHAIN_ID=1000
# 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

# export START_BEACON_SYNC=false # Start the Beacon chain syncing (in development)
15 changes: 10 additions & 5 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ The E2E tests run against local deployments of the parachain, relayer, the ether

* Ubuntu 20.04 or later. MacOs may work, but its not currently a supported configuration.
* Development environment for Rust and Substrate. See parachain [requirements](../parachain/README.md#requirements).
* Node 14 LTS. Can install using [nvm](https://github.com/nvm-sh/nvm#installing-and-updating):
* Node 16. Can install using [nvm](https://github.com/nvm-sh/nvm#installing-and-updating):

```bash
nvm install 14.17.4
nvm use 14.17.4
nvm install 16.13.2
nvm use 16.13.2
```

* Development environment for Ethereum smart contracts.
Expand All @@ -22,7 +22,12 @@ The E2E tests run against local deployments of the parachain, relayer, the ether
* 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
* lodestar - `yarn global add @chainsafe/[email protected]`
* lodestar - https://chainsafe.github.io/lodestar/install/source/ Use `v0.40.0-dev.ccdf688e6e`. Newer versions should work but hasn't been tested.

```bash
yarn global add @chainsafe/[email protected]
```

* sponge - Is available in the `moreutils` package.

```bash
Expand All @@ -32,7 +37,7 @@ The E2E tests run against local deployments of the parachain, relayer, the ether
* polkadot-launch

```bash
yarn global add polkadot-launch@2.2.1
yarn global add polkadot-launch@2.3.0
```

* direnv - https://direnv.net/
Expand Down
54 changes: 0 additions & 54 deletions test/config/initial-beacon-sync-fake.json

This file was deleted.

78 changes: 21 additions & 57 deletions test/scripts/start-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ infura_endpoint_ws="${ETH_WS_ENDPOINT:-ws://localhost:8546}/${INFURA_PROJECT_ID:
parachain_relay_eth_key="${PARACHAIN_RELAY_ETH_KEY:-0x8013383de6e5a891e7754ae1ef5a21e7661f1fe67cd47ca8ebf4acd6de66879a}"
beefy_relay_eth_key="${BEEFY_RELAY_ETH_KEY:-0x935b65c833ced92c43ef9de6bff30703d941bd92a2637cb00cfad389f5862109}"

start_beacon_sync="${START_BEACON_SYNC:-false}"
beacon_endpoint_http="${BEACON_HTTP_ENDPOINT:-http://localhost:9596}"

output_dir=/tmp/snowbridge
Expand All @@ -34,11 +33,6 @@ start_geth() {
fi

local data_dir="$output_dir/geth"

# removes TTD bomb for when beacon chain is not used
if [ "$start_beacon_sync" == "false" ]; then
jq 'del(.config.terminalTotalDifficulty)' "$output_dir/genesis.json" | sponge "$output_dir/genesis.json"
fi

if [ "$eth_network" == "localhost" ]; then
echo "Starting geth local net"
Expand All @@ -63,10 +57,6 @@ start_geth() {
}

start_lodestar() {
if [ "$start_beacon_sync" == "false" ]; then
return
fi

if [ "$eth_network" == "localhost" ]; then
echo "Waiting for geth API to be ready"
sleep 2
Expand Down Expand Up @@ -152,25 +142,21 @@ start_polkadot_launch()
-d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params": ["latest", false],"id":1}' \
| node scripts/helpers/transformEthHeader.js > "$output_dir/initialHeader.json"

if [ "$start_beacon_sync" == "true" ]; then
initial_beacon_block=$(curl "$beacon_endpoint_http/eth/v1/beacon/states/head/finality_checkpoints" \
| jq -r '.data.finalized.root')
initial_beacon_block=$(curl "$beacon_endpoint_http/eth/v1/beacon/states/head/finality_checkpoints" \
| jq -r '.data.finalized.root')

curl "$beacon_endpoint_http/eth/v1/light_client/bootstrap/$initial_beacon_block" \
| node scripts/helpers/transformInitialBeaconSync.js > "$output_dir/initialBeaconSync_tmp.json"
curl "$beacon_endpoint_http/eth/v1/light_client/bootstrap/$initial_beacon_block" \
| node scripts/helpers/transformInitialBeaconSync.js > "$output_dir/initialBeaconSync_tmp.json"

validatorsRoot=$(curl "$beacon_endpoint_http/eth/v1/beacon/genesis" \
| jq -r '.data.genesis_validators_root')
validatorsRoot=$(curl "$beacon_endpoint_http/eth/v1/beacon/genesis" \
| jq -r '.data.genesis_validators_root')

jq \
--arg validatorsRoot "$validatorsRoot" \
' .validators_root = $validatorsRoot
' \
"$output_dir/initialBeaconSync_tmp.json" \
> "$output_dir/initialBeaconSync.json"
else
cp config/initial-beacon-sync-fake.json "$output_dir/initialBeaconSync.json"
fi
jq \
--arg validatorsRoot "$validatorsRoot" \
' .validators_root = $validatorsRoot
' \
"$output_dir/initialBeaconSync_tmp.json" \
> "$output_dir/initialBeaconSync.json"

cat "$output_dir/spec.json" | node scripts/helpers/mutateSpec.js "$output_dir/initialHeader.json" "$output_dir/contracts.json" "$output_dir/initialBeaconSync.json" | sponge "$output_dir/spec.json"

Expand Down Expand Up @@ -319,35 +305,19 @@ start_relayer()
done
) &

# Launch ethereum relay
# Launch beacon relay
(
: > ethereum-relay.log
: > beacon-relay.log
while :
do
echo "Starting ethereum relay at $(date)"
"${relay_bin}" run ethereum \
--config $output_dir/ethereum-relay.json \
--substrate.private-key "//Relay" \
>>ethereum-relay.log 2>&1 || true
echo "Starting beacon relay at $(date)"
"${relay_bin}" run beacon \
--config $output_dir/beacon-relay.json \
--substrate.private-key "//BeaconRelay" \
>>beacon-relay.log 2>&1 || true
sleep 20
done
) &

if [ "$start_beacon_sync" == "true" ]; then
# Launch beacon relay
(
: > beacon-relay.log
while :
do
echo "Starting beacon relay at $(date)"
"${relay_bin}" run beacon \
--config $output_dir/beacon-relay.json \
--substrate.private-key "//BeaconRelay" \
>>beacon-relay.log 2>&1 || true
sleep 20
done
) &
fi
}

cleanup() {
Expand Down Expand Up @@ -377,14 +347,8 @@ start_relayer
echo "Process Tree:"
pstree -T $$

sleep 3
until grep "Syncing headers starting..." ethereum-relay.log > /dev/null; do
echo "Waiting for ethereum relay to generate the DAG cache. This can take up to 20 minutes."
sleep 20
done

until grep "Done retrieving finalized headers" ethereum-relay.log > /dev/null; do
echo "Waiting for ethereum relay to sync headers..."
until grep "starting to sync finalized headers" beacon-relay.log > /dev/null; do
echo "Waiting for beacon relay to sync headers..."
sleep 5
done

Expand Down

0 comments on commit 69fdd4b

Please sign in to comment.