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
12 changes: 9 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ pub struct DeployAndWaitArgs {
#[arg(long = "observer-host")]
pub observer_host: Option<String>,

/// Observer node gRPC port for finalization checks (falls back to 40452 if not specified)
/// Observer node gRPC port for finalization checks (falls back to 40452 if not specified).
/// The observer HTTP port is this value + 1. For a standalone node (no separate observer),
/// pass an observer port whose +1 equals the node's HTTP port.
#[arg(long = "observer-port")]
pub observer_port: Option<u16>,

Expand Down Expand Up @@ -569,7 +571,9 @@ pub struct BondValidatorArgs {
#[arg(long = "observer-host")]
pub observer_host: Option<String>,

/// Observer node gRPC port for finalization checks (falls back to 40452 if not specified)
/// Observer node gRPC port for finalization checks (falls back to 40452 if not specified).
/// The observer HTTP port is this value + 1. For a standalone node (no separate observer),
/// pass an observer port whose +1 equals the node's HTTP port.
#[arg(long = "observer-port")]
pub observer_port: Option<u16>,

Expand Down Expand Up @@ -666,7 +670,9 @@ pub struct TransferArgs {
#[arg(long = "observer-host")]
pub observer_host: Option<String>,

/// Observer node gRPC port for finalization checks (falls back to 40452 if not specified)
/// Observer node gRPC port for finalization checks (falls back to 40452 if not specified).
/// The observer HTTP port is this value + 1. For a standalone node (no separate observer),
/// pass an observer port whose +1 equals the node's HTTP port.
#[arg(long = "observer-port")]
pub observer_port: Option<u16>,

Expand Down
71 changes: 53 additions & 18 deletions src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,38 +268,73 @@ impl F1r3flyConnectionManager {
total_timeout_secs: u64,
poll_interval_secs: u64,
) -> Result<Option<crate::f1r3fly_api::DeployFinalizationStatus>, ConnectionError> {
let api = self.observer_api()?;
let observer_api = self.observer_api()?;
let node_api = self.api();
let http_port = self.observer_http_port();
let max_attempts = (total_timeout_secs / poll_interval_secs.max(1)).max(1) as u32;

for attempt in 1..=max_attempts {
match api
match observer_api
.deploy_finalization_status(deploy_sig_hex, http_port)
.await
{
Ok(Some(status)) => {
if status.is_terminal() {
tracing::debug!(
deploy_sig = deploy_sig_hex,
state = %status.state,
attempt,
"Deploy reached terminal state"
);
return Ok(Some(status));
}
Ok(Some(status)) if status.is_terminal() => {
tracing::debug!(
deploy_sig = deploy_sig_hex,
state = %status.state,
attempt,
"Deploy reached terminal state"
);
return Ok(Some(status));
}
// Non-terminal status — keep polling to the next attempt.
Ok(Some(_)) => {}
Ok(None) => {
// 404 — endpoint not available on this node version.
// Caller falls back to legacy flow.
return Ok(None);
}
Err(e) => {
tracing::warn!(
deploy_sig = deploy_sig_hex,
attempt,
error = %e,
"deploy-finalization-status query failed; will retry"
);
// Observer is unavailable => fallback to deploy-node (its HTTP port).
match &node_api {
Ok(na) => {
match na
.deploy_finalization_status(deploy_sig_hex, self.config.http_port)
.await
{
Ok(Some(status)) if status.is_terminal() => {
tracing::debug!(
deploy_sig = deploy_sig_hex,
state = %status.state,
attempt,
"Deploy reached terminal state (node API)"
);
return Ok(Some(status));
}
// Non-terminal status from node API is expected while polling.
// Keep silent and continue to the next poll attempt.
Ok(Some(_)) => {}
Ok(None) => return Ok(None),
Err(node_err) => {
tracing::warn!(
deploy_sig = deploy_sig_hex,
attempt,
observer_error = %e,
node_error = %node_err,
"deploy-finalization-status failed on observer and fallback node; will retry"
);
}
}
}
Err(_) => {
tracing::warn!(
deploy_sig = deploy_sig_hex,
attempt,
observer_error = %e,
"deploy-finalization-status failed on observer and no fallback node connection; will retry"
);
}
}
}
}

Expand Down