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: create struct for gateway compiler #383

Merged

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Jul 7, 2024

This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Jul 7, 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 Jul 7, 2024

Codecov Report

Attention: Patch coverage is 80.76923% with 10 lines in your changes missing coverage. Please review.

Project coverage is 83.33%. Comparing base (528d350) to head (542d4c3).

Files Patch % Lines
crates/gateway/src/compilation.rs 81.81% 5 Missing and 3 partials ⚠️
crates/gateway/src/config.rs 80.00% 1 Missing ⚠️
crates/gateway/src/gateway.rs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #383      +/-   ##
==========================================
+ Coverage   83.28%   83.33%   +0.04%     
==========================================
  Files          37       37              
  Lines        1723     1734      +11     
  Branches     1723     1734      +11     
==========================================
+ Hits         1435     1445      +10     
- Misses        211      212       +1     
  Partials       77       77              

☔ 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 July 7, 2024 12:15
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/gateway_compilar_struct branch from 3b74aa0 to 9622e9a Compare July 7, 2024 12:40
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 9 of 9 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ArniStarkware, @dafnamatsry, and @Yael-Starkware)


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

    pub stateless_tx_validator_config: StatelessTransactionValidatorConfig,
    pub stateful_tx_validator_config: StatefulTransactionValidatorConfig,
    pub gateway_compiler_config: GatewayCompilerConfig,

Consider renaming to just compiler_config

Code quote:

gateway_

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

    let optional_class_info = match &tx {
        RPCTransaction::Declare(declare_tx) => {
            let gateway_compiler = GatewayCompiler { config: Default::default() };

GatewayCompiler::default()

Code quote:

GatewayCompiler { config: Default::default() };

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

    let optional_class_info = match &external_tx {
        RPCTransaction::Declare(declare_tx) => Some(
            GatewayCompiler { config: Default::default() }

GatewayCompiler::default()

Code quote:

GatewayCompiler { config: Default::default() }

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

            GatewayCompiler { config: Default::default() }
                .compile_contract_class(declare_tx)
                .unwrap(),

Shouldn't this return a result instead of unwrapping?
If not, I would still use expect instead of unwrap

Code quote:

.unwrap(),

@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/gateway_compilar_struct branch from 9622e9a to 0f5d3d2 Compare July 8, 2024 10:27
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 9 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry, @Yael-Starkware, and @yair-starkware)


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

Previously, yair-starkware (Yair) wrote…

Consider renaming to just compiler_config

I like the name you suggested.
Done.


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

Previously, yair-starkware (Yair) wrote…

GatewayCompiler::default()

It is odd. I see this struct as corresponding to StatelessTransactionValidator/ StatefulTransactionValidator.

These structs do not implement Default.
Very soon, this config is going to be non-empty. For actual cases - it is going to be loaded from the node-config. For tests it should be manually set.


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

Previously, yair-starkware (Yair) wrote…

GatewayCompiler::default()

As discussed in the previous point.


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

Previously, yair-starkware (Yair) wrote…

Shouldn't this return a result instead of unwrapping?
If not, I would still use expect instead of unwrap

This is a test util, so there is no need to be type-safe here.

Indeed, we might want to be more careful and rename this function accordingly.

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 4 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry and @Yael-Starkware)

@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/gateway_compilar_struct branch 4 times, most recently from 152b7ca to fdf9ddd Compare July 10, 2024 10:00
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: 1 of 9 files reviewed, all discussions resolved (waiting on @dafnamatsry, @Yael-Starkware, and @yair-starkware)


crates/gateway/src/compilation.rs line 25 at r4 (raw file):

    #[allow(dead_code)]
    pub config: GatewayCompilerConfig,
}

Maybe we want to give this file a better name?
Maybe we want to rename the struct?

Code quote:

pub struct GatewayCompiler {
    #[allow(dead_code)]
    pub config: GatewayCompilerConfig,
}

Copy link
Collaborator

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


crates/gateway/src/compilation.rs line 95 at r4 (raw file):

// or unsupported so that the compiler would alert us on new builtins.
fn supported_builtins() -> &'static Vec<String> {
    static SUPPORTED_BUILTINS: OnceLock<Vec<String>> = OnceLock::new();

Wasn't it defined with lazy static? Why did it changed?


crates/gateway/src/compilation_config.rs line 1 at r4 (raw file):

use std::collections::BTreeMap;

The rest of the config structs are in the config.rs right?
Lets be consistent.


crates/gateway/src/compilation_test.rs line 24 at r4 (raw file):

    let declare_tx = RPCDeclareTransaction::V3(tx);

    let result = GatewayCompiler { config: Default::default() }.compile_contract_class(&declare_tx);

Can you define it with a fixture?

Code quote:

GatewayCompiler { config: Default::default() }

@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/gateway_compilar_struct branch from fdf9ddd to 4cbcaea Compare July 10, 2024 12: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: 4 of 9 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry, @Yael-Starkware, and @yair-starkware)


crates/gateway/src/compilation.rs line 95 at r4 (raw file):

Previously, dafnamatsry wrote…

Wasn't it defined with lazy static? Why did it changed?

It was changed Per Gilad's request.
See PR: #353.
Lazy static is deprecated.


crates/gateway/src/compilation_test.rs line 24 at r4 (raw file):

Previously, dafnamatsry wrote…

Can you define it with a fixture?

Done.


crates/gateway/src/compilation_config.rs line 1 at r4 (raw file):

Previously, dafnamatsry wrote…

The rest of the config structs are in the config.rs right?
Lets be consistent.

removed.

@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/gateway_compilar_struct branch 2 times, most recently from acc2304 to bfbbcc2 Compare July 11, 2024 07:45
Copy link
Collaborator

@dafnamatsry dafnamatsry 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 5 of 5 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware and @yair-starkware)


crates/gateway/src/compilation.rs line 95 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

It was changed Per Gilad's request.
See PR: #353.
Lazy static is deprecated.

Thanks!

@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/gateway_compilar_struct branch 2 times, most recently from f454e22 to 48314a4 Compare July 11, 2024 11:13
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/gateway_compilar_struct branch from 48314a4 to 542d4c3 Compare July 14, 2024 07:59
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.

Reviewed 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware and @yair-starkware)

Copy link
Contributor Author

ArniStarkware commented Jul 14, 2024

Merge activity

@ArniStarkware ArniStarkware merged commit ffb8b05 into main Jul 14, 2024
8 checks passed
@ArniStarkware ArniStarkware deleted the arni/declare/compilation/gateway_compilar_struct branch August 21, 2024 07:17
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