Implement block hash for Filecoin #433
ychiaoli18
started this conversation in
Enhancements - Technical
Replies: 1 comment
-
Hi @ychiaoli18! It seems like you have two discussion posts open on this same topic (as linked above). #422 seems to be the primary post; can you explain why you opened a second post? Ideally, all information for a single proposal will live in a single thread. Let me know if we can close this thread! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
This discussion talks about our plan to implement an Ethereum-style JSON-RPC interface for Filecoin. However, Filecoin and Ethereum use different consensus models. Filecoin uses expected consensus that involves tipsets, while Ethereum uses the PoW with a chain of blocks. Therefore if we want to implement the Ethereum-style JSON-RPC, we need a way to map tipsets to a chain of blocks.
The proposed approach is to treat a tipset as a block for Ethereum-style JSON-RPC calls, so if a Filecoin node receives an Ethereum-style JSON-RPC call to retrieve a block's header (such as
eth_getBlockByNumber
oreth_getBlockByHash
), the node should return the header of the tipset. For native Filecoin API calls, we should treat blocks and tipsets in the same way as we do now to ensure backward compatibility.Block Numbers
Ethereum indexes blocks with block numbers, and Ethereum's JSON-RPC API provides
eth_getBlockByNumber
method to get the block's header by using its block number. Since there's only one tipset at each height in Filecoin, we can use the tipset's height as its block number.Block Hash
Ethereum indexes blocks with block hashes as well. For Ethereum, a block hash is a Keccak 256-bit hash of the parent block’s header. The proposed approach for FEVM is to concatenate all the CIDs of a tipset, and take the Keccak 256-bit hash of it.
For efficiency, Lotus can maintain two indexes that map block numbers to tipsets and map block hashes to tipsets in the ChainStore.
Beta Was this translation helpful? Give feedback.
All reactions