-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Codecov ReportAttention: Patch coverage is
@@ 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
🚀 New features to boost your workflow:
|
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
Signed-off-by: georgi-l95 <glazarov95@gmail.com>
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.
@georgi-l95 looks good. A couple of general questions.
String[] parts = fullName().split("\\."); | ||
return parts[parts.length - 1]; |
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.
I've seen this in some other places, I think this should become an utility maybe?
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 point, opened a ticket to track this #1158
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.
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.
final long firstAvailableBlock = blockProvider.availableBlocks().min(); | ||
final long lastAvailableBlock = blockProvider.availableBlocks().max(); |
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.
I have a general question. Do we have to think about gaps? Here a hypothetical scenario:
- We have blocks available: 1, 2, 3, 5, 6 ,7
- Min will be 1
- Max will be 7
- 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?
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.
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.
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.
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.
// TODO(#579) Should get from state config or status, which would be provided by the context from responsible | ||
// facility | ||
boolean onlyLatestState = false; |
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.
Question: what is the meaning of this boolean?
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.
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.
assertEquals(0, response.firstAvailableBlock()); | ||
assertEquals(0, response.lastAvailableBlock()); |
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.
0
(zero) is a valid block number? If we test for no blocks available here, should we not expect something else, like -1
?
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.
Ah, thank you for noticing. Should be -1L, yes. I forgot it from some previous testing that I did 👍
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.
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>
import java.util.List; | ||
import org.hiero.block.api.ServerStatusRequest; | ||
import org.hiero.block.api.ServerStatusResponse; | ||
import org.hiero.block.api.protoc.BlockNodeServiceGrpc; |
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.
Perhaps take a quick look at Jasper's update for how to remove the use of protoc here?
// TODO(#1139) Should get construct a block node version object from application config, which would be provided | ||
// by | ||
// the context from responsible facility |
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.
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?
Reviewer Notes
This PR aims to:
ServerStatusRequest
.Left out for next PRs:
only_latest_state
information, for now we just set it to false.Related Issue(s)
Fixes #1111
Fixes #781