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 emit_event cairo native syscall #1550

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

PearsonWhite
Copy link
Contributor

Implements the emit_event syscall for native cairo syscall handler.

@PearsonWhite PearsonWhite added the native integration Related with the integration of Cairo Native into the Blockifier label Oct 24, 2024
@reviewable-StarkWare
Copy link

This change is Reviewable

@PearsonWhite PearsonWhite changed the title feature(blockifier): add emit_event cairo native syscall feat(blockifier): add emit_event cairo native syscall Oct 24, 2024
Copy link

Artifacts upload triggered. View details here

@PearsonWhite PearsonWhite changed the base branch from rdr/update-testing-suite to rdr/native-storage-read October 25, 2024 18:34
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@PearsonWhite PearsonWhite 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 2 files reviewed, 1 unresolved discussion

a discussion (no related file):
I'm looking for more clarification on the expected error return behavior. For errors that are not of the type SyscallExecutionError::SyscallError, I'm currently using .expect(...), which causes tests to fail in some syscall PRs. This can be handled in several ways. There is currently a discussion on this topic here: https://reviewable.io/reviews/starkware-libs/sequencer/1305#-O96F70GASwm5B06IRKL


@PearsonWhite PearsonWhite marked this pull request as ready for review October 25, 2024 20:19
Copy link
Contributor

@varex83 varex83 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 2 files reviewed, 2 unresolved discussions (waiting on @PearsonWhite)


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

            &event,
        )
        .expect("Number of events exceeded the size limit.");

This should be returned as a runtime error, not expect

Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.12%. Comparing base (e3165c4) to head (3659533).
Report is 407 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1550       +/-   ##
===========================================
+ Coverage   40.10%   69.12%   +29.02%     
===========================================
  Files          26      105       +79     
  Lines        1895    13701    +11806     
  Branches     1895    13701    +11806     
===========================================
+ Hits          760     9471     +8711     
- Misses       1100     3827     +2727     
- Partials       35      403      +368     

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

Copy link
Contributor Author

@PearsonWhite PearsonWhite 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 3 files reviewed, 2 unresolved discussions (waiting on @varex83)

a discussion (no related file):

Previously, PearsonWhite wrote…

I'm looking for more clarification on the expected error return behavior. For errors that are not of the type SyscallExecutionError::SyscallError, I'm currently using .expect(...), which causes tests to fail in some syscall PRs. This can be handled in several ways. There is currently a discussion on this topic here: https://reviewable.io/reviews/starkware-libs/sequencer/1305#-O96F70GASwm5B06IRKL

Changed this. Currently returning errors as encoded Felts in the retdata.



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

Previously, varex83 (Bohdan Ohorodnii) wrote…

This should be returned as a runtime error, not expect

Done.

@xrvdg
Copy link
Contributor

xrvdg commented Oct 29, 2024

crates/blockifier/src/execution/native/utils.rs line 25 at r2 (raw file):

}

pub fn decode_felts_as_str(encoding: &[Felt]) -> String {

There's a function called format_panic_data that has the exact same signature. Could that be used instead?

@rodrigo-pino rodrigo-pino force-pushed the rdr/native-storage-read branch 2 times, most recently from a00063b to 8ad184c Compare October 30, 2024 11:19
@PearsonWhite PearsonWhite force-pushed the rdr/native-storage-read branch from 8ad184c to 93ac2d0 Compare October 30, 2024 19:39
Copy link

Artifacts upload triggered. View details here

@rodrigo-pino rodrigo-pino force-pushed the rdr/native-storage-read branch 3 times, most recently from 9327187 to 56d98f9 Compare October 30, 2024 22:19
Copy link
Contributor Author

@PearsonWhite PearsonWhite 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 3 files reviewed, 4 unresolved discussions (waiting on @varex83 and @xrvdg)


crates/blockifier/src/execution/native/utils.rs line 25 at r2 (raw file):

Previously, xrvdg (Xander van der Goot) wrote…

There's a function called format_panic_data that has the exact same signature. Could that be used instead?

format_panic_data is meant for a Vec of Felts that are short strings, and thus are limited to 31 characters. Longer explanation below:

I think format_panic_data is used for an array of Felts where each Felt is an error in the format:
(<felt_as_str_as_felt> ('<str_as_felt>'), where the Felt represents a short string. For example, it would take the felt array slice: [0x7820213d2079] and return the String (0x7820213d2079 ('x != y')

But the Vec<Felt> from call_info.execution.retdata.0 in this case was created with encode_str_as_felts (String->Vec). Each Felt is not meant to independent; it's just part of the string. format_panic_data would interpret each Felt as an error, see that it can be interpreted as a string, output the format above, and join it with the other results. You would get the following:

"(0x457863656564656420746865206d6178696d756d206b657973206c656e6774 ('Exceeded the maximum keys lengt'), 0x682c206b657973206c656e6774683a2035312c206d6178206b657973206c65 ('h, keys length: 51, max keys le'), 0x6e6774683a2035302e00000000000000000000000000000000000000000000 ('ngth: 50.'))"

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 3 files at r4, 4 of 4 files at r7, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @xrvdg)

@rodrigo-pino rodrigo-pino force-pushed the rdr/handle-syscall-error branch 2 times, most recently from 5a001b3 to d90688f Compare November 12, 2024 15:00
Copy link
Contributor

@xrvdg xrvdg left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r7, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @Yoni-Starkware)

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.

Dismissed @xrvdg from 2 discussions.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @Yoni-Starkware)

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 @avi-starkware and @Yoni-Starkware)

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 r8, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware)

Copy link
Contributor

@avi-starkware avi-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 r8, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware)

@rodrigo-pino rodrigo-pino force-pushed the rdr/handle-syscall-error branch 2 times, most recently from 816c81b to b0fa3a9 Compare November 14, 2024 12:36
@varex83 varex83 changed the base branch from rdr/handle-syscall-error to main November 14, 2024 15:51
@varex83 varex83 force-pushed the pwhite/emit_event branch 2 times, most recently from 5dd4c78 to fb263f5 Compare November 14, 2024 16:07
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
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 1 of 3 files at r4, 2 of 4 files at r7, 2 of 2 files at r9, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @meship-starkware, @noaov1, @varex83, and @xrvdg)

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: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @meship-starkware, @noaov1, @varex83, and @xrvdg)

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)

@Yoni-Starkware Yoni-Starkware merged commit a07960d into main Nov 14, 2024
12 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2024
@meship-starkware meship-starkware deleted the pwhite/emit_event branch November 19, 2024 08:48
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.

8 participants