Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve agent logging #1797

Merged
merged 26 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
65a8547
Just use defaults of individual components
mattiekat Feb 7, 2023
0728580
Removed redundant log info
mattiekat Feb 7, 2023
775b94b
Reduced "Indexed block range" to debug
mattiekat Feb 7, 2023
6b000b7
Make serial submitter a little easier to read
mattiekat Feb 7, 2023
36eff14
Make sponsored call op a little easier to parse
mattiekat Feb 7, 2023
92d139f
Filter out debug messages from hyper
mattiekat Feb 8, 2023
077f58c
Minor cleanup
mattiekat Feb 8, 2023
0634c29
Decrease verbosity of metadata builder in logs
mattiekat Feb 8, 2023
c0e18be
log updates
mattiekat Feb 9, 2023
4a114a1
More logging updates
mattiekat Feb 9, 2023
d5eef63
update ethers for testing
mattiekat Feb 9, 2023
8abaaf3
Merge branch 'main' into mattie/improve-relayer-logs
mattiekat Feb 9, 2023
56f2921
run locally with debug logging
mattiekat Feb 9, 2023
00f93ed
Drop retriable jsonrpc warn to info
mattiekat Feb 9, 2023
6c363dd
Update ethers
mattiekat Feb 9, 2023
bd7540e
More log cleanup
mattiekat Feb 9, 2023
0b4449e
Fix hyperlane message span
mattiekat Feb 9, 2023
f87a520
Limit max release log level
mattiekat Feb 9, 2023
3e821aa
Change our log level to debug
mattiekat Feb 9, 2023
ee36b81
Standardized log messages
mattiekat Feb 9, 2023
8e1b9b1
Update log message
mattiekat Feb 10, 2023
ea3cf9f
Update log message
mattiekat Feb 10, 2023
24af9ca
Switch to tagged release
mattiekat Feb 10, 2023
ee9a9c0
PR updates
mattiekat Feb 10, 2023
92b6f1c
Fmt
mattiekat Feb 10, 2023
38fc152
Merge branch 'main' into mattie/improve-relayer-logs
asaj Feb 11, 2023
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
20 changes: 10 additions & 10 deletions rust/Cargo.lock

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

6 changes: 3 additions & 3 deletions rust/agents/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ coingecko = { git = "https://github.com/hyperlane-xyz/coingecko-rs", tag = "2022
config = "~0.13.3"
serde = {version = "1.0", features = ["derive"]}
serde_json = { version = "1.0", default-features = false }
ethers = { git = "https://github.com/hyperlane-xyz/ethers-rs", tag = "2023-01-10-04" }
mattiekat marked this conversation as resolved.
Show resolved Hide resolved
ethers-contract = { git = "https://github.com/hyperlane-xyz/ethers-rs", tag = "2023-01-10-04", features=["legacy"] }
ethers = { git = "https://github.com/hyperlane-xyz/ethers-rs", tag = "2023-02-10-01" }
ethers-contract = { git = "https://github.com/hyperlane-xyz/ethers-rs", tag = "2023-02-10-01", features=["legacy"] }
thiserror = "1.0"
async-trait = { version = "0.1", default-features = false }
futures-util = "0.3"
eyre = "0.6"
reqwest = { version = "0", features = ["json"]}
strum = "0.24"
tracing = "0.1"
tracing = { version = "0.1", features = ["release_max_level_debug"] }
tracing-futures = "0.2"
tracing-subscriber = "0.3"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use async_trait::async_trait;
use coingecko::CoinGeckoClient;
use eyre::{eyre, Result};
use tokio::{sync::RwLock, time::timeout};
use tracing::{debug, info};

use hyperlane_core::{HyperlaneMessage, KnownHyperlaneDomain, TxCostEstimate, U256};

Expand Down Expand Up @@ -200,16 +201,25 @@ impl GasPaymentPolicy for GasPaymentPolicyMeetsEstimatedCost {
.await?;

let meets_requirement = *current_payment >= origin_token_tx_cost;
tracing::info!(
message_id=?message.id(),
message_nonce=?message.nonce,
tx_cost_estimate=?tx_cost_estimate,
destination_token_tx_cost=?destination_token_tx_cost,
origin_token_tx_cost=?origin_token_tx_cost,
current_payment=?current_payment,
meets_requirement=?meets_requirement,
"Evaluated whether message gas payment meets estimated cost",
);
if !meets_requirement {
info!(
%message,
?tx_cost_estimate,
?destination_token_tx_cost,
?origin_token_tx_cost,
?current_payment,
"Message gas payment does not meet estimated cost",
);
} else {
debug!(
%message,
?tx_cost_estimate,
?destination_token_tx_cost,
?origin_token_tx_cost,
?current_payment,
"Message gas payment meets estimated cost",
);
}

Ok(meets_requirement)
}
Expand Down
124 changes: 59 additions & 65 deletions rust/agents/relayer/src/msg/gelato_submitter/sponsored_call_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tokio::{
sync::mpsc::UnboundedSender,
time::{sleep, timeout},
};
use tracing::instrument;
use tracing::{error, info, instrument, warn};

use gelato::{
sponsored_call::{SponsoredCallApiCall, SponsoredCallApiCallResult, SponsoredCallArgs},
Expand Down Expand Up @@ -66,27 +66,22 @@ impl SponsoredCallOp {
Self(args)
}

#[instrument(skip(self), fields(msg_id=format!("{:x}", self.message.message.id()), msg_nonce=self.message.message.nonce))]
#[instrument(skip(self), fields(message=?self.message.message))]
pub async fn run(&mut self) {
loop {
match self.tick().await {
Ok(true) => {
// If the message was processed, send it over the channel and
// stop running.
if let Err(err) = self.send_message_processed() {
tracing::error!(
err=?err,
if let Err(error) = self.send_message_processed() {
error!(
?error,
"Unable to send processed message, receiver is closed or dropped.",
);
}
return;
}
Err(err) => {
tracing::warn!(
err=?err,
"Error occurred in sponsored_call_op tick",
);
}
Err(error) => warn!(?error, "Error occurred in sponsored_call_op tick"),
_ => {}
}

Expand All @@ -102,68 +97,67 @@ impl SponsoredCallOp {
if let Ok(true) = self.message_delivered().await {
return Ok(true);
}
if let Some(metadata) = self
let Some(metadata) = self
.metadata_builder
.fetch_metadata(&self.message.message, self.mailbox.clone())
.await?
{
// Estimate transaction costs for the process call. If there are issues, it's
// likely that gas estimation has failed because the message is
// reverting. This is defined behavior, so we just log the error and
// move onto the next tick.
let tx_cost_estimate = match self
.mailbox
.process_estimate_costs(&self.message.message, &metadata)
.await
{
Ok(tx_cost_estimate) => tx_cost_estimate,
Err(err) => {
tracing::info!(error=?err, "Error estimating process costs");
return Ok(false);
}
};

// If the gas payment requirement hasn't been met, sleep briefly and wait for
// the next tick.
let (meets_gas_requirement, gas_payment) = self
.gas_payment_enforcer
.message_meets_gas_payment_requirement(&self.message.message, &tx_cost_estimate)
.await?;
else {
return Ok(false)
};

if !meets_gas_requirement {
tracing::info!(gas_payment=?gas_payment, "Gas payment requirement not met yet");
// Estimate transaction costs for the process call. If there are issues, it's
// likely that gas estimation has failed because the message is
// reverting. This is defined behavior, so we just log the error and
// move onto the next tick.
let tx_cost_estimate = match self
.mailbox
.process_estimate_costs(&self.message.message, &metadata)
.await
{
Ok(tx_cost_estimate) => tx_cost_estimate,
Err(error) => {
info!(?error, "Error estimating process costs");
return Ok(false);
}
};

// Send the sponsored call.
let sponsored_call_result = self.send_sponsored_call_api_call(&metadata).await?;
tracing::info!(
msg=?self.message,
task_id=sponsored_call_result.task_id,
"Sent sponsored call",
);
// If the gas payment requirement hasn't been met, sleep briefly and wait for
// the next tick.
let (meets_gas_requirement, gas_payment) = self
.gas_payment_enforcer
.message_meets_gas_payment_requirement(&self.message.message, &tx_cost_estimate)
.await?;

// Wait for a terminal state, timing out according to the retry_submit_interval.
match timeout(
self.opts.retry_submit_interval,
self.poll_for_terminal_state(sponsored_call_result.task_id.clone()),
)
.await
{
Ok(result) => {
// Bubble up any error that may have occurred in `poll_for_terminal_state`.
result
}
// If a timeout occurred, don't bubble up an error, instead just log
// and set ourselves up for the next tick.
Err(err) => {
tracing::info!(err=?err, "Sponsored call timed out, reattempting");
Ok(false)
}
if !meets_gas_requirement {
info!(?gas_payment, "Gas payment requirement not met yet");
return Ok(false);
}

// Send the sponsored call.
let sponsored_call_result = self.send_sponsored_call_api_call(&metadata).await?;
info!(
msg=?self.message,
task_id=sponsored_call_result.task_id,
"Sent sponsored call",
);

// Wait for a terminal state, timing out according to the retry_submit_interval.
match timeout(
self.opts.retry_submit_interval,
self.poll_for_terminal_state(sponsored_call_result.task_id.clone()),
)
.await
{
Ok(result) => {
// Bubble up any error that may have occurred in `poll_for_terminal_state`.
result
}
// If a timeout occurred, don't bubble up an error, instead just log
// and set ourselves up for the next tick.
Err(error) => {
info!(?error, "Sponsored call timed out, reattempting");
Ok(false)
}
} else {
tracing::info!("Unable to fetch metadata for message");
Ok(false)
}
}

Expand Down Expand Up @@ -192,7 +186,7 @@ impl SponsoredCallOp {
let task_status_result = task_status_api_call.run().await?;
let task_state = task_status_result.task_state();

tracing::info!(
info!(
task_id=task_id,
task_state=?task_state,
task_status_result=?task_status_result,
Expand Down
Loading