Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify checkpoint creation and pruning, take 2 #3369

Closed

Conversation

HeinrichApfelmus
Copy link
Contributor

Issue number

ADP-1497

Overview

In this pull request, we consolidate and simplify the creation and pruning of checkpoints.

Specifically, we introduce a function extendAndPrune that computes a delta which

  • adds new checkpoints
  • prunes the existing checkpoints

based on their block height.

⚠️ Unfortunately, making checkpoints based on their block height works well for "node-mode", but not for "light-mode", as we do not access all block heights in sequence. The solution is to add a CheckpointPolicy field to the ChainFollower data type, so that the chain following logic can drive the creation of checkpoints according to the policy. This will be added in another pull request, which needs to be merged before this one. (But I only understood this after clicking the button… 🤷, hence this draft.)

Details

  • The sparseArithmetic is modeled on the previous checkpointing policy, but it is not equal to it. Specifically, when synchronizing the chain far away from the tip, at most two checkpoints are kept: genesis and the latest synchronization point. We only keep multiple checkpoints when we are within epochStability of the tip, as we expect rollbacks only then.

Comments

… and encapsulate checkpoint creation and pruning logic completely in `Cardano.Wallet.Checkpoints`.
… using a `CheckpointPolicy`
iohk-bors bot added a commit that referenced this pull request Jul 1, 2022
3372: Add `checkpointPolicy` field to `ChainFollower` r=HeinrichApfelmus a=HeinrichApfelmus

### Issue number

ADP-1497

### Overview

In this pull request, we add a `checkpointPolicy` field to the `ChainFollower` type.

This policy enables any chain synchronizer which does *not* retrieve full blocks — such as `lightSync` — to target those block heights at which the follower makes checkpoints.

ℹ️  This pull request only changes the `ChainFollower` type — incorporating this new information into the `lightSync` algorithm is left for a future pull request.

### Details

* We also add a `defaultPolicy` to `Cardano.Wallet.Checkpoints` in order to reduce cognitive burden in the places where a `ChainFollower` is constructed.

### Comments

* It would be better to adjust the `lightSync` algorithm before merging #3369 — otherwise, no good checkpoints will be created in light-mode. That said, light-mode may be so fast that it can work without checkpoints.

Co-authored-by: Heinrich Apfelmus <[email protected]>
@HeinrichApfelmus HeinrichApfelmus self-assigned this Aug 24, 2022
@HeinrichApfelmus
Copy link
Contributor Author

Closed in favor of #3988

@HeinrichApfelmus HeinrichApfelmus deleted the HeinrichApfelmus/ADP-1043/extendAndPrune branch June 7, 2023 16:00
iohk-bors bot added a commit that referenced this pull request Jun 12, 2023
3988: [ADP-3031] Simplify checkpoint pruning, take 3 r=HeinrichApfelmus a=HeinrichApfelmus

### Overview


In this pull request, we consolidate and simplify the creation and pruning of checkpoints.

Specifically, we introduce a function `extendAndPrune` that computes a delta which

* adds new checkpoints
* prunes the existing checkpoints

based on their block height.

### Details

* The mechanism for creating checkpoints has changed. Specifically, when synchronizing the chain far away from the `tip`, at most two checkpoints are kept: genesis and the latest synchronization point. We only keep multiple checkpoints when we are within `epochStability` of the tip, as we expect rollbacks only then.
* The `CheckpointPolicy` is tested in the existing module `Cardano.Wallet.Checkpoints.PolicySpec`.

### Comments

* This task evolved out of ADP-1497. Previous attempts to implement this are
    * #3159
    * #3369 

### Issue Number

ADP-3031

Co-authored-by: Heinrich Apfelmus <[email protected]>
iohk-bors bot added a commit that referenced this pull request Jun 16, 2023
3988: [ADP-3031] Simplify checkpoint pruning, take 3 r=HeinrichApfelmus a=HeinrichApfelmus

### Overview


In this pull request, we consolidate and simplify the creation and pruning of checkpoints.

Specifically, we introduce a function `extendAndPrune` that computes a delta which

* adds new checkpoints
* prunes the existing checkpoints

based on their block height.

### Details

* The mechanism for creating checkpoints has changed. Specifically, when synchronizing the chain far away from the `tip`, at most two checkpoints are kept: genesis and the latest synchronization point. We only keep multiple checkpoints when we are within `epochStability` of the tip, as we expect rollbacks only then.
* The `CheckpointPolicy` is tested in the existing module `Cardano.Wallet.Checkpoints.PolicySpec`.

### Comments

* This task evolved out of ADP-1497. Previous attempts to implement this are
    * #3159
    * #3369 

### Issue Number

ADP-3031

Co-authored-by: Heinrich Apfelmus <[email protected]>
iohk-bors bot added a commit that referenced this pull request Jun 16, 2023
3988: [ADP-3031] Simplify checkpoint pruning, take 3 r=HeinrichApfelmus a=HeinrichApfelmus

### Overview


In this pull request, we consolidate and simplify the creation and pruning of checkpoints.

Specifically, we introduce a function `extendAndPrune` that computes a delta which

* adds new checkpoints
* prunes the existing checkpoints

based on their block height.

### Details

* The mechanism for creating checkpoints has changed. Specifically, when synchronizing the chain far away from the `tip`, at most two checkpoints are kept: genesis and the latest synchronization point. We only keep multiple checkpoints when we are within `epochStability` of the tip, as we expect rollbacks only then.
* The `CheckpointPolicy` is tested in the existing module `Cardano.Wallet.Checkpoints.PolicySpec`.

### Comments

* This task evolved out of ADP-1497. Previous attempts to implement this are
    * #3159
    * #3369 

### Issue Number

ADP-3031

Co-authored-by: Heinrich Apfelmus <[email protected]>
iohk-bors bot added a commit that referenced this pull request Jun 16, 2023
3988: [ADP-3031] Simplify checkpoint pruning, take 3 r=HeinrichApfelmus a=HeinrichApfelmus

### Overview


In this pull request, we consolidate and simplify the creation and pruning of checkpoints.

Specifically, we introduce a function `extendAndPrune` that computes a delta which

* adds new checkpoints
* prunes the existing checkpoints

based on their block height.

### Details

* The mechanism for creating checkpoints has changed. Specifically, when synchronizing the chain far away from the `tip`, at most two checkpoints are kept: genesis and the latest synchronization point. We only keep multiple checkpoints when we are within `epochStability` of the tip, as we expect rollbacks only then.
* The `CheckpointPolicy` is tested in the existing module `Cardano.Wallet.Checkpoints.PolicySpec`.

### Comments

* This task evolved out of ADP-1497. Previous attempts to implement this are
    * #3159
    * #3369 

### Issue Number

ADP-3031

Co-authored-by: Heinrich Apfelmus <[email protected]>
iohk-bors bot added a commit that referenced this pull request Jun 16, 2023
3988: [ADP-3031] Simplify checkpoint pruning, take 3 r=HeinrichApfelmus a=HeinrichApfelmus

### Overview


In this pull request, we consolidate and simplify the creation and pruning of checkpoints.

Specifically, we introduce a function `extendAndPrune` that computes a delta which

* adds new checkpoints
* prunes the existing checkpoints

based on their block height.

### Details

* The mechanism for creating checkpoints has changed. Specifically, when synchronizing the chain far away from the `tip`, at most two checkpoints are kept: genesis and the latest synchronization point. We only keep multiple checkpoints when we are within `epochStability` of the tip, as we expect rollbacks only then.
* The `CheckpointPolicy` is tested in the existing module `Cardano.Wallet.Checkpoints.PolicySpec`.

### Comments

* This task evolved out of ADP-1497. Previous attempts to implement this are
    * #3159
    * #3369 

### Issue Number

ADP-3031

Co-authored-by: Heinrich Apfelmus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant