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 call_contract cairo native syscall #1548

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

PearsonWhite
Copy link
Contributor

@PearsonWhite PearsonWhite commented Oct 23, 2024

Implements call_contract in NativeSyscallHandler.

@reviewable-StarkWare
Copy link

This change is Reviewable

@PearsonWhite PearsonWhite added the native integration Related with the integration of Cairo Native into the Blockifier label Oct 23, 2024
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

@rodrigo-pino rodrigo-pino force-pushed the rdr/native-storage-read branch 2 times, most recently from ceff54f to f9d4b21 Compare October 25, 2024 11:55
Copy link

Artifacts upload triggered. View details here

@PearsonWhite PearsonWhite marked this pull request as ready for review October 25, 2024 20:20
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):
In test_track_resources, the logic for what we expect has changed. Now, I'm not sure if the result is expected or not and I need clarification.

Previously, both the outer call and the inner call had to be (Cairo1 | Native) for the inner tracked_resource to be SierraGas.
Now, long as the inner is (Cairo1 | Native) I think SierraGas should be used.

Currently, one case fails: when outer is Cairo0 and inner is Cairo1, SierraGas is expected, but CairoSteps is used.
I've added a complete table of the results here in csv format:

Code snippet:

outer , inner , expected_outer , expected_inner , actual_outer , actual_expected , pass/fail
Cairo0 , Cairo0 , CairoSteps , CairoSteps , CairoSteps , CairoSteps , pass
Cairo0 , Cairo1 , CairoSteps , SierraGas , CairoSteps , CairoSteps , failed <--- Should this fail? Or is it expected?
Cairo1 , Cairo0 , SierraGas , CairoSteps , SierraGas , CairoSteps , pass
Cairo1 , Cairo1 , SierraGas , SierraGas , SierraGas , SierraGas , pass
Cairo0 , Native , CairoSteps , SierraGas , CairoSteps , SierraGas , pass
Native , Cairo1 , SierraGas , SierraGas , SierraGas , SierraGas , pass
Native , Cairo0 , SierraGas , CairoSteps , SierraGas , CairoSteps , pass
Cairo1 , Native , SierraGas , SierraGas , SierraGas , SierraGas , pass
Native , Native , SierraGas , SierraGas , SierraGas , SierraGas , pass

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 203 at r1 (raw file):

        let contract_address = ContractAddress::try_from(address)
            .expect("Failed to convert address argument to a ContractAddress");

Don't use expect, return runtime error instead

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


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

            caller_address: self.contract_address,
            call_type: CallType::Call,
            initial_gas: u64::try_from(*remaining_gas).unwrap(),

Use expect instead of unwrap 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, 3 unresolved discussions (waiting on @varex83)


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

Previously, varex83 (Bohdan Ohorodnii) wrote…

Don't use expect, return runtime error instead

Done.


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

Previously, varex83 (Bohdan Ohorodnii) wrote…

Use expect instead of unwrap here

Done.

Copy link

Artifacts upload triggered. View details here

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.28%. Comparing base (e3165c4) to head (86e7eec).
Report is 406 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1548       +/-   ##
===========================================
+ Coverage   40.10%   69.28%   +29.17%     
===========================================
  Files          26      105       +79     
  Lines        1895    13771    +11876     
  Branches     1895    13771    +11876     
===========================================
+ Hits          760     9541     +8781     
- 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

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

@rodrigo-pino rodrigo-pino force-pushed the rdr/native-storage-read branch 2 times, most recently from 20227be to 9327187 Compare October 30, 2024 21:33
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, 1 unresolved discussion (waiting on @meship-starkware, @noaov1, 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, 1 unresolved discussion (waiting on @noaov1 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1 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, 1 unresolved discussion (waiting on @noaov1, @PearsonWhite, and @Yoni-Starkware)


a discussion (no related file):
Please rebase to resolve conflicts.

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: 1 of 2 files reviewed, all discussions resolved (waiting on @meship-starkware, @noaov1, and @Yoni-Starkware)


a discussion (no related file):

Previously, meship-starkware (Meshi Peled) wrote…

Please rebase to resolve conflicts.

done

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 r9, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1 and @Yoni-Starkware)

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 1 files at r9, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1 and @PearsonWhite)


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 205 at r9 (raw file):

) {
    let cairo_steps_contract = cairo_steps_contract_version.get_test_contract();
    let sierra_gas_contract = FeatureContract::TestContract(CairoVersion::Cairo1);

Please fixturize this (add a case for native class)

Code quote:

sierra_gas_contract

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, 2 unresolved discussions (waiting on @noaov1 and @PearsonWhite)


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 32 at r9 (raw file):

#[test]
fn test_call_contract_that_panics() {

Please add a TODO to support this test once we support reverts

@rodrigo-pino rodrigo-pino force-pushed the pwhite/call_contract branch 2 times, most recently from 97abe4b to 90a251e Compare November 14, 2024 14:56
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 2 files at r11, 3 of 3 files at r12, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1 and @PearsonWhite)


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 202 at r12 (raw file):

#[cfg_attr(
  feature = "cairo_native",
  test_case(CompilerBasedVersion::OldCairo1, CompilerBasedVersion::CairoVersion(CairoVersion::Native); "Cairo1_and_Native")

Thanks! non-blocking

Suggestion:

"OldCairo1_and_Native

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


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 32 at r9 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Please add a TODO to support this test once we support reverts

Added TODO


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 205 at r9 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Please fixturize this (add a case for native class)

done

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: 3 of 4 files reviewed, all discussions resolved (waiting on @noaov1 and @Yoni-Starkware)


crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs line 202 at r12 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Thanks! non-blocking

done

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 1 files at r13, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noaov1)

Copy link

Artifacts upload triggered. View details here

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

7 participants