Companion for init the RuntimeLogger automatically (#2522)

* Lol

* Add the features

* Remove some more runtime logger init calls

* Make companion check work

* Revert "Make companion check work"

This reverts commit a255c798076466c0fa20a4db713fc712772c2b4d.

* Update Substrate
This commit is contained in:
Bastian Köcher
2021-03-01 16:15:34 +01:00
committed by GitHub
parent 135cce9055
commit 7a2c7aa3fe
18 changed files with 231 additions and 192 deletions
+175 -147
View File
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -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 }
@@ -145,7 +145,7 @@ std = [
"pallet-vesting/std",
"serde_derive",
"serde/std",
"log",
"log/std",
"pallet-babe/std",
"babe-primitives/std",
"sp-session/std",
@@ -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",
]
+3 -4
View File
@@ -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, InstanceFilter},
weights::Weight,
};
@@ -64,7 +64,7 @@ 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")]
@@ -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)
@@ -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))
}
+2 -1
View File
@@ -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"
@@ -86,6 +86,7 @@ std = [
"pallet-vesting/std",
"xcm/std",
"xcm-executor/std",
"log/std",
]
runtime-benchmarks = [
"libsecp256k1/hmac",
+8 -10
View File
@@ -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};
@@ -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.
@@ -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;
}
};
@@ -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: {:?}",
@@ -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: {:?}",
@@ -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: {:?}",
@@ -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};
@@ -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)
}
+2 -2
View File
@@ -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.",
);
}
+9 -2
View File
@@ -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 }
@@ -139,7 +139,7 @@ std = [
"sp-version/std",
"serde_derive",
"serde/std",
"log",
"log/std",
"pallet-babe/std",
"babe-primitives/std",
"sp-session/std",
@@ -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",
]
+2 -3
View File
@@ -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,
};
@@ -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)
@@ -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))
}
+2
View File
@@ -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 }
@@ -107,6 +108,7 @@ std = [
"xcm/std",
"xcm-executor/std",
"xcm-builder/std",
"log/std",
]
# When enabled, the runtime api will not be build.
#
+2 -2
View File
@@ -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,
@@ -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)
+2 -2
View File
@@ -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 }
@@ -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",
]
+2 -6
View File
@@ -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;
@@ -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)
+2 -2
View File
@@ -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 }
@@ -144,7 +144,7 @@ std = [
"pallet-vesting/std",
"serde_derive",
"serde/std",
"log",
"log/std",
"pallet-babe/std",
"babe-primitives/std",
"sp-session/std",
+2 -3
View File
@@ -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,
};
@@ -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)
@@ -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))
}
+2
View File
@@ -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"]
@@ -27,4 +28,5 @@ std = [
"sp-core/std",
"sp-runtime/std",
"frame-support/std",
"log/std",
]
+1 -1
View File
@@ -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.