Skip to content

eth_getBlockByNumber can trigger InvalidCastException #8515

@emlautarom1

Description

@emlautarom1

Description
Invoking the method eth_getBlockByNumber in an OP chain can trigger a InvalidCastException.

Steps to Reproduce

  1. Invoke the method eth_getBlockByNumber(["finalized",true])

Actual behavior
Nethermind produces the following response:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32603,
    "message": "Internal error",
    "data": "System.InvalidCastException: Unable to cast object of type 'Nethermind.Core.TxReceipt' to type 'Nethermind.Optimism.OptimismTxReceipt'.\n   at System.Linq.Enumerable.CastICollectionIterator1.ToArray()\n   at Nethermind.Optimism.Rpc.OptimismEthRpcModule.GetBlock(BlockParameter blockParameter, Boolean returnFullTransactionObjects) in /app/src/Nethermind/Nethermind.Optimism/Rpc/OptimismEthRpcModule.cs:line 252\n   at System.Reflection.MethodInvoker.InvokeImpl(Object obj, Object arg1, Object arg2, Object arg3, Object arg4)\n   at System.Reflection.MethodInvoker.Invoke(Object obj, Span1 arguments)\n   at Nethermind.JsonRpc.JsonRpcService.ExecuteAsync(JsonRpcRequest request, String methodName, ResolvedMethodInfo method, JsonRpcContext context) in /app/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs:line 175"
  },
  "id": 1
}

Expected behavior
Nethermind should not throw an exception and instead return a spec-compliant result.

Desktop (please complete the following information):

  • Operating System: Irrelevant
  • Version: Nethermind v1.31.6
  • Installation Method: Irrelevant
  • Consensus Client: op-node v1.12.2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
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