-
Notifications
You must be signed in to change notification settings - Fork 107
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
Update documentation to clarify terminology around block verification #6681
Comments
Hey team! Please add your planning poker estimate with Zenhub @arya2 @conradoplg @dconnolly @oxarbitrage @teor2345 @upbqdn |
What do we actually need to do for this issue? |
I think we should finish the missed renames in #6793 first, then add the information in this ticket to the state requests/service/queues/non-finalized state/finalized state. (Wherever each paragraph is most relevant.) |
|
The documentation and variable names in these types and their methods:
Uses:
Some uses are correct, if they are referring to a block that has actually been committed to the state, a queue, a chain, or a state. But most of them need to be manually updated. |
The verification parts of the request, state service, and consensus rule checks use incorrect terms that are very confusing for developers and auditors. The storage parts use those terms correctly and should be left alone. |
@arya2 can you do a quick check of the list in this comment: Feel free to change what we should rename, or what the new names should be. If you think any of these renames can be done automatically, feel free to add them to #6793. But the old names have to be unique enough that there's no mistakes, and the replacement must be universal. |
Motivation
The verification parts of the request, state service, and state consensus rule checks use incorrect terms that are very confusing for developers and auditors.
The storage parts use those terms correctly and should be left alone.
See the comments of this ticket for potential changes.
Background Notes
Here is some of the confusion in this auditor note that we should resolve in our documentation:
Checkpoint vs Finalized
This is the core of the confusion:
zcashd
. This includes settled network upgrades, but it also goes beyond them to include almost all settled blocks.Verified Block Cache Behaviour
All valid finalized blocks are saved to disk, that's what finalization means in Zebra. Saving to disk is not under user control, and it's not a choice the application makes
automaticallydynamically. The only thing that can stop a finalized block being saved to disk is invalid data, which causes a verification failure in the block commitment, authorization, or chain history roots.Non-finalized blocks are saved to disk if they are part of the best chain, and beyond the rollback limit. If they are not part of the best chain and beyond the rollback limit, they are dropped.
User Confusion about Caching
There's also some potential user confusion here between:
We've had multiple requests for Zebra to become a thin client, so it's important for us to avoid confusion in our user documentation.
The
ephemeral
config only controls state cleanup behaviour, it doesn't impact block validation or storage. Regardless of its setting, Zebra still functions correctly as a fully validating node. (It just doesn't have a cache when it next starts up, which is an entirely valid state.)Semanically Verified vs Non-Finalized
To do contextual validation, the state service will:
Breadth-first order is not guaranteed, because a lower height block from another fork can arrive at any time. Forks are allowed from the finalized tip, and any non-finalized block.
The 28 most recent ancestor blocks must have been validated and committed by the state, regardless of whether they are finalized or non-finalized.
This is incorrect, due to the confusion above.
Verification Order
The Zebra implementation chooses to verify blocks using checkpoints or semantic/contextual verification, based on their heights and its checkpoints. Checkpoint verification happens in strict height order, in both
zebra-consensus
andzebra-state
. There is only one chain fork when checkpointing.Semantic verification happens in parallel in the
zebra-consensus
verifiers, but contextual verification happens in chain order inzebra-state
. Each chain fork is verified in height order, different forks can have different tip heights. (Different chain forks could also be contextually verified in parallel, but Zebra doesn't implement that.)Guaranteed Chain Context
So blocks are not validated by the state until all their ancestors have been validated. If a contextually verified block's ancestors aren't validated, it will wait in the queue and timeout, or be rejected with an error when it is received by the block write task. So
validate_and_commit_non_finalized()
won't be called unless a block has at least 28 ancestors, because it is only called during contextual validation. And before contextual validation starts, Zebra commits at least 1 million blocks using checkpoints.No Cross-Module Dependencies
In most cases, the syncer or gossip downloaders will reject blocks that are too far in front of the tip. This prevents CPU and memory denial of service. But peers can't make Zebra panic by submitting blocks out of order, even if they convince these services to submit those blocks by the state. If that happens, the state will timeout or reject the block.
Originally posted by @teor2345 in #6620 (comment)
The text was updated successfully, but these errors were encountered: