Skip to content

Commit

Permalink
Merge pull request #150 from algorandfoundation/v1.2.2
Browse files Browse the repository at this point in the history
v1.2.2 release
  • Loading branch information
tasosbit authored Feb 13, 2025
2 parents a4656eb + 37310d0 commit 5459822
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 26 deletions.
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 @@ var bootstrapCmd = &cobra.Command{
// 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)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -230,6 +230,6 @@ var bootstrapCmd = &cobra.Command{

}

return runTUI(RootCmd, dataDir, false)
return runTUI(RootCmd, dataDir, false, RootCmd.Version)
},
}
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 @@ var (
},
Run: func(cmd *cobra.Command, args []string) {
log.SetOutput(cmd.OutOrStdout())
err := runTUI(cmd, algodData, IncentivesDisabled)
err := runTUI(cmd, algodData, IncentivesDisabled, cmd.Version)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func Execute(version string, needsUpgrade bool) error {
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 {
if cmd == nil {
return fmt.Errorf("cmd is nil")
}
Expand All @@ -128,7 +128,7 @@ func runTUI(cmd *cobra.Command, dataDir string, incentivesFlag bool) error {
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)
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 @@ import (
// 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 @@ type StateModel struct {

// 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) {
// Preload the node status
status, response, err := NewStatus(ctx, client, httpPkg)
if err != nil {
Expand All @@ -79,6 +82,7 @@ func NewStateModel(ctx context.Context, client api.ClientWithResponsesInterface,
Admin: true,
Watching: true,

Version: version,
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 @@ func WithTitle(title string, view string) string {
}
return view
}
func WithTitles(leftText string, rightText string, view string) string {
if leftText == "" || rightText == "" {
return view
}

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

0 comments on commit 5459822

Please sign in to comment.