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!: gas consumption for stateful precompiles #26

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

ARR4N
Copy link
Collaborator

@ARR4N ARR4N commented Sep 16, 2024

Why this should be merged

Support simultaneous running of a stateful precompile and computation of its gas consumption.

Closes #17. Re the Caution in said issue, the 63/64 rule is already handled by geth.

How this works

The requiredGas func(...) argument of NewStatefulPrecompile() is removed. In its place, the function signature of a stateful precompile accepts supplied gas and returns gas remaining; this was renamed from PrecompiledStatefulRun to PrecompiledStatefulContract as it's no longer just the execution.

type PrecompiledStatefulContract func(env PrecompileEnvironment, input []byte, suppliedGas uint64) (ret []byte, remainingGas uint64, err error)

How this was tested

Existing unit tests for stateful precompiles, refactored accordingly.

@ARR4N ARR4N marked this pull request as ready for review September 16, 2024 18:57
@ARR4N ARR4N requested review from a team, darioush, ceyonur and michaelkaplan13 and removed request for a team September 16, 2024 18:57
@ARR4N ARR4N merged commit c5da3ca into libevm Sep 17, 2024
3 checks passed
@ARR4N ARR4N deleted the arr4n/stateful-precompile-gas branch September 17, 2024 16:59
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.

Dynamic gas for stateful precompiles
2 participants