unit-e icon indicating copy to clipboard operation
unit-e copied to clipboard

Re-calculate stake modifier on startup, instead of storing it in the block index on disk

Open scravy opened this issue 6 years ago • 0 comments

For proposing we need the stake modifier which depends on the stake modifier and kernel of the previous block (and so on). Currently we store it in the block index, but we should have it in memory like the nChainWork/chain-stake.

This is favorable over storing it in the block index as that particular field is a uint256 and contributes a significant amount of space to the blockindex. Even with fast sync we still have the blockindex (but not all the content of the blocks) so this would not prevent it and the block index is supposed to be kept small.

Currently, as a means to get us started, we are saving it in the block index, but we should go back to calculating it.

Another reason to not have it in the block index is that for most parts of the chain we do not need it at all as that will be covered by snapshot/fast sync. I.e. when you start a new node you do not have to recalculate that value but you look it up from the latest snapshot and calculate from there.

The snapshot has been augmented with this functionality already in #446

When dealing with this field properly we should also rename it to chain_stake.

scravy avatar Feb 01 '19 17:02 scravy