From 2485d723fc98c6ad25294f005e9b7c1c76000785 Mon Sep 17 00:00:00 2001 From: Jay Paik Date: Tue, 15 Oct 2024 18:02:12 -0400 Subject: [PATCH] refactor: rename ECDSAValidationModule (#251) --- gas/modular-account/ModularAccount.gas.t.sol | 8 +-- .../ModularAccountBenchmarkBase.sol | 16 +++--- .../SemiModularAccount.gas.t.sol | 5 +- src/factory/AccountFactory.sol | 4 +- ...e.sol => SingleSignerValidationModule.sol} | 2 +- test/account/DeferredValidation.t.sol | 2 +- test/account/GlobalValidationTest.t.sol | 3 +- test/account/ModularAccount.t.sol | 49 +++++++++++-------- test/account/MultiValidation.t.sol | 6 +-- test/account/PerHookData.t.sol | 4 +- test/account/ReplaceModule.t.sol | 6 +-- test/modules/AllowlistModule.t.sol | 5 +- test/modules/TimeRangeModule.t.sol | 5 +- test/utils/AccountTestBase.sol | 26 +++++----- test/utils/ModuleSignatureUtils.sol | 4 +- test/utils/OptimizedTest.sol | 11 +++-- 16 files changed, 85 insertions(+), 71 deletions(-) rename src/modules/validation/{ECDSAValidationModule.sol => SingleSignerValidationModule.sol} (98%) diff --git a/gas/modular-account/ModularAccount.gas.t.sol b/gas/modular-account/ModularAccount.gas.t.sol index 5c5f2a7e..c20dd496 100644 --- a/gas/modular-account/ModularAccount.gas.t.sol +++ b/gas/modular-account/ModularAccount.gas.t.sol @@ -14,7 +14,7 @@ import {Vm} from "forge-std/src/Vm.sol"; import {ModularAccountBase} from "../../src/account/ModularAccountBase.sol"; import {AccountFactory} from "../../src/factory/AccountFactory.sol"; -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; import {ModularAccountBenchmarkBase} from "./ModularAccountBenchmarkBase.sol"; @@ -38,7 +38,7 @@ contract ModularAccountGasTest is ModularAccountBenchmarkBase("ModularAccount") assertEq(logs.length, 4); // Logs: - // 0: ECDSAValidationModule `SignerTransferred` (anonymous) + // 0: SingleSignerValidationModule `SignerTransferred` (anonymous) // 1: ModularAccount `ValidationInstalled` // 2: ModularAccount `Initialized` // 3: AccountFactory `ModularAccountDeployed` @@ -243,7 +243,7 @@ contract ModularAccountGasTest is ModularAccountBenchmarkBase("ModularAccount") vm.deal(address(account1), 1 ether); - ECDSAValidationModule newValidationModule = _deployECDSAValidationModule(); + SingleSignerValidationModule newValidationModule = _deploySingleSignerValidationModule(); uint32 newEntityId = 0; (address owner2, uint256 owner2Key) = makeAddrAndKey("owner2"); @@ -281,7 +281,7 @@ contract ModularAccountGasTest is ModularAccountBenchmarkBase("ModularAccount") owner1Key, _getECDSAReplaySafeHash( account1, - ecdsaValidationModule, + singleSignerValidationModule, _getDeferredInstallHash( account1, deferredInstallNonce, diff --git a/gas/modular-account/ModularAccountBenchmarkBase.sol b/gas/modular-account/ModularAccountBenchmarkBase.sol index f36e84fc..91127c47 100644 --- a/gas/modular-account/ModularAccountBenchmarkBase.sol +++ b/gas/modular-account/ModularAccountBenchmarkBase.sol @@ -20,7 +20,7 @@ import {AccountFactory} from "../../src/factory/AccountFactory.sol"; import {FALLBACK_VALIDATION} from "../../src/helpers/Constants.sol"; import {AllowlistModule} from "../../src/modules/permissions/AllowlistModule.sol"; import {TimeRangeModule} from "../../src/modules/permissions/TimeRangeModule.sol"; -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; import {Counter} from "../../test/mocks/Counter.sol"; import {ModuleSignatureUtils} from "../../test/utils/ModuleSignatureUtils.sol"; @@ -32,7 +32,7 @@ abstract contract ModularAccountBenchmarkBase is BenchmarkBase, ModuleSignatureU AccountFactory public factory; ModularAccount public accountImpl; SemiModularAccountBytecode public semiModularImpl; - ECDSAValidationModule public ecdsaValidationModule; + SingleSignerValidationModule public singleSignerValidationModule; AllowlistModule public allowlistModule; TimeRangeModule public timeRangeModule; @@ -50,10 +50,10 @@ abstract contract ModularAccountBenchmarkBase is BenchmarkBase, ModuleSignatureU accountImpl = _deployModularAccount(IEntryPoint(entryPoint)); semiModularImpl = _deploySemiModularAccountBytecode(IEntryPoint(entryPoint)); - ecdsaValidationModule = _deployECDSAValidationModule(); + singleSignerValidationModule = _deploySingleSignerValidationModule(); factory = new AccountFactory( - entryPoint, accountImpl, semiModularImpl, address(ecdsaValidationModule), address(this) + entryPoint, accountImpl, semiModularImpl, address(singleSignerValidationModule), address(this) ); allowlistModule = new AllowlistModule(); @@ -65,7 +65,7 @@ abstract contract ModularAccountBenchmarkBase is BenchmarkBase, ModuleSignatureU function _deployAccount1() internal { account1 = factory.createAccount(owner1, 0, 0); - signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), 0); + signerValidation = ModuleEntityLib.pack(address(singleSignerValidationModule), 0); } function _deploySemiModularAccountBytecode1() internal { @@ -84,7 +84,7 @@ abstract contract ModularAccountBenchmarkBase is BenchmarkBase, ModuleSignatureU uint32 sessionKeyEntityId = 1; ValidationConfig validationConfig = ValidationConfigLib.pack({ - _module: address(ecdsaValidationModule), + _module: address(singleSignerValidationModule), _entityId: sessionKeyEntityId, _isGlobal: false, _isSignatureValidation: false, @@ -153,14 +153,14 @@ abstract contract ModularAccountBenchmarkBase is BenchmarkBase, ModuleSignatureU (bool success,) = address(account1).call(_getInstallDataSessionKeyCase1()); require(success, "Install Session key 1 failed"); - return ModuleEntityLib.pack(address(ecdsaValidationModule), 1); + return ModuleEntityLib.pack(address(singleSignerValidationModule), 1); } function _verifySessionKeyCase1InstallState() internal view { // Assert account state is correctly set up ValidationDataView memory validationData = - account1.getValidationData(ModuleEntityLib.pack(address(ecdsaValidationModule), 1)); + account1.getValidationData(ModuleEntityLib.pack(address(singleSignerValidationModule), 1)); // Flags assertFalse(validationData.isGlobal); diff --git a/gas/modular-account/SemiModularAccount.gas.t.sol b/gas/modular-account/SemiModularAccount.gas.t.sol index f7564d57..1853cd1b 100644 --- a/gas/modular-account/SemiModularAccount.gas.t.sol +++ b/gas/modular-account/SemiModularAccount.gas.t.sol @@ -14,8 +14,7 @@ import {Vm} from "forge-std/src/Vm.sol"; import {ModularAccountBase} from "../../src/account/ModularAccountBase.sol"; import {AccountFactory} from "../../src/factory/AccountFactory.sol"; - -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; import {ModularAccountBenchmarkBase} from "./ModularAccountBenchmarkBase.sol"; @@ -238,7 +237,7 @@ contract ModularAccountGasTest is ModularAccountBenchmarkBase("SemiModularAccoun vm.deal(address(account1), 1 ether); - ECDSAValidationModule newValidationModule = _deployECDSAValidationModule(); + SingleSignerValidationModule newValidationModule = _deploySingleSignerValidationModule(); uint32 newEntityId = 0; (address owner2, uint256 owner2Key) = makeAddrAndKey("owner2"); diff --git a/src/factory/AccountFactory.sol b/src/factory/AccountFactory.sol index ebac2804..efa77008 100644 --- a/src/factory/AccountFactory.sol +++ b/src/factory/AccountFactory.sol @@ -26,13 +26,13 @@ contract AccountFactory is Ownable { IEntryPoint _entryPoint, ModularAccount _accountImpl, SemiModularAccountBytecode _semiModularImpl, - address _ecdsaValidationModule, + address _singleSignerValidationModule, address owner ) Ownable(owner) { ENTRY_POINT = _entryPoint; ACCOUNT_IMPL = _accountImpl; SEMI_MODULAR_ACCOUNT_IMPL = _semiModularImpl; - SINGLE_SIGNER_VALIDATION_MODULE = _ecdsaValidationModule; + SINGLE_SIGNER_VALIDATION_MODULE = _singleSignerValidationModule; } /** diff --git a/src/modules/validation/ECDSAValidationModule.sol b/src/modules/validation/SingleSignerValidationModule.sol similarity index 98% rename from src/modules/validation/ECDSAValidationModule.sol rename to src/modules/validation/SingleSignerValidationModule.sol index ffc5154c..1f919dc0 100644 --- a/src/modules/validation/ECDSAValidationModule.sol +++ b/src/modules/validation/SingleSignerValidationModule.sol @@ -43,7 +43,7 @@ import {BaseModule} from "../BaseModule.sol"; /// - This validation supports ERC-1271. The signature is valid if it is signed by the owner's private key. /// - This validation supports composition that other validation can relay on entities in this validation /// to validate partially or fully. -contract ECDSAValidationModule is IValidationModule, ReplaySafeWrapper, BaseModule { +contract SingleSignerValidationModule is IValidationModule, ReplaySafeWrapper, BaseModule { using MessageHashUtils for bytes32; uint256 internal constant _SIG_VALIDATION_PASSED = 0; diff --git a/test/account/DeferredValidation.t.sol b/test/account/DeferredValidation.t.sol index 0d352b40..c4f27d1b 100644 --- a/test/account/DeferredValidation.t.sol +++ b/test/account/DeferredValidation.t.sol @@ -31,7 +31,7 @@ contract DeferredValidationTest is AccountTestBase { function setUp() public override { _encodedCall = abi.encodeCall(ModularAccountBase.execute, (makeAddr("dead"), 0, "")); - _deferredValidation = ModuleEntityLib.pack(address(_deployECDSAValidationModule()), 0); + _deferredValidation = ModuleEntityLib.pack(address(_deploySingleSignerValidationModule()), 0); uint32 entityId = 0; (address newSigner, uint256 newSignerKey) = makeAddrAndKey("newSigner"); diff --git a/test/account/GlobalValidationTest.t.sol b/test/account/GlobalValidationTest.t.sol index 89569538..0f34318d 100644 --- a/test/account/GlobalValidationTest.t.sol +++ b/test/account/GlobalValidationTest.t.sol @@ -27,7 +27,8 @@ contract GlobalValidationTest is AccountTestBase { account2 = ModularAccount(payable(factory.getAddress(owner2, 0, TEST_DEFAULT_VALIDATION_ENTITY_ID))); vm.deal(address(account2), 100 ether); - _signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); + _signerValidation = + ModuleEntityLib.pack(address(singleSignerValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); ethRecipient = makeAddr("ethRecipient"); vm.deal(ethRecipient, 1 wei); diff --git a/test/account/ModularAccount.t.sol b/test/account/ModularAccount.t.sol index d36d103c..ca082ba8 100644 --- a/test/account/ModularAccount.t.sol +++ b/test/account/ModularAccount.t.sol @@ -19,7 +19,7 @@ import {ModularAccount} from "../../src/account/ModularAccount.sol"; import {ModularAccountBase} from "../../src/account/ModularAccountBase.sol"; import {ModuleManagerInternals} from "../../src/account/ModuleManagerInternals.sol"; import {SemiModularAccountBytecode} from "../../src/account/SemiModularAccountBytecode.sol"; -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; import {Counter} from "../mocks/Counter.sol"; import {ComprehensiveModule} from "../mocks/modules/ComprehensiveModule.sol"; @@ -104,9 +104,11 @@ contract ModularAccountTest is AccountTestBase { : abi.encodeCall( ModularAccountBase.execute, ( - address(ecdsaValidationModule), + address(singleSignerValidationModule), 0, - abi.encodeCall(ECDSAValidationModule.transferSigner, (TEST_DEFAULT_VALIDATION_ENTITY_ID, owner2)) + abi.encodeCall( + SingleSignerValidationModule.transferSigner, (TEST_DEFAULT_VALIDATION_ENTITY_ID, owner2) + ) ) ); @@ -398,26 +400,33 @@ contract ModularAccountTest is AccountTestBase { vm.stopPrank(); } - // TODO: Consider if this test belongs here or in the tests specific to the ECDSAValidationModule + // TODO: Consider if this test belongs here or in the tests specific to the SingleSignerValidationModule function test_transferOwnership() public withSMATest { if (_isSMATest) { // Note: replaced "owner1" with address(0), this doesn't actually affect the account, but allows the // test to pass by ensuring the signer can be set in the validation. assertEq( - ecdsaValidationModule.signers(TEST_DEFAULT_VALIDATION_ENTITY_ID, address(account1)), address(0) + singleSignerValidationModule.signers(TEST_DEFAULT_VALIDATION_ENTITY_ID, address(account1)), + address(0) ); } else { - assertEq(ecdsaValidationModule.signers(TEST_DEFAULT_VALIDATION_ENTITY_ID, address(account1)), owner1); + assertEq( + singleSignerValidationModule.signers(TEST_DEFAULT_VALIDATION_ENTITY_ID, address(account1)), owner1 + ); } vm.prank(address(entryPoint)); account1.execute( - address(ecdsaValidationModule), + address(singleSignerValidationModule), 0, - abi.encodeCall(ECDSAValidationModule.transferSigner, (TEST_DEFAULT_VALIDATION_ENTITY_ID, owner2)) + abi.encodeCall( + SingleSignerValidationModule.transferSigner, (TEST_DEFAULT_VALIDATION_ENTITY_ID, owner2) + ) ); - assertEq(ecdsaValidationModule.signers(TEST_DEFAULT_VALIDATION_ENTITY_ID, address(account1)), owner2); + assertEq( + singleSignerValidationModule.signers(TEST_DEFAULT_VALIDATION_ENTITY_ID, address(account1)), owner2 + ); } function test_isValidSignature() public withSMATest { @@ -425,7 +434,7 @@ contract ModularAccountTest is AccountTestBase { bytes32 replaySafeHash = _isSMATest ? SemiModularAccountBytecode(payable(account1)).replaySafeHash(message) - : ecdsaValidationModule.replaySafeHash(address(account1), message); + : singleSignerValidationModule.replaySafeHash(address(account1), message); (uint8 v, bytes32 r, bytes32 s) = vm.sign(owner1Key, replaySafeHash); @@ -439,11 +448,11 @@ contract ModularAccountTest is AccountTestBase { // Only need a test case for the negative case, as the positive case is covered by the isValidSignature test function test_signatureValidationFlag_enforce() public withSMATest { - // Install a new copy of ECDSAValidationModule with the signature validation flag set to false + // Install a new copy of SingleSignerValidationModule with the signature validation flag set to false uint32 newEntityId = 2; vm.prank(address(entryPoint)); account1.installValidation( - ValidationConfigLib.pack(address(ecdsaValidationModule), newEntityId, false, false, true), + ValidationConfigLib.pack(address(singleSignerValidationModule), newEntityId, false, false, true), new bytes4[](0), abi.encode(newEntityId, owner1), new bytes[](0) @@ -453,28 +462,28 @@ contract ModularAccountTest is AccountTestBase { bytes32 replaySafeHash = _isSMATest ? SemiModularAccountBytecode(payable(account1)).replaySafeHash(message) - : ecdsaValidationModule.replaySafeHash(address(account1), message); + : singleSignerValidationModule.replaySafeHash(address(account1), message); (uint8 v, bytes32 r, bytes32 s) = vm.sign(owner1Key, replaySafeHash); bytes memory signature = _encode1271Signature( - ModuleEntityLib.pack(address(ecdsaValidationModule), newEntityId), abi.encodePacked(r, s, v) + ModuleEntityLib.pack(address(singleSignerValidationModule), newEntityId), abi.encodePacked(r, s, v) ); vm.expectRevert( abi.encodeWithSelector( - ModularAccountBase.SignatureValidationInvalid.selector, ecdsaValidationModule, newEntityId + ModularAccountBase.SignatureValidationInvalid.selector, singleSignerValidationModule, newEntityId ) ); IERC1271(address(account1)).isValidSignature(message, signature); } function test_userOpValidationFlag_enforce() public withSMATest { - // Install a new copy of ECDSAValidationModule with the userOp validation flag set to false + // Install a new copy of SingleSignerValidationModule with the userOp validation flag set to false uint32 newEntityId = 2; vm.prank(address(entryPoint)); account1.installValidation( - ValidationConfigLib.pack(address(ecdsaValidationModule), newEntityId, true, false, false), + ValidationConfigLib.pack(address(singleSignerValidationModule), newEntityId, true, false, false), new bytes4[](0), abi.encode(newEntityId, owner1), new bytes[](0) @@ -496,7 +505,7 @@ contract ModularAccountTest is AccountTestBase { bytes32 userOpHash = entryPoint.getUserOpHash(userOp); (uint8 v, bytes32 r, bytes32 s) = vm.sign(owner1Key, userOpHash.toEthSignedMessageHash()); userOp.signature = _encodeSignature( - ModuleEntityLib.pack(address(ecdsaValidationModule), newEntityId), + ModuleEntityLib.pack(address(singleSignerValidationModule), newEntityId), GLOBAL_VALIDATION, abi.encodePacked(r, s, v) ); @@ -510,7 +519,7 @@ contract ModularAccountTest is AccountTestBase { 0, "AA23 reverted", abi.encodeWithSelector( - ModularAccountBase.UserOpValidationInvalid.selector, ecdsaValidationModule, newEntityId + ModularAccountBase.UserOpValidationInvalid.selector, singleSignerValidationModule, newEntityId ) ) ); @@ -521,7 +530,7 @@ contract ModularAccountTest is AccountTestBase { account1.executeWithRuntimeValidation( abi.encodeCall(ModularAccountBase.execute, (ethRecipient, 1 wei, "")), _encodeSignature( - ModuleEntityLib.pack(address(ecdsaValidationModule), newEntityId), GLOBAL_VALIDATION, "" + ModuleEntityLib.pack(address(singleSignerValidationModule), newEntityId), GLOBAL_VALIDATION, "" ) ); diff --git a/test/account/MultiValidation.t.sol b/test/account/MultiValidation.t.sol index d01f6a13..b76dc69e 100644 --- a/test/account/MultiValidation.t.sol +++ b/test/account/MultiValidation.t.sol @@ -10,7 +10,7 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import {ModularAccountBase} from "../../src/account/ModularAccountBase.sol"; -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; import {AccountTestBase} from "../utils/AccountTestBase.sol"; import {CODELESS_ADDRESS, TEST_DEFAULT_VALIDATION_ENTITY_ID} from "../utils/TestConstants.sol"; @@ -19,13 +19,13 @@ contract MultiValidationTest is AccountTestBase { using ECDSA for bytes32; using MessageHashUtils for bytes32; - ECDSAValidationModule public validator2; + SingleSignerValidationModule public validator2; address public owner2; uint256 public owner2Key; function setUp() public override { - validator2 = new ECDSAValidationModule(); + validator2 = new SingleSignerValidationModule(); (owner2, owner2Key) = makeAddrAndKey("owner2"); } diff --git a/test/account/PerHookData.t.sol b/test/account/PerHookData.t.sol index 9383295c..01b9e2dc 100644 --- a/test/account/PerHookData.t.sol +++ b/test/account/PerHookData.t.sol @@ -404,7 +404,7 @@ contract PerHookDataTest is CustomValidationTestBase { bytes32 messageHash = keccak256(abi.encodePacked(message)); - bytes32 replaySafeHash = ecdsaValidationModule.replaySafeHash(address(account1), messageHash); + bytes32 replaySafeHash = singleSignerValidationModule.replaySafeHash(address(account1), messageHash); (uint8 v, bytes32 r, bytes32 s) = vm.sign(owner1Key, replaySafeHash); PreValidationHookData[] memory preValidationHookData = new PreValidationHookData[](1); @@ -500,7 +500,7 @@ contract PerHookDataTest is CustomValidationTestBase { abi.encode(_PRE_HOOK_ENTITY_ID_1, _counter) ); // patched to work during SMA tests by enforcing that the new validation is not the fallback validation. - _signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), _VALIDATION_ENTITY_ID); + _signerValidation = ModuleEntityLib.pack(address(singleSignerValidationModule), _VALIDATION_ENTITY_ID); return ( _signerValidation, true, true, true, new bytes4[](0), abi.encode(_VALIDATION_ENTITY_ID, owner1), hooks ); diff --git a/test/account/ReplaceModule.t.sol b/test/account/ReplaceModule.t.sol index 787ad5c5..3ece5fc7 100644 --- a/test/account/ReplaceModule.t.sol +++ b/test/account/ReplaceModule.t.sol @@ -16,7 +16,7 @@ import {ModuleEntityLib} from "@erc6900/reference-implementation/libraries/Modul import {ValidationConfigLib} from "@erc6900/reference-implementation/libraries/ValidationConfigLib.sol"; import {ModularAccountBase} from "../../src/account/ModularAccountBase.sol"; -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; import {MockModule} from "../mocks/modules/MockModule.sol"; import {AccountTestBase} from "../utils/AccountTestBase.sol"; @@ -99,8 +99,8 @@ contract UpgradeModuleTest is AccountTestBase { function test_upgradeModuleValidationFunction() public withSMATest { // Setup new validaiton with pre validation and execution hooks associated with a validator - ECDSAValidationModule validation1 = new ECDSAValidationModule(); - ECDSAValidationModule validation2 = new ECDSAValidationModule(); + SingleSignerValidationModule validation1 = new SingleSignerValidationModule(); + SingleSignerValidationModule validation2 = new SingleSignerValidationModule(); uint32 validationEntityId1 = 10; uint32 validationEntityId2 = 11; diff --git a/test/modules/AllowlistModule.t.sol b/test/modules/AllowlistModule.t.sol index cf8fd92e..de9842ab 100644 --- a/test/modules/AllowlistModule.t.sol +++ b/test/modules/AllowlistModule.t.sol @@ -36,7 +36,8 @@ contract AllowlistModuleTest is CustomValidationTestBase { ); function setUp() public override { - _signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); + _signerValidation = + ModuleEntityLib.pack(address(singleSignerValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); allowlistModule = new AllowlistModule(); @@ -550,7 +551,7 @@ contract AllowlistModuleTest is CustomValidationTestBase { abi.encode(HOOK_ENTITY_ID, allowlistInputs) ); // patched to also work during SMA tests by differentiating the validation - _signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), type(uint32).max - 1); + _signerValidation = ModuleEntityLib.pack(address(singleSignerValidationModule), type(uint32).max - 1); return (_signerValidation, true, true, true, new bytes4[](0), abi.encode(type(uint32).max - 1, owner1), hooks); } diff --git a/test/modules/TimeRangeModule.t.sol b/test/modules/TimeRangeModule.t.sol index f1b63e21..539d16e5 100644 --- a/test/modules/TimeRangeModule.t.sol +++ b/test/modules/TimeRangeModule.t.sol @@ -28,7 +28,8 @@ contract TimeRangeModuleTest is CustomValidationTestBase { uint48 public validAfter; function setUp() public override { - _signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); + _signerValidation = + ModuleEntityLib.pack(address(singleSignerValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); timeRangeModule = new TimeRangeModule(); @@ -264,7 +265,7 @@ contract TimeRangeModuleTest is CustomValidationTestBase { abi.encode(HOOK_ENTITY_ID, validUntil, validAfter) ); // patched to also work during SMA tests by differentiating the validation - _signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), type(uint32).max - 1); + _signerValidation = ModuleEntityLib.pack(address(singleSignerValidationModule), type(uint32).max - 1); return (_signerValidation, true, true, true, new bytes4[](0), abi.encode(type(uint32).max - 1, owner1), hooks); } diff --git a/test/utils/AccountTestBase.sol b/test/utils/AccountTestBase.sol index 1ae9d033..4b83a09b 100644 --- a/test/utils/AccountTestBase.sol +++ b/test/utils/AccountTestBase.sol @@ -18,7 +18,7 @@ import {ModularAccount} from "../../src/account/ModularAccount.sol"; import {SemiModularAccountBytecode} from "../../src/account/SemiModularAccountBytecode.sol"; import {AccountFactory} from "../../src/factory/AccountFactory.sol"; import {FALLBACK_VALIDATION} from "../../src/helpers/Constants.sol"; -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; import {ModuleSignatureUtils} from "./ModuleSignatureUtils.sol"; import {OptimizedTest} from "./OptimizedTest.sol"; @@ -26,7 +26,7 @@ import {TEST_DEFAULT_VALIDATION_ENTITY_ID as EXT_CONST_TEST_DEFAULT_VALIDATION_E "./TestConstants.sol"; /// @dev This contract handles common boilerplate setup for tests using ModularAccount with -/// ECDSAValidationModule. +/// SingleSignerValidationModule. abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { using ModuleEntityLib for ModuleEntity; using MessageHashUtils for bytes32; @@ -34,7 +34,7 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { EntryPoint public entryPoint; address payable public beneficiary; - ECDSAValidationModule public ecdsaValidationModule; + SingleSignerValidationModule public singleSignerValidationModule; ModularAccount public accountImplementation; SemiModularAccountBytecode public semiModularAccountImplementation; AccountFactory public factory; @@ -79,12 +79,12 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { factoryOwner = makeAddr("factoryOwner"); beneficiary = payable(makeAddr("beneficiary")); - // address deployedECDSAValidationModule = address(_deployECDSAValidationModule()); + // address deployedSingleSignerValidationModule = address(_deploySingleSignerValidationModule()); // We etch the single signer validation to the max address, such that it coincides with the fallback // validation module entity for semi modular account tests. - ecdsaValidationModule = _deployECDSAValidationModule(); - // vm.etch(address(0), deployedECDSAValidationModule.code); + singleSignerValidationModule = _deploySingleSignerValidationModule(); + // vm.etch(address(0), deployedSingleSignerValidationModule.code); accountImplementation = _deployModularAccount(entryPoint); @@ -95,7 +95,7 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { entryPoint, accountImplementation, semiModularAccountImplementation, - address(ecdsaValidationModule), + address(singleSignerValidationModule), factoryOwner ); @@ -103,7 +103,8 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { vm.deal(address(account1), 100 ether); - _signerValidation = ModuleEntityLib.pack(address(ecdsaValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); + _signerValidation = + ModuleEntityLib.pack(address(singleSignerValidationModule), TEST_DEFAULT_VALIDATION_ENTITY_ID); _revertSnapshot = vm.snapshot(); } @@ -231,10 +232,11 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { abi.encodeCall( account1.execute, ( - address(ecdsaValidationModule), + address(singleSignerValidationModule), 0, abi.encodeCall( - ECDSAValidationModule.transferSigner, (TEST_DEFAULT_VALIDATION_ENTITY_ID, address(this)) + SingleSignerValidationModule.transferSigner, + (TEST_DEFAULT_VALIDATION_ENTITY_ID, address(this)) ) ) ), @@ -289,7 +291,7 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { ), signingKey, account, - ecdsaValidationModule + singleSignerValidationModule ) ); @@ -308,7 +310,7 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { bytes32 hash, uint256 signingKey, ModularAccount account, - ECDSAValidationModule validationModule + SingleSignerValidationModule validationModule ) internal view returns (bytes memory) { bytes32 replaySafeHash; if (_isSMATest) { diff --git a/test/utils/ModuleSignatureUtils.sol b/test/utils/ModuleSignatureUtils.sol index bee8c959..c60b17be 100644 --- a/test/utils/ModuleSignatureUtils.sol +++ b/test/utils/ModuleSignatureUtils.sol @@ -11,7 +11,7 @@ import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/Messa import {ModularAccount} from "../../src/account/ModularAccount.sol"; import {SemiModularAccountBytecode} from "../../src/account/SemiModularAccountBytecode.sol"; -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; /// @dev Utilities for encoding signatures for modular account validation. Used for encoding user op, runtime, and /// 1271 signatures. @@ -147,7 +147,7 @@ contract ModuleSignatureUtils { function _getECDSAReplaySafeHash( ModularAccount account, - ECDSAValidationModule validationModule, + SingleSignerValidationModule validationModule, bytes32 typedDataHash ) internal view returns (bytes32) { return validationModule.replaySafeHash(address(account), typedDataHash); diff --git a/test/utils/OptimizedTest.sol b/test/utils/OptimizedTest.sol index 2104eb3d..d427aff4 100644 --- a/test/utils/OptimizedTest.sol +++ b/test/utils/OptimizedTest.sol @@ -8,8 +8,7 @@ import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntry import {ModularAccount} from "../../src/account/ModularAccount.sol"; import {SemiModularAccountBytecode} from "../../src/account/SemiModularAccountBytecode.sol"; - -import {ECDSAValidationModule} from "../../src/modules/validation/ECDSAValidationModule.sol"; +import {SingleSignerValidationModule} from "../../src/modules/validation/SingleSignerValidationModule.sol"; /// @dev This contract provides functions to deploy optimized (via IR) precompiled contracts. By compiling just /// the source contracts (excluding the test suite) via IR, and using the resulting bytecode within the tests @@ -54,10 +53,12 @@ abstract contract OptimizedTest is Test { : new SemiModularAccountBytecode(entryPoint); } - function _deployECDSAValidationModule() internal returns (ECDSAValidationModule) { + function _deploySingleSignerValidationModule() internal returns (SingleSignerValidationModule) { return _isOptimizedTest() - ? ECDSAValidationModule(deployCode("out-optimized/ECDSAValidationModule.sol/ECDSAValidationModule.json")) - : new ECDSAValidationModule(); + ? SingleSignerValidationModule( + deployCode("out-optimized/SingleSignerValidationModule.sol/SingleSignerValidationModule.json") + ) + : new SingleSignerValidationModule(); } function _deployEntryPoint070() internal returns (EntryPoint) {