Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/ibc-attestor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ tower-http = { workspace = true, features = ["trace"] }
tonic = { workspace = true, default-features = true }
tonic-reflection = { workspace = true, default-features = true }
prost = { workspace = true, default-features = true }
prometheus = { workspace = true, default-features = true }
warp = { workspace = true, features = ["server"] }
futures = { workspace = true, default-features = true }
async-trait = { workspace = true }
Expand Down
7 changes: 6 additions & 1 deletion apps/ibc-attestor/src/adapter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use thiserror::Error;

use crate::metrics;
use crate::rpc::api::CommitmentType;

use cosmos::CosmosAdapter;
Expand Down Expand Up @@ -76,11 +77,15 @@ impl AdapterEnum {
#[async_trait::async_trait]
impl AttestationAdapter for AdapterEnum {
async fn get_last_height_at_configured_finality(&self) -> Result<u64, AttestationAdapterError> {
match self {
let result = match self {
Self::Evm(a) => a.get_last_height_at_configured_finality().await,
Self::Solana(a) => a.get_last_height_at_configured_finality().await,
Self::Cosmos(a) => a.get_last_height_at_configured_finality().await,
};
if let Ok(height) = &result {
metrics::set_adapter_finalized_height(*height);
}
result
}

async fn get_block_timestamp(&self, height: u64) -> Result<u64, AttestationAdapterError> {
Expand Down
8 changes: 7 additions & 1 deletion apps/ibc-attestor/src/adapter/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use tokio_retry::{RetryIf, strategy::ExponentialBackoff};
use tracing::{debug, error};

use super::AttestationAdapterError;
use crate::metrics;

const MAX_ATTEMPTS: u8 = 3;
const INITIAL_BACKOFF: u64 = 200;
Expand Down Expand Up @@ -44,10 +45,15 @@ where
)
.await;

let final_attempts = attempts.load(Ordering::Relaxed);

if let Err(error) = &result {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think final_attempts is used outside of the if statement below. Then I think we can include it inside that context?

if final_attempts >= MAX_ATTEMPTS {
metrics::inc_retry_failure(operation);
}
error!(
operation,
attempts = attempts.load(Ordering::Relaxed),
attempts = final_attempts,
maxAttempts = MAX_ATTEMPTS,
error = %error,
"request failed"
Expand Down
1 change: 1 addition & 0 deletions apps/ibc-attestor/src/bin/ibc_attestor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fn run_servers(
) -> Result<ServerHandles, anyhow::Error> {
let adapter_name = config.adapter.adapter_name();
let signer_name = config.signer.signer_name();
ibc_attestor::metrics::init(adapter_name, signer_name);
let server_config = config.server;

let grpc_shutdown_rx = shutdown_tx.subscribe();
Expand Down
2 changes: 2 additions & 0 deletions apps/ibc-attestor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub mod attestation_payload;
pub mod config;
/// Logging and observability setup
pub mod logging;
/// Prometheus metrics registry and recording helpers
pub mod metrics;
/// gRPC server and service implementations
pub mod rpc;
/// Signer implementations for local and remote signing
Expand Down
Loading
Loading