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

chore(blockifier): share the utility felt_to_u128 to starknet api #2093

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

ArniStarkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Nov 17, 2024

Copy link

Artifacts upload triggered. View details here

@ArniStarkware ArniStarkware marked this pull request as ready for review November 17, 2024 08:05
Copy link
Contributor Author

@ArniStarkware ArniStarkware 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 6 files reviewed, all discussions resolved (waiting on @barak-b-starkware, @dorimedini-starkware, and @noaov1)


crates/starknet_api/src/core_test.rs line 131 at r1 (raw file):

        format!("{error}"),
        "Out of range Felt 340282366920938463463374607431768211456 is too big to convert to \
         'u128'."

Note the format changed slightly.

Code quote:

        "Out of range Felt 340282366920938463463374607431768211456 is too big to convert to \
         'u128'."

Copy link

codecov bot commented Nov 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.29%. Comparing base (e3165c4) to head (bdc6877).
Report is 915 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2093       +/-   ##
===========================================
+ Coverage   40.10%   77.29%   +37.18%     
===========================================
  Files          26      378      +352     
  Lines        1895    40029    +38134     
  Branches     1895    40029    +38134     
===========================================
+ Hits          760    30939    +30179     
- Misses       1100     6800     +5700     
- Partials       35     2290     +2255     

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

Copy link
Collaborator

@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.

Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware, @barak-b-starkware, and @noaov1)


crates/blockifier/src/abi/sierra_types.rs line 46 at r1 (raw file):

pub fn felt_to_u128(felt: &Felt) -> Result<u128, SierraTypeError> {
    felt.to_u128().ok_or_else(|| SierraTypeError::ValueTooLargeForType { val: *felt, ty: "u128" })
}

isn't it an issue that the returned error type has changed now in the blockifier crate?

Code quote:

pub fn felt_to_u128(felt: &Felt) -> Result<u128, SierraTypeError> {
    felt.to_u128().ok_or_else(|| SierraTypeError::ValueTooLargeForType { val: *felt, ty: "u128" })
}

@ArniStarkware ArniStarkware changed the base branch from arni/chore/next_storage_key/move_to_snapi to graphite-base/2093 November 17, 2024 08:28
@ArniStarkware ArniStarkware force-pushed the arni/chore/felt_to_u128/move_to_snapi branch from 8c66340 to a2b4052 Compare November 17, 2024 08:28
@ArniStarkware ArniStarkware changed the base branch from graphite-base/2093 to main November 17, 2024 08:29
@ArniStarkware ArniStarkware force-pushed the arni/chore/felt_to_u128/move_to_snapi branch from a2b4052 to d8c3ddf Compare November 17, 2024 08: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

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Collaborator

@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.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware, @barak-b-starkware, and @noaov1)

@ArniStarkware ArniStarkware force-pushed the arni/chore/felt_to_u128/move_to_snapi branch from d8c3ddf to 5185f70 Compare November 17, 2024 08:47
@ArniStarkware ArniStarkware changed the base branch from main to arni/blockifier/abi/private_felt_to_u128 November 17, 2024 08:47
Copy link

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@ArniStarkware ArniStarkware 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: 5 of 7 files reviewed, 1 unresolved discussion (waiting on @barak-b-starkware, @dorimedini-starkware, and @noaov1)


crates/blockifier/src/abi/sierra_types.rs line 46 at r1 (raw file):

Previously, dorimedini-starkware wrote…

isn't it an issue that the returned error type has changed now in the blockifier crate?

This function is only used in the context of this file.
The error is propagated to the OS, so I am not sure.

In any case - I created another PR under this on: #2095. It tries to be in the path of least resistance, yet it solves some issues I have with other projects I am working on.


crates/blockifier/src/abi/sierra_types.rs line 68 at r1 (raw file):

        Ok(Self { val: felt_to_u128(&felt)? })
    }
}

These are the two places where felt_to_u128 is used (in a non-test setting).

Code quote:

impl SierraType for SierraU128 {
    fn from_memory(vm: &VirtualMachine, ptr: &mut Relocatable) -> SierraTypeResult<Self> {
        let felt = vm.get_integer(*ptr)?;
        *ptr = (*ptr + 1)?;
        Ok(Self { val: felt_to_u128(&felt)? })
    }

    fn from_storage(
        state: &dyn StateReader,
        contract_address: &ContractAddress,
        key: &StorageKey,
    ) -> SierraTypeResult<Self> {
        let felt = state.get_storage_at(*contract_address, *key)?;
        Ok(Self { val: felt_to_u128(&felt)? })
    }
}

Copy link
Collaborator

@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.

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @barak-b-starkware and @noaov1)


crates/blockifier/src/abi/sierra_types.rs line 68 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

These are the two places where felt_to_u128 is used (in a non-test setting).

who uses SierraU128...?

@ArniStarkware ArniStarkware force-pushed the arni/blockifier/abi/private_felt_to_u128 branch from 0708895 to f6891af Compare November 17, 2024 09:21
@ArniStarkware ArniStarkware force-pushed the arni/chore/felt_to_u128/move_to_snapi branch from 5185f70 to 240f686 Compare November 17, 2024 09:21
Copy link

Artifacts upload triggered. View details here

Copy link
Contributor Author

@ArniStarkware ArniStarkware 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 @barak-b-starkware and @noaov1)


crates/blockifier/src/abi/sierra_types.rs line 68 at r1 (raw file):

Previously, dorimedini-starkware wrote…

who uses SierraU128...?

Only in this file, only for SierraU256. In turn, SeirraU256 is only used in secp.rs

@ArniStarkware ArniStarkware changed the base branch from arni/blockifier/abi/private_felt_to_u128 to graphite-base/2093 November 17, 2024 09:47
@ArniStarkware ArniStarkware force-pushed the arni/chore/felt_to_u128/move_to_snapi branch from 240f686 to 11a7925 Compare November 17, 2024 09:47
@ArniStarkware ArniStarkware changed the base branch from graphite-base/2093 to main November 17, 2024 09:48
@ArniStarkware ArniStarkware force-pushed the arni/chore/felt_to_u128/move_to_snapi branch from 11a7925 to f28da74 Compare November 17, 2024 09:48
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [34.339 ms 34.365 ms 34.397 ms]
change: [-3.9078% -2.4421% -1.1572%] (p = 0.00 < 0.05)
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
5 (5.00%) high severe

Copy link
Collaborator

@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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @barak-b-starkware and @noaov1)

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

Artifacts upload triggered. View details here

Copy link

Artifacts upload triggered. View details here

@ArniStarkware ArniStarkware force-pushed the arni/chore/felt_to_u128/move_to_snapi branch from f28da74 to bdc6877 Compare November 17, 2024 10:24
Copy link

Artifacts upload triggered. View details here

@ArniStarkware ArniStarkware merged commit 28a0f67 into main Dec 18, 2024
21 checks passed
@ArniStarkware ArniStarkware deleted the arni/chore/felt_to_u128/move_to_snapi branch December 18, 2024 15:17
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2024
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