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

[CORE-538] Integrate AutoCLI as part of Cosmos 0.47 -> 0.50 upgrade and re-add a few standalone commands that changed packages #932

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

lcwik
Copy link
Contributor

@lcwik lcwik commented Jan 5, 2024

Changelist

Integrate AutoCLI (using upgrade guide recommendations) and re-add a few standalone commands that changed packages. Notably the change requires instantiating an instance of the app to get the list of modules for AutoCLI to query.

The 3.0.0 command list (with top-level subcommands) is:

  add-genesis-account Add a genesis account to genesis.json
  collect-gentxs      Collect genesis txs and output a genesis.json file
  config              Create or query an application CLI configuration file
  debug               Tool for helping with debugging your application
    addr        Convert an address between hex and bech32
    prefixes    List prefixes used for Human-Readable Part (HRP) in Bech32
    pubkey      Decode a pubkey from proto JSON
    pubkey-raw  Decode a ED25519 or secp256k1 pubkey from hex, base64, or bech32
    raw-bytes   Convert raw bytes output (eg. [10 21 13 255]) to hex
  export              Export state to JSON
  gentx               Generate a genesis tx carrying a self delegation
  help                Help about any command
  init                Initialize private validator, p2p, genesis, and application configuration files
  keys                Manage your application's keys
    add            Add an encrypted private key (either newly generated or recovered), encrypt it, and save to <name> file
    delete         Delete the given keys
    export         Export private keys
    import         Import private keys into the local keybase
    list           List all keys
    list-key-types List all key types
    migrate        Migrate keys from amino to proto serialization format
    mnemonic       Compute the bip39 mnemonic for some input entropy
    parse          Parse address from hex to bech32 and vice versa
    rename         Rename an existing key
    show           Retrieve key information by name or address
  migrate             Migrate genesis to a specified target version
  query               Querying subcommands
    account                  Query for account by address
    assets                   Querying commands for the assets module
    auth                     Querying commands for the auth module
    bank                     Querying commands for the bank module
    block                    Get verified data for the block at given height
    blocktime                Querying commands for the blocktime module
    bridge                   Querying commands for the bridge module
    clob                     Querying commands for the clob module
    delaymsg                 Querying commands for the delaymsg module
    distribution             Querying commands for the distribution module
    epochs                   Querying commands for the epochs module
    evidence                 Query for evidence by hash or for all (paginated) submitted evidence
    feegrant                 Querying commands for the feegrant module
    feetiers                 Querying commands for the feetiers module
    gov                      Querying commands for the governance module
    ibc                      Querying commands for the IBC module
    ibc-transfer             IBC fungible token transfer query subcommands
    interchain-accounts      IBC interchain accounts query subcommands
    params                   Querying commands for the params module
    perpetuals               Querying commands for the perpetuals module
    prices                   Querying commands for the prices module
    rewards                  Querying commands for the rewards module
    sending                  Querying commands for the sending module
    slashing                 Querying commands for the slashing module
    staking                  Querying commands for the staking module
    stats                    Querying commands for the stats module
    subaccounts              Querying commands for the subaccounts module
    tendermint-validator-set Get the full tendermint validator set at given height
    tx                       Query for a transaction by hash, "<addr>/<seq>" combination or comma-separated signatures in a committed block
    txs                      Query for paginated transactions that match a set of events
    upgrade                  Querying commands for the upgrade module
    vest                     Querying commands for the vest module
  rollback            rollback cosmos-sdk and tendermint state by one height
  rosetta             spin up a rosetta server
  start               Run the full node
  status              Query remote node for status
  tendermint          Tendermint subcommands
    bootstrap-state  Bootstrap CometBFT state at an arbitrary block height using a light client
    debug            A utility to kill or watch a CometBFT process while aggregating debugging data
    gen-priv-key     Generate a Tendermint private key file from a given mnemonic.
    reset-state      Remove all the data and WAL
    show-address     Shows this node's tendermint validator consensus address
    show-node-id     Show this node's ID
    show-validator   Show this node's tendermint validator info
    unsafe-reset-all (unsafe) Remove all the data and WAL, reset this node's validator to genesis state
    version          Print tendermint libraries' version
  tx                  Transactions subcommands
    assets              assets transactions subcommands
    bank                Bank transaction subcommands
    blocktime           blocktime transactions subcommands
    bridge              bridge transactions subcommands
    broadcast           Broadcast transactions generated offline
    clob                clob transactions subcommands
    crisis              Crisis transactions subcommands
    decode              Decode a binary encoded transaction string
    delaymsg            delaymsg transactions subcommands
    distribution        Distribution transactions subcommands
    encode              Encode transactions generated offline
    epochs              epochs transactions subcommands
    evidence            Evidence transaction subcommands
    feegrant            Feegrant transactions subcommands
    feetiers            feetiers transactions subcommands
    gov                 Governance transactions subcommands
    ibc                 IBC transaction subcommands
    ibc-transfer        IBC fungible token transfer transaction subcommands
    interchain-accounts IBC interchain accounts transaction subcommands
    multi-sign          Generate multisig signatures for transactions generated offline
    multisign-batch     Assemble multisig transactions in batch from batch signatures
    perpetuals          perpetuals transactions subcommands
    prices              prices transactions subcommands
    rewards             rewards transactions subcommands
    sending             sending transactions subcommands
    sign                Sign a transaction generated offline
    sign-batch          Sign transaction batch files
    slashing            Slashing transaction subcommands
    staking             Staking transaction subcommands
    stats               stats transactions subcommands
    subaccounts         subaccounts transactions subcommands
    validate-signatures validate transactions signatures
    vest                vest transactions subcommands
  validate-genesis    validates the genesis file at the default location or at the location passed as an arg
  version             Print the application binary version information

The 4.0.0 (current) command list (with top-level subcommands) is:

  add-genesis-account Add a genesis account to genesis.json
  collect-gentxs      Collect genesis txs and output a genesis.json file
  config              Utilities for managing application configuration
    diff        Outputs all config values that are different from the app.toml defaults.
    get         Get an application config value
    home        Outputs the folder used as the binary home. No home directory is set when using the tool standalone.
    migrate     Migrate Cosmos SDK app configuration file to the specified version
    set         Set an application config value
    view        View the config file
  debug               Tool for helping with debugging your application
    addr        Convert an address between hex and bech32
    prefixes    List prefixes used for Human-Readable Part (HRP) in Bech32
    pubkey      Decode a pubkey from proto JSON
    pubkey-raw  Decode a ED25519 or secp256k1 pubkey from hex, base64, or bech32
    raw-bytes   Convert raw bytes output (eg. [10 21 13 255]) to hex
  export              Export state to JSON
  gentx               Generate a genesis tx carrying a self delegation
  help                Help about any command
  init                Initialize private validator, p2p, genesis, and application configuration files
  keys                Manage your application's keys
    add            Add an encrypted private key (either newly generated or recovered), encrypt it, and save to <name> file
    delete         Delete the given keys
    export         Export private keys
    import         Import private keys into the local keybase
    import-hex     Import private keys into the local keybase
    list           List all keys
    list-key-types List all key types
    migrate        Migrate keys from amino to proto serialization format
    mnemonic       Compute the bip39 mnemonic for some input entropy
    parse          Parse address from hex to bech32 and vice versa
    rename         Rename an existing key
    show           Retrieve key information by name or address
  migrate             Migrate genesis to a specified target version
  query               Querying subcommands
    assets              Querying commands for the assets module
    auth                Querying commands for the auth module
    bank                Querying commands for the bank module
    block               Query for a committed block by height, hash, or event(s)
    blocktime           Querying commands for the blocktime module
    bridge              Querying commands for the bridge module
    clob                Querying commands for the clob module
    comet-validator-set Get the full CometBFT validator set at given height
    consensus           Querying commands for the consensus module
    delaymsg            Querying commands for the delaymsg module
    distribution        Querying commands for the distribution module
    epochs              Querying commands for the epochs module
    evidence            Querying commands for the evidence module
    feegrant            Querying commands for the feegrant module
    feetiers            Querying commands for the feetiers module
    gov                 Querying commands for the gov module
    ibc                 Querying commands for the IBC module
    ibc-transfer        IBC fungible token transfer query subcommands
    interchain-accounts IBC interchain accounts query subcommands
    params              Querying commands for the params module
    perpetuals          Querying commands for the perpetuals module
    prices              Querying commands for the prices module
    rewards             Querying commands for the rewards module
    sending             Querying commands for the sending module
    slashing            Querying commands for the slashing module
    staking             Querying commands for the staking module
    stats               Querying commands for the stats module
    subaccounts         Querying commands for the subaccounts module
    tx                  Query for a transaction by hash, "<addr>/<seq>" combination or comma-separated signatures in a committed block
    txs                 Query for paginated transactions that match a set of events
    upgrade             Querying commands for the upgrade module
    vest                Querying commands for the vest module
  rollback            rollback Cosmos SDK and CometBFT state by one height
  start               Run the full node
  status              Query remote node for status
  comet               CometBFT subcommands
    bootstrap-state  Bootstrap CometBFT state at an arbitrary block height using a light client
    debug            A utility to kill or watch a CometBFT process while aggregating debugging data
    gen-priv-key     Generate a Tendermint private key file from a given mnemonic.
    reset-state      Remove all the data and WAL
    show-address     Shows this node's CometBFT validator consensus address
    show-node-id     Show this node's ID
    show-validator   Show this node's CometBFT validator info
    unsafe-reset-all (unsafe) Remove all the data and WAL, reset this node's validator to genesis state
    version          Print CometBFT libraries' version
  tx                  Transactions subcommands
    assets              assets transactions subcommands
    auth                Transactions commands for the auth module
    bank                Bank transaction subcommands
    blocktime           blocktime transactions subcommands
    bridge              bridge transactions subcommands
    broadcast           Broadcast transactions generated offline
    clob                clob transactions subcommands
    consensus           Transactions commands for the consensus module
    crisis              Transactions commands for the crisis module
    decode              Decode a binary encoded transaction string
    delaymsg            delaymsg transactions subcommands
    distribution        Distribution transactions subcommands
    encode              Encode transactions generated offline
    epochs              epochs transactions subcommands
    evidence            Evidence transaction subcommands
    feegrant            Feegrant transactions sub-commands
    feetiers            feetiers transactions subcommands
    gov                 Governance transactions subcommands
    ibc                 IBC transaction subcommands
    ibc-transfer        IBC fungible token transfer transaction subcommands
    interchain-accounts IBC interchain accounts transaction subcommands
    multi-sign          Generate multisig signatures for transactions generated offline
    multisign-batch     Assemble multisig transactions in batch from batch signatures
    perpetuals          perpetuals transactions subcommands
    prices              prices transactions subcommands
    rewards             rewards transactions subcommands
    sending             sending transactions subcommands
    sign                Sign a transaction generated offline
    sign-batch          Sign transaction batch files
    slashing            Transactions commands for the slashing module
    staking             Staking transaction subcommands
    stats               stats transactions subcommands
    subaccounts         subaccounts transactions subcommands
    upgrade             Upgrade transaction subcommands
    validate-signatures validate transactions signatures
    vest                vest transactions subcommands
  validate            Validates the genesis file at the default location or at the location passed as an arg
  version             Print the application binary version information

Notable differences are:

  • rosetta was removed due to requiring Cosmos 0.50.2, filed CORE-852.
  • config broken out into several sub-commands
  • query account is now under query auth ...
  • rename of tendermint to comet (note that tendermint is still a valid alias).
  • rename of query tendermint-validator-set to query comet-validator-set (note that tendermint-validator-set is still a valid alias).
  • rename of validate-genesis to validate (note that validate-genesis is still a valid alias).
  • Some new commands like query consensus, tx consensus, keys import-hex.

Test Plan

Validated list of commands that are part of the binary manually and existing tests pass.

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Copy link

linear bot commented Jan 5, 2024

Copy link
Contributor

coderabbitai bot commented Jan 5, 2024

Walkthrough

The update to the codebase primarily encompasses the enhancement of the command-line interface (CLI). Key changes include the importation of new libraries, refinement of the root command setup, the inclusion of a new confixcmd command, and the adoption of autocli for handling module-specific commands. The appCreator structure has been deprecated, with its functionalities restructured into independent functions, and a new mechanism to enumerate modules for autocli has been implemented.

Changes

File Path Change Summary
.../cmd/dydxprotocold/cmd/root.go - New imports added
- Root command initialization updated
- confixcmd command added
- Integration of autocli for module commands
- autoCliOpts function added for module enumeration
- Removed appCreator struct
- Converted appCreator methods to standalone functions

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit's AI:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8d7fe35 and 56ac8f1.
Files ignored due to filter (2)
  • protocol/go.mod
  • protocol/go.sum
Files selected for processing (1)
  • protocol/cmd/dydxprotocold/cmd/root.go (9 hunks)
Additional comments: 5
protocol/cmd/dydxprotocold/cmd/root.go (5)
  • 47-47: The addition of github.com/spf13/viper is not mentioned in the PR overview or AI-generated summary. Ensure that this new dependency is indeed required and properly integrated into the application.

  • 185-185: The addition of confixcmd.ConfigCommand() is consistent with the PR objectives to expand the config command into multiple sub-commands. This change appears to be correctly implemented.

  • 216-251: The autoCliOpts function is a new addition and central to the AutoCLI integration. Ensure that the instantiation of the application and the enumeration of modules are efficient and do not introduce unnecessary overhead, especially since the created app instance is discarded.

  • 272-272: The addition of server.QueryBlockCmd() to the queryCommand function is consistent with the PR objectives to reorganize and expand command functionalities. This change appears to be correctly implemented.

  • 314-314: The newApp function has been converted from a method on the appCreator struct to a standalone function, which aligns with the PR objectives to remove the appCreator struct and streamline the command initialization process.

Comment on lines +149 to +150
if err := autoCliOpts(encodingConfig, initClientCtx).EnhanceRootCommand(rootCmd); err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Using panic for error handling in the autoCliOpts function is not ideal for production code. Consider handling the error gracefully or documenting why a panic is necessary in this context.

@@ -335,7 +384,7 @@ func (a appCreator) newApp(
//
// Deprecated: this feature relies on the use of known unstable, legacy export functionality
// from cosmos.
func (a appCreator) appExport(
func appExport(
Copy link
Contributor

Choose a reason for hiding this comment

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

The appExport function is marked as deprecated and has been converted from a method on the appCreator struct to a standalone function. Ensure that the deprecation is clearly documented and communicated to developers, and that any necessary migration paths or alternatives are provided.

@lcwik lcwik merged commit 7e793b6 into main Jan 5, 2024
@lcwik lcwik deleted the lukecore538.4 branch January 5, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants