Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.2 release #150

Merged
merged 8 commits into from
Feb 13, 2025
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
4 changes: 2 additions & 2 deletions cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
// Execute the TUI if we are caught up.
// TODO: check the delta to see if it is necessary,
if resp.JSON200.CatchupTime == 0 {
err = runTUI(RootCmd, dir, false)
err = runTUI(RootCmd, dir, false, RootCmd.Version)

Check warning on line 92 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L92

Added line #L92 was not covered by tests
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -230,6 +230,6 @@

}

return runTUI(RootCmd, dataDir, false)
return runTUI(RootCmd, dataDir, false, RootCmd.Version)

Check warning on line 233 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L233

Added line #L233 was not covered by tests
},
}
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
Run: func(cmd *cobra.Command, args []string) {
log.SetOutput(cmd.OutOrStdout())
err := runTUI(cmd, algodData, IncentivesDisabled)
err := runTUI(cmd, algodData, IncentivesDisabled, cmd.Version)

Check warning on line 59 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L59

Added line #L59 was not covered by tests
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -116,7 +116,7 @@
return RootCmd.Execute()
}

func runTUI(cmd *cobra.Command, dataDir string, incentivesFlag bool) error {
func runTUI(cmd *cobra.Command, dataDir string, incentivesFlag bool, version string) error {

Check warning on line 119 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L119

Added line #L119 was not covered by tests
if cmd == nil {
return fmt.Errorf("cmd is nil")
}
Expand All @@ -128,7 +128,7 @@
cobra.CheckErr(err)

// Fetch the state and handle any creation errors
state, stateResponse, err := algod.NewStateModel(ctx, client, httpPkg, incentivesFlag)
state, stateResponse, err := algod.NewStateModel(ctx, client, httpPkg, incentivesFlag, version)

Check warning on line 131 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L131

Added line #L131 was not covered by tests
utils.WithInvalidResponsesExplanations(err, stateResponse, cmd.UsageString())
cobra.CheckErr(err)

Expand Down
15 changes: 10 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ prompt_default_no() {

if [ -f nodekit ]; then
warn "A nodekit file already exists in the current directory."
if prompt_default_no "Do you want to upgrade it to the latest nodekit?"; then
# Set the NODEKIT_FORCE_INSTALL environment variable to anything in order to force upgrading nodekit without prompting
if [[ -n "${NODEKIT_FORCE_INSTALL-}" ]] || prompt_default_no "Do you want to upgrade it to the latest nodekit?"; then
rm nodekit
else
info "Not upgrading nodekit.\n\nYou can run nodekit with:\n\n./nodekit\n\nOr start the installer with:\n\n./nodekit bootstrap"
Expand Down Expand Up @@ -103,8 +104,12 @@ trap - exit
success "Downloaded: ${Bold_Green}${target} as nodekit 🎉${Reset}"
info "Explore all nodekit options with:"
echo "./nodekit --help"
echo ""
info "Starting nodekit bootstrap"
echo "./nodekit bootstrap"

./nodekit bootstrap
# Set the NODEKIT_SKIP_BOOTSTRAP environment variable to anything in order to skip bootstrap
# Useful for non-interactive setup
if [[ -z "${NODEKIT_SKIP_BOOTSTRAP-}" ]]; then
echo ""
info "Starting nodekit bootstrap"
echo "./nodekit bootstrap"
./nodekit bootstrap
fi
11 changes: 6 additions & 5 deletions internal/algod/mac/mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ import (
"bytes"
"errors"
"fmt"
"github.com/algorandfoundation/nodekit/internal/algod/utils"
"github.com/algorandfoundation/nodekit/internal/system"
"github.com/charmbracelet/log"
"github.com/spf13/cobra"
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
"strings"
"text/template"

"github.com/algorandfoundation/nodekit/internal/algod/utils"
"github.com/algorandfoundation/nodekit/internal/system"
"github.com/charmbracelet/log"
"github.com/spf13/cobra"
)

// MustBeServiceMsg is an error message indicating that a service must be installed to manage it.
const MustBeServiceMsg = "service must be installed to be able to manage it"

// HomeBrewNotFoundMsg is the error message returned when Homebrew is not detected on the system during execution.
const HomeBrewNotFoundMsg = "homebrew is not installed. please install Homebrew and try again"
const HomeBrewNotFoundMsg = "brew not found. please go to https://brew.sh to install Homebrew before trying again"

// IsService check if Algorand service has been created with launchd (macOS)
// Note that it needs to be run in super-user privilege mode to
Expand Down
6 changes: 5 additions & 1 deletion internal/algod/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// including status, metrics, accounts, keys, and other configurations.
type StateModel struct {

// Version indicates the version of the application.
Version string

// Status represents the current status of the algod node,
// including network state and round information.
Status Status
Expand Down Expand Up @@ -56,7 +59,7 @@

// NewStateModel initializes and returns a new StateModel instance
// along with an API response and potential error.
func NewStateModel(ctx context.Context, client api.ClientWithResponsesInterface, httpPkg api.HttpPkgInterface, incentivesDisabled bool) (*StateModel, api.ResponseInterface, error) {
func NewStateModel(ctx context.Context, client api.ClientWithResponsesInterface, httpPkg api.HttpPkgInterface, incentivesDisabled bool, version string) (*StateModel, api.ResponseInterface, error) {

Check warning on line 62 in internal/algod/state.go

View check run for this annotation

Codecov / codecov/patch

internal/algod/state.go#L62

Added line #L62 was not covered by tests
// Preload the node status
status, response, err := NewStatus(ctx, client, httpPkg)
if err != nil {
Expand All @@ -79,6 +82,7 @@
Admin: true,
Watching: true,

Version: version,

Check warning on line 85 in internal/algod/state.go

View check run for this annotation

Codecov / codecov/patch

internal/algod/state.go#L85

Added line #L85 was not covered by tests
Client: client,
HttpPkg: httpPkg,
Context: ctx,
Expand Down
1 change: 1 addition & 0 deletions ui/internal/test/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

func GetState(client api.ClientWithResponsesInterface) *algod.StateModel {
sm := &algod.StateModel{
Version: "vTest",
Status: algod.Status{
State: algod.StableState,
Version: "v-test",
Expand Down
2 changes: 1 addition & 1 deletion ui/modals/transaction/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (m ViewModel) FormatedAddress() string {
}

func (m ViewModel) IsQREnabled() bool {
return m.State.Status.Network == "testnet-v1.0" // || m.State.Status.Network == "mainnet-v1.0"
return m.State.Status.Network == "testnet-v1.0" || m.State.Status.Network == "mainnet-v1.0"
}

// New creates and instance of the ViewModel with a default controls.Model
Expand Down
21 changes: 13 additions & 8 deletions ui/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ func (m StatusViewModel) View() string {

row3 := lipgloss.JoinHorizontal(lipgloss.Left, beginning, middle, end)

return style.WithTitle("Status", style.ApplyBorder(max(0, size-2), 5, "5").Render(
lipgloss.JoinVertical(lipgloss.Left,
row1,
"",
style.Cyan.Render(" -- "+strconv.Itoa(m.Data.Metrics.Window)+" round average --"),
row2,
row3,
)))
return style.WithTitles(
"( "+style.Red.Render(fmt.Sprintf("Nodekit-%s", m.Data.Version))+" )",
lipgloss.NewStyle().Foreground(lipgloss.Color("5")).Render("Status"),
style.ApplyBorder(max(0, size-2), 5, "5").Render(
lipgloss.JoinVertical(lipgloss.Left,
row1,
"",
style.Cyan.Render(" -- "+strconv.Itoa(m.Data.Metrics.Window)+" round average --"),
row2,
row3,
),
),
)
}

// MakeStatusViewModel constructs the model to be used in a tea.Program
Expand Down
3 changes: 3 additions & 0 deletions ui/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
var statusViewSnapshots = map[string]StatusViewModel{
"Syncing": {
Data: &algod.StateModel{
Version: "v0.0.0-test",
Status: algod.Status{
LastRound: 1337,
NeedsUpdate: true,
Expand All @@ -31,6 +32,7 @@ var statusViewSnapshots = map[string]StatusViewModel{
},
"Hidden": {
Data: &algod.StateModel{
Version: "v0.0.0-test",
Status: algod.Status{
LastRound: 1337,
NeedsUpdate: true,
Expand All @@ -47,6 +49,7 @@ var statusViewSnapshots = map[string]StatusViewModel{
},
"Loading": {
Data: &algod.StateModel{
Version: "v0.0.0-test",
Status: algod.Status{
LastRound: 1337,
NeedsUpdate: true,
Expand Down
24 changes: 24 additions & 0 deletions ui/style/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@
}
return view
}
func WithTitles(leftText string, rightText string, view string) string {
if leftText == "" || rightText == "" {
return view
}

Check warning on line 65 in ui/style/style.go

View check run for this annotation

Codecov / codecov/patch

ui/style/style.go#L64-L65

Added lines #L64 - L65 were not covered by tests

pad := 4
controlWidth := lipgloss.Width(leftText) + lipgloss.Width(rightText)

lines := strings.Split(view, "\n")

if lipgloss.Width(view) >= controlWidth+(2*pad) {
line := lines[0]
lineWidth := lipgloss.Width(line)
lineLeft := ansi.Truncate(line, pad, "") + leftText
lineRight := rightText + TruncateLeft(line, lineWidth-pad)

midTemplate := TruncateLeft(line, pad)
midLen := lineWidth - lipgloss.Width(lineLeft) - lipgloss.Width(lineRight)
midLine := ansi.Truncate(midTemplate, midLen, "")
lines[0] = lineLeft + midLine + lineRight
}
return strings.Join(lines, "\n")
}

func WithControls(nav string, view string) string {
if nav == "" {
return view
Expand Down
2 changes: 1 addition & 1 deletion ui/testdata/Test_StatusSnapshot/Syncing.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
╭──Status────────────────────────────────────────────────────────────────────────────────╮
╭───( Nodekit-v0.0.0-test )─────────────────────────────────────────────────────Status───╮
│ Latest Round: 1337 SYNCING │
│ │
│ -- 0 round average -- │
Expand Down
13 changes: 13 additions & 0 deletions unattended.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# Install nodekit, replacing any previous nodekit (FORCE_INSTALL) and skipping the interactive bootstrap
wget -qO- https://nodekit.run/install.sh | NODEKIT_FORCE_INSTALL=1 NODEKIT_SKIP_BOOTSTRAP=1 bash

# Install node
./nodekit install -f

# Wait a bit for connections to be established
sleep 2m

# Start a fast catchup
./nodekit catchup start