You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If block.timestamp is already past the previous end, the new phase will in reality be shorter than the intended DAO_PHASE_DURATION. In the worst case, block.timestamp could surpass newPhaseStart + DAO_PHASE_DURATION immediately, allowing multiple rapid switchPhase calls and effectively skipping phases. This leads to irregular and potentially manipulated proposal cycles.
Impact:
Phases lasts less than 2 weeks.
In the worst case scenario, phases can become significantly shorter than intended, giving insufficient time for proposals to be created, voted on, or executed as expected.
The governance process becomes unpredictable and possibly unfair, undermining trust in the DAO's decision-making mechanism.
Proof of Concept:
You can execute the following test by running forge test --mt testSwitchPhaseDurationReducedDueToDelay -vv:
functiontestSwitchPhaseDurationReducedDueToDelay()public{uint64DAO_PHASE_DURATION=dao.DAO_PHASE_DURATION();// Get the current phase end time(,uint64currentEnd,,)=dao.daoPhase();// Simulate a delay: Advance time by 1 hour after the current phase enduint64timeAfterEnd=currentEnd+1hours;vm.warp(timeAfterEnd);// Assume switchPhase is called after the delaydao.switchPhase();// Get the new phase start and end times(uint64newStart,uint64newEnd,,)=dao.daoPhase();// The new phase end is set to newStart + DAO_PHASE_DURATIONuint64expectedEnd=newStart+DAO_PHASE_DURATION;// However, since block.timestamp > newStart, the actual duration remaining is less than 2 weeks// Calculate the remaining duration of the new phaseuint64remainingDuration=newEnd>uint64(block.timestamp) ? newEnd-uint64(block.timestamp) : 0;// The remaining duration should be less than DAO_PHASE_DURATIONassertTrue(remainingDuration<DAO_PHASE_DURATION);// Verify that the new phase will last less than the expected DAO_PHASE_DURATIONuint64expectedRemainingDuration=expectedEnd-uint64(block.timestamp);assertEq(remainingDuration,expectedRemainingDuration);// Logging for more clarityemitlog_named_uint("Current Timestamp:",uint64(block.timestamp));emitlog_named_uint("New Phase Start:",newStart);emitlog_named_uint("New Phase End:",newEnd);emitlog_named_uint("DAO_PHASE_DURATION(2 weeks):",DAO_PHASE_DURATION);emitlog_named_uint("Remaining Duration of New Phase:",remainingDuration);}
Recommendation
Ensure that the new phase duration is calculated from the current block.timestamp rather than from daoPhase.end.
The text was updated successfully, but these errors were encountered:
softstackio
changed the title
[M-1] Phase duration will be shortened each time switchPhase is delayed
[M-01] Phase duration will be shortened each time switchPhase is delayed
Dec 10, 2024
We are discussing this.
The implication of the suggested solution, we would not stay at fixed time windows anymore, like the Phase start is always at 12:00 PM.
It would start to slightly shift each phase,
12:01 PM,
12:02 PM,
12:05 PM,
...
Severity: Medium
Likelihood: High
Description:
When switchPhase is called, the new phase's start and end timestamps are derived from the previous phase's
end
timestamp :If block.timestamp is already past the previous end, the new phase will in reality be shorter than the intended DAO_PHASE_DURATION. In the worst case, block.timestamp could surpass newPhaseStart + DAO_PHASE_DURATION immediately, allowing multiple rapid switchPhase calls and effectively skipping phases. This leads to irregular and potentially manipulated proposal cycles.
Impact:
Proof of Concept:
You can execute the following test by running
forge test --mt testSwitchPhaseDurationReducedDueToDelay -vv
:Recommendation
Ensure that the new phase duration is calculated from the current block.timestamp rather than from daoPhase.end.
The text was updated successfully, but these errors were encountered: