kaiachain / kaia

GNU Lesser General Public License v3.0
21 stars 27 forks source link

kaiax/staking: Implement Preload feature #114

Closed blukat29 closed 1 month ago

blukat29 commented 1 month ago

Proposed changes

The SideState feature has two usages.

Types of changes

Please put an x in the boxes related to your change.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Related issues

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

blukat29 commented 1 month ago

@hyeonLewis PTAL. Without this PR, the CreateSnapshot at node startup might break.

blukat29 commented 1 month ago

@hyeonLewis I thought the Preload feature may be inaccurate because it stores StakingInfo keyed by block numbers. When there is a bad block then block rewind, the block state may differ on the same number. In the process of moving from number-keyed to roothash-keyed, I got to store the state. But on a second thought, while I will keep the roothash-key, but resource-wise it's better to store the StakingInfo than the whole StateDB.

blukat29 commented 1 month ago

@hyeonLewis Modified to store pre-calculated StakingInfo instead and tests pass. Let me polish it and fix the "can't be released" issues.