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

On-demand calculation for Ghostdag for Higher Levels #494

Open
wants to merge 67 commits into
base: master
Choose a base branch
from

Conversation

coderofstuff
Copy link
Collaborator

@coderofstuff coderofstuff commented Jun 22, 2024

Introduction

Currently, for each block that we process header processor will calculate ghostdag for all levels. This preprocessing allows for the faster calculation of the pruning proof during pruning but imposes a significant overhead for the processing of each block. It is far better to defer this higher level GD calculation for when it's actually needed - during pruning proof building.

Main Changes

  • During header processing, calculate only the ghostdag for the header at level 0 (primary ghostdag). So instead of calculating for 255 levels, we only calculate for the one.
  • Calculate the ghostdag for when it's needed (when build_pruning_proof is called):
    • during initial IBD
    • during pruning point movement
  • Introduces 2 new prefixes:
    • TempGhostdag
    • TempGhostdagCompact
  • Includes upgrade logic from version 3 to 4 that doesn't require a DB reset
    • Deletes all higher level GD records which are no longer necessary given that these will be calculated on-demand

Not included

  • minimization of proof size

@coderofstuff coderofstuff changed the base branch from master to dev June 22, 2024 01:04
Copy link
Contributor

@someone235 someone235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be a blocker for merge, but it would be nice if each function will have a comment with a bit of explanation, because it can be hard to get the guiding logic for the whole process if you're not familiar with it

consensus/src/consensus/services.rs Outdated Show resolved Hide resolved
consensus/src/pipeline/header_processor/processor.rs Outdated Show resolved Hide resolved
consensus/src/pipeline/pruning_processor/processor.rs Outdated Show resolved Hide resolved
consensus/src/pipeline/pruning_processor/processor.rs Outdated Show resolved Hide resolved
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
consensus/src/processes/ghostdag/ordering.rs Outdated Show resolved Hide resolved
coderofstuff and others added 24 commits June 25, 2024 18:56
Co-authored-by: Ori Newman <[email protected]>
Co-authored-by: Ori Newman <[email protected]>
Co-authored-by: Ori Newman <[email protected]>
apply_proof only inserts parent entries for a header from the proof into
the relations store for a level if there was GD data in the old stores
for that header.

This adds a check to filter out parent records not in relations store
…cient root

This happens when there's not enough headers in the pruning proof but it satisfies validation
relations.get_parents on GD gets extra parents that aren't in the
current GD store. so get_blue_work throws an error

next, ORIGIN was mising from the GD so add that
The new prefixes added are compatible with the old version. We don't want to trigger a db delete with this change
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
consensus/src/processes/pruning_proof/mod.rs Outdated Show resolved Hide resolved
@michaelsutton michaelsutton deleted the branch kaspanet:master September 11, 2024 18:34
@michaelsutton michaelsutton reopened this Sep 11, 2024
@michaelsutton michaelsutton changed the base branch from dev to master September 11, 2024 18:42
Copy link
Contributor

@michaelsutton michaelsutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial pass -- minor details out of core changes

consensus/src/pipeline/header_processor/processor.rs Outdated Show resolved Hide resolved
consensus/src/pipeline/header_processor/processor.rs Outdated Show resolved Hide resolved
consensus/src/pipeline/header_processor/processor.rs Outdated Show resolved Hide resolved
consensus/src/processes/ghostdag/protocol.rs Outdated Show resolved Hide resolved
consensus/src/processes/ghostdag/protocol.rs Outdated Show resolved Hide resolved
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.

3 participants