-
Notifications
You must be signed in to change notification settings - Fork 306
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
unified_scheduler_logic: replace get_account_locks_unchecked #2554
unified_scheduler_logic: replace get_account_locks_unchecked #2554
Conversation
// the checks before calling this (say, with some ad-hoc type like | ||
// `SanitizedTransactionWithCheckedAccountLocks`) or do the checks here, resulting in | ||
// eliminating the redundant one in the replaying stage and in the handler. | ||
let locks = transaction.get_account_locks_unchecked(); |
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.
get rid of 2 allocations here
unified-scheduler-logic/src/lib.rs
Outdated
.map(|(index, address)| { | ||
LockContext::new( | ||
usage_queue_loader(*address), | ||
if message.is_writable(index) { |
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.
iteration + call to is_writable
is what get_account_locks_unchecked
was doing anyway.
So would expect performance to be slightly better since we are removing allocation and an iteration without adding additional work.
unified-scheduler-logic/src/lib.rs
Outdated
let message = transaction.message(); | ||
let lock_contexts = message |
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.
nit: method chain can be extended further:
let lock_contexts = transaction
.message()
.account_keys()
...
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.
unified-scheduler-logic/src/lib.rs
Outdated
// Locks are validated later in the pipeline. Here we create a task | ||
// without checking that locks are valid. |
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.
in fact, checking locks must be done prior to enqueuing tasks. that's because SchedulingStateMachine
will cause dead locks on the existence of non-unique UsageQeueue
s inside a given Task
.
So, the original comment was wrong and misleading... Nevertheless, this comment has been serving as a reminder for me. how about retaining it while being updated like this?:
// It's crucial for tasks to be validated with
// `SanitizedTransaction::validate_account_locks()` prior to the creation.
// That's because it's part of protocol consensus regarding the rejection of
// blocks containing malformed transactions (`AccountLoadedTwice` and
// `TooManyAccountLocks`). Even more,`SchedulingStateMachine` can't properly
// handle transactions with duplicate addresses (those falling under
// `AccountLoadedTwice`).
//
// However, it's okay for now not to call `::validate_account_locks()` here.
//
// Currently the replaying stage is always calling `get_account_locks()`
// regardless unified scheduler is enabled or not at the blockstore
// (`Bank::prepare_sanitized_batch()` is called in `process_entries()`).
// This verification will be hoisted for optimization
// when removing `--block-verificatio-method=blockstore-processor`.
//
// As for banking stage with unified scheduler, it will need to run
// `.validate_account_locks()` at least once somewhere in the code path.
// In the distant future, this function (`create_task()`) should be adjusted
// so that both stages do the checks before calling this (say, with some ad-hoc
// type like `SanitizedTransactionWithCheckedAccountLocks`) or do the checks
// here, to simplify the two code paths regarding the essential
// `validate_account_locks` validation.
//
// Lastly, `validate_account_locks()` is currently called in
// `DefaultTransactionHandler::handle()` via
// `Bank::prepare_unlocked_batch_from_single_tx()` as well.
// This redundancy is known. It was just left as-is out of abundance of caution.
(please reword and/or reformat as needed...)
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.
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.
lgtm. thanks for updating the comment.
(ci is failing partly due to test_scheduler_drop_short_circuiting
.... sorry about that. I'll work on it soon.)
Problem
validate_account_locks
function got pulled intoaccount_locks
fromsdk
get_account_locks
andget_account_locks_unchecked
will be deprecatedget_account_locks_unchecked
Summary of Changes
get_account_locks_unchecked
with more direct accessFixes #