Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes on the deploy scripts #213

Merged
merged 11 commits into from
Oct 7, 2024
57 changes: 49 additions & 8 deletions multisig/interaction/config/aggregator-snippets.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
deployAggregator() {
CHECK_VARIABLES AGGREGATOR_WASM CHAIN_SPECIFIC_TOKEN ALICE_ADDRESS
CHECK_VARIABLES AGGREGATOR_WASM CHAIN_SPECIFIC_TOKEN ORACLE_ADDR_0 ORACLE_ADDR_1 ORACLE_ADDR_2

MIN_STAKE=$(echo "$RELAYER_REQUIRED_STAKE*10^18" | bc)
STAKE=$(echo "$ORACLE_REQUIRED_STAKE*10^18" | bc)
mxpy --verbose contract deploy --bytecode=${AGGREGATOR_WASM} --recall-nonce --pem=${ALICE} \
--gas-limit=100000000 --arguments str:EGLD ${MIN_STAKE} 1 1 1 ${ALICE_ADDRESS} \
--gas-limit=100000000 --arguments str:EGLD ${STAKE} 1 2 3 \
${ORACLE_ADDR_0} ${ORACLE_ADDR_1} ${ORACLE_ADDR_2} \
--send --outfile=deploy-price-agregator-testnet.interaction.json --proxy=${PROXY} --chain=${CHAIN_ID} || return

TRANSACTION=$(mxpy data parse --file="./deploy-price-agregator-testnet.interaction.json" --expression="data['emittedTransactionHash']")
Expand All @@ -17,13 +18,25 @@ deployAggregator() {
update-config AGGREGATOR ${ADDRESS}
}

stake() {
stakeOracles() {
CHECK_VARIABLES AGGREGATOR

MIN_STAKE=$(echo "$RELAYER_REQUIRED_STAKE*10^18" | bc)
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ALICE} \
--gas-limit=35000000 --function="stake" --value=${MIN_STAKE} \
STAKE=$(echo "$ORACLE_REQUIRED_STAKE*10^18" | bc)
echo "---------------------------------------------------------"
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ORACLE_WALLET0} \
--gas-limit=35000000 --function="stake" --value=${STAKE} \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
echo "---------------------------------------------------------"
echo "---------------------------------------------------------"
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ORACLE_WALLET1} \
--gas-limit=35000000 --function="stake" --value=${STAKE} \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
echo "---------------------------------------------------------"
echo "---------------------------------------------------------"
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ORACLE_WALLET2} \
--gas-limit=35000000 --function="stake" --value=${STAKE} \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
echo "---------------------------------------------------------"
}

submitAggregatorBatch() {
Expand All @@ -32,7 +45,27 @@ submitAggregatorBatch() {
FEE=$(echo "scale=0; $FEE_AMOUNT*10^$NR_DECIMALS_CHAIN_SPECIFIC/1" | bc)

CURRENT_TIME=$(date +%s)
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ALICE} \
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ORACLE_WALLET0} \
--gas-limit=15000000 --function="submitBatch" \
--arguments str:GWEI str:${CHAIN_SPECIFIC_TOKEN_TICKER} ${CURRENT_TIME} ${FEE} 0 \
--send --proxy=${PROXY} --chain=${CHAIN_ID} || return

# super-terrible hack, I'm ashamed of it. This is to allow submissions to be executed in different blocks
# TODO: fix this
sleep 6

CURRENT_TIME=$(date +%s)
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ORACLE_WALLET1} \
--gas-limit=15000000 --function="submitBatch" \
--arguments str:GWEI str:${CHAIN_SPECIFIC_TOKEN_TICKER} ${CURRENT_TIME} ${FEE} 0 \
--send --proxy=${PROXY} --chain=${CHAIN_ID} || return

# super-terrible hack, I'm ashamed with it. This is to allow submissions to be executed in different blocks
# TODO: fix this
sleep 6

CURRENT_TIME=$(date +%s)
mxpy --verbose contract call ${AGGREGATOR} --recall-nonce --pem=${ORACLE_WALLET2} \
--gas-limit=15000000 --function="submitBatch" \
--arguments str:GWEI str:${CHAIN_SPECIFIC_TOKEN_TICKER} ${CURRENT_TIME} ${FEE} 0 \
--send --proxy=${PROXY} --chain=${CHAIN_ID} || return
Expand Down Expand Up @@ -62,3 +95,11 @@ unpauseAggregator() {
--gas-limit=5000000 --function="unpause" \
--send --proxy=${PROXY} --chain=${CHAIN_ID} || return
}

aggregator-upgrade() {
CHECK_VARIABLES AGGREGATOR AGGREGATOR_WASM

mxpy --verbose contract upgrade ${AGGREGATOR} --bytecode=${AGGREGATOR_WASM} --recall-nonce --pem=${ALICE} \
--gas-limit=100000000 --send \
--outfile="upgrade-aggregator.json" --proxy=${PROXY} --chain=${CHAIN_ID} || return
}
40 changes: 28 additions & 12 deletions multisig/interaction/config/configs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ ALICE_ADDRESS=erd1zsha9cvx7gwraytgp740dcjzwy9v5xwnmas77d33uve6sk0rs0vqel4ln5

#============WASM FILES==============

AGGREGATOR_WASM="./price-aggregator.wasm"
AGGREGATOR_WASM="./multiversx-price-aggregator-sc.wasm"
SAFE_WASM="./esdt-safe.wasm"
BRIDGED_TOKENS_WRAPPER_WASM="./bridged-tokens-wrapper.wasm"
MULTI_TRANSFER_WASM="./multi-transfer-esdt.wasm"
MULTISIG_WASM="./multisig.wasm"
PROXY_WASM="./bridge-proxy.wasm"
FAUCET_WASM="./faucet.wasm"

#============CONTRACT ADDRESSES==============

Expand All @@ -26,6 +27,8 @@ SAFE=erd1qqqqqqqqqqqqqpgqkhx64czgpc84eftg6q25lrfyv95ndwtcs0vqwusfuh
BRIDGED_TOKENS_WRAPPER=erd1qqqqqqqqqqqqqpgqlgjwk8mpfycxpdf9q2sgzcndtdhdxr5ss0vqgygjmn
MULTI_TRANSFER=erd1qqqqqqqqqqqqqpgqjsh8kss3w67xks7ths5d795q3nz8y52as0vqu0ujzg
MULTISIG=erd1qqqqqqqqqqqqqpgqdcat402y6c62hv07gt04rynjg4668z9fs0vq3qxepp
BRIDGE_PROXY=erd1qqqqqqqqqqqqqpgqk09rka2dslnf9ns5eze2s5xw2hfjxm0jzlsqzyjh28
FAUCET=erd1qqqqqqqqqqqqqpgqhhlx9mpdc92l0psszy3cf9lxhg9vzhs8zlsqjeeqqn

#============TOKENS SETTINGS==============
NR_DECIMALS_CHAIN_SPECIFIC=6
Expand All @@ -36,14 +39,18 @@ UNIVERSAL_TOKEN_DISPLAY_NAME=WrappedUSDC

CHAIN_SPECIFIC_TOKEN_TICKER=ETHUSDC
CHAIN_SPECIFIC_TOKEN_DISPLAY_NAME=EthereumWrappedUSDC
UNIVERSAL_TOKENS_ALREADY_MINTED=0
UNIVERSAL_TOKENS_ALREADY_MINTED=0 # do not add the decimals on this value

#============TOKENS TO BE WHITELISTED==============
UNIVERSAL_TOKEN=
CHAIN_SPECIFIC_TOKEN=MEX-a659d0
ERC20_TOKEN=0x2E8e0BBe20Ecd819c721D164fb91F7c33BDFC756
MINTBURN_WHITELIST=true
NATIVE_TOKEN=true

TOTAL_BALANCE=0
MINT_BALANCE=0
BURN_BALANCE=0
#============BRIDGE SETTINGS==============

FEE_AMOUNT=50 # value without decimals
Expand All @@ -52,21 +59,22 @@ MAX_AMOUNT=100000 # value without decimals
RELAYER_REQUIRED_STAKE=0 #1000eGLD
SLASH_AMOUNT=0
QUORUM=3
ORACLE_REQUIRED_STAKE=1 #1EGLD

MAX_TX_PER_BATCH=70
MAX_TX_BLOCK_DURATION_PER_BATCH=100 #10minutes

#============RELAYERS ADDRESSES==============
RELAYER_ADDR_0=erd1l9hpewk3dd6mz5j0yytjnzqtydukslmsms2d0fn0pg8pc42chqgqk8pm5u
RELAYER_ADDR_1=erd1tfj6fpr5hd5fw8h6efycw42mk3c4wynausntvg6x98kcyn5npkkqmq7t9g
RELAYER_ADDR_2=erd1689ky73s93aptw8ek0wrrzujtus365ygrqgj0hgj4cn09n5k3kuqyhr0j7
RELAYER_ADDR_3=erd1uae36y2qvrslexcv3mwjqy9lwrlspvkdyjsar2xcj5ctrq7th26q8twvyc
RELAYER_ADDR_4=erd1pkwhtl85ze02ckaf0t6qgycgx863kxyefxyqxumcth0nwtu3a9yqzg2yn2
RELAYER_ADDR_5=erd197rmyux8ttzuwssh9thsewlzsc766tvpnussqkpew5vm9x63k0kqw56hr7
RELAYER_ADDR_6=erd1yhqfhsf237uyz4uzzg0duy9hhg8t3j4wtt020c5cy59w2v2jvkgq6nxf0c
RELAYER_ADDR_7=erd1pgvt06tyhlwegkdkzknyhcxfl3wz69wseqeqashm3d83mxjaewzqnug90w
RELAYER_ADDR_8=erd1ujfl0yxff6ey008ef89au4dn486dj549kpjuuu4xxtn9q550x3gqcu6wed
RELAYER_ADDR_9=erd1zsha9cvx7gwraytgp740dcjzwy9v5xwnmas77d33uve6sk0rs0vqel4ln5
RELAYER_ADDR_0=erd1l9hpewk3dd6mz5j0yytjnzqtydukslmsms2d0fn0pg8pc42chqgqk8pm5u
RELAYER_ADDR_1=erd1tfj6fpr5hd5fw8h6efycw42mk3c4wynausntvg6x98kcyn5npkkqmq7t9g
RELAYER_ADDR_2=erd1689ky73s93aptw8ek0wrrzujtus365ygrqgj0hgj4cn09n5k3kuqyhr0j7
RELAYER_ADDR_3=erd1uae36y2qvrslexcv3mwjqy9lwrlspvkdyjsar2xcj5ctrq7th26q8twvyc
RELAYER_ADDR_4=erd1pkwhtl85ze02ckaf0t6qgycgx863kxyefxyqxumcth0nwtu3a9yqzg2yn2
RELAYER_ADDR_5=erd197rmyux8ttzuwssh9thsewlzsc766tvpnussqkpew5vm9x63k0kqw56hr7
RELAYER_ADDR_6=erd1yhqfhsf237uyz4uzzg0duy9hhg8t3j4wtt020c5cy59w2v2jvkgq6nxf0c
RELAYER_ADDR_7=erd1pgvt06tyhlwegkdkzknyhcxfl3wz69wseqeqashm3d83mxjaewzqnug90w
RELAYER_ADDR_8=erd1ujfl0yxff6ey008ef89au4dn486dj549kpjuuu4xxtn9q550x3gqcu6wed
RELAYER_ADDR_9=erd1zsha9cvx7gwraytgp740dcjzwy9v5xwnmas77d33uve6sk0rs0vqel4ln5

RELAYER_WALLET0="./walletsRelay/${RELAYER_ADDR_0}.pem"
RELAYER_WALLET1="./walletsRelay/${RELAYER_ADDR_1}.pem"
Expand All @@ -79,3 +87,11 @@ RELAYER_WALLET7="./walletsRelay/${RELAYER_ADDR_7}.pem"
RELAYER_WALLET8="./walletsRelay/${RELAYER_ADDR_8}.pem"
RELAYER_WALLET9="./walletsRelay/${RELAYER_ADDR_9}.pem"

#============ORACLE ADDRESSES==============
ORACLE_ADDR_0=erd1ek7r87m623y94n8htdjhmhwud6vwhxanwl2xzdfl3kccejhefuqqhwjmv2
ORACLE_ADDR_1=erd1vpz5mpsttd9q5puuaqr7kxfjhwsv2zqqu9jdhyrvkpyfhpnsf5qqhtkkca
ORACLE_ADDR_2=erd10f8xflx9svsje0v2ujggp76jkzyxwpj0rxzgmvx5kle5vqk4f5qqg57m7t

ORACLE_WALLET0="./walletsOracle/${ORACLE_ADDR_0}.pem"
ORACLE_WALLET1="./walletsOracle/${ORACLE_ADDR_1}.pem"
ORACLE_WALLET2="./walletsOracle/${ORACLE_ADDR_2}.pem"
53 changes: 53 additions & 0 deletions multisig/interaction/config/faucet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
deployFaucet() {
CHECK_VARIABLES FAUCET_WASM ALICE

mxpy --verbose contract deploy --bytecode=${FAUCET_WASM} --recall-nonce --pem=${ALICE} \
--gas-limit=20000000 \
--send --outfile=deploy-faucet-testnet.interaction.json --proxy=${PROXY} --chain=${CHAIN_ID} || return

TRANSACTION=$(mxpy data parse --file="./deploy-faucet-testnet.interaction.json" --expression="data['emittedTransactionHash']")
ADDRESS=$(mxpy data parse --file="./deploy-faucet-testnet.interaction.json" --expression="data['contractAddress']")

mxpy data store --key=address-testnet-faucet --value=${ADDRESS}
mxpy data store --key=deployTransaction-testnet --value=${TRANSACTION}

echo ""
echo "Faucet: ${ADDRESS}"
update-config FAUCET ${ADDRESS}
}

setMintRoleForUniversalToken() {
CHECK_VARIABLES ALICE ALICE_ADDRESS

mxpy --verbose contract call ${ESDT_SYSTEM_SC_ADDRESS} --recall-nonce --pem=${ALICE} \
--gas-limit=60000000 --function="setSpecialRole" \
--arguments str:${UNIVERSAL_TOKEN} ${ALICE_ADDRESS} str:ESDTRoleLocalMint \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}

mintAndDeposit() {
CHECK_VARIABLES ALICE ALICE_ADDRESS FAUCET

read -p "Amount to mint (without decimals): " AMOUNT_TO_MINT
VALUE_TO_MINT=$(echo "scale=0; $AMOUNT_TO_MINT*10^$NR_DECIMALS_UNIVERSAL/1" | bc)
mxpy --verbose contract call ${ALICE_ADDRESS} --recall-nonce --pem=${ALICE} \
--gas-limit=300000 --function="ESDTLocalMint" \
--arguments str:${UNIVERSAL_TOKEN} ${VALUE_TO_MINT} \
--send --proxy=${PROXY} --chain=${CHAIN_ID}

sleep 6

mxpy --verbose contract call ${FAUCET} --recall-nonce --pem=${ALICE} \
--gas-limit=5000000 --function="ESDTTransfer" \
--arguments str:${UNIVERSAL_TOKEN} ${VALUE_TO_MINT} str:deposit 100 \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}

unSetMintRoleForUniversalToken() {
CHECK_VARIABLES ALICE ALICE_ADDRESS ESDT_SYSTEM_SC_ADDRESS

mxpy --verbose contract call ${ESDT_SYSTEM_SC_ADDRESS} --recall-nonce --pem=${ALICE} \
--gas-limit=60000000 --function="unSetSpecialRole" \
--arguments str:${UNIVERSAL_TOKEN} ${ALICE_ADDRESS} str:ESDTRoleLocalMint \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}
57 changes: 49 additions & 8 deletions multisig/interaction/config/menu_functions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ source $SCRIPTPATH/config/relayers-snippets.sh
source $SCRIPTPATH/config/upgrade-snippets.sh
source $SCRIPTPATH/config/wrapped-snippets.sh
source $SCRIPTPATH/config/safe-snippets.sh
source $SCRIPTPATH/config/faucet.sh

CHECK_VARIABLES ALICE PROXY CHAIN_ID

Expand All @@ -25,23 +26,45 @@ function upgrade-wrapper-chain-specific-token {
wrapper-updateWhitelistedToken
}

function init-supply-mint-burn {
initSupplyMintBurn
}

function deploy-bridge-contracts {
confirmation-with-skip deployAggregator
confirmation-with-skip stake
confirmation-with-skip manual-update-config-file
confirmation-with-skip stakeOracles

confirmation-with-skip deployBridgedTokensWrapper
manual-update-config-file
confirmation-with-skip deployMultiTransfer
manual-update-config-file
confirmation-with-skip deploySafe
confirmation-with-skip deployMultisig
manual-update-config-file
confirmation-with-skip deployBridgeProxy
confirmation-with-skip setBridgeProxyContractAddress
confirmation-with-skip setBridgedTokensWrapper
manual-update-config-file
confirmation-with-skip deployMultisig
manual-update-config-file

confirmation-with-skip setBridgeProxyContractAddressOnMultiTransfer
confirmation-with-skip setBridgedTokensWrapperOnMultiTransfer

confirmation-with-skip setBridgedTokensWrapperOnSCProxy
confirmation-with-skip setMultiTransferOnSCProxy
confirmation-with-skip setEsdtSafeOnSCProxy

confirmation-with-skip setEsdtSafeOnWrapper
confirmation-with-skip setWrappingContractAddress
confirmation-with-skip setSCProxyOnWrapper

confirmation-with-skip setBridgedTokensWrapperOnEsdtSafe

confirmation-with-skip changeChildContractsOwnershipSafe
confirmation-with-skip changeChildContractsOwnershipMultiTransfer
confirmation-with-skip changeChildContractsOwnershipProxy
confirmation-with-skip setMultiTransferOnEsdtSafe
confirmation-with-skip setEsdtSafeOnMultiTransfer

confirmation-with-skip setEsdtSafeOnMultiTransferThroughMultisig

confirmation-with-skip stakeRelayers
}

function remove-whitelist-token {
Expand Down Expand Up @@ -86,6 +109,7 @@ function whitelist-token {
echo -e
confirmation-with-skip manual-update-config-file

confirmation-with-skip setPairDecimals
confirmation-with-skip submitAggregatorBatch

confirmation-with-skip esdtSafeSetMaxBridgedAmountForToken
Expand All @@ -101,6 +125,7 @@ function whitelist-native-token {
echo -e
confirmation-with-skip manual-update-config-file

confirmation-with-skip setPairDecimals
confirmation-with-skip submitAggregatorBatch

confirmation-with-skip esdtSafeSetMaxBridgedAmountForToken
Expand Down Expand Up @@ -151,4 +176,20 @@ function mint-chain-specific {
update-config UNIVERSAL_TOKENS_ALREADY_MINTED ${AMOUNT_TO_MINT}
confirmation-with-skip transferToSC
confirmation-with-skip unSetMintRole
}
}

function upgrade-aggregator {
aggregator-upgrade
}

function faucet-deposit {
confirmation-with-skip deployFaucet
echo -e
echo "Update UNIVERSAL_TOKEN and NR_DECIMALS_UNIVERSAL in BRIDGE SETTINGS section in configs.cfg"
echo -e
confirmation-with-skip manual-update-config-file

confirmation-with-skip setMintRoleForUniversalToken
confirmation-with-skip mintAndDeposit
confirmation-with-skip unSetMintRoleForUniversalToken
}
31 changes: 27 additions & 4 deletions multisig/interaction/config/multisig-snippets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ addMapping() {
addTokenToWhitelist() {
CHECK_VARIABLES CHAIN_SPECIFIC_TOKEN CHAIN_SPECIFIC_TOKEN_TICKER MULTISIG MINTBURN_WHITELIST NATIVE_TOKEN

BALANCE=$(echo "$TOTAL_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)
MINT=$(echo "$MINT_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)
BURN=$(echo "$BURN_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)

mxpy --verbose contract call ${MULTISIG} --recall-nonce --pem=${ALICE} \
--gas-limit=60000000 --function="esdtSafeAddTokenToWhitelist" \
--arguments str:${CHAIN_SPECIFIC_TOKEN} str:${CHAIN_SPECIFIC_TOKEN_TICKER} ${MINTBURN_WHITELIST} ${NATIVE_TOKEN} \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
${BALANCE} ${MINT} ${BURN} --send --proxy=${PROXY} --chain=${CHAIN_ID}
}

removeTokenFromWhitelist() {
Expand Down Expand Up @@ -190,18 +194,37 @@ multiTransferEsdtSetMaxBridgedAmountForToken() {
}


setMultiTransferOnEsdtSafe() {
setMultiTransferOnEsdtSafeThroughMultisig() {
CHECK_VARIABLES MULTISIG

mxpy --verbose contract call ${MULTISIG} --recall-nonce --pem=${ALICE} \
--gas-limit=60000000 --function="setMultiTransferOnEsdtSafe" \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}

setEsdtSafeOnMultiTransfer() {
setEsdtSafeOnMultiTransferThroughMultisig() {
CHECK_VARIABLES MULTISIG

mxpy --verbose contract call ${MULTISIG} --recall-nonce --pem=${ALICE} \
--gas-limit=60000000 --function="setEsdtSafeOnMultiTransfer" \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}
}

initSupplyMintBurn() {
CHECK_VARIABLES MULTISIG

echo -e
echo "PREREQUIREMENTS: The MINT_BALANCE & BURN_BALANCE values should be defined in configs.cfg file"
echo "The script automatically apply denomination factors based on the number of the decimals the token has"
echo -e

confirmation-with-skip manual-update-config-file

MINT=$(echo "$MINT_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)
BURN=$(echo "$BURN_BALANCE*10^$NR_DECIMALS_CHAIN_SPECIFIC" | bc)

mxpy --verbose contract call ${MULTISIG} --recall-nonce --pem=${ALICE} \
--gas-limit=60000000 --function="initSupplyMintBurnEsdtSafe" \
--arguments str:${CHAIN_SPECIFIC_TOKEN} ${MINT} ${BURN} \
--send --proxy=${PROXY} --chain=${CHAIN_ID}
}
Loading
Loading