@@ -399,6 +399,7 @@ impl Batcher {
399399 Ok ( msg) => msg,
400400 Err ( e) => {
401401 warn ! ( "Failed to deserialize message: {}" , e) ;
402+ self . metrics . user_error ( & [ "deserialize_error" , "" ] ) ;
402403 return Ok ( ( ) ) ;
403404 }
404405 } ;
@@ -419,7 +420,7 @@ impl Batcher {
419420 ValidityResponseMessage :: InvalidChainId ,
420421 )
421422 . await ;
422-
423+ self . metrics . user_error ( & [ "invalid_chain_id" , "" ] ) ;
423424 return Ok ( ( ) ) ;
424425 }
425426
@@ -435,7 +436,8 @@ impl Batcher {
435436 ) ,
436437 )
437438 . await ;
438-
439+ self . metrics
440+ . user_error ( & [ "invalid_paument_service_address" , "" ] ) ;
439441 return Ok ( ( ) ) ;
440442 }
441443
@@ -447,6 +449,7 @@ impl Batcher {
447449 ValidityResponseMessage :: InvalidSignature ,
448450 )
449451 . await ;
452+ self . metrics . user_error ( & [ "invalid_signature" , "" ] ) ;
450453 return Ok ( ( ) ) ;
451454 } ;
452455 info ! ( "Message signature verified" ) ;
@@ -455,6 +458,7 @@ impl Batcher {
455458 if proof_size > self . max_proof_size {
456459 error ! ( "Proof size exceeds the maximum allowed size." ) ;
457460 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: ProofTooLarge ) . await ;
461+ self . metrics . user_error ( & [ "proof_too_large" , "" ] ) ;
458462 return Ok ( ( ) ) ;
459463 }
460464
@@ -478,6 +482,10 @@ impl Batcher {
478482 ) ) ,
479483 )
480484 . await ;
485+ self . metrics . user_error ( & [
486+ "disabled_verifier" ,
487+ & format ! ( "{}" , verification_data. proving_system) ,
488+ ] ) ;
481489 return Ok ( ( ) ) ;
482490 }
483491
@@ -488,6 +496,10 @@ impl Batcher {
488496 ValidityResponseMessage :: InvalidProof ( ProofInvalidReason :: RejectedProof ) ,
489497 )
490498 . await ;
499+ self . metrics . user_error ( & [
500+ "rejected_proof" ,
501+ & format ! ( "{}" , verification_data. proving_system) ,
502+ ] ) ;
491503 return Ok ( ( ) ) ;
492504 }
493505 }
@@ -509,6 +521,7 @@ impl Batcher {
509521 ValidityResponseMessage :: InsufficientBalance ( addr) ,
510522 )
511523 . await ;
524+ self . metrics . user_error ( & [ "insufficient_balance" , "" ] ) ;
512525 return Ok ( ( ) ) ;
513526 }
514527
@@ -530,6 +543,7 @@ impl Batcher {
530543 "Failed to get user nonce from Ethereum for address {addr:?}. Error: {e:?}"
531544 ) ;
532545 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: InvalidNonce ) . await ;
546+ self . metrics . user_error ( & [ "invalid_nonce" , "" ] ) ;
533547 return Ok ( ( ) ) ;
534548 }
535549 } ;
@@ -548,6 +562,7 @@ impl Batcher {
548562 let Some ( user_balance) = self . get_user_balance ( & addr) . await else {
549563 error ! ( "Could not get balance for address {addr:?}" ) ;
550564 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: EthRpcError ) . await ;
565+ self . metrics . user_error ( & [ "eth_rpc_error" , "" ] ) ;
551566 return Ok ( ( ) ) ;
552567 } ;
553568
@@ -560,6 +575,7 @@ impl Batcher {
560575 error ! ( "Failed to get user proof count: User not found in user states, but it should have been already inserted" ) ;
561576 std:: mem:: drop ( batch_state_lock) ;
562577 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: InvalidNonce ) . await ;
578+ self . metrics . user_error ( & [ "invalid_nonce" , "" ] ) ;
563579 return Ok ( ( ) ) ;
564580 } ;
565581
@@ -570,6 +586,7 @@ impl Batcher {
570586 ValidityResponseMessage :: InsufficientBalance ( addr) ,
571587 )
572588 . await ;
589+ self . metrics . user_error ( & [ "insufficient_balance" , "" ] ) ;
573590 return Ok ( ( ) ) ;
574591 }
575592
@@ -578,13 +595,15 @@ impl Batcher {
578595 error ! ( "Failed to get cached user nonce: User not found in user states, but it should have been already inserted" ) ;
579596 std:: mem:: drop ( batch_state_lock) ;
580597 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: InvalidNonce ) . await ;
598+ self . metrics . user_error ( & [ "invalid_nonce" , "" ] ) ;
581599 return Ok ( ( ) ) ;
582600 } ;
583601
584602 if expected_nonce < msg_nonce {
585603 std:: mem:: drop ( batch_state_lock) ;
586604 warn ! ( "Invalid nonce for address {addr}, had nonce {expected_nonce:?} < {msg_nonce:?}" ) ;
587605 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: InvalidNonce ) . await ;
606+ self . metrics . user_error ( & [ "invalid_nonce" , "" ] ) ;
588607 return Ok ( ( ) ) ;
589608 }
590609
@@ -608,13 +627,15 @@ impl Batcher {
608627 let Some ( user_min_fee) = batch_state_lock. get_user_min_fee ( & addr) . await else {
609628 std:: mem:: drop ( batch_state_lock) ;
610629 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: InvalidNonce ) . await ;
630+ self . metrics . user_error ( & [ "invalid_nonce" , "" ] ) ;
611631 return Ok ( ( ) ) ;
612632 } ;
613633
614634 if msg_max_fee > user_min_fee {
615635 std:: mem:: drop ( batch_state_lock) ;
616636 warn ! ( "Invalid max fee for address {addr}, had fee {user_min_fee:?} < {msg_max_fee:?}" ) ;
617637 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: InvalidMaxFee ) . await ;
638+ self . metrics . user_error ( & [ "invalid_max_fee" , "" ] ) ;
618639 return Ok ( ( ) ) ;
619640 }
620641
@@ -634,6 +655,7 @@ impl Batcher {
634655 {
635656 error ! ( "Error while adding entry to batch: {e:?}" ) ;
636657 send_message ( ws_conn_sink, ValidityResponseMessage :: AddToBatchError ) . await ;
658+ self . metrics . user_error ( & [ "add_to_batch_error" , "" ] ) ;
637659 return Ok ( ( ) ) ;
638660 } ;
639661
@@ -674,6 +696,7 @@ impl Batcher {
674696 std:: mem:: drop ( batch_state_lock) ;
675697 warn ! ( "Invalid nonce for address {addr}. Queue entry with nonce {nonce} not found" ) ;
676698 send_message ( ws_conn_sink. clone ( ) , ValidityResponseMessage :: InvalidNonce ) . await ;
699+ self . metrics . user_error ( & [ "invalid_nonce" , "" ] ) ;
677700 return ;
678701 } ;
679702
@@ -686,7 +709,8 @@ impl Batcher {
686709 ValidityResponseMessage :: InvalidReplacementMessage ,
687710 )
688711 . await ;
689-
712+ self . metrics
713+ . user_error ( & [ "invalid_replacement_message" , "" ] ) ;
690714 return ;
691715 }
692716
@@ -723,6 +747,8 @@ impl Batcher {
723747 ValidityResponseMessage :: InvalidReplacementMessage ,
724748 )
725749 . await ;
750+ self . metrics
751+ . user_error ( & [ "invalid_replacement_message" , "" ] ) ;
726752 return ;
727753 }
728754
0 commit comments