-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from icon-project/story/update-contract-deplo…
…y-script-#180 Story/update contract deploy script #180
- Loading branch information
Showing
11 changed files
with
407 additions
and
187 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Run bsc node with | ||
cd icon-bridge/devnet/docker/bsc-node | ||
docker run -d -p 8545:8545 -p 8546:8546 bsc-node | ||
|
||
Run goloop node using "icon" docker image from | ||
icon-bridge/devnet/docker/icon-hmny/src/docker-compose.nodes.yml | ||
|
||
To build javascore | ||
make buildsc | ||
|
||
Provide parameters in scripts/config.sh | ||
|
||
Deploy smart contract with | ||
cd ./scripts/ | ||
./deploysc.sh | ||
|
||
Run relay with | ||
export bmr_config_json=$(cat ./_ixh/bmr.config.json) | ||
docker-compose -f docker-compose-bmr.yml up -d |
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,18 @@ | ||
version: '3.3' | ||
services: | ||
|
||
bmr: | ||
image: localnets:5000/bmr:latest | ||
container_name: bmr | ||
network_mode: host | ||
restart: unless-stopped | ||
# ports: | ||
# - 6060:6060 # golang pprof | ||
entrypoint: ["/bin/bash", "-c"] | ||
command: | ||
- | | ||
echo '$bmr_config_json' >/config.json | ||
/bin/iconbridge -config /config.json | ||
environment: | ||
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} | ||
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} |
Empty file.
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,47 @@ | ||
#!/bin/sh | ||
BUILD_DIR=$(echo "$(cd "$(dirname "../../../../../")"; pwd)"/build) | ||
BASE_DIR=$(echo "$(cd "$(dirname "../../")"; pwd)") | ||
|
||
export ICONBRIDGE_CONFIG_DIR=$BASE_DIR/_ixh | ||
export ICONBRIDGE_CONTRACTS_DIR=$BUILD_DIR/contracts | ||
export ICONBRIDGE_SCRIPTS_DIR=$BASE_DIR/scripts | ||
export ICONBRIDGE_BIN_DIR=$BASE_DIR | ||
|
||
export CONFIG_DIR=${CONFIG_DIR:-${ICONBRIDGE_CONFIG_DIR}} | ||
export CONTRACTS_DIR=${CONTRACTS_DIR:-${ICONBRIDGE_CONTRACTS_DIR}} | ||
export SCRIPTS_DIR=${SCRIPTS_DIR:-${ICONBRIDGE_SCRIPTS_DIR}} | ||
|
||
################################################################################### | ||
|
||
export ICON_ENDPOINT='http://localhost:9080/api/v3/default' | ||
#'https://lisbon.net.solidwallet.io/api/v3/icon_dex' | ||
export ICON_KEY_STORE=$ICONBRIDGE_CONFIG_DIR/keystore/icon.god.wallet.json | ||
export ICON_SECRET=$ICONBRIDGE_CONFIG_DIR/keystore/icon.god.wallet.secret | ||
export ICON_NATIVE_COIN=('ICX') | ||
export ICON_NATIVE_TOKEN=('TICX' 'ETH') | ||
export ICON_WRAPPED_COIN=('TBNB' 'BNB') | ||
|
||
export GOLOOP_RPC_STEP_LIMIT=5000000000 | ||
export GOLOOP_RPC_NID='0x5b9a77' | ||
#'0x2' | ||
GOLOOPCHAIN=${GOLOOPCHAIN:-'goloop'} | ||
export GOLOOP_RPC_URI=$ICON_ENDPOINT | ||
export GOLOOP_RPC_KEY_STORE=$ICON_KEY_STORE | ||
export GOLOOP_RPC_KEY_SECRET=$ICON_SECRET | ||
|
||
################################################################################### | ||
|
||
export BSC_ENDPOINT='http://localhost:8545' | ||
#'https://data-seed-prebsc-1-s1.binance.org:8545' | ||
export BSC_RPC_URI=$BSC_ENDPOINT | ||
export BSC_KEY_STORE=$ICONBRIDGE_CONFIG_DIR/keystore/bsc.god.wallet.json | ||
export BSC_SECRET=$ICONBRIDGE_CONFIG_DIR/keystore/bsc.god.wallet.secret | ||
export BSC_NID=${BSC_NID:-'97'} | ||
export BSC_BMC_NET=${BSC_BMC_NET:-'0x61.bsc'} | ||
|
||
export BSC_NATIVE_COIN=('BNB') | ||
export BSC_NATIVE_TOKEN=('TBNB' 'ETH') | ||
export BSC_WRAPPED_COIN=('ICX' 'TICX') | ||
|
||
|
||
|
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,201 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Parts of this code is adapted from https://github.com/icon-project/btp/blob/goloop2moonbeam/testnet/goloop2moonbeam/scripts | ||
source config.sh | ||
source keystore.sh | ||
source rpc.sh | ||
|
||
|
||
deploysc() { | ||
|
||
echo "start..." | ||
echo "check god keys..." | ||
if [ ! -f "${ICON_KEY_STORE}" ]; then | ||
ensure_key_store $ICON_KEY_STORE $ICON_SECRET | ||
echo "Fund newly created wallet " $ICON_KEY_STORE | ||
exit 0 | ||
fi | ||
if [ ! -f "${BSC_KEY_STORE}" ]; then | ||
ensure_bsc_key_store $BSC_KEY_STORE $BSC_SECRET | ||
echo "Fund newly created wallet " $BSC_KEY_STORE | ||
exit 0 | ||
fi | ||
export PRIVATE_KEY="[\""$(cat $BSC_KEY_STORE.priv)"\"]" | ||
# add owners | ||
echo "List/Create user accounts" | ||
ensure_key_store $CONFIG_DIR/keystore/icon.bts.wallet.json $CONFIG_DIR/keystore/icon.bts.wallet.secret | ||
ensure_key_store $CONFIG_DIR/keystore/icon.bmc.wallet.json $CONFIG_DIR/keystore/icon.bmc.wallet.secret | ||
ensure_key_store $CONFIG_DIR/keystore/icon.bmr.wallet.json $CONFIG_DIR/keystore/icon.bmr.wallet.secret | ||
ensure_key_store $CONFIG_DIR/keystore/icon.fa.wallet.json $CONFIG_DIR/keystore/icon.fa.wallet.secret | ||
|
||
ensure_bsc_key_store $CONFIG_DIR/keystore/bsc.bts.wallet.json $CONFIG_DIR/keystore/bsc.bts.wallet.secret | ||
ensure_bsc_key_store $CONFIG_DIR/keystore/bsc.bmc.wallet.json $CONFIG_DIR/keystore/bsc.bmc.wallet.secret | ||
ensure_bsc_key_store $CONFIG_DIR/keystore/bsc.bmr.wallet.json $CONFIG_DIR/keystore/bsc.bmr.wallet.secret | ||
|
||
echo "$GOLOOP_RPC_NID.icon" >$CONFIG_DIR/net.btp.icon #0x240fa7.icon | ||
mkdir -p $CONFIG_DIR/tx | ||
|
||
source token.javascore.sh | ||
source token.solidity.sh | ||
|
||
echo "Deploy Javascore" | ||
sleep 2 | ||
#deploy icon | ||
deploy_javascore_bmc | ||
deploy_javascore_bts | ||
for v in "${ICON_NATIVE_TOKEN[@]}" | ||
do | ||
deploy_javascore_irc2 $v $v | ||
done | ||
|
||
|
||
#deploy bsc | ||
deploy_solidity_bmc | ||
deploy_solidity_bts | ||
for v in "${BSC_NATIVE_TOKEN[@]}" | ||
do | ||
deploy_solidity_token $v $v | ||
done | ||
|
||
generate_addresses_json >$CONFIG_DIR/addresses.json | ||
|
||
#configure icon | ||
echo "CONFIGURE ICON" | ||
configure_javascore_add_bmc_owner | ||
configure_javascore_bmc_setFeeAggregator | ||
configure_javascore_add_bts | ||
configure_javascore_add_bts_owner | ||
configure_javascore_bts_setICXFee | ||
#configure bsc | ||
echo "CONFIGURE BSC" | ||
configure_solidity_add_bmc_owner | ||
configure_solidity_add_bts_service | ||
configure_solidity_set_fee_ratio | ||
configure_solidity_add_bts_owner | ||
|
||
|
||
#Link icon | ||
echo "LINK ICON" | ||
configure_javascore_addLink | ||
configure_bmc_javascore_addRelay | ||
echo "Register ICON Tokens" | ||
for v in "${ICON_NATIVE_TOKEN[@]}" | ||
do | ||
configure_javascore_register_native_token $v $v | ||
get_btp_icon_coinId $v | ||
done | ||
for v in "${ICON_WRAPPED_COIN[@]}" | ||
do | ||
configure_javascore_register_wrapped_coin $v $v | ||
get_btp_icon_coinId $v | ||
done | ||
|
||
|
||
#Link bsc | ||
echo "LINK BSC" | ||
add_icon_link | ||
set_link_height | ||
add_icon_relay | ||
echo "Register BSC Tokens" | ||
for v in "${BSC_NATIVE_TOKEN[@]}" | ||
do | ||
bsc_register_native_token $v $v | ||
get_coinID $v | ||
done | ||
for v in "${BSC_WRAPPED_COIN[@]}" | ||
do | ||
bsc_register_wrapped_coin $v $v | ||
get_coinID $v | ||
done | ||
|
||
generate_relay_config >$CONFIG_DIR/bmr.config.json | ||
wait_for_file $CONFIG_DIR/bmr.config.json | ||
echo "Done deploying" | ||
} | ||
|
||
wait_for_file() { | ||
FILE_NAME=$1 | ||
timeout=10 | ||
while [ ! -f "$FILE_NAME" ]; do | ||
if [ "$timeout" == 0 ]; then | ||
echo "ERROR: Timeout while waiting for the file $FILE_NAME." | ||
exit 1 | ||
fi | ||
sleep 1 | ||
timeout=$(expr $timeout - 1) | ||
|
||
echo "waiting for the output file: $FILE_NAME" | ||
done | ||
} | ||
|
||
|
||
|
||
generate_relay_config() { | ||
jq -n ' | ||
.base_dir = $base_dir | | ||
.log_level = "debug" | | ||
.console_level = "trace" | | ||
.log_writer.filename = $log_writer_filename | | ||
.relays = [ $b2i_relay, $i2b_relay ]' \ | ||
--arg base_dir "bmr" \ | ||
--arg log_writer_filename "bmr/bmr.log" \ | ||
--argjson b2i_relay "$( | ||
jq -n ' | ||
.name = "b2i" | | ||
.src.address = $src_address | | ||
.src.endpoint = [ $src_endpoint ] | | ||
.src.options = $src_options | | ||
.src.offset = $src_offset | | ||
.dst.address = $dst_address | | ||
.dst.endpoint = [ $dst_endpoint ] | | ||
.dst.options = $dst_options | | ||
.dst.key_store = $dst_key_store | | ||
.dst.key_store.coinType = $dst_key_store_cointype | | ||
.dst.key_password = $dst_key_password ' \ | ||
--arg src_address "$(cat $CONFIG_DIR/btp.bsc.btp.address)" \ | ||
--arg src_endpoint "$BSC_ENDPOINT" \ | ||
--argjson src_offset "$(cat $CONFIG_DIR/btp.bsc.block.height)" \ | ||
--argjson src_options "$( | ||
jq -n {} | ||
)" \ | ||
--arg dst_address "$(cat $CONFIG_DIR/btp.icon.btp.address)" \ | ||
--arg dst_endpoint "$ICON_ENDPOINT" \ | ||
--argfile dst_key_store "$CONFIG_DIR/keystore/icon.bmr.wallet.json" \ | ||
--arg dst_key_store_cointype "icx" \ | ||
--arg dst_key_password "$(cat $CONFIG_DIR/keystore/icon.bmr.wallet.secret)" \ | ||
--argjson dst_options '{"step_limit":13610920010, "tx_data_size_limit":8192}' | ||
)" \ | ||
--argjson i2b_relay "$( | ||
jq -n ' | ||
.name = "i2b" | | ||
.src.address = $src_address | | ||
.src.endpoint = [ $src_endpoint ] | | ||
.src.offset = $src_offset | | ||
.src.options.verifier.blockHeight = $src_options_verifier_blockHeight | | ||
.src.options.verifier.validatorsHash = $src_options_verifier_validatorsHash | | ||
.dst.address = $dst_address | | ||
.dst.endpoint = [ $dst_endpoint ] | | ||
.dst.options = $dst_options | | ||
.dst.tx_data_size_limit = $dst_tx_data_size_limit | | ||
.dst.key_store = $dst_key_store | | ||
.dst.key_store.coinType = $dst_key_store_cointype | | ||
.dst.key_password = $dst_key_password ' \ | ||
--arg src_address "$(cat $CONFIG_DIR/btp.icon.btp.address)" \ | ||
--arg src_endpoint "$ICON_ENDPOINT" \ | ||
--argjson src_offset "$(cat $CONFIG_DIR/btp.icon.block.height)" \ | ||
--argjson src_options_verifier_blockHeight "$(cat $CONFIG_DIR/btp.icon.block.height)" \ | ||
--arg src_options_verifier_validatorsHash "$(cat $CONFIG_DIR/btp.icon.validators.hash)" \ | ||
--arg dst_address "$(cat $CONFIG_DIR/btp.bsc.btp.address)" \ | ||
--arg dst_endpoint "$BSC_ENDPOINT" \ | ||
--argfile dst_key_store "$CONFIG_DIR/keystore/bsc.bmr.wallet.json" \ | ||
--arg dst_key_store_cointype "evm" \ | ||
--arg dst_key_password "$(cat $CONFIG_DIR/keystore/bsc.bmr.wallet.secret)" \ | ||
--argjson dst_tx_data_size_limit 8192 \ | ||
--argjson dst_options '{"gas_limit":8000000}' | ||
)" | ||
} | ||
|
||
#wait-for-it.sh $GOLOOP_RPC_ADMIN_URI | ||
# run provisioning | ||
deploysc |
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
Oops, something went wrong.