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

go-algorand 3.2.2-stable #3305

Merged
merged 5 commits into from
Dec 13, 2021
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
2 changes: 1 addition & 1 deletion buildnumber.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
2
14 changes: 9 additions & 5 deletions catchup/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool,

if err != nil {
if err == errLedgerAlreadyHasBlock {
// ledger already has the block, no need to request this block from anyone.
return true
// ledger already has the block, no need to request this block.
// only the agreement could have added this block into the ledger, catchup is complete
s.log.Infof("fetchAndWrite(%d): the block is already in the ledger. The catchup is complete", r)
return false
}
s.log.Debugf("fetchAndWrite(%v): Could not fetch: %v (attempt %d)", r, err, i)
peerSelector.rankPeer(psp, peerRankDownloadFailed)
Expand Down Expand Up @@ -353,8 +355,10 @@ func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool,
s.log.Infof("fetchAndWrite(%d): no need to re-evaluate historical block", r)
return true
case ledgercore.BlockInLedgerError:
s.log.Infof("fetchAndWrite(%d): block already in ledger", r)
return true
// the block was added to the ledger from elsewhere after fetching it here
// only the agreement could have added this block into the ledger, catchup is complete
s.log.Infof("fetchAndWrite(%d): after fetching the block, it is already in the ledger. The catchup is complete", r)
return false
case protocol.Error:
if !s.protocolErrorLogged {
logging.Base().Errorf("fetchAndWrite(%v): unrecoverable protocol error detected: %v", r, err)
Expand Down Expand Up @@ -387,7 +391,7 @@ func (s *Service) pipelineCallback(r basics.Round, thisFetchComplete chan bool,
thisFetchComplete <- fetchResult

if !fetchResult {
s.log.Infof("failed to fetch block %v", r)
s.log.Infof("pipelineCallback(%d): did not fetch or write the block", r)
return 0
}
return r
Expand Down
55 changes: 52 additions & 3 deletions cmd/goal/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (
partKeyOutDir string
partKeyFile string
partKeyDeleteInput bool
listpartkeyCompat bool
partkeyCompat bool
importDefault bool
mnemonic string
dumpOutFile string
Expand Down Expand Up @@ -167,7 +167,10 @@ func init() {
installParticipationKeyCmd.Flags().BoolVar(&partKeyDeleteInput, "delete-input", false, "Acknowledge that installpartkey will delete the input key file")

// listpartkey flags
listParticipationKeysCmd.Flags().BoolVarP(&listpartkeyCompat, "compatibility", "c", false, "Print output in compatibility mode. This option will be removed in a future release, please use REST API for tooling.")
listParticipationKeysCmd.Flags().BoolVarP(&partkeyCompat, "compatibility", "c", false, "Print output in compatibility mode. This option will be removed in a future release, please use REST API for tooling.")

// partkeyinfo flags
partkeyInfoCmd.Flags().BoolVarP(&partkeyCompat, "compatibility", "c", false, "Print output in compatibility mode. This option will be removed in a future release, please use REST API for tooling.")

// import flags
importCmd.Flags().BoolVarP(&importDefault, "default", "f", false, "Set this account as the default one")
Expand Down Expand Up @@ -1069,6 +1072,7 @@ func uintToStr(number uint64) string {
// legacyListParticipationKeysCommand prints key information in the same
// format as earlier versions of goal. Some users are using this information
// in scripts and need some extra time to migrate to the REST API.
// DEPRECATED
func legacyListParticipationKeysCommand() {
dataDir := ensureSingleDataDir()

Expand Down Expand Up @@ -1118,7 +1122,7 @@ var listParticipationKeysCmd = &cobra.Command{
Long: `List all participation keys tracked by algod along with summary of additional information. For detailed key information use 'partkeyinfo'.`,
Args: validateNoPosArgsFn,
Run: func(cmd *cobra.Command, args []string) {
if listpartkeyCompat {
if partkeyCompat {
legacyListParticipationKeysCommand()
return
}
Expand Down Expand Up @@ -1364,12 +1368,57 @@ func strOrNA(value *uint64) string {
return uintToStr(*value)
}

// legacyPartkeyInfoCommand prints key information in the same
// format as earlier versions of goal. Some users are using this information
// in scripts and need some extra time to migrate to alternatives.
// DEPRECATED
func legacyPartkeyInfoCommand() {
type partkeyInfo struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`
Address string `codec:"acct"`
FirstValid basics.Round `codec:"first"`
LastValid basics.Round `codec:"last"`
VoteID crypto.OneTimeSignatureVerifier `codec:"vote"`
SelectionID crypto.VRFVerifier `codec:"sel"`
VoteKeyDilution uint64 `codec:"voteKD"`
}

onDataDirs(func(dataDir string) {
fmt.Printf("Dumping participation key info from %s...\n", dataDir)
client := ensureGoalClient(dataDir, libgoal.DynamicClient)

// Make sure we don't already have a partkey valid for (or after) specified roundLastValid
parts, err := client.ListParticipationKeyFiles()
if err != nil {
reportErrorf(errorRequestFail, err)
}

for filename, part := range parts {
fmt.Println("------------------------------------------------------------------")
info := partkeyInfo{
Address: part.Address().String(),
FirstValid: part.FirstValid,
LastValid: part.LastValid,
VoteID: part.VotingSecrets().OneTimeSignatureVerifier,
SelectionID: part.VRFSecrets().PK,
VoteKeyDilution: part.KeyDilution,
}
infoString := protocol.EncodeJSON(&info)
fmt.Printf("File: %s\n%s\n", filename, string(infoString))
}
})
}

var partkeyInfoCmd = &cobra.Command{
Use: "partkeyinfo",
Short: "Output details about all available part keys",
Long: `Output details about all available part keys in the specified data directory(ies), such as key validity period.`,
Args: validateNoPosArgsFn,
Run: func(cmd *cobra.Command, args []string) {
if partkeyCompat {
legacyPartkeyInfoCommand()
return
}

onDataDirs(func(dataDir string) {
fmt.Printf("Dumping participation key info from %s...\n", dataDir)
Expand Down