From cf5187b90cb909cd286428a33f38643b6cba0c84 Mon Sep 17 00:00:00 2001 From: Paul Noel <35237584+panoel@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:59:43 +0000 Subject: [PATCH] tilt: eth speedup (#2214) * ethereum/scripts: add register all script * devnet: update eth startup script * ethereum/scripts - remove unused scripts * ethereum/scripts: add register all script * devnet: update eth startup script * ethereum/scripts - remove unused scripts * devnet: update eth-devnet2 script --- devnet/eth-devnet.yaml | 2 +- devnet/eth-devnet2.yaml | 2 +- ethereum/scripts/register_algo_chain.js | 32 ------ ethereum/scripts/register_all_chains.js | 116 ++++++++++++++++++++++ ethereum/scripts/register_aptos_chain.js | 32 ------ ethereum/scripts/register_bsc_chain.js | 27 ----- ethereum/scripts/register_near_chain.js | 29 ------ ethereum/scripts/register_solana_chain.js | 36 ------- ethereum/scripts/register_terra2_chain.js | 29 ------ ethereum/scripts/register_terra_chain.js | 37 ------- ethereum/scripts/register_worm_chain.js | 26 ----- 11 files changed, 118 insertions(+), 250 deletions(-) delete mode 100644 ethereum/scripts/register_algo_chain.js create mode 100644 ethereum/scripts/register_all_chains.js delete mode 100644 ethereum/scripts/register_aptos_chain.js delete mode 100644 ethereum/scripts/register_bsc_chain.js delete mode 100644 ethereum/scripts/register_near_chain.js delete mode 100644 ethereum/scripts/register_solana_chain.js delete mode 100644 ethereum/scripts/register_terra2_chain.js delete mode 100644 ethereum/scripts/register_terra_chain.js delete mode 100644 ethereum/scripts/register_worm_chain.js diff --git a/devnet/eth-devnet.yaml b/devnet/eth-devnet.yaml index c1aa0ffe6..9485cdf77 100644 --- a/devnet/eth-devnet.yaml +++ b/devnet/eth-devnet.yaml @@ -54,7 +54,7 @@ spec: command: - /bin/sh - -c - - "npm run migrate && npx truffle exec scripts/deploy_test_token.js && npm run deploy-batched-vaa-sender && npx truffle exec scripts/register_solana_chain.js && npx truffle exec scripts/register_terra_chain.js && npx truffle exec scripts/register_terra2_chain.js && npx truffle exec scripts/register_bsc_chain.js && npx truffle exec scripts/register_algo_chain.js && npx truffle exec scripts/register_near_chain.js && npx truffle exec scripts/register_worm_chain.js && npx truffle exec scripts/register_aptos_chain.js && nc -lkp 2000 0.0.0.0" + - "npm run migrate && npx truffle exec scripts/deploy_test_token.js && npm run deploy-batched-vaa-sender && npx truffle exec scripts/register_all_chains.js && nc -lkp 2000 0.0.0.0" readinessProbe: periodSeconds: 1 failureThreshold: 300 diff --git a/devnet/eth-devnet2.yaml b/devnet/eth-devnet2.yaml index 7a3802d98..9c0948cc4 100644 --- a/devnet/eth-devnet2.yaml +++ b/devnet/eth-devnet2.yaml @@ -56,7 +56,7 @@ spec: command: - /bin/sh - -c - - "sed -i 's/CHAIN_ID=0x2/CHAIN_ID=0x4/g;s/EVM_CHAIN_ID=1/EVM_CHAIN_ID=1397/g' .env && npm run migrate && npx truffle exec scripts/deploy_test_token.js && npx truffle exec scripts/register_solana_chain.js && npx truffle exec scripts/register_terra_chain.js && npx truffle exec scripts/register_terra2_chain.js && npx truffle exec scripts/register_eth_chain.js && npx truffle exec scripts/register_algo_chain.js && npx truffle exec scripts/register_near_chain.js && npx truffle exec scripts/register_worm_chain.js && npx truffle exec scripts/register_aptos_chain.js && nc -lkp 2000 0.0.0.0" + - "sed -i 's/CHAIN_ID=0x2/CHAIN_ID=0x4/g;s/EVM_CHAIN_ID=1/EVM_CHAIN_ID=1397/g' .env && npm run migrate && npx truffle exec scripts/deploy_test_token.js && npx truffle exec scripts/register_all_chains.js && nc -lkp 2000 0.0.0.0" readinessProbe: periodSeconds: 1 failureThreshold: 300 diff --git a/ethereum/scripts/register_algo_chain.js b/ethereum/scripts/register_algo_chain.js deleted file mode 100644 index 492434db8..000000000 --- a/ethereum/scripts/register_algo_chain.js +++ /dev/null @@ -1,32 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const TokenImplementation = artifacts.require("TokenImplementation"); -const BridgeImplementationFullABI = jsonfile.readFileSync( - "../build/contracts/BridgeImplementation.json" -).abi; -const algoTokenBridgeVAA = process.env.REGISTER_ALGO_TOKEN_BRIDGE_VAA; - -module.exports = async function(callback) { - try { - const accounts = await web3.eth.getAccounts(); - const initialized = new web3.eth.Contract( - BridgeImplementationFullABI, - TokenBridge.address - ); - - // Register the ALGO endpoint - await initialized.methods - .registerChain("0x" + algoTokenBridgeVAA) - .send({ - value: 0, - from: accounts[0], - gasLimit: 2000000, - }); - - callback(); - } catch (e) { - callback(e); - } -}; diff --git a/ethereum/scripts/register_all_chains.js b/ethereum/scripts/register_all_chains.js new file mode 100644 index 000000000..46844e2dd --- /dev/null +++ b/ethereum/scripts/register_all_chains.js @@ -0,0 +1,116 @@ +// run this script with truffle exec + +const jsonfile = require("jsonfile"); +const TokenBridge = artifacts.require("TokenBridge"); +const NFTBridge = artifacts.require("NFTBridgeEntrypoint"); +const BridgeImplementationFullABI = jsonfile.readFileSync( + "../build/contracts/BridgeImplementation.json" +).abi; +const solTokenBridgeVAA = process.env.REGISTER_SOL_TOKEN_BRIDGE_VAA; +const solNFTBridgeVAA = process.env.REGISTER_SOL_NFT_BRIDGE_VAA; +const terraTokenBridgeVAA = process.env.REGISTER_TERRA_TOKEN_BRIDGE_VAA; +const terraNFTBridgeVAA = process.env.REGISTER_TERRA_NFT_BRIDGE_VAA; +const terra2TokenBridgeVAA = process.env.REGISTER_TERRA2_TOKEN_BRIDGE_VAA; +const bscTokenBridgeVAA = process.env.REGISTER_BSC_TOKEN_BRIDGE_VAA; +const algoTokenBridgeVAA = process.env.REGISTER_ALGO_TOKEN_BRIDGE_VAA; +const nearTokenBridgeVAA = process.env.REGISTER_NEAR_TOKEN_BRIDGE_VAA; +const wormchainTokenBridgeVAA = process.env.REGISTER_WORMCHAIN_TOKEN_BRIDGE_VAA; +const aptosTokenBridgeVAA = process.env.REGISTER_APTOS_TOKEN_BRIDGE_VAA; + +module.exports = async function(callback) { + try { + const accounts = await web3.eth.getAccounts(); + const tokenBridge = new web3.eth.Contract( + BridgeImplementationFullABI, + TokenBridge.address + ); + const nftBridge = new web3.eth.Contract( + BridgeImplementationFullABI, + NFTBridge.address + ); + + // Register the Solana token bridge endpoint + console.log("Registering solana..."); + await tokenBridge.methods.registerChain("0x" + solTokenBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the Solana NFT bridge endpoint + await nftBridge.methods.registerChain("0x" + solNFTBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the terra token bridge endpoint + console.log("Registering Terra..."); + await tokenBridge.methods.registerChain("0x" + terraTokenBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the terra NFT bridge endpoint + await nftBridge.methods.registerChain("0x" + terraNFTBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the terra2 token bridge endpoint + console.log("Registering Terra2..."); + await tokenBridge.methods.registerChain("0x" + terra2TokenBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the BSC endpoint + console.log("Registering BSC..."); + await tokenBridge.methods.registerChain("0x" + bscTokenBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the ALGO endpoint + console.log("Registering Algo..."); + await tokenBridge.methods.registerChain("0x" + algoTokenBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the near token bridge endpoint + console.log("Registering Near..."); + await tokenBridge.methods.registerChain("0x" + nearTokenBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the wormhole token bridge endpoint + console.log("Registering Wormchain..."); + await tokenBridge.methods + .registerChain("0x" + wormchainTokenBridgeVAA) + .send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + // Register the APTOS endpoint + console.log("Registering Aptos..."); + await tokenBridge.methods.registerChain("0x" + aptosTokenBridgeVAA).send({ + value: 0, + from: accounts[0], + gasLimit: 2000000, + }); + + callback(); + } catch (e) { + callback(e); + } +}; diff --git a/ethereum/scripts/register_aptos_chain.js b/ethereum/scripts/register_aptos_chain.js deleted file mode 100644 index 75f64664d..000000000 --- a/ethereum/scripts/register_aptos_chain.js +++ /dev/null @@ -1,32 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const TokenImplementation = artifacts.require("TokenImplementation"); -const BridgeImplementationFullABI = jsonfile.readFileSync( - "../build/contracts/BridgeImplementation.json" -).abi; -const aptosTokenBridgeVAA = process.env.REGISTER_APTOS_TOKEN_BRIDGE_VAA; - -module.exports = async function(callback) { - try { - const accounts = await web3.eth.getAccounts(); - const initialized = new web3.eth.Contract( - BridgeImplementationFullABI, - TokenBridge.address - ); - - // Register the APTOS endpoint - await initialized.methods - .registerChain("0x" + aptosTokenBridgeVAA) - .send({ - value: 0, - from: accounts[0], - gasLimit: 2000000, - }); - - callback(); - } catch (e) { - callback(e); - } -}; diff --git a/ethereum/scripts/register_bsc_chain.js b/ethereum/scripts/register_bsc_chain.js deleted file mode 100644 index 9aee5b4e3..000000000 --- a/ethereum/scripts/register_bsc_chain.js +++ /dev/null @@ -1,27 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const TokenImplementation = artifacts.require("TokenImplementation"); -const BridgeImplementationFullABI = jsonfile.readFileSync("../build/contracts/BridgeImplementation.json").abi -const bscTokenBridgeVAA = process.env.REGISTER_BSC_TOKEN_BRIDGE_VAA - -module.exports = async function (callback) { - try { - const accounts = await web3.eth.getAccounts(); - const initialized = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address); - - // Register the BSC endpoint - await initialized.methods.registerChain("0x" + bscTokenBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000 - }); - - callback(); - } - catch (e) { - callback(e); - } -} - diff --git a/ethereum/scripts/register_near_chain.js b/ethereum/scripts/register_near_chain.js deleted file mode 100644 index 2632253c4..000000000 --- a/ethereum/scripts/register_near_chain.js +++ /dev/null @@ -1,29 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const BridgeImplementationFullABI = jsonfile.readFileSync( - "../build/contracts/BridgeImplementation.json" -).abi; -const nearTokenBridgeVAA = process.env.REGISTER_NEAR_TOKEN_BRIDGE_VAA; - -module.exports = async function (callback) { - try { - const accounts = await web3.eth.getAccounts(); - const tokenBridge = new web3.eth.Contract( - BridgeImplementationFullABI, - TokenBridge.address - ); - - // Register the near token bridge endpoint - await tokenBridge.methods.registerChain("0x" + nearTokenBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000, - }); - - callback(); - } catch (e) { - callback(e); - } -}; diff --git a/ethereum/scripts/register_solana_chain.js b/ethereum/scripts/register_solana_chain.js deleted file mode 100644 index 6314f1ca1..000000000 --- a/ethereum/scripts/register_solana_chain.js +++ /dev/null @@ -1,36 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const NFTBridge = artifacts.require("NFTBridgeEntrypoint"); -const TokenImplementation = artifacts.require("TokenImplementation"); -const BridgeImplementationFullABI = jsonfile.readFileSync("../build/contracts/BridgeImplementation.json").abi -const solTokenBridgeVAA = process.env.REGISTER_SOL_TOKEN_BRIDGE_VAA -const solNFTBridgeVAA = process.env.REGISTER_SOL_NFT_BRIDGE_VAA - -module.exports = async function (callback) { - try { - const accounts = await web3.eth.getAccounts(); - const tokenBridge = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address); - const nftBridge = new web3.eth.Contract(BridgeImplementationFullABI, NFTBridge.address); - - // Register the Solana token bridge endpoint - await tokenBridge.methods.registerChain("0x" + solTokenBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000 - }); - - // Register the Solana NFT bridge endpoint - await nftBridge.methods.registerChain("0x" + solNFTBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000 - }); - - callback(); - } - catch (e) { - callback(e); - } -} diff --git a/ethereum/scripts/register_terra2_chain.js b/ethereum/scripts/register_terra2_chain.js deleted file mode 100644 index d3db9312a..000000000 --- a/ethereum/scripts/register_terra2_chain.js +++ /dev/null @@ -1,29 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const BridgeImplementationFullABI = jsonfile.readFileSync( - "../build/contracts/BridgeImplementation.json" -).abi; -const terra2TokenBridgeVAA = process.env.REGISTER_TERRA2_TOKEN_BRIDGE_VAA; - -module.exports = async function (callback) { - try { - const accounts = await web3.eth.getAccounts(); - const tokenBridge = new web3.eth.Contract( - BridgeImplementationFullABI, - TokenBridge.address - ); - - // Register the terra2 token bridge endpoint - await tokenBridge.methods.registerChain("0x" + terra2TokenBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000, - }); - - callback(); - } catch (e) { - callback(e); - } -}; diff --git a/ethereum/scripts/register_terra_chain.js b/ethereum/scripts/register_terra_chain.js deleted file mode 100644 index eea8bca76..000000000 --- a/ethereum/scripts/register_terra_chain.js +++ /dev/null @@ -1,37 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const NFTBridge = artifacts.require("NFTBridgeEntrypoint"); -const TokenImplementation = artifacts.require("TokenImplementation"); -const BridgeImplementationFullABI = jsonfile.readFileSync("../build/contracts/BridgeImplementation.json").abi -const terraTokenBridgeVAA = process.env.REGISTER_TERRA_TOKEN_BRIDGE_VAA -const terraNFTBridgeVAA = process.env.REGISTER_TERRA_NFT_BRIDGE_VAA - -module.exports = async function (callback) { - try { - const accounts = await web3.eth.getAccounts(); - const tokenBridge = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address); - const nftBridge = new web3.eth.Contract(BridgeImplementationFullABI, NFTBridge.address); - - // Register the terra token bridge endpoint - await tokenBridge.methods.registerChain("0x" + terraTokenBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000 - }); - - // Register the terra NFT bridge endpoint - await nftBridge.methods.registerChain("0x" + terraNFTBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000 - }); - - callback(); - } - catch (e) { - callback(e); - } -} - diff --git a/ethereum/scripts/register_worm_chain.js b/ethereum/scripts/register_worm_chain.js deleted file mode 100644 index 27ff820f9..000000000 --- a/ethereum/scripts/register_worm_chain.js +++ /dev/null @@ -1,26 +0,0 @@ -// run this script with truffle exec - -const jsonfile = require("jsonfile"); -const TokenBridge = artifacts.require("TokenBridge"); -const TokenImplementation = artifacts.require("TokenImplementation"); -const BridgeImplementationFullABI = jsonfile.readFileSync("../build/contracts/BridgeImplementation.json").abi; -const wormchainTokenBridgeVAA = process.env.REGISTER_WORMCHAIN_TOKEN_BRIDGE_VAA - -module.exports = async function (callback) { - try { - const accounts = await web3.eth.getAccounts(); - const tokenBridge = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address - ); - - // Register the wormhole token bridge endpoint - await tokenBridge.methods.registerChain("0x" + wormchainTokenBridgeVAA).send({ - value: 0, - from: accounts[0], - gasLimit: 2000000 - }); - - callback(); - } catch (e) { - callback(e); - } -};