-
Notifications
You must be signed in to change notification settings - Fork 10
feat(backfill): Backfill Plugin - Part 1 Autonomous Flow #1384
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
Conversation
1772198
to
aa47fe0
Compare
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.
Pull Request Overview
This PR introduces a comprehensive backfill plugin system that enables block nodes to automatically detect and fill gaps in their historical block data by fetching missing blocks from other block nodes in the network. The implementation includes autonomous gap detection, gRPC client infrastructure for inter-node communication, and extends the existing block messaging system to support backfill operations.
- Adds a new backfill plugin module with autonomous gap detection and block fetching capabilities
- Introduces a new
BlockSource
enum andBackfilledBlockNotification
type to distinguish between publisher and backfill operations - Extends existing verification and persistence plugins to handle backfilled blocks appropriately
Reviewed Changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
settings.gradle.kts | Adds backfill module to the build configuration |
block-node/spi/src/main/java/org/hiero/block/node/spi/blockmessaging/* | Introduces BlockSource enum and BackfilledBlockNotification types |
block-node/messaging/src/main/java/* | Updates messaging infrastructure to support backfilled block notifications |
block-node/verification/src/main/java/* | Extends verification plugin to handle backfilled blocks |
block-node/backfill/* | Complete new backfill plugin implementation with gRPC client and configuration |
Comments suppressed due to low confidence (1)
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Outdated
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Outdated
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Outdated
Show resolved
Hide resolved
block-node/spi/src/main/java/org/hiero/block/node/spi/blockmessaging/BlockSource.java
Outdated
Show resolved
Hide resolved
If you're going to experiment with copilot as reviewer, please do so on a separate PR to reduce the noise for everyone else. |
9d50982
to
1212b4b
Compare
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.
Great progress @AlfredoG87!
I leave comments and considerations to help you cleanup. I have only reviewed
/block-node/app and /block-node/backfill as a first pass. No tests reviewed as well.
More reviews to come. 🙌
.../src/testFixtures/java/org/hiero/block/node/app/fixtures/plugintest/SimpleBlockRangeSet.java
Show resolved
Hide resolved
...java/org/hiero/block/node/app/fixtures/plugintest/SimpleInMemoryHistoricalBlockFacility.java
Outdated
Show resolved
Hide resolved
...k-node/app/src/testFixtures/java/org/hiero/block/node/app/fixtures/server/BlockNodeMock.java
Outdated
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeSubscribeClient.java
Outdated
Show resolved
Hide resolved
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.
Made it halfway, good start.
Will circle back for a 2nd pass
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillConfiguration.java
Outdated
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillConfiguration.java
Outdated
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillConfiguration.java
Outdated
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillConfiguration.java
Outdated
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillGrpcClient.java
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillPlugin.java
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillPlugin.java
Outdated
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillPlugin.java
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillPlugin.java
Outdated
Show resolved
Hide resolved
block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillPlugin.java
Outdated
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/proto/block_node_source.proto
Outdated
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/proto/block_node_source.proto
Outdated
Show resolved
Hide resolved
...de/backfill/src/main/java/org/hiero/block/node/backfill/client/proto/block_node_source.proto
Outdated
Show resolved
Hide resolved
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.
Good job @AlfredoG87!
I leave a couple of more comments after going through all the rest of the files.
...oric/src/main/java/org/hiero/block/node/blocks/files/historic/BlocksFilesHistoricPlugin.java
Outdated
Show resolved
Hide resolved
...e/verification/src/main/java/org/hiero/block/node/verification/BlockVerificationSession.java
Outdated
Show resolved
Hide resolved
...e/verification/src/main/java/org/hiero/block/node/verification/BlockVerificationSession.java
Outdated
Show resolved
Hide resolved
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.
Unblocking this to make progress. @AlfredoG87 will address concerns that were captured in follow ups.
Great work!
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.
Unblocking based on offline sync.
Non-functional suggestions will be addressed by @AlfredoG87 in 0.16.
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.
Good work.
A couple items that probably should be addressed here, but pretty much everything could be addressed in follow-up work.
...oric/src/main/java/org/hiero/block/node/blocks/files/historic/BlocksFilesHistoricPlugin.java
Outdated
Show resolved
Hide resolved
...-node/messaging/src/main/java/org/hiero/block/node/messaging/BlockMessagingFacilityImpl.java
Show resolved
Hide resolved
...am-publisher/src/main/java/org/hiero/block/node/stream/publisher/PublisherServicePlugin.java
Outdated
Show resolved
Hide resolved
...k-node/app/src/testFixtures/java/org/hiero/block/node/app/fixtures/server/BlockNodeMock.java
Outdated
Show resolved
Hide resolved
Includes Configuration, module-info.java, gradle project and BlockGap Record. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - proto structure for json file as it is being used by CN and MN: block_node_source.proto - block-nodes.json sources file example on test resources - Added PBJ Compiler plugin and task to generate BlockNodeSources classes Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - Added BlockNode ServerStatus Service Client for fetching the serverStatus method - Added BlockNode Subscribe Service Client for fetching blocks using blockStreamSubscribe method - Added BlockNode Client that re-uses a single webClient within all the service clients. - Added BackfillGrpcClient with retry logic, gap check and Json parse and Backfill gRPC client related logic - needed Helidon dependencies and module-info.java package changes Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - UT skeleton for backfill plugin - Some logic related to gap detection and blocks fetching, still very raw and uncompleted Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - fixed module-info.java Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - stylefix Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - Add new notification type: BackfilledBlockNotification - Refactor BlockNodeSubscribeClient to work with UnparsedBlock Responses instead of parsed. - Other general improvements Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> stylefix Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> Adding a lifetime cycle management to the BackfillGrpcCLient so it can re-use BlockNodeClient classes, optimizing the use of resources throughout the life of the service. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> nit import optimization and logger level change Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - Add BlockSource Enum to distinguish between Verification and Persistence Notifications by source - extend VerificationPlugin & PersistencePlugin to respect BlockSource enum (no breaking changes for publishers). Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - added autonomous loop scheduler - improve metrics and logs - added countdownLatch to wait for last batch to finish processing before starting a new one. - added cooldown period between batches to give system and network time to catch its breath - added persistence and verification block notification handlers to work together with the countdownLatch mechanism Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - added functionality for backfill retries metrics counter - fixed persistence and verification handlers to ignore block notifications that are not originating from backfill itself. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - renamed status to Status, comply with codacy suggestions Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - removed BlockGap in favor of LongRange, in preparations for further improvements also for simplification Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> clean up, simplification and improvement in readability overall housekeeping Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - Some improvements on BackfillPlugin that came up during Happy Path UT - BN Serve Mock on text fixtures to allow the retrival of blocks from another BN on the test. - Optimizations of module-info.java files - Happy Path Unit Test - Added Configuration for initial delay of first task execution. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - fixed UT Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - fixed UT path to relative Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> - added more UTs and fixed retry logic since it was taking too long due to the exponential nature of increasing, so I made it linear. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> adding stop after the test. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> added a third block node mock server for an online but without the needed gap example. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> Added a new UT when not a single block-node is available Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> We only need 1 unavailable BN for this test Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> adding some test coverage to the messaging facility impl changes Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> Copilot code review suggestions Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> Addressed all PR review comments Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> Addressed all PR review comments and some more so CI passes again. Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> some more PR comments addressed around BlockSource not using null but UNKNOWN Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> Configuration improvements Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> improving comment around batch latch Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]> PR review comments improvements Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
618b3c0
to
c6a36a0
Compare
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
...ublisher/src/main/java/org/hiero/block/node/stream/publisher/LiveStreamPublisherManager.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Signed-off-by: Alfredo Gutierrez Grajeda <[email protected]>
Codecov ReportAttention: Patch coverage is ❌ Your patch status has failed because the patch coverage (78.97%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #1384 +/- ##
============================================
- Coverage 79.55% 79.49% -0.07%
- Complexity 964 1022 +58
============================================
Files 114 122 +8
Lines 4383 4804 +421
Branches 461 495 +34
============================================
+ Hits 3487 3819 +332
- Misses 716 782 +66
- Partials 180 203 +23
🚀 New features to boost your workflow:
|
Reviewer Notes
build.gradle.kts
,module-info.java
file,BackfillConfiguraion.java
, initialBackfillPlugin.java
and added toblock-node/app/build.gradle.kts
as a runtimeOnly dependency so it can be picked up by the plugin system.proto
definition to matchblock-node.json
file example from CN and MN, to use same schema and file and wired up the PBJ Compiler for that proto and generate "POJO" ClassesBlockNodeSources
andBlockNodeConfig
that can be used to serialize and deseralize its corresponding json files.backfill plugin
project:block-node.json
build.gradle.kts
file of the backfill plugin.subscribeBlockStream
endpoint to fetch the actual blocks.subscribeBlockStream
API service endpoint. abstracts away receiving the blocks and exposes an intuitive api that based on the request start and end returns a list of the blocks requested.Testing:
SimpleBlockRangeSet
used in Testing Fixtures and UTs, specifically the methodstreamRanges
that was not working as expected.Related Issue(s)
Fixes #1351
Fixes #1352
Fixes #1353
Fixes #1354