Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/test-start-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
timeout-minutes: 10
run: |
set -euo pipefail
printf "2\n1\n" | ./start-node.sh 2>&1 | tee preprod_output.txt &
printf "1\n2\n1\n" | ./start-node.sh 2>&1 | tee preprod_output.txt &
START_PID=$!
sleep 30
if ! kill -0 $START_PID 2>/dev/null; then
Expand All @@ -65,7 +65,7 @@ jobs:
timeout-minutes: 3
run: |
set -euo pipefail
printf "3\n1\n" | ./start-node.sh 2>&1 | tee preview_output.txt &
printf "1\n3\n1\n" | ./start-node.sh 2>&1 | tee preview_output.txt &
START_PID=$!
sleep 30
if ! kill -0 $START_PID 2>/dev/null; then
Expand All @@ -92,7 +92,7 @@ jobs:
timeout-minutes: 3
run: |
set -euo pipefail
printf "4\n1\n" | ./start-node.sh 2>&1 | tee sancho_output.txt &
printf "1\n4\n1\n" | ./start-node.sh 2>&1 | tee sancho_output.txt &
START_PID=$!
sleep 30
if ! kill -0 $START_PID 2>/dev/null; then
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ txs/
dumps/
node/
secrets/
utilities/
node-*/
/scripts/poison
/scripts/poison/

# Python virtual environment
venv/
__pycache__/
*.pyc
*.pyc

# Config file (user-specific, example is tracked)
config/cardano-node-config.json
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,122 @@ Make sure you have a node running for these.
./scripts/drep/delegate-to-self.sh
```

## Using Multiple Nodes and External Nodes

This toolkit supports connecting to multiple Cardano nodes simultaneously - both Docker containers and external nodes running outside of Docker. You can run scripts against different networks and nodes at the same time.

### External Node Configuration

External nodes use environment variables `CARDANO_NODE_SOCKET_PATH` and `CARDANO_NODE_NETWORK_ID`. You can configure these through the `start-node.sh` script, which will prompt you for the values and confirm them before use.

**Important:** Only one external node connection is supported at a time. For multiple external nodes, switch environment variables between script executions.

#### Setting Up External Node

Use the `start-node.sh` script to configure:

```bash
./start-node.sh
# Select: "Configure connection to an external node via socket file"
# Enter socket path and network ID
# Confirm the values
```

Or set environment variables directly:

```bash
export CARDANO_NODE_SOCKET_PATH="/path/to/node.socket"
export CARDANO_NODE_NETWORK_ID=1 # 1=preprod, 2=preview, 4=sanchonet

# Run scripts
./scripts/query/tip.sh
```

#### Network Magic Numbers

- **preprod**: Network ID `1`
- **preview**: Network ID `2`
- **sanchonet**: Network ID `4`
- **mainnet**: Network ID `764824073` (blocked for external nodes)

### Docker Container Selection

Specify which Docker container to use:

```bash
# Use specific container
CARDANO_CONTAINER_NAME="node-preprod-10.5.3-container" ./scripts/query/tip.sh

# Use different container
CARDANO_CONTAINER_NAME="node-preview-10.5.3-container" ./scripts/query/tip.sh
```

### Multiple Docker Containers

When multiple Docker containers are running, the toolkit will:
- **Automatically select** the only container if only one is running
- **Prompt you to choose** if multiple containers are running (interactive mode)
- **Use the first container** if running non-interactively (no TTY)

To avoid prompts, specify the container name:

```bash
CARDANO_CONTAINER_NAME="node-preprod-10.5.3-container" ./scripts/query/tip.sh
```

### Single Node Configuration (Backward Compatible)

For backward compatibility, you can still use the old single-node format:

```json
{
"socket_path": "/path/to/your/node.socket",
"network": "preprod",
"network_id": 1,
"mode": "external"
}
```

### Requirements

- **Local cardano-cli**: When using external node mode, you must have `cardano-cli` installed locally and available in your PATH
- **Network restriction**: Mainnet connections via external sockets are **not allowed** for security reasons. Only testnet networks (preprod, preview, sanchonet) are supported
- **Socket file**: The socket file must be accessible and the node must be running

### Network Magic Numbers

- **preprod**: Network ID `1`
- **preview**: Network ID `2`
- **sanchonet**: Network ID `4`
- **mainnet**: Network ID `764824073` (blocked for external nodes, allowed in Docker mode)

### Example: Running Scripts Against Multiple Networks

```bash
# Terminal 1: Query preprod via external node
CARDANO_NODE_SOCKET_PATH="/path/to/preprod.socket" CARDANO_NODE_NETWORK_ID=1 ./scripts/query/tip.sh

# Terminal 2: Query preview via external node (switch env vars)
CARDANO_NODE_SOCKET_PATH="/path/to/preview.socket" CARDANO_NODE_NETWORK_ID=2 ./scripts/query/tip.sh

# Terminal 3: Use Docker container for mainnet
CARDANO_CONTAINER_NAME="node-mainnet-10.5.3-container" ./scripts/query/tip.sh
```

### Node Selection Priority

The toolkit uses the following priority order:

1. `CARDANO_NODE_SOCKET_PATH` + `CARDANO_NODE_NETWORK_ID` - External node (environment variables)
2. `CARDANO_CONTAINER_NAME` - Direct container name specification (for Docker mode)
3. Docker mode with container selection - Default fallback

**Note:** External nodes require both `CARDANO_NODE_SOCKET_PATH` and `CARDANO_NODE_NETWORK_ID` to be set. Use the `start-node.sh` script to configure and confirm these values.

### Version Check

When using external node mode, the toolkit will automatically check and display your local `cardano-cli` version and which node is being used. If `cardano-cli` is not found in PATH, you'll receive a warning.

## Common Error Messages

### Docker desktop application not open
Expand All @@ -247,3 +363,19 @@ Cannot connect to the Docker daemon at unix:///Users/XXXX/.docker/run/docker.soc
```

**Fix:** Open docker desktop

### Mainnet connection blocked

```bash
Error: Mainnet connections are not allowed. Please use testnet networks (preprod, preview, sanchonet) only.
```

**Fix:** This error appears when attempting to connect to mainnet via external socket. Use Docker mode for mainnet, or switch to a testnet network.

### cardano-cli not found

```bash
Warning: cardano-cli not found in PATH. External node mode requires cardano-cli to be installed locally.
```

**Fix:** Install `cardano-cli` locally and ensure it's in your PATH when using external node mode.
39 changes: 21 additions & 18 deletions scripts/cc/authorize-hot-key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,43 @@ tx_cert_path="$tx_path_stub.cert"
tx_unsigned_path="$tx_path_stub.unsigned"
tx_signed_path="$tx_path_stub.signed"

# Get the container name from the get-container script
container_name="$("$script_dir/../helper/get-container.sh")"

if [ -z "$container_name" ]; then
echo "Failed to determine a running container."
exit 1
fi

echo "Using running container: $container_name"

# Function to execute cardano-cli commands inside the container
container_cli() {
docker exec -ti $container_name cardano-cli "$@"
# Source the cardano-cli wrapper
source "$script_dir/../helper/cardano-cli-wrapper.sh"

# Helper function to get UTXO with validation
get_utxo() {
local address=$1
local utxo_output
utxo_output=$(cardano_cli conway query utxo --address "$address" --out-file /dev/stdout)
local utxo
utxo=$(echo "$utxo_output" | jq -r 'keys[0]')
if [ -z "$utxo" ] || [ "$utxo" = "null" ]; then
echo "Error: No UTXO found at address: $address" >&2
exit 1
fi
echo "$utxo"
}


echo "Authorizing hot key for the constitutional committee."

container_cli conway governance committee create-hot-key-authorization-certificate \
cardano_cli conway governance committee create-hot-key-authorization-certificate \
--cold-verification-key-file "$keys_dir/cc-cold.vkey" \
--hot-key-file "$keys_dir/cc-hot.vkey" \
--out-file "$tx_cert_path"

echo "Building transaction"

container_cli conway transaction build \
cardano_cli conway transaction build \
--witness-override 2 \
--tx-in $(container_cli conway query utxo --address $(cat "$keys_dir/payment.addr") --out-file /dev/stdout | jq -r 'keys[0]') \
--tx-in $(cardano_cli conway query utxo --address $(cat "$keys_dir/payment.addr") --out-file /dev/stdout | jq -r 'keys[0]') \
--change-address $(cat "$keys_dir/payment.addr") \
--certificate-file "$tx_cert_path" \
--out-file "$tx_unsigned_path"

echo "Signing transaction"

container_cli conway transaction sign \
cardano_cli conway transaction sign \
--tx-body-file "$tx_unsigned_path" \
--signing-key-file "$keys_dir/payment.skey" \
--signing-key-file "$keys_dir/cc-cold.skey" \
Expand All @@ -54,4 +57,4 @@ container_cli conway transaction sign \
# Submit the transaction
echo "Submitting transaction"

container_cli conway transaction submit --tx-file $tx_signed_path
cardano_cli conway transaction submit --tx-file $tx_signed_path
24 changes: 6 additions & 18 deletions scripts/cc/generate-cc-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,8 @@ project_root=$(cd "$script_dir/../.." && pwd)
# Define directory paths relative to project root
keys_dir="$project_root/keys"

# Get the container name from the get-container script
container_name="$("$script_dir/../helper/get-container.sh")"

if [ -z "$container_name" ]; then
echo "Failed to determine a running container."
exit 1
fi

echo "Using running container: $container_name"

# Function to execute cardano-cli commands inside the container
container_cli() {
docker exec -ti $container_name cardano-cli "$@"
}
# Source the cardano-cli wrapper
source "$script_dir/../helper/cardano-cli-wrapper.sh"

# Check if CC keys already exist
if [ -f "$keys_dir/cc-cold.vkey" ]; then
Expand All @@ -33,19 +21,19 @@ fi
echo "Generating constitutional committee hot and cold keys."

# Generate CC cold keys
container_cli conway governance committee key-gen-cold \
cardano_cli conway governance committee key-gen-cold \
--verification-key-file "$keys_dir/cc-cold.vkey" \
--signing-key-file "$keys_dir/cc-cold.skey"

# Generate CC hot keys
container_cli conway governance committee key-gen-hot \
cardano_cli conway governance committee key-gen-hot \
--verification-key-file "$keys_dir/cc-hot.vkey" \
--signing-key-file "$keys_dir/cc-hot.skey"

# Generate CC cold key hash
container_cli conway governance committee key-hash \
cardano_cli conway governance committee key-hash \
--verification-key-file "$keys_dir/cc-cold.vkey" > "$keys_dir/cc-cold-key-hash.hash"

# Generate CC hot key hash
container_cli conway governance committee key-hash \
cardano_cli conway governance committee key-hash \
--verification-key-file "$keys_dir/cc-hot.vkey" > "$keys_dir/cc-hot-key-hash.hash"
20 changes: 4 additions & 16 deletions scripts/cc/generate-new-hot-key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,17 @@ project_root=$(cd "$script_dir/../.." && pwd)
# Define directory paths relative to project root
keys_dir="$project_root/keys"

# Get the container name from the get-container script
container_name="$("$script_dir/../helper/get-container.sh")"

if [ -z "$container_name" ]; then
echo "Failed to determine a running container."
exit 1
fi

echo "Using running container: $container_name"

# Function to execute cardano-cli commands inside the container
container_cli() {
docker exec -ti $container_name cardano-cli "$@"
}
# Source the cardano-cli wrapper
source "$script_dir/../helper/cardano-cli-wrapper.sh"

# Generate hot CC keys
echo "Generating a new constitutional committee hot key (replacing the existing one)."

# Generate CC hot keys
container_cli conway governance committee key-gen-hot \
cardano_cli conway governance committee key-gen-hot \
--verification-key-file "$keys_dir/cc-hot.vkey" \
--signing-key-file "$keys_dir/cc-hot.skey"

# Generate CC hot key hash
container_cli conway governance committee key-hash \
cardano_cli conway governance committee key-hash \
--verification-key-file "$keys_dir/cc-hot.vkey" > "$keys_dir/cc-hot-key-hash.hash"
Loading