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
a725a3c2
Unverified
Commit
a725a3c2
authored
Oct 25, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(ctb): Better helper functions for pre-removal check
parent
40c997f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
LivenessModule.sol
packages/contracts-bedrock/src/Safe/LivenessModule.sol
+10
-11
No files found.
packages/contracts-bedrock/src/Safe/LivenessModule.sol
View file @
a725a3c2
...
@@ -89,9 +89,8 @@ contract LivenessModule is ISemver {
...
@@ -89,9 +89,8 @@ contract LivenessModule is ISemver {
internal
internal
{
{
require(
require(
!_isAboveMinOwners(_newOwnersCount)
_newOwnersCount < MIN_OWNERS || _canRemove(_ownerToRemove),
|| LIVENESS_GUARD.lastLive(_ownerToRemove) < block.timestamp - LIVENESS_INTERVAL,
"LivenessModule: the safe still has sufficient owners, or the owner to remove has signed recently"
"LivenessModule: owner has signed recently"
);
);
if (_newOwnersCount > 0) {
if (_newOwnersCount > 0) {
// Remove the owner and update the threshold
// Remove the owner and update the threshold
...
@@ -133,12 +132,19 @@ contract LivenessModule is ISemver {
...
@@ -133,12 +132,19 @@ contract LivenessModule is ISemver {
);
);
}
}
/// @notice Checks if the owner can be removed
/// @param _owner The owner to be removed
/// @return canRemove_ bool indicating if the owner can be removed
function _canRemove(address _owner) internal view returns (bool canRemove_) {
canRemove_ = LIVENESS_GUARD.lastLive(_owner) + LIVENESS_INTERVAL < block.timestamp;
}
/// @notice A FREI-PI invariant check enforcing requirements on number of owners and threshold.
/// @notice A FREI-PI invariant check enforcing requirements on number of owners and threshold.
function _verifyFinalState() internal view {
function _verifyFinalState() internal view {
address[] memory owners = SAFE.getOwners();
address[] memory owners = SAFE.getOwners();
uint256 numOwners = owners.length;
uint256 numOwners = owners.length;
require(
require(
_isAboveMinOwners(numOwners)
|| (numOwners == 1 && owners[0] == FALLBACK_OWNER),
numOwners >= MIN_OWNERS
|| (numOwners == 1 && owners[0] == FALLBACK_OWNER),
"LivenessModule: Safe must have the minimum number of owners or be owned solely by the fallback owner"
"LivenessModule: Safe must have the minimum number of owners or be owned solely by the fallback owner"
);
);
...
@@ -168,13 +174,6 @@ contract LivenessModule is ISemver {
...
@@ -168,13 +174,6 @@ contract LivenessModule is ISemver {
threshold_ = (_numOwners * 75 + 99) / 100;
threshold_ = (_numOwners * 75 + 99) / 100;
}
}
/// @notice Check if the number of owners is greater than or equal to the minimum number of owners.
/// @param numOwners The number of owners.
/// @return A boolean indicating if the number of owners is greater than or equal to the minimum number of owners.
function _isAboveMinOwners(uint256 numOwners) internal view returns (bool) {
return numOwners >= MIN_OWNERS;
}
/// @notice Getter function for the Safe contract instance
/// @notice Getter function for the Safe contract instance
/// @return safe_ The Safe contract instance
/// @return safe_ The Safe contract instance
function safe() public view returns (Safe safe_) {
function safe() public view returns (Safe safe_) {
...
...
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