Add debug log when gossip block recieved (#1026)

* Add debug! log for processing gossip block

* Fix stray dbg! command
This commit is contained in:
Paul Hauner 2020-04-20 16:16:42 +10:00 committed by GitHub
parent 49c77fe74b
commit 2d3acadfb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 2 deletions

View File

@ -1445,7 +1445,34 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self,
block: SignedBeaconBlock<T::EthSpec>,
) -> Result<GossipVerifiedBlock<T>, BlockError> {
GossipVerifiedBlock::new(block, self)
let slot = block.message.slot;
let graffiti_string = String::from_utf8(block.message.body.graffiti[..].to_vec())
.unwrap_or_else(|_| format!("{:?}", &block.message.body.graffiti[..]));
match GossipVerifiedBlock::new(block, self) {
Ok(verified) => {
debug!(
self.log,
"Successfully processed gossip block";
"graffiti" => graffiti_string,
"slot" => slot,
"root" => format!("{:?}", verified.block_root()),
);
Ok(verified)
}
Err(e) => {
debug!(
self.log,
"Rejected gossip block";
"error" => format!("{:?}", e),
"graffiti" => graffiti_string,
"slot" => slot,
);
Err(e)
}
}
}
/// Returns `Ok(block_root)` if the given `unverified_block` was successfully verified and

View File

@ -304,6 +304,10 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
Err(BlockError::ProposalSignatureInvalid)
}
}
pub fn block_root(&self) -> Hash256 {
self.block_root
}
}
impl<T: BeaconChainTypes> IntoFullyVerifiedBlock<T> for GossipVerifiedBlock<T> {

View File

@ -112,7 +112,6 @@ pub fn get_config<E: EthSpec>(
.map_err(|_| format!("Invalid port: {}", port_str))?;
client_config.network.libp2p_port = port;
client_config.network.discovery_port = port;
dbg!(&client_config.network.discovery_port);
}
if let Some(port_str) = cli_args.value_of("discovery-port") {