Skip to content

Commit fff41d9

Browse files
committed
cmt + messaging fix
1 parent a51d234 commit fff41d9

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

batcher/aligned-batcher/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,9 @@ impl Batcher {
657657
if self.user_balance_is_unlocked(&addr).await {
658658
send_message(
659659
ws_conn_sink.clone(),
660-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
661660
SubmitProofResponseMessage::InsufficientBalance(
662661
addr,
663-
nonced_verification_data.nonce - 1,
662+
nonced_verification_data.nonce,
664663
),
665664
)
666665
.await;
@@ -753,10 +752,9 @@ impl Batcher {
753752
std::mem::drop(batch_state_lock);
754753
send_message(
755754
ws_conn_sink.clone(),
756-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
757755
SubmitProofResponseMessage::InsufficientBalance(
758756
addr,
759-
nonced_verification_data.nonce - 1,
757+
nonced_verification_data.nonce,
760758
),
761759
)
762760
.await;
@@ -1692,10 +1690,9 @@ impl Batcher {
16921690
error!("Could not get balance for non-paying address {replacement_addr:?}");
16931691
send_message(
16941692
ws_sink.clone(),
1695-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
16961693
SubmitProofResponseMessage::InsufficientBalance(
16971694
replacement_addr,
1698-
client_msg.verification_data.nonce - 1,
1695+
client_msg.verification_data.nonce,
16991696
),
17001697
)
17011698
.await;
@@ -1706,10 +1703,9 @@ impl Batcher {
17061703
error!("Insufficient funds for non-paying address {replacement_addr:?}");
17071704
send_message(
17081705
ws_sink.clone(),
1709-
// last_valid_nonce = client_msg.verification_data.nonce - 1.
17101706
SubmitProofResponseMessage::InsufficientBalance(
17111707
replacement_addr,
1712-
client_msg.verification_data.nonce - 1,
1708+
client_msg.verification_data.nonce,
17131709
),
17141710
)
17151711
.await;

batcher/aligned-sdk/src/communication/messaging.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,15 @@ pub async fn receive(
127127
Ok(data) => data,
128128
Err(e) => {
129129
warn!("Error while handling batcher response: {:?}", e);
130-
if let SubmitError::InsufficientBalance(_, last_valid_nonce) = e {
130+
// When submitting multiple batches a InsufficientBalance error may occur when the `max_balance` of a user within the
131+
// BatcherPaymentService.sol is exceeded. This leads to a scenario where some proofs are verified and others rejected with
132+
// The SubmitError::InsufficientBalance(error_nonce) thrown. To ensure the user is notified of that some of there proofs were rejected
133+
// we return upon erroring the nonce of the proof that has errored (is returned earlier) and set that as the new `last_proof_nonce`.
134+
// This ensures the client messaging protocol continues receivng verification and error responses until all messages are received.
135+
if let SubmitError::InsufficientBalance(_, error_nonce) = e {
131136
aligned_submitted_data.push(Err(e));
137+
138+
let last_valid_nonce = error_nonce - 1;
132139
if last_valid_nonce < last_proof_nonce {
133140
last_proof_nonce = last_valid_nonce;
134141
}

0 commit comments

Comments
 (0)