Skip to content

Commit

Permalink
Merge branch 'main' into feat/algod-node-install
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	cmd/root.go
#	cmd/root_test.go
#	cmd/status.go
#	internal/block.go
#	internal/block_test.go
#	internal/metrics.go
#	internal/state_test.go
#	ui/pages/accounts/model.go
#	ui/protocol.go
#	ui/protocol_test.go
#	ui/status.go
#	ui/status_test.go
  • Loading branch information
PhearZero committed Dec 9, 2024
2 parents 4f964cd + 386afe2 commit 4f30b6a
Show file tree
Hide file tree
Showing 76 changed files with 1,034 additions and 660 deletions.
2 changes: 1 addition & 1 deletion .docker/start_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [ -d "$ALGORAND_DATA" ]; then
algod -o -d "$ALGORAND_DATA" -l "0.0.0.0:8080"
else
sed -i "s/NUM_ROUNDS/${NUM_ROUNDS:-30000}/" "/node/run/template.json"
sed -i "s/\"NetworkName\": \"\"/\"NetworkName\": \"hack-tui\"/" "/node/run/template.json"
sed -i "s/\"NetworkName\": \"\"/\"NetworkName\": \"algorun-tui\"/" "/node/run/template.json"
goal network create --noclean -n tuinet -r "${ALGORAND_DATA}/.." -t "/node/run/template.json"

# Cycle Network
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/node_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
- name: Run Ubuntu commands
run: |
go build .
sudo ./hack-tui node install
sudo ./hack-tui node start
sudo ./algorun-tui node install
sudo ./algorun-tui node start
systemctl status algorand.service
export TOKEN=$(cat /var/lib/algorand/algod.admin.token)
curl http://localhost:8080/v2/participation -H "X-Algo-API-Token: $TOKEN" | grep "null"
sudo ./hack-tui node stop
sudo ./hack-tui node upgrade
# sudo ./hack-tui node configure
sudo ./hack-tui node uninstall
sudo ./algorun-tui node stop
sudo ./algorun-tui node upgrade
# sudo ./algorun-tui node configure
sudo ./algorun-tui node uninstall
macos:
runs-on: macos-latest
Expand All @@ -46,13 +46,13 @@ jobs:
- name: Run MacOs commands
run: |
go build .
sudo ./hack-tui node install
sudo ./hack-tui node start
sudo ./algorun-tui node install
sudo ./algorun-tui node start
sudo launchctl print system/com.algorand.algod
sleep 5
export TOKEN=$(cat ~/.algorand/algod.admin.token)
curl http://localhost:8080/v2/participation -H "X-Algo-API-Token: $TOKEN" | grep "null"
sudo ./hack-tui node stop
sudo ./hack-tui node upgrade
# sudo ./hack-tui node configure
sudo ./hack-tui node uninstall
sudo ./algorun-tui node stop
sudo ./algorun-tui node upgrade
# sudo ./algorun-tui node configure
sudo ./algorun-tui node uninstall
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
algorun-tui
coverage
hack-tui
bin
.data

Expand Down
23 changes: 16 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

A guide on how to contribute to this project.

# Getting Started
# Building

Clone the project

```bash
git clone git@github.com:algorandfoundation/hack-tui.git
git clone git@github.com:algorandfoundation/algorun-tui.git
```

Change to the directory

```bash
cd hack-tui
cd algorun-tui
```

Build the project
Expand All @@ -22,7 +22,8 @@ Build the project
make build
```

Running a Participation Node
Optionally, run a sandboxed participation node


```bash
docker compose up
Expand All @@ -31,12 +32,19 @@ docker compose up
Create a configuration file for the participation node in the root directory of the project (.algorun.yaml)

```yaml
server: http://localhost:8080
token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
algod-endpoint: http://localhost:8080
algod-token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```
Launch the TUI
> [!NOTE]
> If you skipped the docker container or config file, try running `./bin/algorun` standalone,
> which will detect your algorand data directory from the `ALGORAND_DATA` environment variable that works for `goal`.
> Otherwise, provide the `--algod-endpoint` and `--algod-token` arguments so that it can find your node.
> Note that algorun requires the admin algod token.

```bash
./bin/algorun
```
Expand All @@ -59,7 +67,7 @@ All submodules and endpoints **SHOULD** align with the command/ui namespaces.
Example Command:

```bash
hacktui status
algorun status
```

Example Structure
Expand Down Expand Up @@ -122,6 +130,7 @@ This package is the ViewModel and View in MVC.
# Generating RPC package

The `api` package is generated via [oapi-codegen](https://github.com/oapi-codegen/oapi-codegen).
This is only required when adding new or missing RPC interfaces from the algod specification.
Its configuration is found under `generate.yaml` and can be run with the following make command:

```bash
Expand Down
137 changes: 57 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# ⌨️ Hack-TUI
# ⌨️ AlgoRun-TUI

<div align="center">
<img alt="Terminal Render" src="/assets/Banner.gif" width="65%">
</div>

<div align="center">
<a target="_blank" href="https://github.com/algorandfoundation/hack-tui">
<img alt="CI Badge" src="https://img.shields.io/badge/CI-TODO-red"/>
<a target="_blank" href="https://github.com/algorandfoundation/algorun-tui/actions/workflows/test.yaml">
<img alt="CI Badge" src="https://github.com/algorandfoundation/algorun-tui/actions/workflows/test.yaml/badge.svg"/>
</a>
<a target="_blank" href="https://github.com/algorandfoundation/hack-tui">
<a target="_blank" href="https://github.com/algorandfoundation/algorun-tui">
<img alt="CD Badge" src="https://img.shields.io/badge/CD-TODO-red"/>
</a>
<a target="_blank" href="https://github.com/algorandfoundation/hack-tui/stargazers">
<img alt="Repository Stars Badge" src="https://img.shields.io/github/stars/algorandfoundation/hack-tui?color=7B1E7A&logo=star&style=flat" />
<a target="_blank" href="https://github.com/algorandfoundation/algorun-tui/stargazers">
<img alt="Repository Stars Badge" src="https://img.shields.io/github/stars/algorandfoundation/algorun-tui?color=7B1E7A&logo=star&style=flat" />
</a>
<img alt="Repository Visitors Badge" src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Falgorandfoundation%2Fhack-tui&countColor=%237B1E7A&style=flat" />
<img alt="Repository Visitors Badge" src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Falgorandfoundation%2Falgorun-tui&countColor=%237B1E7A&style=flat" />
</div>

---
Expand All @@ -27,117 +27,94 @@ Built with [bubbles](https://github.com/charmbracelet/bubbles) & [bubbletea](htt
# 🚀 Get Started

Run the build or ~~download the latest cli(WIP)~~.

> [!NOTE]
> We do not have pre-built binaries yet. If you are comfortable doing so, you are welcome to build it yourself and provide feedback.
## Building

1. Clone the repository
Download the latest release by running

```bash
git clone https://github.com/algorandfoundation/hack-tui.git
curl -fsSL https://raw.githubusercontent.com/algorandfoundation/algorun-tui/refs/heads/main/install.sh | bash
```

2. Change to the project directory
Launch the TUI by replacing the `<ENDPOINT>` and `<TOKEN>`
with your server in the following example

> [!IMPORTANT]
> TUI requires the *admin* token in order to access participation key information. This can be found in the `algod.admin.token` file, e.g. `/var/lib/algorand/algod.admin.token`
```bash
cd hack-tui
./algorun --algod-endpoint <ENDPOINT> --algod-token <TOKEN>
```

3. Run the build command
# ℹ️ Advanced Usage

```bash
make build
```
## 🧑‍💻 Commands

4. Start a participation node
The default command will launch the full TUI application

```bash
docker compose up
./algorun
```

> [!NOTE]
> The docker image is used for development and testing purposes. TUI will also work with native algod.
> If you have a node installed already, you can skip this step.
### Status

5. Connect to the node
Render only the status overview in the terminal

```bash
./bin/algorun --server http://localhost:8080 --token aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
./algorun status
```

> [!CAUTION]
> This project is in alpha state and under heavy development. We do not recommend performing actions (e.g. key management) on participation nodes connected to public networks.
> [!NOTE]
> If you skipped the docker container, try running `./bin/algorun` standalone, which will detect your algorand data directory from the `ALGORAND_DATA` environment variable that works for `goal`. Otherwise, provide the `--server` and `--token` arguments so that it can find your node. Note that algorun requires the admin algod token.
# ℹ️ Usage

## ⚙️ Configuration

Configuration is loaded in the following order:

1. Configuration file (.algorun.yaml)
1. Current Directory
2. Home Directory
3. /etc/algorun/
2. ENV Configuration
- ALGORUN\_\*
3. CLI Flag Arguments
4. ALGORAND_DATA parsing

This results in `ALGORAND_DATA` taking precedence in the loading order.

### .algorun.yaml
### Help

Example configuration file:
Display the usage information for the command

```yaml
server: "http://localhost:8080"
token: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
```bash
./algorun help
```
## ⚙️ Configuration

### Environment Variables
Configuration precedence takes place in the following order:

| Name | Example |
| -------------- | -------------------------------------------------------------------------------- |
| ALGORUN_SERVER | ALGORUN_SERVER="http://localhost:8080" |
| ALGORUN_TOKEN | ALGORUN_TOKEN="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
1. [ALGORAND_DATA Parsing](#algorand_data)
2. [Configuration File](#configuration-file)
3. [Environment Variables](#environment-variables)
4. [Command Line Flag Arguments](#flags)

### Flags

The application supports the `server` and `token` flags for configuration.
The application supports the `algod-endpoint` and `algod-token` flags for configuration.

```bash
algorun --server http://localhost:8080 --token aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
./algorun --algod-endpoint http://localhost:8080 --algod-token aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

> [!IMPORTANT]
> TUI requires the *admin* token in order to access participation key information. This can be found in the `algod.admin.token` file, e.g. `/var/lib/algorand/algod.admin.token`
### Configuration File

## 🧑‍💻 Commands
The configuration file is named `.algorun.yaml` and is loaded in the following order:

The default command will launch the full TUI application
1. Current Directory
2. Home Directory
3. /etc/algorun/

```bash
algorun
Example `.algorun.yaml` configuration file:

```yaml
algod-endpoint: "http://localhost:8080"
algod-token: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
```
### Status
### Environment Variables
Render only the status overview in the terminal
Environment variables can be set in order to override a configuration or ALGORAND_DATA setting
but cannot be used to override the command line arguments.
```bash
algorun status
```
The following are the additional ENV variables the TUI supports
### Help
| Name | Example |
|------------------------|----------------------------------------------------------------------------------------|
| ALGORUN_ALGOD-ENDPOINT | ALGORUN_ALGOD-ENDPOINT="http://localhost:8080" |
| ALGORUN_ALGOD-TOKEN | ALGORUN_ALGOD-TOKEN="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
Display the usage information for the command
### ALGORAND_DATA
The TUI searches the environment for an `ALGORAND_DATA` variable.
It then loads the `algod-token` and `algod-endpoint` values from
the algod data directory.

```bash
algorun help
```
2 changes: 1 addition & 1 deletion cmd/node/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package node

import (
"github.com/algorandfoundation/hack-tui/ui/style"
"github.com/algorandfoundation/algorun-tui/ui/style"
"github.com/spf13/cobra"
)

Expand Down
Loading

0 comments on commit 4f30b6a

Please sign in to comment.