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

Update hashProposal visibility to view #5097

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/popular-horses-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

`Governor`: Change `hashProposal()` visibility to view.
12 changes: 8 additions & 4 deletions contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,20 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72
* advance, before the proposal is submitted.
*
* Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the
* same proposal (with same operation and same description) will have the same id if submitted on multiple governors
* across multiple networks. This also means that in order to execute the same operation twice (on the same
* governor) the proposer will have to change the description in order to avoid proposal id conflicts.
* same proposal will share its id with another governor in a different network where the same proposal was
* submitted. We recommend using the description field as a discriminator to avoid proposal id conflicts.
* Similarly, developers can add both `chainId` and `address(this)` to the hash computation by overriding
* this function.
*
* IMPORTANT: Overriding this function may have unexpected effects after an upgrade. Consider to verify
* that the new implementation doesn't allow a proposer to forge an id.
*/
function hashProposal(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public pure virtual returns (uint256) {
) public view virtual returns (uint256) {
return uint256(keccak256(abi.encode(targets, values, calldatas, descriptionHash)));
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/IGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ interface IGovernor is IERC165, IERC6372 {
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) external pure returns (uint256);
) external view returns (uint256);

/**
* @notice module:core
Expand Down