harmony-one / harmony

The core protocol of harmony
https://harmony.one
GNU Lesser General Public License v3.0
1.46k stars 286 forks source link

Do not save validator wrapper state data for every block in archival node #3843

Open rlan35 opened 3 years ago

rlan35 commented 3 years ago

Summary and Current Design

The archival node is meant to be saving all state data for all history blocks so that you can query state from a history block. Currently, our archival node saves all state data for validator state changes (due to block reward on every block). This causes huge storage burden for archival nodes because for each block, the modified validator data are stored again. The reason is that currently validator data are stored as a single data structure and any single change such as block reward change, will cause the whole validator data structure (ValidatorWrapper) to change, which causes the storage of a new copy of the data in the state db.

Proposal

Modify the archival node state storage logic so that the validator wrapper data are excluded from the storage for every block. This way, the archival node won't waste the db space for storing mostly identical data (except the block reward part).

Related codes

validator wrapper data structure: https://github.com/harmony-one/harmony/blob/main/staking/types/validator.go#L89 logic about state commitment on new blocks: https://github.com/harmony-one/harmony/blob/main/core/blockchain.go#L1171

lcgogo commented 3 years ago

when will the code release? my explorer node now has 12TB !!! even more than the ETH archive node.

./harmony --run=explorer --run.shard=0

Should I need resync or the new version will decrease the useless data automaticlly?

AlexiaChen commented 3 years ago

Hey @lcgogo Need to wait, this improved PR is being tested, the specific release time need to consult @rlan35

lcgogo commented 3 years ago

Hey @lcgogo Need to wait, this improved PR is being tested, the specific release time need to consult @rlan35

Hi Alexia, is this PR included in the latest 4.2.1 ?

sophoah commented 2 years ago

@lcgogo it is not

lcgogo commented 2 years ago

@lcgogo it is not

Does 4.3.0 contain this PR?

lcgogo commented 2 years ago

@lcgogo it is not

Does 4.3.0 contain this PR?

@rlan35 @AlexiaChen @sophoah

AlexiaChen commented 2 years ago

@lcgogo it is not

Does 4.3.0 contain this PR?

@rlan35 @AlexiaChen @sophoah

Hey @lcgogo FYI: https://github.com/harmony-one/harmony/pull/3844#issuecomment-956829146 you can ask @rlan35 @sophoah to get more information.

lcgogo commented 2 years ago

@lcgogo it is not

Does 4.3.0 contain this PR?

@rlan35 @AlexiaChen @sophoah

Hey @lcgogo FYI: #3844 (comment) you can ask @rlan35 @sophoah to get more information.

@AlexiaChen many thanks. Should I resync my archive node to reduce the data size?

AlexiaChen commented 2 years ago

@lcgogo it is not

Does 4.3.0 contain this PR?

@rlan35 @AlexiaChen @sophoah

Hey @lcgogo FYI: #3844 (comment) you can ask @rlan35 @sophoah to get more information.

@AlexiaChen many thanks. Should I resync my archive node to reduce the data size?

you can try. or you can confirm with @rlan35 . I do not know more detail or progress about this issue. :)

AlexiaChen commented 2 years ago

@lcgogo

Here are related PRs you can check, seems not merged into master:

its all about state pruning

lcgogo commented 2 years ago

Thanks, will watch that PR to merge