Adjust for optional totalDifficulty in JSON-RPC BlockObject#3883
Adjust for optional totalDifficulty in JSON-RPC BlockObject#3883
Conversation
execution_chain/rpc/rpc_utils.nim
Outdated
| defer: | ||
| txFrame.dispose() | ||
|
|
||
| txFrame.getScore(blockHash) |
There was a problem hiding this comment.
I want to note that, ideally here getScore returns a None in case the block referenced is post-merge.
However from reading the code it would seem that is not the case (but it was probably the long term plan).
One could assume that getScore here would return failure if block post merge:
But this comment indicates that the score is still stored also for each post merge block:
nimbus-eth1/execution_chain/db/core_db/core_apps.nim
Lines 606 to 613 in 08efe95
I have not tested this yet but I would assume that it will still find a score.
execution_chain/rpc/rpc_utils.nim
Outdated
| return res | ||
|
|
||
| proc getTotalDifficulty*(chain: ForkedChainRef, blockHash: Hash32): Opt[UInt256] = | ||
| let txFrame = chain.txFrame(blockHash).txFrameBegin() |
There was a problem hiding this comment.
Using txFrame here for the fork-aware view, even though this value is not needed for current forks (post merge forks). I assumed it was useful also when using it for uncle blocks (pre-merge). But after looking into the code it is not. I will adjust to the baseTxFrame version.
There was a problem hiding this comment.
@bhartnett I think it is not needed to do the txFrame version as you have added here: https://github.com/status-im/nimbus-eth1/blob/bal-devnet-0/execution_chain/rpc/debug.nim#L119-L122
As this value is not supposed to change anymore. (and ideally does not get set post merge, but ok)
There was a problem hiding this comment.
@kdeme Good point. In that case should it just always return zero?
8124197 to
1e1bc62
Compare
|
I will go ahead and merge this version as it is an improvement:
|
Going for optionally
totalDifficultyinstead of removal.See reasoning in discussion here: #3882 (comment)
Depends on status-im/nim-web3#233