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
b51e604e
Unverified
Commit
b51e604e
authored
Oct 24, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ctb): Improve commenting on LivenessGuard
parent
c7d5b2b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
LivenessGuard.sol
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
+12
-6
No files found.
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
View file @
b51e604e
...
...
@@ -9,6 +9,12 @@ import { Enum } from "safe-contracts/common/Enum.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
/// @title LivenessGuard
/// @notice This Guard contract is used to track the liveness of Safe owners.
/// @dev It keeps track of the last time each owner participated in signing a transaction.
/// If an owner does not participate in a transaction for a certain period of time, they are considered inactive.
/// This Guard is intended to be used in conjunction with the LivenessModule contract, but does
/// not depend on it.
contract LivenessGuard is ISemver, BaseGuard {
using EnumerableSet for EnumerableSet.AddressSet;
...
...
@@ -24,11 +30,11 @@ contract LivenessGuard is ISemver, BaseGuard {
Safe public immutable safe;
/// @notice A mapping of the timestamp at which an owner last participated in signing a
/// an executed transaction.
/// an executed transaction
, or called showLiveness
.
mapping(address => uint256) public lastLive;
/// @notice An enumerable set of addresses used to store the list of owners before execution,
/// and then to update the last
Signed
mapping according to changes in the set observed
/// and then to update the last
Live
mapping according to changes in the set observed
/// after execution.
EnumerableSet.AddressSet private ownersBefore;
...
...
@@ -40,8 +46,8 @@ contract LivenessGuard is ISemver, BaseGuard {
/// @notice We use this post execution hook to compare the set of owners before and after.
/// If the set of owners has changed then we:
/// 1. Add new owners to the last
Signed
mapping
/// 2. Delete removed owners from the last
Signed
mapping
/// 1. Add new owners to the last
Live
mapping
/// 2. Delete removed owners from the last
Live
mapping
function checkAfterExecution(bytes32, bool) external {
// Get the current set of owners
address[] memory ownersAfter = safe.getOwners();
...
...
@@ -52,12 +58,12 @@ contract LivenessGuard is ISemver, BaseGuard {
// If the value was present, remove() returns true.
address ownerAfter = ownersAfter[i];
if (ownersBefore.remove(ownerAfter) == false) {
// This address was not already an owner, add it to the last
Signed
mapping
// This address was not already an owner, add it to the last
Live
mapping
lastLive[ownerAfter] = block.timestamp;
}
}
// Now iterate over the remaining ownersBefore entries. Any remaining addresses are no longer an owner, so we
// delete them from the last
Signed
mapping.
// delete them from the last
Live
mapping.
for (uint256 j = 0; j < ownersBefore.length(); j++) {
address ownerBefore = ownersBefore.at(j);
delete lastLive[ownerBefore];
...
...
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