Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Companion for init the RuntimeLogger automatically #2522

Merged
merged 9 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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: 9 additions & 2 deletions runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.13", optional = true }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.123", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
Expand Down Expand Up @@ -145,7 +145,7 @@ std = [
"pallet-vesting/std",
"serde_derive",
"serde/std",
"log",
"log/std",
"pallet-babe/std",
"babe-primitives/std",
"sp-session/std",
Expand Down Expand Up @@ -194,3 +194,10 @@ try-runtime = [
# runtime without clashing with the runtime api exported functions
# in WASM.
disable-runtime-api = []

# A feature that should be enabled when the runtime should be build for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
on-chain-release-build = [
"sp-api/disable-logging",
]
7 changes: 3 additions & 4 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ use sp_version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug, RuntimeDebug,
parameter_types, construct_runtime, RuntimeDebug,
traits::{KeyOwnerProofSystem, Randomness, LockIdentifier, Filter, InstanceFilter},
weights::Weight,
};
use frame_system::{EnsureRoot, EnsureOneOf};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_session::{historical as session_historical};
use pallet_session::historical as session_historical;
use static_assertions::const_assert;

#[cfg(feature = "std")]
Expand Down Expand Up @@ -696,7 +696,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
);
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
log::warn!("Unable to create signed payload: {:?}", e);
}).ok()?;
let signature = raw_payload.using_encoded(|payload| {
C::sign(payload, public)
Expand Down Expand Up @@ -1318,7 +1318,6 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
frame_support::debug::RuntimeLogger::init();
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}
Expand Down
3 changes: 2 additions & 1 deletion runtime/parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = "0.4.13"
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.123", features = [ "derive" ], optional = true }
derive_more = "0.99.11"
Expand Down Expand Up @@ -86,6 +86,7 @@ std = [
"pallet-vesting/std",
"xcm/std",
"xcm-executor/std",
"log/std",
]
runtime-benchmarks = [
"libsecp256k1/hmac",
Expand Down
18 changes: 8 additions & 10 deletions runtime/parachains/src/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use primitives::v1::{
CandidateReceipt, HeadData, CandidateHash, Hash,
};
use frame_support::{
decl_storage, decl_module, decl_error, decl_event, ensure, debug,
dispatch::DispatchResult, IterableStorageMap, weights::Weight, traits::Get,
decl_storage, decl_module, decl_error, decl_event, ensure, dispatch::DispatchResult, IterableStorageMap,
weights::Weight, traits::Get,
};
use parity_scale_codec::{Encode, Decode};
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
Expand Down Expand Up @@ -213,7 +213,7 @@ decl_module! {
}
}

const LOG_TARGET: &str = "parachains_runtime_inclusion";
const LOG_TARGET: &str = "runtime::inclusion";

impl<T: Config> Module<T> {
/// Block initialization logic, called by initializer.
Expand Down Expand Up @@ -343,11 +343,11 @@ impl<T: Config> Module<T> {
let commitments = match PendingAvailabilityCommitments::take(&para_id) {
Some(commitments) => commitments,
None => {
debug::warn!(r#"
Inclusion::process_bitfields:
PendingAvailability and PendingAvailabilityCommitments
are out of sync, did someone mess with the storage?
"#);
log::warn!(
target: LOG_TARGET,
"Inclusion::process_bitfields: PendingAvailability and PendingAvailabilityCommitments
are out of sync, did someone mess with the storage?",
);
continue;
}
};
Expand Down Expand Up @@ -460,7 +460,6 @@ impl<T: Config> Module<T> {
&candidate.candidate.commitments.horizontal_messages,
)
{
frame_support::debug::RuntimeLogger::init();
log::debug!(
target: LOG_TARGET,
"Validation outputs checking during inclusion of a candidate {} for parachain `{}` failed: {:?}",
Expand Down Expand Up @@ -631,7 +630,6 @@ impl<T: Config> Module<T> {
T::BlockNumber::from(validation_outputs.hrmp_watermark),
&validation_outputs.horizontal_messages,
) {
frame_support::debug::RuntimeLogger::init();
log::debug!(
target: LOG_TARGET,
"Validation outputs checking for parachain `{}` failed: {:?}",
Expand Down
3 changes: 1 addition & 2 deletions runtime/parachains/src/inclusion_inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ impl<T: Config> ProvideInherent for Module<T> {
) {
Ok(_) => (signed_bitfields, backed_candidates),
Err(err) => {
frame_support::debug::RuntimeLogger::init();
frame_support::debug::warn!(
log::warn!(
target: "runtime_inclusion_inherent",
"dropping signed_bitfields and backed_candidates because they produced \
an invalid inclusion inherent: {:?}",
Expand Down
8 changes: 5 additions & 3 deletions runtime/parachains/src/runtime_api_impl/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use primitives::v1::{
GroupIndex, CandidateEvent, PersistedValidationData, SessionInfo,
InboundDownwardMessage, InboundHrmpMessage, Hash, AuthorityDiscoveryId
};
use frame_support::debug;
use crate::{initializer, inclusion, scheduler, configuration, paras, session_info, dmp, hrmp, shared};


Expand Down Expand Up @@ -85,8 +84,11 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
match <scheduler::Module<T>>::group_assigned_to_core(core_index, backed_in_number) {
Some(g) => g,
None => {
debug::warn!("Could not determine the group responsible for core extracted \
from list of cores for some prior block in same session");
log::warn!(
target: "runtime::polkadot-api::v1",
"Could not determine the group responsible for core extracted \
from list of cores for some prior block in same session",
);

GroupIndex(0)
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/parachains/src/ump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl<Config: xcm_executor::Config> UmpSink for XcmSink<Config> {
}
}
} else {
frame_support::debug::error!(
target: "xcm",
log::error!(
target: "runtime::ump-sink",
"Failed to decode versioned XCM from upward message.",
);
}
Expand Down
11 changes: 9 additions & 2 deletions runtime/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.13", optional = true }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.123", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
Expand Down Expand Up @@ -139,7 +139,7 @@ std = [
"sp-version/std",
"serde_derive",
"serde/std",
"log",
"log/std",
"pallet-babe/std",
"babe-primitives/std",
"sp-session/std",
Expand Down Expand Up @@ -189,3 +189,10 @@ try-runtime = [
# runtime without clashing with the runtime api exported functions
# in WASM.
disable-runtime-api = []

# A feature that should be enabled when the runtime should be build for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
on-chain-release-build = [
"sp-api/disable-logging",
]
5 changes: 2 additions & 3 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use sp_version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug, RuntimeDebug,
parameter_types, construct_runtime, RuntimeDebug,
traits::{KeyOwnerProofSystem, Randomness, LockIdentifier, Filter},
weights::Weight,
};
Expand Down Expand Up @@ -742,7 +742,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
claims::PrevalidateAttests::<Runtime>::new(),
);
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
log::warn!("Unable to create signed payload: {:?}", e);
}).ok()?;
let signature = raw_payload.using_encoded(|payload| {
C::sign(payload, public)
Expand Down Expand Up @@ -1314,7 +1314,6 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
frame_support::debug::RuntimeLogger::init();
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ serde = { version = "1.0.123", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
smallvec = "1.6.1"
hex-literal = "0.3.1"
log = { version = "0.4.14", default-features = false }

frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -107,6 +108,7 @@ std = [
"xcm/std",
"xcm-executor/std",
"xcm-builder/std",
"log/std",
]
# When enabled, the runtime api will not be build.
#
Expand Down
4 changes: 2 additions & 2 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use runtime_parachains::{
runtime_api_impl::v1 as runtime_api_impl,
};
use frame_support::{
parameter_types, construct_runtime, debug, traits::{KeyOwnerProofSystem, Filter, EnsureOrigin}, weights::Weight,
parameter_types, construct_runtime, traits::{KeyOwnerProofSystem, Filter, EnsureOrigin}, weights::Weight,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
Expand Down Expand Up @@ -289,7 +289,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
);
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
log::warn!("Unable to create signed payload: {:?}", e);
}).ok()?;
let signature = raw_payload.using_encoded(|payload| {
C::sign(payload, public)
Expand Down
4 changes: 2 additions & 2 deletions runtime/test-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.13", optional = true }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.123", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
Expand Down Expand Up @@ -109,11 +109,11 @@ std = [
"pallet-vesting/std",
"serde_derive",
"serde/std",
"log",
"pallet-babe/std",
"babe-primitives/std",
"sp-session/std",
"pallet-randomness-collective-flip/std",
"runtime-common/std",
"log/std",
"sp-election-providers/std",
]
8 changes: 2 additions & 6 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives};
use sp_version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, Randomness},
weights::Weight,
};
use frame_support::{parameter_types, construct_runtime, traits::{KeyOwnerProofSystem, Randomness}, weights::Weight};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_session::historical as session_historical;
Expand Down Expand Up @@ -392,7 +388,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
);
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
log::warn!("Unable to create signed payload: {:?}", e);
}).ok()?;
let signature = raw_payload.using_encoded(|payload| {
C::sign(payload, public)
Expand Down
4 changes: 2 additions & 2 deletions runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.13", optional = true }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.123", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
Expand Down Expand Up @@ -144,7 +144,7 @@ std = [
"pallet-vesting/std",
"serde_derive",
"serde/std",
"log",
"log/std",
"pallet-babe/std",
"babe-primitives/std",
"sp-session/std",
Expand Down
5 changes: 2 additions & 3 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use sp_version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug, RuntimeDebug,
parameter_types, construct_runtime, RuntimeDebug,
traits::{KeyOwnerProofSystem, Randomness, Filter, InstanceFilter},
weights::Weight,
};
Expand Down Expand Up @@ -476,7 +476,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
);
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
log::warn!("Unable to create signed payload: {:?}", e);
}).ok()?;
let signature = raw_payload.using_encoded(|payload| {
C::sign(payload, public)
Expand Down Expand Up @@ -1033,7 +1033,6 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
frame_support::debug::RuntimeLogger::init();
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}
Expand Down
2 changes: 2 additions & 0 deletions xcm/xcm-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "mas
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
log = { version = "0.4.14", default-features = false }

[features]
default = ["std"]
Expand All @@ -27,4 +28,5 @@ std = [
"sp-core/std",
"sp-runtime/std",
"frame-support/std",
"log/std",
]
2 changes: 1 addition & 1 deletion xcm/xcm-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<Config: config::Config> ExecuteXcm for XcmExecutor<Config> {
(origin, Xcm::TeleportAsset { assets, effects }) => {
// check whether we trust origin to teleport this asset to us via config trait.
// TODO: should de-wildcard `assets` before passing in.
frame_support::debug::print!("Teleport from {:?}", origin);
log::debug!(target: "runtime::xcm-executor", "Teleport from {:?}", origin);
if assets.iter().all(|asset| Config::IsTeleporter::filter_asset_location(asset, &origin)) {
// We only trust the origin to send us assets that they identify as their
// sovereign assets.
Expand Down