-
Notifications
You must be signed in to change notification settings - Fork 3
AMPL Chainbridge local geth deployment
Nithin Krishna edited this page Mar 12, 2021
·
3 revisions
- Run local geth networks
./scripts/start-geth.sh gethBaseChain # localhost:7545
./scripts/start-geth.sh gethSatChain1 # localhost:8545
./scripts/start-geth.sh gethSatChain2 # localhost:9545
- Setup deployer key
# create keyfile
export KEYFILE=[Path to key file]
export PASSPHRASE=
- Deploy AMPL contracts
# deploy base-chain ampleforth oracle, policy and token contracts
yarn hardhat --network gethBaseChain testnet:deploy:ampleforth \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
# deploy cross-chain ample contracts on satellite-chain-1
yarn hardhat \
--network gethSatChain1 \
deploy:ampleforth_xc \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--token-name "sat1-chainBridge-Ample" \
--token-symbol "sat1CBAmple" \
--base-chain-network gethBaseChain
# deploy cross-chain ample contracts on satellite-chain-2
yarn hardhat \
--network gethSatChain2 \
deploy:ampleforth_xc \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--token-name "sat2-chainBridge-Ample" \
--token-symbol "sat2CBAmple" \
--base-chain-network gethBaseChain
- Deploy Chain bridge contracts and connections
# deploy contracts on base chain
yarn hardhat --network gethBaseChain deploy:chain_bridge:base_chain \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--chain-id 251 \
--relayers "[\"0x70c76fa963f2d6d06bb9c640ab843c96bd48c590\",\"0xce101c1b7029d06e332f920ae117dd65d8eba955\"]" \
--relayer-threshold 1 \
--fee 0 \
--expiry 1000
# deploy contracts on satellite-chain-1
yarn hardhat --network gethSatChain1 deploy:chain_bridge:satellite_chain \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--chain-id 252 \
--relayers "[\"0x70c76fa963f2d6d06bb9c640ab843c96bd48c590\",\"0xce101c1b7029d06e332f920ae117dd65d8eba955\"]" \
--relayer-threshold 1 \
--fee 0 \
--expiry 1000
# deploy contracts on satellite-chain-2
yarn hardhat --network gethSatChain2 deploy:chain_bridge:satellite_chain \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--chain-id 253 \
--relayers "[\"0x70c76fa963f2d6d06bb9c640ab843c96bd48c590\",\"0xce101c1b7029d06e332f920ae117dd65d8eba955\"]" \
--relayer-threshold 1 \
--fee 0 \
--expiry 1000
- Generate the chain-bridge config file required to run relayers
# the following command generates the chain-bridge config-1.json/config-2.json
yarn hardhat config:chain_bridge \
--networks "[\"gethBaseChain\",\"gethSatChain1\",\"gethSatChain2\"]" \
--relayer-address "0x70c76fa963f2d6d06bb9c640ab843c96bd48c590"
yarn hardhat config:chain_bridge \
--networks "[\"gethBaseChain\",\"gethSatChain1\",\"gethSatChain2\"]" \
--relayer-address "0xce101c1b7029d06e332f920ae117dd65d8eba955"
chainbridge --config config-1.json --verbosity trace --latest
chainbridge --config config-2.json --verbosity trace --latest
{
"chains": [
{
"name": "gethBaseChain",
"type": "ethereum",
"id": "251",
"endpoint": "http://localhost:7545",
"from": "0x70c76fa963f2d6d06bb9c640ab843c96bd48c590",
"opts": {
"bridge": "0xF9FB5a5D90a4cE57ef66488BD5737d1da934b65d",
"genericHandler": "0xB78b87EdBE1598EC399fC369AbfA4370D4D764bc",
"erc20Handler": "0x4f54DF40D78159df27b8A42B81A536292109b94A",
"erc721Handler": "0x88667ee21C436C3Cd029Af7e11D49fC009d7Bca3",
"startBlock": "752"
}
},
{
"name": "gethSatChain1",
"type": "ethereum",
"id": "252",
"endpoint": "http://localhost:7550",
"from": "0x70c76fa963f2d6d06bb9c640ab843c96bd48c590",
"opts": {
"bridge": "0xD7e36FC5540986f20e42a5941777Ec333b4Cf875",
"genericHandler": "0xF63DC56cD7B55DE02A0341A5F4bbFAf9657721D9",
"erc20Handler": "0x29e7210028defEF426302407F867a99775c8313F",
"erc721Handler": "0x90B0425ed5D437beb8ED833E9C7908a809972725",
"startBlock": "770"
}
},
{
"name": "gethSatChain2",
"type": "ethereum",
"id": "253",
"endpoint": "http://localhost:7555",
"from": "0x70c76fa963f2d6d06bb9c640ab843c96bd48c590",
"opts": {
"bridge": "0x88c6FC308F6e428cdffbBa1f02b141138EC7beb4",
"genericHandler": "0x0E7aa9B4E5a669937AFD39c238519A08Ec997989",
"erc20Handler": "0xD7e36FC5540986f20e42a5941777Ec333b4Cf875",
"erc721Handler": "0xF63DC56cD7B55DE02A0341A5F4bbFAf9657721D9",
"startBlock": "783"
}
}
]
}
NOTE: Replace http
urls to ws
, as chain-bridge expects web socket connections.
- http://localhost:7545 -> ws://localhost:7546
- http://localhost:7550 -> ws://localhost:7551
- http://localhost:7555 -> ws://localhost:7556
- Inspect state
# prints ampl state
yarn hardhat info:ampl \
--networks "[\"gethBaseChain\",\"gethSatChain1\",\"gethSatChain2\"]"
# prints ampl balances across chains
yarn hardhat info:ampl:balance \
--networks "[\"gethBaseChain\",\"gethSatChain1\",\"gethSatChain2\"]" \
--wallet "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585"
# prints bridge state
yarn hardhat info:chain_bridge \
--networks "[\"gethBaseChain\",\"gethSatChain1\",\"gethSatChain2\"]"
- Cross-chain transactions
# trigger rebase on main-chain
yarn hardhat --network gethBaseChain testnet:rebase:base_chain \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--rebase-perc 10
# report rebase from base-chain to satellite-chains
yarn hardhat --network gethBaseChain report_rebase:base_chain \
--satellite-chain-networks "[\"gethSatChain1\",\"gethSatChain2\"]" \
--keyfile $KEYFILE --passphrase $PASSPHRASE
# wait for relayer to report rebase execute rebase on satellite chains
yarn hardhat rebase:satellite_chain \
--networks "[\"gethSatChain1\",\"gethSatChain2\"]" \
--keyfile $KEYFILE --passphrase $PASSPHRASE
# cross-chain transfer from base to satellite
yarn hardhat --network gethBaseChain xc_transfer \
--target-chain-network gethSatChain1 \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--recipient-address "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585" \
--amount 100
# cross-chain transfer from satellite to satellite
yarn hardhat --network gethSatChain1 xc_transfer \
--target-chain-network gethSatChain2 \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--recipient-address "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585" \
--amount 100
# cross-chain transfer from satellite to base
yarn hardhat --network gethSatChain2 xc_transfer \
--target-chain-network gethBaseChain \
--keyfile $KEYFILE --passphrase $PASSPHRASE \
--recipient-address "0x3b2b9EfdaE5291F3Bb9C7e6508C7e67534511585" \
--amount 100