From b5a99aa9376ad2d18b299f227822f9fc5790f762 Mon Sep 17 00:00:00 2001 From: Sergey Nazarov Date: Wed, 25 Sep 2024 13:20:17 +0300 Subject: [PATCH] wip --- docker/Dockerfile | 3 +- docker/README.md | 38 +++++++++---------- docker/entrypoint.sh | 36 ++++++++---------- docker/waves.conf.template | 10 ----- .../scala/com/wavesplatform/Application.scala | 2 +- .../wavesplatform/http/UtilsRouteSpec.scala | 4 +- 6 files changed, 39 insertions(+), 54 deletions(-) delete mode 100644 docker/waves.conf.template diff --git a/docker/Dockerfile b/docker/Dockerfile index 771bae2d3cd..b69b560a0b3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,7 +12,6 @@ ENV WVLOG=/var/log/waves ENV WAVES_INSTALL_PATH=/usr/share/waves ENV WAVES_CONFIG=/etc/waves/waves.conf COPY target /tmp/ -COPY waves.conf.template $WAVES_CONFIG # Setup node COPY entrypoint.sh $WAVES_INSTALL_PATH/bin/entrypoint.sh @@ -41,4 +40,4 @@ WORKDIR $WVDATA HEALTHCHECK CMD curl -f http://localhost:6869/node/status || exit 1 STOPSIGNAL SIGINT -ENTRYPOINT ["/usr/share/waves/bin/entrypoint.sh"] +ENTRYPOINT ["${WAVES_INSTALL_PATH}/bin/entrypoint.sh"] diff --git a/docker/README.md b/docker/README.md index 2ea800ff610..1d666ee0f1c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -28,39 +28,39 @@ It is highly recommended to read more about [Waves Node configuration](https://d ## Running Docker image + + ### Configuration options 1. The image supports Waves Node config customization. To change a config field use corresponding JVM options. JVM options can be sent to JVM using `JAVA_OPTS` environment variable. Please refer to ([complete configuration file](https://github.com/wavesplatform/Waves/blob/master/node/src/main/resources/application.conf)) to get the full path of the configuration item you want to change. -``` -docker run -v /docker/waves/waves-data:/var/lib/waves -v /docker/waves/waves-config:/etc/waves -p 6869:6869 -p 6862:6862 -e JAVA_OPTS="-Dwaves.rest-api.enable=yes -Dwaves.wallet.password=myWalletSuperPassword" -ti wavesplatform/wavesnode -``` + ``` + docker run -v /docker/waves/waves-data:/var/lib/waves -v /docker/waves/waves-config:/etc/waves -p 6869:6869 -p 6862:6862 -e JAVA_OPTS="-Dwaves.rest-api.enable=yes -Dwaves.wallet.password=myWalletSuperPassword" -ti wavesplatform/wavesnode + ``` 2. Waves Node is looking for a config in the directory `/etc/waves/waves.conf` which can be mounted using Docker volumes. During image build, a default configuration will be copied to this directory. While running container if the value of `WAVES_NETWORK` is not `mainnet`, `testnet` or `stagenet`, default configuration won't be enough for correct node working. This is a scenario of using `CUSTOM` network - correct configuration must be provided when running container. If you use `CUSTOM` network and `/etc/waves/waves.conf` is NOT found Waves Node container will exit. -3. By default, `/etc/waves/waves.conf` config includes `/etc/waves/local.conf`. Custom `/etc/waves/local.conf` can be used to override default config entries. Custom `/etc/waves/waves.conf` can be used to override or the whole configuration. For additional information about Docker volumes mapping please refer to `Managing data` item. +3. You can use custom config to override or the whole configuration. For additional information about Docker volumes mapping please refer to `Managing data` item. 4. You can override the default executable by using the following syntax: -``` -docker run -it wavesplatform/wavesnode [command] [args] -``` + ``` + docker run -it wavesplatform/wavesnode [command] [args] + ``` ### Environment variables -**You can run container with predefined environment variables:** - -| Env variable | Description | -|-----------------------------------|--------------| -| `WAVES_WALLET_SEED` | Base58 encoded seed. Overrides `-Dwaves.wallet.seed` JVM config option. | -| `WAVES_WALLET_PASSWORD` | Password for the wallet file. Overrides `-Dwaves.wallet.password` JVM config option. | -| `WAVES_LOG_LEVEL` | Node logging level. Available values: `OFF`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`. More details about logging are available [here](https://docs.waves.tech/en/waves-node/logging-configuration).| -| `WAVES_HEAP_SIZE` | Default Java Heap Size limit in -X Command-line Options notation (`-Xms=[your value]`). More details [here](https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionX.html). | -|`WAVES_NETWORK` | Waves Blockchain network. Available values are `mainnet`, `testnet`, `stagenet`.| -|`JAVA_OPTS` | Additional Waves Node JVM configuration options. | +The following environment variables can be passed to the container: -**Note: All variables are optional.** +| Env variable | Description | +|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `WAVES_WALLET_SEED` | Base58 encoded seed, sets `-Dwaves.wallet.seed` system property. | +| `WAVES_WALLET_PASSWORD` | Password for the wallet file, sets `-Dwaves.wallet.password` system property. | +| `WAVES_LOG_LEVEL` | Node stdout logging level. Available values: `OFF`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`. More details about logging are available [here](https://docs.waves.tech/en/waves-node/logging-configuration). | +| `WAVES_HEAP_SIZE` | Default Java Heap Size limit in -X Command-line Options notation (`-Xmx=[your value]`). More details [here](https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionX.html). | +| `WAVES_NETWORK` | Waves Blockchain network. Available values are `mainnet`, `testnet`, `stagenet`. | +| `JAVA_OPTS` | Additional Waves Node JVM configuration options. | -**Note: Environment variables override values in the configuration file.** +All environment variables are optional, however you need to specify at least the desired network and wallet password (via environment variables, additional system properties defined in the `JAVA_OPTS` environment variable, or in the config file). ### Managing data We recommend to store the blockchain state as well as Waves configuration on the host side. As such, consider using Docker volumes mapping to map host directories inside the container: diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 7e8ff04fe6b..dbb7f9b2b49 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,28 +1,24 @@ #!/bin/bash -shopt -s nullglob -logEcho() { - echo $1 | gosu waves tee -a /var/log/waves/waves.log -} -JAVA_OPTS="${JAVA_OPTS} -Dwaves.defaults.blockchain.type=$WAVES_NETWORK -Dwaves.defaults.directory=$WVDATA" - -logEcho "Node is starting..." -logEcho "WAVES_HEAP_SIZE='${WAVES_HEAP_SIZE}'" -logEcho "WAVES_LOG_LEVEL='${WAVES_LOG_LEVEL}'" -logEcho "JAVA_OPTS='${JAVA_OPTS}'" - -JAVA_OPTS="-Dlogback.stdout.level=${WAVES_LOG_LEVEL} - -XX:+ExitOnOutOfMemoryError +JAVA_OPTS="-XX:+ExitOnOutOfMemoryError -Xmx${WAVES_HEAP_SIZE} - -Dlogback.file.directory=$WVLOG - -Dconfig.override_with_env_vars=true + --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED + -Dlogback.stdout.level=${WAVES_LOG_LEVEL} + -Dlogback.file.directory=${WVLOG} + -Dwaves.config.directory=/etc/waves + -Dwaves.defaults.blockchain.type=${WAVES_NETWORK} + -Dwaves.directory=${WVDATA} + -Dwaves.rest-api.bind-address=0.0.0.0 ${JAVA_OPTS}" -if [ $# -eq 0 ] - then - ARGS="$WAVES_CONFIG" - else - ARGS=$@ +echo "JAVA_OPTS=${JAVA_OPTS}" | tee -a ${WVLOG}/waves.log + +if [ -n ${WAVES_WALLET_SEED} ] ; then + JAVA_OPTS="-Dwaves.wallet.seed=${WAVES_WALLET_SEED} ${JAVA_OPTS}" +fi + +if [ -n ${WAVES_WALLET_PASSWORD} ] ; then + JAVA_OPTS="-Dwaves.wallet.password=${WAVES_WALLET_PASSWORD} ${JAVA_OPTS}" fi exec java $JAVA_OPTS -cp "${WAVES_INSTALL_PATH}/lib/plugins/*:$WAVES_INSTALL_PATH/lib/*" com.wavesplatform.Application $ARGS diff --git a/docker/waves.conf.template b/docker/waves.conf.template deleted file mode 100644 index 14efef70fba..00000000000 --- a/docker/waves.conf.template +++ /dev/null @@ -1,10 +0,0 @@ -waves { - directory = ${WVDATA} - wallet { - seed = ${?WAVES_WALLET_SEED} - password = ${?WAVES_WALLET_PASSWORD} - } - rest-api.bind-address = "0.0.0.0" -} - -include "local.conf" diff --git a/node/src/main/scala/com/wavesplatform/Application.scala b/node/src/main/scala/com/wavesplatform/Application.scala index 886ac6b1a17..a954f7385fc 100644 --- a/node/src/main/scala/com/wavesplatform/Application.scala +++ b/node/src/main/scala/com/wavesplatform/Application.scala @@ -567,7 +567,7 @@ object Application extends ScorexLogging { .map(_.toUpperCase) .getOrElse("TESTNET") - log.warn(s"Config file not defined, default $currentBlockchainType config will be used") + log.info(s"Config file not specified, default $currentBlockchainType config will be used") case Failure(exception) => log.error(s"Couldn't read ${external.get.toPath.toAbsolutePath}", exception) forceStopApplication(Misconfiguration) diff --git a/node/tests/src/test/scala/com/wavesplatform/http/UtilsRouteSpec.scala b/node/tests/src/test/scala/com/wavesplatform/http/UtilsRouteSpec.scala index a1169464478..9941601904b 100644 --- a/node/tests/src/test/scala/com/wavesplatform/http/UtilsRouteSpec.scala +++ b/node/tests/src/test/scala/com/wavesplatform/http/UtilsRouteSpec.scala @@ -284,8 +284,8 @@ class UtilsRouteSpec extends RouteSpec("/utils") with RestAPISettingsHelper with |{-# CONTENT_TYPE DAPP #-} |{-# SCRIPT_TYPE ACCOUNT #-} | - |let looooooooooooooooooooooooongName = base58'${"a" * 3602}' - |${(1 to 18).map(i => s"let a$i = base58'${"a" * 12200}'").mkString("\n")} + |let looooooooooooooooooooooooongName = base64'${"A" * 3518}' # 2640 bytes + |${(1 to 18).map(i => s"let a$i = base64'${"A" * 11912}'").mkString("\n")} # 18 * 8934 bytes |func test() = looooooooooooooooooooooooongName == looooooooooooooooooooooooongName """.stripMargin