Clean up demote program write lock feature (backport #21949) (#21969)

* Clean up demote program write lock feature (#21949)

* Clean up demote program write lock feature

* fix test

(cherry picked from commit 6ff0be6a82)

# Conflicts:
#	programs/bpf_loader/src/syscalls.rs
#	runtime/src/accounts.rs

* resolve conflicts

Co-authored-by: Justin Starry <justin@solana.com>
This commit is contained in:
mergify[bot]
2021-12-17 04:45:22 +00:00
committed by GitHub
parent 0c5a2bcd5a
commit f4521002b9
19 changed files with 98 additions and 203 deletions

View File

@@ -415,7 +415,7 @@ pub fn uses_durable_nonce(tx: &Transaction) -> Option<&CompiledInstruction> {
// Nonce account is writable
&& matches!(
instruction.accounts.get(0),
Some(index) if message.is_writable(*index as usize, true)
Some(index) if message.is_writable(*index as usize)
)
})
}

View File

@@ -140,7 +140,7 @@ impl SanitizedTransaction {
}
/// Return the list of accounts that must be locked during processing this transaction.
pub fn get_account_locks(&self, demote_program_write_locks: bool) -> TransactionAccountLocks {
pub fn get_account_locks(&self) -> TransactionAccountLocks {
let message = &self.message;
let num_readonly_accounts = message.num_readonly_accounts();
let num_writable_accounts = message
@@ -153,7 +153,7 @@ impl SanitizedTransaction {
};
for (i, key) in message.account_keys_iter().enumerate() {
if message.is_writable(i, demote_program_write_locks) {
if message.is_writable(i) {
account_locks.writable.push(key);
} else {
account_locks.readonly.push(key);
@@ -183,7 +183,7 @@ impl SanitizedTransaction {
.and_then(|ix| {
ix.accounts.get(0).and_then(|idx| {
let idx = *idx as usize;
if nonce_must_be_writable && !self.message.is_writable(idx, true) {
if nonce_must_be_writable && !self.message.is_writable(idx) {
None
} else {
self.message.get_account_key(idx)