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

perf: more lightweight second gas limit #76

Closed
wants to merge 1 commit into from
Closed

Conversation

joonazan
Copy link
Contributor

The validation gas limit requires being able to limit the amount of gas that is processed. The original implementation had to scan through the whole callstack on every single instruction. This fixes that so that the scan is done at most once per call.

Copy link
Contributor

@slowli slowli left a comment

Choose a reason for hiding this comment

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

I may be missing something, but I think this logic doesn't always work. Suppose we have gas_limit = 1000 with the execution in the bootloader with 10000 gas left; i.e., initially minimum_gas = 10000 - 1000 = 9000. Suppose the bootloader calls into another contract passing 500 gas to it. Then, since 500 < minimum_gas, minimum_gas will be updated to 500.saturating_sub(1000 - spent) = 0 (assuming spent is sufficiently small). Then, self.state.current_frame.gas < minimum_gas will always be false (including after the called contract returns), so gas limiting won't work.

@joonazan joonazan closed this Oct 4, 2024
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