add total gas calculation
Signed-off-by: AlienTornadosaurusHex <>
This commit is contained in:
parent
9726f20e7b
commit
5a883117db
@ -54,9 +54,9 @@ function timeout(seconds) {
|
|||||||
const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would like to continue? (y/n): `
|
const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would like to continue? (y/n): `
|
||||||
|
|
||||||
async function deploy() {
|
async function deploy() {
|
||||||
if (process.env.STAKING_PROXY_ADDRESS === "") throw Error('Missing STAKING_PROXY_ADDRESS.')
|
if (process.env.STAKING_PROXY_ADDRESS === '') throw Error('Missing STAKING_PROXY_ADDRESS.')
|
||||||
|
|
||||||
if (process.env.REGISTRY_IMPL_ADDRESS === "") throw Error('Missing REGISTRY_IMPL_ADDRESS.')
|
if (process.env.REGISTRY_IMPL_ADDRESS === '') throw Error('Missing REGISTRY_IMPL_ADDRESS.')
|
||||||
|
|
||||||
const signer = await ethers.getSigner()
|
const signer = await ethers.getSigner()
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ function timeout(seconds) {
|
|||||||
const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would like to continue? (y/n): `
|
const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would like to continue? (y/n): `
|
||||||
|
|
||||||
async function deploy() {
|
async function deploy() {
|
||||||
if (process.env.STAKING_PROXY_ADDRESS === "") throw Error('Missing STAKING_PROXY_ADDRESS.')
|
if (process.env.STAKING_PROXY_ADDRESS === '') throw Error('Missing STAKING_PROXY_ADDRESS.')
|
||||||
|
|
||||||
const signer = await ethers.getSigner()
|
const signer = await ethers.getSigner()
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
"contracts/*"
|
"contracts/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"deploy:patch": "yarn hardhat --network mainnet run deploy/deployPatch.js",
|
||||||
|
"deploy:staking": "yarn hardhat --network mainnet run deploy/deployStaking.js",
|
||||||
|
"deploy:registry": "yarn hardhat --network mainnet run deploy/deployRegistryImplementation.js",
|
||||||
"eslint": "eslint --ext .js --ignore-path .gitignore .",
|
"eslint": "eslint --ext .js --ignore-path .gitignore .",
|
||||||
"prettier:check": "prettier --check . --config .prettierrc",
|
"prettier:check": "prettier --check . --config .prettierrc",
|
||||||
"prettier:fix": "prettier --write . --config .prettierrc",
|
"prettier:fix": "prettier --write . --config .prettierrc",
|
||||||
|
@ -66,6 +66,8 @@ describe('Gov Exploit Patch Upgrade Tests', () => {
|
|||||||
let registryImplementation
|
let registryImplementation
|
||||||
let staking
|
let staking
|
||||||
|
|
||||||
|
let totalGas = BigNumber.from(0)
|
||||||
|
|
||||||
let exploit = {
|
let exploit = {
|
||||||
hacker: undefined,
|
hacker: undefined,
|
||||||
salt: '00000000006578706c6f6974', // hex "exploit", hacker addrs must be prepended
|
salt: '00000000006578706c6f6974', // hex "exploit", hacker addrs must be prepended
|
||||||
@ -158,8 +160,12 @@ describe('Gov Exploit Patch Upgrade Tests', () => {
|
|||||||
|
|
||||||
staking = await stakingDeployer.deploy(config.governance, config.TORN, config.registry)
|
staking = await stakingDeployer.deploy(config.governance, config.TORN, config.registry)
|
||||||
|
|
||||||
|
totalGas = totalGas.add((await staking.deployTransaction.wait()).cumulativeGasUsed)
|
||||||
|
|
||||||
staking = await proxyDeployer.deploy(staking.address, governance.address, [])
|
staking = await proxyDeployer.deploy(staking.address, governance.address, [])
|
||||||
|
|
||||||
|
totalGas = totalGas.add((await staking.deployTransaction.wait()).cumulativeGasUsed)
|
||||||
|
|
||||||
registryImplementation = await registryDeployer.deploy(
|
registryImplementation = await registryDeployer.deploy(
|
||||||
config.TORN,
|
config.TORN,
|
||||||
config.governance,
|
config.governance,
|
||||||
@ -168,6 +174,8 @@ describe('Gov Exploit Patch Upgrade Tests', () => {
|
|||||||
config.feeManager,
|
config.feeManager,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
totalGas = totalGas.add((await registryImplementation.deployTransaction.wait()).cumulativeGasUsed)
|
||||||
|
|
||||||
exploit.address = await metamorphicFactory.findMetamorphicContractAddress(exploit.salt)
|
exploit.address = await metamorphicFactory.findMetamorphicContractAddress(exploit.salt)
|
||||||
|
|
||||||
// Snapshot
|
// Snapshot
|
||||||
@ -175,6 +183,10 @@ describe('Gov Exploit Patch Upgrade Tests', () => {
|
|||||||
snapshotId = await takeSnapshot()
|
snapshotId = await takeSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
console.log('\n⛽ Total gas used => ', totalGas.toNumber())
|
||||||
|
})
|
||||||
|
|
||||||
describe('Integrative: Patched Governance', () => {
|
describe('Integrative: Patched Governance', () => {
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await revertSnapshot(snapshotId)
|
await revertSnapshot(snapshotId)
|
||||||
@ -192,6 +204,8 @@ describe('Gov Exploit Patch Upgrade Tests', () => {
|
|||||||
|
|
||||||
const proposal = await proposalDeployer.deploy(staking.address, registryImplementation.address)
|
const proposal = await proposalDeployer.deploy(staking.address, registryImplementation.address)
|
||||||
|
|
||||||
|
totalGas = totalGas.add((await proposal.deployTransaction.wait()).cumulativeGasUsed)
|
||||||
|
|
||||||
// Propose
|
// Propose
|
||||||
|
|
||||||
await governance.propose(proposal.address, 'PATCH')
|
await governance.propose(proposal.address, 'PATCH')
|
||||||
@ -216,7 +230,9 @@ describe('Gov Exploit Patch Upgrade Tests', () => {
|
|||||||
|
|
||||||
await ethers.provider.send('evm_mine', [])
|
await ethers.provider.send('evm_mine', [])
|
||||||
|
|
||||||
await governance.execute(proposalId)
|
const response = await governance.execute(proposalId)
|
||||||
|
|
||||||
|
totalGas = totalGas.add((await response.wait()).cumulativeGasUsed)
|
||||||
|
|
||||||
expect(await torn.balanceOf(await governance.Staking())).to.equal(pE('94092'))
|
expect(await torn.balanceOf(await governance.Staking())).to.equal(pE('94092'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user