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
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ LDFLAGS = -X github.com/LumeraProtocol/supernode/supernode/cmd.Version=$(VERSION
-X github.com/LumeraProtocol/supernode/supernode/cmd.GitCommit=$(GIT_COMMIT) \
-X github.com/LumeraProtocol/supernode/supernode/cmd.BuildTime=$(BUILD_TIME)

# Development build
build:
go build -ldflags "$(LDFLAGS)" -o supernode ./supernode

# Release build (matches GitHub workflow)
build-release:
@mkdir -p release
CGO_ENABLED=1 \
GOOS=linux \
Expand All @@ -27,15 +22,12 @@ build-release:
./supernode
@chmod +x release/supernode-linux-amd64

# Run unit tests (regular tests with code)
test-unit:
go test -v ./...

# Run integration tests
test-integration:
go test -v -p 1 -count=1 -tags=integration ./...

# Run system tests
test-system:
cd tests/system && go test -tags=system_test -v .

Expand Down
271 changes: 126 additions & 145 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,168 +2,188 @@

Lumera Supernode is a companion application for Lumera validators who want to provide cascade, sense, and other services to earn rewards.

## Prerequisites
## gRPC API

Before installing and running the Lumera Supernode, ensure you have the following prerequisites installed:
The supernode exposes two main gRPC services:

### Install Build Essentials
### SupernodeService

```bash
# Ubuntu/Debian
sudo apt update
sudo apt install build-essential
```

### Enable CGO
Provides system status and monitoring information.

CGO must be enabled for the supernode to compile and run properly. Set the environment variable:

```bash
export CGO_ENABLED=1
**Service Definition:**
```protobuf
service SupernodeService {
rpc GetStatus(StatusRequest) returns (StatusResponse);
}
```

To make this permanent, add it to your shell profile:
**StatusResponse includes:**
- `CPU` - CPU usage and remaining capacity
- `Memory` - Total, used, available memory and usage percentage
- `ServiceTasks` - Task information for each active service
- `available_services` - List of available service names

```bash
echo 'export CGO_ENABLED=1' >> ~/.bashrc
source ~/.bashrc
```

## Installation
### CascadeService

### 1. Download the Binary
Handles cascade operations for data storage and retrieval.

Download the latest release from GitHub:
**Service Definition:**
```protobuf
service CascadeService {
rpc Register (stream RegisterRequest) returns (stream RegisterResponse);
rpc Download (DownloadRequest) returns (stream DownloadResponse);
}
```

### 2. Create Configuration File
**Register Operation:**
```protobuf
message RegisterRequest {
oneof request_type {
DataChunk chunk = 1;
Metadata metadata = 2;
}
}

Create a `config.yml` file in your base directory (default: `~/.supernode/config.yml`):
message DataChunk {
bytes data = 1;
}

```yaml
# Supernode Configuration
supernode:
key_name: "mykey" # The name you'll use when creating your key
identity: "" # The address you get back after getting the key
ip_address: "0.0.0.0"
port: 4444
message Metadata {
string task_id = 1;
string action_id = 2;
}

# Keyring Configuration
keyring:
backend: "test" # Options: test, file, os
dir: "keys"
message RegisterResponse {
SupernodeEventType event_type = 1;
string message = 2;
string tx_hash = 3;
}
```

# P2P Network Configuration
p2p:
listen_address: "0.0.0.0"
port: 4445
data_dir: "data/p2p"
**Download Operation:**
```protobuf
message DownloadRequest {
string action_id = 1;
string signature = 2;
}

# Lumera Chain Configuration
lumera:
grpc_addr: "localhost:9090"
chain_id: "lumera"
message DownloadResponse {
oneof response_type {
DownloadEvent event = 1;
DataChunk chunk = 2;
}
}

# RaptorQ Configuration
raptorq:
files_dir: "raptorq_files"
message DownloadEvent {
SupernodeEventType event_type = 1;
string message = 2;
}
```

## Initialization and Key Management
**Event Types:**
- `ACTION_RETRIEVED`, `ACTION_FEE_VERIFIED`, `TOP_SUPERNODE_CHECK_PASSED`
- `METADATA_DECODED`, `DATA_HASH_VERIFIED`, `INPUT_ENCODED`
- `SIGNATURE_VERIFIED`, `RQID_GENERATED`, `RQID_VERIFIED`
- `ARTEFACTS_STORED`, `ACTION_FINALIZED`, `ARTEFACTS_DOWNLOADED`

### Initialize a Supernode
## CLI Commands

The easiest way to set up a supernode is to use the `init` command, which creates a configuration file and sets up keys in one step:
### Core Commands

#### `supernode init`
Initialize a new supernode with interactive setup.

```bash
supernode init mykey --chain-id lumera
supernode init # Interactive setup
supernode init --force # Override existing installation
supernode init -y # Use defaults, skip prompts
supernode init --keyring-backend test # Specify keyring backend with -y
```

This will:
1. Create a `config.yml` file in your base directory (default: `~/.supernode/config.yml`)
2. Generate a new key with the specified name
3. Update the configuration with the key's address
4. Output the key information, including the mnemonic
**Features:**
- Creates `~/.supernode/config.yml`
- Sets up keyring (test, file, or os backend)
- Key recovery from mnemonic or generates new key
- Network configuration (gRPC address, ports, chain ID)

To recover an existing key during initialization:
#### `supernode start`
Start the supernode service.

```bash
supernode init mykey --recover --mnemonic "your mnemonic words here" --chain-id lumera
supernode start # Use default config directory
supernode start -d /path/to/dir # Use custom base directory
```

Additional options:
```bash
# Use a specific keyring backend
supernode init mykey --keyring-backend file --chain-id lumera
**Initializes:**
- P2P networking service
- gRPC server (default port 4444)
- Cascade service for data operations
- Connection to Lumera validator node

# Use a custom keyring directory
supernode init mykey --keyring-dir /path/to/keys --chain-id lumera
#### `supernode version`
Display version information.

# Use a custom base directory
supernode init -d /path/to/basedir mykey --chain-id lumera
```bash
supernode version
```

### Manual Key Management

If you prefer to manage keys manually, you can use the following commands:

#### Create a New Key
### Key Management

Create a new key (use the same name you specified in your config):
#### `supernode keys list`
List all keys in the keyring with addresses.

```bash
supernode keys add mykey
supernode keys list
```

This will output an address like:
**Output format:**
```
lumera15t2e8gjgmuqtj4jzjqfkf3tf5l8vqw69hmrzmr
NAME ADDRESS
---- -------
mykey (selected) lumera15t2e8gjgmuqtj4jzjqfkf3tf5l8vqw69hmrzmr
backup lumera1abc...xyz
```

#### Recover an Existing Key
#### `supernode keys add <name>`
Create a new key (generates mnemonic).

If you have an existing mnemonic phrase:
#### `supernode keys recover <name>`
Recover key from existing mnemonic phrase.

```bash
supernode keys recover mykey <MNEMONIC> # Use quotes if the mnemonic contains spaces, e.g., "word1 word2 word3"
```
### Configuration Management

#### List Keys
#### `supernode config list`
Display current configuration parameters.

```bash
supernode keys list
supernode config list
```

#### Update Configuration with Your Address
**Shows:**
- Key Name, Address, Supernode Address/Port
- Keyring Backend, Lumera gRPC Address, Chain ID

⚠️ **IMPORTANT:** After manually generating or recovering a key, you MUST update your `config.yml` with the generated address:
#### `supernode config update`
Interactive configuration parameter updates.

```yaml
supernode:
key_name: "mykey"
identity: "lumera15t2e8gjgmuqtj4jzjqfkf3tf5l8vqw69hmrzmr" # Your actual address
ip_address: "0.0.0.0"
port: 4444
# ... rest of config
```bash
supernode config update
```

Note: This step is done automatically when using the `init` command.
**Updatable parameters:**
- Supernode IP Address and Port
- Lumera gRPC Address and Chain ID
- Key Name (with key selection from keyring)
- Keyring Backend (with key migration)

## Running the Supernode
### Global Flags

### Start the Supernode
#### `--basedir, -d`
Specify custom base directory (default: `~/.supernode`).

```bash
supernode start
```

### Using Custom Configuration

```bash
# Use specific config file
supernode start -c /path/to/config.yml

# Use custom base directory
supernode start -d /path/to/basedir
supernode start -d /custom/path
supernode config list -d /custom/path
```

## Configuration Parameters
Expand All @@ -182,42 +202,3 @@ supernode start -d /path/to/basedir
| `lumera.grpc_addr` | gRPC endpoint of Lumera validator node | **Yes** | - | `"localhost:9090"` | Must be accessible from supernode |
| `lumera.chain_id` | Lumera blockchain chain identifier | **Yes** | - | `"lumera"` | Must match the actual chain ID |
| `raptorq.files_dir` | Directory to store RaptorQ files | No | `"raptorq_files"` | `"raptorq_files"` | Relative paths are appended to basedir, absolute paths used as-is |

## Command Line Flags

The supernode binary supports the following command-line flags:

| Flag | Short | Description | Value Type | Example | Default |
|------|-------|-------------|------------|---------|---------|
| `--config` | `-c` | Path to configuration file | String | `-c /path/to/config.yml` | `config.yml` in basedir (`~/.supernode/config.yml`) |
| `--basedir` | `-d` | Base directory for data storage | String | `-d /custom/path` | `~/.supernode` |

### Usage Examples

```bash
# Use default config.yml in basedir (~/.supernode/config.yml), with ~/.supernode as basedir
supernode start

# Use custom config file
supernode start -c /etc/supernode/config.yml
supernode start --config /etc/supernode/config.yml

# Use custom base directory
supernode start -d /opt/supernode
supernode start --basedir /opt/supernode

# Combine flags
supernode start -c /etc/supernode/config.yml -d /opt/supernode
```

⚠️ **CRITICAL: Consistent Flag Usage Across Commands**

If you use custom flags (`--config` or `--basedir`) for key management operations, you **MUST** use the same flags for ALL subsequent commands, including the `start` command. Otherwise, your configuration will break and keys will not be found.

### Additional Important Notes:

- Make sure you have sufficient balance in your Lumera account to broadcast transactions
- The P2P port (4445) should not be changed from the default
- Your `key_name` in the config must match the name you used when creating the key
- Your `identity` in the config must match the address generated for your key
- Ensure your Lumera validator node is running and accessible at the configured gRPC address
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
Expand Down Expand Up @@ -127,6 +128,7 @@ require (
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
Expand All @@ -135,6 +137,7 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand Down
Loading