diff --git a/charts/block-node-server/templates/NOTES.txt b/charts/block-node-server/templates/NOTES.txt index ed9b5b247..b4525e7a6 100644 --- a/charts/block-node-server/templates/NOTES.txt +++ b/charts/block-node-server/templates/NOTES.txt @@ -1,8 +1,8 @@ 1. **Get the application URL** by running the following commands: ```bash -kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{.Release.Name}}-{{.Chart.Name}} 8080:{{ .Values.service.port }} -echo "Visit http://127.0.0.1:8080 to use your application" +kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{.Release.Name}}-{{.Chart.Name}} 40840:{{ .Values.service.port }} +echo "Visit http://127.0.0.1:40840 to use your application" ``` {{- if .Values.kubepromstack.enabled }} diff --git a/charts/block-node-server/values.yaml b/charts/block-node-server/values.yaml index 6fb164b06..cb9bfd418 100644 --- a/charts/block-node-server/values.yaml +++ b/charts/block-node-server/values.yaml @@ -38,7 +38,7 @@ securityContext: {} service: type: ClusterIP - port: 8080 + port: 40840 ingress: enabled: false diff --git a/server/docker/Dockerfile b/server/docker/Dockerfile index dbf363ffb..41e64b2b6 100644 --- a/server/docker/Dockerfile +++ b/server/docker/Dockerfile @@ -131,15 +131,15 @@ ENV PATH=${JAVA_HOME}/bin:${PATH} COPY --from=java-builder ${JAVA_HOME}/ ${JAVA_HOME}/ # Expose the port that the application will run on -EXPOSE 8080/tcp +EXPOSE 40840/tcp USER hedera WORKDIR /app # HEALTHCHECK for liveness and readiness HEALTHCHECK --interval=30s --timeout=10s --start-period=3s --retries=3 \ - CMD curl -f http://localhost:8080/healthz/livez || exit 1 && \ - curl -f http://localhost:8080/healthz/readyz || exit 1 + CMD curl -f http://localhost:40840/healthz/livez || exit 1 && \ + curl -f http://localhost:40840/healthz/readyz || exit 1 # RUN the bin script for starting the server ENTRYPOINT ["/bin/bash", "-c", "/app/server-${VERSION}/bin/server"] diff --git a/server/docker/docker-compose.yml b/server/docker/docker-compose.yml index 0d52b366e..aa8d119ad 100644 --- a/server/docker/docker-compose.yml +++ b/server/docker/docker-compose.yml @@ -7,7 +7,7 @@ services: env_file: - .env ports: - - "8080:8080" + - "40840:40840" - "5005:5005" - "9999:9999" - "8849:8849" diff --git a/server/docs/configuration.md b/server/docs/configuration.md index 2ca3835e6..9078cf66e 100644 --- a/server/docs/configuration.md +++ b/server/docs/configuration.md @@ -28,7 +28,7 @@ defaults and can be left unchanged. It is recommended to browse the properties b | SERVICE_DELAY_MILLIS | Service shutdown delay in milliseconds | 500 | | MEDIATOR_RING_BUFFER_SIZE | Size of the ring buffer used by the mediator (must be a power of 2) | 67108864 | | NOTIFIER_RING_BUFFER_SIZE | Size of the ring buffer used by the notifier (must be a power of 2) | 2048 | -| SERVER_PORT | The port the server will listen on | 8080 | +| SERVER_PORT | The port the server will listen on | 40840 | | SERVER_MAX_MESSAGE_SIZE_BYTES | The maximum size of a message frame in bytes | 1048576 | | VERIFICATION_ENABLED | Enables or disables the block verification process | true | | VERIFICATION_SESSION_TYPE | The type of BlockVerificationSession to use, either `ASYNC` or `SYNC` | ASYNC | diff --git a/server/src/main/java/com/hedera/block/server/ServerConfig.java b/server/src/main/java/com/hedera/block/server/ServerConfig.java index 556d54fcb..e0f969f4f 100644 --- a/server/src/main/java/com/hedera/block/server/ServerConfig.java +++ b/server/src/main/java/com/hedera/block/server/ServerConfig.java @@ -49,7 +49,7 @@ public record ServerConfig( static final int minSocketReceiveBufferSizeBytes = 32768; // Constants for port property - static final String defaultPort = "8080"; + static final String defaultPort = "40840"; static final int minPort = 1024; static final int maxPort = 65_535; diff --git a/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java b/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java index 29beea9ab..f2c19a8a9 100644 --- a/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java +++ b/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java @@ -40,6 +40,8 @@ @ExtendWith(MockitoExtension.class) class BlockNodeAppTest { + private static final int DEFAULT_PORT = 40840; + @Mock private ServiceStatus serviceStatus; @@ -84,7 +86,7 @@ void setup() throws IOException { ConsumerConfig consumerConfig = config.getConfigData(ConsumerConfig.class); ProducerConfig producerConfig = config.getConfigData(ProducerConfig.class); - serverConfig = new ServerConfig(4_194_304, 32_768, 32_768, 8080); + serverConfig = new ServerConfig(4_194_304, 32_768, 32_768, DEFAULT_PORT); blockNodeApp = new BlockNodeApp( serviceStatus, @@ -104,7 +106,7 @@ void setup() throws IOException { serverConfig, configurationLogging); - when(webServerBuilder.port(8080)).thenReturn(webServerBuilder); + when(webServerBuilder.port(DEFAULT_PORT)).thenReturn(webServerBuilder); when(webServerBuilder.addProtocol(any(PbjConfig.class))).thenReturn(webServerBuilder); when(webServerBuilder.addRouting(any(PbjRouting.Builder.class))).thenReturn(webServerBuilder); when(webServerBuilder.addRouting(any(HttpRouting.Builder.class))).thenReturn(webServerBuilder); @@ -122,7 +124,7 @@ void testStartServer() throws IOException { verify(serviceStatus).setWebServer(webServer); verify(webServer).start(); verify(healthService).getHealthRootPath(); - verify(webServerBuilder).port(8080); + verify(webServerBuilder).port(DEFAULT_PORT); verify(webServerBuilder).addRouting(any(PbjRouting.Builder.class)); verify(webServerBuilder).addRouting(any(HttpRouting.Builder.class)); verify(webServerBuilder).addProtocol(any(PbjConfig.class)); diff --git a/server/src/test/java/com/hedera/block/server/ServerConfigTest.java b/server/src/test/java/com/hedera/block/server/ServerConfigTest.java index 899fa9ff3..45501d7f3 100644 --- a/server/src/test/java/com/hedera/block/server/ServerConfigTest.java +++ b/server/src/test/java/com/hedera/block/server/ServerConfigTest.java @@ -15,6 +15,7 @@ class ServerConfigTest { private static final String RANGE_ERROR_TEMPLATE = "%s value %d is out of range [%d, %d]"; + private static final int DEFAULT_PORT = 40840; @BeforeEach void setUp() {} @@ -24,16 +25,16 @@ void tearDown() {} @Test void testValidValues() { - ServerConfig serverConfig = new ServerConfig(4_194_304, 32_768, 32_768, 8080); + ServerConfig serverConfig = new ServerConfig(4_194_304, 32_768, 32_768, DEFAULT_PORT); assertEquals(4_194_304, serverConfig.maxMessageSizeBytes()); - assertEquals(8080, serverConfig.port()); + assertEquals(DEFAULT_PORT, serverConfig.port()); } @ParameterizedTest @MethodSource("outOfRangeMaxMessageSizes") void testMessageSizesOutOfBounds(final int messageSize, final String message) { assertThatIllegalArgumentException() - .isThrownBy(() -> new ServerConfig(messageSize, 32_768, 32_768, 8080)) + .isThrownBy(() -> new ServerConfig(messageSize, 32_768, 32_768, DEFAULT_PORT)) .withMessage(message); } @@ -41,7 +42,7 @@ void testMessageSizesOutOfBounds(final int messageSize, final String message) { @MethodSource("outOfRangeSendBufferSizes") void testSocketSendBufferSize(int sendBufferSize, String message) { assertThatIllegalArgumentException() - .isThrownBy(() -> new ServerConfig(4_194_304, sendBufferSize, 32_768, 8080)) + .isThrownBy(() -> new ServerConfig(4_194_304, sendBufferSize, 32_768, DEFAULT_PORT)) .withMessage(message); } @@ -49,7 +50,7 @@ void testSocketSendBufferSize(int sendBufferSize, String message) { @MethodSource("outOfRangeReceiveBufferSizes") void testSocketReceiveBufferSize(int receiveBufferSize, String message) { assertThatIllegalArgumentException() - .isThrownBy(() -> new ServerConfig(4_194_304, 32_768, receiveBufferSize, 8080)) + .isThrownBy(() -> new ServerConfig(4_194_304, 32_768, receiveBufferSize, DEFAULT_PORT)) .withMessage(message); } diff --git a/server/src/test/network-latency-simulator/Dockerfile b/server/src/test/network-latency-simulator/Dockerfile index f3e327abd..9e641a7d2 100644 --- a/server/src/test/network-latency-simulator/Dockerfile +++ b/server/src/test/network-latency-simulator/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:latest # Set environment variables ENV DEBIAN_FRONTEND=noninteractive -ENV GRPC_SERVER="host.docker.internal:8080" +ENV GRPC_SERVER="host.docker.internal:40840" ENV GRPC_METHOD="BlockStreamGrpc/StreamSource" ENV PATH_TO_PROTO="/usr/local/protos/blockstream.proto" ENV PROTO_IMPORT_PATH="/usr/local/protos" diff --git a/server/src/test/network-latency-simulator/README.md b/server/src/test/network-latency-simulator/README.md index f81a67bbd..42d870000 100644 --- a/server/src/test/network-latency-simulator/README.md +++ b/server/src/test/network-latency-simulator/README.md @@ -10,6 +10,7 @@ This test aims to make sure that the system is resilient to network issues and t 1. Move to the `network-latency-simulator` directory. 2. Prepare the Test Context, Build the Docker Image with the network latency simulator. + ```bash cd server/src/test/network-latency-simulator @@ -21,11 +22,14 @@ docker build -t network-latency-simulator . 3. Start the BlockNode Server. (Follow instructions on main README.md) - Due to the Latency, the consumers might be disconnected from the BlockNode, since the current timeout is 1500 ms, you should increase the timeout to 100000ms to be able to correctly test the network issues. (see main README.md of the server for more details on how to change the timeout) 4. Start the producer and a single consumer (this consumer will be the control one without any network issues). + ```bash /server/src/test/resources/producer.sh 1 1000 # this will produce 1000 blocks /server/src/test/resources/consumer.sh 1 1000 # this will consume 1000 blocks ``` + 5. Start the consumer inside the network latency simulator container, you can start as many as you want. + ```bash docker run -it --cap-add=NET_ADMIN network-latency-simulator ``` @@ -48,12 +52,13 @@ There are some environment variables that you can set to change the behavior of - `MAX_LATENCY`: The maximum latency to reach, default is 12000 (ms). **consumer.sh:** -- `GRPC_SERVER`: The gRPC server to connect to, default is `host.docker.internal:8080`, connects to the host BlockNode. +- `GRPC_SERVER`: The gRPC server to connect to, default is `host.docker.internal:40840`, connects to the host BlockNode. - `GRPC_METHOD`: The gRPC method to call, default is `BlockStreamGrpc/StreamSource`. - `PATH_TO_PROTO`: The path to the proto file, default is `/usr/local/protos/blockstream.proto` (inside the container). - `PROTO_IMPORT_PATH`: The import path of the proto file, default is `/usr/local/protos` (inside the container). Example of how to set the environment variables when running the container: + ```bash docker run -it --cap-add=NET_ADMIN -e LATENCY_INCREASE_INTERVAL=5 -e INITIAL_LATENCY=1000 -e JITTER=1000 -e BANDWIDTH=128 -e INCREASE_TIME=5 -e MAX_LATENCY=10000 network-latency-simulator ``` diff --git a/server/src/test/resources/consumer.sh b/server/src/test/resources/consumer.sh index 1459e4561..598429be1 100755 --- a/server/src/test/resources/consumer.sh +++ b/server/src/test/resources/consumer.sh @@ -26,7 +26,7 @@ second_param="${2:-0}" echo "Params are: $first_param, $second_param" # Use environment variables or default values -GRPC_SERVER=${GRPC_SERVER:-"localhost:8080"} +GRPC_SERVER=${GRPC_SERVER:-"localhost:40840"} GRPC_METHOD=${GRPC_METHOD:-"com.hedera.hapi.block.BlockStreamService/subscribeBlockStream"} PATH_TO_PROTO="./block_service.proto" diff --git a/server/src/test/resources/get-block.sh b/server/src/test/resources/get-block.sh index 407106b07..2d096cada 100755 --- a/server/src/test/resources/get-block.sh +++ b/server/src/test/resources/get-block.sh @@ -14,7 +14,7 @@ fi echo "Param is: $1" # Use environment variables or default values -GRPC_SERVER=${GRPC_SERVER:-"localhost:8080"} +GRPC_SERVER=${GRPC_SERVER:-"localhost:40840"} GRPC_METHOD=${GRPC_METHOD:-"com.hedera.hapi.block.BlockAccessService/singleBlock"} PATH_TO_PROTO="./block_service.proto" diff --git a/server/src/test/resources/producer.sh b/server/src/test/resources/producer.sh index f1cfce6af..41c081ece 100755 --- a/server/src/test/resources/producer.sh +++ b/server/src/test/resources/producer.sh @@ -53,7 +53,7 @@ generate_block_proof() { echo "$result" } -GRPC_SERVER="localhost:8080" +GRPC_SERVER="localhost:40840" GRPC_METHOD="com.hedera.hapi.block.BlockStreamService/publishBlockStream" PATH_TO_PROTO="./block_service.proto" diff --git a/server/src/test/resources/smoke-test.sh b/server/src/test/resources/smoke-test.sh index a5a5d7be9..ba359fb4f 100755 --- a/server/src/test/resources/smoke-test.sh +++ b/server/src/test/resources/smoke-test.sh @@ -60,7 +60,7 @@ readiness() { trap "shutdown; exit 1" ERR SIGINT SIGTERM # 1. Call the endpoints /health/livez and /health/readyz -export SERVER_URL="http://localhost:8080" +export SERVER_URL="http://localhost:40840" export LIVENESS_ENDPOINT="/healthz/livez" export READINESS_ENDPOINT="/healthz/readyz" diff --git a/simulator/docs/configuration.md b/simulator/docs/configuration.md index 33f16ee05..f9bbdc279 100644 --- a/simulator/docs/configuration.md +++ b/simulator/docs/configuration.md @@ -9,41 +9,41 @@ There are 3 configuration sets: Uses the prefix `blockStream` so all properties should start with `blockStream.` -| Key | Description | Default Value | -|:---|:---|---:| -| `simulatorMode` | The desired simulator mode to use, it can be either `PUBLISHER` or `CONSUMER`. | `PUBLISHER` | -| `delayBetweenBlockItems` | The delay between each block item in nanoseconds, only applicable when streamingMode=CONSTANT_RATE | `1_500_000` | -| `maxBlockItemsToStream` | exit condition for the simulator and the circular implementations such as `BlockAsDir` or `BlockAsFile` implementations | `10_000` | -| `streamingMode` | can either be `CONSTANT_RATE` or `MILLIS_PER_BLOCK` | `CONSTANT_RATE` | -| `millisecondsPerBlock` | if streamingMode is `MILLIS_PER_BLOCK` this will be the time to wait between blocks in milliseconds | `1_000` | -| `blockItemsBatchSize` | the number of block items to send in a single batch, however if a block has less block items, it will send all the items in a block | `1_000` | +| Key | Description | Default Value | +|:-------------------------|:------------------------------------------------------------------------------------------------------------------------------------|----------------:| +| `simulatorMode` | The desired simulator mode to use, it can be either `PUBLISHER` or `CONSUMER`. | `PUBLISHER` | +| `delayBetweenBlockItems` | The delay between each block item in nanoseconds, only applicable when streamingMode=CONSTANT_RATE | `1_500_000` | +| `maxBlockItemsToStream` | exit condition for the simulator and the circular implementations such as `BlockAsDir` or `BlockAsFile` implementations | `10_000` | +| `streamingMode` | can either be `CONSTANT_RATE` or `MILLIS_PER_BLOCK` | `CONSTANT_RATE` | +| `millisecondsPerBlock` | if streamingMode is `MILLIS_PER_BLOCK` this will be the time to wait between blocks in milliseconds | `1_000` | +| `blockItemsBatchSize` | the number of block items to send in a single batch, however if a block has less block items, it will send all the items in a block | `1_000` | ## GeneratorConfig Uses the prefix `generator` so all properties should start with `generator.` -| Key | Description | Default Value | -|:---|:---|---:| -| `generationMode` | The desired generation Mode to use, it can only be `DIR` or `AD_HOC` | `DIR` | -| `folderRootPath` | If the generationMode is DIR this will be used as the source of the recording to stream to the Block-Node | `` | +| Key | Description | Default Value | +|:------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------:| +| `generationMode` | The desired generation Mode to use, it can only be `DIR` or `AD_HOC` | `DIR` | +| `folderRootPath` | If the generationMode is DIR this will be used as the source of the recording to stream to the Block-Node | `` | | `managerImplementation` | The desired implementation of the BlockStreamManager to use, it can only be `BlockAsDirBlockStreamManager`, `BlockAsFileBlockStreamManager` or `BlockAsFileLargeDataSets` | `BlockAsFileBlockStreamManager` | -| `paddedLength` | on the `BlockAsFileLargeDataSets` implementation, the length of the padded left zeroes `000001.blk.gz` | 36 | -| `fileExtension` | on the `BlockAsFileLargeDataSets` implementation, the extension of the files to be streamed | `.blk.gz` | +| `paddedLength` | on the `BlockAsFileLargeDataSets` implementation, the length of the padded left zeroes `000001.blk.gz` | 36 | +| `fileExtension` | on the `BlockAsFileLargeDataSets` implementation, the extension of the files to be streamed | `.blk.gz` | ## GrpcConfig Uses the prefix `grpc` so all properties should start with `grpc.` -| Key | Description | Default Value | -|:---|:---|---:| -| `serverAddress` | The host of the Block-Node | `localhost` | -| `port` | The port of the Block-Node | `8080` | +| Key | Description | Default Value | +|:----------------|:---------------------------|--------------:| +| `serverAddress` | The host of the Block-Node | `localhost` | +| `port` | The port of the Block-Node | `40840` | ## PrometheusConfig Uses the prefix `prometheus` so all properties should start with `prometheus.` -| Key | Description | Default Value | -|:---|:---|--------------:| -| `endpointEnabled` | Whether Prometheus endpoint is enabled | `false` | -| `endpointPortNumber` | Port number for Prometheus endpoint | `9998` | \ No newline at end of file +| Key | Description | Default Value | +|:---------------------|:---------------------------------------|--------------:| +| `endpointEnabled` | Whether Prometheus endpoint is enabled | `false` | +| `endpointPortNumber` | Port number for Prometheus endpoint | `9998` | diff --git a/simulator/src/main/java/com/hedera/block/simulator/config/data/GrpcConfig.java b/simulator/src/main/java/com/hedera/block/simulator/config/data/GrpcConfig.java index fd17595b8..3d4f3b73d 100644 --- a/simulator/src/main/java/com/hedera/block/simulator/config/data/GrpcConfig.java +++ b/simulator/src/main/java/com/hedera/block/simulator/config/data/GrpcConfig.java @@ -15,4 +15,4 @@ @ConfigData("grpc") public record GrpcConfig( @ConfigProperty(defaultValue = "localhost") String serverAddress, - @ConfigProperty(defaultValue = "8080") @Min(0) @Max(65535) int port) {} + @ConfigProperty(defaultValue = "40840") @Min(0) @Max(65535) int port) {} diff --git a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java index c8bc30303..85ad63272 100644 --- a/suites/src/main/java/com/hedera/block/suites/BaseSuite.java +++ b/suites/src/main/java/com/hedera/block/suites/BaseSuite.java @@ -105,7 +105,7 @@ public static void teardown() { * *