Skip to content

Conversation

@winder
Copy link
Contributor

@winder winder commented Feb 25, 2022

Summary

New algokey subcommand to generate transactions for bringing an account online or offline.

Usage:

~$ algokey part keyreg -h
Make key registration transaction

Usage:
  algokey part keyreg [flags]

Flags:
      --account string      account address to bring offline, mutually exclusive with keyfile
      --fee uint            transaction fee (default 1000)
      --firstvalid uint     first round where the transaction may be committed to the ledger
  -h, --help                help for keyreg
      --keyfile string      participation keys to register, file is opened to fetch metadata for the transaction, mutually exclusive with account
      --lastvalid uint      last round where the generated transaction may be committed to the ledger, defaults to firstvalid + 1000
      --network string      the network where the provided keys will be registered, one of mainnet/testnet/betanet (default "mainnet")
      --offline             set to bring an account offline
  -o, --outputFile string   write signed transaction to this file, or '-' to write to stdout

Test Plan

New e2e test.

@rotemh
Copy link
Contributor

rotemh commented Feb 25, 2022

what is a usage example?

@winder
Copy link
Contributor Author

winder commented Feb 25, 2022

@rotemh please see the updated description for the help output. For a real example check out the e2e test: https://github.com/algorand/go-algorand/pull/3689/files#diff-41f523fc4a0e8cc8e6e8df028f9e5858ab083bcba4711d6328d7e3873cc192dcR24

keyregCmd.Flags().StringVar(&params.addr, "account", "", "account address to bring offline, mutually exclusive with partkey-file")

// TODO: move 'bundleGenesisInject' into something that can be imported here instead of using constants.
validNetworks = map[string]networkGenesis{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of hard-coding this, do this dynamically similar to .go-algorand/cmd/goal/node.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That command is also hard coded:

validNetworks := map[string][]byte{
			"mainnet": genesisMainnet,
			"testnet": genesisTestnet,
			"betanet": genesisBetanet,
			"devnet":  genesisDevnet,
		}

The reason I didn't use those objects is that they aren't readily accessible and I didn't want to refactor anything as part of this PR.

}

keyregCmd.Flags().Uint64Var(&params.fee, "fee", minFee, "transaction fee")
keyregCmd.Flags().Uint64Var(&params.firstValid, "first-valid", 0, "first round where the transaction may be committed to the ledger")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the same parameter names ( when possible ), as in goal to retain some level of consistency. In this case first-valid -> firstvalid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It looks like there are 2 problems with this.

  1. algokey uses first and last to define the key ranges. Technically this is slightly different, being the transaction ranges, so I'll keep consistent with goal on that one.
  2. algokey refers to the key file as keyfile and goal account installpartkey refers to it as partkey. For this I'll keep consistent with algokey.

keyregCmd.Flags().StringVar(&params.network, "network", "mainnet", "the network where the provided keys will be registered, one of mainnet/testnet/betanet")
keyregCmd.MarkFlagRequired("network") // nolint:errcheck
keyregCmd.Flags().BoolVar(&params.offline, "offline", false, "set to bring an account offline")
keyregCmd.Flags().StringVar(&params.txFile, "tx-file", "", fmt.Sprintf("write signed transaction to this file, or '%s' to write to stdout", stdoutFilenameValue))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using dynamic parameter output could cause issues with the automated documentation generator for these tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double-checked the output of algokey generate-docs <dir>. This is not a problem.

part = &partkey.Participation

if params.firstValid < uint64(part.FirstValid) {
return fmt.Errorf("first-valid (%d) is earlier than the key first valid (%d)", params.firstValid, part.FirstValid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please rephrase the error message so that it would be clear what is the expectation and what was violated ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( same issue with the rest of the error messages below )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll reword this one, but the others look good to me

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see requests above.

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2022

Codecov Report

Merging #3689 (14ed2ef) into master (1bb149d) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3689      +/-   ##
==========================================
- Coverage   49.91%   49.91%   -0.01%     
==========================================
  Files         382      382              
  Lines       64412    64412              
==========================================
- Hits        32150    32149       -1     
  Misses      28832    28832              
- Partials     3430     3431       +1     
Impacted Files Coverage Δ
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
crypto/merkletrie/trie.go 66.42% <0.00%> (-2.19%) ⬇️
crypto/merkletrie/node.go 91.62% <0.00%> (-1.87%) ⬇️
cmd/tealdbg/debugger.go 71.42% <0.00%> (-0.99%) ⬇️
data/abi/abi_type.go 87.67% <0.00%> (-0.95%) ⬇️
network/requestTracker.go 70.25% <0.00%> (-0.87%) ⬇️
network/wsNetwork.go 62.99% <0.00%> (+0.19%) ⬆️
network/wsPeer.go 68.61% <0.00%> (+0.27%) ⬆️
catchup/service.go 70.12% <0.00%> (+0.74%) ⬆️
data/transactions/verify/txn.go 45.02% <0.00%> (+0.86%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bb149d...14ed2ef. Read the comment docs.

@winder winder requested a review from tsachiherman February 25, 2022 21:39
@tsachiherman tsachiherman dismissed their stale review February 25, 2022 22:34

requested changes applied.

tsachiherman
tsachiherman previously approved these changes Feb 28, 2022
@algojohnlee algojohnlee merged commit 6b7dfb6 into algorand:master Feb 28, 2022
@winder winder deleted the will/algokey-keyreg branch February 28, 2022 18:59
@winder winder self-assigned this Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants