Skip to content

Commit

Permalink
remove unused log target (#2447)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyWooo committed Jan 30, 2024
1 parent 080a457 commit 918f879
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 64 deletions.
26 changes: 14 additions & 12 deletions tee-worker/sidechain/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ impl<
type ScheduledEnclave = ScheduledEnclave;
type StateHandler = StateHandler;

fn logging_target(&self) -> &'static str {
"aura"
}

fn get_scheduled_enclave(&mut self) -> Arc<Self::ScheduledEnclave> {
self.scheduled_enclave.clone()
}
Expand Down Expand Up @@ -246,15 +242,12 @@ impl<
let expected_author = slot_author::<AuthorityPair>(slot, epoch_data)?;

if expected_author == &self.authority_pair.public() {
log::info!(target: self.logging_target(), "Claiming slot ({})", *slot);
log::info!("Claiming slot ({})", *slot);
return Some(self.authority_pair.public())
}

if self.claim_strategy == SlotClaimStrategy::Always {
log::debug!(
target: self.logging_target(),
"Not our slot but we still claim it."
);
log::debug!("Not our slot but we still claim it.");
return Some(self.authority_pair.public())
}

Expand All @@ -281,7 +274,10 @@ impl<
&self,
parentchain_header_hash: &<ParentchainBlock::Header as ParentchainHeaderTrait>::Hash,
) -> Result<Option<ParentchainBlock::Header>, ConsensusError> {
log::trace!(target: self.logging_target(), "import Integritee blocks until {}", hex_encode(parentchain_header_hash.encode().as_ref()));
log::trace!(
"import Integritee blocks until {}",
hex_encode(parentchain_header_hash.encode().as_ref())
);
let maybe_parentchain_block = self
.parentchain_integritee_import_trigger
.import_until(|parentchain_block| {
Expand All @@ -296,7 +292,10 @@ impl<
&self,
parentchain_header_hash: &<ParentchainBlock::Header as ParentchainHeaderTrait>::Hash,
) -> Result<Option<ParentchainBlock::Header>, ConsensusError> {
log::trace!(target: self.logging_target(), "import TargetA blocks until {}", hex_encode(parentchain_header_hash.encode().as_ref()));
log::trace!(
"import TargetA blocks until {}",
hex_encode(parentchain_header_hash.encode().as_ref())
);
let maybe_parentchain_block = self
.maybe_parentchain_target_a_import_trigger
.clone()
Expand All @@ -313,7 +312,10 @@ impl<
&self,
parentchain_header_hash: &<ParentchainBlock::Header as ParentchainHeaderTrait>::Hash,
) -> Result<Option<ParentchainBlock::Header>, ConsensusError> {
log::trace!(target: self.logging_target(), "import TargetB blocks until {}", hex_encode(parentchain_header_hash.encode().as_ref()));
log::trace!(
"import TargetB blocks until {}",
hex_encode(parentchain_header_hash.encode().as_ref())
);
let maybe_parentchain_block = self
.maybe_parentchain_target_b_import_trigger
.clone()
Expand Down
60 changes: 12 additions & 48 deletions tee-worker/sidechain/consensus/slots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
/// State handler context for authoring
type StateHandler: HandleState<StateT = SgxExternalities>;

/// The logging target to use when logging messages.
fn logging_target(&self) -> &'static str;

/// Get scheduled enclave
fn get_scheduled_enclave(&mut self) -> Arc<Self::ScheduledEnclave>;

Expand Down Expand Up @@ -281,15 +278,11 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
is_single_worker: bool,
) -> Option<SlotResult<Self::Output>> {
let (_timestamp, slot) = (slot_info.timestamp, slot_info.slot);
let logging_target = self.logging_target();

let remaining_duration = self.proposing_remaining_duration(&slot_info);

if remaining_duration == Duration::default() {
debug!(
target: logging_target,
"Skipping proposal slot {} since there's no time left to propose", *slot,
);
debug!("Skipping proposal slot {} since there's no time left to propose", *slot,);

return None
}
Expand All @@ -299,15 +292,11 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
Ok(Some(peeked_header)) => peeked_header,
Ok(None) => slot_info.last_imported_integritee_parentchain_head.clone(),
Err(e) => {
warn!(
target: logging_target,
"Failed to peek latest Integritee parentchain block header: {:?}", e
);
warn!("Failed to peek latest Integritee parentchain block header: {:?}", e);
return None
},
};
trace!(
target: logging_target,
"on_slot: a priori latest Integritee block number: {:?}",
latest_integritee_parentchain_header.number()
);
Expand All @@ -317,15 +306,11 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
Ok(Some(peeked_header)) => Some(peeked_header),
Ok(None) => slot_info.maybe_last_imported_target_a_parentchain_head.clone(),
Err(e) => {
debug!(
target: logging_target,
"Failed to peek latest target_a_parentchain block header: {:?}", e
);
debug!("Failed to peek latest target_a_parentchain block header: {:?}", e);
None
},
};
trace!(
target: logging_target,
"on_slot: a priori latest TargetA block number: {:?}",
maybe_latest_target_a_parentchain_header.clone().map(|h| *h.number())
);
Expand All @@ -335,15 +320,11 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
Ok(Some(peeked_header)) => Some(peeked_header),
Ok(None) => slot_info.maybe_last_imported_target_b_parentchain_head.clone(),
Err(e) => {
debug!(
target: logging_target,
"Failed to peek latest target_a_parentchain block header: {:?}", e
);
debug!("Failed to peek latest target_a_parentchain block header: {:?}", e);
None
},
};
trace!(
target: logging_target,
"on_slot: a priori latest TargetB block number: {:?}",
maybe_latest_target_b_parentchain_header.clone().map(|h| *h.number())
);
Expand All @@ -352,7 +333,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
Ok(epoch_data) => epoch_data,
Err(e) => {
warn!(
target: logging_target,
"Unable to fetch epoch data at block {:?}: {:?}",
latest_integritee_parentchain_header.hash(),
e,
Expand All @@ -365,10 +345,7 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
let authorities_len = self.authorities_len(&epoch_data);

if !authorities_len.map(|a| a > 0).unwrap_or(false) {
debug!(
target: logging_target,
"Skipping proposal slot. Authorities len {:?}", authorities_len
);
debug!("Skipping proposal slot. Authorities len {:?}", authorities_len);
}

// Return early if MRENCLAVE doesn't match - it implies that the enclave should be updated
Expand All @@ -380,7 +357,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {

if !scheduled_enclave.is_mrenclave_matching(next_sidechain_number) {
warn!(
target: logging_target,
"Skipping sidechain block {} due to mismatch MRENCLAVE, current: {:?}, expect: {:?}",
next_sidechain_number,
scheduled_enclave.get_current_mrenclave().map(hex::encode),
Expand Down Expand Up @@ -417,7 +393,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
Ok(h) => h,
Err(e) => {
debug!(
target: logging_target,
"Failed to import Integritee blocks until nr{:?}: {:?}",
latest_integritee_parentchain_header.number(),
e
Expand All @@ -426,7 +401,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
},
};
trace!(
target: logging_target,
"on_slot: a posteriori latest Integritee block number: {:?}",
last_imported_integritee_header.clone().map(|h| *h.number())
);
Expand All @@ -438,7 +412,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
Ok(None) => None,
Err(e) => {
debug!(
target: logging_target,
"Failed to import TargetA blocks until nr{:?}: {:?}",
header.number(),
e
Expand All @@ -450,7 +423,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
None
};
trace!(
target: logging_target,
"on_slot: a posteriori latest TargetA block number: {:?}",
maybe_last_imported_target_a_header.map(|h| *h.number())
);
Expand All @@ -462,7 +434,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
Ok(None) => None,
Err(e) => {
debug!(
target: logging_target,
"Failed to import TargetB blocks until nr{:?}: {:?}",
header.number(),
e
Expand All @@ -475,23 +446,22 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
};

trace!(
target: logging_target,
"on_slot: a posteriori latest TargetB block number: {:?}",
maybe_last_imported_target_b_header.map(|h| *h.number())
);

let proposer = match self.proposer(latest_integritee_parentchain_header.clone(), shard) {
Ok(p) => p,
Err(e) => {
warn!(target: logging_target, "Could not create proposer: {:?}", e);
warn!("Could not create proposer: {:?}", e);
return None
},
};

let proposing = match proposer.propose(remaining_duration) {
Ok(p) => p,
Err(e) => {
warn!(target: logging_target, "Could not propose: {:?}", e);
warn!("Could not propose: {:?}", e);
return None
},
};
Expand All @@ -500,7 +470,6 @@ pub trait SimpleSlotWorker<ParentchainBlock: ParentchainBlockTrait> {
error!("Running as single worker, skipping timestamp within slot check")
} else if !timestamp_within_slot(&slot_info, &proposing.block) {
warn!(
target: logging_target,
"⌛️ Discarding proposal for slot {}, block number {}; block production took too long",
*slot, proposing.block.block().header().block_number(),
);
Expand Down Expand Up @@ -558,8 +527,6 @@ impl<ParentchainBlock: ParentchainBlockTrait, T: SimpleSlotWorker<ParentchainBlo
shards: Vec<Self::ShardIdentifier>,
is_single_worker: bool,
) -> Self::Output {
let logging_target = SimpleSlotWorker::logging_target(self);

let mut remaining_shards = shards.len();
let mut slot_results = Vec::with_capacity(remaining_shards);

Expand All @@ -572,10 +539,7 @@ impl<ParentchainBlock: ParentchainBlockTrait, T: SimpleSlotWorker<ParentchainBlo
// important to check against millis here. We had the corner-case in production
// setup where `shard_remaining_duration` contained only nanos.
if shard_remaining_duration.as_millis() == u128::default() {
info!(
target: logging_target,
"⌛️ Could not produce blocks for all shards; block production took too long",
);
info!("⌛️ Could not produce blocks for all shards; block production took too long",);

return slot_results
}
Expand All @@ -595,13 +559,13 @@ impl<ParentchainBlock: ParentchainBlockTrait, T: SimpleSlotWorker<ParentchainBlo
Some(res) => {
slot_results.push(res);
debug!(
target: logging_target,
"on_slot: produced block for slot: {:?} in shard {:?}", shard_slot, shard
"on_slot: produced block for slot: {:?} in shard {:?}",
shard_slot, shard
)
},
None => info!(
target: logging_target,
"Did not propose a block for slot {} in shard {:?}", *slot_info.slot, shard
"Did not propose a block for slot {} in shard {:?}",
*slot_info.slot, shard
),
}

Expand Down
4 changes: 0 additions & 4 deletions tee-worker/sidechain/consensus/slots/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ where

type StateHandler = HandleStateMock;

fn logging_target(&self) -> &'static str {
"test"
}

fn get_scheduled_enclave(&mut self) -> Arc<Self::ScheduledEnclave> {
todo!()
}
Expand Down

0 comments on commit 918f879

Please sign in to comment.