# Allow changing vote time for Aragon Voting The Lido DAO is an Aragon organization. Since Aragon provides a full end-to-end framework to build DAOs, we use its standard tools. We use standard aragon [Voting contract](https://github.com/aragon/aragon-apps/blob/master/apps/voting/contracts/Voting.sol) that has been initialized with `voteTime` 24 hours. As the the number of LDO token holders grows, 24 hours is no longer the optimal value for voting time, neither from voting organization point of view, nor from the security point of view. In the future, we plan to increase the voting period again, for example, to one week. Aragon voting not allow to change this parameter trough the setter, so we’ve forked the app and add a setter, a role and coressponed event for `voteTime` variable. This change will require upgrade the voting contract, adding of a new role and republish the UI. ## The current mechanics When someone starts a vote, the `Voting` contract [stores the time] of the vote start: ```solidity Vote storage vote_ = votes[voteId]; vote_.startDate = getTimestamp64(); ``` To determine if the vote has ended, the contract subtracts the vote start time from the current time and [compares the result] with the configured vote time (which is a global configuration value that is the same for all votes): ```solidity function _isVoteOpen(Vote storage vote_) internal view returns (bool) { return getTimestamp64() < vote_.startDate.add(voteTime) && !vote_.executed; } ``` The `voteTime` storage variable is set at the time of the contract deploy and cannot be changed afterwards. [stores the time]: https://github.com/aragon/aragon-apps/blob/master/apps/voting/contracts/Voting.sol#L291 [compares the result]: https://github.com/aragon/aragon-apps/blob/master/apps/voting/contracts/Voting.sol#L407 ## Changing vote time We can introduce the ability to change the vote time using two different approaches. ### Approach 1: allow changing global config The most simple approach would be to add a function that allows the authorized party to change the `voteTime` storage variable's value. The upside is simplicity, the code modifications are trivial (the addition of one function and one permission) and easily understandable. The downside is that changing vote time would affect all currently unexecuted votes since only vote start time is stored for each vote: * Decreasing the vote time might close the currently ongoing votes. * Increasing the vote time might re-open already decided votes unless they're executed. So this action is potentially dangerous and may bring the unexpected side effects. If we're to go this way, we need a proper communication with the DAO holders and a careful choise of the timing. ### Approach 2: store vote end time per vote The second approach is to store vote end time for each vote, calculating it at the moment of vote creation using the global vote time configuration that can be changed by an authorized party: ```solidity Vote storage vote_ = votes[voteId]; vote_.endDate = getTimestamp64() + voteTime; ``` The upside is that changing vote time would only affect votes created after the change is applied. The downside is complexity of the code changes: * addition of the `endDate` field to the `Vote` structure; * modification of `_newVote` and `_isVoteOpen` functions. Moreover, we'd need to support the pre-change votes that have no value inside the `endDate` field. For these votes, we'd have to either use the global `voteTime` value to calculate vote end time, like it's done in the current implementation, or migrate them during the upgrade. The first option still won't make the upgrade process safe, and the second one would require introducing even more non-trivial and ad-hoc code containing a loop through all votes. ## The proposed approach Given all this considerations, we propose to go with the first approach. It's less safe but can be easily audited. The permission required to change vote time would be assigned only to the DAO voting app itself, and the vote time change moment would be chosen so that it won't affect any other votes. ## Scope of the audit Commit: https://github.com/lidofinance/aragon-apps/commit/8c46da8704d0011c42ece2896dbf4aeee069b84a Contracts: Voting.sol: [apps/voting/contracts/Voting.sol](https://github.com/lidofinance/aragon-apps/blob/master/apps/voting/contracts/Voting.sol) ## Voting contract requirements The patched voting contract should behave in the same way as the original aragon voting contract and additionally allow changing the voting time. The initial aragon voting contract can be found here: https://github.com/aragon/aragon-apps/tree/master/apps/voting