Skip to content

Commit 96fea29

Browse files
Require that msgSender be an owner of the Safe (#17900)
* Add SaferSafes as child of the module and guard * Add ISaferSafes * Test comment and assertion fixes * Improve comments * Make LivenessModule2 and TimelockGuard abstract Move semver to SaferSafes semver lock * fix test contract name * Move semver to SaferSafes * Disable the guard and module upon ownership transfer * Add _disableThisGuard function * Update tests * Add config resets * fmt * fix test_changeOwnershipToFallback_canRechallenge_succeeds * Simplify by clearing config directly * Put _disableThisGuard into child contract * Add timelockDelay reset on _disableThisGuard * semver-lock * Move _disableThisGuard logic into TimelockGuard * clear livenessSafeConfig at tend of _disableThisModule * Clarify use of SENTINEL_OWNER * Fix the ordering of the disableGuard and disableModule calls * semver-lock * remove unused imports * rename _disableThisGuard to _disableGuard * bump semver * Add test to remove unrelated guard * Add SENTINEL_MODULE constant * Clean up using ternary if * Reset cancellationThreshold to 0 on changeOwnership * Fix moduleFound if/else handling * Clear pending transactions * Pre-pr fixes * Add test contract to test name lint exclusions * fix name of test contract * Move _disableGuard impl into TimelockGuard * Add missing natspec * Add gas limit testing on changeOwnershipToFallback * Remove interfaces for abstract contracts * Move state changes out into internal _clearLivenessModule * Improve names on the internal _disableX methods * Add clearTimelockGuard function * Add _disableGuard helper to TLG tests * Limit number of transactions cancelled to 100 * Revert "Remove interfaces for abstract contracts" This reverts commit bd03288. * Move livenessModule2 address into TestUtils Reduces diff a bit * Reduce diff somewhat * Remove unused arg * Update packages/contracts-bedrock/src/safe/TimelockGuard.sol Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> * Fix iface * update abi for iface fix * Do not clear or disable the module during ownership transfer * Fix inaccurate comment on _disableAndClearGuard * Further improve comment * remove unused import * fix test name * Do not clear guard during changeOwnershipToFallback * Remove unused SENTINEL_MODULE var * Remove dangling comment * Revert "Remove dangling comment" This reverts commit d266d12. * Fix whitespace * remove unnecessary internal _clearTimelockGuard function It's no longer reused in the change ownership call. * Address feedback * Add missing assertion * Move guard slot into constants * semver-lock * Remove LivenessModule from semver-lock * fix: fmt, semver-lock, unused imports * Remove unused variable * fix semver lock by resetting old LivenessModule * fix unused import * Require that msgSender be an owner of the Safe * fix compiler error * Fix placement of _msgSender check * semver-lock * Add TimelockGuard_NotOwner test * Bump semver * Add test comment, make into fuzz test * Improvements to SaferSafes styling (#17903) * Add public getter livenessSafeConfiguration to return a struct rather than tuple * Use Safe as input type to mappings and functions on LivenessModule2 * Add dividers based on function type * fmt * snapshots * Remove conditional return of 0 in the cancellationThreshold if the guard is not enabled * rename timelockConfiguration func to timelockDelay * semver-lock * Add missing natspec on tests and convert to fuzzing where possible * fix import and abi snapshot * fix: off by one error in challenge period test * fix test name --------- Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
1 parent bb24f93 commit 96fea29

File tree

11 files changed

+385
-197
lines changed

11 files changed

+385
-197
lines changed

packages/contracts-bedrock/scripts/deploy/DeployOwnership.s.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,14 @@ contract DeployOwnership is Deploy {
324324
removeDeployerFromSafe({ _name: "SecurityCouncilSafe", _newThreshold: exampleCouncilConfig.safeConfig.threshold });
325325

326326
// Verify the module was configured correctly
327-
(uint256 configuredPeriod, address configuredFallback) =
328-
LivenessModule2(livenessModule).livenessSafeConfiguration(address(safe));
327+
LivenessModule2.ModuleConfig memory verifyConfig =
328+
LivenessModule2(livenessModule).livenessSafeConfiguration(safe);
329329
require(
330-
configuredPeriod == exampleCouncilConfig.livenessModuleConfig.livenessInterval,
330+
verifyConfig.livenessResponsePeriod == exampleCouncilConfig.livenessModuleConfig.livenessInterval,
331331
"DeployOwnership: configured liveness interval must match expected value"
332332
);
333333
require(
334-
configuredFallback == exampleCouncilConfig.livenessModuleConfig.fallbackOwner,
334+
verifyConfig.fallbackOwner == exampleCouncilConfig.livenessModuleConfig.fallbackOwner,
335335
"DeployOwnership: configured fallback owner must match expected value"
336336
);
337337

packages/contracts-bedrock/snapshots/abi/SaferSafes.json

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
{
5050
"inputs": [
5151
{
52-
"internalType": "address",
52+
"internalType": "contract GnosisSafe",
5353
"name": "_safe",
5454
"type": "address"
5555
}
@@ -62,7 +62,7 @@
6262
{
6363
"inputs": [
6464
{
65-
"internalType": "address",
65+
"internalType": "contract GnosisSafe",
6666
"name": "",
6767
"type": "address"
6868
}
@@ -81,7 +81,7 @@
8181
{
8282
"inputs": [
8383
{
84-
"internalType": "address",
84+
"internalType": "contract GnosisSafe",
8585
"name": "_safe",
8686
"type": "address"
8787
}
@@ -163,7 +163,7 @@
163163
},
164164
{
165165
"internalType": "address",
166-
"name": "",
166+
"name": "_msgSender",
167167
"type": "address"
168168
}
169169
],
@@ -227,7 +227,7 @@
227227
{
228228
"inputs": [
229229
{
230-
"internalType": "address",
230+
"internalType": "contract GnosisSafe",
231231
"name": "_safe",
232232
"type": "address"
233233
}
@@ -246,22 +246,29 @@
246246
{
247247
"inputs": [
248248
{
249-
"internalType": "address",
250-
"name": "",
249+
"internalType": "contract GnosisSafe",
250+
"name": "_safe",
251251
"type": "address"
252252
}
253253
],
254254
"name": "livenessSafeConfiguration",
255255
"outputs": [
256256
{
257-
"internalType": "uint256",
258-
"name": "livenessResponsePeriod",
259-
"type": "uint256"
260-
},
261-
{
262-
"internalType": "address",
263-
"name": "fallbackOwner",
264-
"type": "address"
257+
"components": [
258+
{
259+
"internalType": "uint256",
260+
"name": "livenessResponsePeriod",
261+
"type": "uint256"
262+
},
263+
{
264+
"internalType": "address",
265+
"name": "fallbackOwner",
266+
"type": "address"
267+
}
268+
],
269+
"internalType": "struct LivenessModule2.ModuleConfig",
270+
"name": "",
271+
"type": "tuple"
265272
}
266273
],
267274
"stateMutability": "view",
@@ -560,7 +567,7 @@
560567
"type": "address"
561568
}
562569
],
563-
"name": "timelockConfiguration",
570+
"name": "timelockDelay",
564571
"outputs": [
565572
{
566573
"internalType": "uint256",
@@ -902,6 +909,11 @@
902909
"name": "TimelockGuard_InvalidVersion",
903910
"type": "error"
904911
},
912+
{
913+
"inputs": [],
914+
"name": "TimelockGuard_NotOwner",
915+
"type": "error"
916+
},
905917
{
906918
"inputs": [],
907919
"name": "TimelockGuard_TransactionAlreadyCancelled",

packages/contracts-bedrock/snapshots/semver-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@
208208
"sourceCodeHash": "0x950725f8b9ad9bb3b6b5e836f67e18db824a7864bac547ee0eeba88ada3de0e9"
209209
},
210210
"src/safe/SaferSafes.sol:SaferSafes": {
211-
"initCodeHash": "0x68567829042bbd450ffd477848ddcda288e36714846fdcc02c315f2d0d332da6",
212-
"sourceCodeHash": "0x06fc6d5df3c5769b645ff319d8b94415e501711c19cb0b1bce2631771d22294f"
211+
"initCodeHash": "0xaa17bb150c9bcf19675a33e9762b050148aceae9f6a9a6ba020fc6947ebaab39",
212+
"sourceCodeHash": "0xc4201612048ff051ed795521efa3eece1a6556f2c514a268b180d84a2ad8b2d1"
213213
},
214214
"src/universal/OptimismMintableERC20.sol:OptimismMintableERC20": {
215215
"initCodeHash": "0x3c85eed0d017dca8eda6396aa842ddc12492587b061e8c756a8d32c4610a9658",

packages/contracts-bedrock/snapshots/storageLayout/SaferSafes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[
22
{
33
"bytes": "32",
4-
"label": "livenessSafeConfiguration",
4+
"label": "_livenessSafeConfiguration",
55
"offset": 0,
66
"slot": "0",
7-
"type": "mapping(address => struct LivenessModule2.ModuleConfig)"
7+
"type": "mapping(contract GnosisSafe => struct LivenessModule2.ModuleConfig)"
88
},
99
{
1010
"bytes": "32",
1111
"label": "challengeStartTime",
1212
"offset": 0,
1313
"slot": "1",
14-
"type": "mapping(address => uint256)"
14+
"type": "mapping(contract GnosisSafe => uint256)"
1515
},
1616
{
1717
"bytes": "32",

0 commit comments

Comments
 (0)