Skip to content

Commit 5c9a180

Browse files
authored
Merge pull request #3303 from ProvableHQ/feat/increase-program-size-2048
[Feat] Increase program size limit to 2048 kB
2 parents 5138185 + 9c6b81f commit 5c9a180

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

console/network/src/consensus_heights.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub enum ConsensusVersion {
5959
V15 = 15,
6060
/// V16: Moves the block's spend limit check to the finalize phase.
6161
/// Supports storing of transaction rejection reasons.
62-
/// Increase the program size limit to 1024 kB and the transaction size limit to 1280 kB.
62+
/// Increase the program size limit to 2048 kB and the transaction size limit to 2304 kB.
6363
/// Update the deployment storage cost for programs exceeding 512 kB.
6464
V16 = 16,
6565
}

console/network/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub trait Network:
219219
const MAX_PROGRAM_SIZE: [(ConsensusVersion, usize); 3] = [
220220
(ConsensusVersion::V1, 100_000), // 100 kB
221221
(ConsensusVersion::V14, 512_000), // 512 kB
222-
(ConsensusVersion::V16, 1_024_000), // 1024 kB
222+
(ConsensusVersion::V16, 2_048_000), // 2048 kB
223223
];
224224
/// The maximum number of mappings in a program.
225225
const MAX_MAPPINGS: usize = 31;
@@ -269,7 +269,7 @@ pub trait Network:
269269
const MAX_TRANSACTION_SIZE: [(ConsensusVersion, usize); 3] = [
270270
(ConsensusVersion::V1, 128_000), // 128 kB
271271
(ConsensusVersion::V14, 768_000), // 768 kB
272-
(ConsensusVersion::V16, 1_280_000), // 1280 kB
272+
(ConsensusVersion::V16, 2_304_000), // 2304 kB
273273
];
274274

275275
/// The state root type.

synthesizer/process/src/cost.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ function over_five_thousand:
12941294
// Storage cost for an execution transaction at the maximum transaction size.
12951295
const V1_STORAGE_COST_MAX: u64 = 3_276_800;
12961296
const V14_STORAGE_COST_MAX: u64 = 117_964_800;
1297-
const V16_STORAGE_COST_MAX: u64 = 327_680_000;
1297+
const V16_STORAGE_COST_MAX: u64 = 1_061_683_200;
12981298

12991299
fn test_storage_cost_bounds<N: Network>() {
13001300
// Calculate the bounds directly above and below the size threshold.
@@ -1380,9 +1380,9 @@ function over_five_thousand:
13801380
let expected_above =
13811381
above * above * MainnetV0::DEPLOYMENT_FEE_MULTIPLIER / DEPLOYMENT_STORAGE_PENALTY_THRESHOLD;
13821382
assert_eq!(deployment_storage_cost::<MainnetV0>(above).unwrap(), expected_above);
1383-
// At the V16 max program size (1024 kB): cost is exactly 2x the linear cost.
1384-
let max = 1_024_000u64;
1385-
assert_eq!(deployment_storage_cost::<MainnetV0>(max).unwrap(), 2 * max * MainnetV0::DEPLOYMENT_FEE_MULTIPLIER);
1383+
// At the V16 max program size (2048 kB = 4x the threshold): cost is exactly 4x the linear cost.
1384+
let max = 2_048_000u64;
1385+
assert_eq!(deployment_storage_cost::<MainnetV0>(max).unwrap(), 4 * max * MainnetV0::DEPLOYMENT_FEE_MULTIPLIER);
13861386
}
13871387

13881388
#[test]

synthesizer/program/src/parse.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ function compute:
483483
let mut s = String::with_capacity(max_program_size);
484484
for i in 0..n {
485485
s.push_str(&format!("closure c{i}:\n input r0 as u128;\n"));
486-
for j in 0..10 {
487-
s.push_str(&format!(" cast r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 into r{j} as [u128; 32u32];\n"));
486+
for j in 0..30 {
487+
s.push_str(&format!(" cast r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 into r{j} as [u128; 64u32];\n"));
488488
}
489489
s.push_str(&format!(" output r{} as [u128; 32u32];\n", 4000));
490490
}
@@ -496,8 +496,8 @@ function compute:
496496
let mut s = String::with_capacity(max_program_size);
497497
for i in 0..n {
498498
s.push_str(&format!("function f{i}:\n add 1u128 1u128 into r0;\n"));
499-
for j in 0..200 {
500-
s.push_str(&format!(" cast r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 into r{j} as [u128; 32u32];\n"));
499+
for j in 0..250 {
500+
s.push_str(&format!(" cast r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 r0 into r{j} as [u128; 64u32];\n"));
501501
}
502502
}
503503
s

synthesizer/src/vm/tests/test_v16/program_size.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use super::*;
1717

18-
/// Generates a large program string that exceeds the V14 size limit (512KB) but fits within V16 (1024KB).
18+
/// Generates a large program string that exceeds the V14 size limit (512KB) but fits within V16 (2048KB).
1919
fn generate_large_program() -> String {
2020
let mut program = String::from(
2121
"program large_program_generated.aleo;
@@ -27,7 +27,7 @@ constructor:
2727
);
2828

2929
// Add each individual function
30-
for i in 0..5 {
30+
for i in 0..11 {
3131
program.push_str(&format!("function compute_{i}:\n"));
3232
program.push_str(" input r0 as u64.public;\n");
3333

0 commit comments

Comments
 (0)