From d0064031295132fe66f7f3a5d269d0e539218f13 Mon Sep 17 00:00:00 2001 From: OneTony Date: Mon, 21 Jul 2025 18:31:31 +0300 Subject: [PATCH 1/4] fix: budget cap dos --- .../governance/IProposalValidator.sol | 3 +- .../snapshots/abi/ProposalValidator.json | 10 +++ .../snapshots/semver-lock.json | 4 +- .../src/governance/ProposalValidator.sol | 36 ++++++++- .../test/governance/ProposalValidator.t.sol | 74 +++++++++++++++++-- 5 files changed, 115 insertions(+), 12 deletions(-) diff --git a/packages/contracts-bedrock/interfaces/governance/IProposalValidator.sol b/packages/contracts-bedrock/interfaces/governance/IProposalValidator.sol index 7d93349984ea2..b3af292941650 100644 --- a/packages/contracts-bedrock/interfaces/governance/IProposalValidator.sol +++ b/packages/contracts-bedrock/interfaces/governance/IProposalValidator.sol @@ -31,6 +31,7 @@ interface IProposalValidator is ISemver { error ProposalValidator_InvalidProposer(); error ProposalValidator_InvalidProposal(); error ProposalValidator_InvalidVotingModule(); + error ProposalValidator_AttestationCreatedAfterLastVotingCycle(); event ProposalSubmitted( bytes32 indexed proposalHash, @@ -130,7 +131,7 @@ interface IProposalValidator is ISemver { function approveProposal(bytes32 _proposalHash, bytes32 _attestationUid) external; - function canApproveProposal(bytes32 _attestationUid, address _delegate) external view returns (bool canApprove_); + function canApproveProposal(bytes32 _attestationUid, address _delegate, bytes32 _proposalHash) external view returns (bool canApprove_); function moveToVoteProtocolOrGovernorUpgradeProposal( uint248 _againstThreshold, diff --git a/packages/contracts-bedrock/snapshots/abi/ProposalValidator.json b/packages/contracts-bedrock/snapshots/abi/ProposalValidator.json index 2afaef89b24f9..3d2aaab9b4bfc 100644 --- a/packages/contracts-bedrock/snapshots/abi/ProposalValidator.json +++ b/packages/contracts-bedrock/snapshots/abi/ProposalValidator.json @@ -101,6 +101,11 @@ "internalType": "address", "name": "_delegate", "type": "address" + }, + { + "internalType": "bytes32", + "name": "_proposalHash", + "type": "bytes32" } ], "name": "canApproveProposal", @@ -788,6 +793,11 @@ "name": "VotingCycleDataSet", "type": "event" }, + { + "inputs": [], + "name": "ProposalValidator_AttestationCreatedAfterLastVotingCycle", + "type": "error" + }, { "inputs": [], "name": "ProposalValidator_AttestationExpired", diff --git a/packages/contracts-bedrock/snapshots/semver-lock.json b/packages/contracts-bedrock/snapshots/semver-lock.json index fd811a1f8d457..79413823b41df 100644 --- a/packages/contracts-bedrock/snapshots/semver-lock.json +++ b/packages/contracts-bedrock/snapshots/semver-lock.json @@ -176,8 +176,8 @@ "sourceCodeHash": "0x18f43b227decd0f2a895b8b55e23fa6a47706697c272bbf2482b3f912be446e1" }, "src/governance/ProposalValidator.sol:ProposalValidator": { - "initCodeHash": "0xbac284f6ec21a5d65d5b86d7e6406e0805d77e15dc4bd66397f0111701110e0e", - "sourceCodeHash": "0x58048692d1da18d17958b2dc950055ae2a58ab645385b0aed3528b289dfee21d" + "initCodeHash": "0x6bfc253bb99c0caac5840740bc476bc8f66ced97956e0638c2e9c0e412e0ca86", + "sourceCodeHash": "0x289e7dee40106ffdb3f53b8308c6f80419794504b368e95d5e4d21b65f81d895" }, "src/legacy/DeployerWhitelist.sol:DeployerWhitelist": { "initCodeHash": "0x53099379ed48b87f027d55712dbdd1da7d7099925426eb0531da9c0012e02c29", diff --git a/packages/contracts-bedrock/src/governance/ProposalValidator.sol b/packages/contracts-bedrock/src/governance/ProposalValidator.sol index c871a2b9431d4..05b4343249454 100644 --- a/packages/contracts-bedrock/src/governance/ProposalValidator.sol +++ b/packages/contracts-bedrock/src/governance/ProposalValidator.sol @@ -92,6 +92,9 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { /// @notice Thrown when the voting module address is invalid (zero address). error ProposalValidator_InvalidVotingModule(); + /// @notice Thrown when the attestation was created after the last voting cycle. + error ProposalValidator_AttestationCreatedAfterLastVotingCycle(); + /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ @@ -587,7 +590,7 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { } // validate the attestation - _validateTopDelegateAttestation(_attestationUid, _msgSender()); + _validateTopDelegateAttestation(_attestationUid, _msgSender(), _proposalHash); // store the approval proposal.delegateApprovals[_delegate] = true; @@ -599,9 +602,19 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { /// @notice Checks if a delegate can approve a proposal. /// @dev Helper function for UI integration. /// @param _attestationUid The UID of the attestation to check. + /// @param _delegate The delegate to check the attestation for. + /// @param _proposalHash The hash of the proposal to check the attestation for. /// @return canApprove_ True if the delegate can approve the proposal, false otherwise. - function canApproveProposal(bytes32 _attestationUid, address _delegate) external view returns (bool canApprove_) { - canApprove_ = _validateTopDelegateAttestation(_attestationUid, _delegate); + function canApproveProposal( + bytes32 _attestationUid, + address _delegate, + bytes32 _proposalHash + ) + external + view + returns (bool canApprove_) + { + canApprove_ = _validateTopDelegateAttestation(_attestationUid, _delegate, _proposalHash); } /// @notice Moves a Protocol or Governor Upgrade proposal to vote by proposing it on the Governor. @@ -936,13 +949,21 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { /// @return canApprove_ True if the attestation is valid, false otherwise. function _validateTopDelegateAttestation( bytes32 _attestationUid, - address _delegate + address _delegate, + bytes32 _proposalHash ) internal view returns (bool canApprove_) { Attestation memory attestation = IEAS(Predeploys.EAS).getAttestation(_attestationUid); + ProposalData storage proposal = _proposals[_proposalHash]; + // get the previous voting cycle data, proposal.votingCycle should never be 0 + // since voting cycles already exist before the ProposalValidator is deployed + VotingCycleData memory previousVotingCycleData = votingCycles[proposal.votingCycle - 1]; + if (previousVotingCycleData.startingTimestamp == 0) { + revert ProposalValidator_InvalidVotingCycle(); + } // Check if attestation exists, equivalent to calling EAS.isAttestationValid(_attestationUid) if (attestation.uid == bytes32(0)) { @@ -959,6 +980,13 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { revert ProposalValidator_AttestationRevoked(); } + // since the attestations are updated daily we should only allow attestations + // created before the last voting cycle of the proposal + // check if attestation was created after the previous voting cycle + if (attestation.time > previousVotingCycleData.startingTimestamp + previousVotingCycleData.duration) { + revert ProposalValidator_AttestationCreatedAfterLastVotingCycle(); + } + (, bool _includePartialDelegation,) = abi.decode(attestation.data, (string, bool, string)); // check if the attestation includes partial delegation or the recipient is not the caller diff --git a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol index edab6a51f1a4c..995c8ef399726 100644 --- a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol +++ b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol @@ -1847,6 +1847,17 @@ contract ProposalValidator_SubmitFundingProposal_TestFail is ProposalValidator_I /// @title ProposalValidator_ApproveProposal_Test /// @notice Happy path tests for approveProposal function contract ProposalValidator_ApproveProposal_Test is ProposalValidator_Init { + function setUp() public override { + super.setUp(); + + // create a new voting cycle + // cycle number decreased by 1 and start time CYCLE_DURATION before the current cycle + vm.prank(owner); + validator.setVotingCycleData( + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + ); + } + function test_approveProposal_succeeds(bytes32 _proposalHash, uint8 proposalTypeValue) public { // Ensure the proposal hash is not 0 vm.assume(_proposalHash != bytes32(0)); @@ -1924,6 +1935,18 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { validator.approveProposal(_proposalHash, topDelegateAttestation_A); } + function test_approveProposal_invalidVotingCycle_reverts(bytes32 _proposalHash, uint8 proposalTypeValue) public { + // Bound the proposal type to valid enum values (0-4) + proposalTypeValue = uint8(bound(proposalTypeValue, 0, 4)); + ProposalValidator.ProposalType proposalType = ProposalValidator.ProposalType(proposalTypeValue); + // set proposal data so that the proposal exists + validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); + + vm.expectRevert(IProposalValidator.ProposalValidator_InvalidVotingCycle.selector); + vm.prank(topDelegate_A); + validator.approveProposal(_proposalHash, topDelegateAttestation_A); + } + function test_approveProposal_invalidSchema_reverts(bytes32 _proposalHash, uint8 proposalTypeValue) public { // Bound the proposal type to valid enum values (0-4) proposalTypeValue = uint8(bound(proposalTypeValue, 0, 4)); @@ -1953,6 +1976,11 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { // set proposal data so that the proposal exists validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); + // set the voting cycle data of the previous cycle + vm.prank(owner); + validator.setVotingCycleData( + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + ); vm.expectRevert(IProposalValidator.ProposalValidator_InvalidAttestationSchema.selector); vm.prank(topDelegate_A); @@ -1965,6 +1993,11 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { ProposalValidator.ProposalType proposalType = ProposalValidator.ProposalType(proposalTypeValue); // set proposal data so that the proposal exists validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); + // set the voting cycle data of the previous cycle + vm.prank(owner); + validator.setVotingCycleData( + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + ); // revoke the attestation vm.prank(owner); @@ -1996,6 +2029,11 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { // Set mock proposal data of a random proposal in the validator contract validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); + // set the voting cycle data of the previous cycle + vm.prank(owner); + validator.setVotingCycleData( + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + ); // Expect the invalid attestation error to be reverted vm.expectRevert(IProposalValidator.ProposalValidator_InvalidAttestation.selector); @@ -2015,6 +2053,11 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { // Set mock proposal data of a random proposal in the validator contract validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); + // set the voting cycle data of the previous cycle + vm.prank(owner); + validator.setVotingCycleData( + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + ); // create an attestation with partial delegation vm.prank(owner); @@ -2054,6 +2097,11 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { // Set mock proposal data of a random proposal in the validator contract validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); + // set the voting cycle data of the previous cycle + vm.prank(owner); + validator.setVotingCycleData( + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + ); // Expect the invalid attestation error to be reverted when attestation doesn't exist vm.expectRevert(IProposalValidator.ProposalValidator_InvalidAttestation.selector); @@ -2065,20 +2113,36 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { /// @title ProposalValidator_CanApproveProposal_Test /// @notice Tests for the canApproveProposal function contract ProposalValidator_CanApproveProposal_Test is ProposalValidator_Init { - function test_canApproveProposal_returnTrue_succeeds() public view { + function test_canApproveProposal_returnTrue_succeeds(bytes32 _proposalHash, uint8 proposalTypeValue) public { + // Bound the proposal type to valid enum values (0-4) + proposalTypeValue = uint8(bound(proposalTypeValue, 0, 4)); + ProposalValidator.ProposalType proposalType = ProposalValidator.ProposalType(proposalTypeValue); + // set the voting cycle data of the previous cycle + validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); + vm.prank(owner); + validator.setVotingCycleData( + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + ); + // Attestation already created in setUp - bool canApprove = validator.canApproveProposal(topDelegateAttestation_A, topDelegate_A); + bool canApprove = validator.canApproveProposal(topDelegateAttestation_A, topDelegate_A, _proposalHash); assertTrue(canApprove); } - function test_canApproveProposal_returnFalse_succeeds(bytes32 attestationUid, address delegate) public { + function test_canApproveProposal_returnFalse_succeeds( + bytes32 _attestationUid, + address _delegate, + bytes32 _proposalHash + ) + public + { // Ensure the attestation uid is not one of the top delegates - vm.assume(attestationUid != topDelegateAttestation_A); + vm.assume(_attestationUid != topDelegateAttestation_A); bool canApprove; // Expect the invalid attestation error to be reverted vm.expectRevert(IProposalValidator.ProposalValidator_InvalidAttestation.selector); - try validator.canApproveProposal(attestationUid, delegate) returns (bool result_) { + try validator.canApproveProposal(_attestationUid, _delegate, _proposalHash) returns (bool result_) { canApprove = result_; } catch { canApprove = false; From 18fb7dfdd4d0242c5281431e0a2c6bd91255346d Mon Sep 17 00:00:00 2001 From: OneTony Date: Mon, 21 Jul 2025 19:53:05 +0300 Subject: [PATCH 2/4] fix: invalid proposal case --- .../snapshots/semver-lock.json | 4 ++-- .../src/governance/ProposalValidator.sol | 19 +++++++++++-------- .../test/governance/ProposalValidator.t.sol | 11 ++++++++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/contracts-bedrock/snapshots/semver-lock.json b/packages/contracts-bedrock/snapshots/semver-lock.json index 79413823b41df..ad21f166cd02f 100644 --- a/packages/contracts-bedrock/snapshots/semver-lock.json +++ b/packages/contracts-bedrock/snapshots/semver-lock.json @@ -176,8 +176,8 @@ "sourceCodeHash": "0x18f43b227decd0f2a895b8b55e23fa6a47706697c272bbf2482b3f912be446e1" }, "src/governance/ProposalValidator.sol:ProposalValidator": { - "initCodeHash": "0x6bfc253bb99c0caac5840740bc476bc8f66ced97956e0638c2e9c0e412e0ca86", - "sourceCodeHash": "0x289e7dee40106ffdb3f53b8308c6f80419794504b368e95d5e4d21b65f81d895" + "initCodeHash": "0xbde4767f895dc1c2409f82ac812725724d9d36deb98587182cc062388150254a", + "sourceCodeHash": "0xd45f7b1024035d24709e37c179f6d9400b023a3bac3ee15b289554c19fe56132" }, "src/legacy/DeployerWhitelist.sol:DeployerWhitelist": { "initCodeHash": "0x53099379ed48b87f027d55712dbdd1da7d7099925426eb0531da9c0012e02c29", diff --git a/packages/contracts-bedrock/src/governance/ProposalValidator.sol b/packages/contracts-bedrock/src/governance/ProposalValidator.sol index 05b4343249454..3f2885ba4087a 100644 --- a/packages/contracts-bedrock/src/governance/ProposalValidator.sol +++ b/packages/contracts-bedrock/src/governance/ProposalValidator.sol @@ -575,7 +575,7 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { address _delegate = _msgSender(); ProposalData storage proposal = _proposals[_proposalHash]; // check if the proposal exists - if (proposal.proposer == address(0)) { + if (proposal.proposer == address(0) || proposal.votingCycle == 0) { revert ProposalValidator_ProposalDoesNotExist(); } @@ -590,7 +590,7 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { } // validate the attestation - _validateTopDelegateAttestation(_attestationUid, _msgSender(), _proposalHash); + _validateTopDelegateAttestation(_attestationUid, _msgSender(), proposal.votingCycle - 1); // store the approval proposal.delegateApprovals[_delegate] = true; @@ -614,7 +614,13 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { view returns (bool canApprove_) { - canApprove_ = _validateTopDelegateAttestation(_attestationUid, _delegate, _proposalHash); + // TODO: this function should be fixed in OPT-957 + ProposalData storage proposal = _proposals[_proposalHash]; + if (proposal.votingCycle == 0) { + return false; + } + + canApprove_ = _validateTopDelegateAttestation(_attestationUid, _delegate, proposal.votingCycle - 1); } /// @notice Moves a Protocol or Governor Upgrade proposal to vote by proposing it on the Governor. @@ -950,17 +956,14 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { function _validateTopDelegateAttestation( bytes32 _attestationUid, address _delegate, - bytes32 _proposalHash + uint256 _lastVotingCycle ) internal view returns (bool canApprove_) { Attestation memory attestation = IEAS(Predeploys.EAS).getAttestation(_attestationUid); - ProposalData storage proposal = _proposals[_proposalHash]; - // get the previous voting cycle data, proposal.votingCycle should never be 0 - // since voting cycles already exist before the ProposalValidator is deployed - VotingCycleData memory previousVotingCycleData = votingCycles[proposal.votingCycle - 1]; + VotingCycleData memory previousVotingCycleData = votingCycles[_lastVotingCycle]; if (previousVotingCycleData.startingTimestamp == 0) { revert ProposalValidator_InvalidVotingCycle(); } diff --git a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol index 995c8ef399726..5bd0cc57297e3 100644 --- a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol +++ b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol @@ -2129,7 +2129,7 @@ contract ProposalValidator_CanApproveProposal_Test is ProposalValidator_Init { assertTrue(canApprove); } - function test_canApproveProposal_returnFalse_succeeds( + function test_canApproveProposal_returnFalseRevert_succeeds( bytes32 _attestationUid, address _delegate, bytes32 _proposalHash @@ -2150,6 +2150,15 @@ contract ProposalValidator_CanApproveProposal_Test is ProposalValidator_Init { assertEq(canApprove, false); } + + function test_canApproveProposal_returnFalseProposalNotFound_reverts(bytes32 _proposalHash) public { + validator.setProposalData( + _proposalHash, topDelegate_A, ProposalValidator.ProposalType.ProtocolOrGovernorUpgrade, false, 0, 0 + ); + + bool canApprove = validator.canApproveProposal(topDelegateAttestation_A, topDelegate_A, _proposalHash); + assertEq(canApprove, false); + } } /// @title ProposalValidator_MoveToVoteProtocolOrGovernorUpgradeProposal_Test From 563c8c9cad1f6ac678e8cdb6b8811055be2b3618 Mon Sep 17 00:00:00 2001 From: OneTony Date: Mon, 21 Jul 2025 20:45:55 +0300 Subject: [PATCH 3/4] fix: test --- .../contracts-bedrock/test/governance/ProposalValidator.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol index 5bd0cc57297e3..3c2504a9b4f5a 100644 --- a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol +++ b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol @@ -1854,7 +1854,7 @@ contract ProposalValidator_ApproveProposal_Test is ProposalValidator_Init { // cycle number decreased by 1 and start time CYCLE_DURATION before the current cycle vm.prank(owner); validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD + CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD ); } From 8546f56a3851b8bf10312ab2c734eecb5a6a8007 Mon Sep 17 00:00:00 2001 From: OneTony Date: Mon, 21 Jul 2025 20:56:36 +0300 Subject: [PATCH 4/4] fix: tests --- .../src/governance/ProposalValidator.sol | 2 ++ .../test/governance/ProposalValidator.t.sol | 28 +++++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/contracts-bedrock/src/governance/ProposalValidator.sol b/packages/contracts-bedrock/src/governance/ProposalValidator.sol index 3f2885ba4087a..681c73e180d2a 100644 --- a/packages/contracts-bedrock/src/governance/ProposalValidator.sol +++ b/packages/contracts-bedrock/src/governance/ProposalValidator.sol @@ -590,6 +590,8 @@ contract ProposalValidator is OwnableUpgradeable, ReinitializableBase, ISemver { } // validate the attestation + // proposal.votingCycle should never be 0, voting cycles already exist before the ProposalValidator is deployed + // and should be set by the OP Foundation _validateTopDelegateAttestation(_attestationUid, _msgSender(), proposal.votingCycle - 1); // store the approval diff --git a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol index 3c2504a9b4f5a..fd60076f71c81 100644 --- a/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol +++ b/packages/contracts-bedrock/test/governance/ProposalValidator.t.sol @@ -1853,9 +1853,7 @@ contract ProposalValidator_ApproveProposal_Test is ProposalValidator_Init { // create a new voting cycle // cycle number decreased by 1 and start time CYCLE_DURATION before the current cycle vm.prank(owner); - validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD - ); + validator.setVotingCycleData(CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD); } function test_approveProposal_succeeds(bytes32 _proposalHash, uint8 proposalTypeValue) public { @@ -1978,9 +1976,7 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); // set the voting cycle data of the previous cycle vm.prank(owner); - validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD - ); + validator.setVotingCycleData(CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD); vm.expectRevert(IProposalValidator.ProposalValidator_InvalidAttestationSchema.selector); vm.prank(topDelegate_A); @@ -1995,9 +1991,7 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); // set the voting cycle data of the previous cycle vm.prank(owner); - validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD - ); + validator.setVotingCycleData(CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD); // revoke the attestation vm.prank(owner); @@ -2031,9 +2025,7 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); // set the voting cycle data of the previous cycle vm.prank(owner); - validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD - ); + validator.setVotingCycleData(CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD); // Expect the invalid attestation error to be reverted vm.expectRevert(IProposalValidator.ProposalValidator_InvalidAttestation.selector); @@ -2055,9 +2047,7 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); // set the voting cycle data of the previous cycle vm.prank(owner); - validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD - ); + validator.setVotingCycleData(CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD); // create an attestation with partial delegation vm.prank(owner); @@ -2099,9 +2089,7 @@ contract ProposalValidator_ApproveProposal_TestFail is ProposalValidator_Init { validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); // set the voting cycle data of the previous cycle vm.prank(owner); - validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD - ); + validator.setVotingCycleData(CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD); // Expect the invalid attestation error to be reverted when attestation doesn't exist vm.expectRevert(IProposalValidator.ProposalValidator_InvalidAttestation.selector); @@ -2120,9 +2108,7 @@ contract ProposalValidator_CanApproveProposal_Test is ProposalValidator_Init { // set the voting cycle data of the previous cycle validator.setProposalData(_proposalHash, topDelegate_A, proposalType, false, 0, CYCLE_NUMBER); vm.prank(owner); - validator.setVotingCycleData( - CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, START_TIMESTAMP, DISTRIBUTION_THRESHOLD - ); + validator.setVotingCycleData(CYCLE_NUMBER - 1, START_TIMESTAMP - DURATION, DURATION, DISTRIBUTION_THRESHOLD); // Attestation already created in setUp bool canApprove = validator.canApproveProposal(topDelegateAttestation_A, topDelegate_A, _proposalHash);