Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
57cfa4d3
Unverified
Commit
57cfa4d3
authored
Oct 26, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ctb): Address feedback
parent
854db439
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
14 deletions
+13
-14
LivenessGuard.sol
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
+5
-3
LivenessGuard.t.sol
packages/contracts-bedrock/test/LivenessGuard.t.sol
+1
-0
LivenessModule.t.sol
packages/contracts-bedrock/test/LivenessModule.t.sol
+6
-11
SafeSigners.t.sol
packages/contracts-bedrock/test/SafeSigners.t.sol
+1
-0
No files found.
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
View file @
57cfa4d3
...
@@ -81,7 +81,8 @@ contract LivenessGuard is ISemver, BaseGuard {
...
@@ -81,7 +81,8 @@ contract LivenessGuard is ISemver, BaseGuard {
// Cache the set of owners prior to execution.
// Cache the set of owners prior to execution.
// This will be used in the checkAfterExecution method.
// This will be used in the checkAfterExecution method.
address[] memory owners = SAFE.getOwners();
address[] memory owners = SAFE.getOwners();
for (uint256 i = 0; i < owners.length; i++) {
uint256 ownersLength = owners.length;
for (uint256 i = 0; i < ownersLength; i++) {
ownersBefore.add(owners[i]);
ownersBefore.add(owners[i]);
}
}
...
@@ -133,8 +134,9 @@ contract LivenessGuard is ISemver, BaseGuard {
...
@@ -133,8 +134,9 @@ contract LivenessGuard is ISemver, BaseGuard {
}
}
// Now iterate over the remaining ownersBefore entries. Any remaining addresses are no longer an owner, so we
// Now iterate over the remaining ownersBefore entries. Any remaining addresses are no longer an owner, so we
// delete them from the lastLive mapping.
// delete them from the lastLive mapping.
for (uint256 j = 0; j < ownersBefore.length(); j++) {
uint256 ownersBeforeLength = ownersBefore.length();
address ownerBefore = ownersBefore.at(j);
for (uint256 i = 0; i < ownersBeforeLength; i++) {
address ownerBefore = ownersBefore.at(i);
delete lastLive[ownerBefore];
delete lastLive[ownerBefore];
}
}
}
}
...
...
packages/contracts-bedrock/test/LivenessGuard.t.sol
View file @
57cfa4d3
...
@@ -29,6 +29,7 @@ contract LivenessGuard_TestInit is Test, SafeTestTools {
...
@@ -29,6 +29,7 @@ contract LivenessGuard_TestInit is Test, SafeTestTools {
}
}
contract LivenessGuard_Constructor_Test is LivenessGuard_TestInit {
contract LivenessGuard_Constructor_Test is LivenessGuard_TestInit {
/// @dev Tests that the constructor correctly sets the current time as the lastLive time for each owner
function test_constructor_works() external {
function test_constructor_works() external {
address[] memory owners = safeInstance.owners;
address[] memory owners = safeInstance.owners;
livenessGuard = new LivenessGuard(safeInstance.safe);
livenessGuard = new LivenessGuard(safeInstance.safe);
...
...
packages/contracts-bedrock/test/LivenessModule.t.sol
View file @
57cfa4d3
...
@@ -20,6 +20,7 @@ contract OwnerSimulator is OwnerManager {
...
@@ -20,6 +20,7 @@ contract OwnerSimulator is OwnerManager {
setupOwners(_owners, _threshold);
setupOwners(_owners, _threshold);
}
}
/// @dev Exposes the OwnerManager's removeOwner function so that anyone may call without needing auth
function removeOwnerWrapped(address prevOwner, address owner, uint256 _threshold) public {
function removeOwnerWrapped(address prevOwner, address owner, uint256 _threshold) public {
OwnerManager(address(this)).removeOwner(prevOwner, owner, _threshold);
OwnerManager(address(this)).removeOwner(prevOwner, owner, _threshold);
}
}
...
@@ -194,9 +195,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -194,9 +195,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
/// Will sign a transaction with the first M owners in the owners list
/// Will sign a transaction with the first M owners in the owners list
vm.warp(block.timestamp + livenessInterval);
vm.warp(block.timestamp + livenessInterval);
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
vm.expectRevert(
vm.expectRevert("LivenessModule: the owner to remove has signed recently");
"LivenessModule: the safe still has sufficient owners, or the owner to remove has signed recently"
);
_removeAnOwner(safeInstance.owners[0]);
_removeAnOwner(safeInstance.owners[0]);
}
}
...
@@ -206,9 +205,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -206,9 +205,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
vm.warp(block.timestamp + livenessInterval);
vm.warp(block.timestamp + livenessInterval);
vm.prank(safeInstance.owners[0]);
vm.prank(safeInstance.owners[0]);
livenessGuard.showLiveness();
livenessGuard.showLiveness();
vm.expectRevert(
vm.expectRevert("LivenessModule: the owner to remove has signed recently");
"LivenessModule: the safe still has sufficient owners, or the owner to remove has signed recently"
);
_removeAnOwner(safeInstance.owners[0]);
_removeAnOwner(safeInstance.owners[0]);
}
}
...
@@ -242,8 +239,8 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -242,8 +239,8 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
}
}
/// @dev Tests if remove owners reverts if it removes too many owners without
swapping to the fallback owner
/// @dev Tests if remove owners reverts if it removes too many owners without
removing all of them
function test_removeOwners_belowMinButNot
ToFallbackOwner
_reverts() external {
function test_removeOwners_belowMinButNot
Emptied
_reverts() external {
// Remove all but one owner
// Remove all but one owner
uint256 numOwners = safeInstance.owners.length - 1;
uint256 numOwners = safeInstance.owners.length - 1;
...
@@ -254,9 +251,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
...
@@ -254,9 +251,7 @@ contract LivenessModule_RemoveOwners_TestFail is LivenessModule_TestInit {
address[] memory prevOwners = _getPrevOwners(ownersToRemove);
address[] memory prevOwners = _getPrevOwners(ownersToRemove);
vm.warp(block.timestamp + livenessInterval + 1);
vm.warp(block.timestamp + livenessInterval + 1);
vm.expectRevert(
vm.expectRevert("LivenessModule: must transfer ownership to fallback owner");
"LivenessModule: Safe must have the minimum number of owners or be owned solely by the fallback owner"
);
livenessModule.removeOwners(prevOwners, ownersToRemove);
livenessModule.removeOwners(prevOwners, ownersToRemove);
}
}
...
...
packages/contracts-bedrock/test/SafeSigners.t.sol
View file @
57cfa4d3
...
@@ -21,6 +21,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
...
@@ -21,6 +21,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
/// @dev Maps every key to one of the 4 signatures types.
/// @dev Maps every key to one of the 4 signatures types.
/// This is used in the tests below as a pseudorandom mechanism for determining which
/// This is used in the tests below as a pseudorandom mechanism for determining which
/// signature type to use for each key.
/// signature type to use for each key.
/// @param _key The key to map to a signature type.
function sigType(uint256 _key) internal pure returns (SigTypes sigType_) {
function sigType(uint256 _key) internal pure returns (SigTypes sigType_) {
uint256 t = _key % 4;
uint256 t = _key % 4;
sigType_ = SigTypes(t);
sigType_ = SigTypes(t);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment