Refactor: Add AccountKeys struct for static and dynamic message keys (#22960)
This commit is contained in:
@ -156,7 +156,7 @@ impl SanitizedTransaction {
|
||||
if self.message.has_duplicates() {
|
||||
Err(TransactionError::AccountLoadedTwice)
|
||||
} else if feature_set.is_active(&feature_set::max_tx_account_locks::id())
|
||||
&& self.message.account_keys_len() > MAX_TX_ACCOUNT_LOCKS
|
||||
&& self.message.account_keys().len() > MAX_TX_ACCOUNT_LOCKS
|
||||
{
|
||||
Err(TransactionError::TooManyAccountLocks)
|
||||
} else {
|
||||
@ -167,17 +167,16 @@ impl SanitizedTransaction {
|
||||
/// Return the list of accounts that must be locked during processing this transaction.
|
||||
pub fn get_account_locks_unchecked(&self) -> TransactionAccountLocks {
|
||||
let message = &self.message;
|
||||
let account_keys = message.account_keys();
|
||||
let num_readonly_accounts = message.num_readonly_accounts();
|
||||
let num_writable_accounts = message
|
||||
.account_keys_len()
|
||||
.saturating_sub(num_readonly_accounts);
|
||||
let num_writable_accounts = account_keys.len().saturating_sub(num_readonly_accounts);
|
||||
|
||||
let mut account_locks = TransactionAccountLocks {
|
||||
writable: Vec::with_capacity(num_writable_accounts),
|
||||
readonly: Vec::with_capacity(num_readonly_accounts),
|
||||
};
|
||||
|
||||
for (i, key) in message.account_keys_iter().enumerate() {
|
||||
for (i, key) in account_keys.iter().enumerate() {
|
||||
if message.is_writable(i) {
|
||||
account_locks.writable.push(key);
|
||||
} else {
|
||||
@ -215,7 +214,7 @@ impl SanitizedTransaction {
|
||||
if self
|
||||
.signatures
|
||||
.iter()
|
||||
.zip(self.message.account_keys_iter())
|
||||
.zip(self.message.account_keys().iter())
|
||||
.map(|(signature, pubkey)| signature.verify(pubkey.as_ref(), &message_bytes))
|
||||
.any(|verified| !verified)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ impl Sanitize for VersionedTransaction {
|
||||
|
||||
// Signatures are verified before message keys are loaded so all signers
|
||||
// must correspond to static account keys.
|
||||
if self.signatures.len() > self.message.static_account_keys_len() {
|
||||
if self.signatures.len() > self.message.static_account_keys().len() {
|
||||
return Err(SanitizeError::IndexOutOfBounds);
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ impl VersionedTransaction {
|
||||
fn _verify_with_results(&self, message_bytes: &[u8]) -> Vec<bool> {
|
||||
self.signatures
|
||||
.iter()
|
||||
.zip(self.message.static_account_keys_iter())
|
||||
.zip(self.message.static_account_keys().iter())
|
||||
.map(|(signature, pubkey)| signature.verify(pubkey.as_ref(), message_bytes))
|
||||
.collect()
|
||||
}
|
||||
|
Reference in New Issue
Block a user