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

feat: minor changes to aa bundler #1333

Open
wants to merge 2 commits 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
4 changes: 2 additions & 2 deletions packages/boba/bundler/src/BundlerCollectorTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function bundlerCollectorTracer(): BundlerCollectorTracer {
this.calls.push({
type: frame.getError() != null ? 'REVERT' : 'RETURN',
gasUsed: frame.getGasUsed(),
data: toHex(frame.getOutput()).slice(0, 1000),
data: toHex(frame.getOutput()).slice(0, 4000),
})
},

Expand All @@ -165,7 +165,7 @@ export function bundlerCollectorTracer(): BundlerCollectorTracer {
// from opcode
const ofs = parseInt(log.stack.peek(0).toString())
const len = parseInt(log.stack.peek(1).toString())
const data = toHex(log.memory.slice(ofs, ofs + len)).slice(0, 1000)
const data = toHex(log.memory.slice(ofs, ofs + len)).slice(0, 4000)
// this.debug.push(opcode + ' ' + data)
this.calls.push({
type: opcode,
Expand Down
2 changes: 1 addition & 1 deletion packages/boba/bundler/src/modules/ExecutionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class ExecutionManager {
this.autoInterval = autoBundleInterval
if (autoBundleInterval !== 0) {
this.autoBundleInterval = setInterval(() => {
void this.attemptBundle(true)
void this.attemptBundle(true).catch(e => console.error('auto-bundle failed', e))
}, autoBundleInterval * 1000)
}
this.maxMempoolSize = maxMempoolSize
Expand Down
12 changes: 8 additions & 4 deletions packages/boba/bundler/src/modules/MempoolManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ export class MempoolManager {
}

private checkReplaceUserOp (oldEntry: MempoolEntry, entry: MempoolEntry): void {
const oldGas = BigNumber.from(oldEntry.userOp.maxPriorityFeePerGas).toNumber()
const newGas = BigNumber.from(entry.userOp.maxPriorityFeePerGas).toNumber()
const oldMaxPriorityFeePerGas = BigNumber.from(oldEntry.userOp.maxPriorityFeePerGas).toNumber()
const newMaxPriorityFeePerGas = BigNumber.from(entry.userOp.maxPriorityFeePerGas).toNumber()
const oldMaxFeePerGas = BigNumber.from(oldEntry.userOp.maxFeePerGas).toNumber()
const newMaxFeePerGas = BigNumber.from(entry.userOp.maxFeePerGas).toNumber()
// the error is "invalid fields", even though it is detected only after validation
requireCond(newGas > oldGas * 1.1,
`Replacement UserOperation must have higher gas (old=${oldGas} new=${newGas}) `, ValidationErrors.InvalidFields)
requireCond(newMaxPriorityFeePerGas >= oldMaxPriorityFeePerGas * 1.1,
`Replacement UserOperation must have higher maxPriorityFeePerGas (old=${oldMaxPriorityFeePerGas} new=${newMaxPriorityFeePerGas}) `, ValidationErrors.InvalidFields)
requireCond(newMaxFeePerGas >= oldMaxFeePerGas * 1.1,
`Replacement UserOperation must have higher maxFeePerGas (old=${oldMaxFeePerGas} new=${newMaxFeePerGas}) `, ValidationErrors.InvalidFields)
}

getSortedForInclusion (): MempoolEntry[] {
Expand Down
2 changes: 1 addition & 1 deletion packages/boba/bundler/src/modules/ReputationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class ReputationManager {
if (entry == null) {
return ReputationStatus.OK
}
const minExpectedIncluded = Math.min(entry.opsSeen / this.params.minInclusionDenominator)
const minExpectedIncluded = Math.floor(entry.opsSeen / this.params.minInclusionDenominator)
if (minExpectedIncluded <= entry.opsIncluded + this.params.throttlingSlack) {
return ReputationStatus.OK
} else if (minExpectedIncluded <= entry.opsIncluded + this.params.banSlack) {
Expand Down
2 changes: 2 additions & 0 deletions packages/boba/bundler/src/parseScannerResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ export function parseScannerResult(
'CREATE',
'COINBASE',
'SELFDESTRUCT',
'RANDOM',
'PREVRANDAO',
])

// eslint-disable-next-line @typescript-eslint/no-base-to-string
Expand Down
10 changes: 5 additions & 5 deletions packages/boba/bundler_sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ An abstract base-class to create UserOperation for a contract wallet.

### SimpleWalletAPI

An implementation of the BaseWalletAPi, for the SimpleWallet sample of account-abstraction.
An implementation of the BaseWalletAPI, for the SimpleWallet sample of account-abstraction.

```typescript
owner = provider.getSigner()
Expand All @@ -28,7 +28,7 @@ const walletAPI = new SimpleWalletAPI({
owner,
factoryAddress
})
const op = await walletAPi.createSignedUserOp({
const op = await walletAPI.createSignedUserOp({
target: recipient.address,
data: recipient.interface.encodeFunctionData('something', ['hello'])
})
Expand All @@ -39,20 +39,20 @@ const op = await walletAPi.createSignedUserOp({
A simplified mode that doesn't require a different wallet extension.
Instead, the current provider's account is used as wallet owner by calling its "Sign Message" operation.

This can only work for wallets that use an EIP-191 ("Ethereum Signed Message") signatures (like our sample SimpleWallet)
This can only work for wallets that use an EIP-191 ("Ethereum Signed Message") signature (like our sample SimpleWallet)
Also, the UX is not great (the user is asked to sign a hash, and even the wallet address is not mentioned, only the signer)

```typescript
import { wrapProvider } from '@bobanetwork/bundler_sdk'

//use this account as wallet-owner (which will be used to sign the requests)
const signer = provider.getSigner()
const aaSigner = provider.getSigner()
const config = {
chainId: await provider.getNetwork().then(net => net.chainId),
entryPointAddress,
bundlerUrl: 'http://localhost:3000/rpc'
}
const aaProvider = await wrapProvider(provider, config, aasigner, entryPointWrapperAddress)
const aaProvider = await wrapProvider(provider, config, aaSigner, entryPointWrapperAddress)
const walletAddress = await aaProvider.getSigner().getAddress()

// send some eth to the wallet Address: wallet should have some balance to pay for its own creation, and for calling methods.
Expand Down
4 changes: 2 additions & 2 deletions packages/boba/bundler_sdk/src/ERC4337EthersProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class ERC4337EthersProvider extends BaseProvider {
this.config.entryPointAddress,
this.chainId
)
const waitPromise = new Promise<TransactionReceipt>((resolve, reject) => {
const waitForUserOp = async (): Promise<TransactionReceipt> => await new Promise((resolve, reject) => {
new UserOperationEventListener(
resolve,
reject,
Expand All @@ -148,7 +148,7 @@ export class ERC4337EthersProvider extends BaseProvider {
data: hexValue(userOp.callData), // should extract the actual called method from this "execFromEntryPoint()" call
chainId: this.chainId,
wait: async (confirmations?: number): Promise<TransactionReceipt> => {
const transactionReceipt = await waitPromise
const transactionReceipt = await waitForUserOp()
if (userOp.initCode.length !== 0) {
// checking if the wallet has been deployed by the transaction; it must be if we are here
await this.smartAccountAPI.checkAccountPhantom()
Expand Down
6 changes: 3 additions & 3 deletions packages/boba/bundler_sdk/src/SimpleAccountAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { BaseApiParams, BaseAccountAPI } from './BaseAccountAPI'
export interface SimpleAccountApiParams extends BaseApiParams {
owner: Signer
factoryAddress?: string
index?: number
index?: BigNumberish

}

Expand All @@ -32,7 +32,7 @@ export interface SimpleAccountApiParams extends BaseApiParams {
export class SimpleAccountAPI extends BaseAccountAPI {
factoryAddress?: string
owner: Signer
index: number
index: BigNumberish

/**
* our account contract.
Expand All @@ -46,7 +46,7 @@ export class SimpleAccountAPI extends BaseAccountAPI {
super(params)
this.factoryAddress = params.factoryAddress
this.owner = params.owner
this.index = params.index ?? 0
this.index = BigNumber.from(params.index ?? 0)
}

async _getAccountContract (): Promise<SimpleAccount> {
Expand Down
1 change: 1 addition & 0 deletions packages/boba/bundler_sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { BaseAccountAPI } from './BaseAccountAPI'
export { SimpleAccountAPI } from './SimpleAccountAPI'
export { PaymasterAPI } from './PaymasterAPI'
export { wrapProvider } from './Provider'
Expand Down
Loading