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.0 #129

Merged
merged 46 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6a4a566
fix: add update for brew and restart after upgrade
PhearZero Jan 16, 2025
21b6db5
chore: skip questions when already bootstrapped
PhearZero Jan 16, 2025
a5c990d
fix: improve command error handling
PhearZero Jan 16, 2025
7acadc2
chore: improve active key detection
PhearZero Jan 17, 2025
85a8ff1
Fix: participation key rendering from base64url to base64
Jan 17, 2025
5293b76
chore: disable nodekit upgrade prompts for dev versions
Jan 20, 2025
82ff662
feat: enable incentive eligibility fees
Jan 20, 2025
ed68da4
Merge pull request #113 from algorandfoundation/chore/improve-active-…
PhearZero Jan 20, 2025
34e5df1
Merge pull request #101 from algorandfoundation/fix/upgrade-brew
PhearZero Jan 20, 2025
3186d49
Merge pull request #116 from algorandfoundation/chore/disable-nodekit…
PhearZero Jan 20, 2025
8354c39
Merge pull request #114 from algorandfoundation/fix/keys-view-base64-…
PhearZero Jan 20, 2025
443b633
Merge pull request #119 from algorandfoundation/feat/enable-incentive…
tasosbit Jan 21, 2025
ee0d5a3
feat: add disk space information to debug command
Jan 21, 2025
0fb02c2
feat: add nodekit version to debug command
Jan 21, 2025
a808fe2
Merge pull request #107 from algorandfoundation/feat/improved-error-r…
PhearZero Jan 21, 2025
96999f4
Merge branch 'v1.2.0' into chore/bootstrap-offer-fast-catchup-conditi…
PhearZero Jan 21, 2025
84b2494
Merge pull request #103 from algorandfoundation/chore/bootstrap-offer…
PhearZero Jan 21, 2025
2076624
Merge pull request #123 from algorandfoundation/feat/debug-show-disk-…
PhearZero Jan 21, 2025
45d5371
chore: Changed doc link on landing page to redirect to new dev portal
larkiny Jan 21, 2025
41d034f
Merge pull request #122 from larkiny/chore/update-docs-link
tasosbit Jan 22, 2025
f55b6ce
chore: disable nodekit upgrade prompts for dev versions
Jan 20, 2025
97e2a30
Fix: participation key rendering from base64url to base64
Jan 17, 2025
6ab2f93
feat: enable incentive eligibility fees
Jan 20, 2025
f9665a2
fix: transaction modal support non-resident keys & warn. chore: change
Jan 21, 2025
184d383
fix: accounts golden test
Jan 22, 2025
41c65e2
Merge branch 'v1.2.0' into feat/accounts-page-add-incentive-eligibility
Jan 22, 2025
0dc563e
fix: wait for status from unstable clients
PhearZero Jan 21, 2025
a3421bc
Merge pull request #125 from algorandfoundation/fix/boostrap-handle-u…
PhearZero Jan 22, 2025
2d00496
Fix: Support suspended accounts and re-registering
Jan 22, 2025
28732d2
feat: toggle between QRCode and deep-link
PhearZero Jan 22, 2025
10551b1
test: skip tests
PhearZero Jan 22, 2025
c2a483f
Merge pull request #124 from algorandfoundation/feat/accounts-page-ad…
PhearZero Jan 22, 2025
90b769d
Merge pull request #130 from algorandfoundation/feat/separate-views-i…
PhearZero Jan 22, 2025
1fd6c9f
fix: remove active from SetSuspended
PhearZero Jan 22, 2025
fe79792
Fix: nil pointer dereference when adding new accounts
Jan 22, 2025
0c5afba
docs: regenerate reference
PhearZero Jan 23, 2025
d87ce8c
fix: deterministic state while detecting corrupt keys
PhearZero Jan 23, 2025
aaf752c
Merge pull request #133 from algorandfoundation/fix/finding
PhearZero Jan 23, 2025
75c883f
Merge pull request #132 from algorandfoundation/fix/incentive-logic-n…
PhearZero Jan 23, 2025
f497b8c
fix: nil pointer exception bug in HasChanged
Jan 23, 2025
d578711
fix: suspended state also being unset
Jan 23, 2025
b77b24b
Merge pull request #134 from algorandfoundation/fix/pointer-bug-HasCh…
PhearZero Jan 23, 2025
1270a4f
fix: restore QR network check
Jan 23, 2025
98070da
fix: keyreg offline detection
Jan 23, 2025
2b85877
set active to false for offline keyreg
PhearZero Jan 23, 2025
f852911
Merge pull request #135 from algorandfoundation/fix/keyreg-offline-de…
PhearZero Jan 23, 2025
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ nodekit [flags]
```
-d, --datadir string Data directory for the node
-h, --help help for nodekit
-n, --no-incentives Disable setting incentive eligibility fees
```

### SEE ALSO
Expand All @@ -39,7 +40,7 @@ nodekit [flags]
* [nodekit uninstall](/man/nodekit_uninstall.md) - Uninstall the node daemon
* [nodekit upgrade](/man/nodekit_upgrade.md) - Upgrade the node daemon

###### Auto generated by spf13/cobra on 7-Jan-2025
###### Auto generated by spf13/cobra on 22-Jan-2025

### Installing

Expand Down
144 changes: 89 additions & 55 deletions cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
"time"

"github.com/algorandfoundation/nodekit/api"
cmdutils "github.com/algorandfoundation/nodekit/cmd/utils"
"github.com/algorandfoundation/nodekit/cmd/utils/explanations"
"github.com/algorandfoundation/nodekit/internal/algod"
"github.com/algorandfoundation/nodekit/internal/algod/utils"
"github.com/algorandfoundation/nodekit/internal/system"
"github.com/algorandfoundation/nodekit/ui"
"github.com/algorandfoundation/nodekit/ui/app"
"github.com/algorandfoundation/nodekit/ui/bootstrap"
"github.com/algorandfoundation/nodekit/ui/style"
Expand All @@ -22,6 +19,11 @@
"github.com/spf13/cobra"
)

const CheckAlgodInterval = 10 * time.Second
const CheckAlgodTimeout = 2 * time.Minute

var CatchpointLagThreshold int = 30_000

// bootstrapCmdShort provides a brief description of the "bootstrap" command to initialize a fresh Algorand node.
var bootstrapCmdShort = "Initialize a fresh node"

Expand All @@ -45,13 +47,56 @@

`

var FailedToAutoStartMessage = "Failed to start Algorand automatically."

// bootstrapCmd defines the "debug" command used to display diagnostic information for developers, including debug data.
var bootstrapCmd = &cobra.Command{
Use: "bootstrap",
Short: bootstrapCmdShort,
Long: bootstrapCmdLong,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
var client *api.ClientWithResponses
// Create the Bootstrap TUI
model := bootstrap.NewModel()
log.Warn(style.Yellow.Render(explanations.SudoWarningMsg))
// Try to launch the TUI if it's already running and configured
if algod.IsInitialized() {
// Parse the data directory
dir, err := algod.GetDataDir("")
if err != nil {
log.Fatal(err)
}

Check warning on line 69 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L59-L69

Added lines #L59 - L69 were not covered by tests

// Wait for the client to respond
log.Warn(style.Yellow.Render("Waiting for the node to start..."))
client, err = algod.WaitForClient(context.Background(), dir, CheckAlgodInterval, CheckAlgodTimeout)
if err != nil {
log.Fatal(err)
}

Check warning on line 76 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L72-L76

Added lines #L72 - L76 were not covered by tests

// Fetch the latest status
var resp *api.GetStatusResponse
resp, err = client.GetStatusWithResponse(context.Background())
// This should not happen, we waited for a status already
if err != nil {
log.Fatal(err)
}
if resp.StatusCode() != 200 {
log.Fatal(fmt.Sprintf("Failed to connect to the node at %s", dir))
}

Check warning on line 87 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L79-L87

Added lines #L79 - L87 were not covered by tests

// 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)
if err != nil {
log.Fatal(err)
}
return nil

Check warning on line 96 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L91-L96

Added lines #L91 - L96 were not covered by tests
}
}

// Exit the application in an invalid state
if algod.IsInstalled() && !algod.IsService() {
dataDir, _ := algod.GetDataDir("")
Expand All @@ -63,8 +108,7 @@
log.Fatal("invalid state, exiting")
}

ctx := context.Background()
httpPkg := new(api.HttpPkg)
// Render the welcome text
r, _ := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
)
Expand All @@ -75,11 +119,25 @@
}
fmt.Println(out)

model := bootstrap.NewModel()
// Ensure it the service is started,
// in this case we won't be able to query state without the node running
if algod.IsInstalled() && algod.IsService() && !algod.IsRunning() {
log.Debug("Algorand is installed, but not running. Attempting to start it automatically.")
log.Warn(style.Yellow.Render(explanations.SudoWarningMsg))
err := algod.Start()
if err != nil {
log.Error(FailedToAutoStartMessage)
log.Fatal(err)
}

Check warning on line 131 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L122-L131

Added lines #L122 - L131 were not covered by tests

}

// Prefill questions
if algod.IsInstalled() {
model.BootstrapMsg.Install = false
model.Question = bootstrap.CatchupQuestion
}
// Run the Bootstrap TUI
p := tea.NewProgram(model)
var msg *app.BootstrapMsg
go func() {
Expand All @@ -92,33 +150,44 @@
}
}
}()

if _, err := p.Run(); err != nil {
log.Fatal(err)
}

// If the pointer is empty, return (should not happen)
if msg == nil {
return nil
}

// User Answer for Install Question
if msg.Install {
log.Warn(style.Yellow.Render(explanations.SudoWarningMsg))

// Run the installer

Check warning on line 166 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L166

Added line #L166 was not covered by tests
err := algod.Install()
if err != nil {
return err
}

// Wait for algod
time.Sleep(10 * time.Second)
// Parse the data directory
dir, err := algod.GetDataDir("")
if err != nil {
log.Fatal(err)
}

Check warning on line 176 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L173-L176

Added lines #L173 - L176 were not covered by tests

// Wait for the client to respond
client, err = algod.WaitForClient(context.Background(), dir, CheckAlgodInterval, CheckAlgodTimeout)
if err != nil {
log.Fatal(err)
}

Check warning on line 182 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L179-L182

Added lines #L179 - L182 were not covered by tests

if !algod.IsRunning() {
log.Fatal("algod is not running. Something went wrong with installation")
}
} else {
// This should not happen but just in case, ensure it is running

Check warning on line 188 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L188

Added line #L188 was not covered by tests
if !algod.IsRunning() {
log.Info(style.Green.Render("Starting Algod 🚀"))
log.Warn(style.Yellow.Render(explanations.SudoWarningMsg))
err := algod.Start()
if err != nil {
log.Fatal(err)
Expand All @@ -128,17 +197,18 @@
}
}

// Find the data directory automatically
dataDir, err := algod.GetDataDir("")
// Wait for the client to respond
client, err = algod.WaitForClient(context.Background(), dataDir, CheckAlgodInterval, CheckAlgodTimeout)

Check warning on line 203 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L202-L203

Added lines #L202 - L203 were not covered by tests
if err != nil {
return err
}
// Create the client
client, err := algod.GetClient(dataDir)
if err != nil {
return err
log.Fatal(err)

Check warning on line 205 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L205

Added line #L205 was not covered by tests
}

// User answer for catchup question
if msg.Catchup {
ctx := context.Background()
httpPkg := new(api.HttpPkg)

Check warning on line 211 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L210-L211

Added lines #L210 - L211 were not covered by tests
network, err := utils.GetNetworkFromDataDir(dataDir)
if err != nil {
return err
Expand All @@ -151,51 +221,15 @@
log.Info(style.Green.Render("Latest Catchpoint: " + catchpoint))
}

// Start catchup
res, _, err := algod.StartCatchup(ctx, client, catchpoint, nil)
// Start catchup with round threshold
res, _, err := algod.StartCatchup(ctx, client, catchpoint, &api.StartCatchupParams{Min: &CatchpointLagThreshold})

Check warning on line 225 in cmd/bootstrap.go

View check run for this annotation

Codecov / codecov/patch

cmd/bootstrap.go#L225

Added line #L225 was not covered by tests
if err != nil {
log.Fatal(err)
}
log.Info(style.Green.Render(res))

}

t := new(system.Clock)
// Fetch the state and handle any creation errors
state, stateResponse, err := algod.NewStateModel(ctx, client, httpPkg)
cmdutils.WithInvalidResponsesExplanations(err, stateResponse, cmd.UsageString())
cobra.CheckErr(err)

// Construct the TUI Model from the State
m, err := ui.NewViewportViewModel(state, client)
cobra.CheckErr(err)

// Construct the TUI Application
p = tea.NewProgram(
m,
tea.WithAltScreen(),
tea.WithFPS(120),
)

// Watch for State Updates on a separate thread
// TODO: refactor into context aware watcher without callbacks
go func() {
state.Watch(func(status *algod.StateModel, err error) {
if err == nil {
p.Send(state)
}
if err != nil {
p.Send(state)
p.Send(err)
}
}, ctx, t)
}()

// Execute the TUI Application
_, err = p.Run()
if err != nil {
log.Fatal(err)
}
return nil
return runTUI(RootCmd, dataDir, false)

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
},
}
17 changes: 14 additions & 3 deletions cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import (
"encoding/json"
"fmt"
"os/exec"

cmdutils "github.com/algorandfoundation/nodekit/cmd/utils"
"github.com/algorandfoundation/nodekit/cmd/utils/explanations"
"github.com/algorandfoundation/nodekit/internal/algod"
Expand All @@ -12,12 +14,13 @@
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/log"
"github.com/spf13/cobra"
"os/exec"
"golang.org/x/sys/unix"
)

// DebugInfo represents diagnostic information about
// the Algod service, path availability, and related metadata.
type DebugInfo struct {
Version string `json:"version"`

// InPath indicates whether the `algod` command-line tool is available in the system's executable path.
InPath bool `json:"inPath"`
Expand Down Expand Up @@ -72,11 +75,19 @@
return err
}
folderDebug, err := utils.ToDataFolderConfig(dataDir)
folderDebug.Token = folderDebug.Token[:3] + "..."
if err != nil {
return err
folderDebug.Token = fmt.Sprint(err)

Check warning on line 79 in cmd/debug.go

View check run for this annotation

Codecov / codecov/patch

cmd/debug.go#L79

Added line #L79 was not covered by tests
} else {
folderDebug.Token = folderDebug.Token[:3] + "..."
}

var stat unix.Statfs_t
unix.Statfs(dataDir, &stat)
bytesFree := stat.Bavail * uint64(stat.Bsize)
folderDebug.BytesFree = fmt.Sprintf("%d bytes (%d MB)", bytesFree, bytesFree/1024/1024)

info := DebugInfo{
Version: cmd.Root().Version,
InPath: system.CmdExists("algod"),
IsRunning: algod.IsRunning(),
IsService: algod.IsService(),
Expand Down
Loading
Loading