Skip to content

Commit

Permalink
First working iteration, just make the hash valid :)
Browse files Browse the repository at this point in the history
Next steps: Add metrics to measure time to hash.

Signed-off-by: Alfredo Gutierrez <[email protected]>

initial metrics dashboard and observations

Signed-off-by: Alfredo Gutierrez <[email protected]>

some simplifications and moving around code, also more logs for tests added. and temporary stuff.

Signed-off-by: Alfredo Gutierrez <[email protected]>

Some more improvements and moving things to async model. however I think I will create several implementations to the interfaces with some simple and synchronous and another one concurrent and asynchronous.

Signed-off-by: Alfredo Gutierrez <[email protected]>

clean-up halfway.

Signed-off-by: Alfredo Gutierrez <[email protected]>

major refactor, clean-up 80%

Signed-off-by: Alfredo Gutierrez <[email protected]>

added NoOp implementation for the VerificationService

Signed-off-by: Alfredo Gutierrez <[email protected]>

added javadoc to BlockVerificationService interface

Signed-off-by: Alfredo Gutierrez <[email protected]>

some more javadocs

Signed-off-by: Alfredo Gutierrez <[email protected]>

adding some extra exception handling.

Signed-off-by: Alfredo Gutierrez <[email protected]>

cleanup

Signed-off-by: Alfredo Gutierrez <[email protected]>

cleanup

Signed-off-by: Alfredo Gutierrez <[email protected]>

Fixing Existing Unit tests and removing an addition (requires org.checkerframework.checker.qual;) on module-info by accident

Signed-off-by: Alfredo Gutierrez <[email protected]>

Unit test for StreamingTreeHasher and BlockVerificationService and some refactor around BlockVerificationService

Signed-off-by: Alfredo Gutierrez <[email protected]>

VerificationInjectionModuleTest Unit test and spotless improvements

Signed-off-by: Alfredo Gutierrez <[email protected]>

More unit tests

Signed-off-by: Alfredo Gutierrez <[email protected]>

More unit tests, for BlockVerificationSessionSync

Signed-off-by: Alfredo Gutierrez <[email protected]>

More unit tests, for BlockVerificationSessionSync

Signed-off-by: Alfredo Gutierrez <[email protected]>

Adding UT Coverage for BlockVerificationSession related classes.
Small improvements in other tests as well.
Improvements to the flow of finalizeVerification thanks to issues surfaced during unit testing

Signed-off-by: Alfredo Gutierrez <[email protected]>

restoring original simulator properties file

Signed-off-by: Alfredo Gutierrez <[email protected]>

improvements on performance for ASYNC

Signed-off-by: Alfredo Gutierrez <[email protected]>

improvements for the dashboard and the config class so it logs the actual/final configuration values

Signed-off-by: Alfredo Gutierrez <[email protected]>

Added env mappings for new verification config properties

Signed-off-by: Alfredo Gutierrez <[email protected]>

Added some missing javadocs

Signed-off-by: Alfredo Gutierrez <[email protected]>

adding env config properties documentation

Signed-off-by: Alfredo Gutierrez <[email protected]>

Added remaining javadocs across the whole project

Signed-off-by: Alfredo Gutierrez <[email protected]>

style fixes

Signed-off-by: Alfredo Gutierrez <[email protected]>

convert sha384HashTag to final

Signed-off-by: Alfredo Gutierrez <[email protected]>

some extra tests and dashboard improvement, also update the dashboard on the chart deployment

Signed-off-by: Alfredo Gutierrez <[email protected]>

remove extension

Signed-off-by: Alfredo Gutierrez <[email protected]>

style fixes

Signed-off-by: Alfredo Gutierrez <[email protected]>

changing VerificationResult for SIGNATURE_INVALID a more descriptive one. instead of something more ambiguous why not something more explicit.

Signed-off-by: Alfredo Gutierrez <[email protected]>

added missing return statement

Signed-off-by: Alfredo Gutierrez <[email protected]>

adding Objects.requireNonNull checks, not sure if is really needed and not just redundant. in any case, improvement on existing class

Signed-off-by: Alfredo Gutierrez <[email protected]>

adding Objects.requireNonNull checks, not sure if is really needed and not just redundant. in any case, improvement on existing class

Signed-off-by: Alfredo Gutierrez <[email protected]>

removed ExecutorService CommonPool fulfiller for all executor requests on DI, and provided it only for the current verification session factory.

Signed-off-by: Alfredo Gutierrez <[email protected]>

fixing test after

Signed-off-by: Alfredo Gutierrez <[email protected]>

Refactor VerificationConfig to use Preconditions class to handle verifications, and also used MathUtilities to handle the actual verification.

Signed-off-by: Alfredo Gutierrez <[email protected]>

fixing test

Signed-off-by: Alfredo Gutierrez <[email protected]>

using long instead of Long

Signed-off-by: Alfredo Gutierrez <[email protected]>

PR Review changes

Signed-off-by: Alfredo Gutierrez <[email protected]>

PR Review changes

Signed-off-by: Alfredo Gutierrez <[email protected]>

style fix

Signed-off-by: Alfredo Gutierrez <[email protected]>

add Objects.requireNonNull on constructor

Signed-off-by: Alfredo Gutierrez <[email protected]>

Adding missing NonNull

Signed-off-by: Alfredo Gutierrez <[email protected]>

returning to how it was

Signed-off-by: Alfredo Gutierrez <[email protected]>

Simplifying Constructor logic

Signed-off-by: Alfredo Gutierrez <[email protected]>

Feedback and spotless updating the licence

Signed-off-by: Alfredo Gutierrez <[email protected]>

addressing more feedback from PR Review

Signed-off-by: Alfredo Gutierrez <[email protected]>

Improving and defining a log format.

Signed-off-by: Alfredo Gutierrez <[email protected]>

setting the logging.properties as part of the java args so it gets picked up before anything is logged.

Signed-off-by: Alfredo Gutierrez <[email protected]>

mapping the logging.properties file to the docker-compose stack, so is easy to change the properties once the container is created by changing the file on build/docker and restart the container.

Signed-off-by: Alfredo Gutierrez <[email protected]>

removed no longer needed field

Signed-off-by: Alfredo Gutierrez <[email protected]>

changing to the way it can be overriden using env variables

Signed-off-by: Alfredo Gutierrez <[email protected]>

adding non null to dummy class dependencies

Signed-off-by: Alfredo Gutierrez <[email protected]>

spotless apply changes

Signed-off-by: Alfredo Gutierrez <[email protected]>

add a missing @nonnull

Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Jan 7, 2025
1 parent 287adeb commit c11b4a6
Show file tree
Hide file tree
Showing 59 changed files with 8,396 additions and 3,529 deletions.
4,433 changes: 2,699 additions & 1,734 deletions charts/hedera-block-node/dashboards/block-node-server.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 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.
Expand Down Expand Up @@ -34,5 +34,15 @@ public static boolean isPowerOfTwo(final int toCheck) {
return (0 < toCheck) && ((toCheck & (toCheck - 1)) == 0);
}

/**
* This method checks if the given number is even.
*
* @param toCheck the number to check if it is even
* @return {@code true} if the given number is even
*/
public static boolean isEven(final int toCheck) {
return (toCheck % 2) == 0;
}

private MathUtilities() {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 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.
Expand Down Expand Up @@ -30,6 +30,7 @@ public final class Preconditions {
"The input number [%d] is required to be a whole number.";
private static final String DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE =
"The input number [%d] is required to be a power of two.";
private static final String DEFAULT_REQUIRE_IS_EVEN = "The input number [%d] is required to be even.";

/**
* This method asserts a given {@link String} is not blank.
Expand Down Expand Up @@ -282,5 +283,31 @@ public static int requirePowerOfTwo(final int toCheck, @NonNull final String err
}
}

/**
* This method asserts a given integer is even.
*
* @param toCheck the number to check if it is even
* @return the number to check if it is even
* @throws IllegalArgumentException if the input number to check is not even
*/
public static int requireEven(final int toCheck, @NonNull final String errorMessage) {
if (!MathUtilities.isEven(toCheck)) {
throw new IllegalArgumentException(errorMessage.formatted(toCheck));
} else {
return toCheck;
}
}

/**
* This method asserts a given integer is even.
* Uses default error message DEFAULT_REQUIRE_IS_EVEN if the check fails.
*
* @param toCheck the number to check if it is even
* @return the number to check if it is even
*/
public static int requireEven(final int toCheck) {
return requireEven(toCheck, DEFAULT_REQUIRE_IS_EVEN);
}

private Preconditions() {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 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.
Expand Down Expand Up @@ -207,6 +207,40 @@ public static Stream<Arguments> negativeIntegers() {
Arguments.of(-10_000_000));
}

/**
* Some even numbers.
*/
public static Stream<Arguments> evenIntegers() {
return Stream.of(
Arguments.of(-4),
Arguments.of(-2),
Arguments.of(0),
Arguments.of(2),
Arguments.of(4),
Arguments.of(6),
Arguments.of(8),
Arguments.of(10),
Arguments.of(100),
Arguments.of(1_000));
}

/**
* Some odd numbers.
*/
public static Stream<Arguments> oddIntegers() {
return Stream.of(
Arguments.of(-3),
Arguments.of(-1),
Arguments.of(1),
Arguments.of(3),
Arguments.of(5),
Arguments.of(7),
Arguments.of(9),
Arguments.of(11),
Arguments.of(101),
Arguments.of(1_001));
}

/**
* Provides valid test data for cases where the value to test is greater than or equal to the base value.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 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.
Expand Down Expand Up @@ -49,4 +49,26 @@ void testIsPowerOfTwoFail(final int toTest) {
final boolean actual = MathUtilities.isPowerOfTwo(toTest);
assertThat(actual).isFalse();
}

/**
* This test aims to verify that the {@link MathUtilities#isEven(int)}
* returns {@code true} if the input number is even.
*/
@ParameterizedTest
@MethodSource("com.hedera.block.common.CommonsTestUtility#evenIntegers")
void testIsEvenPass(final int toTest) {
final boolean actual = MathUtilities.isEven(toTest);
assertThat(actual).isTrue();
}

/**
* This test aims to verify that the {@link MathUtilities#isEven(int)}
* returns {@code false} if the input number is odd.
*/
@ParameterizedTest
@MethodSource("com.hedera.block.common.CommonsTestUtility#oddIntegers")
void testIsEvenFail(final int toTest) {
final boolean actual = MathUtilities.isEven(toTest);
assertThat(actual).isFalse();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 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.
Expand Down Expand Up @@ -39,6 +39,7 @@ class PreconditionsTest {
"The input number [%d] is required to be a whole number.";
private static final String DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE =
"The input number [%d] is required to be a power of two.";
private static final String DEFAULT_REQUIRE_IS_EVEN = "The input number [%d] is required to be even.";

/**
* This test aims to verify that the
Expand Down Expand Up @@ -342,6 +343,43 @@ void testRequireInRangeFail(final int toTest, final int lowerBoundary, final int
.withMessage(expectedTestMessage);
}

/**
* This test aims to verify that the
* {@link Preconditions#requireEven(int)} will return the input 'toTest'
* parameter if the even check passes. Test includes overloads.
*
* @param toTest parameterized, the number to test
*/
@ParameterizedTest
@MethodSource("com.hedera.block.common.CommonsTestUtility#evenIntegers")
void testRequireEvenPass(final int toTest) {
final Consumer<Integer> asserts = actual -> assertThat(actual).isEven().isEqualTo(toTest);

final int actual = Preconditions.requireEven(toTest);
assertThat(actual).satisfies(asserts);

final int actualOverload = Preconditions.requireEven(toTest, "test error message");
assertThat(actualOverload).satisfies(asserts);
}

/** This test aims to verify that the {@link Preconditions#requireEven(int)} will throw an {@link IllegalArgumentException} if the even check fails. Test includes overloads.
*
* @param toTest parameterized, the number to test
*/
@ParameterizedTest
@MethodSource("com.hedera.block.common.CommonsTestUtility#oddIntegers")
void testRequireEvenFail(final int toTest) {
assertThatIllegalArgumentException()
.isThrownBy(() -> Preconditions.requireEven(toTest))
.withMessage(DEFAULT_REQUIRE_IS_EVEN.formatted(toTest));

final String testMessage = DEFAULT_REQUIRE_IS_EVEN.concat(" custom test error message");
final String expectedTestMessage = testMessage.formatted(toTest);
assertThatIllegalArgumentException()
.isThrownBy(() -> Preconditions.requireEven(toTest, testMessage))
.withMessage(expectedTestMessage);
}

private static Stream<Arguments> validRequireInRangeValues() {
return Stream.of(
Arguments.of(0, 0, 0),
Expand Down
2 changes: 2 additions & 0 deletions server/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ services:
block-node-server:
container_name: block-node-server
image: block-node-server:${VERSION}
volumes:
- ./logging.properties:/app/logging.properties
env_file:
- .env
ports:
Expand Down
26 changes: 25 additions & 1 deletion server/docker/logging.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# FINEST: provides the most detailed debugging information

# Set the default logging level
# Available Levels are (from most verbose to least verbose):
# ALL FINEST FINER FINE CONFIG INFO WARNING SEVERE OFF
.level=INFO

# Helidon loggers
Expand All @@ -31,8 +33,30 @@ io.helidon.common.level=INFO
# Helidon PBJ Plugin loggers
#com.hedera.pbj.grpc.helidon.PbjProtocolHandler.level=FINE

# Console handler configuration
################################################################################
# Handlers configuration
################################################################################
handlers = java.util.logging.ConsoleHandler

################################################################################
# ConsoleHandler configuration
################################################################################
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

################################################################################
# SimpleFormatter single-line format configuration
################################################################################
# The format syntax uses java.util.Formatter.
# The parameters are:
# %1$ - date/time (java.util.Date)
# %2$ - source (usually class and method)
# %3$ - logger?s name
# %4$ - log level
# %5$ - log message
# %6$ - throwable trace
#
# Example to produce a line such as:
# 2025-01-04 00:34:43 INFO [com.hedera.block.server.Server main] Starting BlockNode Server
#
java.util.logging.SimpleFormatter.format = %1$tF %1$tT %4$-7s [%2$s] %5$s %n
Loading

0 comments on commit c11b4a6

Please sign in to comment.