-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test votes migration for adding a new vote weight mechanism #674
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elenadimitrova
force-pushed
the
feature/governance
branch
from
March 10, 2023 09:47
42c5cf9
to
7024a11
Compare
duncancmt
force-pushed
the
duncancmt-governance
branch
from
March 13, 2023 19:13
45a70d7
to
eff10dc
Compare
duncancmt
commented
Mar 13, 2023
// TODO: we're not handling totalSupply | ||
|
||
// TODO: need to return the migrated weight | ||
function _writeCheckpoint( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is almost entirely copy-pasted from ZeroExVotes
, except for the bits handling .migratedVotes
duncancmt
force-pushed
the
duncancmt-governance
branch
from
March 15, 2023 12:48
484d126
to
664873e
Compare
elenadimitrova
force-pushed
the
duncancmt-governance
branch
3 times, most recently
from
March 20, 2023 12:03
92abe7a
to
b8ac8cf
Compare
duncancmt
force-pushed
the
feature/governance
branch
from
March 20, 2023 14:19
f30eb88
to
01f297b
Compare
elenadimitrova
force-pushed
the
feature/governance
branch
from
March 20, 2023 18:20
bf65c4b
to
538c61f
Compare
elenadimitrova
force-pushed
the
duncancmt-governance
branch
from
March 21, 2023 13:46
b8ac8cf
to
a8bab10
Compare
duncancmt
commented
Mar 21, 2023
duncancmt
commented
Mar 21, 2023
elenadimitrova
force-pushed
the
duncancmt-governance
branch
from
March 21, 2023 16:32
1975065
to
3fd8ba7
Compare
elenadimitrova
changed the title
Demonstrate governance edge cases through failing tests
Test votes migration for adding a new vote weight mechanism
Mar 22, 2023
elenadimitrova
added a commit
that referenced
this pull request
Mar 22, 2023
* Install open zeppelin contracts * Init foundry in governance * Add wrapped ZRX token * Add governance contracts testing to CI * Set optimizer runs to default * Upgrade to patched version of openzeppelin/contracts * Test stakingakng / unwrapping ZRX * Init npm package * Lint fix, removing lib from gitignore * Add openzeppelin contracts git submodule for foundry * Add vanilla governor contract * Fix reference paths to imported packages * Temporarily switch to using a mocked version of ZRX * Ignore foundry's lib in link checker * Fix a conflict in gitignore between forge lib adn built lib * Upload governance code coverage report to coveralls * Flesh out test scenarios for wrapping/unwrapping * Add basic ERC20 name and symbol tests * Wire in basic timelock controller and governor test setup * Test basic governor properties * Add basic voting power delegation tests * Add proposal execution happy path test * Split ERC20Votes logic between wrapped token and ZeroExVotes contracts * Exclude BaseTest from coverage in coveralls * Add protocol specific governor with produciton governance settings * Add a dedicated instance for the treasury governor This is currently using the default 1 token 1 vote mechanism but will be migrated * Add test for updating governance settings for voting delay, voting period and proposal threshold * Create seperate timelock contract instance for treasury and protocol * Test updating the timlock min delay * Set timelock delay to 2 days for protocol and 1 sec for treasury * Remove timelock from treasury governor * Refactor _checkpointsLookup to return entire Checkpoint instad of just number of votes * Update the totalSupply checkpoints updating logic * Quadratic voting power transfers and delegations * Fix workflow yaml * Initialise ZeroExVotes behind a ERC1967Proxy Test it cannot be reinitialised * Remove obsoleted console.logs from test * Storage pack Checkpoint enum * Remove keeping track of total balances for voting * Switch to using the foundry artifact in test * Fix rebase issue * Add timelock control over the treasury governor * Add test for wrapped token transfer * Emit separate events for changing linear and quadratic voting power * Add the ability to cancel a proposal * Limit the governors' cancel function to security council only * Eject security council after a proposal is cancelled * Add ability for governance to set the security council * Merge the governors test suites into one reusable set of tests * Add an empty test function to base test contract to remove it from coverage reports. Fudge but no other way to ignore it in report * Security council can rollback protocol upgrades * Upgrade to solidity 0.8.19 * Move IZeroExGovernor to src * Abstract Security council interface into its own * Emit events when assigning and ejecting the security council * Use a cast to bytes4 instead of LibBytes Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com> * Writing total supply checkpoints and setup of quorum percentage of quadratic total supply for treasure governor * Add test for transferring tokens when delegating * Rename IZeroExSecurityCouncil to ISecurityCouncil * Add security council restrictions to governors * Remove obsolete overflow check * Improve test coverage * Upgrade open-zeppelin contracts to 4.8.2 * Test delegation by signature * Test non security council requests to rollback protocol changes cannot be executed * Better revert messages * Test correct interfaces are supported * Remove obsoleted funciton * Further test delegation by signature scenario * Split the delegation functionality tests * Add test for initialisation of voting contract * Add test for reading checkpoints * Update code comments * Fix compilation warnings * Run smt checker * Add checkpoint tests * Rename parameter in moveEntireVotingPower to match the one in movePartialVotingPower * Switch moveEntireVotingPower to a more generic moveVotingPower implementation as in the open-zeppelin contracts * Install foundry earlier in CI * Switch movePartialVotingPower to the generic moveVotingPower implementation * Write totalSupplyCheckpoints via the generic _writeCheckpoint * Add threshold for quadratic voting power * Remove autoinserted code by OZ * Add openzeppelin/contracts-upgradable * Add initializable base to Voting contract * Fix terminogy error in natspec * Fix code comment * Remove obsoleted overrides and add a missing modifier to moveVotingPower * Remove amount check Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com> * Fix a calculation error and clean tests * Update thresholds for treasury governor * Fix testShouldNotBeAbleToDelegateWithSignatureAfterExpiry * Update from @duncancmt without "memory-safe" the IR optimizer produces significantly worse code and it disables the stack limit evader Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com> * Add onlyProxy to initializer * Fix quadratic voting weight base * Rename voting parameter for clarity * Make addresses immutable (#680) * Make addresses immutable * Fix linting issues --------- Co-authored-by: elenadimitrova <elena@arenabg.com> * Prevent griefing by a malicious ZeroExVotes upgrade (#681) * Gas optimization * Minimal change to prevent malicious ZeroExVotes from griefing * Add demonstration of griefing upgrade * Fix rebase issues with tests * Fix prettier issues * Add checks to test --------- Co-authored-by: elenadimitrova <elena@arenabg.com> * Rename SecurityCouncil contract * Add timestamp to delegator balance updates * Make quadraticThreshold `immutable` for gas efficiency * Remove the logic for ejecting security council * Switch balance timestamp to be a block number * Test votes migration for adding a new vote weight mechanism (#674) * Add Emacs files to .gitignore * Make some functions unproected to demonstrate a migration * Add example (broken) migration * Add migration test for voting logic * Try to simplify tests * Fix compilation errors * Fix underflow test with new logic * Flesh out migration test for voting * Replace cube root library * Fix stack too deep in coverage --------- Co-authored-by: elenadimitrova <elena@arenabg.com> * Change test case to testFail * Update contracts/governance/test/ZeroExVotesMigration.sol Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com> --------- Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com> Co-authored-by: Duncan Townsend <git@duncancmt.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a migration test for the voting logic. We simulate upgrading this to add a cube root vote weight mechanism. This utilizes of the currently unused
DelegateInfo.balanceLastUpdated
property which is passed to the voting contract by the wrapped token.