From 55cf349a3859c7c5a758480f8b3b48c093709e80 Mon Sep 17 00:00:00 2001 From: moldy Date: Thu, 25 Jul 2024 11:33:27 -0400 Subject: [PATCH] feat(rundler): update support for rundler to work with 0.3 --- src/README.md | 5 +- src/instances/rundler.ts | 128 +++++++++++++++++++++++++++------------ src/server.test.ts | 1 + test/utils.ts | 20 +++--- 4 files changed, 105 insertions(+), 49 deletions(-) diff --git a/src/README.md b/src/README.md index 0678505..91ea4a3 100644 --- a/src/README.md +++ b/src/README.md @@ -153,7 +153,8 @@ See [`AltoParameters`](https://github.com/wevm/prool/blob/801ede06ded8b2cb2d59c9 #### Requirements - [Rundler](https://github.com/alchemyplatform/rundler) binary installed - - [Download](https://github.com/alchemyplatform/rundler/releases) + - [Download v0.3.x](https://github.com/alchemyplatform/rundler/releases/tag/v0.3.0) + - Add to `PATH` #### Usage @@ -187,7 +188,7 @@ await bundlerServer.start() #### Parameters -See [RundlerParameters](). +See [RundlerParameters](https://github.com/wevm/prool/blob/main/src/instances/rundler.ts#L7). ### Silius (Bundler Node) diff --git a/src/instances/rundler.ts b/src/instances/rundler.ts index b9ddf1e..aac1b5a 100644 --- a/src/instances/rundler.ts +++ b/src/instances/rundler.ts @@ -12,13 +12,6 @@ export type RundlerParameters = { */ binary?: string - /** - * The version of the entrypoint to use - * - * @default 0.6.0 - */ - entryPointVersion?: '0.6.0' | '0.7.0' - /** * Network to look up a hardcoded chain spec. * @default dev @@ -30,6 +23,13 @@ export type RundlerParameters = { */ chainSpec?: string + /** + * Allows overriding the chain id for a given chain spec + * + * @default unset + */ + chainId?: number | undefined + /** * EVM Node HTTP URL to use. * @@ -90,7 +90,10 @@ export type RundlerParameters = { * Possible values are base_fee_percent and priority_fee_increase_percent. * @default priority_fee_increase_percent */ - priorityFeeModeKind?: 'base_fee_percent' | 'priority_fee_increase_percent' + priorityFeeModeKind?: + | 'base_fee_percent' + | 'priority_fee_increase_percent' + | undefined /** * Priority fee mode value. @@ -129,6 +132,31 @@ export type RundlerParameters = { */ mempoolConfigPath?: string + /** + * Disables entry point version v0.6. + * @default false + */ + disableEntryPointV0_6?: boolean + + /** + * The number of builder accounts to use for entry point version v0.6. + * + * @default 1 + */ + numBuildersV0_6?: number + + /** + * Disables entry point version v0.7. + * @default false + */ + disableEntryPointV0_7?: boolean + + /** + * The number of builder accounts to use for entry point version v0.7. + * @default 1 + */ + numBuildersV0_7?: number + metrics?: { /** * Port to listen on for metrics requests. @@ -261,18 +289,20 @@ export type RundlerParameters = { builder?: { /** - * Private key to use for signing transactions. + * Private keys to use for signing transactions. * If used with awsKmsKeyIds, then explicitly pass in `null` here. * - * @default 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 + * @default ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80','0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d'] */ - privateKey?: string + privateKeys?: string[] /** - * AWS KMS key IDs to use for signing transactions (comma-separated). - * Only required if privateKey is not provided. + * AWS KMS key IDs to use for signing transactions. + * Only required if privateKeys is not provided. + * + * @default null */ - awsKmsKeyIds?: string + awsKmsKeyIds?: string[] /** * Redis URI to use for KMS leasing. @@ -304,9 +334,21 @@ export type RundlerParameters = { /** * Choice of what sender type to use for transaction submission. * @default raw - * options: raw, conditional, flashbots, polygon_bloxroute + * options: raw, flashbots, polygon_bloxroute + */ + sender?: 'raw' | 'flashbots' | 'polygonBloxroute' | undefined + + /** + * Use the submit URL for transaction status checks. + * @default false + */ + useSubmitForStatus?: boolean | undefined + + /** + * If the sender supports the 'dropped' status. Many senders do not support this status, and only support 'pending' or 'mined'. + * @default false */ - sender?: 'raw' | 'conditional' | 'flashbots' | 'polygonBloxroute' + droppedStatusUnsupported?: boolean | undefined /** * After submitting a bundle transaction, the maximum number of blocks to wait for that transaction to mine before trying to resend with higher gas fees. @@ -321,11 +363,16 @@ export type RundlerParameters = { replacementFeePercentIncrease?: number /** - * Maximum number of fee increases to attempt. - * Seven increases of 10% is roughly 2x the initial fees. - * @default 7 + * Maximum number of fee increases to attempt during a cancellation. + * @default 15 */ - maxFeeIncreases?: number + maxCancellationFeeIncreases?: number | undefined + + /** + * The maximum number of blocks to spend in a replacement underpriced state before issuing a transaction cancellation. + * @default 20 + */ + maxReplacementUnderpricedBlocks?: number | undefined /** * Additional builders to send bundles to through the Flashbots relay RPC (comma-separated). @@ -353,6 +400,13 @@ export type RundlerParameters = { */ indexOffset?: number } + + /** + * Log level for the Rundler binary. + * + * @default "debug" + */ + logLevel?: 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'off' | undefined } /** @@ -370,8 +424,12 @@ export type RundlerParameters = { * ``` */ export const rundler = defineInstance((parameters?: RundlerParameters) => { - const { binary = 'rundler', ...args } = (parameters ?? - {}) as RundlerParameters + const { + binary = 'rundler', + logLevel = 'debug', + chainId, + ...args + } = (parameters ?? {}) as RundlerParameters const host = '127.0.0.1' const name = 'rundler' @@ -392,11 +450,11 @@ export const rundler = defineInstance((parameters?: RundlerParameters) => { ...args, builder: { ...args.builder, - privateKey: - args.builder?.privateKey ?? + privateKeys: args.builder?.privateKeys ?? [ '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', + '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d', + ], }, - entryPointVersion: undefined, maxVerificationGas: args.maxVerificationGas ?? 10000000, network: args.network ?? 'dev', nodeHttp: args.nodeHttp ?? 'http://localhost:8545', @@ -413,23 +471,15 @@ export const rundler = defineInstance((parameters?: RundlerParameters) => { args.userOperationEventBlockDistance ?? 100, } satisfies RundlerParameters - const entrypointArgs = (() => { - if (args.entryPointVersion === '0.6.0') - return ['--disable_entry_point_v0_7'] - return ['--disable_entry_point_v0_6'] - })() - return await process.start( ($) => - $( - binary, - ['node', ...toArgs(args_, { casing: 'snake' }), ...entrypointArgs], - { - env: { - RUST_LOG: 'debug', - }, + $(binary, ['node', ...toArgs(args_, { casing: 'snake' })], { + env: { + RUST_LOG: logLevel, + // CHAIN_* overrides for a chain spec can only be set via env vars + ...(chainId != null ? { CHAIN_ID: chainId.toString() } : {}), }, - ), + }), { ...options, resolver({ process, reject, resolve }) { diff --git a/src/server.test.ts b/src/server.test.ts index c603cad..6389320 100644 --- a/src/server.test.ts +++ b/src/server.test.ts @@ -466,6 +466,7 @@ describe("instance: 'rundler'", () => { "id": 0, "jsonrpc": "2.0", "result": [ + "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "0x0000000071727De22E5E9d8BAf0edAc6f37da032", ], } diff --git a/test/utils.ts b/test/utils.ts index d8c2f9e..d5c305e 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -1,4 +1,5 @@ import { resolve } from 'node:path' +import type { RundlerParameters } from '../src/instances/rundler.js' export const altoOptions = ({ port }: { port: number }) => ({ @@ -9,14 +10,17 @@ export const altoOptions = ({ port }: { port: number }) => ], }) as const -export const rundlerOptions = ({ port }: { port: number }) => - ({ - nodeHttp: `http://localhost:${port}`, - builder: { - privateKey: - '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', - }, - }) as const +export const rundlerOptions = ({ + port, +}: { port: number }): RundlerParameters => ({ + nodeHttp: `http://localhost:${port}`, + builder: { + privateKeys: [ + '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', + '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d', + ], + }, +}) export const siliusOptions = ({ port }: { port: number }) => ({