Skip to content

feat(blockifier): exclude l1_data_gas from accounts in VC #5185

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

Merged

Conversation

nimrod-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@nimrod-starkware nimrod-starkware self-assigned this Mar 23, 2025
Copy link
Contributor Author

nimrod-starkware commented Mar 23, 2025

@nimrod-starkware nimrod-starkware marked this pull request as ready for review March 23, 2025 14:21
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/add_to_vc branch from 762f180 to be513b8 Compare March 25, 2025 07:38
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch from 2417026 to 15b9b32 Compare March 25, 2025 07:38
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/add_to_vc branch from be513b8 to d8b6bb5 Compare March 25, 2025 07:51
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch from 15b9b32 to d6174bc Compare March 25, 2025 07:51
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/add_to_vc branch from d8b6bb5 to 565bf41 Compare March 25, 2025 11:18
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch from d6174bc to 09886b9 Compare March 25, 2025 11:18
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 4 files reviewed, 1 unresolved discussion (waiting on @nimrod-starkware)


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

        if returned_version != original_version {
            return self.allocate_execution_info_segment(vm, returned_version, exclude_l1_data_gas);
        }

You have to do something like this. The ptr in this syscall is cached, and you must override it if the syscall us called from one of the whitelisted contracts

Code quote:

        if returned_version != original_version {
            return self.allocate_execution_info_segment(vm, returned_version, exclude_l1_data_gas);
        }

@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/add_to_vc branch from 565bf41 to b9e6c91 Compare March 25, 2025 11:22
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch from 09886b9 to ecd0878 Compare March 25, 2025 11:22
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 4 files reviewed, 3 unresolved discussions (waiting on @nimrod-starkware)


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

    }

    /// Return wether the class is in the data gas accounts set.

Suggestion:

/// Return whether the L1 data gas should be excluded for the `get_execution_info` syscall.

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

    /// Return wether the class is in the data gas accounts set.
    pub fn exclude_l1_data_gas(&self) -> bool {

Suggestion:

pub fn should_exclude_l1_data_gas(&self) -> bool 

Copy link
Contributor Author

@nimrod-starkware nimrod-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 4 files reviewed, 3 unresolved discussions (waiting on @nimrod-starkware and @Yoni-Starkware)


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

Previously, Yoni-Starkware (Yoni) wrote…

You have to do something like this. The ptr in this syscall is cached, and you must override it if the syscall us called from one of the whitelisted contracts

What do you think of something like this pseudo-code

If class hash in data gas accounts or in v1 bounds accounts:
    recalculate the execution info ptr
else:
    use the cached one if exists (otherwise calculate and cache)

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

    }

    /// Return wether the class is in the data gas accounts set.

Done.


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

    /// Return wether the class is in the data gas accounts set.
    pub fn exclude_l1_data_gas(&self) -> bool {

Done.

@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch 2 times, most recently from 78366fc to 62506ee Compare March 25, 2025 11:31
Copy link
Contributor Author

@nimrod-starkware nimrod-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 4 files reviewed, 3 unresolved discussions (waiting on @nimrod-starkware and @Yoni-Starkware)


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

Previously, nimrod-starkware wrote…

What do you think of something like this pseudo-code

If class hash in data gas accounts or in v1 bounds accounts:
    recalculate the execution info ptr
else:
    use the cached one if exists (otherwise calculate and cache)

Done, i think

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.

What about Native? different PR?

Reviewed 1 of 3 files at r1, 1 of 2 files at r3.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @nimrod-starkware)


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

        // If the transaction version was overridden, `self.execution_info_ptr` cannot be used.
        if returned_version != original_version {

Hmmm, this code is not necessary. I'll clean it in a different PR.

Copy link
Contributor Author

@nimrod-starkware nimrod-starkware left a comment

Choose a reason for hiding this comment

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

I'll do native in a future PR (on top of this)

Reviewable status: 2 of 4 files reviewed, all discussions resolved (waiting on @nimrod-starkware)

Copy link
Contributor Author

@nimrod-starkware nimrod-starkware left a comment

Choose a reason for hiding this comment

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

Done:
https://reviewable.io/reviews/starkware-libs/sequencer/5273

Reviewable status: 2 of 4 files reviewed, all discussions resolved (waiting on @nimrod-starkware)

@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/add_to_vc branch from b9e6c91 to 6396d4c Compare March 25, 2025 15:31
@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch from 62506ee to 1067145 Compare March 25, 2025 15:31
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.

Reviewed 1 of 2 files at r4.
Reviewable status: 2 of 4 files reviewed, 2 unresolved discussions (waiting on @nimrod-starkware)


crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs line 378 at r4 (raw file):

        ],
        (_, _) => {
            vec![felt!(if exclude_l1_data_gas { 2_u8 } else { 3 })] // Length of resource bounds array.

Be consistent

Code quote:

2_u8 } else { 3

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

                        vm,
                        context,
                        self.base.should_exclude_l1_data_gas(),

Extract into a var and add a comment above: See the comment about the returned version.

Code quote:

self.base.should_exclude_l1_data_gas(),

Copy link
Contributor Author

@nimrod-starkware nimrod-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: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @nimrod-starkware and @Yoni-Starkware)


crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs line 378 at r4 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Be consistent

Done.

@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch from 1067145 to 6a5227d Compare March 26, 2025 07:26
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.

:lgtm:

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @nimrod-starkware)

@nimrod-starkware nimrod-starkware force-pushed the nimrod/data_gas_accounts/exclude_from_tx_info branch from 6a5227d to 0a32d4e Compare March 26, 2025 08:06
@nimrod-starkware nimrod-starkware changed the base branch from nimrod/data_gas_accounts/add_to_vc to main March 26, 2025 08:06
@nimrod-starkware nimrod-starkware added this pull request to the merge queue Mar 26, 2025
Merged via the queue into main with commit 6f96849 Mar 26, 2025
22 of 34 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 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