chore: Improve network tracing messages (#237)
This commit is contained in:
parent
44465369be
commit
70355a687d
4 changed files with 19 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
use pallas_codec::Fragment;
|
use pallas_codec::Fragment;
|
||||||
use pallas_multiplexer::agents::{Channel, ChannelBuffer, ChannelError};
|
use pallas_multiplexer::agents::{Channel, ChannelBuffer, ChannelError};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
use tracing::{debug, info, warn};
|
||||||
|
|
||||||
use crate::common::Point;
|
use crate::common::Point;
|
||||||
|
|
||||||
|
|
@ -125,10 +126,12 @@ where
|
||||||
pub fn recv_while_busy(&mut self) -> Result<HasBlocks, Error> {
|
pub fn recv_while_busy(&mut self) -> Result<HasBlocks, Error> {
|
||||||
match self.recv_message()? {
|
match self.recv_message()? {
|
||||||
Message::StartBatch => {
|
Message::StartBatch => {
|
||||||
|
info!("batch start");
|
||||||
self.0 = State::Streaming;
|
self.0 = State::Streaming;
|
||||||
Ok(Some(()))
|
Ok(Some(()))
|
||||||
}
|
}
|
||||||
Message::NoBlocks => {
|
Message::NoBlocks => {
|
||||||
|
warn!("no blocks");
|
||||||
self.0 = State::Idle;
|
self.0 = State::Idle;
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
@ -138,6 +141,7 @@ where
|
||||||
|
|
||||||
pub fn request_range(&mut self, range: Range) -> Result<HasBlocks, Error> {
|
pub fn request_range(&mut self, range: Range) -> Result<HasBlocks, Error> {
|
||||||
self.send_request_range(range)?;
|
self.send_request_range(range)?;
|
||||||
|
debug!("range requested");
|
||||||
self.recv_while_busy()
|
self.recv_while_busy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,6 +161,7 @@ where
|
||||||
.ok_or(Error::NoBlocks)?;
|
.ok_or(Error::NoBlocks)?;
|
||||||
|
|
||||||
let body = self.recv_while_streaming()?.ok_or(Error::InvalidInbound)?;
|
let body = self.recv_while_streaming()?.ok_or(Error::InvalidInbound)?;
|
||||||
|
debug!("body received");
|
||||||
|
|
||||||
match self.recv_while_streaming()? {
|
match self.recv_while_streaming()? {
|
||||||
Some(_) => Err(Error::InvalidInbound),
|
Some(_) => Err(Error::InvalidInbound),
|
||||||
|
|
@ -170,6 +175,7 @@ where
|
||||||
let mut all = vec![];
|
let mut all = vec![];
|
||||||
|
|
||||||
while let Some(block) = self.recv_while_streaming()? {
|
while let Some(block) = self.recv_while_streaming()? {
|
||||||
|
debug!("body received");
|
||||||
all.push(block);
|
all.push(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
|
||||||
pub fn find_intersect(&mut self, points: Vec<Point>) -> Result<IntersectResponse, Error> {
|
pub fn find_intersect(&mut self, points: Vec<Point>) -> Result<IntersectResponse, Error> {
|
||||||
self.send_find_intersect(points)?;
|
self.send_find_intersect(points)?;
|
||||||
self.recv_intersect_response()
|
self.recv_intersect_response()
|
||||||
|
|
@ -195,7 +194,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
|
||||||
pub fn request_next(&mut self) -> Result<NextResponse<O>, Error> {
|
pub fn request_next(&mut self) -> Result<NextResponse<O>, Error> {
|
||||||
debug!("requesting next block");
|
debug!("requesting next block");
|
||||||
|
|
||||||
|
|
@ -212,7 +210,6 @@ where
|
||||||
point.ok_or(Error::IntersectionNotFound)
|
point.ok_or(Error::IntersectionNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip_all)]
|
|
||||||
pub fn intersect_tip(&mut self) -> Result<Point, Error> {
|
pub fn intersect_tip(&mut self) -> Result<Point, Error> {
|
||||||
let (_, Tip(point, _)) = self.find_intersect(vec![Point::Origin])?;
|
let (_, Tip(point, _)) = self.find_intersect(vec![Point::Origin])?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use gasket::messaging::SendAdapter;
|
use gasket::messaging::SendAdapter;
|
||||||
use tracing::{debug, error, instrument};
|
use tracing::{error, info, instrument};
|
||||||
|
|
||||||
use pallas_crypto::hash::Hash;
|
use pallas_crypto::hash::Hash;
|
||||||
use pallas_miniprotocols::blockfetch;
|
use pallas_miniprotocols::blockfetch;
|
||||||
|
|
@ -39,14 +39,16 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(self))]
|
#[instrument(skip(self), fields(slot, %hash))]
|
||||||
fn fetch_block(&mut self, slot: u64, hash: Hash<32>) -> Result<Vec<u8>, gasket::error::Error> {
|
fn fetch_block(&mut self, slot: u64, hash: Hash<32>) -> Result<Vec<u8>, gasket::error::Error> {
|
||||||
|
info!("fetching block");
|
||||||
|
|
||||||
match self
|
match self
|
||||||
.client
|
.client
|
||||||
.fetch_single(Point::Specific(slot, hash.to_vec()))
|
.fetch_single(Point::Specific(slot, hash.to_vec()))
|
||||||
{
|
{
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
debug!("block fetch succeded");
|
info!("block fetch succeeded");
|
||||||
Ok(x)
|
Ok(x)
|
||||||
}
|
}
|
||||||
Err(blockfetch::Error::ChannelError(x)) => {
|
Err(blockfetch::Error::ChannelError(x)) => {
|
||||||
|
|
@ -77,6 +79,7 @@ where
|
||||||
let msg = match msg.payload {
|
let msg = match msg.payload {
|
||||||
ChainSyncEvent::RollForward(s, h) => {
|
ChainSyncEvent::RollForward(s, h) => {
|
||||||
let body = self.fetch_block(s, h)?;
|
let body = self.fetch_block(s, h)?;
|
||||||
|
self.block_count.inc(1);
|
||||||
BlockFetchEvent::RollForward(s, h, body)
|
BlockFetchEvent::RollForward(s, h, body)
|
||||||
}
|
}
|
||||||
ChainSyncEvent::Rollback(x) => BlockFetchEvent::Rollback(x),
|
ChainSyncEvent::Rollback(x) => BlockFetchEvent::Rollback(x),
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ pub struct Worker {
|
||||||
channel3_out: Option<DemuxOutputPort>,
|
channel3_out: Option<DemuxOutputPort>,
|
||||||
demuxer: Option<Demuxer<GasketEgress>>,
|
demuxer: Option<Demuxer<GasketEgress>>,
|
||||||
muxer: Option<Muxer<GasketIngress>>,
|
muxer: Option<Muxer<GasketIngress>>,
|
||||||
|
ops_count: gasket::metrics::Counter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Worker {
|
impl Worker {
|
||||||
|
|
@ -110,6 +111,7 @@ impl Worker {
|
||||||
channel3_out,
|
channel3_out,
|
||||||
demuxer: None,
|
demuxer: None,
|
||||||
muxer: None,
|
muxer: None,
|
||||||
|
ops_count: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,7 +143,9 @@ impl Worker {
|
||||||
impl gasket::runtime::Worker for Worker {
|
impl gasket::runtime::Worker for Worker {
|
||||||
fn metrics(&self) -> gasket::metrics::Registry {
|
fn metrics(&self) -> gasket::metrics::Registry {
|
||||||
// TODO: define networking metrics (bytes in / out, etc)
|
// TODO: define networking metrics (bytes in / out, etc)
|
||||||
gasket::metrics::Builder::new().build()
|
gasket::metrics::Builder::new()
|
||||||
|
.with_counter("ops_count", &self.ops_count)
|
||||||
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bootstrap(&mut self) -> Result<(), gasket::error::Error> {
|
fn bootstrap(&mut self) -> Result<(), gasket::error::Error> {
|
||||||
|
|
@ -196,6 +200,8 @@ impl gasket::runtime::Worker for Worker {
|
||||||
mux_res.unwrap()?;
|
mux_res.unwrap()?;
|
||||||
demux_res.unwrap()?;
|
demux_res.unwrap()?;
|
||||||
|
|
||||||
|
self.ops_count.inc(1);
|
||||||
|
|
||||||
Ok(gasket::runtime::WorkOutcome::Partial)
|
Ok(gasket::runtime::WorkOutcome::Partial)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue