Browse Source

Set cap for new allocations per transaction (#27385)

Brooks Prumo 3 years ago
parent
commit
cea7c722b6
1 changed files with 7 additions and 0 deletions
  1. 7 0
      interface/src/instruction.rs

+ 7 - 0
interface/src/instruction.rs

@@ -142,6 +142,13 @@ pub fn instruction_to_nonce_error(
 /// Maximum permitted size of data: 10 MiB
 pub const MAX_PERMITTED_DATA_LENGTH: u64 = 10 * 1024 * 1024;
 
+/// Maximum permitted size of new allocations per transaction, in bytes
+///
+/// The value was chosen such at least one max sized account could be created,
+/// plus some additional resize allocations.
+pub const MAX_PERMITTED_ACCOUNTS_DATA_ALLOCATIONS_PER_TRANSACTION: i64 =
+    MAX_PERMITTED_DATA_LENGTH as i64 * 2;
+
 // SBF program entrypoint assumes that the max account data length
 // will fit inside a u32. If this constant no longer fits in a u32,
 // the entrypoint deserialization code in the SDK must be updated.