-
Notifications
You must be signed in to change notification settings - Fork 107
refactor: move skip validation check to py_validator #2013
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2013 +/- ##
==========================================
- Coverage 80.17% 79.89% -0.28%
==========================================
Files 69 69
Lines 9739 9739
Branches 9739 9739
==========================================
- Hits 7808 7781 -27
- Misses 1471 1501 +30
+ Partials 460 457 -3 ☔ 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.
python PR for CI testing:
https://github.com/starkware-industries/starkware/pull/35347
Reviewable status: 0 of 3 files reviewed, all discussions resolved
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 3 files reviewed, 1 unresolved discussion
-- commits
line 2 at r1:
blocking until python tests run and pass
Previously, Yael-Starkware (YaelD) wrote…
link? |
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.
Reviewed 2 of 3 files at r1.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @dafnamatsry, @Yael-Starkware, and @Yoni-Starkware)
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 0 at r1 (raw file):
A test that checks the skip_validate
functionality is missing (And many more tests TBH).
crates/native_blockifier/src/py_validator.rs
line 79 at r1 (raw file):
deploy_account_tx_hash, )?; }
Suggestion:
let skip_validate = if let AccountTransaction::Invoke(tx) = &account_tx {
self.stateful_validator.skip_validate_due_to_unprocessed_deploy_account(
tx.tx.sender_address(),
tx.tx.nonce(),
deploy_account_tx_hash,
)?
} else {false}
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: 2 of 3 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)
crates/native_blockifier/src/py_validator.rs
line 76 at r1 (raw file):
self.stateful_validator.skip_validate_due_to_unprocessed_deploy_account( tx.tx.sender_address(), tx.tx.nonce(),
Can you avoid using the raw python tx?
Suggestion:
&account_tx.create_tx_info(),
b79bff8
to
6715494
Compare
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: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @dafnamatsry)
Previously, ArniStarkware (Arnon Hod) wrote…
link?
was state at the top :
https://reviewable.io/reviews/starkware-industries/starkware/35347
crates/blockifier/src/blockifier/stateful_validator_test.rs
line at r1 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
A test that checks the
skip_validate
functionality is missing (And many more tests TBH).
added a test, done
crates/native_blockifier/src/py_validator.rs
line 76 at r1 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
Can you avoid using the raw python tx?
done
crates/native_blockifier/src/py_validator.rs
line 79 at r1 (raw file):
deploy_account_tx_hash, )?; }
done.
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: 1 of 3 files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @Yael-Starkware, and @Yoni-Starkware)
crates/blockifier/src/blockifier/stateful_validator.rs
line 117 at r2 (raw file):
// `__validate__` method for subsequent transactions for a better user experience. // (they will otherwise fail solely because the deploy account hasn't been processed yet). pub fn skip_validate_due_to_unprocessed_deploy_account(
I would move this logic as well to py_validator
.
Code quote:
pub fn skip_validate_due_to_unprocessed_deploy_account(
crates/blockifier/src/blockifier/stateful_validator.rs
line 120 at r2 (raw file):
&mut self, sender_address: ContractAddress, tx_nonce: Nonce,
Consider passing AccountTrnasaction, and check that this is Invoke here
Code quote:
sender_address: ContractAddress,
tx_nonce: Nonce,
crates/native_blockifier/src/py_validator.rs
line 71 at r2 (raw file):
let deploy_account_tx_hash = deploy_account_tx_hash.map(|hash| TransactionHash(hash.0)); // We check if the transaction should be skipped due to the deploy account not being // processed.
Suggestion:
let deploy_account_tx_hash = deploy_account_tx_hash.map(|hash| TransactionHash(hash.0));
// We check if the transaction should be skipped due to the deploy account not being
// processed.
6715494
to
6430958
Compare
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 3 files reviewed, 5 unresolved discussions (waiting on @ArniStarkware, @dafnamatsry, and @Yoni-Starkware)
crates/blockifier/src/blockifier/stateful_validator.rs
line 117 at r2 (raw file):
Previously, dafnamatsry wrote…
I would move this logic as well to
py_validator
.
I tried but this function is touching private fields of stateful_validator so I can't use it outside of the crate. I think it also makes sense logically to keep it there because it exposes the implementation details of the stateful validator.
crates/blockifier/src/blockifier/stateful_validator.rs
line 120 at r2 (raw file):
Previously, dafnamatsry wrote…
Consider passing AccountTrnasaction, and check that this is Invoke here
done
crates/native_blockifier/src/py_validator.rs
line 71 at r2 (raw file):
let deploy_account_tx_hash = deploy_account_tx_hash.map(|hash| TransactionHash(hash.0)); // We check if the transaction should be skipped due to the deploy account not being // processed.
Done.
6430958
to
3142af1
Compare
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 3 files reviewed, 7 unresolved discussions (waiting on @dafnamatsry, @Yael-Starkware, and @Yoni-Starkware)
Previously, Yael-Starkware (YaelD) wrote…
was state at the top :
https://reviewable.io/reviews/starkware-industries/starkware/35347
tnx.
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 91 at r3 (raw file):
scenario: INVALID, ..transaction_args });
Suggestion:
// Create a transaction that does not pass validations.
let tx = create_account_tx_for_validate_test_nonce_0(FaultyAccountTxCreatorArgs {
scenario: INVALID,
tx_type: TransactionType::InvokeFunction,
tx_version: TransactionVersion::THREE,
sender_address: faulty_account.get_instance_address(0),
class_hash: faulty_account.get_class_hash(),
max_fee: Fee(BALANCE),
..Default::default()
});
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 95 at r3 (raw file):
let mut stateful_validator = StatefulValidator::create(state, block_context, nonce!(0_u32)); // The transaction validations should be skipped and the function should return Ok. let result = stateful_validator.perform_validations(tx, true);
Suggestion:
// The transaction validations should be skipped and the function should return Ok.
let skip_validate = true;
let result = stateful_validator.perform_validations(tx, skip_validate);
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 96 at r3 (raw file):
// The transaction validations should be skipped and the function should return Ok. let result = stateful_validator.perform_validations(tx, true); assert!(result.is_ok());
Better error representation.
(If the test fails, it will print out why it failed).
Suggestion:
assert_matches!(result, Ok());
3142af1
to
f8692a1
Compare
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 3 files reviewed, 6 unresolved discussions (waiting on @ArniStarkware, @dafnamatsry, and @Yoni-Starkware)
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 91 at r3 (raw file):
scenario: INVALID, ..transaction_args });
Done.
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 95 at r3 (raw file):
let mut stateful_validator = StatefulValidator::create(state, block_context, nonce!(0_u32)); // The transaction validations should be skipped and the function should return Ok. let result = stateful_validator.perform_validations(tx, true);
Done.
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 96 at r3 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
Better error representation.
(If the test fails, it will print out why it failed).
Done.
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.
Reviewed all commit messages.
Reviewable status: 0 of 3 files reviewed, 6 unresolved discussions (waiting on @ArniStarkware and @dafnamatsry)
crates/blockifier/src/blockifier/stateful_validator.rs
line 117 at r2 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
I tried but this function is touching private fields of stateful_validator so I can't use it outside of the crate. I think it also makes sense logically to keep it there because it exposes the implementation details of the stateful validator.
You can move max_nonce_for_validation_skip
(also not related to the rust class) and expose justget_nonce
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.
Reviewed 1 of 1 files at r4.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry)
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.
Reviewed all commit messages.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry)
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.
Reviewed all commit messages.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @Yael-Starkware, and @Yoni-Starkware)
crates/blockifier/src/blockifier/stateful_validator.rs
line 117 at r2 (raw file):
Previously, Yoni-Starkware (Yoni) wrote…
You can move
max_nonce_for_validation_skip
(also not related to the rust class) and expose justget_nonce
+1 to Yoni's suggestion.
crates/blockifier/src/blockifier/stateful_validator.rs
line 122 at r4 (raw file):
account_tx: &AccountTransaction, sender_address: ContractAddress, tx_nonce: Nonce,
Can these be extracted from account_tx
?
Code quote:
sender_address: ContractAddress,
tx_nonce: Nonce,
f8692a1
to
952ce7f
Compare
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 3 files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @dafnamatsry, and @Yoni-Starkware)
crates/blockifier/src/blockifier/stateful_validator.rs
line 117 at r2 (raw file):
Previously, dafnamatsry wrote…
+1 to Yoni's suggestion.
indeed looks better now.
Done.
crates/blockifier/src/blockifier/stateful_validator.rs
line 122 at r4 (raw file):
Previously, dafnamatsry wrote…
Can these be extracted from
account_tx
?
Done.
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.
Reviewed 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Yael-Starkware)
crates/blockifier/src/blockifier/stateful_validator.rs
line 151 at r5 (raw file):
.expect(BLOCK_STATE_ACCESS_ERR) .get_nonce_at(account_address)?; Ok(nonce)
A bit cleaner. non-blocking...
Suggestion:
self
.tx_executor
.block_state
.as_ref()
.expect(BLOCK_STATE_ACCESS_ERR)
.get_nonce_at(account_address);
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 95 at r3 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
Done.
Not critical at all, but IMO the original was better. VSCode does the job of showing the names of the arguments for us.
crates/native_blockifier/src/py_validator.rs
line 90 at r5 (raw file):
// (they will otherwise fail solely because the deploy account hasn't been processed yet). pub fn skip_validate_due_to_unprocessed_deploy_account( py_validator: &mut PyValidator,
You can define it as a method of PyValidator
, and pass self instead.
Code quote:
py_validator: &mut PyValidator,
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: all files reviewed, 2 unresolved discussions (waiting on @dafnamatsry)
crates/blockifier/src/blockifier/stateful_validator.rs
line 151 at r5 (raw file):
Previously, dafnamatsry wrote…
A bit cleaner. non-blocking...
it doesn't work because the error type is different between the value returned from get_nonce_at and get_nonce. Wrapping it with Ok does the job.
Done.
crates/blockifier/src/blockifier/stateful_validator_test.rs
line 95 at r3 (raw file):
Previously, dafnamatsry wrote…
Not critical at all, but IMO the original was better. VSCode does the job of showing the names of the arguments for us.
Done.
crates/native_blockifier/src/py_validator.rs
line 90 at r5 (raw file):
Previously, dafnamatsry wrote…
You can define it as a method of
PyValidator
, and pass self instead.
originally that was what I did and it didn't compile because of the #[pyclass] requirement.
But here since you insisted I found a suitable solution, put in in a different impl clause.
952ce7f
to
295492c
Compare
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.
Reviewed 3 of 3 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Yael-Starkware)
crates/native_blockifier/src/py_validator.rs
line 90 at r5 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
originally that was what I did and it didn't compile because of the #[pyclass] requirement.
But here since you insisted I found a suitable solution, put in in a different impl clause.
Nice!
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: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)
295492c
to
76a9661
Compare
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.
Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)
This reverts commit bad24f2.
This change is