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: post compilation size limit validation #284

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Aug 1, 2024

This PR is imported into this repo. The original PR: starkware-libs/mempool#298.

Note the stack of PRs has a different order in this repo.


This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Aug 1, 2024

@ArniStarkware ArniStarkware marked this pull request as ready for review August 1, 2024 12:41
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/expose_compilation_args branch from 92f1dc5 to f44f1cf Compare August 4, 2024 10:13
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from 229f578 to b76640a Compare August 4, 2024 10:14
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/expose_compilation_args branch from f44f1cf to f54a4f5 Compare August 4, 2024 10:44
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from b76640a to fd09b45 Compare August 4, 2024 10:45
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/expose_compilation_args branch from f54a4f5 to b064637 Compare August 5, 2024 08:21
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from fd09b45 to 6840f82 Compare August 5, 2024 08:21
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/expose_compilation_args branch from b064637 to db6c928 Compare August 5, 2024 08:27
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from 6840f82 to 593e130 Compare August 5, 2024 08:27
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/expose_compilation_args branch from db6c928 to bd04a7e Compare August 5, 2024 14:11
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from 593e130 to 78f25db Compare August 5, 2024 14:12
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 all commit messages.
Reviewable status: 0 of 8 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware, @dafnamatsry, and @yair-starkware)


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

            sierra_to_casm_compiler: SierraToCasmCompiler {
                config: config.sierra_to_casm_compiler_config,
            },

why the duplication of sierra_to_casm_compiler_config?

Code quote:

            config,
            sierra_to_casm_compiler: SierraToCasmCompiler {
                config: config.sierra_to_casm_compiler_config,
            },

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


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

pub struct GatewayCompilerConfig {
    pub sierra_to_casm_compiler_config: SierraToCasmCompilationConfig,
    pub max_raw_casm_class_size: usize,

the word raw confuses me, I am think about eating steak.

Code quote:

raw

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


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

Previously, Yael-Starkware (YaelD) wrote…

the word raw confuses me, I am think about eating steak.

*thinking

@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/expose_compilation_args branch from bd04a7e to c55f0be Compare August 6, 2024 11:22
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from 78f25db to 035c12e Compare August 6, 2024 11:23
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/expose_compilation_args branch from c55f0be to 79ec169 Compare August 6, 2024 12:08
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from 035c12e to 34b50eb Compare August 6, 2024 12:08
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 8 files reviewed, 2 unresolved discussions (waiting on @dafnamatsry, @Yael-Starkware, and @yair-starkware)


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

Previously, Yael-Starkware (YaelD) wrote…

why the duplication of sierra_to_casm_compiler_config?

Done.
Now there is no duplication. - The price is the multiplicity of objects.

@ArniStarkware ArniStarkware changed the base branch from graphite-base/284 to main August 8, 2024 10:05
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 4 of 8 files at r1, 2 of 3 files at r4, 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @Yael-Starkware, and @yair-starkware)


crates/gateway/src/compilation.rs line 27 at r5 (raw file):

impl GatewayCompiler {
    pub fn new(config: GatewayCompilerConfig) -> Self {

In the following PR: https://reviewable.io/reviews/starkware-libs/sequencer/319#- you define different initialisation methods. Are you planning to delete this new later?

Code quote:

pub fn new(config: GatewayCompilerConfig)

crates/gateway/src/config.rs line 230 at r5 (raw file):

#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Validate, PartialEq)]
pub struct GatewayCompilerConfig {
    pub sierra_to_casm_compiler_config: SierraToCasmCompilationConfig,

Maybe better to put it outside of GatewayCompilerConfig?
The SierraToCasmCompilation is given to the GatewayCompiler with a dependency injection (https://reviewable.io/reviews/starkware-libs/sequencer/319#-), so I think it makes sense that it would be outside.

Code quote:

pub sierra_to_casm_compiler_config: SierraToCasmCompilationConfig,

crates/gateway/src/config.rs line 251 at r5 (raw file):

/// The configuration for the post compilation process in the gateway compiler.
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Validate, PartialEq)]
pub struct PostCompilationConfig {

Why do we need this extra level of config, and not just define max_raw_casm_class_size to the GatewayCompilerConfig?

Code quote:

PostCompilationConfig 

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch 2 times, most recently from feb96da to f7d4f8e Compare August 8, 2024 12:05
@ArniStarkware ArniStarkware mentioned this pull request Aug 8, 2024
@ArniStarkware
Copy link
Contributor Author

This PR will be restacked over #357.

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from f7d4f8e to 1354412 Compare August 11, 2024 08:07
@ArniStarkware ArniStarkware changed the base branch from main to arni/declare/compilation/config/move_to_node_config August 11, 2024 08:07
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [64.961 ms 65.046 ms 65.141 ms]
change: [-10.061% -6.9538% -4.2677%] (p = 0.00 < 0.05)
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
3 (3.00%) high mild
2 (2.00%) high severe

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


crates/gateway/src/compilation.rs line 27 at r5 (raw file):

Previously, dafnamatsry wrote…

In the following PR: https://reviewable.io/reviews/starkware-libs/sequencer/319#- you define different initialisation methods. Are you planning to delete this new later?

Deleted. Replaced with the existing new_cario_lang_compiler function.

Rebases made this comment had to follow.


crates/gateway/src/config.rs line 230 at r5 (raw file):

Previously, dafnamatsry wrote…

Maybe better to put it outside of GatewayCompilerConfig?
The SierraToCasmCompilation is given to the GatewayCompiler with a dependency injection (https://reviewable.io/reviews/starkware-libs/sequencer/319#-), so I think it makes sense that it would be outside.

Done. See previous PR in the stack. #374.

Now: GatewayCompilerConfig sits directly in the mempool node config.


crates/gateway/src/config.rs line 251 at r5 (raw file):

Previously, dafnamatsry wrote…

Why do we need this extra level of config, and not just define max_raw_casm_class_size to the GatewayCompilerConfig?

I think it's cleaner that there is a level with all sub-configs. But it is a taste thing.
I plan to also have other similar numbers in this PostCompilerConfig level - like the size of the casm-bytecode.

@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from 1354412 to eeb7ac1 Compare August 11, 2024 08:17
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [64.458 ms 64.513 ms 64.578 ms]
change: [-3.6139% -2.6079% -1.7130%] (p = 0.00 < 0.05)
Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe

Copy link

codecov bot commented Aug 11, 2024

Codecov Report

Attention: Patch coverage is 95.91837% with 2 lines in your changes missing coverage. Please review.

Project coverage is 76.13%. Comparing base (e6fcc96) to head (ff67b95).

Files Patch % Lines
crates/gateway/src/config.rs 92.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           graphite-base/284     #284   +/-   ##
==================================================
  Coverage              76.12%   76.13%           
==================================================
  Files                    329      329           
  Lines                  35241    35288   +47     
  Branches               35241    35288   +47     
==================================================
+ Hits                   26826    26865   +39     
- Misses                  6119     6128    +9     
+ Partials                2296     2295    -1     

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

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 5 of 10 files at r6, all commit messages.
Reviewable status: 6 of 11 files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @Yael-Starkware, and @yair-starkware)


crates/gateway/src/compilation.rs line 22 at r6 (raw file):

#[derive(Clone)]
pub struct GatewayCompiler {
    config: PostCompilationConfig,

Suggestion:

config: GatewayCompilerConfig,

crates/gateway/src/compilation.rs line 27 at r6 (raw file):

impl GatewayCompiler {
    pub fn new_cairo_lang_compiler(config: GatewayCompilerConfig) -> Self {

Once you remove the SierraToCasmCompilationConfig from the GatewayConfig you can pass it here as an argument.


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

Previously, ArniStarkware (Arnon Hod) wrote…

Addressed in #354 (And #355).

Not critical but: for the future, I prefer you address this kind of comments in the same PR.
This field was introduced in this PR, so merging it and immediately renaming it in a following PR feels like extra work that could have been avoided.


crates/gateway/src/config.rs line 230 at r5 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Done. See previous PR in the stack. #374.

Now: GatewayCompilerConfig sits directly in the mempool node config.

With the previous PR the SierraToCasmCompilationConfig sits directly in the mempool node config. So you can remove it from here no?


crates/gateway/src/config.rs line 251 at r5 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

I think it's cleaner that there is a level with all sub-configs. But it is a taste thing.
I plan to also have other similar numbers in this PostCompilerConfig level - like the size of the casm-bytecode.

Ok.

@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/config/move_to_node_config branch from a071e2e to 12c79b6 Compare August 12, 2024 07:19
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from eeb7ac1 to 976f8fb Compare August 12, 2024 07:20
@ArniStarkware ArniStarkware force-pushed the arni/declare/compilation/config/move_to_node_config branch from 12c79b6 to e6fcc96 Compare August 12, 2024 07:43
@ArniStarkware ArniStarkware force-pushed the arni/declare/post_compilation/size_validation branch from 976f8fb to ff67b95 Compare August 12, 2024 07:43
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [64.602 ms 64.689 ms 64.785 ms]
change: [-5.2926% -4.0285% -2.8571%] (p = 0.00 < 0.05)
Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
7 (7.00%) high mild
5 (5.00%) high severe

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


crates/gateway/src/compilation.rs line 22 at r6 (raw file):

#[derive(Clone)]
pub struct GatewayCompiler {
    config: PostCompilationConfig,

The struct called GatewayCompilerConfig also holds the config of the SierraToCasmCompiler. There will be duplication - The GatewayCompiler will have access to unused info - which is used by the SierraToCasmCompiler.

Are you sure?


crates/gateway/src/config.rs line 230 at r5 (raw file):

Previously, dafnamatsry wrote…

With the previous PR the SierraToCasmCompilationConfig sits directly in the mempool node config. So you can remove it from here no?

Got it.
Do we want to do something similar with the RpcStateReaderConfig.

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


crates/gateway/src/compilation.rs line 22 at r6 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

The struct called GatewayCompilerConfig also holds the config of the SierraToCasmCompiler. There will be duplication - The GatewayCompiler will have access to unused info - which is used by the SierraToCasmCompiler.

Are you sure?

I think GatewayCompilerConfig shouldn't hold the SierraToCasmCompilerConfig.

@ArniStarkware ArniStarkware changed the base branch from arni/declare/compilation/config/move_to_node_config to graphite-base/284 August 14, 2024 04:07
@ArniStarkware
Copy link
Contributor Author

A lot of requests regarding this PR. Please Do not review it until I re-publish it.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 16, 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