From 18537023fcd2cd14d34afc95aba361d381f257fe Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 3 Aug 2023 14:56:49 +0200 Subject: [PATCH] document memory/storage insonsistency has beeing the result of gas comparison --- contracts/governance/extensions/GovernorStorage.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contracts/governance/extensions/GovernorStorage.sol b/contracts/governance/extensions/GovernorStorage.sol index fab93b5fcae..6443b789541 100644 --- a/contracts/governance/extensions/GovernorStorage.sol +++ b/contracts/governance/extensions/GovernorStorage.sol @@ -51,6 +51,7 @@ abstract contract GovernorStorage is Governor { * @dev Version of {IGovernorTimelock-queue} with only `proposalId` as an argument. */ function queue(uint256 proposalId) public virtual { + // here, using storage is more efficient than memory ProposalDetails storage details = _proposalDetails[proposalId]; queue(details.targets, details.values, details.calldatas, details.descriptionHash); } @@ -59,6 +60,7 @@ abstract contract GovernorStorage is Governor { * @dev Version of {IGovernor-execute} with only `proposalId` as an argument. */ function execute(uint256 proposalId) public payable virtual { + // here, using storage is more efficient than memory ProposalDetails storage details = _proposalDetails[proposalId]; execute(details.targets, details.values, details.calldatas, details.descriptionHash); } @@ -67,6 +69,7 @@ abstract contract GovernorStorage is Governor { * @dev ProposalId version of {IGovernor-cancel}. */ function cancel(uint256 proposalId) public virtual { + // here, using storage is more efficient than memory ProposalDetails storage details = _proposalDetails[proposalId]; cancel(details.targets, details.values, details.calldatas, details.descriptionHash); } @@ -84,6 +87,7 @@ abstract contract GovernorStorage is Governor { function proposalDetails( uint256 proposalId ) public view virtual returns (address[] memory, uint256[] memory, bytes[] memory, bytes32) { + // here, using memory is more efficient than storage ProposalDetails memory details = _proposalDetails[proposalId]; if (details.descriptionHash == 0) { revert GovernorNonexistentProposal(proposalId);