filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.85k stars 1.27k forks source link

getBlock return an Error #10909

Closed amncjf closed 1 month ago

amncjf commented 1 year ago

Checklist

Lotus component

Lotus Version

All versions

Repro Steps

  1. curl --data '{"jsonrpc": "2.0", "id":1, "method": "eth_getBlockByNumber", "params": ["0x47C87",true] }' -H 'Content-Type:application/json' https://api.node.glif.io/rpc/v1

Describe the Bug

I in https://api.hyperspace.node.glif.io/rpc/v1 call getBlock (294023) interface, return an Error: Error: requested epoch was a null round, Recommended return: { ...prevBlock, parentHash: prevBlock.hash, blockNumber: prevBlock.blockNumber+1, }

Logging Information

N/A
maciejwitowski commented 1 year ago

Can you elaborate on the benefits of the recommended response?

I'm afraid that returning info about the previous block wouldn't be clear enough for the users so it's better to return explicit error.

amncjf commented 1 year ago

There will be no such errors in Ethereum. Most software and libraries are developed according to this setting, such as ethers, web3js, graph_node..., and they are also used to this setting when calling ethereum rpc. If you follow the current practice of filecoin, these The software needs to be modified. Returning an exception just obviously gives us the information that filecoin is empty. Most of the time we don’t need this information. If we return { ...prevBlock, parentHash: prevBlock.hash, blockNumber: prevBlock. blockNumber+1, } We can also judge whether a block is a filecoin empty block (hash == parentHash) Thanks!

aarshkshah1992 commented 1 month ago

@virajbhartiya

Want to take this one ? Note that this API now supports returning "null" responses if no such block exists and so we should change the signature of the RPC methods accordingly and simply return a "null" value if the requested epoch is a null round.

See https://docs.infura.io/api/networks/ethereum/json-rpc-methods/eth_getblockbynumber and the implementation in go-ethereum.

virajbhartiya commented 1 month ago

@aarshkshah1992 Yes I would like to work on this!