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: stateless validator add calldata len validator #38

Merged

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Apr 10, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.83%. Comparing base (7f02f89) to head (16a7af1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   63.15%   70.83%   +7.67%     
==========================================
  Files           5        5              
  Lines          95      120      +25     
  Branches       95      120      +25     
==========================================
+ Hits           60       85      +25     
  Misses         35       35              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it 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: 0 of 4 files reviewed, all discussions resolved (waiting on @Yael-Starkware)


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

        validate_non_zero_l1_gas_fee: true,
        ..VALIDATOR_CONFIG_FOR_TESTING
    },

I tried adding the resource bounds config explicitly to each test that deals with it. Do you consider it readable?

Code quote:

#[case::missing_l1_gas_resource_bounds(
    TransactionValidatorConfig{
        validate_non_zero_l1_gas_fee: true,
        ..VALIDATOR_CONFIG_FOR_TESTING
    },

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/try_2/calldata_len branch from e5c3156 to d6853a5 Compare April 10, 2024 12:23
@ArniStarkware ArniStarkware changed the base branch from main to arni/transaction_validator/stateless/rename_to_stateless_transaction_validator April 10, 2024 12:23
@ArniStarkware
Copy link
Contributor Author

crates/gateway/src/stateless_transaction_validator_test.rs line 38 at r2 (raw file):

        validate_non_zero_l1_gas_fee: true,
        ..VALIDATOR_CONFIG_FOR_TESTING
    },

I tried explicitly adding the resource bounds configuration to each test that deals with it. Do you consider it readable?

Code quote:

    TransactionValidatorConfig{
        validate_non_zero_l1_gas_fee: true,
        ..VALIDATOR_CONFIG_FOR_TESTING
    },

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 1 of 4 files at r1, 1 of 4 files at r2, all commit messages.
Reviewable status: 2 of 6 files reviewed, 4 unresolved discussions (waiting on @ArniStarkware)


crates/gateway/src/stateless_transaction_validator.rs line 50 at r2 (raw file):

        };

        fn validate_reousrce_bounds(

resource

Code quote:

reousrce

crates/gateway/src/stateless_transaction_validator.rs line 50 at r2 (raw file):

        };

        fn validate_reousrce_bounds(

is it common practice to put a function inside a function? never seen it and it was a bit confusing to me.


crates/gateway/src/stateless_transaction_validator_test.rs line 18 at r2 (raw file):

};

const VALIDATOR_CONFIG_FOR_TESTING: TransactionValidatorConfig = TransactionValidatorConfig {

VALIDATOR_DEFAULT_CONFIG_FOR_TESTING

Code quote:

VALIDATOR_CONFIG_FOR_TESTING

crates/gateway/src/stateless_transaction_validator_test.rs line 38 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

I tried explicitly adding the resource bounds configuration to each test that deals with it. Do you consider it readable?

it is not clear to me why this is the default behaviour? would expect it to be both true or both false.
validate_non_zero_l1_gas_fee: true,
validate_non_zero_l2_gas_fee: false,

I think it would be clearer if the default will be false for both and then you will override it with true when needed.
but maybe there is something I don't understand


crates/gateway/src/stateless_transaction_validator_test.rs line 87 at r2 (raw file):

    ),
    Err(TransactionValidatorError::CalldataTooLong { calldata_length: 2, max_calldata_length: 1 })
)]

add another case checking the good flow with non-empty calldata that does not exceed the maximum length

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/rename_to_stateless_transaction_validator branch from e1a5f3b to e67d927 Compare April 11, 2024 09:35
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/try_2/calldata_len branch from d6853a5 to 85b06e2 Compare April 11, 2024 09:52
@ArniStarkware ArniStarkware deleted the branch main April 11, 2024 10:07
@ArniStarkware ArniStarkware reopened this Apr 11, 2024
@ArniStarkware ArniStarkware changed the base branch from arni/transaction_validator/stateless/rename_to_stateless_transaction_validator to main April 11, 2024 10:10
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 7 files reviewed, 3 unresolved discussions (waiting on @Yael-Starkware)


crates/gateway/src/stateless_transaction_validator.rs line 50 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

resource

Done. addressed in #45


crates/gateway/src/stateless_transaction_validator.rs line 50 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

is it common practice to put a function inside a function? never seen it and it was a bit confusing to me.

Done.


crates/gateway/src/stateless_transaction_validator_test.rs line 18 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

VALIDATOR_DEFAULT_CONFIG_FOR_TESTING

Done. addressed in #45


crates/gateway/src/stateless_transaction_validator_test.rs line 38 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

it is not clear to me why this is the default behaviour? would expect it to be both true or both false.
validate_non_zero_l1_gas_fee: true,
validate_non_zero_l2_gas_fee: false,

I think it would be clearer if the default will be false for both and then you will override it with true when needed.
but maybe there is something I don't understand

Good point. Addressed in Pre-PR. #45.


crates/gateway/src/stateless_transaction_validator_test.rs line 87 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

add another case checking the good flow with non-empty calldata that does not exceed the maximum length

Done.

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/try_2/calldata_len branch from 85b06e2 to a1dee40 Compare April 11, 2024 10:40
@ArniStarkware ArniStarkware changed the base branch from main to arni/transaction_validator/stateless/tests/resource_bounds_mapping_param April 11, 2024 10:41
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/tests/resource_bounds_mapping_param branch from de47b45 to 10103bb Compare April 11, 2024 10:42
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/try_2/calldata_len branch from a1dee40 to 2cc8517 Compare April 11, 2024 10:44
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/tests/resource_bounds_mapping_param branch from 10103bb to a9a28ee Compare April 11, 2024 11:58
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/try_2/calldata_len branch from 2cc8517 to a8ad36d Compare April 11, 2024 12:46
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 1 of 4 files at r1, 3 of 3 files at r3, all commit messages.
Reviewable status: 4 of 6 files reviewed, 3 unresolved discussions (waiting on @Yael-Starkware)

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.

:lgtm:

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: 4 of 6 files reviewed, all discussions resolved (waiting on @dafnamatsry)

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/tests/resource_bounds_mapping_param branch from a9a28ee to 484c7fc Compare April 16, 2024 07:41
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/try_2/calldata_len branch from a8ad36d to 12ab270 Compare April 16, 2024 08:19
@ArniStarkware ArniStarkware changed the base branch from arni/transaction_validator/stateless/tests/resource_bounds_mapping_param to main April 16, 2024 08:35
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/try_2/calldata_len branch from 12ab270 to 16a7af1 Compare April 16, 2024 08:36
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.

:lgtm:

Reviewable status: 2 of 6 files reviewed, all discussions resolved (waiting on @dafnamatsry)

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.

:lgtm:

Reviewable status: 2 of 6 files reviewed, all discussions resolved (waiting on @dafnamatsry)

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 4 files at r2, 2 of 2 files at r4.
Reviewable status: all files reviewed (commit messages unreviewed), all discussions resolved (waiting on @dafnamatsry)

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)

@ArniStarkware ArniStarkware merged commit 18186d8 into main Apr 16, 2024
8 checks passed
@ArniStarkware ArniStarkware deleted the arni/transaction_validator/stateless/try_2/calldata_len branch April 21, 2024 08:36
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