From 01943be25e15a075587c170e43aa1291a0b781f7 Mon Sep 17 00:00:00 2001 From: Aleksandr Tarelkin <tarelkinaa@bk.ru> Date: Fri, 5 Jul 2024 13:09:28 +0300 Subject: [PATCH] fix miss --- .../committees/EmergencyExecutionCommittee.sol | 6 +++--- contracts/committees/ProposalsList.sol | 14 +++++++------- contracts/committees/TiebreakerCore.sol | 2 +- test/scenario/tiebraker.t.sol | 1 - 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/contracts/committees/EmergencyExecutionCommittee.sol b/contracts/committees/EmergencyExecutionCommittee.sol index 6586dfc3..1c670227 100644 --- a/contracts/committees/EmergencyExecutionCommittee.sol +++ b/contracts/committees/EmergencyExecutionCommittee.sol @@ -55,10 +55,10 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList { function _encodeEmergencyExecute(uint256 proposalId) private - view + pure returns (bytes memory proposalData, bytes32 key) { - proposalData = abi.encode(ProposalType.EmergencyExecute, bytes32(proposalId)); + proposalData = abi.encode(ProposalType.EmergencyExecute, proposalId); key = keccak256(proposalData); } @@ -87,7 +87,7 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList { ); } - function _encodeEmergencyResetProposalKey() internal view returns (bytes32) { + function _encodeEmergencyResetProposalKey() internal pure returns (bytes32) { return keccak256(abi.encode(ProposalType.EmergencyReset, bytes32(0))); } } diff --git a/contracts/committees/ProposalsList.sol b/contracts/committees/ProposalsList.sol index ecdf9786..625a5841 100644 --- a/contracts/committees/ProposalsList.sol +++ b/contracts/committees/ProposalsList.sol @@ -8,30 +8,30 @@ contract ProposalsList { EnumerableProposals.Bytes32ToProposalMap internal _proposals; - function getProposals(uint256 offset, uint256 limit) public returns (Proposal[] memory proposals) { + function getProposals(uint256 offset, uint256 limit) public view returns (Proposal[] memory proposals) { bytes32[] memory keys = _proposals.orederedKeys(offset, limit); uint256 length = keys.length; - proposals = new Proposal[](keys.length); + proposals = new Proposal[](length); - for (uint256 i = 0; i < keys.length; ++i) { + for (uint256 i = 0; i < length; ++i) { proposals[i] = _proposals.get(keys[i]); } } - function getProposalAt(uint256 index) public returns (Proposal memory) { + function getProposalAt(uint256 index) public view returns (Proposal memory) { return _proposals.at(index); } - function getProposal(bytes32 key) public returns (Proposal memory) { + function getProposal(bytes32 key) public view returns (Proposal memory) { return _proposals.get(key); } - function proposalsLength() public returns (uint256) { + function proposalsLength() public view returns (uint256) { return _proposals.length(); } - function orederedKeys(uint256 offset, uint256 limit) public returns (bytes32[] memory) { + function orederedKeys(uint256 offset, uint256 limit) public view returns (bytes32[] memory) { return _proposals.orederedKeys(offset, limit); } diff --git a/contracts/committees/TiebreakerCore.sol b/contracts/committees/TiebreakerCore.sol index 3f45e90a..a380036a 100644 --- a/contracts/committees/TiebreakerCore.sol +++ b/contracts/committees/TiebreakerCore.sol @@ -58,7 +58,7 @@ contract TiebreakerCore is HashConsensus, ProposalsList { } function _encodeScheduleProposal(uint256 proposalId) internal pure returns (bytes memory data, bytes32 key) { - data = abi.encode(ProposalType.ScheduleProposal, data); + data = abi.encode(ProposalType.ScheduleProposal, proposalId); key = keccak256(data); } diff --git a/test/scenario/tiebraker.t.sol b/test/scenario/tiebraker.t.sol index 1c465fbf..43890ccf 100644 --- a/test/scenario/tiebraker.t.sol +++ b/test/scenario/tiebraker.t.sol @@ -157,7 +157,6 @@ contract TiebreakerScenarioTest is ScenarioTestBlueprint { ); assert(support == quorum); - uint256 lastProposalId = EmergencyProtectedTimelock(address(_dualGovernance.TIMELOCK())).getProposalsCount(); _tiebreakerCommittee.executeSealableResume(address(_WITHDRAWAL_QUEUE)); assertEq(_WITHDRAWAL_QUEUE.isPaused(), false);