-
Notifications
You must be signed in to change notification settings - Fork 6
docs: E2E test plan for BN Verification plugin #908
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
Draft
AlfredoG87
wants to merge
1
commit into
main
Choose a base branch
from
907-verification-test-plan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Verification Test Plan | ||
|
||
## Overview | ||
|
||
Verification is one of the most important functions of a BlockNode, as it is responsible for ensuring the integrity of the blockstream and that the data is correct—as reached by consensus across the network. This document outlines the test plan for the verification module, detailing both positive and negative test cases for the available implementations. | ||
|
||
## Key Considerations | ||
|
||
- **Implementation Variants:** Two implementations exist, SYNC for testing and ASYNC for production. | ||
|
||
- **ASYNC vs. SYNC:** The ASYNC implementation uses a thread pool with a `concurrent` TreeHasher for calculating the block root hash and is approximately 50% faster than the SYNC version, which uses a `naive` TreeHash. | ||
|
||
- **Naive Tree Hasher:** calculates the root hash of the merkle trees in a synchronous manner and using a simple recursive algorithm. | ||
|
||
- **Concurrent Tree Hasher:** calculates the root hash of the merkle trees in an asynchronous manner using a thread pool to parallelize the calculation as the blocks items are received and leafs are appended to the "merkle tree". | ||
|
||
- **Verification Criteria:** A block is verified if the calculated block root hash matches the signature provided in the block_proof. | ||
|
||
- **Acknowledgement Conditions:** The BlockNode sends a BlockAcknowledgement only if the block has been both verified and persisted successfully. | ||
|
||
- **Test Coverage:** End-to-end test scenarios should include both positive and negative cases for both the ASYNC and SYNC implementations. | ||
|
||
## Test Scenarios | ||
|
||
| Test Case ID | Test Name | Scenario Description | Expected Behaviour | Input | Output | Implemented (Y/N) | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note |
||
|--------------|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|---------------------------------------------------------------------------------------------------|-------------------| | ||
| 1 | Positive SYNC Verified | The BlockStream Simulator streams a series of blocks with a valid BlockRootHash and signature. | The BN should return a `PublishStreamResponse` with a `status` of type `EndOfStream` and a `PublishStreamResponseCode` = `STREAM_ITEMS_SUCCESS`. For each block, a corresponding singular `BlockAcknowledgement` field must be provided, containing the expected `block_number`, `block_root_hash`, and `block_already_exists` set to `false`. | A valid blockstream of multiple blocks | Each block has its corresponding BlockAcknowledgement with `block_already_exists`=`false` | Y | | ||
| 2 | Positive ASYNC Verified | The BlockStream Simulator streams a series of blocks using the `ASYNC` implementation with a valid BlockRootHash and signature. | The BN should return a `PublishStreamResponse` with a successful `status` and, for each block, a corresponding singular `BlockAcknowledgement` field matching the block’s details. The responses should indicate successful persistence and verification for streamed all blocks. | A valid blockstream of multiple blocks | Each block has its corresponding BlockAcknowledgement matching the respective block details | Y | | ||
| 3 | Negative SYNC Verification Failure – Invalid BlockRootHash | The simulator streams blocks with an incorrect BlockRootHash that does not match the signed `block_proof`. | The BN should return a `PublishStreamResponse` with `PublishStreamResponseCode=STREAM_ITEMS_BAD_STATE_PROOF` and **no BlockAcknowledgement field** for blocks that fail verification. The error log should capture the mismatch between the calculated block root hash and the provided signature. | Blocks with tampered block root hash | No BlockAcknowledgement field; PublishStreamResponseCode=STREAM_ITEMS_BAD_STATE_PROOF | Y | | ||
| 4 | Negative ASYNC Verification Failure – Tampered Signature | Blocks are streamed with a valid BlockRootHash but with a modified/tampered signature in the `block_proof`. | The BN should return a `PublishStreamResponse` with `PublishStreamResponseCode=STREAM_ITEMS_BAD_STATE_PROOF` and **no BlockAcknowledgement field** for blocks that fail verification. The error log should clearly indicate failure due to signature mismatch, ensuring that tampered blocks are not verified or persisted. | Blocks with altered signatures | No BlockAcknowledgement field; PublishStreamResponseCode=STREAM_ITEMS_BAD_STATE_PROOF | Y | | ||
| 5 | Duplicate Block Handling | The simulator sends a block that has already been verified and persisted, simulating a duplicate entry scenario. | The BN should return a singular `BlockAcknowledgement` field for the duplicate block that includes the expected `block_root_hash` and a flag `block_already_exists` set to `true`, ensuring that duplicate blocks are not re-verified or persisted again. | A blockstream containing duplicate blocks | The duplicate block has its corresponding BlockAcknowledgement with `block_already_exists`=`true` | Y | |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Is it important to note the logic of parallelization here in case it informs testing approach or is that an implementation not necessary?