-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Full TimelockGuard implementation #17584
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
Merged
Merged
Changes from all commits
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
cf4270b
feat: implement configureTimelockGuard function
maurelian 290ec17
feat: implement clearTimelockGuard function
maurelian ef1ccbd
refactor: extract guard checking logic to internal helper function
maurelian a95ed01
feat: implement cancellationThreshold function
maurelian a5054e6
feat: add placeholder functions for remaining TimelockGuard functiona…
maurelian 6084abe
Self review fixes
maurelian e3121ca
Fix warnings on unimplemented functions
maurelian d117aa7
Fix names of test functions
maurelian 56e366d
Satisfy semgrep by removing revert with string
maurelian 4c79044
Remove arg names from unimplemented functions
maurelian 3de308e
Snapshots
maurelian 052e4e6
Add interface
maurelian 54d5e92
Simplify cancellationThreshold() getter
maurelian afdbaf1
Replace _getGuard with isGuardEnabled
maurelian 3f82d24
Allow a timelock delay of zero
maurelian cea893e
TimelockGuard: Add scheduleTransaction()
maurelian c90de48
Add todo note
maurelian c17a782
Pseudocode draft of a non-nested timelock
0d31d51
Remove signatures field from ExecTransactionParams
maurelian 0562482
Refactor tests with improve utils (_getDummyTx, _getSignaturesForTx)
maurelian 227f9eb
Test for TransactionCancelled event
maurelian e7f90ce
Further improve util functions
maurelian 5b1cfcc
Add approve hash test case
maurelian 756cdff
fix warnings
maurelian bac2f8a
Use correct typing for Safe addresses
maurelian e92ed3f
Add additional scheduleTransaction tests
maurelian 18f54e6
Enable specifying which safeInstance in utility functions
maurelian 6782b1b
Change cancelTransaction to accept a tx hash
maurelian 4fccd48
Add increaseCancellationThreshold to cancelTransaction
maurelian b792e04
Add configured boolean to guard config
maurelian 3f407e1
Fix signature reuse vulnerability in cancelTransaction
maurelian 37da3d5
Move signature verification before existence check in scheduleTransac…
maurelian 43d7871
Remove unused console.logs
maurelian 8c9fbf1
Fix increaseCancellationThreshold inputs
maurelian b28d653
Separate cancellation threshold events from transaction cancellation
maurelian 4fff3d1
Remove unused _txHash argument from resetCancellation function
maurelian 56238e8
Update ITimelockGuard to match implementation
maurelian 1856abc
Use configured flag instead of timelockDelay check in clearTimelockGuard
maurelian 4a9f2e2
Add configuration check to scheduleTransaction and fix test names
maurelian 486ab05
Implement checkTransaction
maurelian bf20466
Add itest placeholder contract
maurelian ca166ef
Add comment to checkAfterExecution body
maurelian 8b621c4
pre-pr checks
maurelian 04ad47d
Remove GuardConfig.configured boolean field
maurelian b977666
Remove clearTimelockGuard
maurelian 581cab0
Refactor: Add TransactionBuilder library
maurelian c84267d
Add unreachable AlreadyExecuted error
maurelian 733a6e1
Add integration tests
maurelian 5770509
Add getPendingTransactions function and tests
maurelian 572d6cf
Add tests for getScheduledTransaction
maurelian c8b655c
Add _ prefix in front of internal mappings
maurelian df3daa6
Rename viewTimelockGuard to timelockSafeConfigurationper specs
maurelian 072c1b4
Add maxCancellationThreshold
maurelian 487b098
Improve names on getter functions
maurelian 93256f2
Remove @dev tags with invariants
maurelian daad53b
Update configureTimelockGuard to accept and validate signatures outsi…
maurelian 75bc23b
Refactor: use a single struct to store all state for a given Safe
maurelian a5ea6ee
Do not unnecessarily reset cancellation threshold when config set to 0
maurelian 4d26c46
Revert "Update configureTimelockGuard to accept and validate signatur…
maurelian 5fc7d25
Move timelockDelay out of unnecessary struct
maurelian f8ac2f8
Add top level detail natspec, reorder functions by vis and mutability
maurelian 0a77d01
Remove test that does not conform to spec
maurelian 34b77e5
Add cancelTransactionOnSafe to interface as reverting function
maurelian 2b16f8e
Add many more comments
maurelian e55f7a1
Apply suggestions from code review
maurelian 4add3cd
Fix ITimelockGuard iface to match impl
maurelian 374824c
Rename arguments for consistency
maurelian c615461
Add/fixup @param on events
maurelian 16ac7c3
Small fixes
maurelian 5df4668
Fix ITimelockGuard declaration
maurelian 2694a95
Improve names on getter functions
maurelian c96b476
Move ExecTransactionParams into TimelockGuard.sol
maurelian e7e8016
Address comment nits
maurelian 1912649
Add TimelockGuard_MaxCancellationThreshold_Test and _deploySafe helper
maurelian ba9ac1c
Fix up iface and comment typos
maurelian 45ad7b9
Fix storage lookup in test
maurelian 5f3dca6
Add enum Transaction state and remove cancelled/executed booleans
maurelian 0ef9df5
add /// @custom:field on ScheduledTransaction struct
maurelian 2bb1971
add /// @custom:field on ExecTransactionParams struct
maurelian f3905ee
Add SemverComp to enforce minimum Safe version
maurelian c7e9eb4
Rename empty function to signCancellationForSafe
maurelian 0d5dac0
Fix location of external view functions
maurelian 24f20a1
Add some more comments where helpful.
maurelian 5b68fb4
Further expand on the maxCancellationThreshold rationale
maurelian 2daf9a1
Clarify blocking threshold
maurelian f5618ac
iFace fixes
maurelian 1d709b3
Fix iface
maurelian ee0cde7
Move update of tx state, event emission and cancellationThreshold int…
maurelian fa7c6d6
Simplified comment
maurelian de6e131
remove unclear comments
maurelian 93e0ca9
fix semgrep sol-style-use-abi-encodecall
maurelian 433c048
snapshots
maurelian 82eb756
Add course of actions table
maurelian f768b54
Remove unnecessary address arg from signCancellation
maurelian 3374a34
Merge branch 'develop' into jm/timelock-single-struct
maurelian d9f2f86
Fix test names
maurelian db0f5af
Fix test name validation
maurelian a19dbc0
Remove enabled guard check from configureTimelockGuard
maurelian 06ae5e2
Allow <ContractName>_Integration_Test in tests
maurelian 05362ab
Add isExcludedTest in checkContractNameFilePath()
maurelian 7972739
Update semver-lock
maurelian ab455d3
Merge branch 'develop' into jm/timelock-single-struct
maurelian 40f24d5
Fix typo
maurelian 8997094
fix typo in tests
maurelian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
packages/contracts-bedrock/interfaces/safe/ITimelockGuard.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.4; | ||
|
||
library Enum { | ||
type Operation is uint8; | ||
} | ||
|
||
interface ITimelockGuard { | ||
maurelian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
enum TransactionState { | ||
NotScheduled, | ||
Pending, | ||
Cancelled, | ||
Executed | ||
} | ||
struct ScheduledTransaction { | ||
uint256 executionTime; | ||
TransactionState state; | ||
ExecTransactionParams params; | ||
} | ||
maurelian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
struct ExecTransactionParams { | ||
address to; | ||
uint256 value; | ||
bytes data; | ||
Enum.Operation operation; | ||
uint256 safeTxGas; | ||
uint256 baseGas; | ||
uint256 gasPrice; | ||
address gasToken; | ||
address payable refundReceiver; | ||
} | ||
|
||
error TimelockGuard_GuardNotConfigured(); | ||
error TimelockGuard_GuardNotEnabled(); | ||
error TimelockGuard_GuardStillEnabled(); | ||
error TimelockGuard_InvalidTimelockDelay(); | ||
error TimelockGuard_TransactionAlreadyCancelled(); | ||
error TimelockGuard_TransactionAlreadyScheduled(); | ||
error TimelockGuard_TransactionNotScheduled(); | ||
maurelian marked this conversation as resolved.
Show resolved
Hide resolved
maurelian marked this conversation as resolved.
Show resolved
Hide resolved
maurelian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
error TimelockGuard_TransactionNotReady(); | ||
error TimelockGuard_TransactionAlreadyExecuted(); | ||
error TimelockGuard_InvalidVersion(); | ||
|
||
event CancellationThresholdUpdated(address indexed safe, uint256 oldThreshold, uint256 newThreshold); | ||
event GuardConfigured(address indexed safe, uint256 timelockDelay); | ||
event TransactionCancelled(address indexed safe, bytes32 indexed txHash); | ||
event TransactionScheduled(address indexed safe, bytes32 indexed txHash, uint256 executionTime); | ||
event TransactionExecuted(address indexed safe, bytes32 txHash); | ||
event Message(string message); | ||
|
||
function cancelTransaction(address _safe, bytes32 _txHash, uint256 _nonce, bytes memory _signatures) external; | ||
function signCancellation(bytes32 _txHash) external; | ||
function cancellationThreshold(address _safe) external view returns (uint256); | ||
function checkTransaction( | ||
address _to, | ||
uint256 _value, | ||
bytes memory _data, | ||
Enum.Operation _operation, | ||
uint256 _safeTxGas, | ||
uint256 _baseGas, | ||
uint256 _gasPrice, | ||
address _gasToken, | ||
address payable _refundReceiver, | ||
bytes memory _signatures, | ||
address _msgSender | ||
) | ||
external; | ||
function checkAfterExecution(bytes32, bool) external; | ||
function configureTimelockGuard(uint256 _timelockDelay) external; | ||
function scheduledTransaction( | ||
address _safe, | ||
bytes32 _txHash | ||
) | ||
external | ||
view | ||
returns (ScheduledTransaction memory); | ||
function safeConfigs(address) external view returns (uint256 timelockDelay); | ||
function scheduleTransaction( | ||
address _safe, | ||
uint256 _nonce, | ||
ExecTransactionParams memory _params, | ||
bytes memory _signatures | ||
) | ||
external; | ||
function version() external view returns (string memory); | ||
function timelockConfiguration(address _safe) external view returns (uint256 timelockDelay); | ||
function maxCancellationThreshold(address _safe) external view returns (uint256); | ||
function pendingTransactions(address _safe) | ||
external | ||
view | ||
returns (ScheduledTransaction[] memory); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.