iotexproject / iotex-core

Official implementation of IoTeX blockchain protocol in Go. An ultra-efficient EVM blockchain offering 1000 TPS with instant 1-block finality. Perfect for DeFi, DePIN tokenomics, Identities, and any trusted logic requiring Web3 composability
https://iotex.io
Apache License 2.0
1.55k stars 324 forks source link

Implement HeaderByHeight in filedao #4229

Open Liuhaai opened 5 months ago

Liuhaai commented 5 months ago

What would you like to be added

HeaderByHeight, which to be implemented in filedao_v2, should be used instead of GetBlockByHeight in https://github.com/iotexproject/iotex-core/blob/1791f82354c672631690e7b759de6bb51cb2a031/blockchain/filedao/filedao.go#L235

// Before 
blk, err := v2.GetBlockByHeight(height)
// After 
header, err := v2.HeaderByHeight(height)

Why is this needed

Some queries can be optmized by HeaderByHeight

How important you think this is for IoTeX

Additional information

Let us know any background or context that would help us better understand the request (for example the particular use-case that prompted this request)

millken commented 5 months ago

Currently HeaderByHeight still needs to deseralize the entire block, the cost is the same as GetBlockByHeight.

Liuhaai commented 5 months ago

Currently HeaderByHeight still needs to deseralize the entire block, the cost is the same as GetBlockByHeight.

I see no HeaderByHeight is implemented in filedao_v2. Could you give a snippet why should the whole block be deseralized?