-
Notifications
You must be signed in to change notification settings - Fork 11
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
chore: add missing deploy_tx to get_sender_address and make run_validate return the mempool_input #527
Conversation
…ate return the mempool_input
2f720cc
to
fb2cf30
Compare
Codecov ReportAttention: Patch coverage is
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. |
There was a problem hiding this 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(())
}
There was a problem hiding this 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.
Previously, Yael-Starkware (YaelD) wrote…
Do we want to abandon this PR or merge it with a TODO? |
PRs should be migrated to the |
There was a problem hiding this 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
This change is