-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Block Verification Feature #414
base: main
Are you sure you want to change the base?
Changes from all commits
0ba868b
2d62e25
53d0ebb
d86b0eb
9b55f2b
7f8e46e
25d4bb0
9fe7505
f2df2c5
a6a7ddf
f6ca146
e104327
61f2294
c7483f2
ab20ed6
aeb8850
773425d
47efaee
95434d8
8c363e8
606e416
7c3d716
d209718
07f85d6
bd9fb75
863707c
5856d2b
36fcd2d
553985a
eeb977b
f173ed8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import com.hedera.block.server.producer.ProducerBlockItemObserver; | ||
import com.hedera.block.server.producer.ProducerConfig; | ||
import com.hedera.block.server.service.ServiceStatus; | ||
import com.hedera.block.server.verification.StreamVerificationHandlerImpl; | ||
import com.hedera.hapi.block.BlockItemUnparsed; | ||
import com.hedera.hapi.block.PublishStreamRequestUnparsed; | ||
import com.hedera.hapi.block.PublishStreamResponse; | ||
|
@@ -65,6 +66,7 @@ public class PbjBlockStreamServiceProxy implements PbjBlockStreamService { | |
* @param streamMediator the live stream mediator | ||
* @param serviceStatus the service status | ||
* @param streamPersistenceHandler the stream persistence handler | ||
* @param streamVerificationHandler the stream verification handler | ||
* @param notifier the notifier | ||
* @param blockNodeContext the block node context | ||
*/ | ||
|
@@ -73,13 +75,15 @@ public PbjBlockStreamServiceProxy( | |
@NonNull final LiveStreamMediator streamMediator, | ||
@NonNull final ServiceStatus serviceStatus, | ||
@NonNull final BlockNodeEventHandler<ObjectEvent<SubscribeStreamResponseUnparsed>> streamPersistenceHandler, | ||
@NonNull final StreamVerificationHandlerImpl streamVerificationHandler, | ||
@NonNull final Notifier notifier, | ||
@NonNull final BlockNodeContext blockNodeContext) { | ||
this.serviceStatus = serviceStatus; | ||
this.notifier = notifier; | ||
this.blockNodeContext = blockNodeContext; | ||
|
||
streamMediator.subscribe(streamPersistenceHandler); | ||
streamMediator.subscribe(streamVerificationHandler); | ||
this.streamMediator = streamMediator; | ||
Comment on lines
81
to
87
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. we should add null checks here on all lines 81-87 as they are assignment and will be used later, lets fail early here. |
||
} | ||
|
||
|
@@ -119,6 +123,12 @@ public Pipeline<? super Bytes> open( | |
} | ||
} | ||
|
||
/** | ||
* Publishes the block stream. | ||
* | ||
* @param helidonProducerObserver the helidon producer observer | ||
* @return the pipeline | ||
*/ | ||
Pipeline<List<BlockItemUnparsed>> publishBlockStream( | ||
Pipeline<? super PublishStreamResponse> helidonProducerObserver) { | ||
LOGGER.log(DEBUG, "Executing bidirectional publishBlockStream gRPC method"); | ||
|
@@ -153,6 +163,12 @@ Pipeline<List<BlockItemUnparsed>> publishBlockStream( | |
} | ||
} | ||
|
||
/** | ||
* Subscribes to the block stream. | ||
* | ||
* @param subscribeStreamRequest the subscribe stream request | ||
* @param subscribeStreamResponseObserver the subscribe stream response observer | ||
*/ | ||
void subscribeBlockStream( | ||
SubscribeStreamRequest subscribeStreamRequest, | ||
Pipeline<? super SubscribeStreamResponseUnparsed> subscribeStreamResponseObserver) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,11 +173,25 @@ public enum CompressionType { | |
private final int minCompressionLevel; | ||
private final int maxCompressionLevel; | ||
|
||
/** | ||
* Constructs a new instance of {@link CompressionType}. | ||
* | ||
* @param minCompressionLevel the minimum compression level | ||
* @param maxCompressionLevel the maximum compression level | ||
*/ | ||
CompressionType(final int minCompressionLevel, final int maxCompressionLevel) { | ||
this.minCompressionLevel = minCompressionLevel; | ||
this.maxCompressionLevel = maxCompressionLevel; | ||
} | ||
|
||
/** | ||
* This method verifies that the compression level is within the | ||
* acceptable range for the given compression type. | ||
* | ||
* @param levelToCheck the compression level to check | ||
* @throws IllegalArgumentException if the compression level is not within | ||
* the acceptable range | ||
*/ | ||
Comment on lines
+176
to
+194
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. Thanks for the docs! I've missed that :) |
||
public void verifyCompressionLevel(final int levelToCheck) { | ||
Preconditions.requireInRange(levelToCheck, minCompressionLevel, maxCompressionLevel); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,7 @@ | |
/** | ||
* A marker interface that groups all writers that operate on a local file | ||
* system. | ||
* | ||
* @param <V> the type of the value to be written | ||
Comment on lines
+22
to
+23
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. Thanks for the docs again :) |
||
*/ | ||
interface LocalBlockWriter<V> extends BlockWriter<V> {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.block.server.verification; | ||
|
||
/** | ||
* An enum representing the status of block verification. | ||
*/ | ||
public enum BlockVerificationStatus { | ||
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. Should we also add an |
||
/** | ||
* The Block has been verified. | ||
*/ | ||
VERIFIED, | ||
/** | ||
* The Block failed verification, either due to an invalid signature or an invalid hash. | ||
*/ | ||
SIGNATURE_INVALID | ||
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. This implies that it's strictly signature issue, maybe add invalid hash enum or change name to something more ambiguous, as we are not sure at this point what is the root cause ? |
||
} |
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.
Let's stick with the old formatting of the md tables for now. I will make a discussion so that the team will be able to vote on what the formatting should be for the tables so we can all be on the same page.