@@ -35,6 +35,7 @@ use linera_views::{
35
35
views:: { ClonableView , CryptoHashView , RootView , View } ,
36
36
} ;
37
37
use serde:: { Deserialize , Serialize } ;
38
+ use tracing:: instrument;
38
39
39
40
use crate :: {
40
41
block:: { Block , ConfirmedBlock } ,
@@ -309,6 +310,12 @@ pub struct ChainTipState {
309
310
impl ChainTipState {
310
311
/// Checks that the proposed block is suitable, i.e. at the expected height and with the
311
312
/// expected parent.
313
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
314
+ next_block_height = %self . next_block_height,
315
+ block_hash = ?self . block_hash,
316
+ proposed_height = %new_block. height,
317
+ proposed_previous_hash = ?new_block. previous_block_hash
318
+ ) ) ]
312
319
pub fn verify_block_chaining ( & self , new_block : & ProposedBlock ) -> Result < ( ) , ChainError > {
313
320
ensure ! (
314
321
new_block. height == self . next_block_height,
@@ -326,6 +333,10 @@ impl ChainTipState {
326
333
327
334
/// Returns `true` if the validated block's height is below the tip height. Returns an error if
328
335
/// it is higher than the tip.
336
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
337
+ next_block_height = %self . next_block_height,
338
+ height = %height
339
+ ) ) ]
329
340
pub fn already_validated_block ( & self , height : BlockHeight ) -> Result < bool , ChainError > {
330
341
ensure ! (
331
342
self . next_block_height >= height,
@@ -337,6 +348,10 @@ impl ChainTipState {
337
348
}
338
349
339
350
/// Checks if the measurement counters would be valid.
351
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
352
+ next_block_height = %self . next_block_height,
353
+ num_transactions = %transactions. len( )
354
+ ) ) ]
340
355
pub fn update_counters (
341
356
& mut self ,
342
357
transactions : & [ Transaction ] ,
@@ -391,6 +406,10 @@ where
391
406
self . context ( ) . extra ( ) . chain_id ( )
392
407
}
393
408
409
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
410
+ chain_id = %self . chain_id( ) ,
411
+ next_block_height = %self . tip_state. get( ) . next_block_height
412
+ ) ) ]
394
413
pub async fn query_application (
395
414
& mut self ,
396
415
local_time : Timestamp ,
@@ -408,6 +427,10 @@ where
408
427
. with_execution_context ( ChainExecutionContext :: Query )
409
428
}
410
429
430
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
431
+ chain_id = %self . chain_id( ) ,
432
+ application_id = %application_id
433
+ ) ) ]
411
434
pub async fn describe_application (
412
435
& mut self ,
413
436
application_id : ApplicationId ,
@@ -419,6 +442,11 @@ where
419
442
. with_execution_context ( ChainExecutionContext :: DescribeApplication )
420
443
}
421
444
445
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
446
+ chain_id = %self . chain_id( ) ,
447
+ target = %target,
448
+ height = %height
449
+ ) ) ]
422
450
pub async fn mark_messages_as_received (
423
451
& mut self ,
424
452
target : & ChainId ,
@@ -459,6 +487,10 @@ where
459
487
460
488
/// Returns true if there are no more outgoing messages in flight up to the given
461
489
/// block height.
490
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
491
+ chain_id = %self . chain_id( ) ,
492
+ height = %height
493
+ ) ) ]
462
494
pub fn all_messages_delivered_up_to ( & self , height : BlockHeight ) -> bool {
463
495
tracing:: debug!(
464
496
"Messages left in {:.8}'s outbox: {:?}" ,
@@ -478,6 +510,10 @@ where
478
510
}
479
511
480
512
/// Invariant for the states of active chains.
513
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
514
+ chain_id = %self . chain_id( ) ,
515
+ local_time = %local_time
516
+ ) ) ]
481
517
pub async fn ensure_is_active ( & mut self , local_time : Timestamp ) -> Result < ( ) , ChainError > {
482
518
// Initialize ourselves.
483
519
if self
@@ -506,6 +542,9 @@ where
506
542
507
543
/// Verifies that this chain is up-to-date and all the messages executed ahead of time
508
544
/// have been properly received by now.
545
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
546
+ chain_id = %self . chain_id( )
547
+ ) ) ]
509
548
pub async fn validate_incoming_bundles ( & self ) -> Result < ( ) , ChainError > {
510
549
let chain_id = self . chain_id ( ) ;
511
550
let pairs = self . inboxes . try_load_all_entries ( ) . await ?;
@@ -526,6 +565,10 @@ where
526
565
Ok ( ( ) )
527
566
}
528
567
568
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
569
+ chain_id = %self . chain_id( ) ,
570
+ origin = %origin
571
+ ) ) ]
529
572
pub async fn next_block_height_to_receive (
530
573
& self ,
531
574
origin : & ChainId ,
@@ -540,13 +583,21 @@ where
540
583
/// Returns the height of the highest block we have, plus one. Includes preprocessed blocks.
541
584
///
542
585
/// The "+ 1" is so that it can be used in the same places as `next_block_height`.
586
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
587
+ chain_id = %self . chain_id( ) ,
588
+ next_block_height = %self . tip_state. get( ) . next_block_height
589
+ ) ) ]
543
590
pub async fn next_height_to_preprocess ( & self ) -> Result < BlockHeight , ChainError > {
544
591
if let Some ( height) = self . preprocessed_blocks . indices ( ) . await ?. last ( ) {
545
592
return Ok ( height. saturating_add ( BlockHeight ( 1 ) ) ) ;
546
593
}
547
594
Ok ( self . tip_state . get ( ) . next_block_height )
548
595
}
549
596
597
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
598
+ chain_id = %self . chain_id( ) ,
599
+ origin = %origin
600
+ ) ) ]
550
601
pub async fn last_anticipated_block_height (
551
602
& self ,
552
603
origin : & ChainId ,
@@ -567,6 +618,11 @@ where
567
618
/// round timeouts.
568
619
///
569
620
/// Returns `true` if incoming `Subscribe` messages created new outbox entries.
621
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
622
+ chain_id = %self . chain_id( ) ,
623
+ origin = %origin,
624
+ bundle_height = %bundle. height
625
+ ) ) ]
570
626
pub async fn receive_message_bundle (
571
627
& mut self ,
572
628
origin : & ChainId ,
@@ -630,6 +686,10 @@ where
630
686
}
631
687
632
688
/// Updates the `received_log` trackers.
689
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
690
+ chain_id = %self . chain_id( ) ,
691
+ num_trackers = %new_trackers. len( )
692
+ ) ) ]
633
693
pub fn update_received_certificate_trackers (
634
694
& mut self ,
635
695
new_trackers : BTreeMap < ValidatorPublicKey , u64 > ,
@@ -649,6 +709,9 @@ where
649
709
}
650
710
}
651
711
712
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
713
+ chain_id = %self . chain_id( )
714
+ ) ) ]
652
715
pub fn current_committee ( & self ) -> Result < ( Epoch , & Committee ) , ChainError > {
653
716
self . execution_state
654
717
. system
@@ -661,6 +724,10 @@ where
661
724
}
662
725
663
726
/// Removes the incoming message bundles in the block from the inboxes.
727
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
728
+ chain_id = %self . chain_id( ) ,
729
+ timestamp = %timestamp
730
+ ) ) ]
664
731
pub async fn remove_bundles_from_inboxes (
665
732
& mut self ,
666
733
timestamp : Timestamp ,
@@ -739,6 +806,10 @@ where
739
806
}
740
807
741
808
/// Returns the outboxes for the given targets, or an error if any of them are missing.
809
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
810
+ chain_id = %self . chain_id( ) ,
811
+ num_targets = %targets. len( )
812
+ ) ) ]
742
813
pub async fn load_outboxes (
743
814
& self ,
744
815
targets : & [ ChainId ] ,
@@ -750,6 +821,10 @@ where
750
821
751
822
/// Executes a block: first the incoming messages, then the main operation.
752
823
/// Does not update chain state other than the execution state.
824
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
825
+ chain_id = %block. chain_id,
826
+ block_height = %block. height
827
+ ) ) ]
753
828
#[ expect( clippy:: too_many_arguments) ]
754
829
async fn execute_block_inner (
755
830
chain : & mut ExecutionStateView < C > ,
@@ -859,6 +934,10 @@ where
859
934
860
935
/// Executes a block: first the incoming messages, then the main operation.
861
936
/// Does not update chain state other than the execution state.
937
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
938
+ chain_id = %self . chain_id( ) ,
939
+ block_height = %block. height
940
+ ) ) ]
862
941
pub async fn execute_block (
863
942
& mut self ,
864
943
block : & ProposedBlock ,
@@ -919,6 +998,10 @@ where
919
998
/// Applies an execution outcome to the chain, updating the outboxes, state hash and chain
920
999
/// manager. This does not touch the execution state itself, which must be updated separately.
921
1000
/// Returns the set of event streams that were updated as a result of applying the block.
1001
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
1002
+ chain_id = %self . chain_id( ) ,
1003
+ block_height = %block. inner( ) . inner( ) . header. height
1004
+ ) ) ]
922
1005
pub async fn apply_confirmed_block (
923
1006
& mut self ,
924
1007
block : & ConfirmedBlock ,
@@ -953,6 +1036,10 @@ where
953
1036
954
1037
/// Adds a block to `preprocessed_blocks`, and updates the outboxes where possible.
955
1038
/// Returns the set of streams that were updated as a result of preprocessing the block.
1039
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
1040
+ chain_id = %self . chain_id( ) ,
1041
+ block_height = %block. inner( ) . inner( ) . header. height
1042
+ ) ) ]
956
1043
pub async fn preprocess_block (
957
1044
& mut self ,
958
1045
block : & ConfirmedBlock ,
@@ -979,6 +1066,10 @@ where
979
1066
}
980
1067
981
1068
/// Verifies that the block is valid according to the chain's application permission settings.
1069
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
1070
+ block_height = %block. height,
1071
+ num_transactions = %block. transactions. len( )
1072
+ ) ) ]
982
1073
fn check_app_permissions (
983
1074
app_permissions : & ApplicationPermissions ,
984
1075
block : & ProposedBlock ,
@@ -1021,6 +1112,10 @@ where
1021
1112
}
1022
1113
1023
1114
/// Returns the hashes of all blocks we have in the given range.
1115
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
1116
+ chain_id = %self . chain_id( ) ,
1117
+ next_block_height = %self . tip_state. get( ) . next_block_height
1118
+ ) ) ]
1024
1119
pub async fn block_hashes (
1025
1120
& self ,
1026
1121
range : impl RangeBounds < BlockHeight > ,
@@ -1066,6 +1161,10 @@ where
1066
1161
/// Updates the outboxes with the messages sent in the block.
1067
1162
///
1068
1163
/// Returns the set of all recipients.
1164
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
1165
+ chain_id = %self . chain_id( ) ,
1166
+ block_height = %block. header. height
1167
+ ) ) ]
1069
1168
async fn process_outgoing_messages (
1070
1169
& mut self ,
1071
1170
block : & Block ,
@@ -1157,6 +1256,10 @@ where
1157
1256
/// Updates the event streams with events emitted by the block if they form a contiguous
1158
1257
/// sequence (might not be the case when preprocessing a block).
1159
1258
/// Returns the set of updated event streams.
1259
+ #[ instrument( target = "telemetry_only" , skip_all, fields(
1260
+ chain_id = %self . chain_id( ) ,
1261
+ block_height = %block. header. height
1262
+ ) ) ]
1160
1263
async fn process_emitted_events (
1161
1264
& mut self ,
1162
1265
block : & Block ,
0 commit comments