Change ContextuallyVerifiedBlockWithTrees
into an enum to correctly represent verification statuses
#6912
Labels
A-consensus
Area: Consensus rule updates
A-state
Area: State / database changes
C-audit
Category: Issues arising from audit findings
C-bug
Category: This is a bug
C-tech-debt
Category: Code maintainability issues
Motivation
ContextuallyVerifiedBlockWithTrees
actually represents two different types with two different verification statuses. This is a maintainability issue.Design Background
Blocks from the checkpoint verifier are checkpoint-verified: they are semantically verified, but their transaction authorizing data isn't bound to their header.
Blocks from the non-finalized state are contextually verified: their transaction authorizing data is bound to their header. (And their trees have been calculated.)
Complex Code or Requirements
The consensus code is correct, but the names and types we're using could cause bugs during future changes.
Design
The current code is:
zebra/zebra-state/src/request.rs
Lines 277 to 282 in c058f77
The different verification statuses can be represented using an enum:
Here are some example code changes that we could do:
In the match statement in
commit_finalized_direct()
:FinalizableBlock::Checkpoint { checkpoint_verified }
replacesContextuallyVerifiedBlockWithTrees { checkpoint_verified, treestate: None }
FinalizableBlock::Contextual { contextually_verified, treestate }
replacesContextuallyVerifiedBlockWithTrees { checkpoint_verified, treestate: Some(treestate) }
The
Checkpoint
case can construct aContextuallyVerifiedBlockWithTrees
from the checkpoint block and the trees incommit_finalized_direct()
. Then the rest of the finalized state can useContextuallyVerifiedBlockWithTrees
instead of passing separatefinalized, history_tree, note_commitment_trees
arguments.Testing
Our existing tests should cover this change.
Related Work
This is part of:
The text was updated successfully, but these errors were encountered: