diff --git a/internal/algod/mac/mac.go b/internal/algod/mac/mac.go index 3286ca15..09909552 100644 --- a/internal/algod/mac/mac.go +++ b/internal/algod/mac/mac.go @@ -113,11 +113,19 @@ func Upgrade(force bool) error { if !system.CmdExists("brew") { return errors.New("homebrew is not installed") } - - return system.RunAll(system.CmdsList{ + err := system.RunAll(system.CmdsList{ {"brew", "--prefix", "algorand", "--installed"}, + {"brew", "update"}, {"brew", "upgrade", "algorand", "--formula"}, }) + if err != nil { + return err + } + err = Stop(false) + if err != nil { + return err + } + return Start(false) } // Start algorand with launchd diff --git a/internal/algod/state.go b/internal/algod/state.go index ac4bc8c9..d3b0edf6 100644 --- a/internal/algod/state.go +++ b/internal/algod/state.go @@ -116,6 +116,7 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co if !s.Watching { break } + // Abort on Fast-Catchup if s.Status.State == FastCatchupState { // Update current render @@ -132,6 +133,9 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co cb(s, nil) continue } + // Fetch Keys + s.UpdateKeys(ctx, t) + cb(s, nil) // Wait for the next block s.Status, _, err = s.Status.Wait(ctx) @@ -140,9 +144,6 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co continue } - // Fetch Keys - s.UpdateKeys(ctx, t) - if s.Status.State == SyncingState { cb(s, nil) continue @@ -176,18 +177,18 @@ func (s *StateModel) UpdateKeys(ctx context.Context, t system.Time) { if err == nil { s.Admin = true s.Accounts = ParticipationKeysToAccounts(s.ParticipationKeys) + + // For each account, update the data from the RPC endpoint for _, acct := range s.Accounts { - // For each account, update the data from the RPC endpoint - if s.Status.State == StableState { - // Skip eon errors - rpcAcct, err := GetAccount(s.Client, acct.Address) - if err != nil { - continue - } - - s.Accounts[acct.Address] = s.Accounts[acct.Address].Merge(rpcAcct) - s.Accounts[acct.Address] = s.Accounts[acct.Address].UpdateExpiredTime(t, s.ParticipationKeys, int(s.Status.LastRound), s.Metrics.RoundTime) + // Skip eon errors + rpcAcct, err := GetAccount(s.Client, acct.Address) + if err != nil { + continue } + + s.Accounts[acct.Address] = s.Accounts[acct.Address].Merge(rpcAcct) + s.Accounts[acct.Address] = s.Accounts[acct.Address].UpdateExpiredTime(t, s.ParticipationKeys, int(s.Status.LastRound), s.Metrics.RoundTime) } + } } diff --git a/main.go b/main.go index e6692df6..b4235688 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ func main() { var needsUpgrade = false resp, err := api.GetNodeKitReleaseWithResponse(new(api.HttpPkg)) if err == nil && resp.ResponseCode >= 200 && resp.ResponseCode < 300 { - if resp.JSON200 != version { + if version != "dev" && resp.JSON200 != version { needsUpgrade = true // Warn on all commands but version if len(os.Args) > 1 && os.Args[1] != "--version" { diff --git a/ui/modal/testdata/Test_Snapshot/InfoModal.golden b/ui/modal/testdata/Test_Snapshot/InfoModal.golden index 01b5a749..0c3299be 100644 --- a/ui/modal/testdata/Test_Snapshot/InfoModal.golden +++ b/ui/modal/testdata/Test_Snapshot/InfoModal.golden @@ -31,21 +31,21 @@ - ╭──Key Information────────────────────────────────────────────────────────────────────────────────────────╮ - │ │ - │ Account: TUIDKH2C7MUHZDD77MAMUREJRKNK25SYXB7OAFA6JFBB24PEL5UX4S4GUU │ - │ Participation ID: DRINJEQ6PN4GDQYE6ECJFRTVSCXZA4BUWNZMPFL6Q2MFTEFBPXGA │ - │ Integrity: 4OAJOXKPLUQM2 │ - │ │ - │ Vote Key: dHynahCuNWpeR9BcE-B8VE1GM_KdUj759k9ja8zNY30 │ - │ Selection Key: DM9cyZ0oLuVHDtVzhkhLIW06uE0J9faf6aL_FeLFj3o │ - │ State Proof Key: -DAZBTXOletJxFUhEaYQaWaNs3Q4DLEwOlJ68gI8IGq9Ss_1szOimQiAt-f6lqk4FxEe_XvaAXkMbv2_9OiE1g │ - │ │ - │ Vote First Valid: 47733256 │ - │ Vote Last Valid: 47861731 │ - │ Vote Key Dilution: 359 │ - │ │ - ╰──────────────────────────────────────────────────────────────────────────────( (d)elete | (o)nline )────╯ + ╭──Key Information──────────────────────────────────────────────────────────────────────────────────────────╮ + │ │ + │ Account: TUIDKH2C7MUHZDD77MAMUREJRKNK25SYXB7OAFA6JFBB24PEL5UX4S4GUU │ + │ Participation ID: DRINJEQ6PN4GDQYE6ECJFRTVSCXZA4BUWNZMPFL6Q2MFTEFBPXGA │ + │ Integrity: 4OAJOXKPLUQM2 │ + │ │ + │ Vote Key: dHynahCuNWpeR9BcE+B8VE1GM/KdUj759k9ja8zNY30= │ + │ Selection Key: DM9cyZ0oLuVHDtVzhkhLIW06uE0J9faf6aL/FeLFj3o= │ + │ State Proof Key: +DAZBTXOletJxFUhEaYQaWaNs3Q4DLEwOlJ68gI8IGq9Ss/1szOimQiAt+f6lqk4FxEe/XvaAXkMbv2/9OiE1g== │ + │ │ + │ Vote First Valid: 47733256 │ + │ Vote Last Valid: 47861731 │ + │ Vote Key Dilution: 359 │ + │ │ + ╰────────────────────────────────────────────────────────────────────────────────( (d)elete | (o)nline )────╯ diff --git a/ui/modals/info/info.go b/ui/modals/info/info.go index 376f07a5..992d8c38 100644 --- a/ui/modals/info/info.go +++ b/ui/modals/info/info.go @@ -94,9 +94,9 @@ func (m ViewModel) View() string { } account := lipgloss.JoinHorizontal(lipgloss.Left, style.Cyan.Render("Account: "), m.Participation.Address) id := style.Cyan.Render("Participation ID: ") + m.Participation.Id - selection := style.Yellow.Render("Selection Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:]) - vote := style.Yellow.Render("Vote Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:]) - stateProof := style.Yellow.Render("State Proof Key: ") + *utils.UrlEncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey) + selection := style.Yellow.Render("Selection Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:]) + vote := style.Yellow.Render("Vote Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:]) + stateProof := style.Yellow.Render("State Proof Key: ") + *utils.Base64EncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey) voteFirstValid := style.Purple("Vote First Valid: ") + utils.IntToStr(m.Participation.Key.VoteFirstValid) voteLastValid := style.Purple("Vote Last Valid: ") + utils.IntToStr(m.Participation.Key.VoteLastValid) voteKeyDilution := style.Purple("Vote Key Dilution: ") + utils.IntToStr(m.Participation.Key.VoteKeyDilution) diff --git a/ui/modals/info/testdata/Test_Snapshot/Visible.golden b/ui/modals/info/testdata/Test_Snapshot/Visible.golden index b43255a0..88c57f10 100644 --- a/ui/modals/info/testdata/Test_Snapshot/Visible.golden +++ b/ui/modals/info/testdata/Test_Snapshot/Visible.golden @@ -1,13 +1,13 @@ - -Account: TUIDKH2C7MUHZDD77MAMUREJRKNK25SYXB7OAFA6JFBB24PEL5UX4S4GUU -Participation ID: DRINJEQ6PN4GDQYE6ECJFRTVSCXZA4BUWNZMPFL6Q2MFTEFBPXGA -Integrity: 4OAJOXKPLUQM2 - -Vote Key: dHynahCuNWpeR9BcE-B8VE1GM_KdUj759k9ja8zNY30 -Selection Key: DM9cyZ0oLuVHDtVzhkhLIW06uE0J9faf6aL_FeLFj3o -State Proof Key: -DAZBTXOletJxFUhEaYQaWaNs3Q4DLEwOlJ68gI8IGq9Ss_1szOimQiAt-f6lqk4FxEe_XvaAXkMbv2_9OiE1g - -Vote First Valid: 47733256 -Vote Last Valid: 47861731 -Vote Key Dilution: 359 - \ No newline at end of file + +Account: TUIDKH2C7MUHZDD77MAMUREJRKNK25SYXB7OAFA6JFBB24PEL5UX4S4GUU +Participation ID: DRINJEQ6PN4GDQYE6ECJFRTVSCXZA4BUWNZMPFL6Q2MFTEFBPXGA +Integrity: 4OAJOXKPLUQM2 + +Vote Key: dHynahCuNWpeR9BcE+B8VE1GM/KdUj759k9ja8zNY30= +Selection Key: DM9cyZ0oLuVHDtVzhkhLIW06uE0J9faf6aL/FeLFj3o= +State Proof Key: +DAZBTXOletJxFUhEaYQaWaNs3Q4DLEwOlJ68gI8IGq9Ss/1szOimQiAt+f6lqk4FxEe/XvaAXkMbv2/9OiE1g== + +Vote First Valid: 47733256 +Vote Last Valid: 47861731 +Vote Key Dilution: 359 + \ No newline at end of file diff --git a/ui/utils/utils.go b/ui/utils/utils.go index af9d89fa..ac569ed9 100644 --- a/ui/utils/utils.go +++ b/ui/utils/utils.go @@ -7,6 +7,13 @@ import ( func toPtr[T any](constVar T) *T { return &constVar } +func Base64EncodeBytesPtrOrNil(b []byte) *string { + if b == nil || len(b) == 0 || isZeros(b) { + return nil + } + return toPtr(base64.StdEncoding.EncodeToString(b)) +} + func UrlEncodeBytesPtrOrNil(b []byte) *string { if b == nil || len(b) == 0 || isZeros(b) { return nil