1- use ethlambda_types:: { attestation:: SignedAttestation , block:: SignedBlockWithAttestation } ;
1+ use ethlambda_types:: {
2+ ShortRoot , attestation:: SignedAttestation , block:: SignedBlockWithAttestation ,
3+ } ;
24use libp2p:: gossipsub:: Event ;
35use ssz:: { Decode , Encode } ;
46use tracing:: { error, info, trace} ;
7+ use tree_hash:: TreeHash ;
58
69use super :: {
710 encoding:: { compress_message, decompress_message} ,
@@ -32,7 +35,18 @@ pub async fn handle_gossipsub_message(server: &mut P2PServer, event: Event) {
3235 return ;
3336 } ;
3437 let slot = signed_block. message . block . slot ;
35- info ! ( %slot, "Received new block from gossipsub, sending for processing" ) ;
38+ let block_root = signed_block. message . block . tree_hash_root ( ) ;
39+ let proposer = signed_block. message . block . proposer_index ;
40+ let parent_root = signed_block. message . block . parent_root ;
41+ let attestation_count = signed_block. message . block . body . attestations . len ( ) ;
42+ info ! (
43+ %slot,
44+ proposer,
45+ block_root = %ShortRoot ( & block_root. 0 ) ,
46+ parent_root = %ShortRoot ( & parent_root. 0 ) ,
47+ attestation_count,
48+ "Received block from gossip"
49+ ) ;
3650 server. blockchain . notify_new_block ( signed_block) . await ;
3751 }
3852 Some ( ATTESTATION_TOPIC_KIND ) => {
@@ -49,7 +63,16 @@ pub async fn handle_gossipsub_message(server: &mut P2PServer, event: Event) {
4963 } ;
5064 let slot = signed_attestation. message . slot ;
5165 let validator = signed_attestation. validator_id ;
52- info ! ( %slot, %validator, "Received new attestation from gossipsub, sending for processing" ) ;
66+ info ! (
67+ %slot,
68+ validator,
69+ head_root = %ShortRoot ( & signed_attestation. message. head. root. 0 ) ,
70+ target_slot = signed_attestation. message. target. slot,
71+ target_root = %ShortRoot ( & signed_attestation. message. target. root. 0 ) ,
72+ source_slot = signed_attestation. message. source. slot,
73+ source_root = %ShortRoot ( & signed_attestation. message. source. root. 0 ) ,
74+ "Received attestation from gossip"
75+ ) ;
5376 server
5477 . blockchain
5578 . notify_new_attestation ( signed_attestation)
@@ -77,7 +100,15 @@ pub async fn publish_attestation(server: &mut P2PServer, attestation: SignedAtte
77100 . behaviour_mut ( )
78101 . gossipsub
79102 . publish ( server. attestation_topic . clone ( ) , compressed)
80- . inspect ( |_| trace ! ( %slot, %validator, "Published attestation to gossipsub" ) )
103+ . inspect ( |_| info ! (
104+ %slot,
105+ validator,
106+ target_slot = attestation. message. target. slot,
107+ target_root = %ShortRoot ( & attestation. message. target. root. 0 ) ,
108+ source_slot = attestation. message. source. slot,
109+ source_root = %ShortRoot ( & attestation. message. source. root. 0 ) ,
110+ "Published attestation to gossipsub"
111+ ) )
81112 . inspect_err ( |err| {
82113 tracing:: warn!( %slot, %validator, %err, "Failed to publish attestation to gossipsub" )
83114 } ) ;
@@ -86,6 +117,9 @@ pub async fn publish_attestation(server: &mut P2PServer, attestation: SignedAtte
86117pub async fn publish_block ( server : & mut P2PServer , signed_block : SignedBlockWithAttestation ) {
87118 let slot = signed_block. message . block . slot ;
88119 let proposer = signed_block. message . block . proposer_index ;
120+ let block_root = signed_block. message . block . tree_hash_root ( ) ;
121+ let parent_root = signed_block. message . block . parent_root ;
122+ let attestation_count = signed_block. message . block . body . attestations . len ( ) ;
89123
90124 // Encode to SSZ
91125 let ssz_bytes = signed_block. as_ssz_bytes ( ) ;
@@ -99,7 +133,16 @@ pub async fn publish_block(server: &mut P2PServer, signed_block: SignedBlockWith
99133 . behaviour_mut ( )
100134 . gossipsub
101135 . publish ( server. block_topic . clone ( ) , compressed)
102- . inspect ( |_| info ! ( %slot, %proposer, "Published block to gossipsub" ) )
136+ . inspect ( |_| {
137+ info ! (
138+ %slot,
139+ proposer,
140+ block_root = %ShortRoot ( & block_root. 0 ) ,
141+ parent_root = %ShortRoot ( & parent_root. 0 ) ,
142+ attestation_count,
143+ "Published block to gossipsub"
144+ )
145+ } )
103146 . inspect_err (
104147 |err| tracing:: warn!( %slot, %proposer, %err, "Failed to publish block to gossipsub" ) ,
105148 ) ;
0 commit comments