@@ -1198,99 +1198,61 @@ async fn handle_notification(
1198
1198
"New receipt notification detected!"
1199
1199
) ;
1200
1200
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
+
1201
1206
let signer = new_receipt_notification. signer_address ( ) ;
1202
1207
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" ,
1216
1211
) ;
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
+
1235
1213
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
1249
1214
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" ,
1253
1218
) ;
1219
+
1254
1220
// TODO: save the receipt in the failed receipts table?
1255
1221
bail ! (
1256
1222
"No sender address found for receipt signer address {} in {} escrow accounts. \
1257
- The escrow accounts contain {} signer->sender mappings but none match this signer. \
1258
1223
This suggests either: (1) escrow accounts not yet loaded, (2) signer not authorized, or (3) wrong escrow account type (V1 vs V2).",
1259
1224
signer,
1260
- match sender_type {
1261
- SenderType :: Legacy => "V1" ,
1262
- SenderType :: Horizon => "V2" ,
1263
- } ,
1264
- signer_count
1225
+ sender_type_str,
1265
1226
) ;
1266
1227
} ;
1228
+
1267
1229
let allocation_id = new_receipt_notification. allocation_id ( ) ;
1268
1230
let allocation_str = allocation_id. to_hex ( ) ;
1269
1231
match allocation_id {
1270
1232
AllocationId :: Legacy ( _) => {
1271
1233
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" ,
1277
1239
) ;
1278
1240
}
1279
1241
AllocationId :: Horizon ( collection_id) => {
1280
1242
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" ,
1286
1248
) ;
1287
1249
}
1288
1250
}
1251
+
1289
1252
// 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
+
1294
1256
let actor_name = format ! (
1295
1257
"{}{sender_address}:{allocation_for_actor_name}" ,
1296
1258
prefix
@@ -1302,37 +1264,41 @@ async fn handle_notification(
1302
1264
// logs in sender_account.rs:1174
1303
1265
// otherwise there is a mistmatch!!!!
1304
1266
tracing:: debug!(
1305
- "Looking for SenderAllocation actor: '{}' for allocation_id: {} (variant: {:?}, address: {})" ,
1306
1267
actor_name,
1307
- allocation_id,
1268
+ allocation_id=%allocation_id,
1269
+ "Looking for SenderAllocation actor: (variant: {})" ,
1308
1270
match allocation_id {
1309
1271
AllocationId :: Legacy ( _) => "Legacy" ,
1310
1272
AllocationId :: Horizon ( _) => "Horizon" ,
1311
1273
} ,
1312
- allocation_id. address( )
1313
1274
) ;
1275
+
1314
1276
let Some ( sender_allocation) = ActorRef :: < SenderAllocationMessage > :: where_is ( actor_name) else {
1315
1277
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 \
1317
1281
receipt notification. Starting a new sender_allocation.",
1318
- sender_address,
1319
- allocation_id
1320
1282
) ;
1283
+
1284
+ let type_segment = match sender_type {
1285
+ SenderType :: Legacy => "legacy:" ,
1286
+ SenderType :: Horizon => "horizon:" ,
1287
+ } ;
1288
+
1321
1289
let sender_account_name = format ! (
1322
1290
"{}{}{sender_address}" ,
1323
1291
prefix
1324
1292
. as_ref( )
1325
1293
. map_or( String :: default ( ) , |prefix| format!( "{prefix}:" ) ) ,
1326
- match sender_type {
1327
- SenderType :: Legacy => "legacy:" ,
1328
- SenderType :: Horizon => "horizon:" ,
1329
- }
1294
+ type_segment,
1330
1295
) ;
1331
1296
tracing:: debug!(
1332
- "Looking for SenderAccount: name='{}', allocation={}" ,
1333
1297
sender_account_name,
1334
- allocation_id
1298
+ allocation_id=%allocation_id,
1299
+ "Looking for SenderAccount" ,
1335
1300
) ;
1301
+
1336
1302
let Some ( sender_account) = ActorRef :: < SenderAccountMessage > :: where_is ( sender_account_name)
1337
1303
else {
1338
1304
bail ! (
0 commit comments