Skip to content

Commit

Permalink
spell pt 2 validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrent committed Jun 23, 2024
1 parent aaae971 commit de7b0fe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
43 changes: 28 additions & 15 deletions tasks/validation/proposal-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from './utils/governance'
import { advanceTime, getLatestBlockNumber } from '#/utils/time'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { resetFork } from '#/utils/chain'
import fs from 'fs'
import { BigNumber } from 'ethers'
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
Expand All @@ -30,7 +29,7 @@ import { RTokenP1 } from '@typechain/RTokenP1'
import { StRSRP1Votes } from '@typechain/StRSRP1Votes'
import { IMain } from '@typechain/IMain'
import { Whales, getWhalesFile } from '#/scripts/whalesConfig'
import { proposal_3_4_0_step_1, proposal_3_4_0_step_2 } from './proposals/3_4_0'
import { proposal_3_4_0_step_2 } from './proposals/3_4_0'
import { validateSubgraphURL, Network } from '#/utils/fork'

interface Params {
Expand Down Expand Up @@ -362,19 +361,31 @@ const runCheck_mint = async (
console.log('Successfully minted RTokens')
}

task('print-proposal')
task('save-proposal-pt-2')
.addParam('rtoken', 'the address of the RToken being upgraded')
.addParam('gov', 'the address of the OWNER of the RToken being upgraded')
.addParam('time', 'the address of the timelock')
.setAction(async (params, hre) => {
const proposal = await proposal_3_4_0_step_2(hre, params.rtoken, params.gov, params.time)
const chainId = await getChainId(hre)

console.log(`\nGenerating and proposing proposal...`)
const [tester] = await hre.ethers.getSigners()
// make sure config exists
if (!networkConfig[chainId]) {
throw new Error(`Missing network configuration for ${hre.network.name}`)
}

await hre.run('give-rsr', { address: tester.address })
await stakeAndDelegateRsr(hre, params.rtoken, tester.address)
const spellAddr =
chainId == '1'
? '0xb1df3a104d73ff86f9aaab60b491a5c44b090391'
: '0x1744c9933feb8e76563fce63d5c95a4e7f967c2a'
const proposal = await proposal_3_4_0_step_2(
hre,
params.rtoken,
params.gov,
params.time,
spellAddr
)

console.log(`\nGenerating and hashing proposal...`)
const governor = await hre.ethers.getContractAt('Governance', params.gov)

const call = await governor.populateTransaction.propose(
Expand All @@ -386,21 +397,23 @@ task('print-proposal')

console.log(`Proposal Transaction:\n`, call.data)

const r = await governor.propose(
const proposalId = await governor.hashProposal(
proposal.targets,
proposal.values,
proposal.calldatas,
proposal.description
hre.ethers.utils.keccak256(hre.ethers.utils.toUtf8Bytes(proposal.description))
)
const resp = await r.wait()

console.log('\nSuccessfully proposed!')
console.log(`Proposal ID: ${resp.events![0].args!.proposalId}`)

proposal.proposalId = resp.events![0].args!.proposalId.toString()
console.log(`Proposal ID: ${proposalId}`)
proposal.proposalId = proposalId.toString()
proposal.governor = params.gov
proposal.timelock = params.time
proposal.rtoken = params.rtoken

fs.writeFileSync(
`./tasks/validation/proposals/proposal-${proposal.proposalId}.json`,
JSON.stringify(proposal, null, 2)
)

console.log("Saved to proposals folder. Don't forget to run `proposal-validator`!")
})
3 changes: 1 addition & 2 deletions tasks/validation/utils/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ export const proposeUpgrade = async (

console.log(`Proposal Transaction:\n`, call.data)

await validatePropState(await governor.state(proposalId), ProposalState.Active)

const r = await governor.propose(
proposal.targets,
proposal.values,
Expand All @@ -302,6 +300,7 @@ export const proposeUpgrade = async (
const resp = await r.wait()
proposalId = bn(resp.events![0].args!.proposalId)

await validatePropState(await governor.state(proposalId), ProposalState.Pending)
console.log('\nSuccessfully proposed!')
} else {
console.log('\nAlready proposed!')
Expand Down

0 comments on commit de7b0fe

Please sign in to comment.