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

refactor(types,client)!: refactor global address sdk.Config #18372

Merged
merged 21 commits into from
Nov 29, 2023

Conversation

bizk
Copy link
Contributor

@bizk bizk commented Nov 6, 2023

Description

Closes: #18594

ref #7448


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features

    • Implemented a new method for handling address coin types and purposes, streamlining the configuration process.
  • Refactor

    • Updated key generation functions to use a standardized BIP44 path.
    • Simplified the configuration by removing global settings for coin type and purpose.
  • Tests

    • Enhanced test assertions for better readability and consistency.
    • Adjusted test cases to align with the updated key generation logic.
  • Documentation

    • Updated CHANGELOG to reflect recent changes in the types module.
  • Chores

    • Removed outdated test functions and cases related to deprecated configuration methods.

@github-actions github-actions bot added C:CLI C:Keys Keybase, KMS and HSMs labels Nov 6, 2023
@julienrbrt julienrbrt changed the title feat: Refactor global sdk.Config refactor(types,client)!: refactor global sdk.Config Nov 22, 2023
@bizk bizk marked this pull request as ready for review November 23, 2023 17:29
@bizk bizk requested a review from a team as a code owner November 23, 2023 17:29
@bizk bizk changed the title refactor(types,client)!: refactor global sdk.Config refactor(types,client)!: refactor global address sdk.Config Nov 23, 2023
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: 10

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 875a71c and 28344a3.
Files selected for processing (14)
  • client/context.go (2 hunks)
  • client/keys/add.go (1 hunks)
  • client/keys/add_ledger_test.go (4 hunks)
  • client/keys/add_test.go (2 hunks)
  • client/keys/delete_test.go (1 hunks)
  • client/keys/export_test.go (1 hunks)
  • client/keys/rename_test.go (1 hunks)
  • crypto/ledger/ledger_mock.go (1 hunks)
  • tests/integration/runtime/query_test.go (1 hunks)
  • testutil/key.go (2 hunks)
  • testutil/key_test.go (2 hunks)
  • types/address.go (1 hunks)
  • types/config.go (3 hunks)
  • types/config_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/integration/runtime/query_test.go
Additional comments: 13
crypto/ledger/ledger_mock.go (1)
  • 42-47:
    The change from sdk.GetConfig().GetCoinType() to sdk.GetAddressConfig().GetCoinType() correctly reflects the new configuration pattern.
client/keys/export_test.go (1)
  • 93-95: The change from sdk.GetConfig().GetFullBIP44Path() to sdk.GetAddressConfig().GetFullBIP44Path() aligns with the refactor to use the new AddressConfig struct. Ensure that the GetAddressConfig() method is properly implemented and that it returns a valid AddressConfig instance with the correct BIP44 path configuration.
client/keys/add.go (1)
  • 82-82: The flagCoinType is now correctly using the GetAddressConfig().GetCoinType() method to set the default coin type for HD derivation. This change aligns with the refactor to use the new AddressConfig struct instead of the global sdk.Config. Ensure that all other parts of the codebase that rely on the coin type are updated to use GetAddressConfig() as well.
client/context.go (2)
  • 75-79: The AddressConfigs field has been added to the Context struct to hold the new sdk.AddressConfig. This change aligns with the pull request's goal to refactor address configurations.

  • 338-342: The WithAddressConfig method has been correctly implemented to allow updating the Context with a specific sdk.AddressConfig. This method is essential for the new modular approach to address configuration.

client/keys/delete_test.go (1)
  • 36-36:
    The update to use sdk.GetAddressConfig().GetFullBIP44Path() aligns with the refactor to use the new AddressConfig struct.
client/keys/rename_test.go (1)
  • 33-33:
    The update to use sdk.GetAddressConfig().GetFullBIP44Path() aligns with the refactor of the global sdk.Config to use the new AddressConfig struct.
testutil/key_test.go (2)
  • 18-24:
    The refactoring from GetConfig() to GetAddressConfig() is correctly implemented here.

  • 43-49:
    The changes are consistent with the new address configuration pattern.

testutil/key.go (2)
  • 14-20: The NewMnemonic function is being called with sdk.NewAddressConfig().GetFullBIP44Path(), which creates a new AddressConfig each time the function is called. This could lead to inconsistencies if the AddressConfig is meant to be a singleton or if its instantiation is expensive. Verify if AddressConfig should be instantiated once and reused.

  • 63-71: Similar to the previous comment, sdk.NewAddressConfig().GetFullBIP44Path() is used multiple times within the same function, potentially creating multiple instances of AddressConfig. Consider reusing a single instance if applicable.

client/keys/add_ledger_test.go (2)
  • 32-41: The config object is being used to set Bech32 prefixes, but the addressConfig object is used to set the BIP-44 purpose and coin type. This is inconsistent with the summary which states that the global sdk.Config is being refactored in favor of AddressConfig. Verify that the Bech32 prefix settings are also meant to be migrated to the new AddressConfig structure or if they should remain part of the global sdk.Config.

  • 94-100: The addressConfig is being set again with the same values as before, and the global config is being used to set Bech32 prefixes again. This seems redundant and could be a mistake. Verify if this repetition is intentional or if it should be removed to avoid confusion and potential errors.

types/address.go Outdated Show resolved Hide resolved
client/keys/add_test.go Outdated Show resolved Hide resolved
client/keys/add_test.go Outdated Show resolved Hide resolved
types/config.go Show resolved Hide resolved
types/config.go Show resolved Hide resolved
client/keys/add_ledger_test.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
client/context.go Outdated Show resolved Hide resolved
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: 7

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 28344a3 and 2cdd14c.
Files selected for processing (12)
  • client/keys/add.go (1 hunks)
  • client/keys/add_ledger_test.go (4 hunks)
  • client/keys/add_test.go (1 hunks)
  • client/keys/delete_test.go (1 hunks)
  • crypto/ledger/ledger_mock.go (1 hunks)
  • crypto/ledger/ledger_test.go (1 hunks)
  • simapp/simd/cmd/testnet.go (1 hunks)
  • testutil/key.go (3 hunks)
  • testutil/key_test.go (4 hunks)
  • testutil/network/network.go (3 hunks)
  • types/address.go (2 hunks)
  • types/config_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • client/keys/add.go
Additional comments: 15
client/keys/add_ledger_test.go (1)
  • 39-40: Verify if the addressConfig should also be set with a custom coin type to match the test's intention of using a custom configuration.
client/keys/add_test.go (1)
  • 221-238: The changes to the address configuration system are correctly implemented in the test. The addressConfig is properly initialized and used in the clientCtx, and the path variable is correctly derived from clientCtx.AddressConfigs.GetFullBIP44Path() and used in the kb.NewAccount call.
crypto/ledger/ledger_mock.go (1)
  • 42-47: The removal of the derivation path check against sdk.GetConfig().GetCoinType() is consistent with the refactor to use the new AddressConfig struct. Ensure that the validation logic is now correctly implemented elsewhere in the codebase to maintain security and correctness.
crypto/ledger/ledger_test.go (1)
  • 19-21: The TestPublicKeyUnsafe function appears to be unchanged, but ensure that the changes in the global address configuration do not affect the expected behavior of this test, especially since the sdk.CoinType might now be coming from a different configuration source.
simapp/simd/cmd/testnet.go (1)
  • 276-279: The addition of sdk.NewAddressConfig().GetFullBIP44Path() as an argument to GenerateSaveCoinKey aligns with the new address configuration system. Ensure that GenerateSaveCoinKey is updated to handle this new argument and that all other parts of the codebase that interact with address configurations are consistently using the new AddressConfig struct and methods.
testutil/key.go (3)
  • 14-20: The update to use sdk.NewAddressConfig().GetFullBIP44Path() in GenerateCoinKey is consistent with the refactor of the address configuration system.

  • 37-43: The addition of the hdPath parameter to GenerateSaveCoinKey function signature is consistent with the refactor and allows for more flexible key generation.

  • 64-72: The logic for generating or recovering a new account using the provided mnemonic and hdPath is correctly implemented and aligns with the new address configuration system.

testutil/key_test.go (4)
  • 21-21: The summary states that NewFundraiserParams has been replaced with types.CoinType, but the code still uses NewFundraiserParams. Please verify if the summary is accurate or if the code needs to be updated.

  • 35-35: The update to use types.NewAddressConfig().GetFullBIP44Path() in TestGenerateSaveCoinKey aligns with the changes described in the summary.

  • 61-61: The update to use types.NewAddressConfig().GetFullBIP44Path() in TestGenerateSaveCoinKeyOverwriteFlag aligns with the changes described in the summary.

  • 35-35: Ensure that all parts of the codebase that require the BIP44 path have been updated to use the new types.NewAddressConfig().GetFullBIP44Path() method.

Also applies to: 61-61

testutil/network/network.go (3)
  • 135-135: The addition of AddressConfig to the Config struct aligns with the refactor to centralize address configuration.

  • 167-167: Initialization of AddressConfig in the DefaultConfig function is consistent with the refactor to use the new address configuration system.

  • 461-461: The update to include cfg.AddressConfig.GetFullBIP44Path() as an argument to testutil.GenerateSaveCoinKey is consistent with the changes to the address configuration system.

client/keys/delete_test.go Outdated Show resolved Hide resolved
types/config_test.go Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
client/keys/add_ledger_test.go Outdated Show resolved Hide resolved
client/keys/add_ledger_test.go Outdated Show resolved Hide resolved
client/keys/add_ledger_test.go Outdated Show resolved Hide resolved
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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2cdd14c and e3bd0d2.
Files selected for processing (2)
  • types/address.go (2 hunks)
  • types/config_test.go (1 hunks)
Additional comments: 1
types/config_test.go (1)
  • 20-22: The TestKeyringServiceName test case remains valid and unaffected by the refactor.

types/config_test.go Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
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: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e3bd0d2 and ce6e6e8.
Files selected for processing (1)
  • client/keys/delete_test.go (1 hunks)
Additional comments: 2
client/keys/delete_test.go (2)
  • 36-36: The update to use sdk.GetAddressConfig().GetFullBIP44Path() for the path variable is consistent with the refactor of the global address configuration within the SDK.

  • 37-37: Skip this comment as it has been previously addressed.

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 ce6e6e8 and 04b2a7a.
Files selected for processing (2)
  • client/keys/add_ledger_test.go (4 hunks)
  • types/address.go (2 hunks)
Additional comments: 2
types/address.go (2)
  • 731-735: The NewAddressConfig function is correctly named and initializes the AddressConfig with default values.

  • 738-740: The GetFullBIP44Path method correctly returns the BIP44 path using the purpose and coinType fields.

types/address.go Outdated Show resolved Hide resolved
client/keys/add_ledger_test.go Outdated Show resolved Hide resolved
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 04b2a7a and 545c053.
Files selected for processing (10)
  • client/keys/add_ledger_test.go (3 hunks)
  • client/keys/add_test.go (1 hunks)
  • client/keys/delete_test.go (1 hunks)
  • client/keys/export_test.go (1 hunks)
  • client/keys/rename_test.go (1 hunks)
  • simapp/simd/cmd/testnet.go (1 hunks)
  • testutil/key.go (3 hunks)
  • testutil/key_test.go (4 hunks)
  • testutil/network/network.go (1 hunks)
  • types/address.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • client/keys/export_test.go
  • testutil/key_test.go
Additional comments: 13
client/keys/add_ledger_test.go (3)
  • 35-37: The code correctly sets the Bech32 prefixes for account, validator, and consensus node addresses. This is necessary for the test to reflect the address formats used in the specific blockchain network being tested.

  • 52-56: The test case Test_runAddCmdLedgerWithCustomCoinType is correctly setting up the command and its flags. It's important to ensure that the flags are consistent with the command's expected behavior.

  • 86-87: The test case Test_runAddCmdLedgerWithCustomCoinType checks the string representation of the public key. It's important to ensure that the expected public key string is correct and matches the output of the ledger device or mock being used.

client/keys/add_test.go (1)
  • 233-235: The change from sdk.GetConfig().GetFullBIP44Path() to sdk.GetFullBIP44Path() aligns with the refactor in the SDK to centralize the management of address configurations. Ensure that the new method sdk.GetFullBIP44Path() is correctly implemented and that it provides the expected BIP44 path in the context of this test.
client/keys/delete_test.go (1)
  • 36-36: The change in how the BIP44 path is retrieved is consistent with the refactor described in the pull request summary. Ensure that the new method sdk.GetFullBIP44Path() is correctly implemented and that all tests and usages have been updated accordingly.
client/keys/rename_test.go (1)
  • 33-33: The change from sdk.GetConfig().GetFullBIP44Path() to sdk.GetFullBIP44Path() should be verified to ensure that the new function provides the correct BIP44 path without requiring additional context or configuration.
simapp/simd/cmd/testnet.go (1)
  • 276-276: The use of sdk.GetFullBIP44Path() to provide the HD path for the GenerateSaveCoinKey function aligns with the new AddressConfig struct and its methods. Ensure that the sdk.GetFullBIP44Path() function is implemented correctly and returns the expected BIP44 path based on the new address configuration system.
testutil/key.go (3)
  • 14-20: The update to use sdk.GetFullBIP44Path() directly in GenerateCoinKey is consistent with the refactor described in the summary.

  • 37-41: The addition of the hdPath parameter to GenerateSaveCoinKey aligns with the refactor to improve key management by introducing more structured handling of BIP-0044 paths.

  • 64-72: The use of the hdPath parameter in the GenerateSaveCoinKey function for generating or recovering a new account is in line with the changes described in the summary.

testutil/network/network.go (1)
  • 458-458: The addition of sdk.GetFullBIP44Path() as an argument to testutil.GenerateSaveCoinKey is consistent with the changes described in the summary. Ensure that the sdk.GetFullBIP44Path() function is implemented as expected and that all necessary parts of the codebase are updated to use this new approach for obtaining the BIP44 path.
types/address.go (2)
  • 32-35: The removal of commented-out configuration setup lines is a good cleanup, considering the new AddressConfig system.

  • 713-714: The new GetFullBIP44Path function correctly uses the Purpose and CoinType constants to return the BIP44 path.

client/keys/delete_test.go Outdated Show resolved Hide resolved
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: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 545c053 and d906067.
Files selected for processing (1)
  • client/keys/delete_test.go (1 hunks)
Additional comments: 1
client/keys/delete_test.go (1)
  • 36-36: The change in how the BIP44 path is retrieved aligns with the refactor described in the pull request summary. Ensure that the new method sdk.GetFullBIP44Path() is correctly implemented and that it does not introduce any regressions or unexpected behavior in the test cases.

@bizk bizk enabled auto-merge November 28, 2023 18:10
@bizk bizk disabled auto-merge November 28, 2023 18:10
@cosmos cosmos deleted a comment from coderabbitai bot Nov 28, 2023
Copy link
Contributor Author

@bizk bizk left a comment

Choose a reason for hiding this comment

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

Reviewed

Copy link
Contributor

coderabbitai bot commented Nov 28, 2023

Walkthrough

Walkthrough

The overarching change involves the removal of global configuration for address coin types and purposes, as well as the global sdk.Config in the Cosmos SDK. This refactoring aims to eliminate poor design choices related to global variables, enhance modularity, and ensure the core SDK remains minimal and well-designed. The changes affect how BIP44 paths are handled, with direct references to SDK functions replacing previous global config calls, and the removal of certain functions and tests related to the now-obsolete global config.

Changes

File Pattern Change Summary
types/..., client/keys/..., crypto/ledger/..., simapp/..., tests/..., testutil/... Removal of global config calls for setting and getting coin types and purposes; direct usage of sdk.CoinType and sdk.GetFullBIP44Path() instead.
client/keys/add_ledger_test.go, client/keys/add_test.go, client/keys/delete_test.go, client/keys/export_test.go, client/keys/rename_test.go Adjustments in test functions to use sdk.GetFullBIP44Path() instead of sdk.GetConfig().GetFullBIP44Path().
crypto/ledger/ledger_mock.go, crypto/ledger/ledger_test.go Removal of checks against the coin type in the ledger mock and changes in the ledger tests to align with the new key generation approach.
types/address.go, types/config.go, types/config_test.go Removal of SetCoinType, SetPurpose, and their corresponding getters; addition of GetFullBIP44Path function; removal of tests for removed functions.

Assessment against linked issues

Objective Addressed Explanation
Remove global bech32 prefixes from the SDK (#7448) The summary does not explicitly mention the removal of bech32 prefixes, but the overall direction of removing global config suggests this may have been addressed.
Eliminate the rest of the global sdk.Config before the v1.0 release (#7448)
Address the issue of global config variables being a poor design choice (#7448)
Keep the core SDK minimal and ensure modularity (#7448)
Leverage changes from issue #7242 for address parsing within handlers (#7448) The summary does not provide details on changes related to address parsing within handlers.
Consider proposals for removing bech32 prefixes as outlined in issues #9690 and #13140 (#7448) The summary does not provide details on whether proposals from these issues were considered.
Explore the possibility of removing sdk.Config entirely (#7448) The changes indicate a move towards removing sdk.Config.
Evaluate the initial proposal to pass parameters into keepers or attach them to sdk.Context (#7448) The summary does not provide details on the implementation of this proposal.
Assess the potential removal of ValAddress and ConsAddress from types/ (#7448) The summary does not mention changes related to ValAddress and ConsAddress.

The assessment indicates that while the main objectives related to the removal of global sdk.Config and enhancing modularity have been addressed, the summary does not provide enough information to confirm the status of all specific objectives, particularly those related to bech32 prefixes and the handling of address parsing within handlers.


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0c633a5 and 246aedb.
Files selected for processing (17)
  • CHANGELOG.md (1 hunks)
  • client/keys/add.go (1 hunks)
  • client/keys/add_ledger_test.go (3 hunks)
  • client/keys/add_test.go (1 hunks)
  • client/keys/delete_test.go (1 hunks)
  • client/keys/export_test.go (1 hunks)
  • client/keys/rename_test.go (1 hunks)
  • crypto/ledger/ledger_mock.go (1 hunks)
  • crypto/ledger/ledger_test.go (1 hunks)
  • simapp/simd/cmd/testnet.go (1 hunks)
  • tests/integration/runtime/query_test.go (1 hunks)
  • testutil/key.go (3 hunks)
  • testutil/key_test.go (4 hunks)
  • testutil/network/network.go (1 hunks)
  • types/address.go (2 hunks)
  • types/config.go (3 hunks)
  • types/config_test.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • client/keys/rename_test.go
  • tests/integration/runtime/query_test.go
Additional comments: 20
CHANGELOG.md (1)
  • 69-69: The changelog entry correctly summarizes the significant change made by pull request #18372. It is clear and concise, indicating the removal of the global configuration for address coin type and purpose.
client/keys/add.go (1)
  • 79-85: The change from sdk.GetConfig().GetCoinType() to sdk.CoinType in flagCoinType is consistent with the refactor to remove global configuration. Ensure that sdk.CoinType is properly initialized before this point in the code.
client/keys/add_ledger_test.go (2)
  • 32-41: The removal of global Bech32 prefix configuration is consistent with the refactor to remove global configurations. Ensure that the Bech32 prefix is now being set correctly elsewhere in the codebase.

  • 49-56: The addition of cmd := AddKeyCommand() and cmd.Flags().AddFlagSet(Commands().PersistentFlags()) in the first test function is consistent with the refactor to remove global configurations and to ensure that the command is properly configured for the test.

client/keys/add_test.go (1)
  • 233-235: The change from sdk.GetConfig().GetFullBIP44Path() to sdk.GetFullBIP44Path() aligns with the refactor to remove global configuration and use direct function calls instead. Ensure that the new function sdk.GetFullBIP44Path() provides the correct BIP44 path as expected in the context of this test.
client/keys/delete_test.go (1)
  • 36-36: The update to use sdk.GetFullBIP44Path() directly aligns with the refactor to remove global configuration for address coin type and purpose. Ensure that the new method provides the correct BIP44 path as expected in the context of this test.
client/keys/export_test.go (1)
  • 93-95: The change from sdk.GetConfig().GetFullBIP44Path() to sdk.GetFullBIP44Path() is consistent with the refactor described in the pull request summary. Ensure that the new method provides the correct BIP44 path as expected by the NewAccount function.
crypto/ledger/ledger_mock.go (1)
  • 42-43: The removal of the derivation path validation against the coin type is a significant change. Ensure that the new validation logic is implemented elsewhere to maintain the security and correctness of the key derivation process.
crypto/ledger/ledger_test.go (1)
  • 19-21: The change from NewParams to NewFundraiserParams in TestPublicKeyUnsafe is consistent with the refactor and the pull request's goal to streamline key generation and account recovery.
simapp/simd/cmd/testnet.go (1)
  • 276-279: The addition of sdk.GetFullBIP44Path() as an argument to testutil.GenerateSaveCoinKey is consistent with the refactor to remove global configuration for address coin type and purpose. Ensure that the sdk.GetFullBIP44Path() function is available and correctly returns the full BIP44 path as expected in this context.
testutil/key.go (3)
  • 14-20: The update to use sdk.GetFullBIP44Path() directly aligns with the refactor to remove global configuration dependency.

  • 37-43: The addition of the hdPath parameter to GenerateSaveCoinKey function signature is a good practice to allow more flexibility in specifying the BIP44 path.

  • 64-72: The logic to handle both generation and recovery of a key based on the provided mnemonic is correctly implemented.

testutil/key_test.go (5)
  • 21-21: The use of types.CoinType directly aligns with the refactor to remove global configuration. Ensure that types.CoinType is correctly defined and accessible in the context where this test is run.

  • 35-35: The addition of types.GetFullBIP44Path() as an argument to GenerateSaveCoinKey is consistent with the refactor. Verify that types.GetFullBIP44Path() is implemented correctly and provides the expected BIP44 path.

  • 61-61: The addition of types.GetFullBIP44Path() as an argument to GenerateSaveCoinKey is consistent with the refactor. Verify that types.GetFullBIP44Path() is implemented correctly and provides the expected BIP44 path.

  • 65-65: The test for the overwrite functionality of GenerateSaveCoinKey with overwrite=false is important to ensure that existing keys are not overwritten unintentionally. This test should fail if an attempt is made to overwrite an existing key without setting the flag to true.

  • 69-69: The test for the overwrite functionality of GenerateSaveCoinKey with overwrite=true is important to ensure that existing keys can be intentionally overwritten when required. This test should pass if the flag is set to true and the key is successfully overwritten.

testutil/network/network.go (1)
  • 458-458: The addition of sdk.GetFullBIP44Path() as an argument to testutil.GenerateSaveCoinKey aligns with the refactor to remove global configuration for address coin type and purpose. Ensure that the GenerateSaveCoinKey function has been updated to handle this new argument and that all parts of the code that interact with this function are updated to pass the correct BIP44 path.
types/config_test.go (1)
  • 20-22: The test case TestConfig_SetTxEncoder is using the deprecated sdk.NewConfig() and Seal() method. However, since the test functions TestConfig_SetPurpose and TestConfig_SetCoinType have been removed, this test case should also be updated or removed if it's no longer relevant due to the refactor.

types/address.go Show resolved Hide resolved
testutil/key.go Show resolved Hide resolved
testutil/key.go Show resolved Hide resolved
client/keys/add_ledger_test.go Show resolved Hide resolved
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

utACK

@julienrbrt
Copy link
Member

nit, this does not close the mentioned issue. We should just reference it.

@@ -128,18 +127,6 @@ func (config *Config) SetFullFundraiserPath(fullFundraiserPath string) {
config.fullFundraiserPath = fullFundraiserPath
}

// Set the BIP-0044 Purpose code on the config
func (config *Config) SetPurpose(purpose uint32) {
Copy link
Member

Choose a reason for hiding this comment

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

Have you checked on sourcegraph if those were used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is being used in some chains, but as far as I can see, all of them use types.Purpose directly. GetPurpose is only used on tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So Get/SetPurpose is redundant, since it is never really used

types/config.go Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
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: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 246aedb and 21d6c7d.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 69-69: The changelog entry correctly reflects the changes described in the summary regarding the removal of global configuration for coin type and purpose. Ensure that the associated code changes are also included in the pull request.

@tac0turtle tac0turtle added this pull request to the merge queue Nov 29, 2023
Merged via the queue into cosmos:main with commit a37f416 Nov 29, 2023
57 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:Keys Keybase, KMS and HSMs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove address parameters from global sdk.Config
6 participants