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

Additional bridge dev scripts #320

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions eth-bridge/contracts/dev-scripts/common.sh
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 4 additions & 8 deletions eth-bridge/contracts/dev-scripts/eth-to-sub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

12 changes: 12 additions & 0 deletions eth-bridge/contracts/dev-scripts/fake-mint.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 9 additions & 8 deletions eth-bridge/contracts/dev-scripts/setup-contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 6 additions & 7 deletions eth-bridge/contracts/dev-scripts/setup-pallet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion eth-bridge/contracts/dev-scripts/sub-to-eth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions eth-bridge/contracts/dev-scripts/vote-eth.sh
Original file line number Diff line number Diff line change
@@ -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

8 changes: 8 additions & 0 deletions eth-bridge/contracts/dev-scripts/vote-sub.sh
Original file line number Diff line number Diff line change
@@ -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}'