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(gateway): add fee non zero validation #12

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Mar 20, 2024

This change is Reviewable

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch 2 times, most recently from e06cfff to 952c4dd Compare March 20, 2024 14:07
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch 4 times, most recently from 39d7882 to f35ff45 Compare March 24, 2024 08:56
Copy link
Collaborator

@elintul elintul 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 2 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @dafnamatsry)


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

    pub max_allowed_tx_version: TransactionVersion,

    pub enforce_fee: bool,

I think in Python we only use this flag for testing.

Code quote:

enforce_fee

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch from f35ff45 to ebac973 Compare March 24, 2024 15:51
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch from 952c4dd to e1172c4 Compare March 24, 2024 16:06
@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2024

Codecov Report

Attention: Patch coverage is 92.72727% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 88.46%. Comparing base (60b6092) to head (b2dcffd).

Files Patch % Lines
crates/gateway/src/starknet_api_utils.rs 93.44% 4 Missing ⚠️
crates/gateway/src/transaction_validator.rs 91.83% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@                                Coverage Diff                                @@
##           arni/transaction_validator/stateless/skelaton      #12      +/-   ##
=================================================================================
+ Coverage                                          83.70%   88.46%   +4.75%     
=================================================================================
  Files                                                  4        4              
  Lines                                                135      234      +99     
  Branches                                             135      234      +99     
=================================================================================
+ Hits                                                 113      207      +94     
- Misses                                                20       22       +2     
- Partials                                               2        5       +3     

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

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch from ebac973 to d78d39c Compare March 24, 2024 16:24
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch from e1172c4 to 1ef827f Compare March 24, 2024 16:35
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch 2 times, most recently from 5296e8c to f450b07 Compare March 24, 2024 16:53
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch from 1ef827f to ece33af Compare March 24, 2024 16:54
@ArniStarkware ArniStarkware requested a review from elintul March 24, 2024 16:58
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, 1 unresolved discussion (waiting on @dafnamatsry and @elintul)


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

Previously, elintul (Elin) wrote…

I think in Python we only use this flag for testing.

Removed. If it is required, we will add it later.

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch from f450b07 to 33aa4af Compare March 25, 2024 08:40
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch from ece33af to 2683200 Compare March 25, 2024 08:41
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch from 33aa4af to c7884cd Compare March 25, 2024 09:32
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch from 2683200 to f7972ff Compare March 25, 2024 09:36
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.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @elintul)


crates/gateway/src/starknet_api_utils.rs line 57 at r4 (raw file):

impl TransactionParametersExt for Transaction {
    fn max_fee(&self) -> StarknetApiTransactionResult<Fee> {

I think it is getting too complicated with macros and many trait extensions.

Consider the following:

let resource_bounds = match self {
  StarknetApiTransaction::Declare(
                starknet_api::transaction::DeclareTransaction::V0(_)
                | starknet_api::transaction::DeclareTransaction::V1(_)
                | starknet_api::transaction::DeclareTransaction::V2(_),
            ) => unimplemented!(),
  Transaction::Declare(DeclareTransaction::V3(tx)) => tx.resource_bounds,
  ...
}

... compute max_fee from resource_bounds ...

Ok(max_fee)

@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch from c7884cd to a865f4d Compare March 31, 2024 06:16
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch from f7972ff to e6ae424 Compare March 31, 2024 06:18
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/skelaton branch from a865f4d to 60b6092 Compare March 31, 2024 08:45
@ArniStarkware ArniStarkware force-pushed the arni/transaction_validator/stateless/non_zero_fee branch from e6ae424 to b2dcffd Compare March 31, 2024 09:20
@ArniStarkware ArniStarkware changed the base branch from arni/transaction_validator/stateless/skelaton to arni/transaction_validator/stateless/tx_size March 31, 2024 09:21
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 @dafnamatsry and @elintul)


crates/gateway/src/starknet_api_utils.rs line 57 at r4 (raw file):

Previously, dafnamatsry wrote…

I think it is getting too complicated with macros and many trait extensions.

Consider the following:

let resource_bounds = match self {
  StarknetApiTransaction::Declare(
                starknet_api::transaction::DeclareTransaction::V0(_)
                | starknet_api::transaction::DeclareTransaction::V1(_)
                | starknet_api::transaction::DeclareTransaction::V2(_),
            ) => unimplemented!(),
  Transaction::Declare(DeclareTransaction::V3(tx)) => tx.resource_bounds,
  ...
}

... compute max_fee from resource_bounds ...

Ok(max_fee)

I reordered the PRs.
(This PR sitis on top of #15 now).

Now, the macro infrastructure is cleaner, smaller and clearer.

@ArniStarkware
Copy link
Contributor Author

replaced with: #29

@ArniStarkware ArniStarkware deleted the arni/transaction_validator/stateless/non_zero_fee branch April 10, 2024 08:28
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