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

feat: use tracing macros instead of vlog #237

Merged
merged 3 commits into from
Oct 16, 2023
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
11 changes: 6 additions & 5 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ members = [
]

[workspace.dependencies]
tracing = "0.1"
vise = { git = "https://github.com/matter-labs/vise.git" }
1 change: 1 addition & 0 deletions bin/withdrawal-finalizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ envconfig = "0.10.0"
tokio-util = "0.7.9"
sqlx = { version = "0.7", features = ["postgres", "runtime-tokio-rustls"] }
dotenvy = "0.15.7"
tracing = { workspace = true }

client = { path = "../../client" }
storage = { path = "../../storage" }
Expand Down
24 changes: 12 additions & 12 deletions bin/withdrawal-finalizer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ where
(Some(b1), Some(b2)) => Ok(std::cmp::min(b1, b2)),
(b1, b2) => {
if b1.is_none() {
vlog::info!(concat!(
tracing::info!(concat!(
"information about l2 to l1 events is missing, ",
"starting from L1 block corresponding to L2 block 1"
));
}

if b2.is_none() {
vlog::info!(concat!(
tracing::info!(concat!(
"information about last block seen is missing, ",
"starting from L1 block corresponding to L2 block 1"
));
Expand Down Expand Up @@ -149,14 +149,14 @@ async fn main() -> Result<()> {
let sentry_guard = vlog::init();

if sentry_guard.is_some() {
vlog::info!(
tracing::info!(
"Starting Sentry url: {}, l1_network: {}, l2_network {}",
std::env::var("MISC_SENTRY_URL").unwrap(),
std::env::var("CHAIN_ETH_NETWORK").unwrap(),
std::env::var("CHAIN_ETH_ZKSYNC_NETWORK").unwrap(),
);
} else {
vlog::info!("No sentry url configured");
tracing::info!("No sentry url configured");
}

let prometheus_exporter_handle = run_prometheus_exporter()?;
Expand Down Expand Up @@ -191,7 +191,7 @@ async fn main() -> Result<()> {
)
.await?;

vlog::info!("Starting from L2 block number {from_l2_block}");
tracing::info!("Starting from L2 block number {from_l2_block}");

let (we_tx, we_rx) = tokio::sync::mpsc::channel(CHANNEL_CAPACITY);

Expand All @@ -205,7 +205,7 @@ async fn main() -> Result<()> {
)
.await?;

vlog::info!("Starting from L1 block number {from_l1_block}");
tracing::info!("Starting from L1 block number {from_l1_block}");

let (tokens, last_token_seen_at_block) = storage::get_tokens(&pgpool.clone()).await?;

Expand Down Expand Up @@ -262,7 +262,7 @@ async fn main() -> Result<()> {
let batch_finalization_gas_limit = U256::from_dec_str(&config.batch_finalization_gas_limit)?;
let one_withdrawal_gas_limit = U256::from_dec_str(&config.one_withdrawal_gas_limit)?;

vlog::info!(
tracing::info!(
"finalization gas limits one: {}, batch: {}",
config.one_withdrawal_gas_limit,
config.batch_finalization_gas_limit,
Expand All @@ -282,19 +282,19 @@ async fn main() -> Result<()> {

tokio::select! {
r = block_events_handle => {
vlog::error!("Block Events stream ended with {r:?}");
tracing::error!("Block Events stream ended with {r:?}");
}
r = withdrawal_events_handle => {
vlog::error!("Withdrawals Events stream ended with {r:?}");
tracing::error!("Withdrawals Events stream ended with {r:?}");
}
r = watcher_handle => {
vlog::error!("Finalizer main loop ended with {r:?}");
tracing::error!("Finalizer main loop ended with {r:?}");
}
r = prometheus_exporter_handle => {
vlog::error!("Prometheus exporter ended with {r:?}");
tracing::error!("Prometheus exporter ended with {r:?}");
}
r = finalizer_handle => {
vlog::error!("Finalizer ended with {r:?}");
tracing::error!("Finalizer ended with {r:?}");
}
}

Expand Down
3 changes: 1 addition & 2 deletions chain-events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ ethers = { version = "2.0.10", features = ["ws"] }
futures = "0.3.28"
thiserror = "1.0.49"
tokio = { version = "1.33.0", features = ["time"] }
tracing = { workspace = true }
vise = { workspace = true }


vlog = { path = "../vlog" }
ethers-log-decode = { path = "../ethers-log-decode" }
14 changes: 7 additions & 7 deletions chain-events/src/block_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl BlockEvents {
Some(p)
}
Err(e) => {
vlog::warn!("Block events stream reconnect attempt failed: {e}");
tracing::warn!("Block events stream reconnect attempt failed: {e}");
CHAIN_EVENTS_METRICS.l1_reconnects_on_error.inc();
None
}
Expand Down Expand Up @@ -107,7 +107,7 @@ impl BlockEvents {
.await
{
Err(e) => {
vlog::warn!("Block events worker failed with {e}");
tracing::warn!("Block events worker failed with {e}");
}
Ok(block) => from_block = block,
}
Expand Down Expand Up @@ -153,7 +153,7 @@ impl BlockEvents {
.number
.expect("last block always has a number; qed");

vlog::info!(
tracing::info!(
"Filtering logs from {} to {}",
from_block
.into()
Expand Down Expand Up @@ -193,7 +193,7 @@ impl BlockEvents {
while let Some(log) = logs.next().await {
let log = match log {
Err(e) => {
vlog::warn!("L1 block events stream ended with {e}");
tracing::warn!("L1 block events stream ended with {e}");
break;
}
Ok(log) => log,
Expand All @@ -217,7 +217,7 @@ impl BlockEvents {
}
}

vlog::info!("all event streams have terminated, exiting...");
tracing::info!("all event streams have terminated, exiting...");

Ok(last_seen_block)
}
Expand Down Expand Up @@ -272,7 +272,7 @@ where
)
.await
else {
vlog::error!("Failed to retreive transaction {:?}", log.transaction_hash);
tracing::error!("Failed to retreive transaction {:?}", log.transaction_hash);
return Err(Error::NoTransaction);
};

Expand Down Expand Up @@ -319,7 +319,7 @@ where
.map_err(|_| Error::ChannelClosing)?;
}
L1Events::BlocksExecution(event) => {
vlog::info!(
tracing::info!(
"Received a block execution event {event:?} {:?}",
log.transaction_hash
);
Expand Down
28 changes: 14 additions & 14 deletions chain-events/src/l2_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl L2EventsListener {
Some(p)
}
Err(e) => {
vlog::warn!("Withdrawal events stream reconnect attempt failed: {e}");
tracing::warn!("Withdrawal events stream reconnect attempt failed: {e}");
CHAIN_EVENTS_METRICS.reconnects_on_error.inc();
None
}
Expand All @@ -101,7 +101,7 @@ impl L2EventsListener {
{
let from_block: BlockNumber = from_block.into();
let to_block: BlockNumber = to_block.into();
vlog::debug!("querying past token events {from_block:?} - {to_block:?}");
tracing::debug!("querying past token events {from_block:?} - {to_block:?}");

// Query all deployment events emitted by Deployer and with address of l2_erc20_bridge_addr
// as a topic1. This narrows down the query to basically only the needed results so
Expand Down Expand Up @@ -140,7 +140,7 @@ impl L2EventsListener {
if self.tokens.insert(address) {
let event = l2_event.into();

vlog::info!("sending token event {event:?}");
tracing::info!("sending token event {event:?}");
sender
.send(event)
.await
Expand Down Expand Up @@ -256,7 +256,7 @@ impl L2EventsListener {
let pagination_old = pagination;
if pagination > 2 {
pagination /= 2;
vlog::debug!(
tracing::debug!(
"Decreasing pagination from {pagination_old} to {pagination}",
);
}
Expand All @@ -265,7 +265,7 @@ impl L2EventsListener {
let pagination_old = pagination;
if pagination + PAGINATION_INCREASE_STEP < PAGINATION_STEP {
pagination += PAGINATION_INCREASE_STEP;
vlog::debug!(
tracing::debug!(
"Increasing pagination from {pagination_old} to {pagination}",
);
}
Expand All @@ -274,7 +274,7 @@ impl L2EventsListener {
}
}
Err(e) => {
vlog::warn!("Withdrawal events worker failed with {e}");
tracing::warn!("Withdrawal events worker failed with {e}");
}
}

Expand Down Expand Up @@ -336,8 +336,8 @@ impl L2EventsListener {
WithdrawalFilter::signature(),
];

vlog::debug!("last_seen_l2_token_block {last_seen_l2_token_block:?}");
vlog::debug!("from_block {from_block:?}");
tracing::debug!("last_seen_l2_token_block {last_seen_l2_token_block:?}");
tracing::debug!("from_block {from_block:?}");

let latest_block = middleware
.get_block(BlockNumber::Latest)
Expand Down Expand Up @@ -382,7 +382,7 @@ impl L2EventsListener {
while let Some(log) = logs.next().await {
let log = match log {
Err(e) => {
vlog::info!("L2 withdrawal events stream ended with {e:?}");
tracing::info!("L2 withdrawal events stream ended with {e:?}");
if rpc_query_too_large(&e) {
return Ok((last_seen_block, RunResult::PaginationTooLarge));
}
Expand Down Expand Up @@ -419,15 +419,15 @@ impl L2EventsListener {
break;
}
Err(e) => {
vlog::warn!("Stopping event loop with an error {e}");
tracing::warn!("Stopping event loop with an error {e}");
break;
}
_ => (),
};
}
}

vlog::info!("withdrawal streams being closed");
tracing::info!("withdrawal streams being closed");

Ok((last_seen_block, RunResult::OtherError))
}
Expand Down Expand Up @@ -458,7 +458,7 @@ impl L2EventsListener {
amount: *amount,
};
let event = we.into();
vlog::info!("sending withdrawal event {event:?}");
tracing::info!("sending withdrawal event {event:?}");
sender
.send(event)
.await
Expand Down Expand Up @@ -486,12 +486,12 @@ impl L2EventsListener {
CHAIN_EVENTS_METRICS.new_token_added.inc();

let event = l2_event.into();
vlog::info!("sending new token event {event:?}");
tracing::info!("sending new token event {event:?}");
sender
.send(event)
.await
.map_err(|_| Error::ChannelClosing)?;
vlog::info!("Restarting on the token added event {address}");
tracing::info!("Restarting on the token added event {address}");
return Ok(Some(NewTokenAdded));
}
}
Expand Down
2 changes: 1 addition & 1 deletion finalizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ futures = "0.3.28"
thiserror = "1.0.49"
sqlx = { version = "0.7", features = ["postgres", "runtime-tokio-rustls"] }
tokio = { version = "1.33.0", features = ["time"] }
tracing = { workspace = true }
vise = { workspace = true }

client = { path = "../client" }
storage = { path = "../storage" }
vlog = { path = "../vlog" }
tx-sender = { path = "../tx-sender" }
withdrawals-meterer = { path = "../withdrawals-meterer" }
Loading
Loading