Skip to content
Merged
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5e21e62
Change user_last_max_fee validation
Mechanix97 Apr 16, 2025
9bc03de
verify batch limits
Mechanix97 Apr 16, 2025
27f46a9
Add try_push mock
Mechanix97 Apr 16, 2025
3dbf64a
fix warnings
Mechanix97 Apr 16, 2025
0bb312c
Change try_push_to_queue logic
Mechanix97 Apr 16, 2025
50b225b
Add remove from q logic
Mechanix97 Apr 16, 2025
72cfeb2
cargo fmt
Mechanix97 Apr 16, 2025
b037de8
add errors
Mechanix97 Apr 16, 2025
c02e861
Use DoublePriorityQueue
Mechanix97 Apr 21, 2025
d4b0c86
Fix queue len
Mechanix97 Apr 21, 2025
2d5ab6a
cargo fmt
Mechanix97 Apr 21, 2025
e8654bd
Fix format
Mechanix97 Apr 21, 2025
d500e2c
Remove unused error
Mechanix97 Apr 21, 2025
c311cd0
Modify len
Mechanix97 Apr 21, 2025
8ef8f50
Remove double q
Mechanix97 Apr 21, 2025
93209db
Merge remote-tracking branch 'origin/staging' into feat/batch_queue_l…
Mechanix97 Apr 21, 2025
31ee142
Add new error type
Mechanix97 Apr 22, 2025
e23efc7
Merge remote-tracking branch 'origin/staging' into feat/batch_queue_l…
Mechanix97 Apr 22, 2025
b389750
remove sub
Mechanix97 Apr 22, 2025
ec9870a
cargo fmt
Mechanix97 Apr 22, 2025
085d0db
Add new config param
Mechanix97 Apr 22, 2025
206098b
Add validation and update user_state
Mechanix97 Apr 22, 2025
86b2548
remove warning
Mechanix97 Apr 22, 2025
e3aac58
Add verification to non-payers
Mechanix97 Apr 22, 2025
eef1a05
fix spelling
Mechanix97 Apr 22, 2025
5695a7a
change max_proof_size to 4 MiB
Mechanix97 Apr 22, 2025
aead1d8
refactor: drop batch lock early and more readable code
MarcosNicolau Apr 28, 2025
7b92058
chore: address clippy warnings
MarcosNicolau Apr 28, 2025
c4c864b
refactor: entry removal
MarcosNicolau Apr 28, 2025
8fc52d5
chore: address clippy warnings
MarcosNicolau Apr 28, 2025
eeb557d
refactor: compare with Ordering
MarcosNicolau Apr 28, 2025
f89d7c4
fix: last_max_fee_limit
JuArce May 9, 2025
2f8df91
Simplify functions
MauroToscano May 9, 2025
23a941a
Fix conflicts
MauroToscano May 9, 2025
0e918af
Fix compile
MauroToscano May 9, 2025
cc7cc05
Add comments
MauroToscano May 9, 2025
1a706b2
fix: cargo fmt
JuArce May 9, 2025
29e87b3
fix: undo msg_max_fee > user_last_max_fee_limit changes
JuArce May 9, 2025
656243f
fix: cargo fmt
JuArce May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,18 @@ impl Batcher {
return Ok(());
};

if msg_max_fee > user_last_max_fee_limit {
std::mem::drop(batch_state_lock);
warn!("Invalid max fee for address {addr}, had fee limit of {user_last_max_fee_limit:?}, sent {msg_max_fee:?}");
send_message(
ws_conn_sink.clone(),
SubmitProofResponseMessage::InvalidMaxFee,
)
.await;
self.metrics.user_error(&["invalid_max_fee", ""]);
return Ok(());
}

let Some(user_accumulated_fee) = batch_state_lock.get_user_total_fees_in_queue(&addr).await
else {
std::mem::drop(batch_state_lock);
Expand Down Expand Up @@ -782,18 +794,6 @@ impl Batcher {
return Ok(());
}

if msg_max_fee > user_last_max_fee_limit {
std::mem::drop(batch_state_lock);
warn!("Invalid max fee for address {addr}, had fee limit of {user_last_max_fee_limit:?}, sent {msg_max_fee:?}");
send_message(
ws_conn_sink.clone(),
SubmitProofResponseMessage::InvalidMaxFee,
)
.await;
self.metrics.user_error(&["invalid_max_fee", ""]);
return Ok(());
}

// * ---------------------------------------------------------------------*
// * Add message data into the queue and update user state *
// * ---------------------------------------------------------------------*
Expand Down Expand Up @@ -1028,6 +1028,19 @@ impl Batcher {
BatchQueueEntryPriority::new(max_fee, nonce),
);

// if max batch qty exceded, remove least priority element
if batch_state_lock.batch_queue.len() > self.max_batch_proof_qty {
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
info!("Queue limit exceded, removing least priority element");

if let Some(lowest_priority_entry) = batch_state_lock.batch_queue.pop() {
send_message(
lowest_priority_entry.0.messaging_sink.unwrap(),
SubmitProofResponseMessage::AddToBatchError,
Comment thread
Mechanix97 marked this conversation as resolved.
Outdated
)
.await;
}
}

// Update metrics
let queue_len = batch_state_lock.batch_queue.len();
let queue_size_bytes = calculate_batch_size(&batch_state_lock.batch_queue)?;
Expand Down
Loading