@@ -497,27 +497,9 @@ impl Batcher {
497497
498498 async fn handle_get_nonce_for_address_msg (
499499 self : Arc < Self > ,
500- mut address : Address ,
500+ address : Address ,
501501 ws_conn_sink : WsMessageSink ,
502502 ) -> Result < ( ) , Error > {
503- if self . is_nonpaying ( & address) {
504- info ! ( "Handling nonpaying message" ) ;
505- let Some ( non_paying_config) = self . non_paying_config . as_ref ( ) else {
506- warn ! (
507- "There isn't a non-paying configuration loaded. This message will be ignored"
508- ) ;
509- send_message (
510- ws_conn_sink. clone ( ) ,
511- GetNonceResponseMessage :: InvalidRequest (
512- "There isn't a non-paying configuration loaded." . to_string ( ) ,
513- ) ,
514- )
515- . await ;
516- return Ok ( ( ) ) ;
517- } ;
518- let replacement_addr = non_paying_config. replacement . address ( ) ;
519- address = replacement_addr;
520- }
521503
522504 let cached_user_nonce = {
523505 let batch_state_lock = self . batch_state . lock ( ) . await ;
@@ -593,8 +575,19 @@ impl Batcher {
593575 return Ok ( ( ) ) ;
594576 } ;
595577
596- let mut nonced_verification_data = client_msg. verification_data . clone ( ) ;
597- let mut signature = client_msg. signature ;
578+ let nonced_verification_data;
579+ let signature;
580+
581+ if self . has_to_pay ( & addr) {
582+ nonced_verification_data = client_msg. verification_data . clone ( ) ;
583+ signature = client_msg. signature ;
584+ } else {
585+ info ! ( "Generating non-paying data" ) ;
586+ let non_paying_data = self . generate_non_paying_data ( & client_msg) . await ;
587+ addr = non_paying_data. address ;
588+ nonced_verification_data = non_paying_data. nonced_verification_data ;
589+ signature = non_paying_data. signature ;
590+ }
598591
599592 // When pre-verification is enabled, batcher will verify proofs for faster feedback with clients
600593 if self . pre_verification_is_enabled {
@@ -636,14 +629,6 @@ impl Batcher {
636629 }
637630 }
638631
639- if self . is_nonpaying ( & addr) && self . non_paying_config . is_some ( ) {
640- info ! ( "Generating non-paying data" ) ;
641- let non_paying_data = self . generate_non_paying_data ( & client_msg) . await ;
642- addr = non_paying_data. address ;
643- nonced_verification_data = non_paying_data. nonced_verification_data ;
644- signature = non_paying_data. signature ;
645- }
646-
647632 info ! ( "Handling message" ) ;
648633
649634 // We don't need a batch state lock here, since if the user locks its funds
@@ -1107,7 +1092,7 @@ impl Batcher {
11071092
11081093 // If the proof submitter is the nonpaying one, we should update the state
11091094 // of the replacement address.
1110- proof_submitter_addr = if self . is_nonpaying ( & proof_submitter_addr) {
1095+ proof_submitter_addr = if self . has_to_pay ( & proof_submitter_addr) {
11111096 self . get_nonpaying_replacement_addr ( )
11121097 . unwrap_or ( proof_submitter_addr)
11131098 } else {
@@ -1746,11 +1731,12 @@ impl Batcher {
17461731 0.0
17471732 }
17481733
1749- /// Only relevant for testing and for users to easily use Aligned
1750- fn is_nonpaying ( & self , addr : & Address ) -> bool {
1734+ /// An address has to pay if it's on mainnet or is not the special designated address on testnet
1735+ fn has_to_pay ( & self , addr : & Address ) -> bool {
1736+ self . non_paying_config . is_none ( ) ||
17511737 self . non_paying_config
17521738 . as_ref ( )
1753- . is_some_and ( |non_paying_config| non_paying_config. address = = * addr)
1739+ . is_some_and ( |non_paying_config| non_paying_config. address ! = * addr)
17541740 }
17551741
17561742 fn get_nonpaying_replacement_addr ( & self ) -> Option < Address > {
0 commit comments