-
Notifications
You must be signed in to change notification settings - Fork 329
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
Structured logs for relayer logic #1491
Changes from 1 commit
a29c9c7
4df293f
5ae8e42
50ff524
794a7bf
cc5e158
d75c832
9d17f44
a2c3311
5906035
74913b7
dcf662a
f9ca4db
5de3f2b
1d15085
60e66e6
4d94d54
d189d2c
3166f76
c93249b
1bba81b
6df6b63
85c60fa
b8e9c7c
d84bccd
c5f7d87
0507161
914373c
d1ae093
108d081
e6b41f9
73d135e
6cb9023
c69aa81
7ae8880
bfec7d6
45a9761
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use core::convert::Infallible; | ||
use core::time::Duration; | ||
use crossbeam_channel::Receiver; | ||
use tracing::{debug, trace, warn}; | ||
use tracing::{debug, span, trace, warn}; | ||
|
||
use ibc::events::IbcEvent; | ||
|
||
|
@@ -19,13 +19,19 @@ pub fn spawn_refresh_client<ChainA: ChainHandle, ChainB: ChainHandle>( | |
) -> Option<TaskHandle> { | ||
if client.is_expired_or_frozen() { | ||
warn!( | ||
"skipping refresh client task on frozen client: {}", | ||
client.id() | ||
client = %client.id, | ||
"skipping refresh client task on frozen client", | ||
); | ||
None | ||
} else { | ||
Some(spawn_background_task( | ||
format!("RefreshClientWorker({})", client), | ||
span!( | ||
tracing::Level::ERROR, | ||
"RefreshClientWorker", | ||
client = %client.id, | ||
src_chain = %client.src_chain.id(), | ||
dst_chain = %client.dst_chain.id(), | ||
), | ||
Some(Duration::from_secs(1)), | ||
move || { | ||
let res = client.refresh().map_err(|e| { | ||
|
@@ -52,40 +58,47 @@ pub fn detect_misbehavior_task<ChainA: ChainHandle, ChainB: ChainHandle>( | |
) -> Option<TaskHandle> { | ||
if client.is_expired_or_frozen() { | ||
warn!( | ||
"skipping detect misbehavior task on frozen client: {}", | ||
client.id() | ||
client = %client.id(), | ||
"skipping detect misbehavior task on frozen client", | ||
); | ||
return None; | ||
} | ||
|
||
{ | ||
debug!("[{}] doing first misbehavior check", client); | ||
let _span = span!( | ||
tracing::Level::DEBUG, | ||
"DetectMisbehaviorFirstCheck", | ||
client = %client.id, | ||
src_chain = %client.src_chain.id(), | ||
dst_chain = %client.dst_chain.id(), | ||
) | ||
.entered(); | ||
debug!("doing first check"); | ||
let misbehavior_result = client.detect_misbehaviour_and_submit_evidence(None); | ||
debug!( | ||
"[{}] detect misbehavior result: {:?}", | ||
client, misbehavior_result | ||
); | ||
trace!("detect misbehavior result: {:?}", misbehavior_result); | ||
} | ||
|
||
let handle = spawn_background_task( | ||
format!("DetectMisbehaviorWorker({})", client), | ||
span!( | ||
tracing::Level::ERROR, | ||
"DetectMisbehaviorWorker", | ||
client = %client.id, | ||
src_chain = %client.src_chain.id(), | ||
dst_chain = %client.dst_chain.id(), | ||
), | ||
Comment on lines
+82
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit more repetitive than the previous approach, but this allows filtering logs by any of the individual ID fields. If this level of detail is not desirable, we could implement |
||
Some(Duration::from_millis(600)), | ||
move || -> Result<Next, TaskError<Infallible>> { | ||
if let Ok(cmd) = receiver.try_recv() { | ||
match cmd { | ||
WorkerCmd::IbcEvents { batch } => { | ||
trace!("[{}] worker received batch: {:?}", client, batch); | ||
trace!("received batch: {:?}", batch); | ||
|
||
for event in batch.events { | ||
if let IbcEvent::UpdateClient(update) = event { | ||
debug!("[{}] checking misbehavior for updated client", client); | ||
debug!("checking misbehavior for updated client"); | ||
let misbehavior_result = | ||
client.detect_misbehaviour_and_submit_evidence(Some(update)); | ||
trace!( | ||
"[{}] detect misbehavior result: {:?}", | ||
client, | ||
misbehavior_result | ||
); | ||
trace!("detect misbehavior result: {:?}", misbehavior_result); | ||
|
||
match misbehavior_result { | ||
MisbehaviourResults::ValidClient => {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be folded into the "DetectMisbehaviorWorker" span below, but I thought it would be useful to distinguish these contexts since the other one is performed in a background worker task.