Skip to content

Commit

Permalink
Replace log with tracing in sc-consensus-subspace
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Nov 25, 2023
1 parent 5e71c48 commit 45a8479
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/sc-consensus-subspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ targets = ["x86_64-unknown-linux-gnu"]
async-trait = "0.1.73"
codec = { package = "parity-scale-codec", version = "3.6.5", features = ["derive"] }
futures = "0.3.29"
log = "0.4.20"
lru = "0.11.0"
parking_lot = "0.12.1"
rand = "0.8.5"
Expand Down Expand Up @@ -47,6 +46,7 @@ subspace-proof-of-space = { version = "0.1.0", path = "../subspace-proof-of-spac
subspace-verification = { version = "0.1.0", path = "../subspace-verification" }
thiserror = "1.0.48"
tokio = { version = "1.34.0", features = ["sync"] }
tracing = "0.1.37"

[dev-dependencies]
# TODO: Restore in the future, currently tests are mostly broken and useless
Expand Down
37 changes: 14 additions & 23 deletions crates/sc-consensus-subspace/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use crate::slot_worker::SubspaceSyncOracle;
use crate::{SubspaceLink, SubspaceNotificationSender};
use codec::{Decode, Encode};
use futures::StreamExt;
use log::{debug, info, warn};
use parking_lot::Mutex;
use rand::prelude::*;
use rand_chacha::ChaCha8Rng;
Expand All @@ -51,6 +50,7 @@ use subspace_archiving::archiver::{Archiver, NewArchivedSegment};
use subspace_core_primitives::crypto::kzg::Kzg;
use subspace_core_primitives::objects::BlockObjectMapping;
use subspace_core_primitives::{BlockNumber, RecordedHistorySegment, SegmentHeader, SegmentIndex};
use tracing::{debug, info, warn};

/// This corresponds to default value of `--max-runtime-instances` in Substrate
const BLOCKS_TO_ARCHIVE_CONCURRENCY: usize = 8;
Expand Down Expand Up @@ -100,10 +100,7 @@ where
let mut cache = Vec::with_capacity(Self::INITIAL_CACHE_CAPACITY);
let mut next_key_index = 0;

debug!(
target: "subspace",
"Started loading segment headers into cache"
);
debug!("Started loading segment headers into cache");
while let Some(segment_headers) =
aux_store
.get_aux(&Self::key(next_key_index))?
Expand All @@ -115,10 +112,7 @@ where
cache.extend(segment_headers);
next_key_index += 1;
}
debug!(
target: "subspace",
"Finished loading segment headers into cache"
);
debug!("Finished loading segment headers into cache");

Ok(Self {
inner: Arc::new(SegmentHeadersStoreInner {
Expand Down Expand Up @@ -435,9 +429,8 @@ where
// Continuing from existing initial state
let last_archived_block_number = last_segment_header.last_archived_block().number;
info!(
target: "subspace",
"Last archived block {}",
last_archived_block_number,
%last_archived_block_number,
"Resuming archiver from last archived block",
);

// Set initial value, this is needed in case only genesis block was archived and there
Expand Down Expand Up @@ -476,7 +469,7 @@ where

archiver
} else {
info!(target: "subspace", "Starting archiving from genesis");
info!("Starting archiving from genesis");

Archiver::new(subspace_link.kzg().clone()).expect("Incorrect parameters for archiver")
};
Expand Down Expand Up @@ -509,10 +502,8 @@ where

if let Some(blocks_to_archive_to) = blocks_to_archive_to {
info!(
target: "subspace",
"Archiving already produced blocks {}..={}",
blocks_to_archive_from,
blocks_to_archive_to,
blocks_to_archive_from, blocks_to_archive_to,
);

let thread_pool = ThreadPoolBuilder::new()
Expand Down Expand Up @@ -568,7 +559,6 @@ where
let encoded_block = encode_block(block);

debug!(
target: "subspace",
"Encoded block {} has size of {:.2} kiB",
block_number_to_archive,
encoded_block.len() as f32 / 1024.0
Expand Down Expand Up @@ -633,11 +623,15 @@ fn finalize_block<Block, Backend, Client>(
client
.apply_finality(import_op, hash, None, true)
.map_err(|error| {
warn!(target: "subspace", "Error applying finality to block {:?}: {}", (hash, number), error);
warn!(
"Error applying finality to block {:?}: {}",
(hash, number),
error
);
error
})?;

debug!(target: "subspace", "Finalizing blocks up to ({:?}, {})", number, hash);
debug!("Finalizing blocks up to ({:?}, {})", number, hash);

telemetry!(
telemetry;
Expand Down Expand Up @@ -737,10 +731,8 @@ where
let block_hash_to_archive = block.block.hash();

debug!(
target: "subspace",
"Archiving block {:?} ({})",
block_number_to_archive,
block_hash_to_archive
block_number_to_archive, block_hash_to_archive
);

if parent_block_hash != best_archived_block_hash {
Expand Down Expand Up @@ -774,7 +766,6 @@ where

let encoded_block = encode_block(block);
debug!(
target: "subspace",
"Encoded block {} has size of {:.2} kiB",
block_number_to_archive,
encoded_block.len() as f32 / 1024.0
Expand Down
12 changes: 4 additions & 8 deletions crates/sc-consensus-subspace/src/block_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::verifier::VerificationError;
use crate::{aux_schema, slot_worker, SubspaceLink};
use futures::channel::mpsc;
use futures::StreamExt;
use log::warn;
use sc_client_api::backend::AuxStore;
use sc_client_api::BlockBackend;
use sc_consensus::block_import::{
Expand All @@ -50,6 +49,7 @@ use subspace_core_primitives::{
};
use subspace_proof_of_space::Table;
use subspace_verification::{calculate_block_weight, PieceCheckParams, VerifySolutionParams};
use tracing::warn;

/// Notification with number of the block that is about to be imported and acknowledgement sender
/// that can be used to pause block production if desired.
Expand Down Expand Up @@ -371,9 +371,8 @@ where
})?
{
warn!(
target: "subspace",
"Ignoring block with solution provided by farmer in block list: {}",
pre_digest.solution().public_key
public_key = %pre_digest.solution().public_key,
"Ignoring block with solution provided by farmer in block list",
);

return Err(Error::FarmerInBlockList(
Expand Down Expand Up @@ -672,12 +671,9 @@ where

if &found_segment_commitment != segment_commitment {
warn!(
target: "subspace",
"Different segment commitment for segment index {} was found in storage, \
likely fork below archiving point. expected {:?}, found {:?}",
segment_index,
segment_commitment,
found_segment_commitment
segment_index, segment_commitment, found_segment_commitment
);
return Err(Error::DifferentSegmentCommitment(segment_index));
}
Expand Down
1 change: 0 additions & 1 deletion crates/sc-consensus-subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use crate::archiver::{ArchivedSegmentNotification, FINALIZATION_DEPTH_IN_SEGMENT
use crate::block_import::BlockImportingNotification;
use crate::notification::{SubspaceNotificationSender, SubspaceNotificationStream};
use crate::slot_worker::{NewSlotNotification, RewardSigningNotification};
use log::warn;
use lru::LruCache;
use parking_lot::Mutex;
use sp_api::{BlockT, NumberFor};
Expand Down
Loading

0 comments on commit 45a8479

Please sign in to comment.