From 9726f20e7b044465ba5a6d7bf7e40477a590402b Mon Sep 17 00:00:00 2001 From: AlienTornadosaurusHex <> Date: Sat, 27 May 2023 16:54:38 +0000 Subject: [PATCH] test deploy scripts Signed-off-by: AlienTornadosaurusHex <> --- deploy/deployPatch.js | 36 +++++++++++++---- deploy/deployRegistryImplementation.js | 32 ++++++++++++--- deploy/deployStaking.js | 42 +++++++++++++++----- hardhat.config.js | 7 +++- package.json | 1 + yarn.lock | 54 +++++++++++++++++++++++++- 6 files changed, 148 insertions(+), 24 deletions(-) diff --git a/deploy/deployPatch.js b/deploy/deployPatch.js index f73c51c..57cb2e6 100644 --- a/deploy/deployPatch.js +++ b/deploy/deployPatch.js @@ -8,13 +8,30 @@ const { createInterface } = require('readline') const prompter = createInterface({ input: process.stdin, output: process.stdout }) +function idToNetwork(id) { + switch (id) { + case 1: + return 'Mainnet' + case 3: + return 'Ropsten' + case 4: + return 'Rinkeby' + case 5: + return 'Goerli' + case 11155111: + return 'Sepolia' + default: + throw Error('\nChain Id could not be recognized. What network are you using?\n') + } +} + function _prompt(prompt, resolve) { prompter.question(prompt, (answer) => { if (answer == 'y') { resolve(true) - } else if (answer == 'n') { + } else { resolve(false) - } else _prompt('', resolve) + } }) } @@ -37,11 +54,13 @@ function timeout(seconds) { const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would like to continue? (y/n): ` async function deploy() { + if (process.env.STAKING_PROXY_ADDRESS === "") throw Error('Missing STAKING_PROXY_ADDRESS.') + + if (process.env.REGISTRY_IMPL_ADDRESS === "") throw Error('Missing REGISTRY_IMPL_ADDRESS.') + const signer = await ethers.getSigner() - if (process.env.STAKING_PROXY_ADDRESS === undefined) throw Error('Missing STAKING_PROXY_ADDRESS.') - - if (process.env.REGISTRY_IMPL_ADDRESS === undefined) throw Error('Missing REGISTRY_IMPL_ADDRESS.') + const _network = await ethers.provider.getNetwork() const stakingProxyAddress = `${process.env.STAKING_PROXY_ADDRESS}` @@ -53,18 +72,21 @@ async function deploy() { if (await prompt(promptMessageBase('Continuing to PatchProposal deployment.'))) { patchProposal = await patchProposalDeployer.deploy(stakingProxyAddress, registryImplementationAddress) - console.log(deployedMessage('PatchProposal', 1, patchProposal.address)) + console.log(deployedMessage('PatchProposal', _network.chainId, patchProposal.address)) } else { return '\nDecided to stop at PatchProposal deployment.\n' } if (await prompt(promptMessageBase('Continuing to contract verification.'))) { + console.log('\nWaiting 20 seconds.\n') + await timeout(20) + await hre.run('verify:verify', { address: patchProposal.address, constructorArguments: [stakingProxyAddress, registryImplementationAddress], }) - console.log(verifiedMessage('PatchProposal')) + console.log(verifiedMessage('PatchProposal', patchProposal.address)) } else { return '\nDecided to stop at contract verification.\n' } diff --git a/deploy/deployRegistryImplementation.js b/deploy/deployRegistryImplementation.js index d52d5e5..e41b7bc 100644 --- a/deploy/deployRegistryImplementation.js +++ b/deploy/deployRegistryImplementation.js @@ -10,13 +10,30 @@ const { createInterface } = require('readline') const prompter = createInterface({ input: process.stdin, output: process.stdout }) +function idToNetwork(id) { + switch (id) { + case 1: + return 'Mainnet' + case 3: + return 'Ropsten' + case 4: + return 'Rinkeby' + case 5: + return 'Goerli' + case 11155111: + return 'Sepolia' + default: + throw Error('\nChain Id could not be recognized. What network are you using?\n') + } +} + function _prompt(prompt, resolve) { prompter.question(prompt, (answer) => { if (answer == 'y') { resolve(true) - } else if (answer == 'n') { + } else { resolve(false) - } else _prompt('', resolve) + } }) } @@ -39,9 +56,11 @@ function timeout(seconds) { const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would like to continue? (y/n): ` async function deploy() { + if (process.env.STAKING_PROXY_ADDRESS === "") throw Error('Missing STAKING_PROXY_ADDRESS.') + const signer = await ethers.getSigner() - if (process.env.STAKING_PROXY_ADDRESS === undefined) throw Error('Missing STAKING_PROXY_ADDRESS.') + const _network = await ethers.provider.getNetwork() const stakingProxyAddress = `${process.env.STAKING_PROXY_ADDRESS}` @@ -57,12 +76,15 @@ async function deploy() { stakingProxyAddress, config.feeManager, ) - console.log(deployedMessage('RelayerRegistry (Implementation)', 1, registry.address)) + console.log(deployedMessage('RelayerRegistry (Implementation)', _network.chainId, registry.address)) } else { return '\nDecided to stop at RelayerRegistry (Implementation) deployment.\n' } if (await prompt(promptMessageBase('Continuing to contract verification.'))) { + console.log('\nWaiting 20 seconds.\n') + await timeout(20) + await hre.run('verify:verify', { address: registry.address, constructorArguments: [ @@ -73,7 +95,7 @@ async function deploy() { config.feeManager, ], }) - console.log(verifiedMessage('RelayerRegistry (Implementation)')) + console.log(verifiedMessage('RelayerRegistry (Implementation)', registry.address)) } else { return '\nDecided to stop at contract verification.\n' } diff --git a/deploy/deployStaking.js b/deploy/deployStaking.js index 7c409c2..3819542 100644 --- a/deploy/deployStaking.js +++ b/deploy/deployStaking.js @@ -10,13 +10,30 @@ const { createInterface } = require('readline') const prompter = createInterface({ input: process.stdin, output: process.stdout }) +function idToNetwork(id) { + switch (id) { + case 1: + return 'Mainnet' + case 3: + return 'Ropsten' + case 4: + return 'Rinkeby' + case 5: + return 'Goerli' + case 11155111: + return 'Sepolia' + default: + throw Error('\nChain Id could not be recognized. What network are you using?\n') + } +} + function _prompt(prompt, resolve) { prompter.question(prompt, (answer) => { if (answer == 'y') { resolve(true) - } else if (answer == 'n') { + } else { resolve(false) - } else _prompt('', resolve) + } }) } @@ -41,6 +58,8 @@ const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would lik async function deploy() { const signer = await ethers.getSigner() + const _network = await ethers.provider.getNetwork() + const stakingDeployer = (await ethers.getContractFactory('TornadoStakingRewards')).connect(signer) const proxyDeployer = (await ethers.getContractFactory('AdminUpgradeableProxy')).connect(signer) @@ -48,34 +67,37 @@ async function deploy() { if (await prompt(promptMessageBase('Continuing to TornadoStakingRewards (Implementation) deployment.'))) { impl = await stakingDeployer.deploy(config.governance, config.TORN, config.registry) - console.log(deployedMessage('TornadoStakingRewards (Implementation)', 1, impl.address)) + console.log(deployedMessage('TornadoStakingRewards (Implementation)', _network.chainId, impl.address)) } else { return '\nDecided to stop at TornadoStakingRewards (Implementation) deployment.\n' } if (await prompt(promptMessageBase('Continuing to Staking Proxy deployment.'))) { - proxy = await proxyDeployer.deploy(impl.address, governance.address, []) - console.log(deployedMessage('Staking Proxy', 1, proxy.address)) + proxy = await proxyDeployer.deploy(impl.address, config.governance, []) + console.log(deployedMessage('Staking Proxy', _network.chainId, proxy.address)) } else { return '\nDecided to stop at Staking Proxy deployment.\n' } if (await prompt(promptMessageBase('Continuing to contract verification.'))) { + console.log('\nWaiting 20 seconds.\n') + await timeout(20) + await hre.run('verify:verify', { address: impl.address, constructorArguments: [config.governance, config.TORN, config.registry], }) - console.log(verifiedMessage('TornadoStakingRewards (Implementation)')) - console.log('\nWaiting 5 seconds.\n') - await timeout(5) + console.log(verifiedMessage('TornadoStakingRewards (Implementation)', impl.address)) + console.log('\nWaiting 20 seconds.\n') + await timeout(20) await hre.run('verify:verify', { address: proxy.address, - constructorArguments: [impl.address, governance.address, []], + constructorArguments: [impl.address, config.governance, []], }) - console.log(verifiedMessage('Staking Proxy')) + console.log(verifiedMessage('Staking Proxy', proxy.address)) } else { return '\nDecided to stop at contract verification.\n' } diff --git a/hardhat.config.js b/hardhat.config.js index 8ece551..f87defb 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -1,6 +1,6 @@ require('dotenv').config() +require('@nomicfoundation/hardhat-verify') require('@nomiclabs/hardhat-ethers') -require('@nomiclabs/hardhat-etherscan') require('@nomiclabs/hardhat-waffle') require('hardhat-spdx-license-identifier') require('hardhat-storage-layout') @@ -57,6 +57,11 @@ module.exports = { url: 'http://localhost:8545', timeout: 120000, }, + goerli: { + url: `${process.env.RPC_URL}`, + accounts: process.env.PRIVATE_KEY ? [`${process.env.PRIVATE_KEY}`] : undefined, + timeout: 9999999, + }, mainnet: { url: `${process.env.RPC_URL}`, accounts: process.env.PRIVATE_KEY ? [`${process.env.PRIVATE_KEY}`] : undefined, diff --git a/package.json b/package.json index 2d60182..902eb3e 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "devDependencies": { "@ethersproject/testcases": "^5.5.0", + "@nomicfoundation/hardhat-verify": "^1.0.0", "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-etherscan": "^2.1.6", "@nomiclabs/hardhat-waffle": "^2.0.1", diff --git a/yarn.lock b/yarn.lock index ae7b18f..fc465e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1069,6 +1069,21 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@nomicfoundation/hardhat-verify@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-verify/-/hardhat-verify-1.0.0.tgz#f18be34f5e7fdb2ffd4f55e8516108568b99da5c" + integrity sha512-R3UM/w2+e4D9PZRaeJHbC0caHSu/FV3ykAFBFg+RPNsfSzNgtHeRJXS+V+2HnVJYPaucBUD0v/6qtU8BZAouoQ== + dependencies: + "@ethersproject/abi" "^5.1.2" + "@ethersproject/address" "^5.0.2" + cbor "^8.1.0" + chalk "^2.4.2" + debug "^4.1.1" + lodash.clonedeep "^4.5.0" + semver "^6.3.0" + table "^6.8.0" + undici "^5.14.0" + "@nomiclabs/hardhat-ethers@^2.0.2": version "2.0.2" resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.0.2.tgz#c472abcba0c5185aaa4ad4070146e95213c68511" @@ -2772,6 +2787,13 @@ bufferutil@^4.0.1: dependencies: node-gyp-build "^4.3.0" +busboy@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" + integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA== + dependencies: + streamsearch "^1.1.0" + bytes@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" @@ -2881,6 +2903,13 @@ cbor@^8.0.0: dependencies: nofilter "^3.0.3" +cbor@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-8.1.0.tgz#cfc56437e770b73417a2ecbfc9caf6b771af60d5" + integrity sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg== + dependencies: + nofilter "^3.1.0" + chai@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" @@ -7071,7 +7100,7 @@ nofilter@^1.0.4: resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-1.0.4.tgz#78d6f4b6a613e7ced8b015cec534625f7667006e" integrity sha512-N8lidFp+fCz+TD51+haYdbDGrcBWwuHX40F5+z0qkUjMJ5Tp+rdSuAkMJ9N9eoolDlEVTf6u5icM+cNKkKW2mA== -nofilter@^3.0.3: +nofilter@^3.0.3, nofilter@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-3.1.0.tgz#c757ba68801d41ff930ba2ec55bab52ca184aa66" integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g== @@ -8711,6 +8740,11 @@ stream-to-pull-stream@^1.7.1: looper "^3.0.0" pull-stream "^3.2.3" +streamsearch@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" + integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== + strict-uri-encode@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" @@ -8914,6 +8948,17 @@ table@^6.0.9: string-width "^4.2.3" strip-ansi "^6.0.1" +table@^6.8.0: + version "6.8.1" + resolved "https://registry.yarnpkg.com/table/-/table-6.8.1.tgz#ea2b71359fe03b017a5fbc296204471158080bdf" + integrity sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA== + dependencies: + ajv "^8.0.1" + lodash.truncate "^4.4.2" + slice-ansi "^4.0.0" + string-width "^4.2.3" + strip-ansi "^6.0.1" + tape@^4.6.3: version "4.14.0" resolved "https://registry.yarnpkg.com/tape/-/tape-4.14.0.tgz#e4d46097e129817175b90925f2385f6b1bcfa826" @@ -9283,6 +9328,13 @@ underscore@1.9.1: resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961" integrity sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg== +undici@^5.14.0: + version "5.22.1" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.22.1.tgz#877d512effef2ac8be65e695f3586922e1a57d7b" + integrity sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw== + dependencies: + busboy "^1.6.0" + union-value@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"