hyperledger-labs / blockchain-carbon-accounting

This project implements blockchain applications for climate action and accounting, including emissions calculations, carbon trading, and validation of climate claims. It is part of the Linux Foundation's Hyperledger Climate Action and Accounting SIG.
https://wiki.hyperledger.org/display/CASIG/Carbon+Accounting+and+Certification+WG
Apache License 2.0
188 stars 104 forks source link

add new hardhat task for complete admin switch #155

Closed sichen1234 closed 3 years ago

sichen1234 commented 3 years ago

Add new hardhat task to complete admin switch of the DAO

jamesondh commented 3 years ago

See new documentation on running the completeTimelockAdminSwitch task after deployment under the "Deploying contracts to a public testnet" and "Deploying to xDai" sections: https://github.com/opentaps/blockchain-carbon-accounting/blob/main/net-emissions-token-network/docs/using-the-contracts.md#deploying-contracts-to-a-public-testnet and commit https://github.com/opentaps/blockchain-carbon-accounting/commit/8f757b98ddd7bc31a2162bf1d0150805527d0210

sichen1234 commented 3 years ago

Can you pls explain what all the parameters mean: npx hardhat completeTimelockAdminSwitch --network goerli --timelock 0xE13Ec0c623e67486267B54dd28E172A94f72B527 --governor 0x7c385742B2332b65D536396bdcb10EE7Db821eA9 --target 0xE13Ec0c623e67486267B54dd28E172A94f72B527 --value 0 --signature "setPendingAdmin(address)" --data 0x0000000000000000000000007c385742b2332b65d536396bdcb10ee7db821ea9 --eta 1619623658

For example, after I've updated my Governor and Timelock locally, I got $ npx hardhat deploy --network localhost Nothing to compile Deploying DAOToken with account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 reusing "DAOToken" at 0x5FbDB2315678afecb367f032d93F642f64180aa3 DAO Token deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3 Delegated voting power of deployer to self. Deploying DAO with account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Timelock deployed to: 0x4A679253410272dd5232B3Ff7cF5dbB88f295319 Governor deployed to: 0x7a2088a1bFc9d81c55368AE168C2C02570cB814F Initialized Governor address on DAOToken. Queued setPendingAdmin() on Timelock. Advanced 51 hours. Executed setPendingAdmin() on Timelock. Called __acceptAdmin() on Governor. Done performing Timelock admin switch. Deploying NetEmissionsTokenNetwork with account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 reusing "DefaultProxyAdmin" at 0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6 reusing "NetEmissionsTokenNetwork_Implementation" at 0x8A791620dd6260079BF849Dc5567aDC3F2FdC318 NetEmissionsTokenNetwork deployed to: 0x610178dA211FEF7D417bC0e6FeD39F05609AD788 Timelock address set so that the DAO has permission to issue tokens with issueOnBehalf().

How would I switch the Timelock admin after this upgrade?

jamesondh commented 3 years ago

Since you are upgrading Governor/Timelock on localhost, it performs the Timelock switch automatically. When you perform it on a live testnet/mainnet, it will output the npx hardhat completeTimelockAdminSwitch ... command for you to run in two days.

completeTimelockAdminSwitch does two things: run executeTransaction() on itself to call setPendingAdmin() to the Governor contract (since it is deployed after Timelock and must be set manually after deployment), and then call __acceptAdmin() on Governor to complete the switch. Most of the parameters are for the first command: