Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .env.ink-sepolia
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
L1_RPC_URL="..."
L1_BEACON_URL="..."

GETH_DATADIR="/data" # Sets the directory for the Geth data
GETH_NETWORKID="763373" # Sets the network id
GETH_AUTHRPC_ADDR="0.0.0.0" # Sets the listening address for authenticated APIs
GETH_AUTHRPC_PORT="8551" # Sets the listening port for authenticated APIs
GETH_AUTHRPC_JWTSECRET="/var/secrets/jwt.txt" # Sets the path to a JWT secret for authenticated RPC endpoints
GETH_AUTHRPC_VHOSTS="*" # Sets the virtual hostnames from which to accept requests, accepts '*' wildcard
GETH_METRICS="true" # Enables metrics collection and reporting
GETH_METRICS_EXPENSIVE="false" # Disables expensive metrics collection and reporting
GETH_METRICS_ADDR="localhost" # Sets the metrics HTTP server listening interface
GETH_METRICS_PORT="6060" # Sets the metrics HTTP server listening port
GETH_GCMODE="archive" # Sets the blockchain garbage collection mode
GETH_SYNCMODE="full" # Sets the blockchain sync mode
GETH_MAXPEERS="0" # Disables the network by setting the maximum number of peers to 0
GETH_NODISCOVER="true" # Disables the peer discovery mechanism
GETH_HTTP="true" # Enables the HTTP-RPC server
GETH_HTTP_ADDR="0.0.0.0" # Sets the HTTP-RPC server listening interface
GETH_HTTP_PORT="8545" # Sets the HTTP-RPC server listening port
GETH_HTTP_VHOSTS="*" # Sets the virtual hostnames from which to accept requests, accepts '*' wildcard
GETH_HTTP_CORSDOMAIN="*" # Sets the domains from which to accept cross-origin requests
GETH_HTTP_API="web3,debug,eth,txpool,net,engine" # Sets the APIs offered over the HTTP-RPC interface
GETH_WS="true" # Enables the WS-RPC server
GETH_WS_ADDR="0.0.0.0" # Sets the WS-RPC server listening interface
GETH_WS_PORT="8546" # Sets the WS-RPC server listening port
GETH_WS_ORIGINS="*" # Sets the origins from which to accept websockets requests
GETH_WS_API="debug,eth,txpool,net,engine" # Sets the APIs offered over the WS-RPC interface
GETH_RPC_ALLOW_UNPROTECTED_TXS="false" # Disables unprotected (non EIP155 signed) transactions via RPC

OP_NODE_L1_ETH_RPC=$L1_RPC_URL
OP_NODE_L1_RPC_KIND="standard" # Sets the kind of RPC provider
OP_NODE_L2_ENGINE_AUTH="/var/secrets/jwt.txt" # Sets the path to the JWT secret key
OP_NODE_ROLLUP_LOAD_PROTOCOL_VERSIONS="true" # Enables loading of protocol versions from the superchain L1 ProtocolVersions contract
OP_NODE_ROLLUP_HALT="major" # Halts on incompatible protocol version requirements of the given level
OP_NODE_ROLLUP_CONFIG="/config/sepolia/rollup.json" # Sets the rollup chain parameters
OP_NODE_SEQUENCER_ENABLED="false" # Disables sequencing of new L2 blocks
OP_NODE_SEQUENCER_L1_CONFS="5" # Sets the number of L1 blocks to keep distance from the L1 head for picking an L1 origin
OP_NODE_VERIFIER_L1_CONFS="4" # Sets the number of L1 blocks to keep distance from the L1 head before deriving L2 data from
OP_NODE_LOG_FORMAT="json" # Sets the log output format
OP_NODE_LOG_LEVEL="info" # Sets the log level
OP_NODE_P2P_DISABLE="false" # Enables the P2P stack
OP_NODE_P2P_LISTEN_IP="0.0.0.0" # Sets the IP to bind LibP2P and Discv5 to
OP_NODE_P2P_LISTEN_TCP_PORT="9222" # Sets the TCP port to bind LibP2P to
OP_NODE_P2P_LISTEN_UDP_PORT="9222" # Sets the UDP port to bind Discv5 to
OP_NODE_P2P_PEER_SCORING="none" # Sets the peer scoring strategy to none
OP_NODE_P2P_PEER_BANNING="false" # Disables peer banning
OP_NODE_P2P_PEER_BANNING_DURATION="0h1m0s" # Sets the duration that peers are banned for
OP_NODE_P2P_BOOTNODES="enr:-Iu4QN7Ohk84lCZMSAbuPbU1vSMF93J7FUUab2_JBNX8q6wSPBeWrGu85ENsL-s2fcf9gvYc_Eiw8ZzdBzP5i05g9DwBgmlkgnY0gmlwhCP2ulGJc2VjcDI1NmsxoQLqBVn4RC7vvLvOB95odV2bp6zKCQHPw7j60wBG68qGJYN0Y3CCIyuDdWRwgiMs" # Sets the bootnodes for discovering other node records
OP_NODE_P2P_ADVERTISE_TCP="9003" # Sets the TCP port to advertise in Discv5
OP_NODE_P2P_ADVERTISE_UDP="9003" # Sets the UDP port to advertise in Discv5
# OP_NODE_P2P_ADVERTISE_IP="<EXTERNAL_P2P_IP>" # Sets the IP address to advertise in Discv5 (disabled locally)
OP_NODE_P2P_SYNC_REQ_RESP="true" # Enables P2P req-resp alternative sync method
OP_NODE_P2P_STATIC="/ip4/34.32.241.134/tcp/9003/p2p/16Uiu2HAmKx8zPiN5WrbDW8hVRnwVXzfYdpt6PpPU6s98t5WtCTx5" # Sets the static connections to make and maintain
OP_NODE_RPC_ADDR="0.0.0.0" # Sets the RPC listening address
OP_NODE_RPC_PORT="9545" # Sets the RPC listening port
OP_NODE_RPC_ENABLE_ADMIN="true" # Enables the admin API
OP_NODE_SNAPSHOT_LOG="/var/snapshot.log" # Sets the path to the snapshot log file
OP_NODE_METRICS_ENABLED="true" # Enables the metrics server
OP_NODE_METRICS_ADDR="0.0.0.0" # Sets the metrics listening address
OP_NODE_METRICS_PORT="7300" # Sets the metrics listening port
OP_NODE_PPROF_ENABLED="false" # Enables the pprof server
OP_NODE_L1_BEACON=$L1_BEACON_URL # Defines blob archive node
OP_NODE_L2_ENGINE_RPC=ws://op-geth:8551 # Sets the address of the L2 Engine JSON-RPC endpoint
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
jwt.txt
secrets
geth
**/.DS_Store
.env
var/snapshot.log
75 changes: 73 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# node
How to run an Ink Node
# Running an Ink Node 🐙

## Setup Instructions 🛠️

### Configuration ⚙️

To run the Ink node, it's required to bring your own L1 Sepolia Node. We suggest using [QuickNode](https://www.quicknode.com/) for this purpose.

Create a `.env` file in the root of the repository with the following environment variables, replacing `...` with your node's details:

```sh
L1_RPC_URL=...
L1_BEACON_URL=...
```

### Installation 📥

Run the setup script:

```
./setup.sh
```

### Execution 🚀

Start the Ink node using Docker Compose:

```sh
docker compose up # --build to force rebuild the images
```

## Verifying Sync Status 🔎

### op-node API 🌐

You can use the optimism_syncStatus method on the op-node API to know what’s the current status:

```sh
curl -X POST -H "Content-Type: application/json" --data \
'{"jsonrpc":"2.0","method":"optimism_syncStatus","params":[],"id":1}' \
http://localhost:9545 | jq
```

### op-geth API 🌐

When your local node is fully synced, calling the eth_blockNumber method on the op-geth API should return the latest block number as seen on the [block explorer](https://explorer-sepolia.inkonchain.com/).

```sh
curl http://localhost:8545 -X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params": [],"id":1}' | jq -r .result | sed 's/^0x//' | awk '{printf "%d\n", "0x" $0}';
```

### Comparing w/ Remote RPC 👀

Use this script to compare your local finalized block with the one retrieved from the Remote RPC:

```sh
local_block=$(curl -s -X POST http://localhost:8545 -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["finalized", false],"id":1}' \
| jq -r .result.number | sed 's/^0x//' | awk '{printf "%d\n", "0x" $0}'); \
remote_block=$(curl -s -X POST https://rpc-gel-sepolia.inkonchain.com/ -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["finalized", false],"id":1}' \
| jq -r .result.number | sed 's/^0x//' | awk '{printf "%d\n", "0x" $0}'); \
echo -e "Local finalized block: $local_block\nRemote finalized block: $remote_block"
```

The node is in sync when both the Local finalized block and Remote finalized block are equal. E.g.:

```
Local finalized block: 4449608
Remote finalized block: 4449608
```
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
op-geth: # this is Optimism's geth client
build:
context: .
dockerfile: op-geth/Dockerfile
ports:
- 8545:8545 # RPC
- 8546:8546 # websocket
- 30303:30303 # P2P TCP (currently unused)
- 30303:30303/udp # P2P UDP (currently unused)
- 7301:6060 # metrics
volumes:
- ./geth:/data:rw
- ./var:/var:rw
env_file:
- .env.ink-sepolia
user: "1000:1000"
environment:
- GETH_DATA_DIR=/data
op-node:
build:
context: .
dockerfile: op-node/Dockerfile
depends_on:
- op-geth
ports:
- 9545:9545 # RPC
- 9222:9222 # P2P TCP
- 9222:9222/udp # P2P UDP
- 7300:7300 # metrics
- 6060:6060 # pprof
volumes:
- ./var:/var:rw
env_file:
- .env.ink-sepolia
user: "1000:1000"
43 changes: 43 additions & 0 deletions op-geth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM golang:1.21 AS build-op-geth

WORKDIR /app

ENV REPO=https://github.com/ethereum-optimism/op-geth.git
ENV VERSION=v1.101315.3
# for verification:
ENV COMMIT=8af19cf20261c0b62f98cc27da3a268f542822ee

RUN git clone $REPO --branch $VERSION --single-branch . && \
git switch -c branch-$VERSION && \
bash -c '[ "$(git rev-parse HEAD)" = "$COMMIT" ]'

RUN go run build/ci.go install -static ./cmd/geth

FROM golang:1.21 AS run-op-geth

RUN apt-get update && \
apt-get install -y --no-install-recommends \
netcat-openbsd \
jq \
curl \
supervisor && \
rm -rf /var/lib/apt/lists/*

RUN mkdir -p /var/log/supervisor

# Create non-root user
RUN useradd -m -u 1000 -s /bin/bash opuser

WORKDIR /app

COPY --from=build-op-geth /app/build/bin/geth ./
COPY op-geth/config /config
COPY op-geth/entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh

# Set proper ownership
RUN chown -R opuser:opuser /app /var/log/supervisor

USER opuser

ENTRYPOINT [ "./entrypoint.sh" ]
Loading