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 9 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
31 changes: 23 additions & 8 deletions modules/4337/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This changelog only contains changes starting from version 0.2.0

# Version 0.3.0
# Version: Unreleased

## Compiler settings

Expand All @@ -14,20 +14,35 @@ Solidity optimizer: enabled with 10.000.000 runs

The official deployments support the EntryPoint v0.7.0 with the canonical deployment at `0x0000000071727De22E5E9d8BAf0edAc6f37da032`.

## Expected addresses
## Expected addresses with [Safe Singleton Factory](https://github.com/safe-global/safe-singleton-factory)

- `SafeModuleSetup` at `0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47`
- `Safe4337Module` at `0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226`
- `SafeModuleSetup` at `0xF2C2C95C168Ef121b052B4c518889CFe166cB4Fa`
- `Safe4337Module` at `0x68C77b778228823a06e3CbcDA816d46D80B1C728`
remedcu marked this conversation as resolved.
Show resolved Hide resolved

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

### Security Fixes
### General

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

### Compatibility Fixes
# Version 0.3.0

## Compiler settings

Solidity compiler: [0.8.23](https://github.com/ethereum/solidity/releases/tag/v0.8.23)

None
Solidity optimizer: enabled with 10.000.000 runs

## Supported EntryPoint

The official deployments support the EntryPoint v0.7.0 with the canonical deployment at `0x0000000071727De22E5E9d8BAf0edAc6f37da032`.

## Expected addresses with [Deterministic Deployment Proxy](https://github.com/Arachnid/deterministic-deployment-proxy)

- `SafeModuleSetup` at `0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47`
- `Safe4337Module` at `0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226`

## Changes

### General

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
16 changes: 10 additions & 6 deletions modules/passkey/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ Solidity compiler: [0.8.26](https://github.com/ethereum/solidity/releases/tag/v0
Solidity optimizer: enabled with 10.000.000 runs (via IR for all contracts except `FCLP256Verifier`)
EVM target: Paris

## Expected addresses
## Expected addresses with [Safe Singleton Factory](https://github.com/safe-global/safe-singleton-factory)
remedcu marked this conversation as resolved.
Show resolved Hide resolved

- `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 All @@ -38,7 +42,7 @@ Solidity compiler: [0.8.24](https://github.com/ethereum/solidity/releases/tag/v0
Solidity optimizer: enabled with 10.000.000 runs
EVM target: Paris

## Expected addresses
## Expected addresses with [Deterministic Deployment Proxy](https://github.com/Arachnid/deterministic-deployment-proxy)
remedcu marked this conversation as resolved.
Show resolved Hide resolved

- `SafeWebAuthnSignerFactory` at `0xF7488fFbe67327ac9f37D5F722d83Fc900852Fbf`
- `DaimoP256Verifier` at `0xc2b78104907F722DABAc4C69f826a522B2754De4`
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
24 changes: 23 additions & 1 deletion modules/recovery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

# Version: Unreleased

## Compiler settings

Solidity compiler: [0.8.20](https://github.com/ethereum/solidity/releases/tag/v0.8.20)

Solidity optimizer: enabled via IR with 1.000.000 runs

## Recovery Period

The recovery period is 14 days.

## Expected addresses with [Safe Singleton Factory](https://github.com/safe-global/safe-singleton-factory)

- `SocialRecoveryModule` at `0x9BacD92F4687Db306D7ded5d4513a51EA05df25b`
remedcu marked this conversation as resolved.
Show resolved Hide resolved

## 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 All @@ -12,7 +34,7 @@ Solidity optimizer: enabled via IR with 1.000.000 runs

The recovery period is 14 days.

## Expected addresses
## Expected addresses with [Deterministic Deployment Proxy](https://github.com/Arachnid/deterministic-deployment-proxy)
remedcu marked this conversation as resolved.
Show resolved Hide resolved

- `SocialRecoveryModule` at `0x4Aa5Bf7D840aC607cb5BD3249e6Af6FC86C04897`

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