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(rundler): update support for rundler to work with 0.3 #26

Open
wants to merge 1 commit into
base: main
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
5 changes: 3 additions & 2 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
128 changes: 89 additions & 39 deletions src/instances/rundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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).
Expand Down Expand Up @@ -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
}

/**
Expand All @@ -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'
Expand All @@ -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',
Expand All @@ -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 }) {
Expand Down
1 change: 1 addition & 0 deletions src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ describe("instance: 'rundler'", () => {
"id": 0,
"jsonrpc": "2.0",
"result": [
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"0x0000000071727De22E5E9d8BAf0edAc6f37da032",
],
}
Expand Down
20 changes: 12 additions & 8 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { resolve } from 'node:path'
import type { RundlerParameters } from '../src/instances/rundler.js'

export const altoOptions = ({ port }: { port: number }) =>
({
Expand All @@ -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 => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this change I was getting type errors because the as const was making the privateKeys param readonly which doesn't match string[]

nodeHttp: `http://localhost:${port}`,
builder: {
privateKeys: [
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
'0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',
],
},
})

export const siliusOptions = ({ port }: { port: number }) =>
({
Expand Down
Loading