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

feat: abstract RPC error over HaltReason #14104

Merged
merged 4 commits into from
Jan 30, 2025
Merged

Conversation

klkvr
Copy link
Collaborator

@klkvr klkvr commented Jan 30, 2025

Introduces HaltReason AT for EVM traits and FromEvmHalt trait which is required to be implemented by RPC implementation error.

For now the default halt reason is used everywhere because current revm does not yet have ResultAndState generic over it, but it should be easy to plug into existing traits once we migrate to new revm.

Base automatically changed from klkvr/generic-errors to main January 30, 2025 13:14
@github-actions github-actions bot requested a review from rkrasiuk as a code owner January 30, 2025 13:14
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

makes sense,
some (doc) nits

crates/evm/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +330 to +332
ExecutionResult::Revert { .. } | ExecutionResult::Halt { .. } => {
// We know that transaction succeeded with a higher gas limit before, so any failure
// means that we need to increase it.
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, this now exempts all haltreasons, I am not sure if this is okay.
judging from the docs it might because we don't expect those.
so this seems fine,
I'd like to keep the docs+context here

@mattsse mattsse added A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library labels Jan 30, 2025
@klkvr klkvr requested a review from mattsse January 30, 2025 18:13
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

last nit :)

Comment on lines -340 to -354
// Both `OutOfGas` and `InvalidEFOpcode` can occur dynamically if the gas
// left is too low. Treat this as an out of gas
// condition, knowing that the call succeeds with a
// higher gas limit.
//
// Common usage of invalid opcode in OpenZeppelin:
// <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/94697be8a3f0dfcd95dfb13ffbd39b5973f5c65d/contracts/metatx/ERC2771Forwarder.sol#L360-L367>

// Increase the lowest gas limit.
*lowest_gas_limit = tx_gas_limit;
}
err => {
// These cases should be unreachable because we know the transaction
// succeeds, but if they occur, treat them as an
// error.
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we keep these docs, why we don't return an error on halt here?

@mattsse mattsse added this pull request to the merge queue Jan 30, 2025
Merged via the queue into main with commit 28f2690 Jan 30, 2025
44 checks passed
@mattsse mattsse deleted the klkvr/generic-halt-reason branch January 30, 2025 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants