Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

feat: added voting delay, configurable delay, voting, and submission periods, and checkpoints for periods #66

Merged
merged 33 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a3d9e07
added set quorum fns
dd0sxx Dec 12, 2023
af9c1ef
SetQuorumPct
dd0sxx Dec 12, 2023
2bb3f4e
SetQuorumPct 721
dd0sxx Dec 12, 2023
cbce3da
compiles without tests
dd0sxx Dec 13, 2023
b48750e
tests work
dd0sxx Dec 13, 2023
cccded6
fmt
dd0sxx Dec 13, 2023
8f59376
pushing changes
dd0sxx Dec 13, 2023
c16d10e
builds w no tests
dd0sxx Dec 14, 2023
264218e
got rid of hardcoded 1/3 / 2/3 periods
dd0sxx Dec 14, 2023
228f830
added internal fn
dd0sxx Dec 14, 2023
83825c6
init to default value
dd0sxx Dec 14, 2023
66d1bdc
Merge branch 'main' into theo/update-submission-period
dd0sxx Dec 14, 2023
62e48c6
uint48
dd0sxx Dec 14, 2023
8e06643
added view fns
dd0sxx Dec 14, 2023
69117cf
so close
dd0sxx Dec 15, 2023
1550514
5 MOORE
dd0sxx Dec 15, 2023
aba8341
CLOSER
dd0sxx Dec 15, 2023
d2e978c
YES
dd0sxx Dec 15, 2023
1f2823f
new tests added
dd0sxx Dec 15, 2023
abe2676
Merge branch 'main' into theo/update-submission-period
dd0sxx Dec 15, 2023
a109d5d
fix
dd0sxx Dec 15, 2023
6dd31ff
comment
dd0sxx Dec 15, 2023
f028e5f
Update PeriodPctCheckpoints.sol
dd0sxx Dec 15, 2023
6960a96
Update PeriodPctCheckpoints.sol
dd0sxx Dec 15, 2023
84b362f
Update src/lib/QuorumCheckpoints.sol
0xrajath Dec 15, 2023
448bc49
delayPeriodTimestamp weight
dd0sxx Dec 15, 2023
3a4c010
added weight test
dd0sxx Dec 15, 2023
88946da
tests
dd0sxx Dec 15, 2023
a000c44
test
dd0sxx Dec 15, 2023
4eaf6a1
test
dd0sxx Dec 15, 2023
0d50295
comments and insert return fn
dd0sxx Dec 15, 2023
8e546f6
comments
dd0sxx Dec 15, 2023
ddd9839
fixed
dd0sxx Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
uint48
  • Loading branch information
dd0sxx committed Dec 14, 2023
commit 62e48c644a40c368ae071d3552c9e67e90e08b2a
6 changes: 0 additions & 6 deletions src/lib/LlamaUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ library LlamaUtils {
return uint96(n);
}

/// @dev Reverts if `n` does not fit in a `uint224`.
function toUint224(uint256 n) internal pure returns (uint224) {
if (n > type(uint224).max) revert UnsafeCast(n);
return uint224(n);
}

/// @dev Increments a `uint256` without checking for overflow.
function uncheckedIncrement(uint256 i) internal pure returns (uint256) {
unchecked {
Expand Down
14 changes: 7 additions & 7 deletions src/lib/QuorumCheckpoints.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ library QuorumCheckpoints {
}

struct Checkpoint {
uint224 timestamp;
uint48 timestamp;
uint16 voteQuorumPct;
uint16 vetoQuorumPct;
Comment on lines 27 to 28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can bump this up right to fill the entire word. I know it makes no difference to the actual Pct, but if I remember right it's cheaper to access a full word (i.e 256) vs less than that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we can leave it as is if we want to be consistent on using uint16 for Percentages everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint16 makes the most sense because the max value is 10000 anyways and uint8 is not enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's let the auditors golf this i don't think we should worry about that in this pr

}
Expand All @@ -42,7 +42,7 @@ library QuorumCheckpoints {
*/
function getAtProbablyRecentTimestamp(History storage self, uint256 timestamp) internal view returns (uint16, uint16) {
require(timestamp < block.timestamp, "PolicyholderCheckpoints: timestamp is not in the past");
uint224 _timestamp = LlamaUtils.toUint224(timestamp);
uint48 _timestamp = LlamaUtils.toUint48(timestamp);

uint256 len = self._checkpoints.length;

Expand Down Expand Up @@ -77,7 +77,7 @@ library QuorumCheckpoints {
* accidentally introducing a bug or breaking change.
*/
function push(History storage self, uint256 vetoQuorumPct, uint256 voteQuorumPct) internal returns (uint16, uint16) {
return _insert(self._checkpoints, LlamaUtils.toUint224(block.timestamp), LlamaUtils.toUint16(voteQuorumPct), LlamaUtils.toUint16(vetoQuorumPct));
return _insert(self._checkpoints, LlamaUtils.toUint48(block.timestamp), LlamaUtils.toUint16(voteQuorumPct), LlamaUtils.toUint16(vetoQuorumPct));
}

/**
Expand All @@ -99,7 +99,7 @@ library QuorumCheckpoints {
view
returns (
bool exists,
uint224 timestamp,
uint48 timestamp,
uint16 voteQuorumPct,
uint16 vetoQuorumPct
)
Expand All @@ -126,7 +126,7 @@ library QuorumCheckpoints {
*/
function _insert(
Checkpoint[] storage self,
uint224 timestamp,
uint48 timestamp,
uint16 voteQuorumPct,
uint16 vetoQuorumPct
) private returns (uint16, uint16) {
Expand Down Expand Up @@ -163,7 +163,7 @@ library QuorumCheckpoints {
*/
function _upperBinaryLookup(
Checkpoint[] storage self,
uint224 timestamp,
uint48 timestamp,
uint256 low,
uint256 high
) private view returns (uint256) {
Expand All @@ -187,7 +187,7 @@ library QuorumCheckpoints {
*/
function _lowerBinaryLookup(
Checkpoint[] storage self,
uint224 timestamp,
uint48 timestamp,
uint256 low,
uint256 high
) private view returns (uint256) {
Expand Down