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: add missing deploy_tx to get_sender_address and make run_validate return the mempool_input #527

Closed

Conversation

Yael-Starkware
Copy link
Contributor

@Yael-Starkware Yael-Starkware commented Jul 24, 2024

This change is Reviewable

@Yael-Starkware Yael-Starkware force-pushed the yael/missing_sender_address_for_deploy_simpler branch from 2f720cc to fb2cf30 Compare July 24, 2024 07:50
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 71.42857% with 6 lines in your changes missing coverage. Please review.

Project coverage is 81.11%. Comparing base (fc5813a) to head (fb2cf30).
Report is 1 commits behind head on main.

Files Patch % Lines
crates/gateway/src/utils.rs 66.66% 4 Missing ⚠️
crates/gateway/src/gateway.rs 50.00% 0 Missing and 1 partial ⚠️
...ates/gateway/src/stateful_transaction_validator.rs 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #527      +/-   ##
==========================================
- Coverage   81.21%   81.11%   -0.11%     
==========================================
  Files          42       42              
  Lines        1826     1832       +6     
  Branches     1826     1832       +6     
==========================================
+ Hits         1483     1486       +3     
- Misses        269      272       +3     
  Partials       74       74              

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

Copy link
Contributor

@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 @Yael-Starkware)


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

    let validator = stateful_tx_validator.instantiate_validator(state_reader_factory)?;
    let mempool_input = stateful_tx_validator.run_validate(&tx, optional_class_info, validator)?;

The second part of my suggestion.

Suggestion:

    let validator = stateful_tx_validator.instantiate_validator(state_reader_factory)?;
    let account_tx = external_tx_to_account_tx(
            external_tx,
            optional_class_info,
            &self.config.chain_info.chain_id, // Requires another step for this refactor. As this implies, the chain_info is no longer a property of the validator (it never really was...)
        )?;
    
    stateful_tx_validator.run_validate(&account_tx, validator)?;
    
    let tx_hash = get_tx_hash(&account_tx);
    let sender_address = get_sender_address(&account_tx);
    let mempool_input = MempoolInput {
            tx: external_tx_to_thin_tx(external_tx, tx_hash, sender_address),
            account: Account { sender_address, state: AccountState { nonce: account_nonce } },
        }

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

            account: Account { sender_address, state: AccountState { nonce: account_nonce } },
        })
    }

I think it is odd that the validator returns all of these things.
In my opinion, the correct thing to do is to change the input of the stateful validator so it returns nothing.

Move the creation of account transactions out - into process_tx.

Suggestion:

impl StatefulTransactionValidator {
    pub fn run_validate<V: StatefulTransactionValidatorTrait>(
        &self,
        account_tx: ...,
        mut validator: V,
    ) -> StatefulTransactionValidatorResult<()> {


        let account_nonce = validator.get_nonce(sender_address)?;
        let skip_validate = skip_stateful_validations(external_tx, account_nonce); // fix me.
        validator.validate(account_tx, skip_validate)?;
        Ok(())
    }

Copy link
Contributor Author

@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 4 files reviewed, 2 unresolved discussions (waiting on @dafnamatsry)


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

Previously, ArniStarkware (Arnon Hod) wrote…

The second part of my suggestion.

yeah I fully agree, I actually already implemented it like that, but then it also requires changing the tests to get the account_tx instead of rpc_tx.
Since the ThinTransaction and AccountTransaction should eventually become InternalTransaction, and after consulting with @dafnamatsry about it, we decided to do the full refactor when we'll start using the Internal Transaction.

but indeed getting the mempool_input from the run_validate is odd.

@ArniStarkware
Copy link
Contributor

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

Previously, Yael-Starkware (YaelD) wrote…

yeah I fully agree, I actually already implemented it like that, but then it also requires changing the tests to get the account_tx instead of rpc_tx.
Since the ThinTransaction and AccountTransaction should eventually become InternalTransaction, and after consulting with @dafnamatsry about it, we decided to do the full refactor when we'll start using the Internal Transaction.

but indeed getting the mempool_input from the run_validate is odd.

Do we want to abandon this PR or merge it with a TODO?

@ArniStarkware
Copy link
Contributor

PRs should be migrated to the sequencer repo.

Copy link
Contributor Author

@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 4 files reviewed, 2 unresolved discussions (waiting on @dafnamatsry)


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

Previously, ArniStarkware (Arnon Hod) wrote…

Do we want to abandon this PR or merge it with a TODO?

not to abandon for sure, maybe modify, I will talk with @dafnamatsry

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.

3 participants