From 9e6da7f029216480cf40a28b7482ef89de1f3c21 Mon Sep 17 00:00:00 2001 From: thinkAfCod Date: Wed, 31 Jan 2024 17:29:40 +0800 Subject: [PATCH] feat: Dockerfile add entrypoint --- README.md | 79 +++++++++++++++++++++++---------- docker/Dockerfile | 1 + docker/jvm.dock | 2 + docker/start-hildr-node-java.sh | 19 +++++--- 4 files changed, 71 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 633a5c2f..a4c24c0e 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,61 @@ Follow the [spec](https://github.com/ethereum-optimism/optimism/blob/develop/spe ## System requirements To run a `hildr-node` and `op-geth` node, at least 4C8G and 100GB of disk is required, as well as the installation of Java version 21 and Go version 1.20.8, must lower then v1.21. +## Running `hildr-node` + +First, use Docker start a `op-geth` container in hildr project root directory: + +```shell +cd ./docker && docker compose -f docker/docker-compose.yml up op-geth +``` + +### Use shell +Then, once op-geth has been started, start up the `hildr-node` in `hildr` project root directory: +```shell +./gradlew :hildr-node:build -x test \ + && nohup java --enable-preview \ + -cp hildr-node/build/libs/hildr-node-{version}.jar io.optimism.Hildr \ + --network optimism-sepolia \ + --jwt-secret $JWT_SECRET + --l1-rpc-url $L1_RPC_URL + --l1-ws-rpc-url $L1_WS_RPC_URL + --l2-rpc-url $L2_RPC_URL \ + --l2-engine-url $L2_AUTH_RPC_URL \ + --rpc-port $HILDR_RPC_PORT \ # Choose any available port. + --log-level $LOG_LEVEL \ # can be either: "DEBUG","TRACE","INFO","WARN","ERROR" + --sync-mode full >l2-hildr-node.log 2>&1 & +``` + +### Use docker + +Running a native hildr container on optimism-sepolia network: +```shell +docker run -it ghcr.io/optimism-java/hildr:latest-native \ + --network optimism-sepolia \ + --jwt-secret $JWT_SECRET \ + --l1-rpc-url $L1_RPC_URL \ + --l1-ws-rpc-url $L1_WS_RPC_URL \ + --l2-rpc-url $L2_RPC_URL \ + --l2-engine-url $L2_AUTH_RPC_URL \ + --rpc-port $HILDR_RPC_PORT \ + --log-level $LOG_LEVEL \ # can be either: "DEBUG","TRACE","INFO","WARN","ERROR" + --sync-mode full +``` + +Running a java hildr container on optimism-sepolia network: +```shell +docker run -it ghcr.io/optimism-java/hildr:latest \ + --network optimism-sepolia \ + --jwt-secret $JWT_SECRET \ + --l1-rpc-url $L1_RPC_URL \ + --l1-ws-rpc-url $L1_WS_RPC_URL \ + --l2-rpc-url $L2_RPC_URL \ + --l2-engine-url $L2_AUTH_RPC_URL \ + --rpc-port $HILDR_RPC_PORT \ + --log-level $LOG_LEVEL \ # can be either: "DEBUG","TRACE","INFO","WARN","ERROR" + --sync-mode full +``` + ## Installing Hildr Node ### Building `hildr-node` from source @@ -82,30 +137,6 @@ EXECUTION_CLIENT_WS_PORT=5546 ``` -### Running `hildr-node` - -First, use Docker start a `op-geth` container in hildr project root directory: - -```shell -cd ./docker && docker compose -f docker/docker-compose.yml up op-geth -``` - -Then, once op-geth has been started, start up the `hildr-node` in `hildr` project root directory: -```shell -./gradlew :hildr-node:build -x test \ - && export $(grep -v '^#' .env|xargs) \ - && nohup java --enable-preview \ - -cp hildr-node/build/libs/hildr-node-0.2.0.jar io.optimism.Hildr \ - --network optimism-sepolia \ - --jwt-secret $JWT_SECRET - --l1-rpc-url $L1_RPC_URL - --l1-ws-rpc-url $L1_WS_RPC_URL - --l2-rpc-url http://127.0.0.1:5545 \ - --l2-engine-url http://127.0.0.1:5551 \ - --rpc-port 11545 \ # Choose any available port. - --sync-mode full >l2-hildr-node.log 2>&1 & -``` - ### Running devnet You also can run a hildr-node on [devnet](./docs/devnet.md) diff --git a/docker/Dockerfile b/docker/Dockerfile index 54619b11..75f13221 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,6 +28,7 @@ COPY --from=builder /root/hildr/hildr-node/build/binary/hildr* . #COPY --from=builder /root/hildr/hildr-node/build/native/nativeCompile/hildr* . RUN chmod 0755 hildr-node && export PATH=/usr/local/bin:$PATH +ENTRYPOINT ["hildr-node"] diff --git a/docker/jvm.dock b/docker/jvm.dock index 7dd017c9..13e1f5ea 100644 --- a/docker/jvm.dock +++ b/docker/jvm.dock @@ -11,3 +11,5 @@ COPY --from=builder /root/hildr/hildr-node/build/docker/hildr-node.jar . COPY --from=builder /root/hildr/docker/start-hildr-node-java.sh . ENV HILDR_JAR /usr/local/bin/hildr-node.jar ENV HILDR_MAIN_CLASS io.optimism.Hildr + +ENTRYPOINT ["java", "--enable-preview", "-cp" , "/usr/local/bin/hildr-node.jar", "io.optimism.Hildr"] \ No newline at end of file diff --git a/docker/start-hildr-node-java.sh b/docker/start-hildr-node-java.sh index d671ae63..746d960f 100755 --- a/docker/start-hildr-node-java.sh +++ b/docker/start-hildr-node-java.sh @@ -12,6 +12,11 @@ then fi fi +if [ $LOG_LEVEL = "" ] +then + LOG_LEVEL="INFO" +fi + if [ $SYNC_MODE = "full" ] then exec java --enable-preview \ @@ -20,11 +25,12 @@ then --jwt-secret $JWT_SECRET \ --l1-rpc-url $L1_RPC_URL \ --l1-ws-rpc-url $L1_WS_RPC_URL \ - --l2-rpc-url http://${EXECUTION_CLIENT}:8545 \ - --l2-engine-url http://${EXECUTION_CLIENT}:8551 \ + --l2-rpc-url http://${EXECUTION_CLIENT}:${EXECUTION_CLIENT_RPC_PORT} \ + --l2-engine-url http://${EXECUTION_CLIENT}:${EXECUTION_CLIENT_AUTH_RPC_PORT} \ --rpc-port $RPC_PORT \ $DEVNET \ - --sync-mode $SYNC_MODE + --sync-mode $SYNC_MODE \ + --log-level $LOG_LEVEL elif [ $SYNC_MODE = "checkpoint"] then exec java --enable-preview \ @@ -33,13 +39,14 @@ then --jwt-secret $JWT_SECRET \ --l1-rpc-url $L1_RPC_URL \ --l1-ws-rpc-url $L1_WS_RPC_URL \ - --l2-rpc-url http://${EXECUTION_CLIENT}:8545 \ - --l2-engine-url http://${EXECUTION_CLIENT}:8551 \ + --l2-rpc-url http://${EXECUTION_CLIENT}:${EXECUTION_CLIENT_RPC_PORT} \ + --l2-engine-url http://${EXECUTION_CLIENT}:${EXECUTION_CLIENT_AUTH_RPC_PORT} \ --rpc-port $RPC_PORT \ $DEVNET \ --sync-mode $SYNC_MODE \ --checkpoint-sync-url $CHECKPOINT_SYNC_URL \ - --checkpoint-hash $CHECKPOINT_HASH + --checkpoint-hash $CHECKPOINT_HASH \ + --log-level $LOG_LEVEL else echo "Sync mode not recognized. Available options are full and checkpoint" fi