status-im / nimbus-eth2

Nim implementation of the Ethereum Beacon Chain
https://nimbus.guide
Other
534 stars 231 forks source link

Support for retrieving state by `state_root` #5001

Open wuzhong-zhu opened 1 year ago

wuzhong-zhu commented 1 year ago

We recently encountered an issue with the beacon API when calling /eth/v1/beacon/states/{state_id}/finality_checkpoints. The API returned a 500 error, indicating that it was not implemented.

Upon reviewing the source code located at https://github.com/status-im/nimbus-eth2/blob/c22962f3821d069f86ee38826443f9830931cc7c/beacon_chain/rpc/rest_beacon_api.nim#LL216C27-L216C27, we discovered that the function was not implemented in the source code.

I just want to ask if there is a roadmap for creating this, and if there is an alternate way to check the finality state of a certain block.

zah commented 1 year ago

Nimbus doesn't implement obtaining a BeaconState by its root, because this would require some additional tables to our database that are not otherwise necessary.

Most applications can be adapted to obtain a state by slot number. For example, if you have a BeaconBlock, you can obtain the state corresponding to the same slot and then verify that the latest_block_header field in the state refers to the same block.