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

Commit

Permalink
Darwinia<>Ethereum bridger (#522)
Browse files Browse the repository at this point in the history
* Change to simple fee market

* Add bridge e2e traits

* Add fee market strategy

* Add strategy in message relay

* Update config

* Handle message timeout

* Update suxt

* Update

* Add inbound contract

* Add outbound contract

* Add simple fee market contract

* Remove inbound in bridge

* Remove outbound in bridge

* Remove fee market in bridge

* Update pangoro subxt client

* Bump version to v0.6.2

* Add chain message committer contract

* Add abis

* fix wrong storage key

* disable check for pangoro-chapel, follow #504

* Add prove method

* Add posa light client

* Fix typo

* Add ecdsa methods

* subquery ethv2

* Update POSALightClient

* Update outbound

* ecdsa subquery api

* Add runner and update template

* Add tracker and microkv

* Add lane message committer

* Support query at some block

* Add comment

* Add getLaneInfo for inbound

* Add darwinia message client

* Update config

* Add pangoro->kiln message delivery

* Optional start block number

* Try scan collecting authorities change signatures

* event handle

* Fix compile

* initialize lifeline state

* kv command

* typo

* Test subquery

* Update contracts client

* Clean

* Generate confirmation proof

* Message confirmation pangoro=>kiln

* Test subquery

* Upgrade runtime

* test ecdsa

* Messages confirmation kiln->pangoro

* test and fix message signature

* Test collecting authorities change signature

* ecdsa relay service

* Read threshold from event

* Update inbound

* Fix

* Remove block number in signature

* Update contract client

* Add alias

* Update fee market

* Fix signature

* Add get relayers interface fro posa

* Update config

* Add thegraph indexer for pangoro evm

* Replace eth_getlog with indexer

* Update inbound

* Update abis

* Update execution layer

* Follow contract update

* Rename kiln to goerli

* Update config template

* Log format

* Clean

* Fix ecdsa operation

* Update light client api

* Fix api

* Fix signatures order

* Refactor beacon light client

* Remove client-pangoro chapel part

* Update

* Update posa light client

* Refactor import finalized header

* Refactor import next sync committee

* Clean

* Fix

* Update abis

* Fix abi method name

* Format

* Fix confirmation

* Fix inbound get_lane_info

* Update gas option

* Add leave and get relayer method

* Update inbound contract

* Refactor message delivery strategy

* Fix calculation

* Update goerli to pangoro message relay

* Fix ecdsa signatures

* Add web3 helper

* Update proof gerneration

* Add gas option

* Update contract method parameters

* Ecdsa related tx confirmation

* Add confirmation to header relay

* Fix

* Fix proof block

* Add confirmation for messages relay

* Get latest messages root event

* Add confirmation limit

* Update contracts

* Format

* Update config

* Ignore tests

* Ignore test

* Add services switch config

* Update config template

* Fix

* Add methods

* Add gas price helper

* Update crate name

* Check execution layer state root

* Add gas price calculation tool

* Optimize gas price for goerli

* Update

* Optimize gas price for pangoro

* Fix

* Skip relayed message root

* Support config header relay interval

* Goerli->Pangoro header relay interval

* Add message limit per delivery

* Skip old events

* Add rpc retry strategy

* Update messages relay strategy

* Format

* Update gas

* Update config template

* Clippy

* Remove local test

* Init

* Bump darwinia subxt client

* Add ecdsa api for darwinia

* Rename

* Fix

* Revert "Rename"

This reverts commit af92bab.

* Rename Pangoro to Darwinia

* Rename goerli to ethereum

* Rename Pangoro to Darwinia

* Rename Goerli to Ethereum

* Rename pangoro to darwinia

* Rename goerli to ethereum

* Rename mods

* Update config template

* Update config

* Remove redundant config

* Update config template

* Update CI

* Fix darwinia-ethereum-pow

Co-authored-by: fewensa <fewensa@protonmail.com>
  • Loading branch information
furoxr and fewensa authored Sep 29, 2022
1 parent 54740b7 commit 879fd97
Show file tree
Hide file tree
Showing 58 changed files with 10,385 additions and 279 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
bridge:
- pangolin-ropsten
- darwinia-ethereum-pow
- darwinia-ethereum
- pangolin-pangoro
- darwinia-crab
- pangoro-chapel
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
- bridger
- pangolin-ropsten
- darwinia-ethereum-pow
- darwinia-ethereum
- pangolin-pangoro
- darwinia-crab
# - pangoro-chapel
# - pangoro-goerli
- pangoro-chapel
- pangoro-goerli
- pangolin-pangolinparachain
- crab-crabparachain
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- bridger
- pangolin-ropsten
- darwinia-ethereum-pow
- darwinia-ethereum
- pangolin-pangoro
- darwinia-crab
- pangoro-chapel
Expand Down
50 changes: 50 additions & 0 deletions .maintain/config/bridge-darwinia-ethereum-pow.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[darwinia]
# The WebSocket endpoint of any archive node (`darwinia --pruning=archive`) and enabling offchain-indexing, supports `ws://` and `wss://`.
endpoint = "ws://127.0.0.1:9944"

# Private key in hex of your account or proxy account to sign relay extrinsics. It is highly recommended to use a proxy account to prevent exposing your main account's private key.
# Proxy account is an account that can "perform" on behalf of your "real" account.
# To allow an account proxying extrinsics, you need to open [Extrinsics in apps.darwinia.network](https://apps.darwinia.network/#/extrinsics), switch to your "real" account, and submit the `proxy.addProxy(proxy_account, ProxyType.EthereumBridge, 0)` extrinsic to delegate it.
# private key of relayer, or, private key of proxy
# Here is a [tool](https://polkadot.subscan.io/tools/ss58_transform) provided by Subscan that helps convert SS58 addresses to public keys.
relayer_private_key = "0x..."
# (optional) real account public key
# If you set `seed` to the private key of your proxy account, you have to set this to the public key of your "real" account as well.
relayer_real_account = "0x..."

# private key to sign ecdsa messages
ecdsa_authority_private_key = "0x..."

[web3]
endpoint = "https://mainnet.infura.io/v3/<YOUR_KEY>"

[ethereum]
# below two need to be all setted if you want to do the relay job
# (optional) the person who will relay darwinia data to ethereum
relayer_private_key = "0x..."
# (optional) the darwinia account public key who will get the reward
relayer_beneficiary_darwinia_account = "0x..."

# listen to set authorities
subscribe_relay_address = "0x5cde5Aafeb8E06Ce9e4F94c2406d3B6CB7098E49"

[shadow]
# The endpoint of [Darwinia Shadow service](https://github.com/darwinia-network/shadow), supports HTTP and HTTPS. For example using the official service:
endpoint = "https://shadow-ethereum.darwinia.network"
thegraph = "https://api.thegraph.com/subgraphs/name/darwinia-network/ethereum-mmr"

[task]
interval_ethereum = 120
interval_relay = 60
interval_guard = 30
interval_check = 90
check_timeout = 2000

[http_client]
timeout = 3000

[thegraph]
endpoint = "https://api.thegraph.com/subgraphs/name/darwinia-network/bridge-ethereum"

[subquery]
endpoint = "https://subql.darwinia.network/subql-bridger-darwinia"
102 changes: 54 additions & 48 deletions .maintain/config/bridge-darwinia-ethereum.toml
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
[darwinia]
# The WebSocket endpoint of any archive node (`darwinia --pruning=archive`) and enabling offchain-indexing, supports `ws://` and `wss://`.
endpoint = "ws://127.0.0.1:9944"

# Private key in hex of your account or proxy account to sign relay extrinsics. It is highly recommended to use a proxy account to prevent exposing your main account's private key.
# Proxy account is an account that can "perform" on behalf of your "real" account.
# To allow an account proxying extrinsics, you need to open [Extrinsics in apps.darwinia.network](https://apps.darwinia.network/#/extrinsics), switch to your "real" account, and submit the `proxy.addProxy(proxy_account, ProxyType.EthereumBridge, 0)` extrinsic to delegate it.
# private key of relayer, or, private key of proxy
# Here is a [tool](https://polkadot.subscan.io/tools/ss58_transform) provided by Subscan that helps convert SS58 addresses to public keys.
relayer_private_key = "0x..."
# (optional) real account public key
# If you set `seed` to the private key of your proxy account, you have to set this to the public key of your "real" account as well.
relayer_real_account = "0x..."

# private key to sign ecdsa messages
ecdsa_authority_private_key = "0x..."

[web3]
endpoint = "https://mainnet.infura.io/v3/<YOUR_KEY>"
[general]
# Whether to relay beacon headers from ethereum to darwinia
header_ethereum_to_darwinia = true
# Whether to relay sync commit from ethereum to darwinia
sync_commit_ethereum_to_darwinia = true
# Whether to relay execution layer state root from ethereum to darwinia
execution_layer_ethereum_to_darwinia = true
# Whether to sign the messages root and relay headers from darwinia to ethereum
ecdsa_service = true
# Whether to relay messages from ethereum to darwinia
msg_ethereum_to_darwinia = true
# Whether to relay messages from darwinia to ethereum
msg_darwinia_to_ethereum = true
# Max number of messages every delivery
max_message_num_per_relaying = 15
# Minimum seconds between two header relay
header_relay_minimum_interval = 900

[darwinia_evm]
endpoint = "https://darwinia-rpc.darwinia.network"
contract_address = "0x9C266C48F07121181d8424768f0deD0170cC63A6"
execution_layer_contract_address = "0xe50F1Ddf0C8778773f07Eb2759d045Ece19F6Cc1"
inbound_address = "0xf1B8a9F8436800499DB8186f2da2fb3e78Ff7c2B"
outbound_address = "0xcA3749C8C3aF04278D596a3fBe461481B6aa1b01"
fee_market_address = "0xcA927Df15afb7629b79dA4713a871190315c7409"
chain_message_committer_address = "0xea7d0fE22AF25d9655f7AdDd6a59E37e84B3AB5F"
lane_message_committer_address = "0x56746a8099a7e6D962802A23e01FeDdc1282cDAe"
# private_key should not start with 0x
private_key = "//Alice"
# Max gas price bridger would use, if eth_gasPrice returns a bigger one. Unit is wei.
max_gas_price = 9000000000

[darwinia_substrate]
endpoint = "wss://darwinia-rpc.darwinia.network"
private_key = "//Alice"

[ethereum]
# below two need to be all setted if you want to do the relay job
# (optional) the person who will relay darwinia data to ethereum
relayer_private_key = "0x..."
# (optional) the darwinia account public key who will get the reward
relayer_beneficiary_darwinia_account = "0x..."

# listen to set authorities
subscribe_relay_address = "0x5cde5Aafeb8E06Ce9e4F94c2406d3B6CB7098E49"

[shadow]
# The endpoint of [Darwinia Shadow service](https://github.com/darwinia-network/shadow), supports HTTP and HTTPS. For example using the official service:
endpoint = "https://shadow-ethereum.darwinia.network"
thegraph = "https://api.thegraph.com/subgraphs/name/darwinia-network/ethereum-mmr"

[task]
interval_ethereum = 120
interval_relay = 60
interval_guard = 30
interval_check = 90
check_timeout = 2000

[http_client]
timeout = 3000

[thegraph]
endpoint = "https://api.thegraph.com/subgraphs/name/darwinia-network/bridge-ethereum"

[subquery]
endpoint = "https://subql.darwinia.network/subql-bridger-darwinia"
# Beacon chain rpc endpoint
endpoint = "https://lodestar-mainnet-rpc.darwinia.network"
# Execution layer rpc endpoint, register one at https://dashboard.alchemy.com/
execution_layer_endpoint = "..."
inbound_address = "0x4E210866d089856a8A0435965FefEe19640487E5"
outbound_address = "0x169F28bfbfFCddFdc772A94Cf020bbB4CAdc8E01"
fee_market_address = "0xCD97185B7d05f8ea91d241C8dfD51a2Cc9c0547a"
# Ethereum account private_key should not starts with 0x.
private_key = "..."
posa_light_client_address = "0xf46349a32cA70C0B9fFbD19937Fb1623e7F3db19"
# Max gas price bridger would use, if eth_gasPrice returns a bigger one. Unit is wei.
max_gas_price = 9000000000
# Bridger use etherscan gas oracle to get more appropriate gas price.
# Register to get a free etherescan api key at https://docs.etherscan.io/api-endpoints/gas-tracker
etherscan_api_key = "api_key..."

[index]
darwinia = { endpoint = "https://subql.darwinia.network/subql-bridger-darwinia/" }
darwinia_evm = { endpoint = "https://thegraph.darwinia.network/ethv2" }
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl DarwiniaScanner {

// subquery
let subquery =
SubqueryComponent::component(bridge_config.subquery, BridgeName::DarwiniaEthereum);
SubqueryComponent::component(bridge_config.subquery, BridgeName::DarwiniaEthereumPow);

// ethereum
let ethereum = EthereumComponent::component(bridge_config.ethereum, config_web3.clone())?;
Expand Down
7 changes: 7 additions & 0 deletions bridges/darwinia-ethereum/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hard_tabs = false
max_width = 100
newline_style = "Unix"
reorder_imports = true
reorder_modules = true
tab_spaces = 4
use_field_init_shorthand = true
Loading

0 comments on commit 879fd97

Please sign in to comment.