Skip to content

feat: derive Hash for evm_rpc_types hex wrappers#596

Open
sueun-dev wants to merge 1 commit into
dfinity:mainfrom
sueun-dev:derive-hash-for-hex-types
Open

feat: derive Hash for evm_rpc_types hex wrappers#596
sueun-dev wants to merge 1 commit into
dfinity:mainfrom
sueun-dev:derive-hash-for-hex-types

Conversation

@sueun-dev

Copy link
Copy Markdown

Fixes #393.

What changed:

  • Derived Hash for the evm_rpc_types hex wrappers generated by impl_hex_string!.
  • Derived Hash for the internal Byte wrapper so HexByte is covered too.
  • Added regression coverage for Hex20 as a HashMap key and HexByte, Hex32, Hex256, and Hex in HashSets.

Why:
These wrappers already compare by decoded bytes through Eq, so hashing the same inner values is consistent with their equality behavior. This lets callers use hash-based collections when they need them without changing Candid, serde, display, or parsing behavior.

Checked:

  • cargo test -p evm_rpc_types
  • cargo test -p evm_rpc_types --all-features

Copilot AI review requested due to automatic review settings May 28, 2026 17:48
@sueun-dev
sueun-dev requested a review from a team as a code owner May 28, 2026 17:48
@cla-idx-bot

cla-idx-bot Bot commented May 28, 2026

Copy link
Copy Markdown

Dear @sueun-dev,

In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA.

If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged.

— The DFINITY Foundation

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR enables Ethereum hex-string wrapper types to be used as keys in hash-based collections by deriving Hash, and adds a unit test that exercises HashMap/HashSet usage for several hex types.

Changes:

  • Derive Hash for all hex-string wrapper types generated by impl_hex_string!.
  • Derive Hash for Byte.
  • Add a test validating Hex20, Hex32, HexByte, Hex, and Hex256 can be used in HashMap/HashSet.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
evm_rpc_types/src/tests.rs Adds a new unit test that checks hex wrapper types work as hash keys/values in HashMap/HashSet.
evm_rpc_types/src/lib.rs Adds Hash derives to hex wrapper types and Byte to support usage in hash-based collections.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sueun-dev
sueun-dev force-pushed the derive-hash-for-hex-types branch from bb4fad4 to 455ba3c Compare May 28, 2026 17:58

@gregorydemay gregorydemay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this PR @sueun-dev !

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.

Hash trate for Hex structs in evm-rpc-types

3 participants