Skip to content

Commit

Permalink
Merge pull request #244 from pimlicolabs/block-tag-env
Browse files Browse the repository at this point in the history
add blocktag support env variable
  • Loading branch information
plusminushalf authored Jun 9, 2024
2 parents 66f784d + 5c7ef25 commit a46575f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
Expand Down
3 changes: 2 additions & 1 deletion src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export const rpcArgsSchema = z.object({
"rpc-url": z.string().url(),
"send-transaction-rpc-url": z.string().url().optional(),
"polling-interval": z.number().int().min(0),
"max-block-range": z.number().int().min(0).optional()
"max-block-range": z.number().int().min(0).optional(),
"block-tag-support-disabled": z.boolean().optional().default(false)
})

export const bundleCopmressionArgsSchema = z.object({
Expand Down
7 changes: 7 additions & 0 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ export const rpcOptions: CliCommandOptions<IRpcArgsInput> = {
description: "Max block range for getLogs calls",
type: "number",
require: false
},
"block-tag-support-disabled": {
description:
"Disable sending block tag when sending eth_estimateGas call",
type: "boolean",
require: false,
default: false
}
}

Expand Down
1 change: 1 addition & 0 deletions src/cli/setupServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const getExecutor = ({
!parsedArgs.tenderly,
parsedArgs["legacy-transactions"],
parsedArgs["fixed-gas-limit-for-estimation"],
parsedArgs["block-tag-support-disabled"],
parsedArgs["local-gas-limit-calculation"]
)
}
Expand Down
9 changes: 6 additions & 3 deletions src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export class Executor {
reputationManager: InterfaceReputationManager
compressionHandler: CompressionHandler | null
gasPriceManager: GasPriceManager
disableBlockTagSupport: boolean
mutex: Mutex

constructor(
Expand All @@ -131,6 +132,7 @@ export class Executor {
simulateTransaction = false,
legacyTransactions = false,
fixedGasLimitForEstimation?: bigint,
disableBlockTagSupport = false,
localGasLimitCalculation = false
) {
this.publicClient = publicClient
Expand All @@ -145,6 +147,7 @@ export class Executor {
this.localGasLimitCalculation = localGasLimitCalculation
this.compressionHandler = compressionHandler
this.gasPriceManager = gasPriceManager
this.disableBlockTagSupport = disableBlockTagSupport
this.entryPoints = entryPoints

this.mutex = new Mutex()
Expand Down Expand Up @@ -263,7 +266,7 @@ export class Executor {
newRequest.nonce,
newRequest.maxFeePerGas,
newRequest.maxPriorityFeePerGas,
"latest",
this.disableBlockTagSupport ? undefined : "latest",
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
Expand Down Expand Up @@ -574,7 +577,7 @@ export class Executor {
nonce,
gasPriceParameters.maxFeePerGas,
gasPriceParameters.maxPriorityFeePerGas,
"pending",
this.disableBlockTagSupport ? undefined : "pending",
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
Expand Down Expand Up @@ -854,7 +857,7 @@ export class Executor {
nonce,
gasPriceParameters.maxFeePerGas,
gasPriceParameters.maxPriorityFeePerGas,
"pending",
this.disableBlockTagSupport ? undefined : "pending",
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
Expand Down
10 changes: 5 additions & 5 deletions src/executor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function filterOpsAndEstimateGas(
nonce: number,
maxFeePerGas: bigint,
maxPriorityFeePerGas: bigint,
blockTag: "latest" | "pending",
blockTag: "latest" | "pending" | undefined,
onlyPre1559: boolean,
fixedGasLimitForEstimation: bigint | undefined,
reputationManager: InterfaceReputationManager,
Expand Down Expand Up @@ -176,7 +176,7 @@ export async function filterOpsAndEstimateGas(
{
account: wallet,
nonce: nonce,
blockTag,
blockTag: blockTag,
...(fixedGasLimitForEstimation !== undefined && {
gas: fixedGasLimitForEstimation
}),
Expand All @@ -200,14 +200,14 @@ export async function filterOpsAndEstimateGas(
data: createCompressedCalldata(opsToSend, perOpInflatorId),
gas: fixedGasLimitForEstimation,
nonce: nonce,
blockTag,
blockTag: blockTag,
...gasOptions
})
}

return { simulatedOps, gasLimit, resubmitAllOps: false }
} catch (err: unknown) {
logger.error({ err }, "error estimating gas")
logger.error({ err, blockTag }, "error estimating gas")
const e = parseViemError(err)

if (e instanceof ContractFunctionRevertedError) {
Expand Down Expand Up @@ -345,7 +345,7 @@ export async function filterOpsAndEstimateGas(
} else {
sentry.captureException(err)
logger.error(
{ error: JSON.stringify(err) },
{ error: JSON.stringify(err), blockTag },
"error estimating gas"
)
return { simulatedOps: [], gasLimit: 0n, resubmitAllOps: false }
Expand Down

0 comments on commit a46575f

Please sign in to comment.