Skip to content

ADR for modular transaction hashing #342

Closed

Description

@thanethomson

CometBFT should support pluggable cryptographic functionality in order to allow users to address a wider range of use cases than possible with the default cryptography we provide. At present the only way they can do this is to fork the project.

Specific use cases here are to be clarified so the team understands what kinds of interface(s) to implement. Another concern potentially addressed by this is one of mitigating security-related risk through isolation of cryptography-related dependencies (probably our highest-impact dependencies) in order to make them easier to replace in case of vulnerabilities.

The first thing we need here is a design in the form of an ADR, and it must be clear from the ADR as to how the aforementioned use cases could be implemented using the design.

Activity

  1. added
    enhancement
    crypto
    on Feb 13, 2023
  2. itsdevbear commented on Feb 13, 2023

    @itsdevbear

    +1, we are currently trying to find a cleaner way to implement querying Ethereum formatted transactions on a CometBFT based chain, and the mismatch of RLP vs Sha256 makes it a requirement to store a mapping of EthHashes to CometTxHashes in some sort of off-chain database. We toyed with the idea of storing this in on chain state, but it creates a state bloat issue since these would be non-prunable.

    By adding the ability to have pluggable hashes, we could ensure that these transactions would return the identical hash as to what would be created if one was processing the same transaction on Ethereum mainnet.

  3. JayT106 commented on Feb 16, 2023

    @JayT106
    Contributor

    in the past, we had similar discussions, and ADR
    tendermint/tendermint#6539

  4. added
    P:consensus-engine-devs
    and removed on Jun 20, 2023
  5. adizere commented on Dec 6, 2023

    @adizere
    Contributor

    Evmos also signalled the need for this recently. We'll likely prioritize this into v1.

  6. added this to the 2024-Q1 milestone on Jan 12, 2024
  7. 1 remaining item

  8. adizere commented on Jan 12, 2024

    @adizere
    Contributor

    I had a look over PR evmos#1. I tried to understand the impact of porting those changes to CometBFT mainline.

    Very much in favor of landing that upstream. Will let @melekes have a more detailed look.

    Additionally, I wonder if we can reduce the amount of dependencies app <> CometBFT. Specifically, from a "beginner's mind" perspective it's concerning that CometBFT needs ability to decode transactions. I looked around the codebase and TxDecoderFn actually does not seem necessary.

    There's 2 cases where CometBFT depends on TxDecoderFn in the above PR:

    1/ Mempool. Ref here. I suspect we might be able to remove this dependency. Instead of CometBFT (a) decoding transactions, then (b) passing them decoded to the app for CheckTx; Comet can simply pass to the app in CheckTx raw transactions and the app itself handles decoding while handling CheckTx.

    2/ BlockExecutor. Ref here. Instead of CometBFT (a) obtaining the ResponsePrepareProposal, and then (b) decoding that response; the application can be assumed to provide in ResponsePrepareProposal decoded transactions, which Comet subsequently uses to build the block.

    We could get to a state where there is no need altogether for type TxDecoderFn. Also, TxI could look as follows, note only Hash seems essential from a quick glance in the codebase:

    type TxI interface {
      // Essential
      Hash() []byte
    
      // The tx comes in as a []byte from wire
      // Bytes() []byte
    
      // Needed for mempool & mempool cache
      // Replaceable with a basic Digest(), or with
      // the Hash() method above
      // Key() TxKey
    
      // Needed only for logging, not necessary
      // String() string
    }

    I might be missing something, but the above would likely improve dev UX. Let's clarify if these simplification are feasible and land them.

  9. self-assigned this
    on Feb 5, 2024
  10. changed the title [-]Pluggable cryptography[/-] [+]ADR for modular transaction hashing[/+] on Mar 9, 2024
  11. linked a pull request that will close this issuedocs(ADR): #113 Modular transaction hashing #2241on Mar 9, 2024
  12. moved this from Todo to In Progress in CometBFTon Mar 13, 2024
  13. fedekunze commented on Mar 16, 2024

    @fedekunze
      // Needed only for logging, not necessary
      // String() string

    The String() is necessary otherwise the hash is by default represented as uppercases, which is non-compatible with the Ethereum hash format (0x...)

  14. modified the milestones: 2024-Q1, 2024-Q2 on Mar 28, 2024
  15. moved this from In Progress to Blocked in CometBFTon Apr 15, 2024
  16. adizere commented on Jun 19, 2024

    @adizere
    Contributor

    // Needed only for logging, not necessary
    // String() string
    The String() is necessary otherwise the hash is by default represented as uppercases, which is non-compatible with the Ethereum hash format (0x...)

    Good, we'll keep it then.

  17. added a commit that references this issue on Jun 20, 2024
    31220bf
  18. moved this from Blocked to Done in CometBFTon Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P:consensus-engine-devscryptoenhancementsecurity

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions