Skip to content

Commit

Permalink
Merge branch 'v1.2.0' into feat/implement-partkey-integrity-hash
Browse files Browse the repository at this point in the history
# Conflicts:
#	ui/modal/testdata/Test_Snapshot/InfoModal.golden
#	ui/modals/info/testdata/Test_Snapshot/Visible.golden
  • Loading branch information
PhearZero committed Jan 20, 2025
2 parents 385c9aa + 8354c39 commit 9d991d1
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 47 deletions.
12 changes: 10 additions & 2 deletions internal/algod/mac/mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions internal/algod/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
}

}
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
30 changes: 15 additions & 15 deletions ui/modal/testdata/Test_Snapshot/InfoModal.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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 )────╯



Expand Down
6 changes: 3 additions & 3 deletions ui/modals/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions ui/modals/info/testdata/Test_Snapshot/Visible.golden
Original file line number Diff line number Diff line change
@@ -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

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
7 changes: 7 additions & 0 deletions ui/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d991d1

Please sign in to comment.