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

AA-213: Standalone ValidationManager package #153

Merged
merged 11 commits into from
Oct 20, 2023
Merged
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
18 changes: 0 additions & 18 deletions packages/bundler/contracts/BundlerHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,3 @@ contract GetUserOpHashes {
}
}
}

contract GetCodeHashes {

error CodeHashesResult(bytes32 hash);
constructor(address[] memory addresses) {
revert CodeHashesResult(getCodeHashes(addresses));
}

function getCodeHashes(address[] memory addresses) public view returns (bytes32) {
bytes32[] memory hashes = new bytes32[](addresses.length);
for (uint i = 0; i < addresses.length; i++) {
hashes[i] = addresses[i].codehash;
}
bytes memory data = abi.encode(hashes);
return (keccak256(data));
}

}
1 change: 1 addition & 0 deletions packages/bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@account-abstraction/contracts": "^0.6.0",
"@account-abstraction/sdk": "^0.6.0",
"@account-abstraction/utils": "^0.6.0",
"@account-abstraction/validation-manager": "^0.6.0",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/properties": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/bundler/src/BundlerServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { Provider } from '@ethersproject/providers'
import { Signer, utils } from 'ethers'
import { parseEther } from 'ethers/lib/utils'

import { AddressZero, deepHexlify, erc4337RuntimeVersion } from '@account-abstraction/utils'
import { AddressZero, deepHexlify, erc4337RuntimeVersion, RpcError } from '@account-abstraction/utils'

import { BundlerConfig } from './BundlerConfig'
import { UserOpMethodHandler } from './UserOpMethodHandler'
import { Server } from 'http'
import { RpcError } from './utils'
import { EntryPoint__factory, UserOperationStruct } from '@account-abstraction/contracts'
import { DebugMethodHandler } from './DebugMethodHandler'

Expand Down
2 changes: 1 addition & 1 deletion packages/bundler/src/DebugMethodHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReputationDump, ReputationManager } from './modules/ReputationManager'
import { MempoolManager } from './modules/MempoolManager'
import { SendBundleReturn } from './modules/BundleManager'
import { EventsManager } from './modules/EventsManager'
import { StakeInfo } from './modules/Types'
import { StakeInfo } from '@account-abstraction/utils'

export class DebugMethodHandler {
constructor (
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler/src/RpcTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumberish } from 'ethers'
import { TransactionReceipt } from '@ethersproject/providers'
import { UserOperation } from './modules/Types'
import { UserOperation } from '@account-abstraction/utils'

/**
* RPC calls return types
Expand Down
7 changes: 2 additions & 5 deletions packages/bundler/src/UserOpMethodHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import { Log, Provider } from '@ethersproject/providers'

import { BundlerConfig } from './BundlerConfig'
import { resolveProperties } from 'ethers/lib/utils'
import { deepHexlify, erc4337RuntimeVersion } from '@account-abstraction/utils'
import { UserOperation, deepHexlify, erc4337RuntimeVersion, requireCond, RpcError, tostr, getAddr, ValidationErrors } from '@account-abstraction/utils'
import { UserOperationStruct, EntryPoint } from '@account-abstraction/contracts'
import { UserOperationEventEvent } from '@account-abstraction/contracts/dist/types/EntryPoint'
import { calcPreVerificationGas } from '@account-abstraction/sdk'
import { requireCond, RpcError, tostr } from './utils'
import { ExecutionManager } from './modules/ExecutionManager'
import { getAddr } from './modules/moduleUtils'
import { UserOperationByHashResponse, UserOperationReceipt } from './RpcTypes'
import { ExecutionErrors, UserOperation, ValidationErrors } from './modules/Types'

const HEX_REGEX = /^0x[a-fA-F\d]*$/i

Expand Down Expand Up @@ -133,7 +130,7 @@ export class UserOpMethodHandler {
data: userOp.callData
}).then(b => b.toNumber()).catch(err => {
const message = err.message.match(/reason="(.*?)"/)?.at(1) ?? 'execution reverted'
throw new RpcError(message, ExecutionErrors.UserOperationReverted)
throw new RpcError(message, ValidationErrors.UserOperationReverted)
})
validAfter = BigNumber.from(validAfter)
validUntil = BigNumber.from(validUntil)
Expand Down
5 changes: 2 additions & 3 deletions packages/bundler/src/modules/BundleManager.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { EntryPoint } from '@account-abstraction/contracts'
import { MempoolManager } from './MempoolManager'
import { ValidateUserOpResult, ValidationManager } from './ValidationManager'
import { ValidateUserOpResult, ValidationManager } from '@account-abstraction/validation-manager'
import { BigNumber, BigNumberish } from 'ethers'
import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers'
import Debug from 'debug'
import { ReputationManager, ReputationStatus } from './ReputationManager'
import { Mutex } from 'async-mutex'
import { GetUserOpHashes__factory } from '../types'
import { StorageMap, UserOperation } from './Types'
import { getAddr, mergeStorageMap, runContractScript } from './moduleUtils'
import { UserOperation, StorageMap, getAddr, mergeStorageMap, runContractScript } from '@account-abstraction/utils'
import { EventsManager } from './EventsManager'
import { ErrorDescription } from '@ethersproject/abi/lib/interface'

Expand Down
13 changes: 7 additions & 6 deletions packages/bundler/src/modules/ExecutionManager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ReputationManager } from './ReputationManager'
import { clearInterval } from 'timers'
import { MempoolManager } from './MempoolManager'
import { BundleManager, SendBundleReturn } from './BundleManager'
import Debug from 'debug'
import { ValidationManager } from './ValidationManager'
import { Mutex } from 'async-mutex'
import { UserOperation } from './Types'
import { ValidationManager } from '@account-abstraction/validation-manager'
import { UserOperation } from '@account-abstraction/utils'
import { clearInterval } from 'timers'

import { BundleManager, SendBundleReturn } from './BundleManager'
import { MempoolManager } from './MempoolManager'
import { ReputationManager } from './ReputationManager'

const debug = Debug('aa.exec')

Expand Down
12 changes: 9 additions & 3 deletions packages/bundler/src/modules/MempoolManager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { BigNumber, BigNumberish } from 'ethers'
import { getAddr } from './moduleUtils'
import { requireCond, RpcError } from '../utils'
import {
ReferencedCodeHashes,
RpcError,
StakeInfo,
UserOperation,
ValidationErrors,
getAddr,
requireCond
} from '@account-abstraction/utils'
import { ReputationManager } from './ReputationManager'
import Debug from 'debug'
import { ReferencedCodeHashes, StakeInfo, UserOperation, ValidationErrors } from './Types'

const debug = Debug('aa.mempool')

Expand Down
3 changes: 1 addition & 2 deletions packages/bundler/src/modules/ReputationManager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Debug from 'debug'
import { requireCond, tostr } from '../utils'
import { BigNumber } from 'ethers'
import { Provider } from '@ethersproject/providers'

import { StakeInfo, ValidationErrors } from './Types'
import { StakeInfo, ValidationErrors, requireCond, tostr } from '@account-abstraction/utils'
import { IStakeManager__factory } from '../types'

const debug = Debug('aa.rep')
Expand Down
47 changes: 0 additions & 47 deletions packages/bundler/src/modules/Types.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/bundler/src/modules/initServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExecutionManager } from './ExecutionManager'
import { BundlerReputationParams, ReputationManager } from './ReputationManager'
import { MempoolManager } from './MempoolManager'
import { BundleManager } from './BundleManager'
import { ValidationManager } from './ValidationManager'
import { ValidationManager } from '@account-abstraction/validation-manager'
import { EntryPoint__factory } from '@account-abstraction/contracts'
import { parseEther } from 'ethers/lib/utils'
import { Signer } from 'ethers'
Expand All @@ -20,7 +20,7 @@ export function initServer (config: BundlerConfig, signer: Signer): [ExecutionMa
const entryPoint = EntryPoint__factory.connect(config.entryPoint, signer)
const reputationManager = new ReputationManager(getNetworkProvider(config.network), BundlerReputationParams, parseEther(config.minStake), config.minUnstakeDelay)
const mempoolManager = new MempoolManager(reputationManager)
const validationManager = new ValidationManager(entryPoint, reputationManager, config.unsafe)
const validationManager = new ValidationManager(entryPoint, config.unsafe)
const eventsManager = new EventsManager(entryPoint, mempoolManager, reputationManager)
const bundleManager = new BundleManager(entryPoint, eventsManager, mempoolManager, validationManager, reputationManager,
config.beneficiary, parseEther(config.minBalance), config.maxBundleGas, config.conditionalRpc)
Expand Down
71 changes: 0 additions & 71 deletions packages/bundler/src/modules/moduleUtils.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/bundler/src/runBundler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'

import { Command } from 'commander'
import { erc4337RuntimeVersion } from '@account-abstraction/utils'
import { erc4337RuntimeVersion, supportsRpcMethod } from '@account-abstraction/utils'
import { ethers, Wallet, Signer } from 'ethers'

import { BundlerServer } from './BundlerServer'
Expand All @@ -11,7 +11,7 @@ import { EntryPoint, EntryPoint__factory } from '@account-abstraction/contracts'
import { initServer } from './modules/initServer'
import { DebugMethodHandler } from './DebugMethodHandler'
import { DeterministicDeployer } from '@account-abstraction/sdk'
import { supportsDebugTraceCall, supportsRpcMethod } from './utils'
import { supportsDebugTraceCall } from '@account-abstraction/validation-manager'
import { resolveConfiguration } from './Config'
import { bundlerConfigDefault } from './BundlerConfig'
import { JsonRpcProvider } from '@ethersproject/providers'
Expand Down
80 changes: 0 additions & 80 deletions packages/bundler/src/utils.ts

This file was deleted.

Loading