Skip to content

Commit

Permalink
Merge pull request #314 from yoanslvy/feat/updateToRhinestoneAuditedC…
Browse files Browse the repository at this point in the history
…ontracts

feat: update to rhinestone audited contracts
  • Loading branch information
plusminushalf authored Nov 3, 2024
2 parents fec911c + b293e3e commit c5b6cde
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 83 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-camels-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Fixed support for latest audited 7579 contracts
Binary file modified bun.lockb
Binary file not shown.
20 changes: 16 additions & 4 deletions packages/permissionless-test/mock-aa-infra/alto/constants.ts

Large diffs are not rendered by default.

122 changes: 97 additions & 25 deletions packages/permissionless-test/mock-aa-infra/alto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import {
SAFE_7579_LAUNCHPAD_CREATECALL,
SAFE_7579_MODULE_CREATECALL,
SAFE_7579_REGISTRY_CREATECALL,
SAFE_7579_REGISTRY_RESOLVER_CREATECALL,
SAFE_7579_REGISTRY_RESOLVER_PROXY_CREATECALL,
SAFE_7579_REGISTRY_SCHEMA_CREATECALL,
SAFE_7579_REGISTRY_SCHEMA_PROXY_CREATECALL,
SAFE_MULTI_SEND_CALL_ONLY_CREATECALL,
SAFE_MULTI_SEND_CREATECALL,
SAFE_PROXY_FACTORY_CREATECALL,
Expand All @@ -60,6 +64,7 @@ import {
const DETERMINISTIC_DEPLOYER = "0x4e59b44847b379578588920ca78fbf26c0b4956c"
const SAFE_SINGLETON_FACTORY = "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7"
const BICONOMY_SINGLETON_FACTORY = "0x988C135a1049Ce61730724afD342fb7C56CD2776"
const SAFE_7579_REGISTRY = "0x000000000069E2a187AEFFb852bF3cCdC95151B2"
export const ENTRY_POINT_SIMULATIONS_ADDRESS =
"0x74Cb5e4eE81b86e70f9045036a1C5477de69eE87"

Expand Down Expand Up @@ -98,6 +103,11 @@ export const setupContracts = async (rpc: string) => {
address: walletClient.account.address
})

await anvilClient.setCode({
address: SAFE_SINGLETON_FACTORY,
bytecode: SAFE_SINGLETON_FACTORY_BYTECODE
})

await Promise.all([
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
Expand Down Expand Up @@ -149,28 +159,16 @@ export const setupContracts = async (rpc: string) => {
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: SAFE_7579_MODULE_CREATECALL,
data: SAFE_V07_MODULE_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_REGISTRY_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: SAFE_7579_LAUNCHPAD_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: SAFE_V07_MODULE_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: KERNEL_V06_ECDSA_VALIDATOR_V2_2_CREATECALL,
Expand Down Expand Up @@ -286,8 +284,26 @@ export const setupContracts = async (rpc: string) => {
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: ERC_7579_TEST_MODULE_CREATECALL,
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_REGISTRY_SCHEMA_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_REGISTRY_RESOLVER_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_REGISTRY_SCHEMA_PROXY_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_REGISTRY_RESOLVER_PROXY_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
Expand All @@ -305,11 +321,6 @@ export const setupContracts = async (rpc: string) => {
})
])

await anvilClient.setCode({
address: SAFE_SINGLETON_FACTORY,
bytecode: SAFE_SINGLETON_FACTORY_BYTECODE
})

await Promise.all([
walletClient.sendTransaction({
to: SAFE_SINGLETON_FACTORY,
Expand All @@ -334,6 +345,18 @@ export const setupContracts = async (rpc: string) => {
data: SAFE_MULTI_SEND_CALL_ONLY_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_MODULE_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_LAUNCHPAD_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
})
])

Expand Down Expand Up @@ -372,6 +395,55 @@ export const setupContracts = async (rpc: string) => {
})
])

const rhinestoneAttester = "0x000000333034E9f539ce08819E12c1b8Cb29084d"
await anvilClient.setBalance({
address: rhinestoneAttester,
value: parseEther("100")
})

await anvilClient.impersonateAccount({
address: rhinestoneAttester
})

// register schema
await sendTransaction(walletClient, {
account: rhinestoneAttester,
to: SAFE_7579_REGISTRY,
data: "0x1d4d9810000000000000000000000000000000000000000000000000000000000000004000000000000000000000000086430e19d7d204807bbb8cda997bb57b7ee785dd000000000000000000000000000000000000000000000000000000000000024628656e756d20455243373537394d6f64756c655479706520284e6f6e652c56616c696461746f722c4578656375746f722c46616c6c6261636b2c486f6f6b292c737472756374204d6f64756c6554797065417474726962757465732028455243373537394d6f64756c6554797065206d6f64756c65547970652c627974657320656e636f64656441747472696275746573292c737472756374204d6f64756c6541747472696275746573202861646472657373206d6f64756c65416464726573732c6279746573207061636b6564417474726962757465732c4d6f64756c6554797065417474726962757465735b5d2074797065417474726962757465732c6279746573207061636b656445787465726e616c446570656e64656e6379292c656e756d205369676e61747572655479706520284e6f6e652c534543503235364b312c45524331323731292c7374727563742041756469746f722028737472696e67206e616d652c737472696e67207572692c737472696e675b5d20617574686f7273292c737472756374205369676e617475726520285369676e61747572655479706520736967547970652c61646472657373207369676e65722c6279746573207369676e6174757265446174612c627974657333322068617368292c73747275637420417564697453756d6d6172792028737472696e67207469746c652c41756469746f722061756469746f722c4d6f64756c6541747472696275746573206d6f64756c65417474726962757465732c5369676e6174757265207369676e617475726529290000000000000000000000000000000000000000000000000000"
})

// regsiter resolver
await sendTransaction(walletClient, {
account: rhinestoneAttester,
to: SAFE_7579_REGISTRY,
data: "0x9f3e1b53000000000000000000000000f0f468571e764664c93308504642af941d9f77f1"
})

await anvilClient.stopImpersonatingAccount({
address: rhinestoneAttester
})

// deploy module
await sendTransaction(walletClient, {
to: SAFE_7579_REGISTRY,
data: ERC_7579_TEST_MODULE_CREATECALL
})

await anvilClient.impersonateAccount({
address: rhinestoneAttester
})

// attest to module
await sendTransaction(walletClient, {
account: rhinestoneAttester,
to: SAFE_7579_REGISTRY,
data: "0x945e364193d46fcca4ef7d66a413c7bde08bb1ff14bacbd04c4069bb24cd7c21729d7bf100000000000000000000000000000000000000000000000000000000000000400000000000000000000000004fd8d57b94966982b62e9588c27b4171b55e835400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000000104f776e61626c6556616c696461746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000001041636b656520426c6f636b636861696e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001168747470733a2f2f61636b65652e78797a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000012c5a074c49b70c3a16e20c5a06f6e736bc3bd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124d696368616c2050c599657672c3a174696c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4e616f6b6920596f736869646100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f4a616e2050c599657672c3a174696c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000184a6f736566204761747465726d617965722c2050682e442e00000000000000000000000000000000000000004fd8d57b94966982b62e9588c27b4171b55e835400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000000b0101010101000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000005010100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a1e8f5d6ccd82f2a2ac4ca5df4d51c71e48a54d5000000000000000000000000000000000000000000000000000000000000008022d5e995295e4d3b8bd198dc4ed6381026e7520b1bc156174254b97f3662ebbc000000000000000000000000000000000000000000000000000000000000004113d756b32e6788c67a57e3e445e05f0629f0e6f1f0f8af95d8995fd7586fcde03c9589572c75141fe7041c8ca63eab97c8743e98b7c2582dd9382619b23a84dd010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002"
})

await anvilClient.stopImpersonatingAccount({
address: rhinestoneAttester
})

// ==== SETUP KERNEL V0.6 CONTRACTS ==== //
const kernelFactoryOwner = "0x9775137314fE595c943712B0b336327dfa80aE8A"
await anvilClient.setBalance({
Expand Down Expand Up @@ -451,9 +523,9 @@ export const setupContracts = async (rpc: string) => {
"0x41675C099F32341bf84BFc5382aF534df5C7461a", // Safe Singleton
"0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526", // Safe Multi Send
"0x9641d764fc13c8B624c04430C7356C1C7C8102e2", // Safe Multi Send Call Only
"0x3Fdb5BC686e861480ef99A6E3FaAe03c0b9F32e2", // Safe 7579 module
"0xEBe001b3D534B9B6E2500FB78E67a1A137f561CE", // Safe 7579 launchpad
"0x25A4b2F363678E13A0A5DB79b712dE00347a593E", // Safe 7579 Registry
"0x7579EE8307284F293B1927136486880611F20002", // Safe 7579 module
"0x7579011aB74c46090561ea277Ba79D510c6C00ff", // Safe 7579 launchpad
"0x000000000069E2a187AEFFb852bF3cCdC95151B2", // Safe 7579 Registry
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", // EntryPoint V0.6
"0x9406Cc6185a346906296840746125a0E44976454", // Simple Account Factory V0.6
"0x0000001c5b32F37F5beA87BDD5374eB2aC54eA8e", // Biconomy ECDSA Ownership Registry Module
Expand Down Expand Up @@ -481,7 +553,7 @@ export const setupContracts = async (rpc: string) => {
"0x3143E1C0Af0Cdc153423863923Cf4e3818e34Daa", // Trust TokenReceiverFacet
"0xCe36b85d12D81cd619C745c7717f3396E184Ac7C", // Trust DiamondLoupeFacet
"0x2e7f1dAe1F3799d20f5c31bEFdc7A620f664728D", // Trust DefaultFallbackHandler
"0xc98B026383885F41d9a995f85FC480E9bb8bB891", // ERC7579 Test Module
"0x4Fd8d57b94966982B62e9588C27B4171B55E8354", // ERC7579 Test Module
"0x85e23b94e7F5E9cC1fF78BCe78cfb15B81f0DF00", // Thirdweb factory 0.6
"0x4be0ddfebca9a5a4a617dee4dece99e7c862dceb" // Thirdweb factory 0.7
])
Expand Down
12 changes: 9 additions & 3 deletions packages/permissionless-test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,17 @@ export const getSafeClient = async <entryPointVersion extends "0.6" | "0.7">({
version: "1.4.1",
saltNonce: 420n,
safe4337ModuleAddress: erc7579
? "0x3Fdb5BC686e861480ef99A6E3FaAe03c0b9F32e2"
? "0x7579EE8307284F293B1927136486880611F20002"
: undefined,
erc7579LaunchpadAddress: erc7579
? "0xEBe001b3D534B9B6E2500FB78E67a1A137f561CE"
: undefined
? "0x7579011aB74c46090561ea277Ba79D510c6C00ff"
: undefined,
...(erc7579
? {
attesters: ["0x000000333034E9f539ce08819E12c1b8Cb29084d"],
attestersThreshold: 1
}
: {})
})
}

Expand Down
13 changes: 1 addition & 12 deletions packages/permissionless/accounts/safe/toSafeSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1439,12 +1439,9 @@ export async function toSafeSmartAccount<
entryPoint: entryPoint.address
}

let isDeployed = false

if ("initCode" in userOperation) {
message.paymasterAndData =
userOperation.paymasterAndData ?? "0x"
isDeployed = userOperation.initCode === "0x"
}

if ("factory" in userOperation) {
Expand All @@ -1458,14 +1455,6 @@ export async function toSafeSmartAccount<
...userOperation,
sender: userOperation.sender ?? (await this.getAddress())
})
isDeployed = !userOperation.factory
}

let verifyingContract = safe4337ModuleAddress

if (erc7579LaunchpadAddress && !isDeployed) {
verifyingContract =
userOperation.sender ?? (await this.getAddress())
}

const signatures = [
Expand All @@ -1475,7 +1464,7 @@ export async function toSafeSmartAccount<
account: localOwner,
domain: {
chainId,
verifyingContract
verifyingContract: safe4337ModuleAddress
},
types:
entryPoint.version === "0.6"
Expand Down
8 changes: 4 additions & 4 deletions packages/permissionless/actions/erc7579/installModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe.each(getCoreSmartAccounts())(
const opHash = await installModule(smartClient, {
account: smartClient.account,
type: "executor",
address: "0xc98B026383885F41d9a995f85FC480E9bb8bB891",
address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
initData: name.startsWith("Kernel 7579")
? encodePacked(
["address", "bytes"],
Expand Down Expand Up @@ -74,7 +74,7 @@ describe.each(getCoreSmartAccounts())(

const isModuleInstalled = await smartClient.isModuleInstalled({
type: "executor",
address: "0xc98B026383885F41d9a995f85FC480E9bb8bB891",
address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
context: "0x"
})

Expand Down Expand Up @@ -127,7 +127,7 @@ describe.each(getCoreSmartAccounts())(
const opHash = await installModule(smartClient, {
account: smartClient.account,
type: "executor",
address: "0xc98B026383885F41d9a995f85FC480E9bb8bB891",
address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
context: name.startsWith("Kernel 7579")
? encodePacked(
["address", "bytes"],
Expand Down Expand Up @@ -165,7 +165,7 @@ describe.each(getCoreSmartAccounts())(

const isModuleInstalled = await smartClient.isModuleInstalled({
type: "executor",
address: "0xc98B026383885F41d9a995f85FC480E9bb8bB891",
address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
context: "0x"
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe.each(getCoreSmartAccounts())(
{
type: "executor",
address:
"0xc98B026383885F41d9a995f85FC480E9bb8bB891",
"0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
context: name.startsWith("Kernel 7579")
? encodePacked(
["address", "bytes"],
Expand Down Expand Up @@ -88,7 +88,7 @@ describe.each(getCoreSmartAccounts())(

const isModuleInstalled = await smartClient.isModuleInstalled({
type: "executor",
address: "0xc98B026383885F41d9a995f85FC480E9bb8bB891",
address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
context: "0x"
})

Expand Down Expand Up @@ -144,7 +144,7 @@ describe.each(getCoreSmartAccounts())(
{
type: "executor",
address:
"0xc98B026383885F41d9a995f85FC480E9bb8bB891",
"0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
context: name.startsWith("Kernel 7579")
? encodePacked(
["address", "bytes"],
Expand Down Expand Up @@ -187,7 +187,7 @@ describe.each(getCoreSmartAccounts())(

const isModuleInstalled = await smartClient.isModuleInstalled({
type: "executor",
address: "0xc98B026383885F41d9a995f85FC480E9bb8bB891",
address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
context: "0x"
})

Expand Down
Loading

0 comments on commit c5b6cde

Please sign in to comment.