cosmos-sdk icon indicating copy to clipboard operation
cosmos-sdk copied to clipboard

refactor!: (partially) Decouple cometbft/crypto deps

Open raynaudoe opened this issue 8 months ago • 2 comments

Description

This PR contributes to solve the following issues:

  • https://github.com/cosmos/cosmos-sdk/issues/17425
  • https://github.com/cosmos/cosmos-sdk/issues/7357

Most imports made from cometbft/cometbft/crypto were removed and replaced with the (same) code in the new cosmos/cripto repo.

Important: go.mod points to a commit instead to a release of such repo (TODO after this PR's review)

Changes made:

  • replaced imports from cometbft/crypto to cosmos/crypto.
  • New PubKey and PrivKey interfaces design:
    • Base interfaces are now defined here
    • Sdk types are just those types composed with proto.Message
    • Removed LedgerPrivKey type.
  • All sha256 related ops are now imported from cosmos/crypto/hash/sha256
  • Random ops were moved to cosmos/crypto/random
  • Deleted code from the sdk that now lives in cosmos/crypto

TODO (for subsequent PRs):

  • Move curves (both defined in sdk and the ones imported from cometbft's) to cosmos/crypto/curves
  • Abstract out code in cosmos-sdk/crypto/codec from cometbft's types

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...

  • [x] included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • [x] confirmed ! in the type prefix if API or client breaking change
  • [x] targeted the correct branch (see PR Targeting)
  • [x] provided a link to the relevant issue or specification
  • [x] reviewed "Files changed" and left comments if necessary
  • [x] included the necessary unit and integration tests
  • [x] added a changelog entry to CHANGELOG.md
  • [x] updated the relevant documentation or specification, including comments for documenting Go code
  • [x] 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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • [ ] confirmed the correct type prefix in the PR title
  • [ ] confirmed all author checklist items have been addressed
  • [ ] reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Updated keyring interface for enhanced consistency in cryptographic operations.
    • Added SHA-256 hashing capabilities for improved transaction integrity.
  • Bug Fixes

    • Improved hashing functions for better security in signing and verification processes.
  • Dependencies

    • Added new dependencies on github.com/cosmos/crypto to enhance cryptographic functionalities.
  • Chores

    • Refactored import statements to align with updated packages and improved code readability.

raynaudoe avatar Jun 21 '24 18:06 raynaudoe