Skip to content

Commit

Permalink
fix gascalc to use latest geth
Browse files Browse the repository at this point in the history
  • Loading branch information
drortirosh committed Dec 23, 2024
1 parent c6f34e4 commit 5d4e5c6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 44 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ jobs:
runs-on: ubuntu-latest
services:
localgeth:
image: dtr22/geth-dev
ports: [ '8545:8545' ]
image: ethereum/client-go:release-1.14
command: |
--verbosity 2
--http -http.addr 0.0.0.0 --http.api 'eth,net,web3,debug' --http.port 8545
--http.vhosts '*,localhost,host.docker.internal'
--dev --rpc.allow-unprotected-txs
steps:
- uses: actions/setup-node@v1
Expand Down
20 changes: 7 additions & 13 deletions gascalc/GasChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const gasCheckerLogFile = './reports/gas-checker.txt'

const ethers = hre.ethers
const provider = hre.ethers.provider
let ethersSigner = provider.getSigner()
const junkWallet = Wallet.fromMnemonic('test test test test test test test test test test test junk')
const globalSigner = new Wallet(junkWallet.privateKey, provider)
let lastGasUsed: number

const minDepositOrBalance = parseEther('0.1')
Expand Down Expand Up @@ -130,7 +131,7 @@ export class GasChecker {
defaultAbiCoder.encode(['address'], [this.entryPoint().address])
]), 0, 2885201)
console.log('factaddr', factoryAddress)
const fact = SimpleAccountFactory__factory.connect(factoryAddress, ethersSigner)
const fact = SimpleAccountFactory__factory.connect(factoryAddress, globalSigner)
// create accounts
const creationOps: PackedUserOperation[] = []
for (const n of range(count)) {
Expand Down Expand Up @@ -165,7 +166,7 @@ export class GasChecker {
await GasCheckCollector.inst.entryPoint.depositTo(addr, { value: minDepositOrBalance.mul(5) })
}
}
await this.entryPoint().handleOps(creationOps, ethersSigner.getAddress())
await this.entryPoint().handleOps(creationOps, globalSigner.getAddress())
}

/**
Expand Down Expand Up @@ -206,7 +207,7 @@ export class GasChecker {
const destBalance = await getBalance(dest)
if (destBalance.eq(0)) {
console.log('dest replenish', dest)
await ethersSigner.sendTransaction({ to: dest, value: 1 })
await globalSigner.sendTransaction({ to: dest, value: 1 })
}
}
const accountExecFromEntryPoint = this.accountExec(dest, destValue, destCallData)
Expand Down Expand Up @@ -335,20 +336,13 @@ export class GasCheckCollector {
}

async _init (entryPointAddressOrTest: string = 'test'): Promise<this> {
console.log('signer=', await ethersSigner.getAddress())
console.log('signer=', await globalSigner.getAddress())
DefaultGasTestInfo.beneficiary = createAddress()

const bal = await getBalance(ethersSigner.getAddress())
if (bal.gt(parseEther('100000000'))) {
console.log('DONT use geth miner.. use account 2 instead')
await checkForGeth()
ethersSigner = ethers.provider.getSigner(2)
}

if (entryPointAddressOrTest === 'test') {
this.entryPoint = await deployEntryPoint(provider)
} else {
this.entryPoint = EntryPoint__factory.connect(entryPointAddressOrTest, ethersSigner)
this.entryPoint = EntryPoint__factory.connect(entryPointAddressOrTest, globalSigner)
}

const tableHeaders = [
Expand Down
42 changes: 21 additions & 21 deletions reports/gas-checker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@
the destination is "account.entryPoint()", which is known to be "hot" address used by this account
it little higher than EOA call: its an exec from entrypoint (or account owner) into account contract, verifying msg.sender and exec to target)
╔══════════════════════════╤════════╗
║ gas estimate "simple" │ 28979
║ gas estimate "simple" │ 29327
╟──────────────────────────┼────────╢
║ gas estimate "big tx 5k" │ 125224
║ gas estimate "big tx 5k" │ 126098
╚══════════════════════════╧════════╝

╔════════════════════════════════╤═══════╤═══════════════╤════════════════╤═════════════════════╗
║ handleOps description │ count │ total gasUsed │ per UserOp gas │ per UserOp overhead ║
║ │ │ │ (delta for │ (compared to ║
║ │ │ │ one UserOp) │ account.exec()) ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple │ 1 │ 80016 │ │ ║
║ simple │ 1 │ 80004 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple - diff from previous │ 2 │ │ 4219213213
║ simple - diff from previous │ 2 │ │ 4216812841
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple │ 10 │ 459919 │ │ ║
║ simple │ 10 │ 459895 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple - diff from previous │ 11 │ │ 42235 │ 13256
║ simple - diff from previous │ 11 │ │ 42235 │ 12908
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster │ 1 │ 86159 │ │ ║
║ simple paymaster │ 1 │ 86147 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster with diff │ 2 │ │ 4102412045
║ simple paymaster with diff │ 2 │ │ 4104811721
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster │ 10 │ 455670 │ │ ║
║ simple paymaster │ 10 │ 455682 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster with diff │ 11 │ │ 4111212133
║ simple paymaster with diff │ 11 │ │ 4114811821
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx 5k │ 1 │ 181060 │ │ ║
║ big tx 5k │ 1 │ 181036 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx - diff from previous │ 2 │ │ 142702 │ 17478
║ big tx - diff from previous │ 2 │ │ 142702 │ 16604
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx 5k │ 10 │ 1465489 │ │ ║
║ big tx 5k │ 10 │ 1465441 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx - diff from previous │ 11 │ │ 14271017486
║ big tx - diff from previous │ 11 │ │ 14272216624
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp │ 1 │ 87770 │ │ ║
║ paymaster+postOp │ 1 │ 87758 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp with diff │ 2 │ │ 4265913680
║ paymaster+postOp with diff │ 2 │ │ 4264713320
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp │ 10 │ 471836 │ │ ║
║ paymaster+postOp │ 10 │ 471848 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp with diff │ 11 │ │ 4269213713
║ paymaster+postOp with diff │ 11 │ │ 4270413377
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster │ 1 │ 128821 │ │ ║
║ token paymaster │ 1 │ 128809 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster with diff │ 2 │ │ 6640837429
║ token paymaster with diff │ 2 │ │ 6638437057
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster │ 10 │ 726686 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster with diff │ 11 │ │ 6652437545
║ token paymaster with diff │ 11 │ │ 6653637209
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝

9 changes: 7 additions & 2 deletions scripts/docker-gascalc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ services:

#configuration is a copy of github/.workflows/build.xml
localgeth:
image: dtr22/geth-dev
container_name: localgeth
ports: [ '8545:8545' ]
image: ethereum/client-go:release-1.14
command: |
--verbosity 2
--http -http.addr 0.0.0.0 --http.api 'eth,net,web3,debug' --http.port 8545
--http.vhosts '*,localhost,host.docker.internal'
--dev --rpc.allow-unprotected-txs
14 changes: 7 additions & 7 deletions test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ export async function checkForGeth (): Promise<void> {
// NOTE: must run geth with params:
// --http.api personal,eth,net,web3
// --allow-insecure-unlock
if (currentNode.match(/geth/i) != null) {
for (let i = 0; i < 2; i++) {
const acc = await provider.request({ method: 'personal_newAccount', params: ['pass'] }).catch(rethrow())
await provider.request({ method: 'personal_unlockAccount', params: [acc, 'pass'] }).catch(rethrow())
await fund(acc, '10')
}
}
// if (currentNode.match(/geth/i) != null) {
// for (let i = 0; i < 2; i++) {
// const acc = await provider.request({ method: 'personal_newAccount', params: ['pass'] }).catch(rethrow())
// await provider.request({ method: 'personal_unlockAccount', params: [acc, 'pass'] }).catch(rethrow())
// await fund(acc, '10')
// }
// }
}

// remove "array" members, convert values to strings.
Expand Down

0 comments on commit 5d4e5c6

Please sign in to comment.