Skip to content

Fix Kernel 0.3.1 address calculation #258

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

Merged
merged 4 commits into from
Jul 29, 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
5 changes: 5 additions & 0 deletions .changeset/afraid-llamas-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Fixed Kernel 0.3.1 address calculation
5 changes: 5 additions & 0 deletions .changeset/chatty-buses-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added installModules & uninstallModules export
9 changes: 9 additions & 0 deletions packages/permissionless-test/mock-aa-infra/alto/constants.ts

Large diffs are not rendered by default.

33 changes: 32 additions & 1 deletion packages/permissionless-test/mock-aa-infra/alto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import {
KERNEL_V07_ECDSA_VALIDATOR_V3_CREATECALL,
KERNEL_V07_FACTORY_CREATECALL,
KERNEL_V07_META_FACTORY_CREATECALL,
KERNEL_V07_V3_1_ACCOUNT_V3_LOGIC_CREATECALL,
KERNEL_V07_V3_1_ECDSA_VALIDATOR_V3_CREATECALL,
KERNEL_V07_V3_1_FACTORY_CREATECALL,
LIGHT_ACCOUNT_FACTORY_V110_CREATECALL,
SAFE_7579_LAUNCHPAD_CREATECALL,
SAFE_7579_MODULE_CREATECALL,
Expand Down Expand Up @@ -207,6 +210,24 @@ export const setupContracts = async (rpc: string) => {
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: KERNEL_V07_V3_1_FACTORY_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: KERNEL_V07_V3_1_ECDSA_VALIDATOR_V3_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: KERNEL_V07_V3_1_ACCOUNT_V3_LOGIC_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: LIGHT_ACCOUNT_FACTORY_V110_CREATECALL,
Expand Down Expand Up @@ -355,6 +376,13 @@ export const setupContracts = async (rpc: string) => {
data: "0x6e7dbabb0000000000000000000000006723b44abeec4e71ebe3232bd5b455805badd22f0000000000000000000000000000000000000000000000000000000000000001"
})

// register 0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419
await sendTransaction(walletClient, {
account: kernelFactoryOwner,
to: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5" /* kernel factory v0.7 */,
data: "0x6e7dbabb000000000000000000000000aac5D4240AF87249B3f71BC8E4A2cae074A3E4190000000000000000000000000000000000000000000000000000000000000001"
})

await sendTransaction(walletClient, {
account: kernelFactoryOwner,
to: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5" /* kernel factory v0.7 */,
Expand Down Expand Up @@ -417,7 +445,10 @@ export const setupContracts = async (rpc: string) => {
"0x8104e3Ad430EA6d354d013A6789fDFc71E671c43", // Kernel v0.3.0 ECDSA Valdiator
"0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27", // Kernel v0.3.0 Account Logic
"0x6723b44Abeec4E71eBE3232BD5B455805baDD22f", // Kernel v0.3.0 Factory
"0xd703aaE79538628d27099B8c4f621bE4CCd142d5", // Kernel v0.3.0 Meta Factory
"0xd703aaE79538628d27099B8c4f621bE4CCd142d5", // Kernel v0.3.0 & v0.3.1 Meta Factory
"0x845ADb2C711129d4f3966735eD98a9F09fC4cE57", // Kernel v0.3.1 ECDSA Valdiator
"0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D", // Kernel v0.3.1 Account Logic
"0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419", // Kernel v0.3.1 Factory
"0x00004EC70002a32400f8ae005A26081065620D20", // LightAccountFactory v1.1.0
"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba", // LightAccount v1.1.0 implementation
"0x81b9E3689390C7e74cF526594A105Dea21a8cdD5", // Trust Secp256k1VerificationFacet
Expand Down
131 changes: 40 additions & 91 deletions packages/permissionless-test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
signerToTrustSmartAccount
} from "../../permissionless/accounts"
import type { KernelEcdsaSmartAccount } from "../../permissionless/accounts"
import type { KernelVersion } from "../../permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount"
import {
type PimlicoBundlerClient,
type PimlicoPaymasterClient,
Expand Down Expand Up @@ -325,22 +326,25 @@ export const getKernelEcdsaClient = async <T extends EntryPoint>({
anvilRpc,
altoRpc,
privateKey = generatePrivateKey(),
erc7579
}: AAParamType<T> & { erc7579?: boolean }): Promise<
version
}: AAParamType<T> & { version?: KernelVersion<T> }): Promise<
SmartAccountClient<T, Transport, Chain, KernelEcdsaSmartAccount<T>>
> => {
const publicClient = getPublicClient(anvilRpc)

if (erc7579 && entryPoint === ENTRYPOINT_ADDRESS_V06) {
if (
(version === "0.3.0-beta" || version === "0.3.1") &&
entryPoint === ENTRYPOINT_ADDRESS_V06
) {
throw new Error("ERC7579 is not supported for V06")
}

const kernelEcdsaAccount =
erc7579 && entryPoint === ENTRYPOINT_ADDRESS_V07
entryPoint === ENTRYPOINT_ADDRESS_V07
? await signerToEcdsaKernelSmartAccount(publicClient, {
entryPoint: entryPoint as ENTRYPOINT_ADDRESS_V07_TYPE,
entryPoint: entryPoint,
signer: privateKeyToAccount(privateKey),
version: "0.3.0-beta"
version
})
: await signerToEcdsaKernelSmartAccount(publicClient, {
entryPoint,
Expand Down Expand Up @@ -450,12 +454,6 @@ export const getCoreSmartAccounts = () => [
conf as AAParamType<ENTRYPOINT_ADDRESS_V06_TYPE>
)
},
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToTrustSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
}),
supportsEntryPointV06: true,
supportsEntryPointV07: false,
isEip1271Compliant: true
Expand All @@ -465,13 +463,6 @@ export const getCoreSmartAccounts = () => [
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getLightAccountClient(conf),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToLightSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06,
lightAccountVersion: "1.1.0"
}),
supportsEntryPointV06: true,
supportsEntryPointV07: false,
isEip1271Compliant: true
Expand All @@ -481,12 +472,6 @@ export const getCoreSmartAccounts = () => [
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getSimpleAccountClient(conf),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToSimpleSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
}),
supportsEntryPointV06: true,
supportsEntryPointV07: true,
isEip1271Compliant: false
Expand All @@ -496,30 +481,46 @@ export const getCoreSmartAccounts = () => [
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getKernelEcdsaClient(conf),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToEcdsaKernelSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
}),
supportsEntryPointV06: true,
supportsEntryPointV07: true,
isEip1271Compliant: true
},
{
name: "Kernel 7579",
name: "Kernel 7579 0.3.0-beta",
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getKernelEcdsaClient({ ...conf, erc7579: true }),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToEcdsaKernelSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
) =>
getKernelEcdsaClient({
...conf,
version: "0.3.0-beta" as KernelVersion<T>
}),
getErc7579SmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getKernelEcdsaClient({ ...conf, erc7579: true }),
) =>
getKernelEcdsaClient({
...conf,
version: "0.3.0-beta" as KernelVersion<T>
}),
supportsEntryPointV06: false,
supportsEntryPointV07: true,
isEip1271Compliant: true
},
{
name: "Kernel 7579 0.3.1",
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) =>
getKernelEcdsaClient({
...conf,
version: "0.3.1" as KernelVersion<T>
}),
getErc7579SmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) =>
getKernelEcdsaClient({
...conf,
version: "0.3.1" as KernelVersion<T>
}),
supportsEntryPointV06: false,
supportsEntryPointV07: true,
isEip1271Compliant: true
Expand All @@ -536,12 +537,6 @@ export const getCoreSmartAccounts = () => [
conf as AAParamType<ENTRYPOINT_ADDRESS_V06_TYPE>
)
},
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToBiconomySmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
}),
supportsEntryPointV06: true,
supportsEntryPointV07: false,
isEip1271Compliant: true
Expand All @@ -551,13 +546,6 @@ export const getCoreSmartAccounts = () => [
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getSafeClient(conf),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToSafeSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06,
safeVersion: "1.4.1"
}),
supportsEntryPointV06: true,
supportsEntryPointV07: true,
isEip1271Compliant: true
Expand All @@ -567,13 +555,6 @@ export const getCoreSmartAccounts = () => [
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getSafeClient({ ...conf, erc7579: true }),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToSafeSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06,
safeVersion: "1.4.1"
}),
getErc7579SmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getSafeClient({ ...conf, erc7579: true }),
Expand All @@ -597,12 +578,6 @@ export const getCoreSmartAccounts = () => [
privateKey: generatePrivateKey()
})
},
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToTrustSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
}),
supportsEntryPointV06: true,
supportsEntryPointV07: false,
isEip1271Compliant: true
Expand All @@ -616,13 +591,6 @@ export const getCoreSmartAccounts = () => [
...conf,
privateKey: generatePrivateKey()
}),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToLightSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06,
lightAccountVersion: "1.1.0"
}),
supportsEntryPointV06: true,
supportsEntryPointV07: false,
isEip1271Compliant: true
Expand All @@ -636,12 +604,6 @@ export const getCoreSmartAccounts = () => [
...conf,
privateKey: generatePrivateKey()
}),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToSimpleSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
}),
supportsEntryPointV06: true,
supportsEntryPointV07: true,
isEip1271Compliant: false
Expand All @@ -659,12 +621,6 @@ export const getCoreSmartAccounts = () => [
privateKey: generatePrivateKey()
})
},
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToBiconomySmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06
}),
supportsEntryPointV06: true,
supportsEntryPointV07: false,
isEip1271Compliant: true
Expand All @@ -674,13 +630,6 @@ export const getCoreSmartAccounts = () => [
getSmartAccountClient: async <T extends EntryPoint>(
conf: AAParamType<T>
) => getSafeClient({ ...conf, privateKey: generatePrivateKey() }),
getSmartAccountSigner: async (conf: ExistingSignerParamType) =>
signerToSafeSmartAccount(conf.publicClient, {
address: conf.existingAddress, // this is the field we are testing
signer: privateKeyToAccount(conf.privateKey),
entryPoint: ENTRYPOINT_ADDRESS_V06,
safeVersion: "1.4.1"
}),
supportsEntryPointV06: true,
supportsEntryPointV07: true,
isEip1271Compliant: true
Expand Down
20 changes: 20 additions & 0 deletions packages/permissionless/accounts/kernel/abi/KernelV3AccountAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ export const KernelV3InitAbi = [
}
] as const

export const KernelV3_1AccountAbi = [
{
type: "function",
name: "initialize",
inputs: [
{
name: "_rootValidator",
type: "bytes21",
internalType: "ValidationId"
},
{ name: "hook", type: "address", internalType: "contract IHook" },
{ name: "validatorData", type: "bytes", internalType: "bytes" },
{ name: "hookData", type: "bytes", internalType: "bytes" },
{ name: "initConfig", type: "bytes[]", internalType: "bytes[]" }
],
outputs: [],
stateMutability: "nonpayable"
}
] as const

export const KernelV3ExecuteAbi = [
{
type: "function",
Expand Down
Loading
Loading