From add90bec708bf1676fb2b98ecfb6619318ac9a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20=C5=BBuk?= Date: Tue, 19 Sep 2023 10:28:25 +0200 Subject: [PATCH] Additional bridge dev scripts --- eth-bridge/contracts/dev-scripts/common.sh | 9 +++++++++ eth-bridge/contracts/dev-scripts/eth-to-sub.sh | 12 ++++-------- eth-bridge/contracts/dev-scripts/fake-mint.sh | 12 ++++++++++++ .../contracts/dev-scripts/setup-contracts.sh | 17 +++++++++-------- .../contracts/dev-scripts/setup-pallet.sh | 13 ++++++------- eth-bridge/contracts/dev-scripts/sub-to-eth.sh | 5 ++++- eth-bridge/contracts/dev-scripts/vote-eth.sh | 9 +++++++++ eth-bridge/contracts/dev-scripts/vote-sub.sh | 8 ++++++++ 8 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 eth-bridge/contracts/dev-scripts/common.sh create mode 100755 eth-bridge/contracts/dev-scripts/fake-mint.sh create mode 100755 eth-bridge/contracts/dev-scripts/vote-eth.sh create mode 100755 eth-bridge/contracts/dev-scripts/vote-sub.sh diff --git a/eth-bridge/contracts/dev-scripts/common.sh b/eth-bridge/contracts/dev-scripts/common.sh new file mode 100644 index 000000000..a5a39c3fa --- /dev/null +++ b/eth-bridge/contracts/dev-scripts/common.sh @@ -0,0 +1,9 @@ +WALLET_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" +WALLET_ADDRESS="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" +LLD_TOKEN="0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" +LLD_BRIDGE="0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9" +LLM_TOKEN="0x0165878A594ca255338adfa4d48449f69242Eb8F" +LLM_BRIDGE="0xa513E6E4b8f2a923D98304ec87F64353C4D5C853" + +CAST_LLM_BRIDGE="cast send $LLM_BRIDGE --private-key=$WALLET_KEY" +API_ALICE="polkadot-js-api --seed //Alice" diff --git a/eth-bridge/contracts/dev-scripts/eth-to-sub.sh b/eth-bridge/contracts/dev-scripts/eth-to-sub.sh index 97ea2aa56..6f7e0d6d6 100755 --- a/eth-bridge/contracts/dev-scripts/eth-to-sub.sh +++ b/eth-bridge/contracts/dev-scripts/eth-to-sub.sh @@ -2,15 +2,11 @@ set -exuo pipefail -# fake mint some tokens -cast rpc anvil_impersonateAccount 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 -cast rpc anvil_setBalance 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 9999999999999999999 -cast send 0xdc64a140aa3e981100a9beca4e685f962f0cf6c9 --unlocked --from=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 'mint(address,uint256)' 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 9999999999999 -cast rpc anvil_stopImpersonatingAccount 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 +cd "$(dirname "$0")" +. common.sh -# approve bridge -cast send 0xdc64a140aa3e981100a9beca4e685f962f0cf6c9 --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 'approve(address,uint256)' 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 9999999999999 +. fake-mint.sh # burn tokens -cast send 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 'burn(uint256,bytes32)' 10 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d +$CAST_LLM_BRIDGE 'burn(uint256,bytes32)' 10000000000000 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d diff --git a/eth-bridge/contracts/dev-scripts/fake-mint.sh b/eth-bridge/contracts/dev-scripts/fake-mint.sh new file mode 100755 index 000000000..518df230d --- /dev/null +++ b/eth-bridge/contracts/dev-scripts/fake-mint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -exuo pipefail + +cd "$(dirname "$0")" +. common.sh + +# fake mint some tokens +cast rpc anvil_impersonateAccount $LLM_BRIDGE +cast rpc anvil_setBalance $LLM_BRIDGE 9999999999999999999 +cast send $LLM_TOKEN --unlocked --from=$LLM_BRIDGE 'mint(address,uint256)' $WALLET_ADDRESS 9999999999999 +cast rpc anvil_stopImpersonatingAccount $LLM_BRIDGE diff --git a/eth-bridge/contracts/dev-scripts/setup-contracts.sh b/eth-bridge/contracts/dev-scripts/setup-contracts.sh index 6ec4a772c..a7843b594 100755 --- a/eth-bridge/contracts/dev-scripts/setup-contracts.sh +++ b/eth-bridge/contracts/dev-scripts/setup-contracts.sh @@ -2,29 +2,30 @@ set -exuo pipefail -llm_bridge="cast send --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707" +cd "$(dirname "$0")" +. common.sh cd "$(dirname "$0")/.." -forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast +forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --private-key=$WALLET_KEY --broadcast # grant admin role -$llm_bridge 'grantRole(bytes32,address)' 0xa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 +$CAST_LLM_BRIDGE 'grantRole(bytes32,address)' 0xa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775 $WALLET_ADDRESS # grant relay role -$llm_bridge 'grantRole(bytes32,address)' 0x077a1d526a4ce8a773632ab13b4fbbf1fcc954c3dab26cd27ea0e2a6750da5d7 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 +$CAST_LLM_BRIDGE 'grantRole(bytes32,address)' 0x077a1d526a4ce8a773632ab13b4fbbf1fcc954c3dab26cd27ea0e2a6750da5d7 $WALLET_ADDRESS # grant watcher role -$llm_bridge 'grantRole(bytes32,address)' 0x2125d1e225cadc5c8296e2cc1f96ee607770bf4a4a16131e62f6819937437c89 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 +$CAST_LLM_BRIDGE 'grantRole(bytes32,address)' 0x2125d1e225cadc5c8296e2cc1f96ee607770bf4a4a16131e62f6819937437c89 $WALLET_ADDRESS # 1 vote required -$llm_bridge 'setVotesRequired(uint32)' 1 +$CAST_LLM_BRIDGE 'setVotesRequired(uint32)' 1 # no mint delay -$llm_bridge 'setMintDelay(uint256)' 0 +$CAST_LLM_BRIDGE 'setMintDelay(uint256)' 0 # start bridge -$llm_bridge 'setActive(bool)' 1 +$CAST_LLM_BRIDGE 'setActive(bool)' 1 # make sure we get some blocks often cast rpc evm_setIntervalMining 2 diff --git a/eth-bridge/contracts/dev-scripts/setup-pallet.sh b/eth-bridge/contracts/dev-scripts/setup-pallet.sh index 3bc158075..70b808a5f 100755 --- a/eth-bridge/contracts/dev-scripts/setup-pallet.sh +++ b/eth-bridge/contracts/dev-scripts/setup-pallet.sh @@ -2,16 +2,15 @@ set -exuo pipefail -alice_api="polkadot-js-api --seed //Alice" - -cd "$(dirname "$0")/.." +cd "$(dirname "$0")" +. common.sh # make Bob a relay and watcher -polkadot-js-api --seed "//Alice" tx.ethLLMBridge.addRelay 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty -polkadot-js-api --seed "//Alice" tx.ethLLMBridge.addWatcher 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty +$API_ALICE tx.ethLLMBridge.addRelay 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty +$API_ALICE tx.ethLLMBridge.addWatcher 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # votes required = 1 -polkadot-js-api --seed "//Alice" tx.ethLLMBridge.setVotesRequired 1 +$API_ALICE tx.ethLLMBridge.setVotesRequired 1 # start bridge -polkadot-js-api --seed "//Alice" tx.ethLLMBridge.setState Active +$API_ALICE tx.ethLLMBridge.setState Active diff --git a/eth-bridge/contracts/dev-scripts/sub-to-eth.sh b/eth-bridge/contracts/dev-scripts/sub-to-eth.sh index 3d3f10bc3..655cbff91 100755 --- a/eth-bridge/contracts/dev-scripts/sub-to-eth.sh +++ b/eth-bridge/contracts/dev-scripts/sub-to-eth.sh @@ -2,4 +2,7 @@ set -exuo pipefail -polkadot-js-api --seed "//Alice" tx.ethLLMBridge.deposit 1000000000000 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 +cd "$(dirname "$0")" +. common.sh + +$API_ALICE tx.ethLLMBridge.deposit 10000000000000 $WALLET_ADDRESS diff --git a/eth-bridge/contracts/dev-scripts/vote-eth.sh b/eth-bridge/contracts/dev-scripts/vote-eth.sh new file mode 100755 index 000000000..7d8cac9b4 --- /dev/null +++ b/eth-bridge/contracts/dev-scripts/vote-eth.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -exuo pipefail + +cd "$(dirname "$0")" +. common.sh + +$CAST_LLM_BRIDGE 'voteMint(bytes32,uint64,uint256,address)' $1 1 1000000000000 $WALLET_ADDRESS + diff --git a/eth-bridge/contracts/dev-scripts/vote-sub.sh b/eth-bridge/contracts/dev-scripts/vote-sub.sh new file mode 100755 index 000000000..ab72885cc --- /dev/null +++ b/eth-bridge/contracts/dev-scripts/vote-sub.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -exuo pipefail + +cd "$(dirname "$0")" +. common.sh + +polkadot-js-api --seed "//Bob" tx.ethLLMBridge.voteWithdraw $1 '{"eth_block_number": 1, "substrate_recipient": "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d", "amount": 10}'