Skip to content

Conversation

@sorpaas
Copy link
Member

@sorpaas sorpaas commented Dec 12, 2025

The implementation of uint256 plays a considerable role for EVM performance. The underlying uint256 library used right now in rust-evm is primitive-types, but it's known that it's not the best performant out there.

This PR adds an alternative implementation, ruint, which is known to be faster than primitive-types in certain situations.

The alternative implementations will be used if the corresponding feature flags are enabled (if no feature flag is enabled, then by default it will continue to use primitive-types).

A long-term goal for this design choice of this PR is also to unify where the uint256 type is referred -- if, one day, Rust gets a native u256 type, then we want to move to it (and hopefully without much hassle).

Remove all reference of primitive_types except in evm_interpreter::uint.
Eventually this will allow us to support multiple underlying uint types.
We still need to implement those trait functions.
There's no reason to break it, just adding a few old functions back.
We expect frequent change in this trait, so we don't want it to be part of the
public API.
External crates are not allowed to use U256Ext.
Too different compared with primitive-types and ruint to reliably support.
Some semantics doesn't follow common uint standard.
Perhaps at a later date when we have type alias impl trait.
@sorpaas sorpaas added this pull request to the merge queue Dec 14, 2025
Merged via the queue into master with commit 6cb53ef Dec 14, 2025
5 checks passed
@sorpaas sorpaas deleted the sp-uint branch December 14, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants