Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: kernel and simulate ci runs #152

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@ERC4337/account-abstraction": "github:kopy-kat/account-abstraction#develop",
"@ERC4337/account-abstraction-v0.6": "github:eth-infinitism/account-abstraction#v0.6.0",
"@prb/math": "^4.0.2",
"@rhinestone/erc4337-validation": "^0.0.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the foundry pr is merged should we try again with latest?

"@rhinestone/erc4337-validation": "0.0.1-alpha.5",
"@rhinestone/module-bases": "github:rhinestonewtf/module-bases#d048ec28c8ea8b4155db3ce4f027bc64cd41f9a7",
"@rhinestone/safe7579": "github:rhinestonewtf/safe7579#v1.0.0",
"@rhinestone/sentinellist": "github:rhinestonewtf/sentinellist",
Expand Down
18 changes: 6 additions & 12 deletions pnpm-lock.yaml

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

4 changes: 4 additions & 0 deletions src/accounts/kernel/KernelFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ contract KernelFactory is IAccountFactory {
Kernel.initialize, (rootValidator, IHook(address(hookMultiPlexer)), initData, hex"00")
);
}

function setHookMultiPlexer(address hook) public {
hookMultiPlexer = MockHookMultiPlexer(hook);
}
}
26 changes: 25 additions & 1 deletion src/test/ModuleKitHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { PackedUserOperation } from "../external/ERC4337.sol";
import { ERC4337Helpers } from "./utils/ERC4337Helpers.sol";
import { HelperBase } from "./helpers/HelperBase.sol";
import { Execution } from "../external/ERC7579.sol";
import { Execution, MODULE_TYPE_HOOK } from "../external/ERC7579.sol";
import { prank } from "src/test/utils/Vm.sol";
import {
getAccountType as getAccountTypeFromStorage,
Expand Down Expand Up @@ -46,6 +46,7 @@ import {
import { EncodeLib, HashLib } from "src/test/helpers/SmartSessionHelpers.sol";
import { Solarray } from "solarray/Solarray.sol";
import { recordLogs, VmSafe, getRecordedLogs } from "./utils/Vm.sol";
import { KernelHelpers } from "./helpers/KernelHelpers.sol";

library ModuleKitHelpers {
/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -837,6 +838,27 @@ library ModuleKitHelpers {
);
}

/// @dev Kernel requires us to temporarily disable the hook multiplexer to use smart sessions
modifier withHookFixForKernel(AccountInstance memory instance) {
// Check if account is KERNEL
if (instance.accountType == AccountType.KERNEL) {
// Cache hook multiplexer
address hookMultiplexer =
KernelHelpers(instance.accountHelper).getHookMultiPlexer(instance);
// Uninstall MockHookMultiplexer
instance.uninstallModule(MODULE_TYPE_HOOK, hookMultiplexer, "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it reverts if we don't uninstall it, not sure about having to re-install it (doesn't revert if i remove it) but it made sense to re-install after runinstalling it.

// Set hook multiplexer to address(1)
KernelHelpers(instance.accountHelper).setHookMultiPlexer(instance, address(1));
_;
// Set hook multiplexer back to MockHookMultiplexer
KernelHelpers(instance.accountHelper).setHookMultiPlexer(instance, hookMultiplexer);
// Reinstall MockHookMultiplexer
instance.installModule(MODULE_TYPE_HOOK, hookMultiplexer, "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this as well

} else {
_;
}
}

function useSession(
AccountInstance memory instance,
Session memory session,
Expand All @@ -845,6 +867,7 @@ library ModuleKitHelpers {
bytes memory callData
)
internal
withHookFixForKernel(instance)
{
// Check if smart sessions module is already installed
if (!instance.isModuleInstalled(1, address(instance.smartSession))) {
Expand Down Expand Up @@ -880,6 +903,7 @@ library ModuleKitHelpers {
Execution[] memory executions
)
internal
withHookFixForKernel(instance)
{
// Check if smart sessions module is already installed
if (!instance.isModuleInstalled(1, address(instance.smartSession))) {
Expand Down
3 changes: 2 additions & 1 deletion src/test/RhinestoneModuleKit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { HelperBase } from "./helpers/HelperBase.sol";
import { ERC7579Helpers } from "./helpers/ERC7579Helpers.sol";
import { SafeHelpers } from "./helpers/SafeHelpers.sol";
import { KernelHelpers } from "./helpers/KernelHelpers.sol";
import { NexusHelpers } from "./helpers/NexusHelpers.sol";
import { Auxiliary, AuxiliaryFactory } from "./Auxiliary.sol";
import { PackedUserOperation, IStakeManager, IEntryPoint } from "../external/ERC4337.sol";
import { ENTRYPOINT_ADDR } from "./predeploy/EntryPoint.sol";
Expand Down Expand Up @@ -248,7 +249,7 @@ contract RhinestoneModuleKit is AuxiliaryFactory {
writeHelper(address(new ERC7579Helpers()), DEFAULT);
writeHelper(address(new SafeHelpers()), SAFE);
writeHelper(address(new KernelHelpers()), KERNEL);
writeHelper(address(new ERC7579Helpers()), NEXUS);
writeHelper(address(new NexusHelpers()), NEXUS);
writeHelper(address(new ERC7579Helpers()), CUSTOM);

// Initialize factories
Expand Down
19 changes: 15 additions & 4 deletions src/test/helpers/KernelHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,21 @@ contract KernelHelpers is HelperBase {
abi.encodePacked(ValidatorLib.validatorToIdentifier(IValidator(validator)), signature);
}

function getHookMultiPlexer(AccountInstance memory instance) public view returns (address) {
return address(KernelFactory(instance.accountFactory).hookMultiPlexer());
}

function setHookMultiPlexer(
AccountInstance memory instance,
address hookMultiPlexer
)
public
virtual
deployAccountForAction(instance)
{
KernelFactory(instance.accountFactory).setHookMultiPlexer(hookMultiPlexer);
}

/*//////////////////////////////////////////////////////////////////////////
INTERNAL
//////////////////////////////////////////////////////////////////////////*/
Expand All @@ -475,8 +490,4 @@ contract KernelHelpers is HelperBase {
Kernel(payable(instance.account)).validationConfig(vId);
return address(validationConfig.hook);
}

function getHookMultiPlexer(AccountInstance memory instance) internal view returns (address) {
return address(KernelFactory(instance.accountFactory).hookMultiPlexer());
}
}
Loading
Loading