Skip to content

Commit 4eadc83

Browse files
committed
chore: limt comments
1 parent d0ac19b commit 4eadc83

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

contracts/account/extensions/ERC7579Modules/SocialRecoveryExecutor.sol

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ import {AccountERC7579} from "../AccountERC7579.sol";
1111
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
1212

1313
/**
14-
* @title Implements a Social Recovery Executor module following ERC-7579
14+
* @dev Implements a Social Recovery Executor module following ERC-7579
1515
*
16-
* @dev Features:
17-
* - Timelocked Guardian-based recovery
18-
* - Recovery Execution Scope is limited to reconfiguring installed Validator Modules
19-
* - Recovery Reconfiguration can only be performed by the ERC-7579 Account
16+
* Features:
17+
* - Timelocked Guardian n of m recovery
18+
* - Recovery Execution Scope is restricted to reconfiguring installed Validator Modules
19+
* - Recovery Reconfiguration can only be performed by the installer ERC-7579 Account
2020
* - Guardian Signatures replay attack protection via EIP-712 typed data signing
21-
* - Replay Attack protection includes: chains, accounts, executors, and recovery attempts
2221
*/
2322
contract SocialRecoveryExecutor is IERC7579Module, EIP712, ReentrancyGuard {
2423
using EnumerableSet for EnumerableSet.AddressSet;
@@ -148,6 +147,7 @@ contract SocialRecoveryExecutor is IERC7579Module, EIP712, ReentrancyGuard {
148147
revert InvalidTimelock();
149148
}
150149

150+
// add guardians to the recovery config
151151
for (uint256 i = 0; i < _guardians.length; i++) {
152152
if (_guardians[i] == address(0)) {
153153
revert InvalidGuardian();
@@ -204,12 +204,12 @@ contract SocialRecoveryExecutor is IERC7579Module, EIP712, ReentrancyGuard {
204204
revert InvalidGuardianSignatures();
205205
}
206206

207-
// increment nonce.
208-
_recoveryConfigs[account].nonce++;
209-
210207
// set recovery start time.
211208
_recoveryConfigs[account].recoveryStart = block.timestamp;
212209

210+
// increment nonce.
211+
_recoveryConfigs[account].nonce++;
212+
213213
emit RecoveryStarted(account);
214214
}
215215

@@ -230,12 +230,15 @@ contract SocialRecoveryExecutor is IERC7579Module, EIP712, ReentrancyGuard {
230230
revert InvalidGuardianSignatures();
231231
}
232232

233-
// exection data should be at least:20 bytes for targetValidatorModule, 32 for value and 4 for recovery selector.
233+
// exection data should be at least:
234+
// targetValidatorModule: 20 bytes,
235+
// value: 32 bytes,
236+
// recovery selector: 4 bytes.
234237
if (executionCalldata.length < 56) {
235238
revert InvalidRecoveryCallData();
236239
}
237240

238-
// @TBD sending value to the validator module.
241+
// @TBD implement sending value to the validator module.
239242
// Rationale: In some very specific scenarios, the validator module might need to be paid for the recovery,
240243
// or the recovery logic includes to take all the balance of the account.
241244
(address targetValidatorModule, , ) = ERC7579Utils.decodeSingle(executionCalldata);
@@ -253,12 +256,12 @@ contract SocialRecoveryExecutor is IERC7579Module, EIP712, ReentrancyGuard {
253256
ModePayload.wrap(bytes22(0)) // no payload needed
254257
);
255258

256-
// increment nonce.
257-
_recoveryConfigs[account].nonce++;
258-
259259
// reset recovery status.
260260
_recoveryConfigs[account].recoveryStart = 0;
261261

262+
// increment nonce.
263+
_recoveryConfigs[account].nonce++;
264+
262265
// execute the recovery.
263266
AccountERC7579(payable(account)).executeFromExecutor(Mode.unwrap(mode), executionCalldata);
264267

@@ -289,7 +292,7 @@ contract SocialRecoveryExecutor is IERC7579Module, EIP712, ReentrancyGuard {
289292
}
290293

291294
/// @notice Verifies multiple guardian signatures
292-
/// @dev Checks each signature against the current recovery digest
295+
/// @dev Checks each signature against the current recovery digest and ensures no duplicates
293296
/// @param account The account the signatures are for
294297
/// @param guardianSignatures Array of guardian signatures to verify
295298
/// @return True if all signatures are valid, false otherwise
@@ -306,7 +309,8 @@ contract SocialRecoveryExecutor is IERC7579Module, EIP712, ReentrancyGuard {
306309
if (!guardianSignatureIsValid(account, guardianSignatures[i])) {
307310
return false;
308311
}
309-
// check for signature duplication @TBD optimize O(n^2)
312+
// check for signature duplication
313+
// @TBD optimize O(n^2)
310314
address currentSigner = guardianSignatures[i].signer;
311315
for (uint256 j = 0; j < i; j++) {
312316
if (guardianSignatures[j].signer == currentSigner) {

test/account/extensions/ERC7579Modules/SocialRecoveryExecutorModule.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,8 @@ describe('SocialRecoveryExecutorModule', function () {
546546
});
547547

548548
describe('cancel recovery', async function () {
549-
/**
550-
* @dev Cancel recovery requires the transaction sender to be the account whose recovery is being cancelled.
551-
* Thus, the only way to cancel recovery is via the Account being called by the Canonical EntryPoint, and validated through a Validator Module.
552-
*/
549+
// Cancel recovery requires the transaction sender to be the account whose recovery is being cancelled.
550+
// Thus, the only way to cancel recovery is via the Account being called by the Canonical EntryPoint, and validated through a Validator Module.
553551
it('should fail if a guardian or any non-signer attempts to cancel recovery', async function () {
554552
const operation = await this.accountMock
555553
.createUserOp(this.userOp)

0 commit comments

Comments
 (0)