Skip to content

Transaction gas sent as number instead of hexa string #262

Description

@thaarok

When running against sepolia.infura.io, I get following error:

failed:  eth_sendUserOperation error: {"message":"Cannot read properties of undefined (reading 'slice')"} TypeError: Cannot read properties of undefined (reading 'slice')
    at decodeRevertReason (/home/jkalina/Fantom/bundler/packages/utils/dist/src/decodeRevertReason.js:23:28)
    at ValidationManager._simulateHandleOps (/home/jkalina/Fantom/bundler/packages/validation-manager/dist/src/ValidationManager.js:159:65)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async ValidationManager.validateUserOp (/home/jkalina/Fantom/bundler/packages/validation-manager/dist/src/ValidationManager.js:314:13)

When I add more logging to get the original error (which it is unable to decode):

Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":64,\"error\":{\"code\":-32602,\"message\":\"invalid argument 0: json: cannot unmarshal non-string into Go struct field TransactionArgs.gas of type hexutil.Uint64\"}}\n", error={"code":-32602}, 
requestBody="{\"method\":\"eth_call\",\"params\":[{\"to\":\"0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108\",\"data\":\"0x...\",\"authorizationList\":null,\"gas\":143155},\"latest\"],\"id\":64,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://sepolia.infura.io/v3/...", code=SERVER_ERROR, version=web/5.7.1)

The issue seems to be in:

gas: sum(prevg, userOp.verificationGasLimit, userOp.paymasterVerificationGasLimit).toNumber()

As specified in geth doc, the gas should be sent as a hexa string:
https://geth.ethereum.org/docs/interacting-with-geth/rpc/objects

When I add the conversion like this:

gas: '0x'+sum(prevg, userOp.verificationGasLimit, userOp.paymasterVerificationGasLimit).toNumber().toString(16)

It solves the issue for me.
Can this be fixed in the upstream? Thanks!

Note:
I have also tried to just use .toHexString() instead of .toNumber(), but it produces a leading zero digit, which is also not accepted by geth/Infura:

\"gas\":\"0x022f33\"
invalid argument 0: json: cannot unmarshal hex number with leading zero digits into Go struct field TransactionArgs.gas of type hexutil.Uint64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions