Skip to content

Commit

Permalink
feat: Dockerfile add entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAfCod authored and GrapeBaBa committed Jan 31, 2024
1 parent bfaf3b2 commit a2ed985
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 30 deletions.
79 changes: 55 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]



Expand Down
2 changes: 2 additions & 0 deletions docker/jvm.dock
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
19 changes: 13 additions & 6 deletions docker/start-hildr-node-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ then
fi
fi

if [ $LOG_LEVEL = "" ]
then
LOG_LEVEL="INFO"
fi

if [ $SYNC_MODE = "full" ]
then
exec java --enable-preview \
Expand All @@ -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 \
Expand All @@ -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

0 comments on commit a2ed985

Please sign in to comment.