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

fix blocktag not supported for gnosis #254

Merged
merged 6 commits into from
Jun 17, 2024
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
2 changes: 1 addition & 1 deletion src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const rpcArgsSchema = z.object({
"send-transaction-rpc-url": z.string().url().optional(),
"polling-interval": z.number().int().min(0),
"max-block-range": z.number().int().min(0).optional(),
"block-tag-support-disabled": z.boolean().optional().default(false)
"block-tag-support": z.boolean().optional().default(true)
})

export const bundleCopmressionArgsSchema = z.object({
Expand Down
4 changes: 2 additions & 2 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ export const rpcOptions: CliCommandOptions<IRpcArgsInput> = {
type: "number",
require: false
},
"block-tag-support-disabled": {
"block-tag-support": {
description:
"Disable sending block tag when sending eth_estimateGas call",
type: "boolean",
require: false,
default: false
default: true
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/cli/setupServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const getValidator = ({
metrics,
gasPriceManager,
parsedArgs["chain-type"],
parsedArgs["block-tag-support"],
parsedArgs["entrypoint-simulation-contract"],
parsedArgs["fixed-gas-limit-for-estimation"],
parsedArgs.tenderly,
Expand All @@ -93,6 +94,7 @@ const getValidator = ({
metrics,
gasPriceManager,
parsedArgs["chain-type"],
parsedArgs["block-tag-support"],
parsedArgs["entrypoint-simulation-contract"],
parsedArgs["fixed-gas-limit-for-estimation"],
parsedArgs.tenderly,
Expand Down Expand Up @@ -203,7 +205,7 @@ const getExecutor = ({
!parsedArgs.tenderly,
parsedArgs["legacy-transactions"],
parsedArgs["fixed-gas-limit-for-estimation"],
parsedArgs["block-tag-support-disabled"],
parsedArgs["block-tag-support"],
parsedArgs["local-gas-limit-calculation"]
)
}
Expand Down Expand Up @@ -273,7 +275,8 @@ const getNonceQueuer = ({
parsedArgs["nonce-queuer-log-level"] ||
parsedArgs["log-level"]
}
)
),
parsedArgs["block-tag-support"]
)
}

Expand Down
12 changes: 6 additions & 6 deletions src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class Executor {
reputationManager: InterfaceReputationManager
compressionHandler: CompressionHandler | null
gasPriceManager: GasPriceManager
disableBlockTagSupport: boolean
blockTagSupport: boolean
mutex: Mutex

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

this.mutex = new Mutex()
Expand Down Expand Up @@ -266,7 +266,7 @@ export class Executor {
newRequest.nonce,
newRequest.maxFeePerGas,
newRequest.maxPriorityFeePerGas,
this.disableBlockTagSupport ? undefined : "latest",
this.blockTagSupport ? "latest" : undefined,
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
Expand Down Expand Up @@ -577,7 +577,7 @@ export class Executor {
nonce,
gasPriceParameters.maxFeePerGas,
gasPriceParameters.maxPriorityFeePerGas,
this.disableBlockTagSupport ? undefined : "pending",
this.blockTagSupport ? "pending" : undefined,
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
Expand Down Expand Up @@ -872,7 +872,7 @@ export class Executor {
nonce,
gasPriceParameters.maxFeePerGas,
gasPriceParameters.maxPriorityFeePerGas,
this.disableBlockTagSupport ? undefined : "pending",
this.blockTagSupport ? "pending" : undefined,
this.legacyTransactions,
this.fixedGasLimitForEstimation,
this.reputationManager,
Expand Down
15 changes: 11 additions & 4 deletions src/rpc/EntryPointSimulationsV07.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ async function callPimlicoEntryPointSimulations(
entryPoint: Address,
entryPointSimulationsCallData: Hex[],
entryPointSimulationsAddress: Address,
blockTagSupport: boolean,
stateOverride?: StateOverrides
) {
const callData = encodeFunctionData({
Expand All @@ -261,9 +262,11 @@ async function callPimlicoEntryPointSimulations(
to: entryPointSimulationsAddress,
data: callData
},
"latest",
blockTagSupport
? "latest"
: toHex(await publicClient.getBlockNumber()),
// @ts-ignore
stateOverride
...(stateOverride ? [stateOverride] : [])
]
})) as Hex

Expand All @@ -283,6 +286,7 @@ export async function simulateHandleOp(
targetAddress: Address,
targetCallData: Hex,
entryPointSimulationsAddress: Address,
blockTagSupport: boolean,
stateOverride: StateOverrides = {}
) {
const finalParam = getStateOverrides({
Expand Down Expand Up @@ -314,6 +318,7 @@ export async function simulateHandleOp(
entryPointSimulationsSimulateTargetCallData
],
entryPointSimulationsAddress,
blockTagSupport,
finalParam
)

Expand Down Expand Up @@ -513,7 +518,8 @@ export async function simulateValidation(
queuedUserOperations: UserOperationV07[],
entryPoint: Address,
publicClient: PublicClient,
entryPointSimulationsAddress: Address
entryPointSimulationsAddress: Address,
blockTagSupport: boolean
) {
const userOperations = [...queuedUserOperations, userOperation]
const packedUserOperations = userOperations.map((uo) =>
Expand All @@ -530,7 +536,8 @@ export async function simulateValidation(
publicClient,
entryPoint,
[entryPointSimulationsCallData],
entryPointSimulationsAddress
entryPointSimulationsAddress,
blockTagSupport
)

return {
Expand Down
15 changes: 13 additions & 2 deletions src/rpc/gasEstimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export async function simulateHandleOpV06(
publicClient: PublicClient,
targetAddress: Address,
targetCallData: Hex,
blockTagSupport: boolean,
finalParam: StateOverrides | undefined = undefined,
fixedGasLimitForEstimation?: bigint
): Promise<SimulateHandleOpResult> {
Expand All @@ -100,7 +101,9 @@ export async function simulateHandleOpV06(
gas: `0x${fixedGasLimitForEstimation.toString(16)}`
})
},
"latest",
blockTagSupport
? "latest"
: toHex(await publicClient.getBlockNumber()),
// @ts-ignore
...(finalParam ? [finalParam] : [])
]
Expand Down Expand Up @@ -199,6 +202,7 @@ async function callPimlicoEntryPointSimulations(
entryPoint: Address,
entryPointSimulationsCallData: Hex[],
entryPointSimulationsAddress: Address,
blockTagSupport: boolean,
stateOverride?: StateOverrides,
fixedGasLimitForEstimation?: bigint
) {
Expand All @@ -218,7 +222,9 @@ async function callPimlicoEntryPointSimulations(
gas: `0x${fixedGasLimitForEstimation.toString(16)}`
})
},
"latest",
blockTagSupport
? "latest"
: toHex(await publicClient.getBlockNumber()),
// @ts-ignore
...(stateOverride ? [stateOverride] : [])
]
Expand Down Expand Up @@ -387,6 +393,7 @@ export async function simulateHandleOpV07(
publicClient: PublicClient,
entryPointSimulationsAddress: Address,
chainId: number,
blockTagSupport: boolean,
finalParam: StateOverrides | undefined = undefined,
fixedGasLimitForEstimation?: bigint
): Promise<SimulateHandleOpResult> {
Expand Down Expand Up @@ -522,6 +529,7 @@ export async function simulateHandleOpV07(
entryPointSimulationsSimulateTargetCallData
],
entryPointSimulationsAddress,
blockTagSupport,
finalParam,
fixedGasLimitForEstimation
)
Expand Down Expand Up @@ -582,6 +590,7 @@ export function simulateHandleOp(
targetCallData: Hex,
balanceOverrideEnabled: boolean,
chainId: number,
blockTagSupport: boolean,
stateOverride: StateOverrides = {},
entryPointSimulationsAddress?: Address,
fixedGasLimitForEstimation?: bigint
Expand All @@ -604,6 +613,7 @@ export function simulateHandleOp(
publicClient,
targetAddress,
targetCallData,
blockTagSupport,
finalStateOverride,
// Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet
chainId === 2040 || chainId === 78600
Expand All @@ -626,6 +636,7 @@ export function simulateHandleOp(
publicClient,
entryPointSimulationsAddress,
chainId,
blockTagSupport,
finalStateOverride,
// Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet
chainId === 2040 || chainId === 78600
Expand Down
7 changes: 5 additions & 2 deletions src/rpc/nonceQueuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ export class NonceQueuer {
mempool: MemoryMempool
publicClient: PublicClient<Transport, Chain>
logger: Logger
blockTagSupport: boolean

constructor(
mempool: MemoryMempool,
publicClient: PublicClient<Transport, Chain>,
logger: Logger
logger: Logger,
blockTagSupport: boolean
) {
this.mempool = mempool
this.publicClient = publicClient
this.logger = logger
this.blockTagSupport = blockTagSupport

setInterval(() => {
this.process()
Expand Down Expand Up @@ -143,7 +146,7 @@ export class NonceQueuer {
args: [userOperation.sender, qop.nonceKey]
}
}),
blockTag: "latest"
blockTag: this.blockTagSupport ? "latest" : undefined
})
} catch (error) {
this.logger.error(
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/validation/SafeValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class SafeValidator
metrics: Metrics,
gasPriceManager: GasPriceManager,
chainType: ChainType,
blockTagSupport: boolean,
entryPointSimulationsAddress?: Address,
fixedGasLimitForEstimation?: bigint,
usingTenderly = false,
Expand All @@ -79,6 +80,7 @@ export class SafeValidator
metrics,
gasPriceManager,
chainType,
blockTagSupport,
entryPointSimulationsAddress,
fixedGasLimitForEstimation,
usingTenderly,
Expand Down
10 changes: 8 additions & 2 deletions src/rpc/validation/UnsafeValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ export class UnsafeValidator implements InterfaceValidator {
entryPointSimulationsAddress?: Address
fixedGasLimitForEstimation?: bigint
chainType: ChainType
blockTagSupport: boolean

constructor(
publicClient: PublicClient<Transport, Chain>,
logger: Logger,
metrics: Metrics,
gasPriceManager: GasPriceManager,
chainType: ChainType,
blockTagSupport: boolean,
entryPointSimulationsAddress?: Address,
fixedGasLimitForEstimation?: bigint,
usingTenderly = false,
Expand All @@ -89,6 +91,7 @@ export class UnsafeValidator implements InterfaceValidator {
this.entryPointSimulationsAddress = entryPointSimulationsAddress
this.fixedGasLimitForEstimation = fixedGasLimitForEstimation
this.chainType = chainType
this.blockTagSupport = blockTagSupport
}

async getSimulationResult(
Expand Down Expand Up @@ -186,6 +189,7 @@ export class UnsafeValidator implements InterfaceValidator {
"0x",
this.balanceOverrideEnabled,
this.chainId,
this.blockTagSupport,
stateOverrides,
this.entryPointSimulationsAddress,
this.fixedGasLimitForEstimation
Expand Down Expand Up @@ -233,7 +237,8 @@ export class UnsafeValidator implements InterfaceValidator {
entryPoint,
this.publicClient,
zeroAddress,
"0x"
"0x",
this.blockTagSupport
)

const [simulateValidationResult, runtimeValidation] = await Promise.all(
Expand Down Expand Up @@ -387,7 +392,8 @@ export class UnsafeValidator implements InterfaceValidator {
queuedUserOperations,
entryPoint,
this.publicClient,
this.entryPointSimulationsAddress
this.entryPointSimulationsAddress,
this.blockTagSupport
)

if (simulateValidationResult.status === "failed") {
Expand Down
Loading