pactus-project / pactus

Pactus blockchain
https://pactus.org
MIT License
129 stars 138 forks source link

Pruning on New Block 1:1 #1393

Closed Ja7ad closed 2 months ago

Ja7ad commented 3 months ago

Once a new block is committed, the following operations should be performed:

  1. If the node is a Full Node, no action is needed.
  2. If the node is a Pruned Node, call the PruneBlock function with the block number equal to LastBlockHeight - RetentionBlocks.

This process ensures that for each new block added, one old block will be removed, keeping the store blocks up to the RetentionBlocks number.

https://pips.pactus.org/PIPs/pip-27#pruning-on-new-block

kehiy commented 3 months ago

@b00f @Ja7ad To determine whether a node is a pruned or full node, it's better to pass this information to the store or sync module? Should it be a part of the config? Or check if we have the genesis each time or check once and keep it? I think the best way is to pass it to sync and read it from config.

b00f commented 3 months ago

@kehiy Based on PIP-27 if the genesis block or block number one exists, it is full node.

image

kehiy commented 3 months ago

@b00f OK, I'll add it once #1400 got merged.

kehiy commented 2 months ago

@b00f @Ja7ad If we check prune mode by checking the genesis block, each node will be pruned if it's a new node.

b00f commented 2 months ago

If we check prune mode by checking the genesis block, each node will be pruned if it's a new node.

Good find, check last certificate exists. If not we are at the genesis state.