-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* replace import_next_sync_committee to sync_committee_period_update * Root `next_sync_committee` in `attested_header`, ref: ethereum/consensus-specs#2932 * use body hash verify `latest_execution_payload_state_root` * sync_committee_period_update after it's finalized * revert * test * verify update does not skip a sync committee period * test beacon light client updates * skip import too old state * test beacon light client match spec * test beacon light client match spec * test beacon api * test beacon light client match prater * test beacon light client match mainnet * comment * comment * change interface * update BeaconLCMandatoryReward * deploy new beacon light client * using lodestar ssz * change interface * beacon lc e2e test * finish beacon lc e2e test * update deps * rm log * rm log * beacon light client migrator * compile blc migrator * add block_number in light client * flatten * deploy bnlc migrator * bnlc migrate script * update flatten * test migrator * migrate bnlc testnet * root next_sync_committee in attested_header * migrate bnlc on testnet * match spec test * migrate on mainnet * migrate on mainnet
- Loading branch information
Showing
27 changed files
with
290 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
cast --calldata-decode "import_next_sync_committee(((uint64,uint64,bytes32,bytes32,bytes32),(bytes[512],bytes),(uint64,uint64,bytes32,bytes32,bytes32),bytes32[],(bytes32[2],bytes),bytes4,uint64),((bytes[512],bytes),bytes32[]))" $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
unset TARGET_CHAIN | ||
unset NETWORK_NAME | ||
unset ETH_RPC_URL | ||
export NETWORK_NAME=darwinia | ||
export TARGET_CHAIN=ethlive | ||
export ETH_RPC_URL=https://rpc.darwinia.network | ||
|
||
echo "ETH_FROM: ${ETH_FROM}" | ||
|
||
. $(dirname $0)/base.sh | ||
|
||
load_saddr() { | ||
jq -r ".[\"$TARGET_CHAIN\"].\"$1\"" "$PWD/bin/addr/$MODE/$NETWORK_NAME.json" | ||
} | ||
|
||
load_taddr() { | ||
jq -r ".[\"$NETWORK_NAME\"].\"$1\"" "$PWD/bin/addr/$MODE/$TARGET_CHAIN.json" | ||
} | ||
|
||
# beacon light client config | ||
BLS_PRECOMPILE=0x0000000000000000000000000000000000000800 | ||
SLOT=5225184 | ||
PROPOSER_INDEX=205286 | ||
PARENT_ROOT=0x278b67c45b0684beac03e61036011eb5c58460db0cd37d297507c5dc55bc57a9 | ||
STATE_ROOT=0x5a6c1264b2a98c8fb3012ad095f3dc745f4a55b71cf4b4101defd99c32373ac8 | ||
BODY_ROOT=0x08d9d0ff508a3ca59baf53b79af98f26fa531dec17b52086f59582feae0b9e76 | ||
CURRENT_SYNC_COMMITTEE_HASH=0xe81fbd2b71e6c8f7cd599fb7964a412bcdec3ebdd9843dc92b840c7663be89e8 | ||
GENESIS_VALIDATORS_ROOT=0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95 | ||
|
||
BeaconLightClient=$(deploy BeaconLightClient \ | ||
$BLS_PRECOMPILE \ | ||
$SLOT \ | ||
$PROPOSER_INDEX \ | ||
$PARENT_ROOT \ | ||
$STATE_ROOT \ | ||
$BODY_ROOT \ | ||
$CURRENT_SYNC_COMMITTEE_HASH \ | ||
$GENESIS_VALIDATORS_ROOT) | ||
|
||
ExecutionLayer=$(deploy ExecutionLayer $BeaconLightClient) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
unset TARGET_CHAIN | ||
unset NETWORK_NAME | ||
unset ETH_RPC_URL | ||
export NETWORK_NAME=darwinia | ||
export TARGET_CHAIN=ethlive | ||
export ETH_RPC_URL=https://rpc.darwinia.network | ||
|
||
echo "ETH_FROM: ${ETH_FROM}" | ||
|
||
. $(dirname $0)/base.sh | ||
|
||
load_saddr() { | ||
jq -r ".[\"$TARGET_CHAIN\"].\"$1\"" "$PWD/bin/addr/$MODE/$NETWORK_NAME.json" | ||
} | ||
|
||
load_taddr() { | ||
jq -r ".[\"$NETWORK_NAME\"].\"$1\"" "$PWD/bin/addr/$MODE/$TARGET_CHAIN.json" | ||
} | ||
|
||
HelixDaoMultisig=0xBd1a110ec476b4775c43905000288881367B1a88 | ||
EthereumStorageVerifier=$(load_saddr "EthereumStorageVerifier") | ||
ExecutionLayer=$(load_saddr "ExecutionLayer") | ||
|
||
data=$(seth calldata "changeLightClient(address)" $ExecutionLayer) | ||
seth call -F $HelixDaoMultisig $EthereumStorageVerifier $data | ||
seth send -F $ETH_FROM $HelixDaoMultisig "submitTransaction(address,uint,bytes)" $EthereumStorageVerifier 0 $data | ||
count=$(seth call $HelixDaoMultisig "transactionCount()(uint)") | ||
seth call $HelixDaoMultisig "transactions(uint)(address,uint,bytes,bool)" $(( $count - 1 )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
unset TARGET_CHAIN | ||
unset NETWORK_NAME | ||
unset ETH_RPC_URL | ||
export NETWORK_NAME=pangoro | ||
export TARGET_CHAIN=goerli | ||
# export ETH_RPC_URL=https://pangoro-rpc.darwinia.network | ||
export ETH_RPC_URL=http://35.247.165.91:9933 | ||
|
||
. $(dirname $0)/base.sh | ||
|
||
load_saddr() { | ||
jq -r ".[\"$TARGET_CHAIN\"].\"$1\"" "$PWD/bin/addr/$MODE/$NETWORK_NAME.json" | ||
} | ||
|
||
load_taddr() { | ||
jq -r ".[\"$NETWORK_NAME\"].\"$1\"" "$PWD/bin/addr/$MODE/$TARGET_CHAIN.json" | ||
} | ||
|
||
# beacon light client config | ||
BLS_PRECOMPILE=0x0000000000000000000000000000000000000800 | ||
GENESIS_VALIDATORS_ROOT=0x043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb | ||
|
||
HelixDaoMultisig=0x43d6711EB86C852Ec1E04af55C52a0dd51b2C743 | ||
OLD_BEACON_LC=$(load_saddr "BeaconLightClient") | ||
EthereumStorageVerifier=$(load_saddr "EthereumStorageVerifier") | ||
|
||
BeaconLightClientMigrator=$(dapp create src/migrate/BeaconLightClientMigrator.sol:BeaconLightClientMigrator \ | ||
$HelixDaoMultisig \ | ||
$OLD_BEACON_LC \ | ||
$EthereumStorageVerifier \ | ||
$BLS_PRECOMPILE \ | ||
$GENESIS_VALIDATORS_ROOT) | ||
|
||
save_contract "BeaconLightClientMigrator" "$BeaconLightClientMigrator" | ||
|
||
data=$(seth calldata "changeSetter(address)" $BeaconLightClientMigrator) | ||
seth send $HelixDaoMultisig "submitTransaction(address,uint,bytes)" $EthereumStorageVerifier 0 $data | ||
seth send $BeaconLightClientMigrator "migrate()" | ||
|
||
BeaconLightClient=$(seth call $BeaconLightClientMigrator "new_beacon_lc()(address)") | ||
save_contract "BeaconLightClient" "$BeaconLightClient" | ||
|
||
ExecutionLayer=$(seth call $BeaconLightClientMigrator "new_execution_layer()(address)") | ||
save_contract "ExecutionLayer" "$ExecutionLayer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
contracts/bridge/src/migrate/BeaconLightClientMigrator.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// This file is part of Darwinia. | ||
// Copyright (C) 2018-2022 Darwinia Network | ||
// SPDX-License-Identifier: GPL-3.0 | ||
// | ||
// Darwinia is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Darwinia is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity 0.7.6; | ||
pragma abicoder v2; | ||
|
||
import "../truth/eth/BeaconLightClient.sol"; | ||
import "../truth/eth/ExecutionLayer.sol"; | ||
|
||
|
||
interface IEthereumStorageVerifier { | ||
function changeLightClient(address lightclient) external; | ||
function changeSetter(address setter) external; | ||
} | ||
|
||
contract BeaconLightClientMigrator { | ||
BeaconLightClient public new_beacon_lc; | ||
ExecutionLayer public new_execution_layer; | ||
|
||
address public immutable HELIX_DAO; | ||
address public immutable OLD_BEACON_LC; | ||
address public immutable ETHEREUM_STORAGE_VERIFIER; | ||
address public immutable BLS_PRECOMPILE; | ||
bytes32 public immutable GENESIS_VALIDATORS_ROOT; | ||
|
||
constructor( | ||
address helix_dao, | ||
address old_lc, | ||
address verifier, | ||
address bls, | ||
bytes32 genesis_validators_root | ||
) { | ||
HELIX_DAO = helix_dao; | ||
OLD_BEACON_LC = old_lc; | ||
ETHEREUM_STORAGE_VERIFIER = verifier; | ||
BLS_PRECOMPILE = bls; | ||
GENESIS_VALIDATORS_ROOT = genesis_validators_root; | ||
} | ||
|
||
function migrate() public { | ||
// fetch latest finalized header | ||
( | ||
uint64 slot, | ||
uint64 proposer_index, | ||
bytes32 parent_root, | ||
bytes32 state_root, | ||
bytes32 body_root | ||
) = BeaconLightClient(OLD_BEACON_LC).finalized_header(); | ||
// current sync committee period | ||
uint64 period = slot / 32 / 256; | ||
// fetch current sync_committee hash | ||
bytes32 current_sync_committee_hash = BeaconLightClient(OLD_BEACON_LC).sync_committee_roots(period); | ||
require(current_sync_committee_hash != bytes32(0), "missing"); | ||
|
||
// new BeaconLightClient | ||
new_beacon_lc = new BeaconLightClient( | ||
BLS_PRECOMPILE, | ||
slot, | ||
proposer_index, | ||
parent_root, | ||
state_root, | ||
body_root, | ||
current_sync_committee_hash, | ||
GENESIS_VALIDATORS_ROOT | ||
); | ||
// new ExecutionLayer | ||
new_execution_layer = new ExecutionLayer(address(new_beacon_lc)); | ||
// change light client | ||
IEthereumStorageVerifier(ETHEREUM_STORAGE_VERIFIER).changeLightClient(address(new_execution_layer)); | ||
|
||
returnSetter(); | ||
} | ||
|
||
function returnSetter() public { | ||
// return auth | ||
IEthereumStorageVerifier(ETHEREUM_STORAGE_VERIFIER).changeSetter(HELIX_DAO); | ||
} | ||
} |
Oops, something went wrong.