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(blockifier): support reverted sierra gas tracking and charging #3011

Closed

Conversation

dorimedini-starkware
Copy link
Collaborator

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

github-actions bot commented Dec 29, 2024

Artifacts upload workflows:

@dorimedini-starkware dorimedini-starkware force-pushed the dori/support-sierra-gas-revert branch from aa9044a to 28a4104 Compare December 29, 2024 20:40
Copy link
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 10 files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware)


crates/blockifier/src/execution/entry_point.rs line 179 at r1 (raw file):

                context
                    .sierra_gas_revert_tracker
                    .set_gas_consumed_directly(GasAmount(call_info.execution.gas_consumed));

Note that the c-tor is calling this function. Setting the gas consumed directly should be done just for execute entrypoint.

Suggestion: instead, update the remaining gas regularly with call_info.initial_gas + call_info.gas_consumed, and pass the call_info.tracked_resource as an argument. to the update func.

Code quote:

            if call_info.execution.failed {
                // For Cairo1 revert, need to explicitly set the amount of gas to revert from the
                // call info.
                context
                    .sierra_gas_revert_tracker
                    .set_gas_consumed_directly(GasAmount(call_info.execution.gas_consumed));

crates/blockifier/src/execution/syscalls/hint_processor.rs line 493 at r1 (raw file):

        //    the current tracked value), or we will pass through another syscall before failing -
        //    and by induction (we will reach this point again), the gas will be charged correctly.
        if self.base.context.tracked_resource_stack.last() == Some(&TrackedResource::CairoSteps) {

Suggestion:

Some(&TrackedResource::SierraGas) {

Copy link
Collaborator Author

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 10 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware and @Yoni-Starkware)


crates/blockifier/src/execution/entry_point.rs line 179 at r1 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Note that the c-tor is calling this function. Setting the gas consumed directly should be done just for execute entrypoint.

Suggestion: instead, update the remaining gas regularly with call_info.initial_gas + call_info.gas_consumed, and pass the call_info.tracked_resource as an argument. to the update func.

Done.


a discussion (no related file):
closed in favor of this stack


crates/blockifier/src/execution/syscalls/hint_processor.rs line 493 at r1 (raw file):

        //    the current tracked value), or we will pass through another syscall before failing -
        //    and by induction (we will reach this point again), the gas will be charged correctly.
        if self.base.context.tracked_resource_stack.last() == Some(&TrackedResource::CairoSteps) {

Done.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants