Skip to content

Commit e5a1f87

Browse files
authored
fix: correct account registry invariant docs, remove unnecessary check for recoveryAddress (#16)
* docs: explain more explicitly where the invariant holds * opt: remove account registry check for recoveryAddress != custodyAddress * fix: gas snapshot
1 parent f85aa15 commit e5a1f87

File tree

3 files changed

+20
-34
lines changed

3 files changed

+20
-34
lines changed

.gas-snapshot

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
AccountRegistryTest:testCancelRecoveryFromCustodyAddress() (gas: 134666)
2-
AccountRegistryTest:testCancelRecoveryFromRecoveryAddress() (gas: 134831)
3-
AccountRegistryTest:testCannotCancelRecoveryIfNotStarted() (gas: 92950)
4-
AccountRegistryTest:testCannotCancelRecoveryIfUnauthorized() (gas: 143175)
5-
AccountRegistryTest:testCannotCompleteRecoveryIfNotStarted() (gas: 103929)
6-
AccountRegistryTest:testCannotCompleteRecoveryIfUnauthorized() (gas: 145990)
7-
AccountRegistryTest:testCannotCompleteRecoveryToAddressThatOwnsAnId() (gas: 170123)
8-
AccountRegistryTest:testCannotCompleteRecoveryWhenInEscrow() (gas: 143704)
9-
AccountRegistryTest:testCannotRegisterTwice() (gas: 59173)
10-
AccountRegistryTest:testCannotRequestRecoveryToAddressThatOwnsAnId() (gas: 115853)
11-
AccountRegistryTest:testCannotRequestRecoveryUnlessAuthorized() (gas: 69275)
12-
AccountRegistryTest:testCannotRequestRecoveryUnlessIssued() (gas: 17819)
13-
AccountRegistryTest:testCannotSetRecoveryAddressWithoutId() (gas: 18914)
14-
AccountRegistryTest:testCannotSetSelfAsRecovery() (gas: 61534)
15-
AccountRegistryTest:testCannotTransferIfNoId() (gas: 21711)
16-
AccountRegistryTest:testCannotTransferToAddressWithId() (gas: 90483)
17-
AccountRegistryTest:testRecoveryCompletion() (gas: 133092)
1+
AccountRegistryTest:testCancelRecoveryFromCustodyAddress() (gas: 134604)
2+
AccountRegistryTest:testCancelRecoveryFromRecoveryAddress() (gas: 134769)
3+
AccountRegistryTest:testCannotCancelRecoveryIfNotStarted() (gas: 92888)
4+
AccountRegistryTest:testCannotCancelRecoveryIfUnauthorized() (gas: 143224)
5+
AccountRegistryTest:testCannotCompleteRecoveryIfNotStarted() (gas: 103867)
6+
AccountRegistryTest:testCannotCompleteRecoveryIfUnauthorized() (gas: 145950)
7+
AccountRegistryTest:testCannotCompleteRecoveryToAddressThatOwnsAnId() (gas: 170083)
8+
AccountRegistryTest:testCannotCompleteRecoveryWhenInEscrow() (gas: 143753)
9+
AccountRegistryTest:testCannotRegisterTwice() (gas: 59151)
10+
AccountRegistryTest:testCannotRequestRecoveryToAddressThatOwnsAnId() (gas: 115813)
11+
AccountRegistryTest:testCannotRequestRecoveryUnlessAuthorized() (gas: 69253)
12+
AccountRegistryTest:testCannotRequestRecoveryUnlessIssued() (gas: 17797)
13+
AccountRegistryTest:testCannotSetRecoveryAddressWithoutId() (gas: 18880)
14+
AccountRegistryTest:testCannotTransferIfNoId() (gas: 21689)
15+
AccountRegistryTest:testCannotTransferToAddressWithId() (gas: 90461)
16+
AccountRegistryTest:testRecoveryCompletion() (gas: 133042)
1817
AccountRegistryTest:testRegister() (gas: 89924)
19-
AccountRegistryTest:testRequestRecovery() (gas: 144852)
20-
AccountRegistryTest:testSetRecoveryAddress() (gas: 95427)
18+
AccountRegistryTest:testRequestRecovery() (gas: 144812)
19+
AccountRegistryTest:testSetRecoveryAddress() (gas: 95325)
2120
AccountRegistryTest:testTransfer() (gas: 75750)
2221
NameSpaceTest:testBidAfterOneStep() (gas: 220057)
2322
NameSpaceTest:testBidAndOverpay() (gas: 215676)

src/AccountRegistry.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ contract AccountRegistry {
131131
//////////////////////////////////////////////////////////////*/
132132

133133
/**
134-
* INVARIANT 1: idOf[address] != 0 if msg.sender == recoveryOf[idOf[address]]
134+
* INVARIANT 1: idOf[address] != 0 if msg.sender == recoveryOf[idOf[address]] during
135+
* invocation of requestRecovery, completeRecovery and cancelRecovery
135136
*
136137
* recoveryOf[idOf[address]] != address(0) only if idOf[address] != 0 [setRecoveryAddress]
137138
* when idOf[address] == 0, recoveryof[idOf[address]] also == address(0) [_unsafeTransfer]
@@ -157,7 +158,6 @@ contract AccountRegistry {
157158
uint256 id = idOf[msg.sender];
158159

159160
if (id == 0) revert ZeroId();
160-
if (recoveryAddress == msg.sender) revert InvalidRecoveryAddr();
161161

162162
recoveryOf[id] = recoveryAddress;
163163
emit SetRecoveryAddress(recoveryAddress, id);

test/AccountRegistry.t.sol

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,6 @@ contract AccountRegistryTest is Test {
141141
assertEq(accountRegistry.recoveryOf(1), charlie);
142142
}
143143

144-
function testCannotSetSelfAsRecovery() public {
145-
// 1. alice registers id 1
146-
vm.startPrank(alice);
147-
accountRegistry.register();
148-
149-
// 2. alice sets herself as the recovery address, which fails
150-
vm.expectRevert(InvalidRecoveryAddr.selector);
151-
accountRegistry.setRecoveryAddress(alice);
152-
vm.stopPrank();
153-
154-
assertEq(accountRegistry.recoveryOf(1), address(0));
155-
}
156-
157144
function testCannotSetRecoveryAddressWithoutId() public {
158145
vm.startPrank(alice);
159146
vm.expectRevert(ZeroId.selector);

0 commit comments

Comments
 (0)