Skip to content
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

refactor: use block numbers to track time #210

Merged
merged 12 commits into from
Jun 19, 2023

Conversation

Orland0x
Copy link
Contributor

@Orland0x Orland0x commented Jun 16, 2023

closes #193, #174, #168

Migrates the space contract and execution strategy proposal status functions. to use block numbers instead of timestamps. Note that this does not include the ActiveProposalLimiter, and Timelock contracts which still use timestamps.

@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Merging #210 (ac6b81c) into main (2c5b49f) will decrease coverage by 0.84%.
The diff coverage is 70.00%.

@@            Coverage Diff             @@
##             main     #210      +/-   ##
==========================================
- Coverage   81.66%   80.82%   -0.84%     
==========================================
  Files          29       28       -1     
  Lines         469      459      -10     
  Branches      114      111       -3     
==========================================
- Hits          383      371      -12     
  Misses         73       73              
- Partials       13       15       +2     
Impacted Files Coverage Δ
...werAndActiveProposalsLimiterValidationStrategy.sol 100.00% <ø> (ø)
src/voting-strategies/WhitelistVotingStrategy.sol 100.00% <ø> (ø)
...n-strategies/OptimisticQuorumExecutionStrategy.sol 58.82% <33.33%> (ø)
...on-strategies/EmergencyQuorumExecutionStrategy.sol 67.64% <40.00%> (-8.83%) ⬇️
...ution-strategies/SimpleQuorumExecutionStrategy.sol 77.27% <66.66%> (ø)
src/Space.sol 96.21% <100.00%> (ø)
src/utils/PropositionPower.sol 100.00% <100.00%> (ø)
src/voting-strategies/CompVotingStrategy.sol 100.00% <100.00%> (ø)
src/voting-strategies/OZVotesVotingStrategy.sol 100.00% <100.00%> (ø)

@Orland0x Orland0x requested a review from pscott June 19, 2023 09:13
pscott
pscott previously approved these changes Jun 19, 2023
Copy link
Collaborator

@pscott pscott left a comment

Choose a reason for hiding this comment

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

tACK

Comment on lines +399 to +400
// If a proposal exists, then its execution payload hash will be non-zero.
if (proposal.executionPayloadHash == 0) revert InvalidProposal();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it really impossible to create a proposal with an empty execution payload? Imagine we want to "ratify" something on-chian, then the execution payload could be empty right?

I think proposal.startBlockNumber == 0 would be a better check here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but then the payload hash would be keccak(0) so non zero. Wheras it would technically be possible to have a start block number of zero (ie the proposal was created in the genesis block and there is no voting delay)

Comment on lines 8 to 10
/// @param blockNumber The snapshot block number to get the voting power at. If a particular voting strategy
/// requires a block number instead of a block number, the strategy should resolve the
/// block number to a block number.
Copy link
Collaborator

Choose a reason for hiding this comment

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

can remove the whole "resolve" part

@pscott
Copy link
Collaborator

pscott commented Jun 19, 2023

Question: how does this PR help #193 ?

@Orland0x
Copy link
Contributor Author

Question: how does this PR help #193 ?

there is now no state changes in the voting strategies, so they are view functions and can be queried off chain fairly simply

@pscott
Copy link
Collaborator

pscott commented Jun 19, 2023

Question: how does this PR help #193 ?

there is now no state changes in the voting strategies, so they are view functions and can be queried off chain fairly simply

didn't notice the view :) thx

chore: natspec typo
@Orland0x Orland0x merged commit 5c51bbe into main Jun 19, 2023
pscott added a commit that referenced this pull request Jun 19, 2023
* refactor: timestamps to numbers in space

* refactor: block numbers in proposal status funcs

* refactored: removed timestamp resolver

* refactor: proposal validation to use block nubmers

* refactor: removed snapshot block number

* chore: updated tests

* refactor: make getVotingPower a  view function

* refactor: revert active proposal limiter to timestamps

* refactor: revert timelocks to timestamps

* chore: fixed tests

* Update IVotingStrategy.sol

chore: natspec typo

---------

Co-authored-by: Orlando <[email protected]>
Orland0x added a commit that referenced this pull request Jun 19, 2023
* audit: use uint256 instead of bool in mappings

* opti: use uint256 instead of bools in other mappings

* chore: define TRUE, FALSE in types

* refactor: use TRUE, FALSE consts from types.sol

* chore: comment explain pupose of boolean aliases

* audit: prevent reentrancy issues in execute function (#207)

* audit: prevent reentrancy issues in execute function

* comment: add comment for cached proposal

* comment: remove comment for finalization status modification

* chore: CEI explanation

* chore: typo

---------

Co-authored-by: Orlando <[email protected]>

* refactor: use block numbers to track time (#210)

* refactor: timestamps to numbers in space

* refactor: block numbers in proposal status funcs

* refactored: removed timestamp resolver

* refactor: proposal validation to use block nubmers

* refactor: removed snapshot block number

* chore: updated tests

* refactor: make getVotingPower a  view function

* refactor: revert active proposal limiter to timestamps

* refactor: revert timelocks to timestamps

* chore: fixed tests

* Update IVotingStrategy.sol

chore: natspec typo

---------

Co-authored-by: Orlando <[email protected]>

---------

Co-authored-by: Orlando <[email protected]>
Co-authored-by: Orland0x <[email protected]>
@Orland0x Orland0x deleted the refactor_timestamps_to_block_number branch October 11, 2023 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

audit: Voting Power Not Easily Estimated in User Interface
2 participants