-
Notifications
You must be signed in to change notification settings - Fork 228
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
AA-440 validate using handleOps #243
base: master
Are you sure you want to change the base?
Changes from 2 commits
695cb26
64e60bb
ae02267
ee39c5e
0314372
f9c37f2
2055b72
6f2972a
3545105
9df986b
c5eebfa
4ed0ca0
56482d1
8df579a
114fef8
1dab49f
f2c4a86
be7b10f
b1f2042
cc66bcc
7ef33d3
8ffdff8
dc8320c
acf965d
f616408
c85351a
1e3b92e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[submodule "submodules/account-abstraction"] | ||
path = submodules/account-abstraction | ||
url = https://github.com/eth-infinitism/account-abstraction.git | ||
branch = releases/v0.7 | ||
branch = callValidateUserOp-catch-revert | ||
[submodule "submodules/rip7560"] | ||
path = submodules/rip7560 | ||
url = https://github.com/eth-infinitism/rip7560_contracts.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { JsonRpcProvider } from '@ethersproject/providers' | ||
import { ethers } from 'hardhat' | ||
import { expect } from 'chai' | ||
import { parseEther } from 'ethers/lib/utils' | ||
|
||
|
@@ -29,9 +28,14 @@ describe('BundleServer', function () { | |
let entryPoint: IEntryPoint | ||
let server: BundlerServer | ||
before(async () => { | ||
const provider = ethers.provider | ||
// const provider = ethers.provider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
const provider = new JsonRpcProvider('http://localhost:8545') | ||
const signer = await createSigner() | ||
entryPoint = await deployEntryPoint(provider) | ||
try { | ||
entryPoint = await deployEntryPoint(provider) | ||
} catch (e) { | ||
throw new Error('Failed to deploy entry point - no geth?\n' + e) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Geth or just a node? |
||
} | ||
|
||
const config: BundlerConfig = { | ||
chainId: 1337, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { ethers, BigNumber, BigNumberish, BytesLike } from 'ethers' | |
import { Provider } from '@ethersproject/providers' | ||
|
||
import { TransactionDetailsForUserOp } from './TransactionDetailsForUserOp' | ||
import { defaultAbiCoder } from 'ethers/lib/utils' | ||
import { defaultAbiCoder, hexConcat, hexDataSlice } from 'ethers/lib/utils' | ||
import { PaymasterAPI } from './PaymasterAPI' | ||
import { encodeUserOp, getUserOpHash, IEntryPoint, IEntryPoint__factory, UserOperation } from '@account-abstraction/utils' | ||
|
||
|
@@ -120,12 +120,13 @@ export abstract class BaseAccountAPI { | |
if (factory == null) { | ||
throw new Error(('no counter factual address if not factory')) | ||
} | ||
// use entryPoint to query account address (factory can provide a helper method to do the same, but | ||
// this method attempts to be generic | ||
const retAddr = await this.provider.call({ | ||
to: factory, data: factoryData | ||
const getSenderAddressData = this.entryPointView.interface.encodeFunctionData('getSenderAddress', [hexConcat([factory, factoryData ?? '0x'])]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we use to the factory contract object here? Manually encoding and decoding this data is not pretty. |
||
const senderAddressResult = await this.provider.call({ | ||
to: this.entryPointAddress, | ||
data: getSenderAddressData | ||
}) | ||
const [addr] = defaultAbiCoder.decode(['address'], retAddr) | ||
// the result is "error SenderAddressResult(address)", so remove methodsig first. | ||
const [addr] = defaultAbiCoder.decode(['address'], hexDataSlice(senderAddressResult, 4)) | ||
return addr | ||
} | ||
|
||
|
@@ -205,7 +206,12 @@ export abstract class BaseAccountAPI { | |
if (factoryParams == null) { | ||
return 0 | ||
} | ||
return await this.provider.estimateGas({ to: factoryParams.factory, data: factoryParams.factoryData }) | ||
const senderCreator = await this.entryPointView.senderCreator() | ||
return await this.provider.estimateGas({ | ||
from: senderCreator, | ||
to: factoryParams.factory, | ||
data: factoryParams.factoryData | ||
}) | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
import { arrayify } from 'ethers/lib/utils' | ||
import { Signer } from '@ethersproject/abstract-signer' | ||
import { BaseApiParams, BaseAccountAPI, FactoryParams } from './BaseAccountAPI' | ||
import { ecsign, toRpcSig } from 'ethereumjs-util' | ||
|
||
/** | ||
* constructor params, added no top of base params: | ||
|
@@ -100,6 +101,8 @@ export class SimpleAccountAPI extends BaseAccountAPI { | |
} | ||
|
||
async signUserOpHash (userOpHash: string): Promise<string> { | ||
return await this.owner.signMessage(arrayify(userOpHash)) | ||
const privateKey = (this.owner as any).privateKey | ||
const sig = ecsign(Buffer.from(arrayify(userOpHash)), Buffer.from(arrayify(privateKey))) | ||
return toRpcSig(sig.v, sig.r, sig.s) | ||
Comment on lines
+104
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this change made and how is it related to this issue? |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
pragma solidity >=0.8; | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
import "@account-abstraction/contracts/interfaces/IEntryPoint.sol"; | ||
|
||
struct StakeInfo { | ||
address addr; | ||
uint256 stake; | ||
uint256 unstakeDelaySec; | ||
} | ||
|
||
error StakesRet(StakeInfo[] stakes); | ||
|
||
// helper: get stake info of multiple entities. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we use OpenZeppelin's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. multicall has to be deployed, and only then can be called. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but also this is a bit of reinventing the wheel. Maybe we should just give in and deploy the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we could use multicall, but:
|
||
// This contract is never deployed: it is called using eth_call, and it reverts with the result... | ||
contract GetStakes { | ||
|
||
constructor(IEntryPoint entryPoint, address[] memory addrs) { | ||
StakeInfo[] memory stakes = getStakes(entryPoint, addrs); | ||
revert StakesRet(stakes); | ||
} | ||
|
||
function getStakes(IEntryPoint entryPoint, address[] memory addrs) public view returns (StakeInfo[] memory) { | ||
StakeInfo[] memory stakes = new StakeInfo[](addrs.length); | ||
for (uint256 i = 0; i < addrs.length; i++) { | ||
IStakeManager.DepositInfo memory info = entryPoint.getDepositInfo(addrs[i]); | ||
stakes[i] = StakeInfo(addrs[i], info.stake, info.unstakeDelaySec); | ||
} | ||
return stakes; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.23; | ||
pragma solidity ^0.8; | ||
|
||
import "@account-abstraction/contracts/core/EntryPointSimulations.sol"; | ||
import "@account-abstraction/contracts/interfaces/IStakeManager.sol"; | ||
import "@account-abstraction/contracts/samples/SimpleAccountFactory.sol"; | ||
import "@account-abstraction/contracts/samples/TokenPaymaster.sol"; | ||
//import "@account-abstraction/contracts/samples/TokenPaymaster.sol"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
import "@account-abstraction/rip7560/contracts/predeploys/Rip7560StakeManager.sol"; | ||
|
||
import {NonceManager as NonceManagerRIP7712} from "@account-abstraction/rip7560/contracts/predeploys/NonceManager.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, though the new value will be "develop", until we complete releases/v0.8