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

Using safe-singleton-factory for module deployment #477

Merged
merged 11 commits into from
Aug 13, 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
16 changes: 8 additions & 8 deletions modules/4337/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This changelog only contains changes starting from version 0.2.0

# Version: Unreleased

## Changes
remedcu marked this conversation as resolved.
Show resolved Hide resolved

### General

- Using the [`safe-singleton-factory`](https://github.com/safe-global/safe-singleton-factory) to deploy contracts.

# Version 0.3.0

## Compiler settings
Expand All @@ -21,14 +29,6 @@ The official deployments support the EntryPoint v0.7.0 with the canonical deploy

## Changes

### Security Fixes

None

### Compatibility Fixes

None

### General

- Use the new `PackedUserOperation` struct from EntryPoint v0.7.0 ([#225](https://github.com/safe-global/safe-modules/issues/225))
Expand Down
2 changes: 1 addition & 1 deletion modules/4337/certora/conf/Safe4337Module.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"verify": "Safe4337Module:certora/specs/Safe4337Module.spec",
"packages": [
"@account-abstraction=../../node_modules/.pnpm/@[email protected]/node_modules/@account-abstraction",
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@6.0.4_/node_modules/@safe-global"
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@5.0.10_/node_modules/@safe-global"
]
}
2 changes: 1 addition & 1 deletion modules/4337/certora/conf/SignatureLengthCheck.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"verify": "Safe4337ModuleHarness:certora/specs/SignatureLengthCheck.spec",
"packages": [
"@account-abstraction=../../node_modules/.pnpm/@[email protected]/node_modules/@account-abstraction",
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@6.0.4_/node_modules/@safe-global"
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@5.0.10_/node_modules/@safe-global"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"verify": "Safe4337Module:certora/specs/TransactionExecutionMethods.spec",
"packages": [
"@account-abstraction=../../node_modules/.pnpm/@[email protected]/node_modules/@account-abstraction",
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@6.0.4_/node_modules/@safe-global"
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@5.0.10_/node_modules/@safe-global"
]
}
2 changes: 1 addition & 1 deletion modules/4337/certora/conf/ValidationDataLastBitOne.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"verify": "Safe4337Module:certora/specs/ValidationDataLastBitOne.spec",
"packages": [
"@account-abstraction=../../node_modules/.pnpm/@[email protected]/node_modules/@account-abstraction",
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@6.0.4_/node_modules/@safe-global"
"@safe-global=../../node_modules/.pnpm/@[email protected][email protected][email protected]_utf-8-validate@5.0.10_/node_modules/@safe-global"
]
}
30 changes: 26 additions & 4 deletions modules/4337/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import 'hardhat-deploy'
import dotenv from 'dotenv'
import type { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import yargs from 'yargs/yargs'
import { getSingletonFactoryInfo } from '@safe-global/safe-singleton-factory'
import { DeterministicDeploymentInfo } from 'hardhat-deploy/dist/types'
import './src/tasks/localVerify'
import './src/tasks/deployContracts'
import './src/tasks/codesize'

const argv = yargs(process.argv.slice(2))
.options({ network: { type: 'string', default: 'hardhat' } })
Expand All @@ -30,10 +35,6 @@ if (['mainnet', 'sepolia', 'polygon', 'amoy'].includes(argv.network) && INFURA_K
throw new Error(`Could not find Infura key in env, unable to connect to network ${argv.network}`)
}

import './src/tasks/localVerify'
import './src/tasks/deployContracts'
import './src/tasks/codesize'

const solidityVersion = SOLIDITY_VERSION || '0.8.23'
const soliditySettings = SOLIDITY_SETTINGS
? JSON.parse(SOLIDITY_SETTINGS)
Expand All @@ -45,6 +46,26 @@ const soliditySettings = SOLIDITY_SETTINGS
},
}

const deterministicDeployment = (network: string): DeterministicDeploymentInfo => {
const info = getSingletonFactoryInfo(parseInt(network))
if (!info) {
throw new Error(`
Safe factory not found for network ${network}. You can request a new deployment at https://github.com/safe-global/safe-singleton-factory.
For more information, see https://github.com/safe-global/safe-smart-account#replay-protection-eip-155
`)
}

const gasLimit = BigInt(info.gasLimit)
const gasPrice = BigInt(info.gasPrice)

return {
factory: info.address,
deployer: info.signerAddress,
funding: String(gasLimit * gasPrice),
signedTx: info.transaction,
}
}

const customNetwork = NODE_URL
? {
custom: {
Expand Down Expand Up @@ -98,6 +119,7 @@ const userConfig: HardhatUserConfig = {
},
...customNetwork,
},
deterministicDeployment,
namedAccounts: {
deployer: 0,
},
Expand Down
2 changes: 0 additions & 2 deletions modules/allowances/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import '@nomicfoundation/hardhat-toolbox'
import 'hardhat-deploy'

import './tasks/deploy_verify'

import dotenv from 'dotenv'
import { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import { DeterministicDeploymentInfo } from 'hardhat-deploy/dist/types'
Expand Down
1 change: 0 additions & 1 deletion modules/allowances/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@openzeppelin/contracts": "^5.0.2",
"@safe-global/safe-deployments": "^1.37.0",
"@safe-global/safe-singleton-factory": "^1.0.25",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/mocha": "^10.0.7",
Expand Down
12 changes: 8 additions & 4 deletions modules/passkey/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ EVM target: Paris

## Expected addresses

- `SafeWebAuthnSignerFactory` at `TBD`
- `SafeWebAuthnSharedSigner` at `TBD`
- `DaimoP256Verifier` at `0xc2b78104907F722DABAc4C69f826a522B2754De4`
- `FCLP256Verifier` at `TBD`
- `SafeWebAuthnSignerFactory` at `0x1d31F259eE307358a26dFb23EB365939E8641195`
- `SafeWebAuthnSharedSigner` at `0x94a4F6affBd8975951142c3999aEAB7ecee555c2`
- `FCLP256Verifier` at `0xA86e0054C51E4894D88762a017ECc5E5235f5DBA`
remedcu marked this conversation as resolved.
Show resolved Hide resolved

### Official Deployment Address from 3rd party

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

Choose a reason for hiding this comment

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

Not for this PR, but can we create an issue to deploy the DaimoP256Verifier correctly on chains where it isn't supported?

I don't know how easy it is to make deployment scripts that work with two different CREATE2 deployers, but it should be possible.

Also, we are unnecessarily deploying the DaimoP256Verifier contract with the Safe Singleton proxy with the current deployment scripts, so those need to be adjusted to not deploy this contract (when not on a test network). This should also be reflected in the issue (I don't want to pull in additional changes to this PR to not slow down the review process even further).


## Changes

Expand All @@ -24,6 +27,7 @@ EVM target: Paris

### General

- Using the [`safe-singleton-factory`](https://github.com/safe-global/safe-singleton-factory) to deploy contracts.
- Use compiler version 0.8.26 and use IR optimizer for all contracts (except `FCLP256Verifier` as it introduces perfomance regressions). This simultaneously decreases code size and runtime gas costs.
- Index the `signer` field for `Created` event in the `SafeWebAuthnSignerFactory` contract.
- Use more consistent compiler version pragmas throughout the contracts.
Expand Down
23 changes: 23 additions & 0 deletions modules/passkey/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { HttpNetworkUserConfig } from 'hardhat/types'
import './src/tasks/codesize'
import './src/tasks/deployContracts'
import './src/tasks/localVerify'
import { getSingletonFactoryInfo } from '@safe-global/safe-singleton-factory'
import { DeterministicDeploymentInfo } from 'hardhat-deploy/dist/types'

dotenv.config()
const { CUSTOM_NODE_URL, MNEMONIC, ETHERSCAN_API_KEY, PK } = process.env
Expand Down Expand Up @@ -43,6 +45,26 @@ const compilerSettings = {
},
}

const deterministicDeployment = (network: string): DeterministicDeploymentInfo => {
const info = getSingletonFactoryInfo(parseInt(network))
if (!info) {
throw new Error(`
Safe factory not found for network ${network}. You can request a new deployment at https://github.com/safe-global/safe-singleton-factory.
For more information, see https://github.com/safe-global/safe-smart-account#replay-protection-eip-155
`)
}

const gasLimit = BigInt(info.gasLimit)
const gasPrice = BigInt(info.gasPrice)

return {
factory: info.address,
deployer: info.signerAddress,
funding: String(gasLimit * gasPrice),
signedTx: info.transaction,
}
}

const config: HardhatUserConfig = {
paths: {
artifacts: 'build/artifacts',
Expand All @@ -65,6 +87,7 @@ const config: HardhatUserConfig = {
},
...customNetwork,
},
deterministicDeployment,
solidity: {
compilers: [compilerSettings],
overrides: {
Expand Down
8 changes: 8 additions & 0 deletions modules/recovery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

# Version: Unreleased

## Changes

### General

- Using the [`safe-singleton-factory`](https://github.com/safe-global/safe-singleton-factory) to deploy contracts.

# Version 0.1.0

## Compiler settings
Expand Down
23 changes: 23 additions & 0 deletions modules/recovery/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'hardhat-deploy'
import dotenv from 'dotenv'
import type { HardhatUserConfig, HttpNetworkUserConfig } from 'hardhat/types'
import yargs from 'yargs/yargs'
import { getSingletonFactoryInfo } from "@safe-global/safe-singleton-factory";
import { DeterministicDeploymentInfo } from "hardhat-deploy/dist/types";

import './src/tasks/deployContracts'
import './src/tasks/localVerify'
Expand Down Expand Up @@ -42,6 +44,26 @@ const customNetwork = CUSTOM_NODE_URL
}
: {}

const deterministicDeployment = (network: string): DeterministicDeploymentInfo => {
const info = getSingletonFactoryInfo(parseInt(network));
if (!info) {
throw new Error(`
Safe factory not found for network ${network}. You can request a new deployment at https://github.com/safe-global/safe-singleton-factory.
For more information, see https://github.com/safe-global/safe-smart-account#replay-protection-eip-155
`);
}

const gasLimit = BigInt(info.gasLimit)
const gasPrice = BigInt(info.gasPrice)

return {
factory: info.address,
deployer: info.signerAddress,
funding: String(gasLimit * gasPrice),
signedTx: info.transaction,
};
};

const userConfig: HardhatUserConfig = {
paths: {
artifacts: 'build/artifacts',
Expand Down Expand Up @@ -71,6 +93,7 @@ const userConfig: HardhatUserConfig = {
},
...customNetwork,
},
deterministicDeployment,
namedAccounts: {
deployer: 0,
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"pnpm": "^9"
},
"devDependencies": {
"@safe-global/safe-singleton-factory": "^1.0.31",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"eslint": "^8.57.0",
Expand Down
Loading
Loading