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

WIP 🚧 feat: token voting target improvements #30

Closed
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cb368a3
feat: add condition
clauBv23 Aug 30, 2024
6173c49
feat: add new params to token voting
clauBv23 Aug 30, 2024
7b44355
add target configs permanently and fix tests
novaknole Sep 8, 2024
5ce8060
reinitializer number fixed and old interface
novaknole Sep 10, 2024
84ef2cd
remove todo comments
novaknole Sep 10, 2024
207d988
initializeFrom with build number and data
novaknole Sep 10, 2024
5dfccfc
ivotes checks
novaknole Sep 17, 2024
b2eef30
add initialization modifier for safety + improved targetconfig
novaknole Sep 19, 2024
96bf27b
bytes param added
novaknole Sep 19, 2024
cd5543e
rename param function
novaknole Sep 19, 2024
42073e3
Update packages/contracts/src/TokenVoting.sol
novaknole Sep 25, 2024
2051e27
Update packages/contracts/src/TokenVoting.sol
novaknole Sep 25, 2024
70f28e6
fix typo
novaknole Sep 25, 2024
ccfe8ec
add delegate call
novaknole Sep 26, 2024
f3cb27c
silence warnings
novaknole Sep 26, 2024
386d417
add executor interface
novaknole Sep 26, 2024
329e76b
action as free level
novaknole Sep 27, 2024
283c2c6
Merge pull request #34 from aragon/feature/executors
novaknole Sep 27, 2024
fba0116
Merge pull request #32 from aragon/feature/bytes-param-add
novaknole Sep 27, 2024
6b02e12
remove unneccessary revoke
novaknole Sep 27, 2024
4a8be44
Merge branch 'feat/token-voting-target-improvements' into feature/bet…
novaknole Sep 27, 2024
41b5d7f
Merge pull request #31 from aragon/feature/better-ivote-checks
novaknole Sep 28, 2024
93e6d31
better upgrade tests
novaknole Sep 28, 2024
5178b67
remove hardcoded value
novaknole Sep 28, 2024
4780717
Merge pull request #35 from aragon/feature/add-initializeFrom-upgrade…
novaknole Sep 28, 2024
2690267
callinitialization from osx-commons
novaknole Sep 28, 2024
630bfd9
Merge branch 'feat/token-voting-target-improvements' of https://githu…
novaknole Sep 28, 2024
0647d5d
fix tohex
novaknole Sep 29, 2024
4f86c7c
metadata extension
novaknole Oct 8, 2024
f316675
Update packages/contracts/src/MajorityVotingBase.sol
novaknole Oct 8, 2024
ccfa5d9
Update packages/contracts/src/TokenVoting.sol
novaknole Oct 8, 2024
d49093c
Update packages/contracts/src/TokenVoting.sol
novaknole Oct 8, 2024
ab1af36
Update packages/contracts/src/TokenVoting.sol
novaknole Oct 8, 2024
3176cd4
Update packages/contracts/src/TokenVotingSetup.sol
novaknole Oct 8, 2024
3de9e37
Update packages/contracts/src/TokenVotingSetup.sol
novaknole Oct 8, 2024
9799f4e
Update packages/contracts/src/TokenVotingSetup.sol
novaknole Oct 8, 2024
7b3d080
permission added
novaknole Oct 8, 2024
ba6dcf8
Merge pull request #36 from aragon/feature/metadata
novaknole Oct 8, 2024
4e5d291
metadata rename
novaknole Oct 9, 2024
a857d9e
fix tests and contract (#37)
novaknole Oct 14, 2024
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
8 changes: 6 additions & 2 deletions packages/contracts/deploy/20_new_version/23_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
createVersion: {
_release: VERSION.release,
_pluginSetup: setup.address,
_buildMetadata: toHex(buildMetadataURI),
_releaseMetadata: toHex(releaseMetadataURI),
_buildMetadata: ethers.utils.hexlify(
ethers.utils.toUtf8Bytes(buildMetadataURI)
),
_releaseMetadata: ethers.utils.hexlify(
ethers.utils.toUtf8Bytes(releaseMetadataURI)
),
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const config: HardhatUserConfig = {
deploy: './deploy',
},
mocha: {
timeout: 60_000,
timeout: 6000000,
},
solidity: {
version: '0.8.17',
Expand Down
63 changes: 47 additions & 16 deletions packages/contracts/src/MajorityVotingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {ProposalUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/exte
import {RATIO_BASE, RatioOutOfBounds} from "@aragon/osx-commons-contracts/src/utils/math/Ratio.sol";
import {PluginUUPSUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/PluginUUPSUpgradeable.sol";
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {IProposal} from "@aragon/osx-commons-contracts/src/plugin/extensions/proposal/IProposal.sol";
import {Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol";
import {MetadataExtensionUpgradeable} from "@aragon/osx-commons-contracts/src/utils/metadata/MetadataExtensionUpgradeable.sol";

import {IMajorityVoting} from "./IMajorityVoting.sol";

Expand Down Expand Up @@ -120,6 +123,7 @@ abstract contract MajorityVotingBase is
IMajorityVoting,
Initializable,
ERC165Upgradeable,
MetadataExtensionUpgradeable,
PluginUUPSUpgradeable,
ProposalUpgradeable
{
Expand Down Expand Up @@ -173,9 +177,10 @@ abstract contract MajorityVotingBase is
ProposalParameters parameters;
Tally tally;
mapping(address => IMajorityVoting.VoteOption) voters;
IDAO.Action[] actions;
Action[] actions;
uint256 allowFailureMap;
uint256 minApprovalPower;
TargetConfig targetConfig; // added in v1.3
Copy link

Choose a reason for hiding this comment

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

you mean added in v1.4 ?

}

/// @notice A container for the proposal parameters at the time of proposal creation.
Expand Down Expand Up @@ -214,12 +219,19 @@ abstract contract MajorityVotingBase is
this.getProposal.selector ^
this.updateVotingSettings.selector ^
this.updateMinApprovals.selector ^
this.createProposal.selector;
bytes4(
keccak256(
"createProposal(bytes,(address,uint256,bytes)[],uint256,uint64,uint64,uint8,bool)"
)
);

/// @notice The ID of the permission required to call the `updateVotingSettings` function.
bytes32 public constant UPDATE_VOTING_SETTINGS_PERMISSION_ID =
keccak256("UPDATE_VOTING_SETTINGS_PERMISSION");

/// @notice The ID of the permission required to call the `addAddresses` and `removeAddresses` functions.
bytes32 public constant CREATE_PROPOSAL_PERMISSION_ID = keccak256("CREATE_PROPOSAL_PERMISSION");

/// @notice A mapping between proposal IDs and proposal information.
// solhint-disable-next-line named-parameters-mapping
mapping(uint256 => Proposal) internal proposals;
Expand Down Expand Up @@ -259,6 +271,10 @@ abstract contract MajorityVotingBase is
/// @param proposalId The ID of the proposal.
error ProposalExecutionForbidden(uint256 proposalId);

/// @notice Thrown if the proposal with same actions and metadata already exists.
/// @param proposalId The id of the proposal.
error ProposalAlreadyExists(uint256 proposalId);
Copy link

Choose a reason for hiding this comment

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

Same as with multisig

aragon#19 (comment)


/// @notice Emitted when the voting settings are updated.
/// @param votingMode A parameter to select the vote mode.
/// @param supportThreshold The support threshold value.
Expand All @@ -285,11 +301,15 @@ abstract contract MajorityVotingBase is
function __MajorityVotingBase_init(
IDAO _dao,
VotingSettings calldata _votingSettings,
uint256 _minApprovals
TargetConfig calldata _targetConfig,
uint256 _minApprovals,
bytes calldata _pluginMetadata
) internal onlyInitializing {
__PluginUUPSUpgradeable_init(_dao);
_updateVotingSettings(_votingSettings);
_updateMinApprovals(_minApprovals);
_setTargetConfig(_targetConfig);
_updateMetadata(_pluginMetadata);
}

/// @notice Checks if this or the parent contract supports an interface by its ID.
Expand All @@ -301,12 +321,17 @@ abstract contract MajorityVotingBase is
public
view
virtual
override(ERC165Upgradeable, PluginUUPSUpgradeable, ProposalUpgradeable)
override(
ERC165Upgradeable,
MetadataExtensionUpgradeable,
PluginUUPSUpgradeable,
ProposalUpgradeable
)
returns (bool)
{
// In addition to the current IMajorityVoting interface, also support previous version
// that did not include the isMinApprovalReached() and minApproval() functions, same
// happens with MAJORITY_VOTING_BASE_INTERFACE which did not included updateMinApprovals().
// that did not include the `isMinApprovalReached` and `minApproval` functions, same
// happens with MAJORITY_VOTING_BASE_INTERFACE which did not include `updateMinApprovals`.
return
_interfaceId == MAJORITY_VOTING_BASE_INTERFACE_ID ||
_interfaceId == MAJORITY_VOTING_BASE_INTERFACE_ID ^ this.updateMinApprovals.selector ||
Expand Down Expand Up @@ -362,7 +387,9 @@ abstract contract MajorityVotingBase is
}

/// @inheritdoc IMajorityVoting
function canExecute(uint256 _proposalId) public view virtual returns (bool) {
function canExecute(
uint256 _proposalId
) public view virtual override(IMajorityVoting, IProposal) returns (bool) {
return _canExecute(_proposalId);
}

Expand Down Expand Up @@ -469,7 +496,7 @@ abstract contract MajorityVotingBase is
bool executed,
ProposalParameters memory parameters,
Tally memory tally,
IDAO.Action[] memory actions,
Action[] memory actions,
uint256 allowFailureMap
)
{
Expand All @@ -491,7 +518,6 @@ abstract contract MajorityVotingBase is
_updateVotingSettings(_votingSettings);
}

// todo TBD define if permission should be the same one as update settings
/// @notice Updates the minimal approval value.
/// @param _minApprovals The new minimal approval value.
function updateMinApprovals(
Expand All @@ -517,7 +543,7 @@ abstract contract MajorityVotingBase is
/// @return proposalId The ID of the proposal.
function createProposal(
bytes calldata _metadata,
IDAO.Action[] calldata _actions,
Action[] calldata _actions,
uint256 _allowFailureMap,
uint64 _startDate,
uint64 _endDate,
Expand All @@ -540,14 +566,19 @@ abstract contract MajorityVotingBase is
/// @notice Internal function to execute a vote. It assumes the queried proposal exists.
/// @param _proposalId The ID of the proposal.
function _execute(uint256 _proposalId) internal virtual {
proposals[_proposalId].executed = true;
Proposal storage proposal_ = proposals[_proposalId];

_executeProposal(
dao(),
_proposalId,
proposals[_proposalId].actions,
proposals[_proposalId].allowFailureMap
proposal_.executed = true;

_execute(
proposal_.targetConfig.target,
bytes32(_proposalId),
proposal_.actions,
proposal_.allowFailureMap,
proposal_.targetConfig.operation
);

emit ProposalExecuted(_proposalId);
Copy link

Choose a reason for hiding this comment

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

I can't see it being removed from the plugin side. Just to confirm

Copy link
Author

Choose a reason for hiding this comment

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

the event is defined in IProposal and emitted on each plugin implementation of IProposal

}

/// @notice Internal function to check if a voter can vote. It assumes the queried proposal exists.
Expand Down
Loading
Loading