From 1778256086b4068e19dd26f1bfe954c0c8efcdbe Mon Sep 17 00:00:00 2001 From: Jay Paik Date: Wed, 27 Nov 2024 11:48:17 -0500 Subject: [PATCH] feat: bump spec to v0.8.0-rc.7 --- gas-snapshots/ModularAccount.json | 28 +++++++++---------- gas-snapshots/SemiModularAccount.json | 26 ++++++++--------- gas/BenchmarkBase.sol | 3 +- .../ModularAccountBenchmarkBase.sol | 11 ++++---- package.json | 2 +- pnpm-lock.yaml | 13 +++++---- src/account/AccountStorage.sol | 14 +++++----- src/account/ModularAccountBase.sol | 12 ++++---- src/account/ModularAccountView.sol | 4 +-- src/account/ModuleManagerInternals.sol | 17 ++++++----- src/libraries/ValidationLocatorLib.sol | 10 +++---- test/account/AccountReturnData.t.sol | 4 +-- test/account/DirectCallsFromModule.t.sol | 6 ++-- test/account/HookOrdering.t.sol | 10 +++---- test/account/ModularAccountView.t.sol | 13 ++++++--- test/account/PHCallBuffers.t.sol | 4 +-- .../SemiModularAccountDirectCall.t.sol | 6 ++-- test/libraries/ValidationLocatorLib.t.sol | 6 ++-- test/mocks/modules/ReturnDataModuleMocks.sol | 4 +-- test/modules/TimeRangeModule.t.sol | 11 +++++--- test/utils/AccountTestBase.sol | 4 +-- test/utils/ModuleSignatureUtils.sol | 8 +++--- 22 files changed, 112 insertions(+), 104 deletions(-) diff --git a/gas-snapshots/ModularAccount.json b/gas-snapshots/ModularAccount.json index b6faa36c..66b15ed8 100644 --- a/gas-snapshots/ModularAccount.json +++ b/gas-snapshots/ModularAccount.json @@ -1,16 +1,16 @@ { - "Runtime_AccountCreation": "176354", - "Runtime_BatchTransfers": "92908", - "Runtime_Erc20Transfer": "78340", - "Runtime_InstallSessionKey_Case1": "429739", - "Runtime_NativeTransfer": "54489", - "Runtime_UseSessionKey_Case1_Counter": "78484", - "Runtime_UseSessionKey_Case1_Token": "111797", - "UserOp_BatchTransfers": "197728", - "UserOp_Erc20Transfer": "184702", - "UserOp_InstallSessionKey_Case1": "537419", - "UserOp_NativeTransfer": "160947", - "UserOp_UseSessionKey_Case1_Counter": "194415", - "UserOp_UseSessionKey_Case1_Token": "225399", - "UserOp_deferredValidation": "232968" + "Runtime_AccountCreation": "176256", + "Runtime_BatchTransfers": "92914", + "Runtime_Erc20Transfer": "78346", + "Runtime_InstallSessionKey_Case1": "429647", + "Runtime_NativeTransfer": "54495", + "Runtime_UseSessionKey_Case1_Counter": "78523", + "Runtime_UseSessionKey_Case1_Token": "111836", + "UserOp_BatchTransfers": "197734", + "UserOp_Erc20Transfer": "184708", + "UserOp_InstallSessionKey_Case1": "537327", + "UserOp_NativeTransfer": "160953", + "UserOp_UseSessionKey_Case1_Counter": "194454", + "UserOp_UseSessionKey_Case1_Token": "225438", + "UserOp_deferredValidation": "232882" } \ No newline at end of file diff --git a/gas-snapshots/SemiModularAccount.json b/gas-snapshots/SemiModularAccount.json index f5391edc..a6a55926 100644 --- a/gas-snapshots/SemiModularAccount.json +++ b/gas-snapshots/SemiModularAccount.json @@ -1,16 +1,16 @@ { "Runtime_AccountCreation": "97767", - "Runtime_BatchTransfers": "88735", - "Runtime_Erc20Transfer": "74215", - "Runtime_InstallSessionKey_Case1": "427845", - "Runtime_NativeTransfer": "50374", - "Runtime_UseSessionKey_Case1_Counter": "78787", - "Runtime_UseSessionKey_Case1_Token": "112100", - "UserOp_BatchTransfers": "192852", - "UserOp_Erc20Transfer": "179909", - "UserOp_InstallSessionKey_Case1": "534647", - "UserOp_NativeTransfer": "156184", - "UserOp_UseSessionKey_Case1_Counter": "194667", - "UserOp_UseSessionKey_Case1_Token": "225651", - "UserOp_deferredValidation": "228829" + "Runtime_BatchTransfers": "88746", + "Runtime_Erc20Transfer": "74226", + "Runtime_InstallSessionKey_Case1": "427850", + "Runtime_NativeTransfer": "50385", + "Runtime_UseSessionKey_Case1_Counter": "78826", + "Runtime_UseSessionKey_Case1_Token": "112139", + "UserOp_BatchTransfers": "192863", + "UserOp_Erc20Transfer": "179920", + "UserOp_InstallSessionKey_Case1": "534652", + "UserOp_NativeTransfer": "156195", + "UserOp_UseSessionKey_Case1_Counter": "194706", + "UserOp_UseSessionKey_Case1_Token": "225690", + "UserOp_deferredValidation": "228856" } \ No newline at end of file diff --git a/gas/BenchmarkBase.sol b/gas/BenchmarkBase.sol index 95aec839..4ae83b31 100644 --- a/gas/BenchmarkBase.sol +++ b/gas/BenchmarkBase.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.26; +import {console} from "forge-std/console.sol"; + import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol"; -import {console} from "forge-std/console.sol"; import {MockERC20} from "../test/mocks/MockERC20.sol"; import {OptimizedTest} from "../test/utils/OptimizedTest.sol"; diff --git a/gas/modular-account/ModularAccountBenchmarkBase.sol b/gas/modular-account/ModularAccountBenchmarkBase.sol index 57ae0018..091af661 100644 --- a/gas/modular-account/ModularAccountBenchmarkBase.sol +++ b/gas/modular-account/ModularAccountBenchmarkBase.sol @@ -4,7 +4,8 @@ pragma solidity ^0.8.26; import { HookConfig, ModuleEntity, - ValidationConfig + ValidationConfig, + ValidationFlags } from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import {ValidationDataView} from "@erc6900/reference-implementation/interfaces/IModularAccountView.sol"; import {HookConfigLib} from "@erc6900/reference-implementation/libraries/HookConfigLib.sol"; @@ -29,7 +30,7 @@ import {ModuleSignatureUtils} from "../../test/utils/ModuleSignatureUtils.sol"; import {BenchmarkBase} from "../BenchmarkBase.sol"; abstract contract ModularAccountBenchmarkBase is BenchmarkBase, ModuleSignatureUtils { - using ValidationConfigLib for ValidationConfig; + using ValidationConfigLib for ValidationFlags; AccountFactory public factory; ModularAccount public accountImpl; @@ -172,9 +173,9 @@ abstract contract ModularAccountBenchmarkBase is BenchmarkBase, ModuleSignatureU account1.getValidationData(ModuleEntityLib.pack(address(singleSignerValidationModule), 1)); // Flags - assertFalse(validationData.isGlobal); - assertFalse(validationData.isSignatureValidation); - assertTrue(validationData.isUserOpValidation); + assertFalse(validationData.validationFlags.isGlobal()); + assertFalse(validationData.validationFlags.isSignatureValidation()); + assertTrue(validationData.validationFlags.isUserOpValidation()); // Validation hooks assertEq(validationData.validationHooks.length, 2); diff --git a/package.json b/package.json index f418d296..99d9c9a3 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "v1.0.1", "dependencies": { "account-abstraction": "github:eth-infinitism/account-abstraction#v0.7.0", - "@erc6900/reference-implementation": "github:erc6900/reference-implementation#v0.8.0-rc.5", + "@erc6900/reference-implementation": "github:erc6900/reference-implementation#v0.8.0-rc.7", "solady": "github:Vectorized/solady#v0.0.237" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index da07bfbe..36137074 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@erc6900/reference-implementation': - specifier: github:erc6900/reference-implementation#v0.8.0-rc.5 - version: git+https://git@github.com:erc6900/reference-implementation.git#e5f55ab1c3ac2f78efa14967e90e95c3e4ace38c + specifier: github:erc6900/reference-implementation#v0.8.0-rc.7 + version: https://codeload.github.com/erc6900/reference-implementation/tar.gz/bfe5d75fcabd1e0c8571b65ccaf104c43bc6dfb8 account-abstraction: specifier: github:eth-infinitism/account-abstraction#v0.7.0 version: accountabstraction@git+https://git@github.com:eth-infinitism/account-abstraction.git#d99245ddb2d7bde4d2132757c4394818f1d11da0(ethers@5.7.2)(hardhat@2.22.10(typescript@4.9.5))(lodash@4.17.21)(typechain@5.2.0(typescript@4.9.5)) @@ -39,9 +39,9 @@ packages: resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} engines: {node: '>=6.9.0'} - '@erc6900/reference-implementation@git+https://git@github.com:erc6900/reference-implementation.git#e5f55ab1c3ac2f78efa14967e90e95c3e4ace38c': - resolution: {commit: e5f55ab1c3ac2f78efa14967e90e95c3e4ace38c, repo: git@github.com:erc6900/reference-implementation.git, type: git} - version: 0.8.0-rc.5 + '@erc6900/reference-implementation@https://codeload.github.com/erc6900/reference-implementation/tar.gz/bfe5d75fcabd1e0c8571b65ccaf104c43bc6dfb8': + resolution: {tarball: https://codeload.github.com/erc6900/reference-implementation/tar.gz/bfe5d75fcabd1e0c8571b65ccaf104c43bc6dfb8} + version: 0.8.0-rc.7 '@ethereumjs/rlp@4.0.1': resolution: {integrity: sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw==} @@ -774,6 +774,7 @@ packages: ethereumjs-abi@0.6.8: resolution: {integrity: sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA==} + deprecated: This library has been deprecated and usage is discouraged. ethereumjs-util@6.2.1: resolution: {integrity: sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==} @@ -1810,7 +1811,7 @@ snapshots: js-tokens: 4.0.0 picocolors: 1.1.0 - '@erc6900/reference-implementation@git+https://git@github.com:erc6900/reference-implementation.git#e5f55ab1c3ac2f78efa14967e90e95c3e4ace38c': {} + '@erc6900/reference-implementation@https://codeload.github.com/erc6900/reference-implementation/tar.gz/bfe5d75fcabd1e0c8571b65ccaf104c43bc6dfb8': {} '@ethereumjs/rlp@4.0.1': {} diff --git a/src/account/AccountStorage.sol b/src/account/AccountStorage.sol index 7413c884..20310af1 100644 --- a/src/account/AccountStorage.sol +++ b/src/account/AccountStorage.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {HookConfig} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; +import {HookConfig, ValidationFlags} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import {LinkedListSet, SetValue} from "../libraries/LinkedListSetLib.sol"; import {ValidationLookupKey} from "../libraries/ValidationLocatorLib.sol"; @@ -46,12 +46,12 @@ struct ExecutionStorage { struct ValidationStorage { // The address of the validation module. address module; - // Whether or not this validation can be used as a global validation function. - bool isGlobal; - // Whether or not this validation is allowed to validate ERC-1271 signatures. - bool isSignatureValidation; - // Whether or not this validation is allowed to validate ERC-4337 user operations. - bool isUserOpValidation; + // ValidationFlags layout: + // 0b00000___ // unused + // 0b_____A__ // isGlobal + // 0b______B_ // isSignatureValidation + // 0b_______C // isUserOpValidation + ValidationFlags validationFlags; // Length of the validation hooks for this validation function. The length is stored here, in the same storage // slot as the flags, to save an `sload` when putting the hooks into memory. uint8 validationHookCount; diff --git a/src/account/ModularAccountBase.sol b/src/account/ModularAccountBase.sol index 449c319f..d0bbd01f 100644 --- a/src/account/ModularAccountBase.sol +++ b/src/account/ModularAccountBase.sol @@ -24,7 +24,8 @@ import { HookConfig, IModularAccount, ModuleEntity, - ValidationConfig + ValidationConfig, + ValidationFlags } from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import {HookConfig, HookConfigLib} from "@erc6900/reference-implementation/libraries/HookConfigLib.sol"; import {ModuleEntityLib} from "@erc6900/reference-implementation/libraries/ModuleEntityLib.sol"; @@ -42,7 +43,6 @@ import {UUPSUpgradeable} from "solady/utils/UUPSUpgradeable.sol"; import {ExecutionInstallDelegate} from "../helpers/ExecutionInstallDelegate.sol"; import {_coalescePreValidation, _coalesceValidation} from "../helpers/ValidationResHelpers.sol"; - import {IModularAccountBase} from "../interfaces/IModularAccountBase.sol"; import { DensePostHookData, @@ -83,7 +83,7 @@ abstract contract ModularAccountBase is { using LinkedListSetLib for LinkedListSet; using ModuleEntityLib for ModuleEntity; - using ValidationConfigLib for ValidationConfig; + using ValidationConfigLib for ValidationFlags; using HookConfigLib for HookConfig; using SparseCalldataSegmentLib for bytes; @@ -717,7 +717,7 @@ abstract contract ModularAccountBase is ModuleEntity userOpValidationFunction = validationLookupKey.moduleEntity(_validationStorage); - if (!_validationStorage.isUserOpValidation) { + if (!_validationStorage.validationFlags.isUserOpValidation()) { revert UserOpValidationInvalid(userOpValidationFunction); } @@ -851,7 +851,7 @@ abstract contract ModularAccountBase is ModuleEntity sigValidation = validationLookupKey.moduleEntity(_validationStorage); - if (!_validationStorage.isSignatureValidation) { + if (!_validationStorage.validationFlags.isSignatureValidation()) { revert SignatureValidationInvalid(sigValidation); } @@ -862,7 +862,7 @@ abstract contract ModularAccountBase is } function _isValidationGlobal(ValidationLookupKey validationFunction) internal view virtual returns (bool) { - return getAccountStorage().validationStorage[validationFunction].isGlobal; + return getAccountStorage().validationStorage[validationFunction].validationFlags.isGlobal(); } function _checkIfValidationAppliesCallData( diff --git a/src/account/ModularAccountView.sol b/src/account/ModularAccountView.sol index bee924ae..c6b11773 100644 --- a/src/account/ModularAccountView.sol +++ b/src/account/ModularAccountView.sol @@ -79,9 +79,7 @@ abstract contract ModularAccountView is IModularAccountView { { ValidationStorage storage validationStorage = getAccountStorage().validationStorage[ValidationLocatorLib.moduleEntityToLookupKey(validationFunction)]; - data.isGlobal = validationStorage.isGlobal; - data.isSignatureValidation = validationStorage.isSignatureValidation; - data.isUserOpValidation = validationStorage.isUserOpValidation; + data.validationFlags = validationStorage.validationFlags; data.validationHooks = MemManagementLib.loadValidationHooks(validationStorage); MemManagementLib.reverseArr(data.validationHooks); diff --git a/src/account/ModuleManagerInternals.sol b/src/account/ModuleManagerInternals.sol index 25b882b3..6a09c097 100644 --- a/src/account/ModuleManagerInternals.sol +++ b/src/account/ModuleManagerInternals.sol @@ -23,7 +23,8 @@ import { HookConfig, IModularAccount, ModuleEntity, - ValidationConfig + ValidationConfig, + ValidationFlags } from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import {IValidationHookModule} from "@erc6900/reference-implementation/interfaces/IValidationHookModule.sol"; import {IValidationModule} from "@erc6900/reference-implementation/interfaces/IValidationModule.sol"; @@ -66,15 +67,15 @@ abstract contract ModuleManagerInternals is IModularAccount { // account. address storedAddress = validationStorage.module; + (address moduleAddress,, ValidationFlags validationFlags) = validationConfig.unpackUnderlying(); + if (storedAddress == address(0)) { - validationStorage.module = validationConfig.module(); - } else if (storedAddress != validationConfig.module()) { + validationStorage.module = moduleAddress; + } else if (storedAddress != moduleAddress) { revert ValidationEntityIdInUse(); } - validationStorage.isGlobal = validationConfig.isGlobal(); - validationStorage.isSignatureValidation = validationConfig.isSignatureValidation(); - validationStorage.isUserOpValidation = validationConfig.isUserOpValidation(); + validationStorage.validationFlags = validationFlags; uint256 length = selectors.length; for (uint256 i = 0; i < length; ++i) { @@ -87,9 +88,7 @@ abstract contract ModuleManagerInternals is IModularAccount { function _removeValidationFunction(ValidationStorage storage validationStorage) internal { validationStorage.module = address(0); - validationStorage.isGlobal = false; - validationStorage.isSignatureValidation = false; - validationStorage.isUserOpValidation = false; + validationStorage.validationFlags = ValidationFlags.wrap(0); validationStorage.validationHookCount = 0; validationStorage.executionHookCount = 0; } diff --git a/src/libraries/ValidationLocatorLib.sol b/src/libraries/ValidationLocatorLib.sol index dfff9371..80f338ce 100644 --- a/src/libraries/ValidationLocatorLib.sol +++ b/src/libraries/ValidationLocatorLib.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import {ModuleEntity, ModuleEntityLib} from "@erc6900/reference-implementation/libraries/ModuleEntityLib.sol"; import { ValidationConfig, @@ -60,7 +60,7 @@ library ValidationLocatorLib { returns (ModuleEntity result) { if (_lookupKey.isDirectCallValidation()) { - result = ModuleEntityLib.pack(_lookupKey.directCallAddress(), DIRECT_CALL_VALIDATION_ENTITYID); + result = ModuleEntityLib.pack(_lookupKey.directCallAddress(), DIRECT_CALL_VALIDATION_ENTITY_ID); } else { result = ModuleEntityLib.pack(validationStorage.module, _lookupKey.entityId()); } @@ -204,7 +204,7 @@ library ValidationLocatorLib { pure returns (ValidationLookupKey result) { - if (validationConfig.entityId() == DIRECT_CALL_VALIDATION_ENTITYID) { + if (validationConfig.entityId() == DIRECT_CALL_VALIDATION_ENTITY_ID) { result = ValidationLookupKey.wrap( uint168(uint160(validationConfig.module())) << 8 | _IS_DIRECT_CALL_VALIDATION ); @@ -219,7 +219,7 @@ library ValidationLocatorLib { returns (ValidationLookupKey result) { (address module, uint32 _entityId) = ModuleEntityLib.unpack(_moduleEntity); - if (_entityId == DIRECT_CALL_VALIDATION_ENTITYID) { + if (_entityId == DIRECT_CALL_VALIDATION_ENTITY_ID) { result = ValidationLookupKey.wrap(uint168(uint160(module)) << 8 | _IS_DIRECT_CALL_VALIDATION); } else { result = ValidationLookupKey.wrap(uint168(uint160(_entityId)) << 8); @@ -349,7 +349,7 @@ library ValidationLocatorLib { uint168 result; (address module, uint32 _entityId) = ModuleEntityLib.unpack(_moduleEntity); - if (_entityId == DIRECT_CALL_VALIDATION_ENTITYID) { + if (_entityId == DIRECT_CALL_VALIDATION_ENTITY_ID) { result = uint168(uint160(module)) << 8 | _IS_DIRECT_CALL_VALIDATION; } else { result = uint168(_entityId) << 8; diff --git a/test/account/AccountReturnData.t.sol b/test/account/AccountReturnData.t.sol index 2b1278fc..081d45c8 100644 --- a/test/account/AccountReturnData.t.sol +++ b/test/account/AccountReturnData.t.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import {Call} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import {IModularAccount} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import {ValidationConfigLib} from "@erc6900/reference-implementation/libraries/ValidationConfigLib.sol"; @@ -61,7 +61,7 @@ contract AccountReturnDataTest is AccountTestBase { selectors[0] = IModularAccount.execute.selector; account1.installValidation( ValidationConfigLib.pack( - address(resultConsumerModule), DIRECT_CALL_VALIDATION_ENTITYID, false, false, true + address(resultConsumerModule), DIRECT_CALL_VALIDATION_ENTITY_ID, false, false, true ), // todo: does this need UO validation permission? selectors, "", diff --git a/test/account/DirectCallsFromModule.t.sol b/test/account/DirectCallsFromModule.t.sol index 272543a2..587530e8 100644 --- a/test/account/DirectCallsFromModule.t.sol +++ b/test/account/DirectCallsFromModule.t.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import { Call, IModularAccount, @@ -56,7 +56,7 @@ contract DirectCallsFromModuleTest is AccountTestBase { _module = new DirectCallModule(); assertFalse(_module.preHookRan()); assertFalse(_module.postHookRan()); - _moduleEntity = ModuleEntityLib.pack(address(_module), DIRECT_CALL_VALIDATION_ENTITYID); + _moduleEntity = ModuleEntityLib.pack(address(_module), DIRECT_CALL_VALIDATION_ENTITY_ID); } /* -------------------------------------------------------------------------- */ @@ -160,7 +160,7 @@ contract DirectCallsFromModuleTest is AccountTestBase { vm.prank(address(entryPoint)); account1.installValidation( - ValidationConfigLib.pack(extraOwner, DIRECT_CALL_VALIDATION_ENTITYID, false, false, false), + ValidationConfigLib.pack(extraOwner, DIRECT_CALL_VALIDATION_ENTITY_ID, false, false, false), selectors, "", new bytes[](0) diff --git a/test/account/HookOrdering.t.sol b/test/account/HookOrdering.t.sol index 29d845ce..de6f14a5 100644 --- a/test/account/HookOrdering.t.sol +++ b/test/account/HookOrdering.t.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import { ExecutionManifest, ManifestExecutionHook @@ -200,7 +200,7 @@ contract HookOrderingTest is AccountTestBase { } function test_hookOrder_directCall_moduleExecFunction() public withSMATest { - _installOrderCheckerModuleWithValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITYID); + _installOrderCheckerModuleWithValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITY_ID); vm.prank(address(hookOrderChecker)); HookOrderCheckerModule(address(account1)).foo(17); @@ -209,7 +209,7 @@ contract HookOrderingTest is AccountTestBase { } function test_hookOrder_directCall_moduleExecFunction_noAssoc() public withSMATest { - _installOrderCheckerModuleNoValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITYID); + _installOrderCheckerModuleNoValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITY_ID); vm.prank(address(hookOrderChecker)); HookOrderCheckerModule(address(account1)).foo(17); @@ -329,7 +329,7 @@ contract HookOrderingTest is AccountTestBase { } function test_hookOrder_directCall_accountNativeFunction_withAssoc() public withSMATest { - _installOrderCheckerModuleWithValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITYID); + _installOrderCheckerModuleWithValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITY_ID); vm.prank(address(hookOrderChecker)); HookOrderCheckerModule(address(account1)).foo(17); @@ -338,7 +338,7 @@ contract HookOrderingTest is AccountTestBase { } function test_hookOrder_directCall_accountNativeFunction_noAssoc() public withSMATest { - _installOrderCheckerModuleNoValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITYID); + _installOrderCheckerModuleNoValidationAssocExec(DIRECT_CALL_VALIDATION_ENTITY_ID); vm.prank(address(hookOrderChecker)); HookOrderCheckerModule(address(account1)).foo(17); diff --git a/test/account/ModularAccountView.t.sol b/test/account/ModularAccountView.t.sol index cbd049d9..88af6cef 100644 --- a/test/account/ModularAccountView.t.sol +++ b/test/account/ModularAccountView.t.sol @@ -25,7 +25,8 @@ import { import { HookConfig, IModularAccount, - ModuleEntity + ModuleEntity, + ValidationFlags } from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import { ExecutionDataView, @@ -33,17 +34,21 @@ import { } from "@erc6900/reference-implementation/interfaces/IModularAccountView.sol"; import {HookConfigLib} from "@erc6900/reference-implementation/libraries/HookConfigLib.sol"; import {ModuleEntityLib} from "@erc6900/reference-implementation/libraries/ModuleEntityLib.sol"; +import {ValidationConfigLib} from "@erc6900/reference-implementation/libraries/ValidationConfigLib.sol"; import {IAccountExecute} from "@eth-infinitism/account-abstraction/interfaces/IAccountExecute.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; import {ModularAccount} from "../../src/account/ModularAccount.sol"; import {SemiModularAccountBase} from "../../src/account/SemiModularAccountBase.sol"; import {IModularAccountBase} from "../../src/interfaces/IModularAccountBase.sol"; + import {ComprehensiveModule} from "../mocks/modules/ComprehensiveModule.sol"; import {MockModule} from "../mocks/modules/MockModule.sol"; import {CustomValidationTestBase} from "../utils/CustomValidationTestBase.sol"; contract ModularAccountViewTest is CustomValidationTestBase { + using ValidationConfigLib for ValidationFlags; + ComprehensiveModule public comprehensiveModule; event ReceivedCall(bytes msgData, uint256 msgValue); @@ -283,9 +288,9 @@ contract ModularAccountViewTest is CustomValidationTestBase { ValidationDataView memory data = account1.getValidationData(comprehensiveModuleValidation); bytes4[] memory selectors = data.selectors; - assertTrue(data.isGlobal); - assertTrue(data.isSignatureValidation); - assertTrue(data.isUserOpValidation); + assertTrue(data.validationFlags.isGlobal()); + assertTrue(data.validationFlags.isSignatureValidation()); + assertTrue(data.validationFlags.isUserOpValidation()); assertEq(data.validationHooks.length, 2); assertEq( HookConfig.unwrap(data.validationHooks[0]), diff --git a/test/account/PHCallBuffers.t.sol b/test/account/PHCallBuffers.t.sol index ba1a58ee..2a65bf58 100644 --- a/test/account/PHCallBuffers.t.sol +++ b/test/account/PHCallBuffers.t.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import {IExecutionHookModule} from "@erc6900/reference-implementation/interfaces/IExecutionHookModule.sol"; import { ExecutionManifest, @@ -434,7 +434,7 @@ contract PHCallBufferTest is AccountTestBase { // pre hooks in `_checkPermittedCallerAndAssociatedHooks` (direct call validation, with pre RT hooks) function test_preExecHooks_directCallValidation_withPRTHooks() public withSMATest { - _install3ValAssocExecHooks(DIRECT_CALL_VALIDATION_ENTITYID, true); + _install3ValAssocExecHooks(DIRECT_CALL_VALIDATION_ENTITY_ID, true); _addPreRuntimeValidationHook(); bytes memory callData = abi.encodeCall(account1.execute, (beneficiary, 0 wei, "")); diff --git a/test/account/SemiModularAccountDirectCall.t.sol b/test/account/SemiModularAccountDirectCall.t.sol index 44212971..f6e7bbaf 100644 --- a/test/account/SemiModularAccountDirectCall.t.sol +++ b/test/account/SemiModularAccountDirectCall.t.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import {ModuleEntity, ValidationConfig} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import {HookConfigLib} from "@erc6900/reference-implementation/libraries/HookConfigLib.sol"; import {ModuleEntityLib} from "@erc6900/reference-implementation/libraries/ModuleEntityLib.sol"; @@ -39,9 +39,9 @@ contract SemiModularAccountDirectCallTest is AccountTestBase { function setUp() public override { _revertSnapshot = vm.snapshotState(); _module = new MockSMADirectFallbackModule(); - _directCallModuleEntity = ModuleEntityLib.pack(address(_module), DIRECT_CALL_VALIDATION_ENTITYID); + _directCallModuleEntity = ModuleEntityLib.pack(address(_module), DIRECT_CALL_VALIDATION_ENTITY_ID); - _fallbackDirectCallModuleEntity = ModuleEntityLib.pack(address(owner1), DIRECT_CALL_VALIDATION_ENTITYID); + _fallbackDirectCallModuleEntity = ModuleEntityLib.pack(address(owner1), DIRECT_CALL_VALIDATION_ENTITY_ID); // enforces that this test runs with an SMA. account1 = ModularAccount(payable(factory.createSemiModularAccount(owner1, 0))); diff --git a/test/libraries/ValidationLocatorLib.t.sol b/test/libraries/ValidationLocatorLib.t.sol index a82e77d4..f10646cc 100644 --- a/test/libraries/ValidationLocatorLib.t.sol +++ b/test/libraries/ValidationLocatorLib.t.sol @@ -19,7 +19,7 @@ pragma solidity ^0.8.26; import {Test} from "forge-std/Test.sol"; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import {ModuleEntity, ModuleEntityLib} from "@erc6900/reference-implementation/libraries/ModuleEntityLib.sol"; import { ValidationConfig, @@ -137,7 +137,7 @@ contract ValidationLocatorLibTest is Test { ValidationLookupKey expected; - if (entityId == DIRECT_CALL_VALIDATION_ENTITYID) { + if (entityId == DIRECT_CALL_VALIDATION_ENTITY_ID) { expected = ValidationLocatorLib.packDirectCall(module, false, false).lookupKey(); } else { expected = ValidationLocatorLib.pack(entityId, false, false).lookupKey(); @@ -153,7 +153,7 @@ contract ValidationLocatorLibTest is Test { ValidationLookupKey expected; - if (entityId == DIRECT_CALL_VALIDATION_ENTITYID) { + if (entityId == DIRECT_CALL_VALIDATION_ENTITY_ID) { expected = ValidationLocatorLib.packDirectCall(module, false, false).lookupKey(); } else { expected = ValidationLocatorLib.pack(entityId, false, false).lookupKey(); diff --git a/test/mocks/modules/ReturnDataModuleMocks.sol b/test/mocks/modules/ReturnDataModuleMocks.sol index 0751fb0b..4b08e1a2 100644 --- a/test/mocks/modules/ReturnDataModuleMocks.sol +++ b/test/mocks/modules/ReturnDataModuleMocks.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import { ExecutionManifest, IExecutionModule, @@ -121,7 +121,7 @@ contract ResultConsumerModule is IExecutionModule, ModuleBase, IValidationModule // This result should be allowed based on the manifest permission request bytes memory returnData = IModularAccount(msg.sender).executeWithRuntimeValidation( abi.encodeCall(IModularAccount.execute, (target, 0, abi.encodeCall(RegularResultContract.foo, ()))), - _encodeSignature(ModuleEntityLib.pack(address(this), DIRECT_CALL_VALIDATION_ENTITYID), uint8(0), "") + _encodeSignature(ModuleEntityLib.pack(address(this), DIRECT_CALL_VALIDATION_ENTITY_ID), uint8(0), "") ); bytes32 actual = abi.decode(abi.decode(returnData, (bytes)), (bytes32)); diff --git a/test/modules/TimeRangeModule.t.sol b/test/modules/TimeRangeModule.t.sol index ee46d51a..b5cfd858 100644 --- a/test/modules/TimeRangeModule.t.sol +++ b/test/modules/TimeRangeModule.t.sol @@ -17,12 +17,13 @@ pragma solidity ^0.8.26; -import {ModuleEntity} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; +import {ModuleEntity, ValidationFlags} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; import { HookConfig, ValidationDataView } from "@erc6900/reference-implementation/interfaces/IModularAccountView.sol"; import {HookConfigLib} from "@erc6900/reference-implementation/libraries/HookConfigLib.sol"; import {ModuleEntityLib} from "@erc6900/reference-implementation/libraries/ModuleEntityLib.sol"; +import {ValidationConfigLib} from "@erc6900/reference-implementation/libraries/ValidationConfigLib.sol"; import {_packValidationData} from "@eth-infinitism/account-abstraction/core/Helpers.sol"; import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol"; import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; @@ -35,6 +36,8 @@ import {TimeRangeModule} from "../../src/modules/permissions/TimeRangeModule.sol import {CustomValidationTestBase} from "../utils/CustomValidationTestBase.sol"; contract TimeRangeModuleTest is CustomValidationTestBase { + using ValidationConfigLib for ValidationFlags; + TimeRangeModule public timeRangeModule; uint32 public constant HOOK_ENTITY_ID = 0; @@ -66,9 +69,9 @@ contract TimeRangeModuleTest is CustomValidationTestBase { // Verify that it is installed ValidationDataView memory validationData = account1.getValidationData(_signerValidation); - assertTrue(validationData.isGlobal); - assertTrue(validationData.isSignatureValidation); - assertTrue(validationData.isUserOpValidation); + assertTrue(validationData.validationFlags.isGlobal()); + assertTrue(validationData.validationFlags.isSignatureValidation()); + assertTrue(validationData.validationFlags.isUserOpValidation()); assertEq(validationData.validationHooks.length, 1); assertEq(HookConfig.unwrap(validationData.validationHooks[0]), HookConfig.unwrap(_hookEntity)); diff --git a/test/utils/AccountTestBase.sol b/test/utils/AccountTestBase.sol index be99bee0..58aa7d50 100644 --- a/test/utils/AccountTestBase.sol +++ b/test/utils/AccountTestBase.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.26; -import {DIRECT_CALL_VALIDATION_ENTITYID} from "@erc6900/reference-implementation/helpers/Constants.sol"; +import {DIRECT_CALL_VALIDATION_ENTITY_ID} from "@erc6900/reference-implementation/helpers/Constants.sol"; import { Call, IModularAccount, ModuleEntity } from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; @@ -276,7 +276,7 @@ abstract contract AccountTestBase is OptimizedTest, ModuleSignatureUtils { abi.encodeCall( account1.installValidation, ( - ValidationConfigLib.pack(address(this), DIRECT_CALL_VALIDATION_ENTITYID, true, false, false), + ValidationConfigLib.pack(address(this), DIRECT_CALL_VALIDATION_ENTITY_ID, true, false, false), new bytes4[](0), "", new bytes[](0) diff --git a/test/utils/ModuleSignatureUtils.sol b/test/utils/ModuleSignatureUtils.sol index 5ba229f0..3e55d2d5 100644 --- a/test/utils/ModuleSignatureUtils.sol +++ b/test/utils/ModuleSignatureUtils.sol @@ -20,7 +20,7 @@ pragma solidity ^0.8.26; import {Vm} from "forge-std/Vm.sol"; import { - DIRECT_CALL_VALIDATION_ENTITYID, + DIRECT_CALL_VALIDATION_ENTITY_ID, RESERVED_VALIDATION_DATA_INDEX } from "@erc6900/reference-implementation/helpers/Constants.sol"; import {ModuleEntity} from "@erc6900/reference-implementation/interfaces/IModularAccount.sol"; @@ -98,7 +98,7 @@ contract ModuleSignatureUtils { (address module, uint32 entityId) = validationFunction.unpack(); - if (entityId == DIRECT_CALL_VALIDATION_ENTITYID) { + if (entityId == DIRECT_CALL_VALIDATION_ENTITY_ID) { sig = ValidationLocatorLib.packSignatureDirectCall(module, globalOrNot == GLOBAL_VALIDATION, false, sig); } else { @@ -137,7 +137,7 @@ contract ModuleSignatureUtils { (address module, uint32 entityId) = validationFunction.unpack(); - if (entityId == DIRECT_CALL_VALIDATION_ENTITYID) { + if (entityId == DIRECT_CALL_VALIDATION_ENTITY_ID) { sig = ValidationLocatorLib.packSignatureDirectCall(module, false, false, sig); } else { sig = ValidationLocatorLib.packSignature(entityId, false, false, sig); @@ -237,7 +237,7 @@ contract ModuleSignatureUtils { ) internal pure returns (uint256) { (address module, uint32 entityId) = validationFunction.unpack(); - if (entityId == DIRECT_CALL_VALIDATION_ENTITYID) { + if (entityId == DIRECT_CALL_VALIDATION_ENTITY_ID) { return ValidationLocatorLib.packNonceDirectCall(module, isGlobal, hasDeferredAction) | linearNonce; } else { return ValidationLocatorLib.packNonce(entityId, isGlobal, hasDeferredAction) | linearNonce;