Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/bin/pcli/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl App {
println!("broadcasting transaction and awaiting confirmation...");
let mut rsp = self.view().broadcast_transaction(transaction, true).await?;

let id = (async move {
let id = async move {
while let Some(rsp) = rsp.try_next().await? {
match rsp.status {
Some(status) => match status {
Expand Down Expand Up @@ -140,7 +140,7 @@ impl App {
"should have received BroadcastTransaction status or error"
))
}
.boxed())
.boxed()
.await
.context("error broadcasting transaction")?;

Expand Down
50 changes: 32 additions & 18 deletions crates/view/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use penumbra_num::Amount;
use penumbra_proto::{
util::tendermint_proxy::v1::{
tendermint_proxy_service_client::TendermintProxyServiceClient, BroadcastTxSyncRequest,
GetStatusRequest,
GetStatusRequest, GetStatusResponse, SyncInfo,
},
view::v1::{
self as pb,
Expand Down Expand Up @@ -282,12 +282,15 @@ impl ViewServer {
}.boxed()
}

#[instrument(level = "trace", skip(self))]
async fn tendermint_proxy_client(
&self,
) -> anyhow::Result<TendermintProxyServiceClient<Channel>> {
let client = TendermintProxyServiceClient::connect(self.node.to_string()).await?;

Ok(client)
TendermintProxyServiceClient::connect(self.node.to_string())
.tap(|_| tracing::debug!("connecting to tendermint proxy"))
.await
.tap_err(|error| tracing::error!(?error, "failed to connect to tendermint proxy"))
.map_err(anyhow::Error::from)
}

/// Return the latest block height known by the fullnode or its peers, as
Expand All @@ -296,18 +299,20 @@ impl ViewServer {
pub async fn latest_known_block_height(&self) -> anyhow::Result<(u64, bool)> {
let mut client = self.tendermint_proxy_client().await?;

let rsp = client.get_status(GetStatusRequest {}).await?.into_inner();

//tracing::debug!("{:#?}", rsp);
let GetStatusResponse { sync_info, .. } = client
.get_status(GetStatusRequest {})
.tap(|_| tracing::debug!("querying current status"))
.await
.tap_err(|error| tracing::debug!(?error, "failed to query current status"))?
.into_inner();

let sync_info = rsp
.sync_info
let SyncInfo {
latest_block_height,
catching_up,
..
} = sync_info
.ok_or_else(|| anyhow::anyhow!("could not parse sync_info in gRPC response"))?;

let latest_block_height = sync_info.latest_block_height;

let node_catching_up = sync_info.catching_up;

// There is a `max_peer_block_height` available in TM 0.35, however it should not be used
// as it does not seem to reflect the consensus height. Since clients use `latest_known_block_height`
// to determine the height to attempt syncing to, a validator reporting a non-consensus height
Expand All @@ -316,11 +321,12 @@ impl ViewServer {

tracing::debug!(
?latest_block_height,
?node_catching_up,
?latest_known_block_height
?catching_up,
?latest_known_block_height,
"found latest known block height"
);

Ok((latest_known_block_height, node_catching_up))
Ok((latest_known_block_height, catching_up))
}

#[instrument(skip(self))]
Expand Down Expand Up @@ -1219,8 +1225,16 @@ impl ViewService for ViewServer {
) -> Result<tonic::Response<Self::StatusStreamStream>, tonic::Status> {
self.check_worker().await?;

let (latest_known_block_height, _) =
self.latest_known_block_height().await.map_err(|e| {
let (latest_known_block_height, _) = self
.latest_known_block_height()
.await
.tap_err(|error| {
tracing::debug!(
?error,
"unable to fetch latest known block height from fullnode"
)
})
.map_err(|e| {
tonic::Status::unknown(format!(
"unable to fetch latest known block height from fullnode: {e}"
))
Expand Down