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
da17f609
Unverified
Commit
da17f609
authored
Oct 01, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ctb): Working signature recording
parent
0d9784bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
16 deletions
+13
-16
LivenessGuard.sol
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
+12
-14
LivenessGuard.t.sol
packages/contracts-bedrock/test/LivenessGuard.t.sol
+1
-2
No files found.
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
View file @
da17f609
...
...
@@ -15,12 +15,11 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
}
/// @notice We just need to satisfy the BaseGuard interfae, but we don't actually need to use this method.
function checkAfterExecution(bytes32
txHash, bool success) external
{
function checkAfterExecution(bytes32
, bool) external pure
{
return;
}
/// @notice This checkTransaction implementation records the most recent time which any owner has signed a
/// transaction.
/// @notice Records the most recent time which any owner has signed a transaction.
function checkTransaction(
address to,
uint256 value,
...
...
@@ -32,7 +31,7 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
address gasToken,
address payable refundReceiver,
bytes memory signatures,
address
msgSender
address
)
external
{
...
...
@@ -43,7 +42,7 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
}
// This is a bit of a hack, maybe just replicate the functionality here rather than calling home
bytes
memory txHashData = Safe(payable(msg.sender)).encodeTransactionData
(
bytes
32 txHash = Safe(payable(msg.sender)).getTransactionHash
(
// Transaction info
to,
value,
...
...
@@ -56,23 +55,22 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
gasToken,
refundReceiver,
// Signature info
Safe(payable(msg.sender)).nonce() // check that this works
);
address[] memory signers = _getNSigners(
keccak256(txHashData)
, signatures);
address[] memory signers = _getNSigners(
txHash
, signatures);
for (uint256 i = 0; i < signers.length; i++) {
lastSigned[signers[i]] = block.timestamp;
}
}
function _getNSigners(bytes32 dataHash, bytes memory signatures) internal returns (address[] memory _owners) {
uint256 numSignatures = signatures.length / 65; // division OK?
/// @notice Exctract the signers from a set of signatures.
function _getNSigners(bytes32 dataHash, bytes memory signatures) internal pure returns (address[] memory _owners) {
uint256 numSignatures = signatures.length / 65;
_owners = new address[](numSignatures);
// The following code is extracted from the Safe.checkNSignatures() method. It removes the signature validation
// code,
// and keeps only the parsing code necessary to extract the owner addresses from the signatures.
// We do not double check if the owner derived from a signature is valid. As tHis is handled in
// the final require statement of Safe.checkNSignatures().
/// The following code is extracted from the Safe.checkNSignatures() method. It removes the signature
/// validation code, and keeps only the parsing code necessary to extract the owner addresses from the
/// signatures. We do not double check if the owner derived from a signature is valid. As this is handled
/// in the final require statement of Safe.checkNSignatures().
address currentOwner;
uint8 v;
bytes32 r;
...
...
packages/contracts-bedrock/test/LivenessGuard.t.sol
View file @
da17f609
...
...
@@ -27,7 +27,7 @@ contract LivnessGuard_TestInit is Test, SafeTestTools {
function setUp() public {
safeInstance = _setupSafe();
livenessGuard = new LivenessGuard(safeInstance.safe);
safeInstance.
enableModule
(address(livenessGuard));
safeInstance.
setGuard
(address(livenessGuard));
}
}
...
...
@@ -37,7 +37,6 @@ contract LivnessGuard_TestCheckTx is LivnessGuard_TestInit {
function test_checkTransaction_succeeds() external {
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
// bug signers need to be sorted from low to high
for (uint256 i; i < safeInstance.owners.length; i++) {
assertEq(livenessGuard.lastSigned(safeInstance.owners[i]), block.timestamp);
}
...
...
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