Skip to content

feat: create server status plugin #1137

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

georgi-l95
Copy link
Member

@georgi-l95 georgi-l95 commented May 13, 2025

Reviewer Notes

This PR aims to:

  • Create new plugin responsible for opening a unary endpoint for serving ServerStatusRequest.
  • Handling of this requests is responsibility of the plugin, which returns:
message ServerStatusResponse {
    uint64 first_available_block = 1;
    uint64 last_available_block = 2;
    bool only_latest_state = 3;
    BlockNodeVersions version_information = 4;
}
  • Add unit tests validating the correct behavior, using already existing test fixtures.
  • Add E2E tests validating the behaviour of the endpoint.

Left out for next PRs:

  • Handling of only_latest_state information, for now we just set it to false.
  • Handling the construction of BlockNodeVersions object. We currently does not have this information at hand. Will require some change in order to be availble across the project.

Related Issue(s)

Fixes #1111
Fixes #781

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
@georgi-l95 georgi-l95 added this to the 0.11.0 milestone May 13, 2025
@georgi-l95 georgi-l95 self-assigned this May 13, 2025
@georgi-l95 georgi-l95 added New Feature A new feature, service, or documentation. Major changes that are not backwards compatible. Server Status Plugin Issue related to Server Status Plugin labels May 13, 2025
@georgi-l95 georgi-l95 linked an issue May 13, 2025 that may be closed by this pull request
Copy link

codecov bot commented May 13, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../node/server/status/ServerStatusServicePlugin.java 88.88% 4 Missing ⚠️
@@             Coverage Diff              @@
##               main    #1137      +/-   ##
============================================
+ Coverage     84.86%   84.90%   +0.03%     
- Complexity      916      921       +5     
============================================
  Files           104      105       +1     
  Lines          3719     3755      +36     
  Branches        396      396              
============================================
+ Hits           3156     3188      +32     
- Misses          411      415       +4     
  Partials        152      152              
Files with missing lines Coverage Δ Complexity Δ
.../node/server/status/ServerStatusServicePlugin.java 88.88% <88.88%> (ø) 5.00 <5.00> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Copy link
Contributor

@ata-nas ata-nas left a comment

Choose a reason for hiding this comment

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

@georgi-l95 looks good. A couple of general questions.

Comment on lines +103 to +104
String[] parts = fullName().split("\\.");
return parts[parts.length - 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen this in some other places, I think this should become an utility maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, opened a ticket to track this #1158

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we'd follow the pattern in the stream subscriber plugin and only calculate the value once when the class is first loaded; storing it in a static constant.

Comment on lines +48 to +49
final long firstAvailableBlock = blockProvider.availableBlocks().min();
final long lastAvailableBlock = blockProvider.availableBlocks().max();
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a general question. Do we have to think about gaps? Here a hypothetical scenario:

  1. We have blocks available: 1, 2, 3, 5, 6 ,7
  2. Min will be 1
  3. Max will be 7
  4. If we query for 4 however, we will not see it

Should we generally extend these requests to return ranges in some form which then could be parsed?
This is something for the future, I was wondering if this is relevant in general?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I think it's a valid consideration; however, this endpoint wouldn't care. I mean, the StatusServer query only aims to provide information about what should be available in the block-node. If something is missing, it's the responsibility of another plugin. There's currently an issue related to filling gaps—generally, if we say we have data between 0 and 7, then we should have it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Gaps are the responsibility of the backfill plugin (to be developed). The status service is intended to provide the edges (earliest and latest); not every detail.

That said, nothing prevents us from adding an extension in the future if there is demand.

Comment on lines +51 to +53
// TODO(#579) Should get from state config or status, which would be provided by the context from responsible
// facility
boolean onlyLatestState = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: what is the meaning of this boolean?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is indicating whether this block node offers the latest state snapshot. However we don't have state implemented currently, so it's irrelevant. If we don't set it, it will automatically be false. I left it here for visibility with the TODO comment.

Comment on lines +77 to +78
assertEquals(0, response.firstAvailableBlock());
assertEquals(0, response.lastAvailableBlock());
Copy link
Contributor

Choose a reason for hiding this comment

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

0 (zero) is a valid block number? If we test for no blocks available here, should we not expect something else, like -1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, thank you for noticing. Should be -1L, yes. I forgot it from some previous testing that I did 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally -1 represents "the highest possible block number" (because we prefer to use unsigned values in the protobuf, which are bitwise transliterated with Java long) and is presented to (non-java) API clients as uint64_max.

We use -1L in Java code because we should never reach that high of a block number (at least, not for an hundred billion years or so).

Signed-off-by: georgi-l95 <glazarov95@gmail.com>
@georgi-l95 georgi-l95 marked this pull request as ready for review May 16, 2025 13:43
@georgi-l95 georgi-l95 requested review from a team as code owners May 16, 2025 13:43
@georgi-l95 georgi-l95 requested a review from jasperpotts May 16, 2025 13:43
@jsync-swirlds jsync-swirlds requested a review from AlfredoG87 May 16, 2025 17:04
import java.util.List;
import org.hiero.block.api.ServerStatusRequest;
import org.hiero.block.api.ServerStatusResponse;
import org.hiero.block.api.protoc.BlockNodeServiceGrpc;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps take a quick look at Jasper's update for how to remove the use of protoc here?

Comment on lines +54 to +56
// TODO(#1139) Should get construct a block node version object from application config, which would be provided
// by
// the context from responsible facility
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this plugin is the responsible facility.
The server status is the only place block node version is used, and should probably be filled in by the build from version.txt.

I don't think that becomes config so much as the build can insert the value into the code (as it's always constant for a given build output). That might require some build changes, however, so perhaps it would make sense to have it in config at least temporarily. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature A new feature, service, or documentation. Major changes that are not backwards compatible. Server Status Plugin Issue related to Server Status Plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Server Status Plugin External Test Suites
3 participants