optimism icon indicating copy to clipboard operation
optimism copied to clipboard

`eth_getBlockByNumber` returns the L1 block, not the L2 one.

Open qbzzt opened this issue 2 years ago • 4 comments

Describe the bug

When using the PRC API, retrieval of mainnet block 0x58D5D5 gives the expected result, the transaction: https://optimistic.etherscan.io/tx/5821909

However retrieval of the supposedly identical 0x58d5d5 gives us the Ethereum block: https://etherscan.io/block/5821909

To Reproduce

  1. For the transaction on Optimism

    curl -H 'Content-Type: application/json' 'https://mainnet.optimism.io' -d '{"id": 1, "jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x58D5D5", true]}' | jq .result.transactions
    
  2. For the block on Ethereum:

    curl -H 'Content-Type: application/json' 'https://mainnet.optimism.io' -d '{"id": 1, "jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["0x58d5d5", true]}' | jq .result.transactions   
    

Expected behavior

When I contact https://mainnet.optimism.io I expect to always get the Optimism chain.

Additional context

Discovered by rick from KuCoin, available on Telegram.

qbzzt avatar Apr 16 '22 20:04 qbzzt

Fixed by clearing the cache.. Working on a root cause separately.

mslipper avatar Apr 17 '22 11:04 mslipper

To add more clarity, I am seeing the inverse behavior as well on a certain block. Reproduced the issue on block 0x5C4E6F where the endpoint is retrieving block on Ethereum. 0x5c4e6f retrieves L2 Block

Same Command to Reproduce:

curl --location --request POST 'https://mainnet.optimism.io' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc": "2.0", "method": "eth_getBlockByNumber", "id": 1, "params": ["0x5C4E6F", true] }'

tarunkhasnavis avatar Apr 21 '22 22:04 tarunkhasnavis

Likely that an upstream provider is returning bad results and these results are being cached by our proxy.

smartcontracts avatar Apr 22 '22 14:04 smartcontracts

@mslipper issue fixed, correct?

annieke avatar May 02 '22 16:05 annieke

Believed to be fixed, this was an issue with an upstream node provider. Please reopen this issue if anyone detects similar caching problems.

smartcontracts avatar Sep 06 '22 17:09 smartcontracts