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

Use Arachnid CREATE2 Deployer For Some Contracts #482

Merged
merged 1 commit into from
Aug 15, 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: 1 addition & 4 deletions modules/passkey/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ EVM target: Paris

- `SafeWebAuthnSignerFactory` at `0x1d31F259eE307358a26dFb23EB365939E8641195`
- `SafeWebAuthnSharedSigner` at `0x94a4F6affBd8975951142c3999aEAB7ecee555c2`
- `DaimoP256Verifier` at `0xc2b78104907F722DABAc4C69f826a522B2754De4` ([source](https://p256.eth.limo/))
- `FCLP256Verifier` at `0xA86e0054C51E4894D88762a017ECc5E5235f5DBA`

### Official Deployment Address from 3rd party

- `DaimoP256Verifier` at `0xc2b78104907F722DABAc4C69f826a522B2754De4` ([Source](https://p256.eth.limo/))

## Changes

### Security Fixes
Expand Down
35 changes: 27 additions & 8 deletions modules/passkey/src/deploy/verifiers.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types'
import type { DeployFunction } from 'hardhat-deploy/types'

import DaimoP256Verifier from '../vendor/daimo-eth/P256Verifier.json'

const deploy: DeployFunction = async ({ deployments, getNamedAccounts }) => {
const deploy: DeployFunction = async (hre) => {
const { deployments, getNamedAccounts } = hre

const { deployer } = await getNamedAccounts()
const { deploy } = deployments

await deploy('DaimoP256Verifier', {
from: deployer,
contract: DaimoP256Verifier,
args: [],
deterministicDeployment: true,
log: true,
})
// The official Daimo P-256 verifier contract is deployed using the Arachnid CREATE2 deployer.
await withArachnidDeterministicDeploymentProxy(hre, () =>
deploy('DaimoP256Verifier', {
from: deployer,
contract: DaimoP256Verifier,
args: [],
deterministicDeployment: true,
log: true,
}),
)

await deploy('FCLP256Verifier', {
from: deployer,
Expand All @@ -22,4 +28,17 @@ const deploy: DeployFunction = async ({ deployments, getNamedAccounts }) => {
})
}

function withArachnidDeterministicDeploymentProxy<T>({ config }: HardhatRuntimeEnvironment, f: () => Promise<T>): Promise<T> {
// This is a bit hacky - but the `hardhat-deploy` package reads that deterministic deployment
// configuration before deploying each contract. This means that we can temporarily override the
// the configuration to `undefined` so that it uses the (default) Arachnid deterministic
// deployment proxy for a specific deployment, and then restore the configuration afterwards so
// that remaining contracts use the deterministic deployment factory from `hardhat.config.ts`.
const existingConfig = config.deterministicDeployment
config.deterministicDeployment = undefined
return f().finally(() => {
config.deterministicDeployment = existingConfig
})
}

export default deploy
34 changes: 26 additions & 8 deletions packages/4337-local-bundler/src/deploy/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
import EntryPoint from '@account-abstraction/contracts/artifacts/EntryPoint.json'
import { DeployFunction } from 'hardhat-deploy/types'
import type { HardhatRuntimeEnvironment } from 'hardhat/types'
import type { DeployFunction } from 'hardhat-deploy/types'

const deploy: DeployFunction = async ({ deployments, getNamedAccounts, network }) => {
const deploy: DeployFunction = async (hre) => {
const { deployments, getNamedAccounts, network } = hre
if (!network.tags.entrypoint) {
return
}

const { deployer } = await getNamedAccounts()
const { deploy } = deployments

await deploy('EntryPoint', {
from: deployer,
contract: EntryPoint,
args: [],
log: true,
deterministicDeployment: '0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3',
// The official ERC-4337 entry point contract is deployed using the Arachnid CREATE2 deployer.
await withArachnidDeterministicDeploymentProxy(hre, () =>
deploy('EntryPoint', {
from: deployer,
contract: EntryPoint,
args: [],
log: true,
deterministicDeployment: '0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3',
}),
)
}

function withArachnidDeterministicDeploymentProxy<T>({ config }: HardhatRuntimeEnvironment, f: () => Promise<T>): Promise<T> {
// This is a bit hacky - but the `hardhat-deploy` package reads that deterministic deployment
// configuration before deploying each contract. This means that we can temporarily override the
// the configuration to `undefined` so that it uses the (default) Arachnid deterministic
// deployment proxy for a specific deployment, and then restore the configuration afterwards so
// that remaining contracts use the deterministic deployment factory from `hardhat.config.ts`.
const existingConfig = config.deterministicDeployment
config.deterministicDeployment = undefined
return f().finally(() => {
config.deterministicDeployment = existingConfig
})
}

Expand Down
Loading