-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Add GovernorTimelockControl address to TimelockController salt
#4432
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
Changes from all commits
4a9a6aa
00ff5e1
b63d484
bcb0b84
fd0ef64
5903861
ce91062
29a1b1d
4d21d32
225c6ec
3563815
e775b46
9dd7f39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'openzeppelin-solidity': major | ||
| --- | ||
|
|
||
| `GovernorTimelockControl`: Add the Governor instance address as part of the TimelockController operation `salt` to avoid operation id collisions between governors using the same TimelockController. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,8 +106,9 @@ abstract contract GovernorTimelockControl is IGovernorTimelock, Governor { | |
| } | ||
|
|
||
| uint256 delay = _timelock.getMinDelay(); | ||
| _timelockIds[proposalId] = _timelock.hashOperationBatch(targets, values, calldatas, 0, descriptionHash); | ||
| _timelock.scheduleBatch(targets, values, calldatas, 0, descriptionHash, delay); | ||
| bytes32 salt = _timelockSalt(descriptionHash); | ||
| _timelockIds[proposalId] = _timelock.hashOperationBatch(targets, values, calldatas, 0, salt); | ||
| _timelock.scheduleBatch(targets, values, calldatas, 0, salt, delay); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The decision to not have |
||
|
|
||
| emit ProposalQueued(proposalId, block.timestamp + delay); | ||
|
|
||
|
|
@@ -125,7 +126,7 @@ abstract contract GovernorTimelockControl is IGovernorTimelock, Governor { | |
| bytes32 descriptionHash | ||
| ) internal virtual override { | ||
| // execute | ||
| _timelock.executeBatch{value: msg.value}(targets, values, calldatas, 0, descriptionHash); | ||
| _timelock.executeBatch{value: msg.value}(targets, values, calldatas, 0, _timelockSalt(descriptionHash)); | ||
| // cleanup for refund | ||
| delete _timelockIds[proposalId]; | ||
| } | ||
|
|
@@ -177,4 +178,14 @@ abstract contract GovernorTimelockControl is IGovernorTimelock, Governor { | |
| emit TimelockChange(address(_timelock), address(newTimelock)); | ||
| _timelock = newTimelock; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Computes the {TimelockController} operation salt. | ||
| * | ||
| * It is computed with the governor address itself to avoid collisions across governor instances using the | ||
| * same timelock. | ||
| */ | ||
| function _timelockSalt(bytes32 descriptionHash) private view returns (bytes32) { | ||
| return bytes20(address(this)) ^ descriptionHash; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to use an If a governor instance wants to purposely block another, it'll require to mine the most significant 20 bytes of the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is an interesting proposal. I'd have done a full hash, just because it would have been clearer to everyone what is going on ... but IMO that is also a valid option. |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.