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): add syscall counting for native syscall handler #1555

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

rodrigo-pino
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

Artifacts upload triggered. View details here

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.51%. Comparing base (e3165c4) to head (3d4ab3d).
Report is 274 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1555       +/-   ##
===========================================
+ Coverage   40.10%   68.51%   +28.41%     
===========================================
  Files          26      102       +76     
  Lines        1895    13687    +11792     
  Branches     1895    13687    +11792     
===========================================
+ Hits          760     9378     +8618     
- Misses       1100     3908     +2808     
- Partials       35      401      +366     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Artifacts upload triggered. View details here

@rodrigo-pino rodrigo-pino added the native integration Related with the integration of Cairo Native into the Blockifier label Oct 25, 2024
@rodrigo-pino rodrigo-pino force-pushed the rdr/update-testing-suite branch 4 times, most recently from 6815d18 to a3166cf Compare October 29, 2024 11:06
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor

@meship-starkware meship-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 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @noaov1 and @rodrigo-pino)


crates/blockifier/src/execution/native/entry_point_execution.rs line 79 at r1 (raw file):

            gas_consumed,
        },
        resources: syscall_handler.resources.clone(),

Why are we no longer using default resources?

Code quote:

resources: syscall_handler.resources.clone(),

crates/blockifier/src/execution/native/syscall_handler.rs line 68 at r1 (raw file):

        let syscall_count = self.syscall_counter.entry(*selector).or_default();
        *syscall_count += n
    }

Why are we increasing by n and not by 1? Are there cases where we want to increase it with a different number?

Code quote:

    fn increment_syscall_count_by(&mut self, selector: &SyscallSelector, n: usize) {
        let syscall_count = self.syscall_counter.entry(*selector).or_default();
        *syscall_count += n
    }

Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor

@meship-starkware meship-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 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @noaov1 and @rodrigo-pino)

Copy link

Artifacts upload triggered. View details here

Copy link

github-actions bot commented Nov 6, 2024

Artifacts upload triggered. View details here

Copy link
Contributor

@meship-starkware meship-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, all commit messages.
Reviewable status: 2 of 3 files reviewed, 4 unresolved discussions (waiting on @noaov1 and @rodrigo-pino)

@rodrigo-pino rodrigo-pino force-pushed the rdr/update-testing-suite branch 2 times, most recently from ce5b163 to 48fdf7a Compare November 7, 2024 15:30
Copy link

github-actions bot commented Nov 7, 2024

Artifacts upload triggered. View details here

Copy link

github-actions bot commented Nov 9, 2024

Artifacts upload triggered. View details here

Copy link
Contributor

@meship-starkware meship-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: all files reviewed, 4 unresolved discussions (waiting on @rodrigo-pino)

@rodrigo-pino rodrigo-pino changed the base branch from rdr/update-testing-suite to main November 10, 2024 09:29
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@rodrigo-pino rodrigo-pino 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: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/execution/native/entry_point_execution.rs line 79 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

When running cairo native, the only resource that matters is the gas counter. Please revert.

Done, i've change it default to ChargedResources


crates/blockifier/src/execution/native/entry_point_execution.rs line 65 at r3 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

WDYM?

No longer relevant


crates/blockifier/src/execution/native/entry_point_execution.rs line 74 at r3 (raw file):

Previously, noaov1 (Noa Oved) wrote…

WDYM?

I think doesn't show up in the code anymore


crates/blockifier/src/execution/native/syscall_handler.rs line 68 at r1 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Currently, we need n that is potentially greater for one in the keccak syscall.

Yes, that's it. Didn't want to add an increment_syscall_count_by_one, but if you prefer it that way we can add a specialized function


crates/blockifier/src/execution/native/syscall_handler.rs line 110 at r3 (raw file):

Previously, noaov1 (Noa Oved) wrote…

With this change the method can no linger be called substract_syscall_gas_cost. Consider renaming it or, alternatively, removing this functionality.

Done, tell me what you think!


a.xadfas line at r3 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

What is this file? Can you remove it?

Oooooops! Removed!

Copy link
Collaborator

@noaov1 noaov1 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 1 of 2 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @meship-starkware and @rodrigo-pino)


crates/blockifier/src/execution/native/syscall_handler.rs line 100 at r5 (raw file):

    /// handling all gas-related logics and additional metadata such as `SyscallCounter`). The
    /// difference for native execution is that we need to explicitly call this method at the
    /// beginning of each syscall.

Suggestion:

    /// Handles all gas-related logics and additional metadata such as `SyscallCounter`. In native,
    /// we need to explicitly call this method at the
    /// beginning of each syscall.

crates/blockifier/src/execution/native/entry_point_execution.rs line 73 at r5 (raw file):

            gas_consumed,
        },
        charged_resources: ChargedResources::default(),

We charge according to the gas consumed in the native run

Suggestion:

charged_resources: ChargedResources {
            vm_resources: ExecutionResources::default(),
            gas_for_fee: GasAmount(gas_consumed),
        },
,

Copy link
Contributor

@meship-starkware meship-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: all files reviewed, 2 unresolved discussions (waiting on @rodrigo-pino)


crates/blockifier/src/execution/native/syscall_handler.rs line 68 at r1 (raw file):

Previously, rodrigo-pino (Rodrigo) wrote…

Yes, that's it. Didn't want to add an increment_syscall_count_by_one, but if you prefer it that way we can add a specialized function

No, that's ok. I think it is better this way.

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@rodrigo-pino rodrigo-pino 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: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @noaov1)


crates/blockifier/src/execution/native/entry_point_execution.rs line 73 at r5 (raw file):

Previously, noaov1 (Noa Oved) wrote…

We charge according to the gas consumed in the native run

Done


crates/blockifier/src/execution/native/syscall_handler.rs line 100 at r5 (raw file):

    /// handling all gas-related logics and additional metadata such as `SyscallCounter`). The
    /// difference for native execution is that we need to explicitly call this method at the
    /// beginning of each syscall.

Done Love the writing tips :)

Copy link
Contributor

@meship-starkware meship-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 2 of 2 files at r5.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @noaov1)

Copy link
Contributor

@meship-starkware meship-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 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1)

Copy link
Collaborator

@noaov1 noaov1 left a comment

Choose a reason for hiding this comment

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

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

@noaov1 noaov1 merged commit f82884d into main Nov 10, 2024
12 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
native integration Related with the integration of Cairo Native into the Blockifier
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants