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

core/{state, vm}: update stateless gas costs to follow the verkle-gen-7 testnet #31014

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gballet
Copy link
Member

@gballet gballet commented Jan 10, 2025

Adding values to the witness introduces a new class of issues for computing gas: if there is not enough gas to cover adding an item to the witness, then the item should not be added to the witness.

The problem happens when several items are added together, and that process runs out of gas. The witness gas computation needs a way to signal that not enough gas was provided. These values can not be hardcoded, however, as they are context dependent, i.e. two calls to the same function with the same parameters can give two different results.

The approach is to return both the gas that was actually consumed, and the gas that was necessary. If the values don't match, then a witness update OOG'd. The caller should then charge the consumed value (remaining gas will be 0) and error out.

Why not return a boolean instead of the wanted value? Because when several items are touched, we want to distinguish which item lacked gas.

@gballet gballet added the verkle label Jan 10, 2025
@gballet gballet force-pushed the kaustinen7-gas-costs branch 2 times, most recently from 9f3ab25 to c92a0d4 Compare January 10, 2025 09:36
// list in write mode. If there is enough gas paying for the addition of the code
// hash leaf to the access list, then account creation will proceed unimpaired.
// Thus, only pay for the creation of the code hash leaf here.
wgas := evm.AccessEvents.CodeHashGas(addr, true, gas, false)
Copy link
Member

Choose a reason for hiding this comment

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

If the available gas is not sufficient to pay the cost, availableGas will be returned.

Originally, the evm execution should stop without executing this operation;
Now, the evm execution will execute this operation, and may stop later;

Copy link
Member Author

Choose a reason for hiding this comment

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

already responded during standup - good idea but that's a spec change so we should try to fix it over time but this is what the testnet does.

@gballet gballet force-pushed the kaustinen7-gas-costs branch from 1ceb3e2 to e7dd2e9 Compare January 30, 2025 16:59
@gballet gballet marked this pull request as ready for review January 30, 2025 17:04
@gballet gballet requested a review from holiman as a code owner January 30, 2025 17:04
@rjl493456442 rjl493456442 self-assigned this Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants