-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(basefee-treasury): implement impl
#142
feat(basefee-treasury): implement impl
#142
Conversation
Slither reportTHIS CHECKLIST IS NOT COMPLETE. Use
reentrancy-ethImpact: High
dpos-contract/src/ronin/validator/CoinbaseExecution.sol Lines 102 to 162 in 0b6d306
dpos-contract/src/ronin/validator/CoinbaseExecution.sol Lines 206 to 244 in 0b6d306
dpos-contract/src/ronin/validator/CoinbaseExecution.sol Lines 102 to 162 in 0b6d306
dpos-contract/src/ronin/validator/CoinbaseExecution.sol Lines 102 to 162 in 0b6d306
dpos-contract/src/ronin/validator/CoinbaseExecution.sol Lines 102 to 162 in 0b6d306
dpos-contract/src/ronin/staking/CandidateStaking.sol Lines 120 to 155 in 0b6d306
shadowing-stateImpact: High
uninitialized-stateImpact: High
|
b381ba4
to
1c1ef24
Compare
function _requireValidNonce( | ||
uint256 nonce | ||
) internal view { | ||
require(nonce == getGlobalNonce(), ErrInvalidNonce(getGlobalNonce(), nonce)); |
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.
Should fetch global nonce once
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.
since there will be no onchain failure, this could result in small bytecode increase but imo no gas will be saved even if we cache global nonce
* - `msg.sender` must be `proposal.executor`. | ||
* - `hash` must be existed and passed (ProposalStatus must be Passed). | ||
*/ | ||
function execute( |
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.
Should we support bulk execution? Not sure if there are cases where multiple proposals need to be executed in single tx though
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.
may depend on proposal.executor so no.
function _calcMinVoteAgainst( | ||
uint256 totalVotePower | ||
) internal view returns (uint96 minVoteAgainst) { | ||
uint256 diff = _threshold.denom - _threshold.num; | ||
minVoteAgainst = ((totalVotePower * diff) / _threshold.denom).toUint96(); | ||
require(minVoteAgainst != 0, ErrZeroMinVotePower()); |
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 should be calculated by taking totalVotePower - _calcMinVoteFor
. Because with your implementation, may _calcMinVoteFor + _calcMinVoteAgainst < totalVotePower
, which leads to a situation where the proposal is canceled once the votes just meet _calcMinVoteAgainst
, even though further voting could potentially exceed _calcMinVoteFor
.
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.
Agree. To be more specific, let’s say the total vote power is 31
and the threshold is 0.5
(num = 1, denom = 2). Both _calcMinVoteAgainst
and _calcMinVoteFor
would return 15. Even if the current power of voteFor
is 16, the proposal would still be canceled
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.
acked. However, if it is actually come in this case on production, I still think it is okay if it is cancelled.
require( | ||
_computePeriod(profile.getId2RegisteredAt(cid) + COOLDOWN_PERIOD) <= _computePeriod($._createdAt), | ||
ErrNewlyRegisteredCannotVote(cid) | ||
); |
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 condition prevents new candidates from voting on past proposals. Is it as expected?
Even if someone registers as a candidate and waits a day, he still can’t vote on past proposals.
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.
As expected.
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.
Need to verify with protocol team whether adding balance to a contract without receive()
function is possible at node layer
return false; | ||
} | ||
|
||
if ($._votePow.vFor < _calcMinVoteFor($._totalVotePow)) return false; |
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.
Note that in the case where totalVotePow = 101
and the threshold is 70%
, if $._votePow.For = 70
, it would not satisfy >= 101 * 70% = 70.7
. To be precise, I believe the comparison should be whether $._votePow.vFor * denom >= totalVotePow * num
. Similarly, for early proposal cancellation, we need to compare $._votePow.Against * denom > totalPow * (denom - num)
.
f0e83d2
to
8eedf8a
Compare
Co-authored-by: TuDo1403 <[email protected]>
Description
PR to merge from implement-feature/basefee-treasury/impl to feature/basefee-treasury.