Skip to content

Commit ec32e2c

Browse files
refactor: replace root history capacity with DEFAULT_BATCH_ROOT_HISTORY_LEN constant and set it 200 (#1835)
1 parent 09b69df commit ec32e2c

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

program-libs/batched-merkle-tree/src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub const DEFAULT_BATCH_ADDRESS_TREE_HEIGHT: u32 = 40;
66

77
pub const DEFAULT_BATCH_STATE_TREE_HEIGHT: u32 = 32;
88

9-
pub const DEFAULT_BATCH_STATE_ROOT_HISTORY_LEN: u32 = 20;
9+
pub const DEFAULT_BATCH_ROOT_HISTORY_LEN: u32 = 200;
1010

1111
pub const DEFAULT_NUM_BATCHES: u64 = 2;
1212

program-libs/batched-merkle-tree/src/initialize_address_tree.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use light_merkle_tree_metadata::{
77

88
use crate::{
99
constants::{
10-
DEFAULT_ADDRESS_ZKP_BATCH_SIZE, DEFAULT_BATCH_ADDRESS_TREE_HEIGHT, DEFAULT_BATCH_SIZE,
11-
DEFAULT_ZKP_BATCH_SIZE,
10+
DEFAULT_ADDRESS_ZKP_BATCH_SIZE, DEFAULT_BATCH_ADDRESS_TREE_HEIGHT,
11+
DEFAULT_BATCH_ROOT_HISTORY_LEN, DEFAULT_BATCH_SIZE,
1212
},
1313
errors::BatchedMerkleTreeError,
1414
initialize_state_tree::match_circuit_size,
@@ -43,7 +43,7 @@ impl Default for InitAddressTreeAccountsInstructionData {
4343
input_queue_batch_size: DEFAULT_BATCH_SIZE,
4444
input_queue_zkp_batch_size: DEFAULT_ADDRESS_ZKP_BATCH_SIZE,
4545
height: 40,
46-
root_history_capacity: (DEFAULT_BATCH_SIZE / DEFAULT_ZKP_BATCH_SIZE * 2) as u32,
46+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
4747
bloom_filter_capacity: DEFAULT_BATCH_SIZE * 8,
4848
network_fee: Some(5000),
4949
rollover_threshold: Some(95),
@@ -172,7 +172,8 @@ pub mod test_utils {
172172
pub use super::InitAddressTreeAccountsInstructionData;
173173
use crate::constants::{
174174
ADDRESS_BLOOM_FILTER_CAPACITY, ADDRESS_BLOOM_FILTER_NUM_HASHES,
175-
DEFAULT_ADDRESS_ZKP_BATCH_SIZE, TEST_DEFAULT_BATCH_SIZE, TEST_DEFAULT_ZKP_BATCH_SIZE,
175+
DEFAULT_ADDRESS_ZKP_BATCH_SIZE, DEFAULT_BATCH_ROOT_HISTORY_LEN, TEST_DEFAULT_BATCH_SIZE,
176+
TEST_DEFAULT_ZKP_BATCH_SIZE,
176177
};
177178

178179
impl InitAddressTreeAccountsInstructionData {
@@ -185,7 +186,7 @@ pub mod test_utils {
185186
input_queue_batch_size: TEST_DEFAULT_BATCH_SIZE,
186187
input_queue_zkp_batch_size: TEST_DEFAULT_ZKP_BATCH_SIZE,
187188
height: 40,
188-
root_history_capacity: 20,
189+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
189190
bloom_filter_capacity: 20_000 * 8,
190191
network_fee: Some(5000),
191192
rollover_threshold: Some(95),
@@ -202,7 +203,7 @@ pub mod test_utils {
202203
input_queue_batch_size: 500,
203204
input_queue_zkp_batch_size: TEST_DEFAULT_ZKP_BATCH_SIZE,
204205
height: 40,
205-
root_history_capacity: 20,
206+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
206207
bloom_filter_capacity: 20_000 * 8,
207208
network_fee: Some(5000),
208209
rollover_threshold: Some(95),
@@ -218,7 +219,7 @@ pub mod test_utils {
218219
input_queue_batch_size: 15000,
219220
input_queue_zkp_batch_size: DEFAULT_ADDRESS_ZKP_BATCH_SIZE,
220221
height: 40,
221-
root_history_capacity: 20,
222+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
222223
bloom_filter_capacity: ADDRESS_BLOOM_FILTER_CAPACITY,
223224
network_fee: Some(5000),
224225
rollover_threshold: Some(95),

program-libs/batched-merkle-tree/src/initialize_state_tree.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ pub mod test_utils {
245245
use super::*;
246246
use crate::{
247247
constants::{
248-
STATE_BLOOM_FILTER_CAPACITY, STATE_BLOOM_FILTER_NUM_HASHES, TEST_DEFAULT_BATCH_SIZE,
249-
TEST_DEFAULT_ZKP_BATCH_SIZE,
248+
DEFAULT_BATCH_ROOT_HISTORY_LEN, STATE_BLOOM_FILTER_CAPACITY,
249+
STATE_BLOOM_FILTER_NUM_HASHES, TEST_DEFAULT_BATCH_SIZE, TEST_DEFAULT_ZKP_BATCH_SIZE,
250250
},
251251
queue::{test_utils::assert_queue_inited, BatchedQueueMetadata},
252252
queue_batch_metadata::QueueBatches,
@@ -265,7 +265,7 @@ pub mod test_utils {
265265
input_queue_zkp_batch_size: TEST_DEFAULT_ZKP_BATCH_SIZE,
266266
output_queue_zkp_batch_size: TEST_DEFAULT_ZKP_BATCH_SIZE,
267267
height: DEFAULT_BATCH_STATE_TREE_HEIGHT,
268-
root_history_capacity: 20,
268+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
269269
bloom_filter_capacity: 20_000 * 8,
270270
network_fee: Some(5000),
271271
rollover_threshold: Some(95),
@@ -285,7 +285,7 @@ pub mod test_utils {
285285
input_queue_zkp_batch_size: TEST_DEFAULT_ZKP_BATCH_SIZE,
286286
output_queue_zkp_batch_size: TEST_DEFAULT_ZKP_BATCH_SIZE,
287287
height: DEFAULT_BATCH_STATE_TREE_HEIGHT,
288-
root_history_capacity: 20,
288+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
289289
bloom_filter_capacity: 20_000 * 8,
290290
network_fee: Some(5000),
291291
rollover_threshold: Some(95),
@@ -305,7 +305,7 @@ pub mod test_utils {
305305
input_queue_zkp_batch_size: DEFAULT_ZKP_BATCH_SIZE,
306306
output_queue_zkp_batch_size: DEFAULT_ZKP_BATCH_SIZE,
307307
height: DEFAULT_BATCH_STATE_TREE_HEIGHT,
308-
root_history_capacity: 20,
308+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
309309
bloom_filter_capacity: STATE_BLOOM_FILTER_CAPACITY,
310310
network_fee: Some(5000),
311311
rollover_threshold: Some(95),

program-libs/batched-merkle-tree/src/merkle_tree_metadata.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
99

1010
use crate::{
1111
constants::{
12-
DEFAULT_BATCH_STATE_TREE_HEIGHT, NUM_BATCHES, TEST_DEFAULT_BATCH_SIZE,
13-
TEST_DEFAULT_ZKP_BATCH_SIZE,
12+
DEFAULT_BATCH_ROOT_HISTORY_LEN, DEFAULT_BATCH_STATE_TREE_HEIGHT, NUM_BATCHES,
13+
TEST_DEFAULT_BATCH_SIZE, TEST_DEFAULT_ZKP_BATCH_SIZE,
1414
},
1515
errors::BatchedMerkleTreeError,
1616
initialize_address_tree::InitAddressTreeAccountsInstructionData,
@@ -57,7 +57,7 @@ impl Default for BatchedMerkleTreeMetadata {
5757
sequence_number: 0,
5858
tree_type: TreeType::StateV2 as u64,
5959
height: DEFAULT_BATCH_STATE_TREE_HEIGHT,
60-
root_history_capacity: 20,
60+
root_history_capacity: DEFAULT_BATCH_ROOT_HISTORY_LEN,
6161
capacity: 2u64.pow(DEFAULT_BATCH_STATE_TREE_HEIGHT),
6262
queue_batches: QueueBatches {
6363
currently_processing_batch_index: 0,

sdk-libs/program-test/src/indexer/address_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt::Debug;
22

3-
use light_batched_merkle_tree::constants::DEFAULT_BATCH_STATE_ROOT_HISTORY_LEN;
3+
use light_batched_merkle_tree::constants::DEFAULT_BATCH_ROOT_HISTORY_LEN;
44
use light_client::{
55
fee::FeeConfig,
66
indexer::{AddressMerkleTreeAccounts, IndexerError},
@@ -59,7 +59,7 @@ impl AddressMerkleTreeBundle {
5959
>::new(height, canopy)
6060
.map_err(|_| IndexerError::InvalidResponseData)?;
6161
merkle_tree.merkle_tree.root_history_array_len =
62-
Some(DEFAULT_BATCH_STATE_ROOT_HISTORY_LEN as usize);
62+
Some(DEFAULT_BATCH_ROOT_HISTORY_LEN as usize);
6363
let merkle_tree = IndexedMerkleTreeVersion::V2(Box::new(merkle_tree));
6464

6565
Ok(AddressMerkleTreeBundle {

sdk-libs/program-test/src/indexer/test_indexer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use async_trait::async_trait;
77
use borsh::BorshDeserialize;
88
use light_batched_merkle_tree::{
99
constants::{
10-
DEFAULT_BATCH_ADDRESS_TREE_HEIGHT, DEFAULT_BATCH_STATE_ROOT_HISTORY_LEN,
10+
DEFAULT_BATCH_ADDRESS_TREE_HEIGHT, DEFAULT_BATCH_ROOT_HISTORY_LEN,
1111
DEFAULT_BATCH_STATE_TREE_HEIGHT,
1212
},
1313
merkle_tree::BatchedMerkleTreeAccount,
@@ -1296,7 +1296,7 @@ impl TestIndexer {
12961296
DEFAULT_BATCH_STATE_TREE_HEIGHT as usize,
12971297
0,
12981298
0,
1299-
DEFAULT_BATCH_STATE_ROOT_HISTORY_LEN as usize,
1299+
DEFAULT_BATCH_ROOT_HISTORY_LEN as usize,
13001300
));
13011301
(
13021302
TreeType::StateV2,
@@ -1508,7 +1508,7 @@ impl TestIndexer {
15081508
DEFAULT_BATCH_STATE_TREE_HEIGHT as usize,
15091509
0,
15101510
0,
1511-
DEFAULT_BATCH_STATE_ROOT_HISTORY_LEN as usize,
1511+
DEFAULT_BATCH_ROOT_HISTORY_LEN as usize,
15121512

15131513
));
15141514
(FeeConfig::test_batched().state_merkle_tree_rollover as i64,merkle_tree, Some(params.output_queue_batch_size as usize))

0 commit comments

Comments
 (0)