Limit number of accounts that a transaction can lock (backport #22201) (#22263)

* Limit number of accounts that a transaction can lock (#22201)

(cherry picked from commit 2b5e00d36d)

# Conflicts:
#	accountsdb-plugin-postgres/src/postgres_client/postgres_client_transaction.rs
#	runtime/src/accounts.rs
#	runtime/src/bank.rs
#	sdk/src/feature_set.rs
#	sdk/src/transaction/error.rs
#	storage-proto/proto/transaction_by_addr.proto
#	storage-proto/src/convert.rs

* resolve conflicts

Co-authored-by: Justin Starry <justin@solana.com>
This commit is contained in:
mergify[bot]
2022-01-04 11:34:34 +00:00
committed by GitHub
parent 7d2589e2ac
commit 3b59f67562
10 changed files with 267 additions and 116 deletions

View File

@ -30,8 +30,6 @@ pub enum SanitizeMessageError {
ValueOutOfBounds,
#[error("invalid value")]
InvalidValue,
#[error("duplicate account key")]
DuplicateAccountKey,
}
impl From<SanitizeError> for SanitizeMessageError {
@ -48,13 +46,7 @@ impl TryFrom<LegacyMessage> for SanitizedMessage {
type Error = SanitizeMessageError;
fn try_from(message: LegacyMessage) -> Result<Self, Self::Error> {
message.sanitize()?;
let sanitized_msg = Self::Legacy(message);
if sanitized_msg.has_duplicates() {
return Err(SanitizeMessageError::DuplicateAccountKey);
}
Ok(sanitized_msg)
Ok(Self::Legacy(message))
}
}
@ -310,21 +302,6 @@ mod tests {
#[test]
fn test_try_from_message() {
let dupe_key = Pubkey::new_unique();
let legacy_message_with_dupes = LegacyMessage {
header: MessageHeader {
num_required_signatures: 1,
..MessageHeader::default()
},
account_keys: vec![dupe_key, dupe_key],
..LegacyMessage::default()
};
assert_eq!(
SanitizedMessage::try_from(legacy_message_with_dupes).err(),
Some(SanitizeMessageError::DuplicateAccountKey),
);
let legacy_message_with_no_signers = LegacyMessage {
account_keys: vec![Pubkey::new_unique()],
..LegacyMessage::default()