-
Notifications
You must be signed in to change notification settings - Fork 193
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(evm)!: replace HexAddr
with EIP55Addr
#2004
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes introduce a significant refactor of Ethereum address handling in the codebase, transitioning from the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Keeper
participant EVM
participant AddressValidator
User->>CLI: Create FunToken
CLI->>Keeper: Call CreateFunToken()
Keeper->>AddressValidator: Validate EIP55Addr
AddressValidator-->>Keeper: Return Validity
Keeper->>EVM: Process Token Creation
EVM-->>Keeper: Confirmation of Creation
Keeper-->>CLI: Return Success
CLI-->>User: FunToken Created Successfully
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
HexAddr
with EIP55Addr
HexAddr
with EIP55Addr
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2004 +/- ##
==========================================
- Coverage 65.85% 65.84% -0.02%
==========================================
Files 261 261
Lines 16435 16413 -22
==========================================
- Hits 10824 10807 -17
+ Misses 4802 4798 -4
+ Partials 809 808 -1
|
There isn't actually a tradeoff in safety here. Writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this accomplishes what we wanted 🙌
For documentation purposes: Since any 20-byte array is a valid Ethereum address, |
Context
Please see https://eips.ethereum.org/EIPS/eip-55 for the EIP-55 spec.
Purpose / Abstract
Instead of having a
HexAddr
type that "sublasses" the primitivestring
type, we introduce anEIP55Addr
type which "subclasses"gethcommon.Address
.EIP55Addr
is a stricter type thanHexAddr
, because only valid representations ofgethcommon.Address
are validEIP55Addr
s. We also still inherit fromsdk.CustomProtobufType
, keeping the benefit of usingEIP55Addr
as a custom proto field and allowing it to be serialized into collections state, but avoiding the pitfall described below:HexAddr
was dangerous because one could doaddr := eth.HexAddr("KEVIN")
and bypass the validation checks inHexAddr.Valid()
.EIP55Addr
requires the creator to useNewEIP55AddrFromStr
or pass a validgethcommon.Address
toEIP55Addr{Address: addr}
, andgethcommon.Address
is a canonical 20-byte array, so it can never have alternative representations (e.g. mixed-case alphanumeric characters, or alternative lengths).The underlying
gethcommon.Address
can be accessed viaeip55Addr.Address
, providing a field lookup instead of re-calculating the entiregethcommon.Address
from a string. We also inherit all of thegethcommon.Address
methods, likeString()
andBytes()
, which are helpful for proto marshalling.The PR also refactors tests to use the new
EIP55Addr
type.BREAKING CHANGE: changes underlying proto types from
HexAddr
toEIP55Addr
.Summary by CodeRabbit
New Features
Bug Fixes
Refactor
HexAddr
withEIP55Addr
in relevant components for consistent address handling.Tests