Skip to content

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, ceyonur, darioush 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