-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Extend Checkpoints with new sizes and lookup mechanisms #3589
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
Merged
Merged
Changes from 18 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
4176852
move mock
Amxx 63edb74
Expand Checkpoint library
Amxx da0ea31
rename upperLookupExpEnd → upperLookupRecent
Amxx ed81388
sanity check when pushing checkpoints
Amxx b91832d
Skip redundant optimisation in VotesQuorumFraction
Amxx d2a829c
Merge branch 'master' into feature/checkpoint
Amxx 2a6adb3
reset previous history lookup algorithm and reenable quorum checks
Amxx 28f6e6f
Use unsafeAccess to save gas
Amxx b7e2f64
Merge branch 'master' into feature/checkpoint
Amxx 616c51b
Regenerate contracts
Amxx 3fb185b
Add changelog entry
Amxx ce0c7a6
use StorageSlot for unsafeAccess returns
Amxx 33741e7
minor rewrite for readability
Amxx 8425e4a
fix typo
Amxx 74fef95
testing unsafeAccess
Amxx df3a9b1
fix lint
Amxx e182730
Update CHANGELOG.md
Amxx 9b1f559
Merge branch 'master' into feature/checkpoint
Amxx 768a681
Apply suggestions from code review
Amxx 8d9b177
Update Arrays.sol
Amxx 8dc9d4f
Run prettier as part of the procedural generation
Amxx 4e6aa05
Reactor checkpoints to keep legacy types
Amxx fffde15
add a comment about files being procedurally generated
Amxx ac5466a
add extensions for the comments
Amxx a9a69cf
lint
Amxx 4654237
shorter message
Amxx b486b6b
Merge branch 'master' into feature/checkpoint
Amxx 2848c3a
regenerate & codespell
Amxx 4c6c65e
update generation script path resolution
Amxx 068513c
address comment from PR
Amxx bf12a2b
add more neatspec
Amxx b1d5a09
add more neatspec
Amxx 543d516
Apply suggestions from code review
Amxx 634e279
regenerate
Amxx 17e1ec7
don't insert newline when no previous version is recorded
Amxx d1af38d
improve checkpoint opts generation
Amxx 253e12a
codespell
Amxx 1ccff75
test coverage
Amxx 4d1d3da
grammar
frangio 2d03e54
improve tests
Amxx 69ac69e
Merge remote-tracking branch 'amxx/feature/checkpoint' into feature/c…
Amxx 5661e71
Update test/utils/Checkpoints.test.js
Amxx 6cd42ce
Apply suggestions from code review
Amxx 9c84034
fix generation
Amxx b878b23
Update scripts/generate/templates/Checkpoints.js
Amxx c832e53
Update scripts/generate/templates/Checkpoints.js
Amxx a450545
Update scripts/generate/templates/Checkpoints.js
Amxx 96122a3
Update scripts/generate/templates/Checkpoints.js
Amxx c891f58
fix generation
Amxx 47ed78e
add History.getAtRecentBlock & tests
Amxx 533ccef
wording
Amxx 6caea6a
Merge branch 'master' into feature/checkpoint
Amxx 22491c0
wrap docs
frangio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "../utils/Arrays.sol"; | ||
|
|
||
| contract Uint256ArraysMock { | ||
| using Arrays for uint256[]; | ||
|
|
||
| uint256[] private _array; | ||
|
|
||
| constructor(uint256[] memory array) { | ||
| _array = array; | ||
| } | ||
|
|
||
| function findUpperBound(uint256 element) external view returns (uint256) { | ||
| return _array.findUpperBound(element); | ||
| } | ||
|
|
||
| function unsafeAccess(uint256 pos) external view returns (uint256) { | ||
| return _array.unsafeAccess(pos).value; | ||
| } | ||
| } | ||
|
|
||
| contract AddressArraysMock { | ||
| using Arrays for address[]; | ||
|
|
||
| address[] private _array; | ||
|
|
||
| constructor(address[] memory array) { | ||
| _array = array; | ||
| } | ||
|
|
||
| function unsafeAccess(uint256 pos) external view returns (address) { | ||
| return _array.unsafeAccess(pos).value; | ||
| } | ||
| } | ||
|
|
||
| contract Bytes32ArraysMock { | ||
| using Arrays for bytes32[]; | ||
|
|
||
| bytes32[] private _array; | ||
|
|
||
| constructor(bytes32[] memory array) { | ||
| _array = array; | ||
| } | ||
|
|
||
| function unsafeAccess(uint256 pos) external view returns (bytes32) { | ||
| return _array.unsafeAccess(pos).value; | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "../utils/Checkpoints.sol"; | ||
|
|
||
| contract CheckpointsMock { | ||
| using Checkpoints for Checkpoints.History; | ||
|
|
||
| Checkpoints.History private _totalCheckpoints; | ||
|
|
||
| function latest() public view returns (uint256) { | ||
| return _totalCheckpoints.latest(); | ||
| } | ||
|
|
||
| function push(uint256 value) public returns (uint256, uint256) { | ||
| return _totalCheckpoints.push(value); | ||
| } | ||
|
|
||
| function getAtBlock(uint256 blockNumber) public view returns (uint256) { | ||
| return _totalCheckpoints.getAtBlock(blockNumber); | ||
| } | ||
|
|
||
| function length() public view returns (uint256) { | ||
| return _totalCheckpoints._checkpoints.length; | ||
| } | ||
| } | ||
|
|
||
| contract Checkpoints224Mock { | ||
| using Checkpoints for Checkpoints.Checkpoint224[]; | ||
|
|
||
| Checkpoints.Checkpoint224[] private _totalCheckpoints; | ||
|
|
||
| function latest() public view returns (uint224) { | ||
| return _totalCheckpoints.latest(); | ||
| } | ||
|
|
||
| function push(uint32 key, uint224 value) public returns (uint224, uint224) { | ||
| return _totalCheckpoints.push(key, value); | ||
| } | ||
|
|
||
| function lowerLookup(uint32 key) public view returns (uint224) { | ||
| return _totalCheckpoints.lowerLookup(key); | ||
| } | ||
|
|
||
| function upperLookup(uint32 key) public view returns (uint224) { | ||
| return _totalCheckpoints.upperLookup(key); | ||
| } | ||
|
|
||
| function upperLookupRecent(uint32 key) public view returns (uint224) { | ||
| return _totalCheckpoints.upperLookupRecent(key); | ||
| } | ||
|
|
||
| function length() public view returns (uint256) { | ||
| return _totalCheckpoints.length; | ||
| } | ||
| } | ||
|
|
||
| contract Checkpoints160Mock { | ||
| using Checkpoints for Checkpoints.Checkpoint160[]; | ||
|
|
||
| Checkpoints.Checkpoint160[] private _totalCheckpoints; | ||
|
|
||
| function latest() public view returns (uint160) { | ||
| return _totalCheckpoints.latest(); | ||
| } | ||
|
|
||
| function push(uint96 key, uint160 value) public returns (uint160, uint160) { | ||
| return _totalCheckpoints.push(key, value); | ||
| } | ||
|
|
||
| function lowerLookup(uint96 key) public view returns (uint160) { | ||
| return _totalCheckpoints.lowerLookup(key); | ||
| } | ||
|
|
||
| function upperLookup(uint96 key) public view returns (uint160) { | ||
| return _totalCheckpoints.upperLookup(key); | ||
| } | ||
|
|
||
| function upperLookupRecent(uint96 key) public view returns (uint224) { | ||
| return _totalCheckpoints.upperLookupRecent(key); | ||
| } | ||
|
|
||
| function length() public view returns (uint256) { | ||
| return _totalCheckpoints.length; | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.