Skip to content

Commit 7af70c8

Browse files
authored
Fix deployment (eth-infinitism#452)
* fix deployment of v0.7 - new package version - move test contracts to separate deployment script, deploy only on testnet - add deploy param --simpleAccountFactory - use env SALT - remove typechain output from contracts package
1 parent 8086e7b commit 7af70c8

File tree

11 files changed

+58
-63
lines changed

11 files changed

+58
-63
lines changed

contracts/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "@account-abstraction/contracts",
33
"description": "Account Abstraction (EIP 4337) contracts",
4-
"version": "0.6.0",
5-
"main": "./dist/index.js",
4+
"version": "0.7.0",
65
"scripts": {
76
"prepack": "../scripts/prepack-contracts-package.sh",
87
"postpack": "../scripts/postpack-contracts-package.sh"
@@ -23,10 +22,8 @@
2322
"bugs": {
2423
"url": "https://github.com/eth-infinitism/account-abstraction/issues"
2524
},
26-
"devDependencies": {
25+
"dependencies": {
2726
"@openzeppelin/contracts": "^5.0.0",
28-
"@nomiclabs/hardhat-ethers": "^2.0.2",
29-
"@nomiclabs/hardhat-waffle": "^2.0.1",
3027
"@uniswap/v3-periphery": "^1.4.3"
3128
}
3229
}

deploy/1_deploy_entrypoint.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
11
import { HardhatRuntimeEnvironment } from 'hardhat/types'
22
import { DeployFunction } from 'hardhat-deploy/types'
3-
import { Create2Factory } from '../src/Create2Factory'
43
import { ethers } from 'hardhat'
54

65
const deployEntryPoint: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
76
const provider = ethers.provider
87
const from = await provider.getSigner().getAddress()
9-
await new Create2Factory(ethers.provider).deployFactory()
108

119
const ret = await hre.deployments.deploy(
1210
'EntryPoint', {
1311
from,
1412
args: [],
1513
gasLimit: 6e6,
16-
deterministicDeployment: true
14+
deterministicDeployment: process.env.SALT ?? true,
15+
log: true
1716
})
1817
console.log('==entrypoint addr=', ret.address)
19-
20-
const entryPointAddress = ret.address
21-
const w = await hre.deployments.deploy(
22-
'SimpleAccount', {
23-
from,
24-
args: [entryPointAddress],
25-
gasLimit: 2e6,
26-
deterministicDeployment: true
27-
})
28-
29-
console.log('== wallet=', w.address)
30-
31-
const t = await hre.deployments.deploy('TestCounter', {
32-
from,
33-
deterministicDeployment: true
34-
})
35-
console.log('==testCounter=', t.address)
3618
}
3719

3820
export default deployEntryPoint

deploy/2_deploy_SimpleAccountFactory.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,28 @@ const deploySimpleAccountFactory: DeployFunction = async function (hre: HardhatR
77
const from = await provider.getSigner().getAddress()
88
const network = await provider.getNetwork()
99
// only deploy on local test network.
10-
if (network.chainId !== 31337 && network.chainId !== 1337) {
10+
11+
const forceDeployFactory = process.argv.join(' ').match(/simple-account-factory/) != null
12+
13+
if (!forceDeployFactory && network.chainId !== 31337 && network.chainId !== 1337) {
1114
return
1215
}
1316

1417
const entrypoint = await hre.deployments.get('EntryPoint')
15-
const ret = await hre.deployments.deploy(
18+
await hre.deployments.deploy(
1619
'SimpleAccountFactory', {
1720
from,
1821
args: [entrypoint.address],
1922
gasLimit: 6e6,
2023
log: true,
2124
deterministicDeployment: true
2225
})
23-
console.log('==SimpleAccountFactory addr=', ret.address)
26+
27+
await hre.deployments.deploy('TestCounter', {
28+
from,
29+
deterministicDeployment: true,
30+
log: true
31+
})
2432
}
2533

2634
export default deploySimpleAccountFactory

gascalc/GasChecker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// calculate gas usage of different bundle sizes
22
import '../test/aa.init'
3-
import { defaultAbiCoder, formatEther, hexConcat, parseEther } from 'ethers/lib/utils'
3+
import { defaultAbiCoder, hexConcat, parseEther } from 'ethers/lib/utils'
44
import {
55
AddressZero,
66
checkForGeth,
@@ -321,7 +321,6 @@ export class GasCheckCollector {
321321

322322
const bal = await getBalance(ethersSigner.getAddress())
323323
if (bal.gt(parseEther('100000000'))) {
324-
console.log('bal=', formatEther(bal))
325324
console.log('DONT use geth miner.. use account 2 instead')
326325
await checkForGeth()
327326
ethersSigner = ethers.provider.getSigner(2)

hardhat.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import '@nomiclabs/hardhat-waffle'
22
import '@typechain/hardhat'
3-
import { HardhatUserConfig } from 'hardhat/config'
3+
import { HardhatUserConfig, task } from 'hardhat/config'
44
import 'hardhat-deploy'
55
import '@nomiclabs/hardhat-etherscan'
66

77
import 'solidity-coverage'
88

99
import * as fs from 'fs'
1010

11-
const mnemonicFileName = process.env.MNEMONIC_FILE ?? `${process.env.HOME}/.secret/testnet-mnemonic.txt`
11+
const SALT = '0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3'
12+
process.env.SALT = process.env.SALT ?? SALT
13+
14+
task('deploy', 'Deploy contracts')
15+
.addFlag('simpleAccountFactory', 'deploy sample factory (by default, enabled only on localhost)')
16+
17+
const mnemonicFileName = process.env.MNEMONIC_FILE!
1218
let mnemonic = 'test '.repeat(11) + 'junk'
1319
if (fs.existsSync(mnemonicFileName)) { mnemonic = fs.readFileSync(mnemonicFileName, 'ascii') }
1420

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "accountabstraction",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "ERC-4337 Account Abstraction Implementation",
55
"scripts": {
66
"clean": "rm -rf cache artifacts typechain typechain-types",
@@ -19,9 +19,7 @@
1919
"ci": "yarn compile && hardhat test && yarn run runop",
2020
"ci-gas-calc": "yarn gas-calc && yarn check-gas-reports",
2121
"check-gas-reports": "./scripts/check-gas-reports",
22-
"runop": "hardhat run src/runop.ts ",
23-
"runop-goerli": "AA_URL=https://account-abstraction-goerli.nethermind.io yarn runop --network goerli",
24-
"runop3": "hardhat run src/runop3.ts "
22+
"runop": "hardhat run src/runop.ts "
2523
},
2624
"keywords": [],
2725
"author": "",

reports/gas-checker.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,40 @@
1616
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
1717
║ simple - diff from previous │ 2 │ │ 42192 │ 13213 ║
1818
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
19-
║ simple │ 10 │ 459909 │ │ ║
19+
║ simple │ 10 │ 459921 │ │ ║
2020
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
21-
║ simple - diff from previous │ 11 │ │ 4229513316
21+
║ simple - diff from previous │ 11 │ │ 4222313244
2222
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
2323
║ simple paymaster │ 1 │ 86113 │ │ ║
2424
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
25-
║ simple paymaster with diff │ 2 │ │ 4107212093
25+
║ simple paymaster with diff │ 2 │ │ 4102412045
2626
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
27-
║ simple paymaster │ 10 │ 455732 │ │ ║
27+
║ simple paymaster │ 10 │ 455444 │ │ ║
2828
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
29-
║ simple paymaster with diff │ 11 │ │ 4104012061
29+
║ simple paymaster with diff │ 11 │ │ 4108812109
3030
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
31-
║ big tx 5k │ 1 │ 181038 │ │ ║
31+
║ big tx 5k │ 1 │ 181026 │ │ ║
3232
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
33-
║ big tx - diff from previous │ 2 │ │ 14267817454
33+
║ big tx - diff from previous │ 2 │ │ 14271417490
3434
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
35-
║ big tx 5k │ 10 │ 1465467 │ │ ║
35+
║ big tx 5k │ 10 │ 1465443 │ │ ║
3636
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
3737
║ big tx - diff from previous │ 11 │ │ 142686 │ 17462 ║
3838
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
39-
║ paymaster+postOp │ 1 │ 87736 │ │ ║
39+
║ paymaster+postOp │ 1 │ 87712 │ │ ║
4040
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
41-
║ paymaster+postOp with diff │ 2 │ │ 4265913680
41+
║ paymaster+postOp with diff │ 2 │ │ 4267113692
4242
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
43-
║ paymaster+postOp │ 10 │ 471826 │ │ ║
43+
║ paymaster+postOp │ 10 │ 471754 │ │ ║
4444
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
45-
║ paymaster+postOp with diff │ 11 │ │ 4269213713
45+
║ paymaster+postOp with diff │ 11 │ │ 4272813749
4646
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
47-
║ token paymaster │ 1 │ 128765 │ │ ║
47+
║ token paymaster │ 1 │ 128777 │ │ ║
4848
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
49-
║ token paymaster with diff │ 2 │ │ 6639837419
49+
║ token paymaster with diff │ 2 │ │ 6638637407
5050
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
5151
║ token paymaster │ 10 │ 726504 │ │ ║
5252
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
53-
║ token paymaster with diff │ 11 │ │ 6645437475
53+
║ token paymaster with diff │ 11 │ │ 6639437415
5454
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝
5555

scripts/postpack-contracts-package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
#echo postpack for "contracts" package
33
cd `dirname $0`/..
44
pwd
5-
rm -rf contracts/artifacts contracts/types contracts/dist
5+
rm -rf contracts/artifacts
66

scripts/prepack-contracts-package.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ yarn clean
1111
yarn compile
1212
cd contracts
1313

14-
rm -rf artifacts types dist
14+
rm -rf artifacts
1515

1616
mkdir -p artifacts
17-
cp `find ../artifacts/contracts -type f | grep -v -E 'Test|dbg|bls|IOracle'` artifacts/
18-
npx typechain --target ethers-v5 --out-dir types artifacts/**
19-
npx tsc index.ts -d --outDir dist
17+
cp `find ../artifacts/contracts -type f | grep -v -E 'test|Test|dbg|bls|IOracle'` artifacts/

src/AASigner.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Deferrable, resolveProperties } from '@ethersproject/properties'
55
import { BaseProvider, Provider, TransactionRequest } from '@ethersproject/providers'
66
import { BigNumber, Bytes, ethers, Event, Signer } from 'ethers'
77
import { clearInterval } from 'timers'
8-
import { getAccountAddress, getAccountInitCode } from '../test/testutils'
8+
import { decodeRevertReason, getAccountAddress, getAccountInitCode } from '../test/testutils'
99
import { fillAndSign, getUserOpHash, packUserOp } from '../test/UserOp'
1010
import { PackedUserOperation, UserOperation } from '../test/UserOperation'
1111
import {
@@ -174,11 +174,18 @@ export function localUserOpSender (entryPointAddress: string, signer: Signer, be
174174
}
175175
const gasLimit = BigNumber.from(userOp.preVerificationGas).add(userOp.verificationGasLimit).add(userOp.callGasLimit)
176176
console.log('calc gaslimit=', gasLimit.toString())
177-
const ret = await entryPoint.handleOps([packUserOp(userOp)], beneficiary ?? await signer.getAddress(), {
178-
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
179-
maxFeePerGas: userOp.maxFeePerGas
180-
})
181-
await ret.wait()
177+
try {
178+
const ret = await entryPoint.handleOps([packUserOp(userOp)], beneficiary ?? await signer.getAddress(), {
179+
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
180+
maxFeePerGas: userOp.maxFeePerGas,
181+
gasLimit: 1e6
182+
183+
})
184+
await ret.wait()
185+
} catch (e: any) {
186+
console.log('decoded err=', decodeRevertReason(e))
187+
throw e
188+
}
182189
return undefined
183190
}
184191
}

0 commit comments

Comments
 (0)