Skip to content

Commit

Permalink
Improve readme, bump node, refactor start script
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryun1 committed Mar 18, 2024
1 parent 7aa96d9 commit 0198a8e
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM ghcr.io/intersectmbo/cardano-node:8.8.1-pre
FROM ghcr.io/intersectmbo/cardano-node:8.9.0
ENV CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
ENTRYPOINT ["/usr/local/bin/cardano-node", "run", "+RTS", "-N", "-A16m", "-qg", "-qb", "-RTS", "--topology", "/config/topology.json", "--database-path", "/data/db", "--socket-path", "/ipc/node.socket", "--host-addr", "0.0.0.0", "--port", "3001", "--config", "/config/config.json" ]
123 changes: 97 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# SanchoNet docker node 🤠

**Current version:** node `8.8.1-pre`
**Current version:** node `8.9.0`

A simple dockerized Cardano node setup, for SanchoNet testing.
Accompanied with a few helpful scripts for cardano-cli.
Expand All @@ -23,76 +23,137 @@ softwareupdate --install-rosetta

### Windows Prerequisites

WSL
Windows Subsystem for Linux.

https://learn.microsoft.com/en-us/windows/wsl/install

### Visual Studio Code

So we can more easily navigate directories.
- https://code.visualstudio.com/
[How to Install WSL on Windows](https://learn.microsoft.com/en-us/windows/wsl/install)

### `Docker`

Install docker desktop.
Install docker desktop for your operating system.
- https://docs.docker.com/engine/install/

If you are using Apple silicon make sure you have Rosetta enabled via Docker desktop settings.
If you are using Apple silicon (M1, M2, M3 processor) make sure you have Rosetta enabled via Docker desktop settings.

### Visual Studio Code

So we can more easily navigate directories, and inspect files.
- https://code.visualstudio.com/

## Setup Guide

1. Clone this repository.
### 1. Clone this repository.

You may want to make a nice place for this.
```zsh
You may want to make a nice folder/directory for this first.
```bash
git clone https://github.com/Ryun1/sancho-docker-node.git
```
3. Open the `sancho-docker-node` folder from inside of Visual Studio Code.

4. Open a terminal inside of VSCode and then add execute file provisions to the scripts.
### 2. Open `sancho-docker-node` from within Visual Studio Code.

Open Visual Studio Code and then go `File > Open Folder` selecting `sancho-docker-node` folder.

![Open Folder VS Code](images/setup-2.png)

### 3. Open a terminal in Visual Studio Code.

Open a terminal inside of VSCode.

![Open Terminal Console](images/setup-3.png)

### 4. Update script permissions.

Inside the terminal console, give scripts execute file permissions.

Windows users will have to run this first.
```bash
wsl
```

Fix file permissions.
Run the following command.
```zsh
chmod +x ./start-docker.sh ./stop-docker.sh ./scripts/*
```

5. Follow the [Usage section](#usage).
![Fix permissions](images/setup-4.png)

**Note:** Make sure your terminal shows the correct directory `sancho-docker-node`.

## Basic Usage
- Make sure you have docker desktop open and running.
- I have written a few useful bash scripts that you can use.

### Start Node
**Note:** Before any usage ensure you have docker desktop open and running.

This script:
### Start node

We have a script that:
- pulls the latest SanchoNet node configs
- pulls the Cardano node docker image
- builds and runs the Cardano node image
- pushes the Node logs to the terminal
- pushes the node logs to the terminal

In your terminal execute:
```bash
./start-docker.sh
```

If you want to stop the logs (but the node is still running) you can press `control + c`.

#### Check Node is running
This should look something like:

![Starting node](images/usage-start.png)

In a separate terminal to your running node, you can check its sync progress via this.
**Note:** The first time you do this the node will take a long time to synchronize to the network.

### Check node is running

#### 1. Open a new terminal

Press the plus plus at the top right of your terminal window.

![Open new terminal](./images/usage-check-1.png)

#### 2. Query tip of node.

In your second terminal execute:
```bash
./scripts/node-query-tip.sh
```

### Stop Node
For a fully synced node the terminal should return, with `syncProgress` of `100.00`.

```bash
{
"block": 1185368,
"epoch": 277,
"era": "Conway",
"hash": "13d654899faabb50522f7f608e8d627acaaa8206347c913b0e74754538754eb5",
"slot": 24011698,
"slotInEpoch": 78898,
"slotsToEpochEnd": 7502,
"syncProgress": "100.00"
}
```

For a un-fully synced node the terminal should return, with `syncProgress` of less than `100.00`.
You will have to wait till fully synced node before being able to interact with the network.

```bash
{
"block": 14646,
"epoch": 3,
"era": "Babbage",
"hash": "d72cb1cfb7f7eb9d457d48c0d3e165170565eb371f8f5c7cb3d6d212be97c797",
"slot": 292713,
"slotInEpoch": 33513,
"slotsToEpochEnd": 52887,
"syncProgress": "1.22"
}
```

### Stop node

This script will stop your Cardano node.

In your second terminal execute:
```bash
./stop-docker.sh
```
Expand Down Expand Up @@ -147,4 +208,14 @@ Make sure you have a node running for these.

```bash
./scripts/drep/drep-vote.sh
```
```

## Common Error Messages

### Docker desktop not open

```bash
Cannot connect to the Docker daemon at unix:///Users/ryan/.docker/run/docker.sock. Is the docker daemon running?
```

Fix: Open docker desktop
Binary file added images/setup-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/setup-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/setup-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/usage-check-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/usage-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 38 additions & 19 deletions start-docker.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
#!/bin/sh

# If no node config directory exists, create it
if [ ! -d ./node/config ]; then
mkdir -p ./node/config
# Set directory locations
node_dir="./node"
config_dir="$node_dir/config"
db_dir="$node_dir/db"
ipc_dir="$node_dir/ipc"

# Base URL for node config files
config_base_url="https://book.world.dev.cardano.org/environments/sanchonet/"

# Pull the latest node config files, put them inside the node/config directory

# Create db directory if it doesn't exist
if [ ! -d "$db_dir" ]; then
mkdir -p "$db_dir"
fi

# Pull the latest Node config files, put them inside the node/config directory
cd ./node/config
curl --silent -O -J -L https://book.world.dev.cardano.org/environments/sanchonet/config.json
curl --silent -O -J -L https://book.world.dev.cardano.org/environments/sanchonet/topology.json
curl --silent -O -J -L https://book.world.dev.cardano.org/environments/sanchonet/byron-genesis.json
curl --silent -O -J -L https://book.world.dev.cardano.org/environments/sanchonet/shelley-genesis.json
curl --silent -O -J -L https://book.world.dev.cardano.org/environments/sanchonet/alonzo-genesis.json
curl --silent -O -J -L https://book.world.dev.cardano.org/environments/sanchonet/conway-genesis.json
cd ..
cd ..

# If no node db directory exists, create it
if [ ! -d ./node/db ]; then
mkdir -p ./node/db
# Remove existing ipc directory if it exists and create a new one
if [ -d "$ipc_dir" ]; then
rm -rf "$ipc_dir"
fi
mkdir -p "$ipc_dir"

# Create config directory if it doesn't exist
if [ ! -d "$config_dir" ]; then
mkdir -p "$config_dir"
fi

# List of JSON files to download
config_files=(
"config.json"
"topology.json"
"byron-genesis.json"
"shelley-genesis.json"
"alonzo-genesis.json"
"conway-genesis.json"
)

# Remove any existing socket by overwriting it with an empty directory
mkdir -p ./node/config
# Change directory to the JSON directory and download files
cd "$config_dir" || exit
for file in "${config_files[@]}"; do
curl --silent -O -J -L "${config_base_url}${file}"
done

# Start the Docker container
docker-compose up -d --build
Expand Down

0 comments on commit 0198a8e

Please sign in to comment.