@@ -1198,99 +1198,61 @@ async fn handle_notification(
11981198 "New receipt notification detected!"
11991199 ) ;
12001200 let escrow_accounts = escrow_accounts_rx. borrow ( ) ;
1201+ let sender_type_str = match sender_type {
1202+ SenderType :: Legacy => "V1" ,
1203+ SenderType :: Horizon => "V2" ,
1204+ } ;
1205+
12011206 let signer = new_receipt_notification. signer_address ( ) ;
12021207 tracing:: debug!(
1203- "Looking up sender for signer: {} in {} escrow accounts (sender_type: {:?})" ,
1204- signer,
1205- match sender_type {
1206- SenderType :: Legacy => "V1" ,
1207- SenderType :: Horizon => "V2" ,
1208- } ,
1209- sender_type
1210- ) ;
1211- // Log current escrow account state for debugging
1212- let signer_count = escrow_accounts. signer_count ( ) ;
1213- tracing:: debug!(
1214- "Current escrow accounts contain {} signer->sender mappings" ,
1215- signer_count
1208+ sender_type_str,
1209+ signer = ?signer,
1210+ "Looking up sender for signer in escrow accounts" ,
12161211 ) ;
1217- // Log first few mappings for debugging (but don't spam if there are many)
1218- let mappings_to_show = 5 . min ( signer_count) ;
1219- for ( i, ( existing_signer, existing_sender) ) in
1220- escrow_accounts. iter_signers_to_senders ( ) . enumerate ( )
1221- {
1222- if i >= mappings_to_show {
1223- break ;
1224- }
1225- tracing:: debug!(
1226- "Escrow mapping {}: signer {} -> sender {}" ,
1227- i + 1 ,
1228- existing_signer,
1229- existing_sender
1230- ) ;
1231- }
1232- if signer_count > mappings_to_show {
1233- tracing:: debug!( "... and {} more mappings" , signer_count - mappings_to_show) ;
1234- }
1212+
12351213 let Ok ( sender_address) = escrow_accounts. get_sender_for_signer ( & signer) else {
1236- // Enhanced error with detailed debugging information
1237- tracing:: error!(
1238- "ESCROW LOOKUP FAILURE: No sender found for signer {} in {} escrow accounts containing {} mappings" ,
1239- signer,
1240- match sender_type {
1241- SenderType :: Legacy => "V1" ,
1242- SenderType :: Horizon => "V2" ,
1243- } ,
1244- signer_count
1245- ) ;
1246- // Check if the signer exists in a different case format (shouldn't happen with Address types, but let's verify)
1247- let signer_lower = format ! ( "{:x}" , signer) . to_lowercase ( ) ;
1248- let signer_mixed = format ! ( "{:x?}" , signer) ; // This should match the display format
12491214 tracing:: error!(
1250- "Signer formats: lowercase={}, mixed_case={}" ,
1251- signer_lower ,
1252- signer_mixed
1215+ signer=?signer ,
1216+ sender_type_str ,
1217+ "ESCROW LOOKUP FAILURE: No sender found for signer in escrow accounts" ,
12531218 ) ;
1219+
12541220 // TODO: save the receipt in the failed receipts table?
12551221 bail ! (
12561222 "No sender address found for receipt signer address {} in {} escrow accounts. \
1257- The escrow accounts contain {} signer->sender mappings but none match this signer. \
12581223 This suggests either: (1) escrow accounts not yet loaded, (2) signer not authorized, or (3) wrong escrow account type (V1 vs V2).",
12591224 signer,
1260- match sender_type {
1261- SenderType :: Legacy => "V1" ,
1262- SenderType :: Horizon => "V2" ,
1263- } ,
1264- signer_count
1225+ sender_type_str,
12651226 ) ;
12661227 } ;
1228+
12671229 let allocation_id = new_receipt_notification. allocation_id ( ) ;
12681230 let allocation_str = allocation_id. to_hex ( ) ;
12691231 match allocation_id {
12701232 AllocationId :: Legacy ( _) => {
12711233 tracing:: info!(
1272- "Processing receipt notification: sender={}, allocation_id={}, sender_type={:?}, value={}" ,
1273- sender_address ,
1274- allocation_id ,
1275- sender_type ,
1276- new_receipt_notification . value ( )
1234+ sender_address=%sender_address ,
1235+ allocation_id=allocation_str ,
1236+ sender_type_str ,
1237+ receipt_value=%new_receipt_notification . value ( ) ,
1238+ "Processing receipt notification" ,
12771239 ) ;
12781240 }
12791241 AllocationId :: Horizon ( collection_id) => {
12801242 tracing:: info!(
1281- "Processing receipt notification: sender={}, collection_id={}, sender_type={:?}, value={}" ,
1282- sender_address ,
1283- collection_id ,
1284- sender_type ,
1285- new_receipt_notification . value ( )
1243+ sender_address=%sender_address ,
1244+ collection_id=%collection_id ,
1245+ sender_type_str ,
1246+ receipt_value=%new_receipt_notification . value ( ) ,
1247+ "Processing receipt notification: sender" ,
12861248 ) ;
12871249 }
12881250 }
1251+
12891252 // For actor lookup, use the address format that matches how actors are created
1290- let allocation_for_actor_name = match & allocation_id {
1291- AllocationId :: Legacy ( id) => id. to_string ( ) ,
1292- AllocationId :: Horizon ( collection_id) => collection_id. as_address ( ) . to_string ( ) ,
1293- } ;
1253+ // "0x...."
1254+ let allocation_for_actor_name = allocation_id. address ( ) . to_string ( ) ;
1255+
12941256 let actor_name = format ! (
12951257 "{}{sender_address}:{allocation_for_actor_name}" ,
12961258 prefix
@@ -1302,37 +1264,41 @@ async fn handle_notification(
13021264 // logs in sender_account.rs:1174
13031265 // otherwise there is a mistmatch!!!!
13041266 tracing:: debug!(
1305- "Looking for SenderAllocation actor: '{}' for allocation_id: {} (variant: {:?}, address: {})" ,
13061267 actor_name,
1307- allocation_id,
1268+ allocation_id=%allocation_id,
1269+ "Looking for SenderAllocation actor: (variant: {})" ,
13081270 match allocation_id {
13091271 AllocationId :: Legacy ( _) => "Legacy" ,
13101272 AllocationId :: Horizon ( _) => "Horizon" ,
13111273 } ,
1312- allocation_id. address( )
13131274 ) ;
1275+
13141276 let Some ( sender_allocation) = ActorRef :: < SenderAllocationMessage > :: where_is ( actor_name) else {
13151277 tracing:: warn!(
1316- "No sender_allocation found for sender_address {}, allocation_id {} to process new \
1278+ sender_address=%sender_address,
1279+ allocation_id=%allocation_id,
1280+ "No sender_allocation found for sender_address and allocation_id to process new \
13171281 receipt notification. Starting a new sender_allocation.",
1318- sender_address,
1319- allocation_id
13201282 ) ;
1283+
1284+ let type_segment = match sender_type {
1285+ SenderType :: Legacy => "legacy:" ,
1286+ SenderType :: Horizon => "horizon:" ,
1287+ } ;
1288+
13211289 let sender_account_name = format ! (
13221290 "{}{}{sender_address}" ,
13231291 prefix
13241292 . as_ref( )
13251293 . map_or( String :: default ( ) , |prefix| format!( "{prefix}:" ) ) ,
1326- match sender_type {
1327- SenderType :: Legacy => "legacy:" ,
1328- SenderType :: Horizon => "horizon:" ,
1329- }
1294+ type_segment,
13301295 ) ;
13311296 tracing:: debug!(
1332- "Looking for SenderAccount: name='{}', allocation={}" ,
13331297 sender_account_name,
1334- allocation_id
1298+ allocation_id=%allocation_id,
1299+ "Looking for SenderAccount" ,
13351300 ) ;
1301+
13361302 let Some ( sender_account) = ActorRef :: < SenderAccountMessage > :: where_is ( sender_account_name)
13371303 else {
13381304 bail ! (
0 commit comments