Skip to content

Commit

Permalink
Fixed clippy & logs
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantinzolotarev committed Nov 23, 2024
1 parent 9e311db commit 42194f3
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions crates/scribe/src/events_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,36 +368,34 @@ impl OpPokedValidator {
"OpPokedValidator[{:?}] OpPoked validation started",
self.address
);
loop {
tokio::select! {
// Check if the challenge has been cancelled
_ = self.cancel.cancelled() => {
log::debug!("OpPokedValidator[{:?}] Challenge cancelled", self.address);
break;
}
// Check if the global cancel command sent
_ = self.global_cancel.cancelled() => {
log::debug!("OpPokedValidator[{:?}] Global cancel command received", self.address);
break;
tokio::select! {
// Check if the challenge has been cancelled
_ = self.cancel.cancelled() => {
log::debug!("OpPokedValidator[{:?}] Challenge cancelled", self.address);
Ok(())
}
// Check if the global cancel command sent
_ = self.global_cancel.cancelled() => {
log::debug!("OpPokedValidator[{:?}] Global cancel command received", self.address);
Ok(())
}
_ = tokio::time::sleep(Duration::from_millis(CHALLENGE_POKE_DELAY_MS)) => {
// Verify that the OpPoked is valid
let is_valid = ScribeOptimisticProviderInstance::new(
self.address,
self.provider.clone()
).is_schnorr_signature_valid(self.op_poked.clone()).await?;

if is_valid {
log::debug!("OpPokedValidator[{:?}] OpPoked is valid, no need to challenge", self.address);
return Ok(());
}
_ = tokio::time::sleep(Duration::from_millis(CHALLENGE_POKE_DELAY_MS)) => {
// Verify that the OpPoked is valid
let is_valid = ScribeOptimisticProviderInstance::new(
self.address,
self.provider.clone()
).is_schnorr_signature_valid(self.op_poked.clone()).await?;

if is_valid {
log::debug!("OpPokedValidator[{:?}] OpPoked is valid, no need to challenge", self.address);
break;
}

self.challenge().await?;
break;
}
// Perform the challenge process
self.challenge().await?;
Ok(())
}
}
Ok(())
}

// Perform the challenge process, first with flashbot provider, then with normal provider.
Expand Down Expand Up @@ -429,7 +427,7 @@ impl OpPokedValidator {
match result {
Ok(tx_hash) => {
log::info!(
"OpPokedValidator[{:?}] Flashbot transaction sent: {:?}",
"OpPokedValidator[{:?}] Flashbot transaction sent via flashbots RPC: {:?}",
self.address,
tx_hash
);
Expand All @@ -440,7 +438,7 @@ impl OpPokedValidator {
}
Err(e) => {
log::error!(
"OpPokedValidator[{:?}] Failed to send flashbot transaction: {:?}",
"OpPokedValidator[{:?}] Failed to send challenge transaction via flashbots: {:?}",
self.address,
e
);
Expand All @@ -457,7 +455,7 @@ impl OpPokedValidator {
match contract.challenge(self.op_poked.schnorrData.clone()).await {
Ok(tx_hash) => {
log::info!(
"OpPokedValidator[{:?}] Challenge transaction sent: {:?}",
"OpPokedValidator[{:?}] Challenge transaction sent via public RPC: {:?}",
self.address,
tx_hash
);
Expand All @@ -467,7 +465,7 @@ impl OpPokedValidator {
}
Err(e) => {
log::error!(
"OpPokedValidator[{:?}] Failed to send challenge transaction: {:?}",
"OpPokedValidator[{:?}] Failed to send challenge transaction via public RPC: {:?}",
self.address,
e
);
Expand Down

0 comments on commit 42194f3

Please sign in to comment.