Skip to content

Commit

Permalink
feat: bump spec to v0.8.0-rc.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypaik committed Nov 27, 2024
1 parent 5c94394 commit 1778256
Show file tree
Hide file tree
Showing 22 changed files with 112 additions and 104 deletions.
28 changes: 14 additions & 14 deletions gas-snapshots/ModularAccount.json
Original file line number Diff line number Diff line change
@@ -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"
}
26 changes: 13 additions & 13 deletions gas-snapshots/SemiModularAccount.json
Original file line number Diff line number Diff line change
@@ -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"
}
3 changes: 2 additions & 1 deletion gas/BenchmarkBase.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
11 changes: 6 additions & 5 deletions gas/modular-account/ModularAccountBenchmarkBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 7 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/account/AccountStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/account/ModularAccountBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -717,7 +717,7 @@ abstract contract ModularAccountBase is

ModuleEntity userOpValidationFunction = validationLookupKey.moduleEntity(_validationStorage);

if (!_validationStorage.isUserOpValidation) {
if (!_validationStorage.validationFlags.isUserOpValidation()) {
revert UserOpValidationInvalid(userOpValidationFunction);
}

Expand Down Expand Up @@ -851,7 +851,7 @@ abstract contract ModularAccountBase is

ModuleEntity sigValidation = validationLookupKey.moduleEntity(_validationStorage);

if (!_validationStorage.isSignatureValidation) {
if (!_validationStorage.validationFlags.isSignatureValidation()) {
revert SignatureValidationInvalid(sigValidation);
}

Expand All @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions src/account/ModularAccountView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
17 changes: 8 additions & 9 deletions src/account/ModuleManagerInternals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/libraries/ValidationLocatorLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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
);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountReturnData.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
"",
Expand Down
6 changes: 3 additions & 3 deletions test/account/DirectCallsFromModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 1778256

Please sign in to comment.