Skip to content
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: bubble up PrecompileError #2191

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Wodann
Copy link
Contributor

@Wodann Wodann commented Mar 11, 2025

Precompile errors are represented as a String, but there doesn't seem to be anything limiting us from bubbling up the PrecompileError type. This gives us better static typing for precompile errors.

Copy link

codspeed-hq bot commented Mar 11, 2025

CodSpeed Performance Report

Merging #2191 will degrade performances by 4.78%

Comparing NomicFoundation:refactor/precompile-error (48f6528) with main (f2a2eb7)

Summary

❌ 1 regressions
✅ 7 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
precompile bench | ecrecover precompile 194.7 µs 204.5 µs -4.78%

Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

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

PrecompileError is an internal error similar to Halt, so it is not possible to bubble it up to outside. It is converted to InterpreterResult.

@Wodann
Copy link
Contributor Author

Wodann commented Mar 12, 2025

PrecompileError is an internal error similar to Halt, so it is not possible to bubble it up to outside. It is converted to InterpreterResult.

I could be wrong, but we actually do convert PrecompileError to an EVMError here:
https://github.com/bluealloy/revm/blob/main/crates/precompile/src/interface.rs#L69

It's also exposed in EvmError::Precompile as a String. So we are actually exposing the error, as far as I can tell.

@Wodann
Copy link
Contributor Author

Wodann commented Mar 12, 2025

CodSpeed Performance Report

Merging #2191 will degrade performances by 4.78%

Comparing NomicFoundation:refactor/precompile-error (48f6528) with main (f2a2eb7)

Summary

❌ 1 regressions ✅ 7 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
precompile bench | ecrecover precompile 194.7 µs 204.5 µs -4.78%

I expect the performance regression to be a result of the usage of a nested enum with String. This could be avoided by using enum variants for the BLS12_381 precompile. Something like:

pub enum Error {
    ...
    #[error("G1ADD input should be {G1_ADD_INPUT_LENGTH} bytes, was {length}")]
    InvalidG1AddInputLength { length: usize },
    ...
}

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