Skip to content

Conversation

@AlfredoG87
Copy link
Contributor

@AlfredoG87 AlfredoG87 commented Dec 20, 2025

Reviewer Notes

  • Now CN version for downloading API Protobuf definition supports Tag name, and not only commit hash.
  • Necessary changes to support HAPI 0.69.0 version of protobuf
  • For StreamingHasher: removed masking of NoSuchAlgorithmException under a RuntimeException, since is on the construction, it should fail under the right exception at the class that is instantiating it, and either force recovery or fail, leaving this decision to the instantiating class.
  • Improving BlockProof Selection condition to only use Tss Based proof by checking hasSignedBlockProof and verifying there is a single one.
  • Changed the Simulator to always produce deterministic blocks, so the rootHashOfAllBlockHashesTree always matches between runs, this is needed for E2E Testing scenarios.
  • S3ArchivePluginTest: Improved Flaky test by giving a tiny bit more time.
  • VerificationSession interface now has 2 methods, a void processBlockItems and a finalizeVerification that returns the VerificationNotification result, making use of the end_of_block message that is now received and not relaying on block_proofs alone. This achieves division of processing and hashing block_items, and requesting a block_proof verification.
  • Verification plugin now calculates the root of all previous block hashes when starting from genesis, loads and writes them to disk so full history node can recover fast from restart, and provides previousBlockHash and rootHashOfAllPreviousBlocks when available and enabled. Otherwise (when not available) Verification will rely on the information provided by the BlockFooter as true.
  • Added UTs for AllBlocksHahserHandler

Related Issue(s)

#1906

@AlfredoG87 AlfredoG87 added this to the 0.26.0 milestone Dec 20, 2025
@AlfredoG87 AlfredoG87 added the Feature Enhancement Enhancing an existing feature driven by business requirements. Typically backwards compatible. label Dec 20, 2025
@AlfredoG87 AlfredoG87 self-assigned this Dec 20, 2025
@AlfredoG87 AlfredoG87 marked this pull request as ready for review December 22, 2025 22:18
@AlfredoG87 AlfredoG87 requested review from a team as code owners December 22, 2025 22:18
Copy link
Contributor

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

Still working through this, but there are a few comments below to start with.

Copy link
Contributor

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

A few small items and an API design concern.

… since is on the construction, it should fail under the right exception at the class that is instantiating it, and either force recovery or fail, leaving this decision to the instantiating class.

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
…by checking hasSignedBlockProof and verifying there is a single one.

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
…ashes when starting from genesis.

- Changed the Simulator to always produce deterministic blocks, so the rootHashOfAllBlockHashesTree always matches between runs, this is needed for E2E Testing scenarios.
- Improved Flaky test by giving a tiny bit more time.
- VerificationSession interface now has 2 methods, a void processBlockItems and a finalizeVerification that returns the VerificationNotification result, making use of the end_of_block message that is now received and not relaying on block_proofs alone.

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
…kStreamingHasher into class: AllBlocksHasherHandler that handles initialization and lifecycle managing.

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
… edge case.

Made needed changes in classes to fix bugs found during testing phase.

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
…d it to used the intermeadiate hashes instead of all the previous hasher to buildd the StreamingHasher, also fixed the StreamingHasherm to accept leafCount to be able to resume correct state from saved snapshot.

Made the saving of the hasher snapshot independent and saving automatically every X amount of time.

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
…Hash and the rootOfAllPreviousBlockHash when is created as opposed to when the block is finalized, also, removed the finalizeBlock method, and rely on the blockItems, so far the BlockItemsMessgae comes with endOfBlock, so it's been used internally and returned to the previous design of the VerificationSession with fewer changes

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
…UnparsedBlockItem, to avoid accidental use

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
- Moved .proto to PBJ Default location /src/main/proto, outside of the java classes

Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 87.41007% with 35 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...lock/node/verification/AllBlocksHasherHandler.java 89.36% 10 Missing and 5 partials ⚠️
...k/node/verification/VerificationServicePlugin.java 76.66% 4 Missing and 3 partials ⚠️
...cation/session/impl/ExtendedMerkleTreeSession.java 71.42% 3 Missing and 3 partials ⚠️
...k/simulator/generator/CraftBlockStreamManager.java 87.23% 6 Missing ⚠️
...ication/session/impl/DummyVerificationSession.java 83.33% 0 Missing and 1 partial ⚠️
@@             Coverage Diff              @@
##               main    #1993      +/-   ##
============================================
+ Coverage     78.99%   79.76%   +0.76%     
- Complexity     1241     1296      +55     
============================================
  Files           130      131       +1     
  Lines          5952     6168     +216     
  Branches        646      664      +18     
============================================
+ Hits           4702     4920     +218     
+ Misses          955      945      -10     
- Partials        295      303       +8     
Files with missing lines Coverage Δ Complexity Δ
...ro/block/node/verification/VerificationConfig.java 100.00% <100.00%> (ø) 1.00 <1.00> (ø)
...erification/session/HapiVersionSessionFactory.java 91.30% <100.00%> (+8.69%) 10.00 <1.00> (+1.00)
...rg/hiero/block/common/hasher/HashingUtilities.java 80.58% <100.00%> (+0.77%) 15.00 <1.00> (ø)
...org/hiero/block/common/hasher/StreamingHasher.java 100.00% <100.00%> (+100.00%) 11.00 <0.00> (+11.00)
...enerator/itemhandler/AbstractBlockItemHandler.java 83.33% <100.00%> (ø) 6.00 <3.00> (ø)
...ator/generator/itemhandler/BlockFooterHandler.java 100.00% <100.00%> (ø) 5.00 <2.00> (+1.00)
...ator/generator/itemhandler/EventHeaderHandler.java 100.00% <100.00%> (ø) 5.00 <0.00> (ø)
...enerator/itemhandler/TransactionResultHandler.java 100.00% <100.00%> (ø) 7.00 <2.00> (ø)
...ication/session/impl/DummyVerificationSession.java 88.88% <83.33%> (+2.22%) 2.00 <1.00> (ø)
...cation/session/impl/ExtendedMerkleTreeSession.java 84.48% <71.42%> (-0.30%) 16.00 <12.00> (+3.00) ⬇️
... and 3 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +17 to +18
@Loggable @ConfigProperty(defaultValue = "/opt/hiero/block-node/verification/rootHashOfAllPreviousBlocks.bin")
Path allBlocksHasherFilePath,
Copy link
Contributor

Choose a reason for hiding this comment

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

We could just collapse this to one line; it's a little long, but not so long that it's a problem (in my opinion).
Not strictly necessary, however.

// footer
Bytes rootOfAllPreviousBlockHashes = rootHashOfAllBlockHashesTree != null
? rootHashOfAllBlockHashesTree
: this.blockFooter.rootHashOfAllBlockHashesTree();
Copy link
Contributor

@jsync-swirlds jsync-swirlds Jan 15, 2026

Choose a reason for hiding this comment

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

nitpick: this. is not necessary here.
More significantly, we should detect if blockFooter is null immediately prior to this line and fail the verification rather than throwing a NPE or continuing the process.

Comment on lines +196 to +205
public static <T> T getSingle(List<T> list, Predicate<T> predicate) {
List<T> filtered = list.stream().filter(predicate).toList();

if (filtered.size() != 1) {
throw new IllegalStateException(String.format(
"Expected exactly 1 element matching predicate [%s], but found %d.", predicate, filtered.size()));
}

return filtered.get(0);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of expensive (particularly for large blocks).
Might be better (particularly as it's only used for block proof) to just take the last item, and if it's not the expected type return null.
For the short term (until we support multiple block proofs, which has to come fairly quickly, possibly as soon as next sprint) that should be sufficient.

Comment on lines +197 to +199
LOGGER.log(TRACE, "Persisting all blocks hasher with {0} leaves snapshot to {1}", new Object[] {
hasher.leafCount(), hasherFilePath
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the new Object[] here?

Suggested change
LOGGER.log(TRACE, "Persisting all blocks hasher with {0} leaves snapshot to {1}", new Object[] {
hasher.leafCount(), hasherFilePath
});
LOGGER.log(TRACE, "Persisting all blocks hasher with {0} leaves snapshot to {1}", hasher.leafCount(), hasherFilePath);

Comment on lines +271 to +272
"Cannot rebuild hasher from store: requires a single contiguous range starting from genesis. "
+ "Found {0} range(s) starting at block {1}. Will fall back to block footer values.",
Copy link
Contributor

Choose a reason for hiding this comment

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

This performs a string catenation every time it's called.
we should replace this with a constant to avoid that.

Suggested change
"Cannot rebuild hasher from store: requires a single contiguous range starting from genesis. "
+ "Found {0} range(s) starting at block {1}. Will fall back to block footer values.",
private final static String HASHER_REQUIRES_CONTINUOUS_RANGE_MESSAGE =
"Cannot rebuild hasher from store: requires a single contiguous range starting from genesis. "
+ "Found {0} range(s) starting at block {1}. Will fall back to block footer values.";

Copy link
Contributor

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

Just a couple items to clean up.
Could be done in a follow-up if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Enhancement Enhancing an existing feature driven by business requirements. Typically backwards compatible.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants