Skip to content

Commit 085d0db

Browse files
committed
Add new config param
1 parent ec9870a commit 085d0db

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

batcher/aligned-batcher/src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub struct BatcherConfigFromYaml {
4646
pub max_proof_size: usize,
4747
pub max_batch_byte_size: usize,
4848
pub max_batch_proof_qty: usize,
49+
pub max_queue_size: usize,
4950
pub pre_verification_is_enabled: bool,
5051
pub metrics_port: u16,
5152
pub telemetry_ip_port_address: String,

batcher/aligned-batcher/src/lib.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub struct Batcher {
8888
max_proof_size: usize,
8989
max_batch_byte_size: usize,
9090
max_batch_proof_qty: usize,
91+
max_queue_size: usize,
9192
last_uploaded_batch_block: Mutex<u64>,
9293
pre_verification_is_enabled: bool,
9394
non_paying_config: Option<NonPayingConfig>,
@@ -263,6 +264,7 @@ impl Batcher {
263264
max_proof_size: config.batcher.max_proof_size,
264265
max_batch_byte_size: config.batcher.max_batch_byte_size,
265266
max_batch_proof_qty: config.batcher.max_batch_proof_qty,
267+
max_queue_size: config.batcher.max_queue_size,
266268
last_uploaded_batch_block: Mutex::new(last_uploaded_batch_block),
267269
pre_verification_is_enabled: config.batcher.pre_verification_is_enabled,
268270
non_paying_config,
@@ -794,6 +796,23 @@ impl Batcher {
794796
return Ok(());
795797
}
796798

799+
// * ---------------------------------------------------------------------*
800+
// * Perform validation over batcher queue *
801+
// * ---------------------------------------------------------------------*
802+
803+
// if max batch qty exceded, remove least priority element
804+
if batch_state_lock.batch_queue.len() == self.max_queue_size {
805+
info!("Queue limit exceded, removing least priority element");
806+
807+
// if let Some(lowest_priority_entry) = batch_state_lock.batch_queue.pop() {
808+
// send_message(
809+
// lowest_priority_entry.0.messaging_sink.unwrap(),
810+
// SubmitProofResponseMessage::BatchQueueLimitExceededError,
811+
// )
812+
// .await;
813+
// }
814+
}
815+
797816
// * ---------------------------------------------------------------------*
798817
// * Add message data into the queue and update user state *
799818
// * ---------------------------------------------------------------------*
@@ -1028,19 +1047,6 @@ impl Batcher {
10281047
BatchQueueEntryPriority::new(max_fee, nonce),
10291048
);
10301049

1031-
// if max batch qty exceded, remove least priority element
1032-
if batch_state_lock.batch_queue.len() > self.max_batch_proof_qty {
1033-
info!("Queue limit exceded, removing least priority element");
1034-
1035-
if let Some(lowest_priority_entry) = batch_state_lock.batch_queue.pop() {
1036-
send_message(
1037-
lowest_priority_entry.0.messaging_sink.unwrap(),
1038-
SubmitProofResponseMessage::BatchQueueLimitExceededError,
1039-
)
1040-
.await;
1041-
}
1042-
}
1043-
10441050
// Update metrics
10451051
let queue_len = batch_state_lock.batch_queue.len();
10461052
let queue_size_bytes = calculate_batch_size(&batch_state_lock.batch_queue)?;

config-files/config-batcher.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ batcher:
2121
block_interval: 3
2222
batch_size_interval: 10
2323
transaction_wait_timeout: 96000 # 8 blocks
24-
max_proof_size: 67108864 # 64 MiB
24+
max_proof_size: 4194304 # 4 MiB
2525
max_batch_byte_size: 268435456 # 256 MiB
2626
max_batch_proof_qty: 3000 # 3000 proofs in a batch
27+
max_queue_size: 10000
2728
pre_verification_is_enabled: true
2829
metrics_port: 9093
2930
telemetry_ip_port_address: localhost:4001

0 commit comments

Comments
 (0)