@@ -179,6 +179,7 @@ contract EthereumVaultConnectorWithFallback is EthereumVaultConnectorHarness {
179
179
}
180
180
181
181
contract PermitTest is Test {
182
+ address internal constant COMMON_PREDEPLOYS = 0x4200000000000000000000000000000000000000 ;
182
183
EthereumVaultConnectorWithFallback internal evc;
183
184
SignerECDSA internal signerECDSA;
184
185
SignerERC1271 internal signerERC1271;
@@ -215,7 +216,10 @@ contract PermitTest is Test {
215
216
address msgSender = sender == address (0 ) ? address (uint160 (uint256 (keccak256 (abi.encode (alice))))) : sender;
216
217
data = abi.encode (keccak256 (data));
217
218
218
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
219
+ vm.assume (
220
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
221
+ && alice != address (evc)
222
+ );
219
223
vm.assume (msgSender != address (evc));
220
224
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
221
225
@@ -264,7 +268,7 @@ contract PermitTest is Test {
264
268
data = abi.encode (keccak256 (data));
265
269
266
270
vm.assume (msgSender != address (evc));
267
- vm.assume (! evc.haveCommonOwner (alice, address (0 )));
271
+ vm.assume (! evc.haveCommonOwner (alice, address (0 )) && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) );
268
272
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
269
273
270
274
vm.warp (deadline);
@@ -310,7 +314,10 @@ contract PermitTest is Test {
310
314
&& privateKey < 115792089237316195423570985008687907852837564279074904382605163141518161494337
311
315
);
312
316
address alice = vm.addr (privateKey);
313
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
317
+ vm.assume (
318
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
319
+ && alice != address (evc)
320
+ );
314
321
bytes19 addressPrefix = evc.getAddressPrefix (alice);
315
322
data2 = abi.encode (keccak256 (data2));
316
323
vm.assume (nonce > 0 && nonce < type (uint256 ).max - 1 );
@@ -351,7 +358,10 @@ contract PermitTest is Test {
351
358
&& privateKey < 115792089237316195423570985008687907852837564279074904382605163141518161494337
352
359
);
353
360
address alice = vm.addr (privateKey);
354
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
361
+ vm.assume (
362
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
363
+ && alice != address (evc)
364
+ );
355
365
bytes19 addressPrefix = evc.getAddressPrefix (alice);
356
366
data = abi.encode (keccak256 (data));
357
367
vm.assume (sender != address (0 ) && sender != address (this ));
@@ -369,6 +379,7 @@ contract PermitTest is Test {
369
379
}
370
380
371
381
function test_RevertIfSignerInvalid_Permit (
382
+ bool option ,
372
383
address alice ,
373
384
uint256 nonceNamespace ,
374
385
uint256 nonce ,
@@ -377,7 +388,9 @@ contract PermitTest is Test {
377
388
bytes memory data ,
378
389
bytes calldata signature
379
390
) public {
380
- alice = address (uint160 (bound (uint160 (alice), 0 , 0xFF )));
391
+ alice = option
392
+ ? address (uint160 (bound (uint160 (alice), 0 , 0xFF )))
393
+ : address (uint160 (bound (uint160 (alice), uint160 (COMMON_PREDEPLOYS), uint160 (COMMON_PREDEPLOYS) + 0xFF )));
381
394
bytes19 addressPrefix = evc.getAddressPrefix (alice);
382
395
data = abi.encode (keccak256 (data));
383
396
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
@@ -404,7 +417,10 @@ contract PermitTest is Test {
404
417
) public {
405
418
bytes19 addressPrefix = evc.getAddressPrefix (alice);
406
419
data = abi.encode (keccak256 (data));
407
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
420
+ vm.assume (
421
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
422
+ && alice != address (evc)
423
+ );
408
424
vm.assume (nonce < type (uint256 ).max);
409
425
vm.warp (deadline);
410
426
@@ -436,7 +452,10 @@ contract PermitTest is Test {
436
452
) public {
437
453
bytes19 addressPrefix = evc.getAddressPrefix (alice);
438
454
data = abi.encode (keccak256 (data));
439
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
455
+ vm.assume (
456
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
457
+ && alice != address (evc)
458
+ );
440
459
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
441
460
vm.assume (deadline < type (uint256 ).max);
442
461
vm.warp (deadline + 1 );
@@ -466,7 +485,10 @@ contract PermitTest is Test {
466
485
address alice = vm.addr (privateKey);
467
486
bytes19 addressPrefix = evc.getAddressPrefix (alice);
468
487
data = abi.encode (keccak256 (data));
469
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
488
+ vm.assume (
489
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
490
+ && alice != address (evc)
491
+ );
470
492
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
471
493
vm.assume (value > 0 );
472
494
vm.warp (deadline);
@@ -499,7 +521,10 @@ contract PermitTest is Test {
499
521
bytes calldata signature
500
522
) public {
501
523
bytes19 addressPrefix = evc.getAddressPrefix (alice);
502
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
524
+ vm.assume (
525
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
526
+ && alice != address (evc)
527
+ );
503
528
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
504
529
vm.warp (deadline);
505
530
@@ -531,7 +556,10 @@ contract PermitTest is Test {
531
556
data = abi.encode (keccak256 (data));
532
557
signerECDSA.setPrivateKey (privateKey);
533
558
534
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && alice != address (evc));
559
+ vm.assume (
560
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
561
+ && alice != address (evc)
562
+ );
535
563
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
536
564
vm.warp (deadline);
537
565
vm.deal (address (evc), value);
@@ -569,7 +597,10 @@ contract PermitTest is Test {
569
597
bytes calldata signature ,
570
598
uint16 value
571
599
) public {
572
- vm.assume (! evc.haveCommonOwner (signer, address (0 )) && signer != address (evc));
600
+ vm.assume (
601
+ ! evc.haveCommonOwner (signer, address (0 )) && ! evc.haveCommonOwner (signer, COMMON_PREDEPLOYS)
602
+ && signer != address (evc)
603
+ );
573
604
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
574
605
575
606
bytes19 addressPrefix = evc.getAddressPrefix (signer);
@@ -597,7 +628,7 @@ contract PermitTest is Test {
597
628
address alice = vm.addr (privateKey);
598
629
signerECDSA.setPrivateKey (privateKey);
599
630
600
- vm.assume (! evc.haveCommonOwner (alice, address (0 )));
631
+ vm.assume (! evc.haveCommonOwner (alice, address (0 )) && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) );
601
632
vm.warp (deadline);
602
633
603
634
// ECDSA signature invalid due to signer.
@@ -695,7 +726,7 @@ contract PermitTest is Test {
695
726
address alice = address (new SignerERC1271 (evc));
696
727
SignerERC1271 (alice).setSignatureHash (signature);
697
728
698
- vm.assume (! evc.haveCommonOwner (alice, address (0 )));
729
+ vm.assume (! evc.haveCommonOwner (alice, address (0 )) && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) );
699
730
vm.warp (deadline);
700
731
701
732
// ECDSA signature is always invalid here hence we fall back to ERC-1271 signature
@@ -785,7 +816,10 @@ contract PermitTest is Test {
785
816
address bob = address (new SignerERC1271 (evc));
786
817
address target = address (new Vault (evc));
787
818
788
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, bob));
819
+ vm.assume (
820
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, bob)
821
+ && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
822
+ );
789
823
vm.deal (address (this ), type (uint128 ).max);
790
824
signerECDSA.setPrivateKey (privateKey);
791
825
0 commit comments