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

Revert "Fix deployment" 👍🏾 #502

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@account-abstraction/contracts",
"description": "Account Abstraction (EIP 4337) contracts",
"version": "0.7.0",
"version": "0.6.0",
"main": "./dist/index.js",
"scripts": {
"prepack": "../scripts/prepack-contracts-package.sh",
"postpack": "../scripts/postpack-contracts-package.sh"
Expand All @@ -22,8 +23,10 @@
"bugs": {
"url": "https://github.com/eth-infinitism/account-abstraction/issues"
},
"dependencies": {
"devDependencies": {
"@openzeppelin/contracts": "^5.0.0",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@uniswap/v3-periphery": "^1.4.3"
}
}
22 changes: 20 additions & 2 deletions deploy/1_deploy_entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'
import { Create2Factory } from '../src/Create2Factory'
import { ethers } from 'hardhat'

const deployEntryPoint: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const provider = ethers.provider
const from = await provider.getSigner().getAddress()
await new Create2Factory(ethers.provider).deployFactory()

const ret = await hre.deployments.deploy(
'EntryPoint', {
from,
args: [],
gasLimit: 6e6,
deterministicDeployment: process.env.SALT ?? true,
log: true
deterministicDeployment: true
})
console.log('==entrypoint addr=', ret.address)

const entryPointAddress = ret.address
const w = await hre.deployments.deploy(
'SimpleAccount', {
from,
args: [entryPointAddress],
gasLimit: 2e6,
deterministicDeployment: true
})

console.log('== wallet=', w.address)

const t = await hre.deployments.deploy('TestCounter', {
from,
deterministicDeployment: true
})
console.log('==testCounter=', t.address)
}

export default deployEntryPoint
14 changes: 3 additions & 11 deletions deploy/2_deploy_SimpleAccountFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,20 @@ const deploySimpleAccountFactory: DeployFunction = async function (hre: HardhatR
const from = await provider.getSigner().getAddress()
const network = await provider.getNetwork()
// only deploy on local test network.

const forceDeployFactory = process.argv.join(' ').match(/simple-account-factory/) != null

if (!forceDeployFactory && network.chainId !== 31337 && network.chainId !== 1337) {
if (network.chainId !== 31337 && network.chainId !== 1337) {
return
}

const entrypoint = await hre.deployments.get('EntryPoint')
await hre.deployments.deploy(
const ret = await hre.deployments.deploy(
'SimpleAccountFactory', {
from,
args: [entrypoint.address],
gasLimit: 6e6,
log: true,
deterministicDeployment: true
})

await hre.deployments.deploy('TestCounter', {
from,
deterministicDeployment: true,
log: true
})
console.log('==SimpleAccountFactory addr=', ret.address)
}

export default deploySimpleAccountFactory
3 changes: 2 additions & 1 deletion gascalc/GasChecker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// calculate gas usage of different bundle sizes
import '../test/aa.init'
import { defaultAbiCoder, hexConcat, parseEther } from 'ethers/lib/utils'
import { defaultAbiCoder, formatEther, hexConcat, parseEther } from 'ethers/lib/utils'
import {
AddressZero,
checkForGeth,
Expand Down Expand Up @@ -321,6 +321,7 @@ export class GasCheckCollector {

const bal = await getBalance(ethersSigner.getAddress())
if (bal.gt(parseEther('100000000'))) {
console.log('bal=', formatEther(bal))
console.log('DONT use geth miner.. use account 2 instead')
await checkForGeth()
ethersSigner = ethers.provider.getSigner(2)
Expand Down
10 changes: 2 additions & 8 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import '@nomiclabs/hardhat-waffle'
import '@typechain/hardhat'
import { HardhatUserConfig, task } from 'hardhat/config'
import { HardhatUserConfig } from 'hardhat/config'
import 'hardhat-deploy'
import '@nomiclabs/hardhat-etherscan'

import 'solidity-coverage'

import * as fs from 'fs'

const SALT = '0x90d8084deab30c2a37c45e8d47f49f2f7965183cb6990a98943ef94940681de3'
process.env.SALT = process.env.SALT ?? SALT

task('deploy', 'Deploy contracts')
.addFlag('simpleAccountFactory', 'deploy sample factory (by default, enabled only on localhost)')

const mnemonicFileName = process.env.MNEMONIC_FILE!
const mnemonicFileName = process.env.MNEMONIC_FILE ?? `${process.env.HOME}/.secret/testnet-mnemonic.txt`
let mnemonic = 'test '.repeat(11) + 'junk'
if (fs.existsSync(mnemonicFileName)) { mnemonic = fs.readFileSync(mnemonicFileName, 'ascii') }

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "accountabstraction",
"version": "0.7.0",
"version": "0.6.0",
"description": "ERC-4337 Account Abstraction Implementation",
"scripts": {
"clean": "rm -rf cache artifacts typechain typechain-types",
Expand All @@ -19,7 +19,9 @@
"ci": "yarn compile && hardhat test && yarn run runop",
"ci-gas-calc": "yarn gas-calc && yarn check-gas-reports",
"check-gas-reports": "./scripts/check-gas-reports",
"runop": "hardhat run src/runop.ts "
"runop": "hardhat run src/runop.ts ",
"runop-goerli": "AA_URL=https://account-abstraction-goerli.nethermind.io yarn runop --network goerli",
"runop3": "hardhat run src/runop3.ts "
},
"keywords": [],
"author": "",
Expand Down
30 changes: 15 additions & 15 deletions reports/gas-checker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,40 @@
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple - diff from previous │ 2 │ │ 42192 │ 13213 ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple │ 10 │ 459921 │ │ ║
║ simple │ 10 │ 459909 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple - diff from previous │ 11 │ │ 4222313244
║ simple - diff from previous │ 11 │ │ 4229513316
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster │ 1 │ 86113 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster with diff │ 2 │ │ 4102412045
║ simple paymaster with diff │ 2 │ │ 4107212093
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster │ 10 │ 455444 │ │ ║
║ simple paymaster │ 10 │ 455732 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster with diff │ 11 │ │ 4108812109
║ simple paymaster with diff │ 11 │ │ 4104012061
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx 5k │ 1 │ 181026 │ │ ║
║ big tx 5k │ 1 │ 181038 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx - diff from previous │ 2 │ │ 14271417490
║ big tx - diff from previous │ 2 │ │ 14267817454
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx 5k │ 10 │ 1465443 │ │ ║
║ big tx 5k │ 10 │ 1465467 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx - diff from previous │ 11 │ │ 142686 │ 17462 ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp │ 1 │ 87712 │ │ ║
║ paymaster+postOp │ 1 │ 87736 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp with diff │ 2 │ │ 4267113692
║ paymaster+postOp with diff │ 2 │ │ 4265913680
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp │ 10 │ 471754 │ │ ║
║ paymaster+postOp │ 10 │ 471826 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp with diff │ 11 │ │ 4272813749
║ paymaster+postOp with diff │ 11 │ │ 4269213713
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster │ 1 │ 128777 │ │ ║
║ token paymaster │ 1 │ 128765 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster with diff │ 2 │ │ 6638637407
║ token paymaster with diff │ 2 │ │ 6639837419
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster │ 10 │ 726504 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster with diff │ 11 │ │ 6639437415
║ token paymaster with diff │ 11 │ │ 6645437475
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝

2 changes: 1 addition & 1 deletion scripts/postpack-contracts-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#echo postpack for "contracts" package
cd `dirname $0`/..
pwd
rm -rf contracts/artifacts
rm -rf contracts/artifacts contracts/types contracts/dist

6 changes: 4 additions & 2 deletions scripts/prepack-contracts-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ yarn clean
yarn compile
cd contracts

rm -rf artifacts
rm -rf artifacts types dist

mkdir -p artifacts
cp `find ../artifacts/contracts -type f | grep -v -E 'test|Test|dbg|bls|IOracle'` artifacts/
cp `find ../artifacts/contracts -type f | grep -v -E 'Test|dbg|bls|IOracle'` artifacts/
npx typechain --target ethers-v5 --out-dir types artifacts/**
npx tsc index.ts -d --outDir dist
19 changes: 6 additions & 13 deletions src/AASigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Deferrable, resolveProperties } from '@ethersproject/properties'
import { BaseProvider, Provider, TransactionRequest } from '@ethersproject/providers'
import { BigNumber, Bytes, ethers, Event, Signer } from 'ethers'
import { clearInterval } from 'timers'
import { decodeRevertReason, getAccountAddress, getAccountInitCode } from '../test/testutils'
import { getAccountAddress, getAccountInitCode } from '../test/testutils'
import { fillAndSign, getUserOpHash, packUserOp } from '../test/UserOp'
import { PackedUserOperation, UserOperation } from '../test/UserOperation'
import {
Expand Down Expand Up @@ -174,18 +174,11 @@ export function localUserOpSender (entryPointAddress: string, signer: Signer, be
}
const gasLimit = BigNumber.from(userOp.preVerificationGas).add(userOp.verificationGasLimit).add(userOp.callGasLimit)
console.log('calc gaslimit=', gasLimit.toString())
try {
const ret = await entryPoint.handleOps([packUserOp(userOp)], beneficiary ?? await signer.getAddress(), {
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
maxFeePerGas: userOp.maxFeePerGas,
gasLimit: 1e6

})
await ret.wait()
} catch (e: any) {
console.log('decoded err=', decodeRevertReason(e))
throw e
}
const ret = await entryPoint.handleOps([packUserOp(userOp)], beneficiary ?? await signer.getAddress(), {
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
maxFeePerGas: userOp.maxFeePerGas
})
await ret.wait()
return undefined
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export async function checkForBannedOps (txHash: string, checkPaymaster: boolean

export async function deployEntryPoint (provider = ethers.provider): Promise<EntryPoint> {
const create2factory = new Create2Factory(provider)
const addr = await create2factory.deploy(EntryPoint__factory.bytecode, process.env.SALT, process.env.COVERAGE != null ? 20e6 : 8e6)
const addr = await create2factory.deploy(EntryPoint__factory.bytecode, 0, process.env.COVERAGE != null ? 20e6 : 8e6)
return EntryPoint__factory.connect(addr, provider.getSigner())
}

Expand Down