@@ -179,6 +179,7 @@ contract EthereumVaultConnectorWithFallback is EthereumVaultConnectorHarness {
179
179
}
180
180
181
181
contract PermitTest is Test {
182
+ address internal constant EIP_7587_PRECOMPILES = 0x0000000000000000000000000000000000000100 ;
182
183
address internal constant COMMON_PREDEPLOYS = 0x4200000000000000000000000000000000000000 ;
183
184
EthereumVaultConnectorWithFallback internal evc;
184
185
SignerECDSA internal signerECDSA;
@@ -217,8 +218,8 @@ contract PermitTest is Test {
217
218
data = abi.encode (keccak256 (data));
218
219
219
220
vm.assume (
220
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
221
- && alice != address (evc)
221
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
222
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
222
223
);
223
224
vm.assume (msgSender != address (evc));
224
225
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
@@ -268,7 +269,10 @@ contract PermitTest is Test {
268
269
data = abi.encode (keccak256 (data));
269
270
270
271
vm.assume (msgSender != address (evc));
271
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS));
272
+ vm.assume (
273
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES)
274
+ && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
275
+ );
272
276
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
273
277
274
278
vm.warp (deadline);
@@ -315,8 +319,8 @@ contract PermitTest is Test {
315
319
);
316
320
address alice = vm.addr (privateKey);
317
321
vm.assume (
318
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
319
- && alice != address (evc)
322
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
323
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
320
324
);
321
325
bytes19 addressPrefix = evc.getAddressPrefix (alice);
322
326
data2 = abi.encode (keccak256 (data2));
@@ -359,8 +363,8 @@ contract PermitTest is Test {
359
363
);
360
364
address alice = vm.addr (privateKey);
361
365
vm.assume (
362
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
363
- && alice != address (evc)
366
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
367
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
364
368
);
365
369
bytes19 addressPrefix = evc.getAddressPrefix (alice);
366
370
data = abi.encode (keccak256 (data));
@@ -379,7 +383,7 @@ contract PermitTest is Test {
379
383
}
380
384
381
385
function test_RevertIfSignerInvalid_Permit (
382
- bool option ,
386
+ uint256 option ,
383
387
address alice ,
384
388
uint256 nonceNamespace ,
385
389
uint256 nonce ,
@@ -388,8 +392,10 @@ contract PermitTest is Test {
388
392
bytes memory data ,
389
393
bytes calldata signature
390
394
) public {
391
- alice = option
392
- ? address (uint160 (bound (uint160 (alice), 0 , 0xFF )))
395
+ alice = option % 3 == 0
396
+ ? option % 2 == 0
397
+ ? address (uint160 (bound (uint160 (alice), 0 , 0xFF )))
398
+ : address (uint160 (bound (uint160 (alice), uint160 (EIP_7587_PRECOMPILES), uint160 (EIP_7587_PRECOMPILES) + 0xFF )))
393
399
: address (uint160 (bound (uint160 (alice), uint160 (COMMON_PREDEPLOYS), uint160 (COMMON_PREDEPLOYS) + 0xFF )));
394
400
bytes19 addressPrefix = evc.getAddressPrefix (alice);
395
401
data = abi.encode (keccak256 (data));
@@ -418,8 +424,8 @@ contract PermitTest is Test {
418
424
bytes19 addressPrefix = evc.getAddressPrefix (alice);
419
425
data = abi.encode (keccak256 (data));
420
426
vm.assume (
421
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
422
- && alice != address (evc)
427
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
428
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
423
429
);
424
430
vm.assume (nonce < type (uint256 ).max);
425
431
vm.warp (deadline);
@@ -453,8 +459,8 @@ contract PermitTest is Test {
453
459
bytes19 addressPrefix = evc.getAddressPrefix (alice);
454
460
data = abi.encode (keccak256 (data));
455
461
vm.assume (
456
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
457
- && alice != address (evc)
462
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
463
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
458
464
);
459
465
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
460
466
vm.assume (deadline < type (uint256 ).max);
@@ -486,8 +492,8 @@ contract PermitTest is Test {
486
492
bytes19 addressPrefix = evc.getAddressPrefix (alice);
487
493
data = abi.encode (keccak256 (data));
488
494
vm.assume (
489
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
490
- && alice != address (evc)
495
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
496
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
491
497
);
492
498
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
493
499
vm.assume (value > 0 );
@@ -522,8 +528,8 @@ contract PermitTest is Test {
522
528
) public {
523
529
bytes19 addressPrefix = evc.getAddressPrefix (alice);
524
530
vm.assume (
525
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
526
- && alice != address (evc)
531
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
532
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
527
533
);
528
534
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
529
535
vm.warp (deadline);
@@ -557,8 +563,8 @@ contract PermitTest is Test {
557
563
signerECDSA.setPrivateKey (privateKey);
558
564
559
565
vm.assume (
560
- ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS )
561
- && alice != address (evc)
566
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES )
567
+ && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS) && alice != address (evc)
562
568
);
563
569
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
564
570
vm.warp (deadline);
@@ -598,8 +604,8 @@ contract PermitTest is Test {
598
604
uint16 value
599
605
) public {
600
606
vm.assume (
601
- ! evc.haveCommonOwner (signer, address (0 )) && ! evc.haveCommonOwner (signer, COMMON_PREDEPLOYS )
602
- && signer != address (evc)
607
+ ! evc.haveCommonOwner (signer, address (0 )) && ! evc.haveCommonOwner (signer, EIP_7587_PRECOMPILES )
608
+ && ! evc. haveCommonOwner (signer, COMMON_PREDEPLOYS) && signer != address (evc)
603
609
);
604
610
vm.assume (nonce > 0 && nonce < type (uint256 ).max);
605
611
@@ -628,7 +634,10 @@ contract PermitTest is Test {
628
634
address alice = vm.addr (privateKey);
629
635
signerECDSA.setPrivateKey (privateKey);
630
636
631
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS));
637
+ vm.assume (
638
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES)
639
+ && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
640
+ );
632
641
vm.warp (deadline);
633
642
634
643
// ECDSA signature invalid due to signer.
@@ -726,7 +735,10 @@ contract PermitTest is Test {
726
735
address alice = address (new SignerERC1271 (evc));
727
736
SignerERC1271 (alice).setSignatureHash (signature);
728
737
729
- vm.assume (! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS));
738
+ vm.assume (
739
+ ! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES)
740
+ && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
741
+ );
730
742
vm.warp (deadline);
731
743
732
744
// ECDSA signature is always invalid here hence we fall back to ERC-1271 signature
@@ -818,7 +830,7 @@ contract PermitTest is Test {
818
830
819
831
vm.assume (
820
832
! evc.haveCommonOwner (alice, address (0 )) && ! evc.haveCommonOwner (alice, bob)
821
- && ! evc.haveCommonOwner (alice, COMMON_PREDEPLOYS)
833
+ && ! evc.haveCommonOwner (alice, EIP_7587_PRECOMPILES) && ! evc. haveCommonOwner (alice, COMMON_PREDEPLOYS)
822
834
);
823
835
vm.deal (address (this ), type (uint128 ).max);
824
836
signerECDSA.setPrivateKey (privateKey);
0 commit comments