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: use starknet_api builtin for name trait #319

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Jun 30, 2024

This change is Reviewable

The TODO is addressed here: starkware-libs/starknet-api#288

Copy link
Contributor Author

ArniStarkware commented Jun 30, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @ArniStarkware and the rest of your teammates on Graphite Graphite

@codecov-commenter
Copy link

codecov-commenter commented Jun 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.58%. Comparing base (26060ef) to head (dba37cb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #319      +/-   ##
==========================================
+ Coverage   82.38%   82.58%   +0.20%     
==========================================
  Files          33       33              
  Lines        1612     1631      +19     
  Branches     1612     1631      +19     
==========================================
+ Hits         1328     1347      +19     
  Misses        219      219              
  Partials       65       65              

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

@ArniStarkware ArniStarkware marked this pull request as ready for review June 30, 2024 08:55
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/builtins branch from e6bdf01 to e82f53b Compare June 30, 2024 09:14
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from 31a8d34 to d572302 Compare June 30, 2024 09:14
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/builtins branch from e82f53b to f67b511 Compare June 30, 2024 09:26
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from d572302 to fd9e01e Compare June 30, 2024 09:26
Copy link
Contributor

@yair-starkware yair-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 @ArniStarkware and @Yael-Starkware)


crates/gateway/src/gateway.rs line 187 at r1 (raw file):

// TODO(Arni): Add to a config.
fn get_supported_builtins() -> Vec<String> {

Please use https://docs.rs/once_cell/latest/once_cell/sync/struct.Lazy.html


crates/gateway/src/gateway.rs line 187 at r1 (raw file):

// TODO(Arni): Add to a config.
fn get_supported_builtins() -> Vec<String> {

Consider adding is_supported method to Builtin together with using https://docs.rs/strum/latest/strum/derive.EnumIter.html

This way whenever a new builtin is created it won't be forgotten in this function

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/builtins branch from f67b511 to c2d41e8 Compare July 1, 2024 08:31
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from fd9e01e to d4dbe20 Compare July 1, 2024 08:31
Copy link
Contributor

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


crates/gateway/src/utils.rs line 164 at r1 (raw file):

    true
}

I think this whole code should move the starknet-api , it is relevant for all repos (mempool and blockifier for sure).

@ArniStarkware
Copy link
Contributor Author

crates/gateway/src/utils.rs line 164 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

I think this whole code should move the starknet-api , it is relevant for all repos (mempool and blockifier for sure).

I agree :)
Here it is in Starknet API: https://reviewable.io/reviews/starkware-libs/starknet-api/288#- (in main-mempool branch).

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/builtins branch from c2d41e8 to d0d4053 Compare July 1, 2024 11:34
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch 2 times, most recently from 25fa666 to e060f39 Compare July 1, 2024 13:17
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/builtins branch from d0d4053 to ab76a25 Compare July 1, 2024 14:15
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from e060f39 to a3ddc46 Compare July 1, 2024 14:16
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 4 files reviewed, 2 unresolved discussions (waiting on @Yael-Starkware and @yair-starkware)


crates/gateway/src/gateway.rs line 187 at r1 (raw file):

Previously, yair-starkware (Yair) wrote…

Please use https://docs.rs/once_cell/latest/once_cell/sync/struct.Lazy.html

Done.


crates/gateway/src/gateway.rs line 187 at r1 (raw file):

Previously, yair-starkware (Yair) wrote…

Consider adding is_supported method to Builtin together with using https://docs.rs/strum/latest/strum/derive.EnumIter.html

This way whenever a new builtin is created it won't be forgotten in this function

Done. See related Starknet API PR: https://reviewable.io/reviews/starkware-libs/starknet-api/290#-

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/builtins branch from ab76a25 to 0c30c7a Compare July 2, 2024 08:36
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from a3ddc46 to 6275ce0 Compare July 2, 2024 08:37
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 4 files reviewed, 2 unresolved discussions (waiting on @Yael-Starkware and @yair-starkware)


crates/gateway/src/utils.rs line 164 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

I agree :)
Here it is in Starknet API: https://reviewable.io/reviews/starkware-libs/starknet-api/288#- (in main-mempool branch).

Done*.


crates/gateway/src/utils.rs line 195 at r3 (raw file):

        }
    }
}

The name method is taken from starknet-api (The code supporting it is already merged).

Code quote:

impl NameExt for Builtin {
    fn name(&self) -> &'static str {
        match self {
            Builtin::RangeCheck => RANGE_CHACK_BUILTIN_NAME,
            Builtin::Pedersen => PEDERSEN_BUILTIN_NAME,
            Builtin::Poseidon => POSEIDON_BUILTIN_NAME,
            Builtin::EcOp => EC_OP_BUILTIN_NAME,
            Builtin::Ecdsa => ECDSA_BUILTIN_NAME,
            Builtin::Bitwise => BITWISE_BUILTIN_NAME,
            Builtin::Keccak => KECCAK_BUILTIN_NAME,
            Builtin::SegmentArena => SEGMENT_ARENA_BUILTIN_NAME,
        }
    }
}

@ArniStarkware
Copy link
Contributor Author

crates/gateway/src/utils.rs line 164 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Done*.

See another related PR in SN-API: starkware-libs/starknet-api#290

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from 6275ce0 to 307d91a Compare July 2, 2024 09:14
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch 3 times, most recently from 361094e to 255fbad Compare July 2, 2024 14:59
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from 255fbad to ac80823 Compare July 2, 2024 15:42
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from ac80823 to afdd207 Compare July 3, 2024 07:15
Copy link
Contributor

@Yael-Starkware Yael-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 5 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @yair-starkware)


crates/gateway/src/utils.rs line 164 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

No - They are a property of the gateway.

is_supported_builtin - is a property of the gateway, which is going to be used to create the replacement of the static variable - a config variable.

lets add a todo to consider moving it to starknet-api.
I think it is a property of the whole system and should be in a central place

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from afdd207 to e87b419 Compare July 3, 2024 09:11
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 5 files reviewed, 2 unresolved discussions (waiting on @Yael-Starkware and @yair-starkware)


crates/gateway/src/utils.rs line 164 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

lets add a todo to consider moving it to starknet-api.
I think it is a property of the whole system and should be in a central place

Done.

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from e87b419 to c553217 Compare July 3, 2024 10:03
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 5 files reviewed, 2 unresolved discussions (waiting on @Yael-Starkware and @yair-starkware)


crates/gateway/src/utils.rs line 164 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Done.

See todo: TODO(Arni): Consider moving into Starknet-api.

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from c553217 to 69054eb Compare July 3, 2024 12:02
@ArniStarkware ArniStarkware changed the base branch from main to arni/declare/compilation/compilation_file July 3, 2024 12:02
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from 69054eb to 65d2d27 Compare July 3, 2024 12:34
@ArniStarkware ArniStarkware changed the base branch from arni/declare/compilation/compilation_file to main July 3, 2024 12:34
Copy link
Contributor

@Yael-Starkware Yael-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 3 files at r7, 1 of 2 files at r8, all commit messages.
Reviewable status: 3 of 6 files reviewed, 3 unresolved discussions (waiting on @ArniStarkware and @yair-starkware)


crates/gateway/src/compilation.rs line 66 at r8 (raw file):

// TODO(Arni): Consider moving into Starknet-api.
// List of supported builtins.
// This is an explicit function so that it is explicitly desiced which builtins are supported.

decides?

Code quote:

desiced

crates/gateway/src/compilation.rs line 68 at r8 (raw file):

// This is an explicit function so that it is explicitly desiced which builtins are supported.
// If new builtins are added, they should be added here.
fn is_supported_builtin(builtin: &Builtin) -> bool {

Suggestion:

is_os_supported_builtin

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from 65d2d27 to cb35c83 Compare July 4, 2024 06:24
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: 2 of 6 files reviewed, 1 unresolved discussion (waiting on @Yael-Starkware and @yair-starkware)


crates/gateway/src/compilation.rs line 66 at r8 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

decides?

Done


crates/gateway/src/compilation.rs line 68 at r8 (raw file):

// This is an explicit function so that it is explicitly desiced which builtins are supported.
// If new builtins are added, they should be added here.
fn is_supported_builtin(builtin: &Builtin) -> bool {

Done

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/validation/trait_for_builtin_name branch from cb35c83 to dba37cb Compare July 4, 2024 06:25
Copy link
Contributor

@Yael-Starkware Yael-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 6 files reviewed, 1 unresolved discussion (waiting on @yair-starkware)

Copy link
Contributor

@yair-starkware yair-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 4 files at r3, 1 of 2 files at r8, all commit messages.
Reviewable status: 3 of 6 files reviewed, all discussions resolved (waiting on @Yael-Starkware)

Copy link
Contributor

@yair-starkware yair-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 3 files at r7, 1 of 1 files at r9.
Reviewable status: 4 of 6 files reviewed, all discussions resolved (waiting on @Yael-Starkware)

@ArniStarkware ArniStarkware deleted the arni/declare/post_compilation/validation/trait_for_builtin_name branch August 11, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants