-
Notifications
You must be signed in to change notification settings - Fork 263
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
Calls inspect_account() on the fee payer #2718
Calls inspect_account() on the fee payer #2718
Conversation
@HaoranYi - we missed this one earlier |
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.
Ah. I missed this one. Looks like it is a recent refactoring that moved the fee accounts out of transaction account loading.
Good catch.
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.
Are there any tests for this inspect account feature? We should have a test to ensure all writable accounts are now inspected after this bug fix.
f3efdd4
Good call. I've added tests in f3efdd4. |
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.
The new tests look great but I was actually hoping for a test that would have caught this bug at a higher level. Namely an integration test that tests that all accounts in a transaction were inspected. Actually it would be nice to have two integration tests.. one for a fully loaded transaction and one for a transaction which only validated the fee payer but is still able to be committed (named FeesOnlyTransaction
)
|
||
let message = Message { | ||
account_keys: vec![address0, address1, address2, address3], | ||
header: MessageHeader::default(), |
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.
So I guess this default header is causing all accounts to be loaded as writable because it means there are 0 signers and 0 readonly non-signers? And the program is loaded as readonly because it was demoted by demote_program_id
? Do you mind adding comments describing this behavior?
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.
Sure, I can add a comment. I'm not familiar with these specifics; why is that information germane to this test?
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.
Because it's important that account inspection correctly captures whether an account is loaded with a write lock, right?
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.
I think no, not this test. This test only cares that the accounts are being inspected. The writability is assumed to be correct. (I imagine there are tests that are test this, yes?)
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.
Ok that seems reasonable to me
Looking at the code, I think we might miss sysvar too. |
**: we should see all the accounts in the transactions, right? |
Yeah. we will handle them specially in lt-hash work. Feel free to ignore the comments. It is out the scope of this PR. |
Done! I've added an integration test in a401c5f.
I'm not sure what this would be testing. Should the transaction not load the other accounts in the |
Yeah I'm not really sure either. Maybe it can come later? I'm just thinking about how loading could bail halfway through and so some accounts would be recorded as inspected but others would not be. And in the end we will only be committing state changes for fee payer / nonce. |
@@ -90,6 +93,19 @@ impl TransactionProcessingCallback for MockBankCallback { | |||
.unwrap() | |||
.insert(*program_id, account_data); | |||
} | |||
|
|||
fn inspect_account(&self, address: &Pubkey, account_state: AccountState, is_writable: bool) { |
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.
Do we want the mock to push read-only accounts here?
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.
I was thinking 'yes', but I guess doesn't need to. What would you prefer here?
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.
I don't have any preference, we can keep it as is
svm/tests/integration_test.rs
Outdated
// Ensure all the expected inspected accounts were inspected | ||
let actual_inspected_accounts = mock_bank.inspected_accounts.read().unwrap().clone(); | ||
for (expected_pubkey, expected_account) in expected_inspected_accounts { | ||
let actual_account = actual_inspected_accounts.get(&expected_pubkey).unwrap(); | ||
assert_eq!( | ||
expected_account, *actual_account, | ||
"pubkey: {expected_pubkey}", | ||
); | ||
} |
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.
Should also assert that len
of actual and expected accounts is the same. In your test, the actual inspected accounts includes extra read only accounts.
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.
Good call. I've added a len
check, and also added read-only accounts in 877a38c.
PR #2623 refactored the svm integration tests, so I need to rebase and rewrite the integration test in this PR. |
877a38c
to
b19d98c
Compare
Problem
#2678 added a callback to inspect accounts prior to transaction processing. Unfortunately this did not include the fee payer, which is loaded separately.
Summary of Changes
Also inspect the fee payer.