, Error> {
- let p = utils::pair_from_suri::(uri, pass)?;
- Ok(p.public().as_ref().to_vec())
-}
diff --git a/client/cli/src/commands/insert_key.rs b/client/cli/src/commands/insert_key.rs
new file mode 100644
index 0000000000000000000000000000000000000000..90588f96d20b03bd683612d9d72b7cbddb2baf41
--- /dev/null
+++ b/client/cli/src/commands/insert_key.rs
@@ -0,0 +1,173 @@
+// This file is part of Substrate.
+
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! Implementation of the `insert` subcommand
+
+use crate::{
+ Error, KeystoreParams, CryptoSchemeFlag, SharedParams, utils, with_crypto_scheme,
+ SubstrateCli,
+};
+use std::{sync::Arc, convert::TryFrom};
+use structopt::StructOpt;
+use sp_core::{crypto::KeyTypeId, crypto::SecretString};
+use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore};
+use sc_keystore::LocalKeystore;
+use sc_service::config::{KeystoreConfig, BasePath};
+
+/// The `insert` command
+#[derive(Debug, StructOpt)]
+#[structopt(
+ name = "insert",
+ about = "Insert a key to the keystore of a node."
+)]
+pub struct InsertKeyCmd {
+ /// The secret key URI.
+ /// If the value is a file, the file content is used as URI.
+ /// If not given, you will be prompted for the URI.
+ #[structopt(long)]
+ suri: Option,
+
+ /// Key type, examples: "gran", or "imon"
+ #[structopt(long)]
+ key_type: String,
+
+ #[allow(missing_docs)]
+ #[structopt(flatten)]
+ pub shared_params: SharedParams,
+
+ #[allow(missing_docs)]
+ #[structopt(flatten)]
+ pub keystore_params: KeystoreParams,
+
+ #[allow(missing_docs)]
+ #[structopt(flatten)]
+ pub crypto_scheme: CryptoSchemeFlag,
+}
+
+impl InsertKeyCmd {
+ /// Run the command
+ pub fn run(&self, cli: &C) -> Result<(), Error> {
+ let suri = utils::read_uri(self.suri.as_ref())?;
+ let base_path = self.shared_params
+ .base_path()
+ .unwrap_or_else(|| BasePath::from_project("", "", &C::executable_name()));
+ let chain_id = self.shared_params.chain_id(self.shared_params.is_dev());
+ let chain_spec = cli.load_spec(&chain_id)?;
+ let config_dir = base_path.config_dir(chain_spec.id());
+
+ let (keystore, public) = match self.keystore_params.keystore_config(&config_dir)? {
+ (_, KeystoreConfig::Path { path, password }) => {
+ let public = with_crypto_scheme!(
+ self.crypto_scheme.scheme,
+ to_vec(&suri, password.clone())
+ )?;
+ let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::open(path, password)?);
+ (keystore, public)
+ },
+ _ => unreachable!("keystore_config always returns path and password; qed")
+ };
+
+ let key_type = KeyTypeId::try_from(self.key_type.as_str()).map_err(|_| Error::KeyTypeInvalid)?;
+
+ SyncCryptoStore::insert_unknown(&*keystore, key_type, &suri, &public[..])
+ .map_err(|_| Error::KeyStoreOperation)?;
+
+ Ok(())
+ }
+}
+
+fn to_vec(uri: &str, pass: Option) -> Result, Error> {
+ let p = utils::pair_from_suri::(uri, pass)?;
+ Ok(p.public().as_ref().to_vec())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use structopt::StructOpt;
+ use tempfile::TempDir;
+ use sp_core::{sr25519::Pair, Pair as _, Public};
+ use sc_service::{ChainSpec, GenericChainSpec, ChainType, NoExtension};
+
+ struct Cli;
+
+ impl SubstrateCli for Cli {
+ fn impl_name() -> String {
+ "test".into()
+ }
+
+ fn impl_version() -> String {
+ "2.0".into()
+ }
+
+ fn description() -> String {
+ "test".into()
+ }
+
+ fn support_url() -> String {
+ "test.test".into()
+ }
+
+ fn copyright_start_year() -> i32 {
+ 2020
+ }
+
+ fn author() -> String {
+ "test".into()
+ }
+
+ fn native_runtime_version(_: &Box) -> &'static sp_version::RuntimeVersion {
+ unimplemented!("Not required in tests")
+ }
+
+ fn load_spec(&self, _: &str) -> std::result::Result, String> {
+ Ok(
+ Box::new(
+ GenericChainSpec::from_genesis(
+ "test",
+ "test_id",
+ ChainType::Development,
+ || unimplemented!("Not required in tests"),
+ Vec::new(),
+ None,
+ None,
+ None,
+ NoExtension::None,
+ ),
+ ),
+ )
+ }
+ }
+
+ #[test]
+ fn insert_with_custom_base_path() {
+ let path = TempDir::new().unwrap();
+ let path_str = format!("{}", path.path().display());
+ let (key, uri, _) = Pair::generate_with_phrase(None);
+
+ let inspect = InsertKeyCmd::from_iter(
+ &["insert-key", "-d", &path_str, "--key-type", "test", "--suri", &uri],
+ );
+ assert!(inspect.run(&Cli).is_ok());
+
+ let keystore = LocalKeystore::open(
+ path.path().join("chains").join("test_id").join("keystore"),
+ None,
+ ).unwrap();
+ assert!(keystore.has_keys(&[(key.public().to_raw_vec(), KeyTypeId(*b"test"))]));
+ }
+}
diff --git a/client/cli/src/commands/inspect_key.rs b/client/cli/src/commands/inspect_key.rs
index fb3a7ef4f3b4413856ac738abc639d98f10378bc..2642eee88adcdd944b7b3a160417a99841eb433a 100644
--- a/client/cli/src/commands/inspect_key.rs
+++ b/client/cli/src/commands/inspect_key.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/client/cli/src/commands/inspect_node_key.rs b/client/cli/src/commands/inspect_node_key.rs
index be0b88589d5e9dfd2cc84d0a543ba2ccb4cd836f..4db32aefb5fbb51f1cb8e3719f8900e54dc8b275 100644
--- a/client/cli/src/commands/inspect_node_key.rs
+++ b/client/cli/src/commands/inspect_node_key.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/client/cli/src/commands/key.rs b/client/cli/src/commands/key.rs
index e5bce08145cb8bd482b1b150b81be8e3b2a1b5e2..546454159718d6da5f76de6029dd612e6fa14020 100644
--- a/client/cli/src/commands/key.rs
+++ b/client/cli/src/commands/key.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,11 +17,11 @@
//! Key related CLI utilities
-use crate::Error;
+use crate::{Error, SubstrateCli};
use structopt::StructOpt;
use super::{
- insert::InsertCmd,
+ insert_key::InsertKeyCmd,
inspect_key::InspectKeyCmd,
generate::GenerateCmd,
inspect_node_key::InspectNodeKeyCmd,
@@ -45,17 +45,17 @@ pub enum KeySubcommand {
InspectNodeKey(InspectNodeKeyCmd),
/// Insert a key to the keystore of a node.
- Insert(InsertCmd),
+ Insert(InsertKeyCmd),
}
impl KeySubcommand {
/// run the key subcommands
- pub fn run(&self) -> Result<(), Error> {
+ pub fn run(&self, cli: &C) -> Result<(), Error> {
match self {
KeySubcommand::GenerateNodeKey(cmd) => cmd.run(),
KeySubcommand::Generate(cmd) => cmd.run(),
KeySubcommand::InspectKey(cmd) => cmd.run(),
- KeySubcommand::Insert(cmd) => cmd.run(),
+ KeySubcommand::Insert(cmd) => cmd.run(cli),
KeySubcommand::InspectNodeKey(cmd) => cmd.run(),
}
}
diff --git a/client/cli/src/commands/mod.rs b/client/cli/src/commands/mod.rs
index 9867f61cd277fc626144d5ba8d3aedbe73032c3e..8c0d6acd6a51159bc6ec83fe275895ff44a34a51 100644
--- a/client/cli/src/commands/mod.rs
+++ b/client/cli/src/commands/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -28,7 +28,7 @@ mod revert_cmd;
mod run_cmd;
mod generate_node_key;
mod generate;
-mod insert;
+mod insert_key;
mod inspect_node_key;
mod inspect_key;
mod key;
@@ -43,7 +43,7 @@ pub use self::{
purge_chain_cmd::PurgeChainCmd,
sign::SignCmd,
generate::GenerateCmd,
- insert::InsertCmd,
+ insert_key::InsertKeyCmd,
inspect_key::InspectKeyCmd,
generate_node_key::GenerateNodeKeyCmd,
inspect_node_key::InspectNodeKeyCmd,
diff --git a/client/cli/src/commands/purge_chain_cmd.rs b/client/cli/src/commands/purge_chain_cmd.rs
index 9c9c6e91fb2416c56e8a6e9a3894a8a7aeb31c10..1902d92e6345ad166c557e21012097040a2ab71c 100644
--- a/client/cli/src/commands/purge_chain_cmd.rs
+++ b/client/cli/src/commands/purge_chain_cmd.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/commands/revert_cmd.rs b/client/cli/src/commands/revert_cmd.rs
index b2e3c1bf8e2b674e4313253aa6abd2431701d587..2745ce2c652417b53bbadb90ace51e2cf9d207fd 100644
--- a/client/cli/src/commands/revert_cmd.rs
+++ b/client/cli/src/commands/revert_cmd.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs
index 48bad16afb677336772990404841ed1f9f08d1b9..bbb8d6f68d7f97e162efbac1b201a2d49e069407 100644
--- a/client/cli/src/commands/run_cmd.rs
+++ b/client/cli/src/commands/run_cmd.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/commands/sign.rs b/client/cli/src/commands/sign.rs
index 605fd5b12313f0c75fee8eef4951fafe9ee9f680..a39e14697b9956bf577c601b72969e265ba9184f 100644
--- a/client/cli/src/commands/sign.rs
+++ b/client/cli/src/commands/sign.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/commands/utils.rs b/client/cli/src/commands/utils.rs
index 25c7294fd1e0afa906338c85e3f6e8183da25e9a..1bbff392eca435b902729f725a912ee65c69d012 100644
--- a/client/cli/src/commands/utils.rs
+++ b/client/cli/src/commands/utils.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/commands/vanity.rs b/client/cli/src/commands/vanity.rs
index 33b9025c13fbc2e8e3c82a20205ba97ac7a74c5b..da47e8bb26cc870b1eea88048894b3cd2efeef47 100644
--- a/client/cli/src/commands/vanity.rs
+++ b/client/cli/src/commands/vanity.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/commands/verify.rs b/client/cli/src/commands/verify.rs
index 15abc04002f4c891d9be4f655e6915c6b7d28780..f5bd5a06060c6add64815e52d656de5f7d5038f8 100644
--- a/client/cli/src/commands/verify.rs
+++ b/client/cli/src/commands/verify.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/config.rs b/client/cli/src/config.rs
index 4e1ad19fc46f57569459965b26de22681c82e3d8..017d2b421683fd2357b03daacb9cc77a63ffa486 100644
--- a/client/cli/src/config.rs
+++ b/client/cli/src/config.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -22,7 +22,7 @@ use crate::arg_enums::Database;
use crate::error::Result;
use crate::{
init_logger, DatabaseParams, ImportParams, KeystoreParams, NetworkParams, NodeKeyParams,
- OffchainWorkerParams, PruningParams, SharedParams, SubstrateCli,
+ OffchainWorkerParams, PruningParams, SharedParams, SubstrateCli, InitLoggerParams,
};
use log::warn;
use names::{Generator, Name};
@@ -186,11 +186,11 @@ pub trait CliConfiguration: Sized {
/// Get the keystore configuration.
///
- /// Bu default this is retrieved from `KeystoreParams` if it is available. Otherwise it uses
+ /// By default this is retrieved from `KeystoreParams` if it is available. Otherwise it uses
/// `KeystoreConfig::InMemory`.
- fn keystore_config(&self, base_path: &PathBuf) -> Result<(Option, KeystoreConfig)> {
+ fn keystore_config(&self, config_dir: &PathBuf) -> Result<(Option, KeystoreConfig)> {
self.keystore_params()
- .map(|x| x.keystore_config(base_path))
+ .map(|x| x.keystore_config(config_dir))
.unwrap_or_else(|| Ok((None, KeystoreConfig::InMemory)))
}
@@ -454,15 +454,11 @@ pub trait CliConfiguration: Sized {
) -> Result {
let is_dev = self.is_dev()?;
let chain_id = self.chain_id(is_dev)?;
- let chain_spec = cli.load_spec(chain_id.as_str())?;
+ let chain_spec = cli.load_spec(&chain_id)?;
let base_path = self
.base_path()?
.unwrap_or_else(|| BasePath::from_project("", "", &C::executable_name()));
- let config_dir = base_path
- .path()
- .to_path_buf()
- .join("chains")
- .join(chain_spec.id());
+ let config_dir = base_path.config_dir(chain_spec.id());
let net_config_dir = config_dir.join(DEFAULT_NETWORK_CONFIG_PATH);
let client_id = C::client_id();
let database_cache_size = self.database_cache_size()?.unwrap_or(128);
@@ -542,6 +538,11 @@ pub trait CliConfiguration: Sized {
Ok(self.shared_params().is_log_filter_reloading_disabled())
}
+ /// Should the log color output be disabled?
+ fn disable_log_color(&self) -> Result {
+ Ok(self.shared_params().disable_log_color())
+ }
+
/// Initialize substrate. This must be done only once per process.
///
/// This method:
@@ -554,15 +555,17 @@ pub trait CliConfiguration: Sized {
let tracing_receiver = self.tracing_receiver()?;
let tracing_targets = self.tracing_targets()?;
let disable_log_reloading = self.is_log_filter_reloading_disabled()?;
+ let disable_log_color = self.disable_log_color()?;
sp_panic_handler::set(&C::support_url(), &C::impl_version());
- init_logger(
- &logger_pattern,
+ init_logger(InitLoggerParams {
+ pattern: logger_pattern,
tracing_receiver,
tracing_targets,
disable_log_reloading,
- )?;
+ disable_log_color,
+ })?;
if let Some(new_limit) = fdlimit::raise_fd_limit() {
if new_limit < RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT {
diff --git a/client/cli/src/error.rs b/client/cli/src/error.rs
index 5190cae2c2ff89edc1b9a3916afe428c3969f51a..75867e2f76b280992b43ee1485515f739abee3df 100644
--- a/client/cli/src/error.rs
+++ b/client/cli/src/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -59,9 +59,6 @@ pub enum Error {
expected: usize,
},
- #[error("The base path is missing, please provide one")]
- MissingBasePath,
-
#[error("Unknown key type, must be a known 4-character sequence")]
KeyTypeInvalid,
diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs
index 80882924bd3ad2c67a2e16aba571c5a58bc46640..1402e5e7ae44c64d3e92f8a9c30da49311c78b41 100644
--- a/client/cli/src/lib.rs
+++ b/client/cli/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -112,10 +112,7 @@ pub trait SubstrateCli: Sized {
///
/// Gets the struct from the command line arguments. Print the
/// error message and quit the program in case of failure.
- fn from_args() -> Self
- where
- Self: StructOpt + Sized,
- {
+ fn from_args() -> Self where Self: StructOpt + Sized {
::from_iter(&mut std::env::args_os())
}
@@ -240,30 +237,50 @@ pub trait SubstrateCli: Sized {
fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion;
}
+/// The parameters for [`init_logger`].
+#[derive(Default)]
+pub struct InitLoggerParams {
+ /// A comma seperated list of logging patterns.
+ ///
+ /// E.g.: `test-crate=debug`
+ pub pattern: String,
+ /// The tracing receiver.
+ pub tracing_receiver: sc_tracing::TracingReceiver,
+ /// Optional comma seperated list of tracing targets.
+ pub tracing_targets: Option,
+ /// Should log reloading be disabled?
+ pub disable_log_reloading: bool,
+ /// Should the log color output be disabled?
+ pub disable_log_color: bool,
+}
+
/// Initialize the global logger
///
/// This sets various global logging and tracing instances and thus may only be called once.
pub fn init_logger(
- pattern: &str,
- tracing_receiver: sc_tracing::TracingReceiver,
- profiling_targets: Option,
- disable_log_reloading: bool,
+ InitLoggerParams {
+ pattern,
+ tracing_receiver,
+ tracing_targets,
+ disable_log_reloading,
+ disable_log_color,
+ }: InitLoggerParams,
) -> std::result::Result<(), String> {
use sc_tracing::parse_default_directive;
// Accept all valid directives and print invalid ones
- fn parse_user_directives(mut env_filter: EnvFilter, dirs: &str) -> std::result::Result {
+ fn parse_user_directives(
+ mut env_filter: EnvFilter,
+ dirs: &str,
+ ) -> std::result::Result {
for dir in dirs.split(',') {
env_filter = env_filter.add_directive(parse_default_directive(&dir)?);
}
Ok(env_filter)
}
- if let Err(e) = tracing_log::LogTracer::init() {
- return Err(format!(
- "Registering Substrate logger failed: {:}!", e
- ))
- }
+ tracing_log::LogTracer::init()
+ .map_err(|e| format!("Registering Substrate logger failed: {:}!", e))?;
// Initialize filter - ensure to use `parse_default_directive` for any defaults to persist
// after log filter reloading by RPC
@@ -293,7 +310,7 @@ pub fn init_logger(
if pattern != "" {
// We're not sure if log or tracing is available at this moment, so silently ignore the
// parse error.
- env_filter = parse_user_directives(env_filter, pattern)?;
+ env_filter = parse_user_directives(env_filter, &pattern)?;
}
// If we're only logging `INFO` entries then we'll use a simplified logging format.
@@ -311,11 +328,11 @@ pub fn init_logger(
);
// Make sure to include profiling targets in the filter
- if let Some(profiling_targets) = profiling_targets.clone() {
- env_filter = parse_user_directives(env_filter, &profiling_targets)?;
+ if let Some(tracing_targets) = tracing_targets.clone() {
+ env_filter = parse_user_directives(env_filter, &tracing_targets)?;
}
- let enable_color = atty::is(atty::Stream::Stderr);
+ let enable_color = atty::is(atty::Stream::Stderr) && !disable_log_color;
let timer = ChronoLocal::with_format(if simple {
"%Y-%m-%d %H:%M:%S".to_string()
} else {
@@ -336,7 +353,7 @@ pub fn init_logger(
let subscriber = subscriber_builder
.finish()
.with(logging::NodeNameLayer);
- initialize_tracing(subscriber, tracing_receiver, profiling_targets)
+ initialize_tracing(subscriber, tracing_receiver, tracing_targets)
} else {
let subscriber_builder = subscriber_builder.with_filter_reloading();
let handle = subscriber_builder.reload_handle();
@@ -344,7 +361,7 @@ pub fn init_logger(
let subscriber = subscriber_builder
.finish()
.with(logging::NodeNameLayer);
- initialize_tracing(subscriber, tracing_receiver, profiling_targets)
+ initialize_tracing(subscriber, tracing_receiver, tracing_targets)
}
}
@@ -383,7 +400,9 @@ mod tests {
#[test]
fn test_logger_filters() {
let test_pattern = "afg=debug,sync=trace,client=warn,telemetry,something-with-dash=error";
- init_logger(&test_pattern, Default::default(), Default::default(), false).unwrap();
+ init_logger(
+ InitLoggerParams { pattern: test_pattern.into(), ..Default::default() },
+ ).unwrap();
tracing::dispatcher::get_default(|dispatcher| {
let test_filter = |target, level| {
@@ -442,7 +461,9 @@ mod tests {
fn log_something_with_dash_target_name() {
if env::var("ENABLE_LOGGING").is_ok() {
let test_pattern = "test-target=info";
- init_logger(&test_pattern, Default::default(), Default::default(), false).unwrap();
+ init_logger(
+ InitLoggerParams { pattern: test_pattern.into(), ..Default::default() },
+ ).unwrap();
log::info!(target: "test-target", "{}", EXPECTED_LOG_MESSAGE);
}
@@ -478,7 +499,9 @@ mod tests {
fn prefix_in_log_lines_entrypoint() {
if env::var("ENABLE_LOGGING").is_ok() {
let test_pattern = "test-target=info";
- init_logger(&test_pattern, Default::default(), Default::default(), false).unwrap();
+ init_logger(
+ InitLoggerParams { pattern: test_pattern.into(), ..Default::default() },
+ ).unwrap();
prefix_in_log_lines_process();
}
}
@@ -494,7 +517,7 @@ mod tests {
#[test]
fn do_not_write_with_colors_on_tty_entrypoint() {
if env::var("ENABLE_LOGGING").is_ok() {
- init_logger("", Default::default(), Default::default(), false).unwrap();
+ init_logger(InitLoggerParams::default()).unwrap();
log::info!("{}", ansi_term::Colour::Yellow.paint(EXPECTED_LOG_MESSAGE));
}
}
diff --git a/client/cli/src/params/database_params.rs b/client/cli/src/params/database_params.rs
index 24b23f6076a02302071c76a6da614c8e5c11e6a0..21529f65a56b0b76f6557d31a89e2adb66b4053f 100644
--- a/client/cli/src/params/database_params.rs
+++ b/client/cli/src/params/database_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs
index 376a72b8421f5446e4ccdfae606145478d329c73..7409dbf79dc0f7b1db5d08bc343ec1e4fbe0c5a5 100644
--- a/client/cli/src/params/import_params.rs
+++ b/client/cli/src/params/import_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/params/keystore_params.rs b/client/cli/src/params/keystore_params.rs
index f03fafeb965c0bb3489972816bd7adc18192b48e..d75cdebc5a56839db2a9104a12da7fc8f346825e 100644
--- a/client/cli/src/params/keystore_params.rs
+++ b/client/cli/src/params/keystore_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -18,8 +18,7 @@
use crate::error::Result;
use sc_service::config::KeystoreConfig;
-use std::fs;
-use std::path::PathBuf;
+use std::{fs, path::{PathBuf, Path}};
use structopt::StructOpt;
use crate::error;
use sp_core::crypto::SecretString;
@@ -33,6 +32,7 @@ pub struct KeystoreParams {
/// Specify custom URIs to connect to for keystore-services
#[structopt(long = "keystore-uri")]
pub keystore_uri: Option,
+
/// Specify custom keystore path.
#[structopt(long = "keystore-path", value_name = "PATH", parse(from_os_str))]
pub keystore_path: Option,
@@ -64,15 +64,14 @@ pub struct KeystoreParams {
/// Parse a sercret string, returning a displayable error.
pub fn secret_string_from_str(s: &str) -> std::result::Result {
- Ok(std::str::FromStr::from_str(s)
- .map_err(|_e| "Could not get SecretString".to_string())?)
+ std::str::FromStr::from_str(s).map_err(|_| "Could not get SecretString".to_string())
}
impl KeystoreParams {
/// Get the keystore configuration for the parameters
- /// returns a vector of remote-urls and the local Keystore configuration
- pub fn keystore_config(&self, base_path: &PathBuf) -> Result<(Option, KeystoreConfig)> {
-
+ ///
+ /// Returns a vector of remote-urls and the local Keystore configuration
+ pub fn keystore_config(&self, config_dir: &Path) -> Result<(Option, KeystoreConfig)> {
let password = if self.password_interactive {
#[cfg(not(target_os = "unknown"))]
{
@@ -92,7 +91,7 @@ impl KeystoreParams {
let path = self
.keystore_path
.clone()
- .unwrap_or_else(|| base_path.join(DEFAULT_KEYSTORE_CONFIG_PATH));
+ .unwrap_or_else(|| config_dir.join(DEFAULT_KEYSTORE_CONFIG_PATH));
Ok((self.keystore_uri.clone(), KeystoreConfig::Path { path, password }))
}
diff --git a/client/cli/src/params/mod.rs b/client/cli/src/params/mod.rs
index 93467bc8ec63778e95d116b57cf8b6dc92c12636..8308b123f71f3c5e83fa709cf4ddbc9d910df132 100644
--- a/client/cli/src/params/mod.rs
+++ b/client/cli/src/params/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/params/network_params.rs b/client/cli/src/params/network_params.rs
index a973d61272ced7c47c65121f50e6c18054cc3416..2040bd9bc78ed9c45550c69ec8e61d7c380d6be9 100644
--- a/client/cli/src/params/network_params.rs
+++ b/client/cli/src/params/network_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/params/node_key_params.rs b/client/cli/src/params/node_key_params.rs
index 875411fbfb62000d3e8c5bfc00cce52d3082fa04..d43c87804dd3ba1404e5a3753effa5e3a63e8b09 100644
--- a/client/cli/src/params/node_key_params.rs
+++ b/client/cli/src/params/node_key_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/params/offchain_worker_params.rs b/client/cli/src/params/offchain_worker_params.rs
index f8d48edc4729d5f97e4f389fe78dd3cd794423b9..ef39a1ed41be26bb8f94e5391fbcff1d62006f7f 100644
--- a/client/cli/src/params/offchain_worker_params.rs
+++ b/client/cli/src/params/offchain_worker_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/params/pruning_params.rs b/client/cli/src/params/pruning_params.rs
index 7db808e6d8f2f8e249ff0e057a05297bfcf92a72..80118cafd8769b40c2dc4204b8b4b9de9bb9dbcf 100644
--- a/client/cli/src/params/pruning_params.rs
+++ b/client/cli/src/params/pruning_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/params/shared_params.rs b/client/cli/src/params/shared_params.rs
index 52b1488ea9ccdf9383f2dd6222a478e9b3528fb4..45ce41846bf120319e3b2952ae112340938b3ac4 100644
--- a/client/cli/src/params/shared_params.rs
+++ b/client/cli/src/params/shared_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -46,6 +46,10 @@ pub struct SharedParams {
#[structopt(short = "l", long, value_name = "LOG_PATTERN")]
pub log: Vec,
+ /// Disable log color output.
+ #[structopt(long)]
+ pub disable_log_color: bool,
+
/// Disable feature to dynamically update and reload the log filter.
///
/// By default this feature is enabled, however it leads to a small performance decrease.
@@ -99,6 +103,11 @@ impl SharedParams {
&self.log
}
+ /// Should the log color output be disabled?
+ pub fn disable_log_color(&self) -> bool {
+ self.disable_log_color
+ }
+
/// Is log reloading disabled
pub fn is_log_filter_reloading_disabled(&self) -> bool {
self.disable_log_reloading
diff --git a/client/cli/src/params/transaction_pool_params.rs b/client/cli/src/params/transaction_pool_params.rs
index 3ad278426922ec99ccc42e192cbda9db1d04207b..bf0ed53e531c9745dcd8351b9edebd0a55808997 100644
--- a/client/cli/src/params/transaction_pool_params.rs
+++ b/client/cli/src/params/transaction_pool_params.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/cli/src/runner.rs b/client/cli/src/runner.rs
index e6d35282ada2b491cacbe2b9a112b5cba82bd968..9836471fb9fa2ddd413aeb2c76d7df677a2d8ca3 100644
--- a/client/cli/src/runner.rs
+++ b/client/cli/src/runner.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/aura/src/digests.rs b/client/consensus/aura/src/digests.rs
index 3332e4c6a6dff99f2ee9ad367031fde15a33ada6..fec412b62d1eaf3b38f696a12510fdeeab31832f 100644
--- a/client/consensus/aura/src/digests.rs
+++ b/client/consensus/aura/src/digests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs
index 246b39771277d3e54bc95db097e852a99447e68e..60aad59e8f971a85f53bbe330a91bebdbe3e658b 100644
--- a/client/consensus/aura/src/lib.rs
+++ b/client/consensus/aura/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/babe/rpc/src/lib.rs b/client/consensus/babe/rpc/src/lib.rs
index a90964cdf73f71860365d08a8f4067939e5dfea5..4d5c091e0cbbd88add7aa93d17aeef63e418a790 100644
--- a/client/consensus/babe/rpc/src/lib.rs
+++ b/client/consensus/babe/rpc/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/babe/src/authorship.rs b/client/consensus/babe/src/authorship.rs
index 28a3692958e180430ba7a847505bdac5c68a8e0a..90ad12c4558c828cab7610b61c497ccabac9a361 100644
--- a/client/consensus/babe/src/authorship.rs
+++ b/client/consensus/babe/src/authorship.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! BABE authority selection and slot claiming.
diff --git a/client/consensus/babe/src/aux_schema.rs b/client/consensus/babe/src/aux_schema.rs
index 287121566a417247b835a6c8be55c781ecafb304..d399a12ea8a5b63f6d9c1c6da8235ea3a0a56475 100644
--- a/client/consensus/babe/src/aux_schema.rs
+++ b/client/consensus/babe/src/aux_schema.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Schema for BABE epoch changes in the aux-db.
diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs
index 3f2a583482afb5d7486f44e0f6c45b7e0f5d6111..ea3ca29dad0e09011558475cb4d437e42bdd5eb1 100644
--- a/client/consensus/babe/src/lib.rs
+++ b/client/consensus/babe/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! # BABE (Blind Assignment for Blockchain Extension)
//!
@@ -342,6 +344,11 @@ impl Config {
}
}
}
+
+ /// Get the inner slot duration, in milliseconds.
+ pub fn slot_duration(&self) -> u64 {
+ self.0.slot_duration()
+ }
}
impl std::ops::Deref for Config {
diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs
index 6e0536c85ced76ff1242361e2ab4b4205a990642..82d8f9de5af02e12311e33afa0a02c789d789a6e 100644
--- a/client/consensus/babe/src/tests.rs
+++ b/client/consensus/babe/src/tests.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! BABE testsuite
diff --git a/client/consensus/babe/src/verification.rs b/client/consensus/babe/src/verification.rs
index fd3c27be4f34ef9bb00ba1ef12a4215d0e2a313d..47c4da0834d096c55c0cdf7c11b5e9c492ecd572 100644
--- a/client/consensus/babe/src/verification.rs
+++ b/client/consensus/babe/src/verification.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Verification for BABE headers.
use sp_runtime::{traits::Header, traits::DigestItemFor};
diff --git a/client/consensus/common/src/lib.rs b/client/consensus/common/src/lib.rs
index 1d9b072cfe964f168ac471b2bfcf3cac29009048..a53517c5c35ead9aa8d11c9280972564025251a2 100644
--- a/client/consensus/common/src/lib.rs
+++ b/client/consensus/common/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Collection of common consensus specific implementations
mod longest_chain;
diff --git a/client/consensus/common/src/longest_chain.rs b/client/consensus/common/src/longest_chain.rs
index 981dbad0f607029671b7ad858f2327578fa24e94..8cf32a1dbd3c1587ea61dd9bb3fb23b40c71ddad 100644
--- a/client/consensus/common/src/longest_chain.rs
+++ b/client/consensus/common/src/longest_chain.rs
@@ -1,18 +1,21 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
+
//! Longest chain implementation
use std::sync::Arc;
@@ -98,4 +101,4 @@ impl SelectChain for LongestChain
self.backend.blockchain().best_containing(target_hash, maybe_max_number, import_lock)
.map_err(|e| ConsensusError::ChainLookup(e.to_string()).into())
}
-}
\ No newline at end of file
+}
diff --git a/client/consensus/epochs/src/lib.rs b/client/consensus/epochs/src/lib.rs
index acb07dd668a3c4f3b2c7a2350451d9ac93008926..76e8c8ed5419d3d013407d15648329978449358d 100644
--- a/client/consensus/epochs/src/lib.rs
+++ b/client/consensus/epochs/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Generic utilities for epoch-based consensus engines.
diff --git a/client/consensus/epochs/src/migration.rs b/client/consensus/epochs/src/migration.rs
index e4717b5584e0ec67801ce3d264e90ff350286deb..6e7baba8053af65bfa06cd983b675b90e851d870 100644
--- a/client/consensus/epochs/src/migration.rs
+++ b/client/consensus/epochs/src/migration.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Migration types for epoch changes.
diff --git a/client/consensus/manual-seal/src/consensus.rs b/client/consensus/manual-seal/src/consensus.rs
index 7bafeb50207d486f93055c20e5bfe2649586e743..0cfd99cab5c99419c219b2a6483efa2a30299780 100644
--- a/client/consensus/manual-seal/src/consensus.rs
+++ b/client/consensus/manual-seal/src/consensus.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/manual-seal/src/consensus/babe.rs b/client/consensus/manual-seal/src/consensus/babe.rs
index c2fdf6243c30407504a74b0aba4fd370b9595e3d..1566b647f2c01556acf9a1bc3388c4aaa406eecf 100644
--- a/client/consensus/manual-seal/src/consensus/babe.rs
+++ b/client/consensus/manual-seal/src/consensus/babe.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/manual-seal/src/error.rs b/client/consensus/manual-seal/src/error.rs
index e2628008c24c7c2a3c203af47c0088ea635d13b5..77140c835a3eea86c651f841de8b3c03ca25630a 100644
--- a/client/consensus/manual-seal/src/error.rs
+++ b/client/consensus/manual-seal/src/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/manual-seal/src/finalize_block.rs b/client/consensus/manual-seal/src/finalize_block.rs
index 5780a25f97256331eb1d11b2370dd838ec112ac7..76ae6eeeae5aceebab426be0af8c7f66f13c3aa5 100644
--- a/client/consensus/manual-seal/src/finalize_block.rs
+++ b/client/consensus/manual-seal/src/finalize_block.rs
@@ -1,18 +1,20 @@
-// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Block finalization utilities
diff --git a/client/consensus/manual-seal/src/lib.rs b/client/consensus/manual-seal/src/lib.rs
index 9c4465f82fda1ef57e2e18be6ba88be05518531a..5bf08571195d2b501b6850192ca1e85c3e3ab292 100644
--- a/client/consensus/manual-seal/src/lib.rs
+++ b/client/consensus/manual-seal/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/manual-seal/src/rpc.rs b/client/consensus/manual-seal/src/rpc.rs
index 690b6c1eb9996d086d0a2397b00cdc2c1d5145d0..293d4487a5d5972adacb9c00482868ee90cf4135 100644
--- a/client/consensus/manual-seal/src/rpc.rs
+++ b/client/consensus/manual-seal/src/rpc.rs
@@ -1,18 +1,20 @@
-// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! RPC interface for the `ManualSeal` Engine.
diff --git a/client/consensus/manual-seal/src/seal_block.rs b/client/consensus/manual-seal/src/seal_block.rs
index a4afaa343e9052561204a60cadf731907c863c73..59b99349bf9b2a6b6834d6d8f166be8738bfbd95 100644
--- a/client/consensus/manual-seal/src/seal_block.rs
+++ b/client/consensus/manual-seal/src/seal_block.rs
@@ -1,18 +1,20 @@
-// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Block sealing utilities
diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs
index e353ed6358a00fc94f5069bbeff356ba93347cd6..975a6f17e795f34106448f77518ec2c3b2261ed0 100644
--- a/client/consensus/pow/src/lib.rs
+++ b/client/consensus/pow/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/pow/src/worker.rs b/client/consensus/pow/src/worker.rs
index 4ed863dcd9ed986e6045ac1a96061a03b030a3b7..c19c5524d9774cf84863845ed911c8a8e160d5c4 100644
--- a/client/consensus/pow/src/worker.rs
+++ b/client/consensus/pow/src/worker.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/consensus/slots/build.rs b/client/consensus/slots/build.rs
index 513cc234d4363a854961db1efdea1cbc7007ce56..57424f016f3e520e98345432cc105469a43efefc 100644
--- a/client/consensus/slots/build.rs
+++ b/client/consensus/slots/build.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use std::env;
diff --git a/client/consensus/slots/src/aux_schema.rs b/client/consensus/slots/src/aux_schema.rs
index 1f1fe37068f82b2fef9c789bf0877068d0b1d0c3..c8095f238ec8cefb9235c314650189d61787bfab 100644
--- a/client/consensus/slots/src/aux_schema.rs
+++ b/client/consensus/slots/src/aux_schema.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Schema for slots in the aux-db.
diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs
index 571766bc44b1ae3c584f384fd7872ff4c4c535e4..93d3614584f8f2b196afa4c107fb385d07a2adb1 100644
--- a/client/consensus/slots/src/lib.rs
+++ b/client/consensus/slots/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Slots functionality for Substrate.
//!
diff --git a/client/consensus/slots/src/slots.rs b/client/consensus/slots/src/slots.rs
index e7c84a2c1fd283e437566a342e62cb3c75fe4e3f..0c93e16461ccb1c4783bdcce95bc06c5398b825b 100644
--- a/client/consensus/slots/src/slots.rs
+++ b/client/consensus/slots/src/slots.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Utility stream for yielding slots in a loop.
//!
diff --git a/client/consensus/uncles/src/lib.rs b/client/consensus/uncles/src/lib.rs
index 2a129b200063b97db9cd1bc8b3811d8b16abd75c..f38849300d0da2edf2a70cce0b6ff1c0556ddab1 100644
--- a/client/consensus/uncles/src/lib.rs
+++ b/client/consensus/uncles/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Uncles functionality for Substrate.
#![forbid(unsafe_code, missing_docs)]
diff --git a/client/db/src/bench.rs b/client/db/src/bench.rs
index 5696922b4fbb3006689a01f602c65554e81f8511..f0c187bd379f13071828e7fd337a82729dcb3e54 100644
--- a/client/db/src/bench.rs
+++ b/client/db/src/bench.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/cache/list_cache.rs b/client/db/src/cache/list_cache.rs
index 15ad339b1f2c1a387fd3e5dbac70eaef5df3a79b..341105b16a5b3f324fa35102a4e6085e8a6d1a78 100644
--- a/client/db/src/cache/list_cache.rs
+++ b/client/db/src/cache/list_cache.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/cache/list_entry.rs b/client/db/src/cache/list_entry.rs
index d14fab9274ccb830694082491b5f16bcf27ecf2b..94d4eb9f49b2739c3a0325da899c8a7b57dc3ad6 100644
--- a/client/db/src/cache/list_entry.rs
+++ b/client/db/src/cache/list_entry.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/cache/list_storage.rs b/client/db/src/cache/list_storage.rs
index 377d744effa60faf57521d2a490852ef757ce1bf..e4b3677b4ab310de91323f0a208ec6a327c57115 100644
--- a/client/db/src/cache/list_storage.rs
+++ b/client/db/src/cache/list_storage.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/cache/mod.rs b/client/db/src/cache/mod.rs
index 5501f0f1864c156745c6a3e63e4d8ced9a1cf25c..005d25b90f933491a7dde3a62ae7041a8c155a13 100644
--- a/client/db/src/cache/mod.rs
+++ b/client/db/src/cache/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/changes_tries_storage.rs b/client/db/src/changes_tries_storage.rs
index a2299a82337a05f58ec7ba8dc867270813cc4444..6233eab3ea396fa70cb114552ebff1de4dc4ca8d 100644
--- a/client/db/src/changes_tries_storage.rs
+++ b/client/db/src/changes_tries_storage.rs
@@ -1,18 +1,20 @@
-// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! DB-backed changes tries storage.
diff --git a/client/db/src/children.rs b/client/db/src/children.rs
index bfba797cd467bdbc3f7a1db5d23b7f97511b5be5..62352e6d0614aced3ca0fccee9c33b47a258befe 100644
--- a/client/db/src/children.rs
+++ b/client/db/src/children.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Functionality for reading and storing children hashes from db.
diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs
index e32e45a2f314aef92ba3615c4ec615d9156cf13e..e3b94b03c87d80696dcfb714f4d63aa59cda8dc2 100644
--- a/client/db/src/lib.rs
+++ b/client/db/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/light.rs b/client/db/src/light.rs
index acfb6217ce9e034dd66324e34642aa78eb0a8a95..91f37dd374d9f8912f40529cf1bbe89acc58288c 100644
--- a/client/db/src/light.rs
+++ b/client/db/src/light.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/offchain.rs b/client/db/src/offchain.rs
index c4f0ce115ca54f1453e857cc34b96fd26918f8a8..aead4397343ea32c23142988ad9c1b36e3d94780 100644
--- a/client/db/src/offchain.rs
+++ b/client/db/src/offchain.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/parity_db.rs b/client/db/src/parity_db.rs
index 313069706f33f5128004ada17d58ab241855227f..e56ca4de6cb78d028dd527ad098c1c5ee001f085 100644
--- a/client/db/src/parity_db.rs
+++ b/client/db/src/parity_db.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/stats.rs b/client/db/src/stats.rs
index 8d208024b4bb29a1f064dfc00f3fa14b8df07f85..3fd93db931d029fcb2a8da73fa75f674f6a5b438 100644
--- a/client/db/src/stats.rs
+++ b/client/db/src/stats.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs
index 292d3c5162601af1ee02a0463406e62895be4fd9..bbbc8413be797923549973b54b04358f944df12b 100644
--- a/client/db/src/storage_cache.rs
+++ b/client/db/src/storage_cache.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Global cache state.
diff --git a/client/db/src/upgrade.rs b/client/db/src/upgrade.rs
index 95592d071f777db07cf15e8e2765225f0756bfb2..e87b11b69660cae962f34fa9f11ec27ee602967b 100644
--- a/client/db/src/upgrade.rs
+++ b/client/db/src/upgrade.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Database upgrade logic.
diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs
index e999469c18ff0c96f40580f0ed1192aae5a5268a..dfc1e945b3a4cfa0c3e79e1713e9c99a0b33cf91 100644
--- a/client/db/src/utils.rs
+++ b/client/db/src/utils.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/common/src/error.rs b/client/executor/common/src/error.rs
index df0eaf8cc26101c7f611bf2f1ee46d07fd1fe6ee..0af148fd95809ef1d4c6de2f214fb647051d88a4 100644
--- a/client/executor/common/src/error.rs
+++ b/client/executor/common/src/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/common/src/lib.rs b/client/executor/common/src/lib.rs
index df839d4ab65232bc0552e18864fdc2ab16903c12..050bad27d6c3056a7510ce8dd1bbebfa942b87eb 100644
--- a/client/executor/common/src/lib.rs
+++ b/client/executor/common/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! A set of common definitions that are needed for defining execution engines.
diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs
index b2c35b758271829c8771034da08aee46c52dd3db..8ed294bb83983099f5363c4573d2fb0cb61529ba 100644
--- a/client/executor/common/src/sandbox.rs
+++ b/client/executor/common/src/sandbox.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs
index 564f9dadcbec691e1344872f330a30bd3c543740..5947be4469cd07211b54e82eb5aaacf7c59a4473 100644
--- a/client/executor/common/src/util.rs
+++ b/client/executor/common/src/util.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/common/src/wasm_runtime.rs b/client/executor/common/src/wasm_runtime.rs
index c407d9967cbf9839941772f17b9f75c74a89ea48..cca0d99c4b91cb5eee9e70cf033897d7a0465780 100644
--- a/client/executor/common/src/wasm_runtime.rs
+++ b/client/executor/common/src/wasm_runtime.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Definitions for a wasm runtime.
diff --git a/client/executor/runtime-test/build.rs b/client/executor/runtime-test/build.rs
index a83de21db7f0f387534d6feab29fbfc325474a90..9456d6bc90f4cf567d35a85765a9b0132233e2e9 100644
--- a/client/executor/runtime-test/build.rs
+++ b/client/executor/runtime-test/build.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use substrate_wasm_builder::WasmBuilder;
diff --git a/client/executor/src/integration_tests/mod.rs b/client/executor/src/integration_tests/mod.rs
index 0a00375145fbad9365532720ff68456ff308caea..5920d269c86e1f87586005f01919f1e63d609d8c 100644
--- a/client/executor/src/integration_tests/mod.rs
+++ b/client/executor/src/integration_tests/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/src/integration_tests/sandbox.rs b/client/executor/src/integration_tests/sandbox.rs
index 447e395c2fb084aa0644504138987a673c40614d..3c964c628046540bcc441d0a8eef700dea92d85a 100644
--- a/client/executor/src/integration_tests/sandbox.rs
+++ b/client/executor/src/integration_tests/sandbox.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/src/lib.rs b/client/executor/src/lib.rs
index 56a81b24b4076e39c1d66a7bc57058ae1dcd8e7d..ccb7aa1b445b222db65924526cfdf6e661017cb4 100644
--- a/client/executor/src/lib.rs
+++ b/client/executor/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/src/native_executor.rs b/client/executor/src/native_executor.rs
index b5d67b9e73f4226a1c20d637c3ad7cb0dc41ea87..766dada331cd1b866a4e41a81d56454d74503104 100644
--- a/client/executor/src/native_executor.rs
+++ b/client/executor/src/native_executor.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/src/wasm_runtime.rs b/client/executor/src/wasm_runtime.rs
index 7288df35f31c42b02a6f66f1dc4222a3f60f446d..a7d8b0ce2387ef18b415ddf68e4e3dfe429f5a98 100644
--- a/client/executor/src/wasm_runtime.rs
+++ b/client/executor/src/wasm_runtime.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Traits and accessor functions for calling into the Substrate Wasm runtime.
//!
diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs
index 17b92e04950c9766253af313a115073aed634690..e6a6ef3a61039e73b06e6909ca9bee765eb937f5 100644
--- a/client/executor/wasmi/src/lib.rs
+++ b/client/executor/wasmi/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! This crate provides an implementation of `WasmModule` that is baked by wasmi.
diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs
index 8d20c9a566dc8c5ad3300e4f50c8a3c4bdfdbdc4..c1eb77ff81f344728721405e316f3769783d255e 100644
--- a/client/executor/wasmtime/src/host.rs
+++ b/client/executor/wasmtime/src/host.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! This module defines `HostState` and `HostContext` structs which provide logic and state
//! required for execution of host.
diff --git a/client/executor/wasmtime/src/imports.rs b/client/executor/wasmtime/src/imports.rs
index add62df5cef45851451503ce2a00b3d2e537b45f..b5eaeae5e66cd51f1e0baa6f525430e17cd4cbe9 100644
--- a/client/executor/wasmtime/src/imports.rs
+++ b/client/executor/wasmtime/src/imports.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs
index 089d8cb237b56c42eb43e112d17dde718e6d94c3..2103ab9b7b98c463785aa6912f7e30576b825bd5 100644
--- a/client/executor/wasmtime/src/instance_wrapper.rs
+++ b/client/executor/wasmtime/src/instance_wrapper.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/wasmtime/src/instance_wrapper/globals_snapshot.rs b/client/executor/wasmtime/src/instance_wrapper/globals_snapshot.rs
index 42935d851d95c638b22d35693d7a47d5147356cc..a6b1ed394150d86f38c952563370a1d25508c239 100644
--- a/client/executor/wasmtime/src/instance_wrapper/globals_snapshot.rs
+++ b/client/executor/wasmtime/src/instance_wrapper/globals_snapshot.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/wasmtime/src/lib.rs b/client/executor/wasmtime/src/lib.rs
index 66e4e085235ac3adc2e4026679ec849d002ed94a..db7776d4c58455b7a9d1a571d8f30fbdf85477b8 100644
--- a/client/executor/wasmtime/src/lib.rs
+++ b/client/executor/wasmtime/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
///! Defines a `WasmRuntime` that uses the Wasmtime JIT to execute.
diff --git a/client/executor/wasmtime/src/runtime.rs b/client/executor/wasmtime/src/runtime.rs
index 965b0675357218902a50a1f8bb53e4721c7f5f35..a17a034918db74e6749e5bf4fb6102c8c365144c 100644
--- a/client/executor/wasmtime/src/runtime.rs
+++ b/client/executor/wasmtime/src/runtime.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Defines the compiled Wasm runtime that uses Wasmtime internally.
diff --git a/client/executor/wasmtime/src/state_holder.rs b/client/executor/wasmtime/src/state_holder.rs
index 711d3bb735d7c04306525ba451f1e4be84ed9d21..0e2684cd25130b8aaffa6280a01a6281b773b4b0 100644
--- a/client/executor/wasmtime/src/state_holder.rs
+++ b/client/executor/wasmtime/src/state_holder.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/executor/wasmtime/src/util.rs b/client/executor/wasmtime/src/util.rs
index d2de95d4cc7150d6ed8768ad48181ae9f9885cb4..1437c6f8509bf0350ce65f302002dd899a7d2f22 100644
--- a/client/executor/wasmtime/src/util.rs
+++ b/client/executor/wasmtime/src/util.rs
@@ -1,18 +1,20 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use std::ops::Range;
diff --git a/client/finality-grandpa/rpc/src/error.rs b/client/finality-grandpa/rpc/src/error.rs
index 6464acbe10ea076ed637d603fbf48692509fb8e6..6122db03f880517d7ae43fbd815a76e751562c68 100644
--- a/client/finality-grandpa/rpc/src/error.rs
+++ b/client/finality-grandpa/rpc/src/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/rpc/src/finality.rs b/client/finality-grandpa/rpc/src/finality.rs
index 1f288b86a0e469efefcbc7b826f23c527a8344fc..9272edb39b64d5ce58934bedff6ff8a111d2e83e 100644
--- a/client/finality-grandpa/rpc/src/finality.rs
+++ b/client/finality-grandpa/rpc/src/finality.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/rpc/src/lib.rs b/client/finality-grandpa/rpc/src/lib.rs
index 172473ad6518bc90e709f9bb24ebe98058fb89de..c6e4613c4f5153f58fce2d2bacbf966fb6a91c32 100644
--- a/client/finality-grandpa/rpc/src/lib.rs
+++ b/client/finality-grandpa/rpc/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/rpc/src/notification.rs b/client/finality-grandpa/rpc/src/notification.rs
index fd03a622b21967c723bcdfb67a56bd70ffd5cdd3..4c9141be3631ae4acd359da36ecc0e6a247bd11d 100644
--- a/client/finality-grandpa/rpc/src/notification.rs
+++ b/client/finality-grandpa/rpc/src/notification.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/rpc/src/report.rs b/client/finality-grandpa/rpc/src/report.rs
index a635728cb938adf73d4ae94e1db1a63d5fcb9f50..0482d90f58f0a0bf67001d570c77686440a9f969 100644
--- a/client/finality-grandpa/rpc/src/report.rs
+++ b/client/finality-grandpa/rpc/src/report.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/authorities.rs b/client/finality-grandpa/src/authorities.rs
index de14c7b3ba390ab64f687e7cf897130fd86d7c4b..62a23a7ceab847fc1460333d122eb0704d020d5f 100644
--- a/client/finality-grandpa/src/authorities.rs
+++ b/client/finality-grandpa/src/authorities.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/aux_schema.rs b/client/finality-grandpa/src/aux_schema.rs
index 97041f4081a720a35f9de0d0479f84a6071fd69b..0146269c8f71aa27e8fc44eb5b4042542ac214dc 100644
--- a/client/finality-grandpa/src/aux_schema.rs
+++ b/client/finality-grandpa/src/aux_schema.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Schema for stuff in the aux-db.
diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs
index 276529d555ffe062a12e79b8544cc3265272467e..c217218aecc4ff09502b0ea941aebb0ce9423a16 100644
--- a/client/finality-grandpa/src/communication/gossip.rs
+++ b/client/finality-grandpa/src/communication/gossip.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Gossip and politeness for polite-grandpa.
//!
diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs
index 29fe8bc7471a0b74ac91e41bd77ad0cef832617f..77d2d15e5d0209e89ba86dbb2697096f8619f279 100644
--- a/client/finality-grandpa/src/communication/mod.rs
+++ b/client/finality-grandpa/src/communication/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -846,7 +846,7 @@ fn check_catch_up(
}
Ok(())
- };
+ }
check_weight(
voters,
diff --git a/client/finality-grandpa/src/communication/periodic.rs b/client/finality-grandpa/src/communication/periodic.rs
index dadd7deb57fca1d34dd01baf0d434533f1a99fbe..377882ed5dd2d5d4bb2136fbd5314e0d557b890c 100644
--- a/client/finality-grandpa/src/communication/periodic.rs
+++ b/client/finality-grandpa/src/communication/periodic.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Periodic rebroadcast of neighbor packets.
diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs
index 27a394a062bc8b99eca9f6af6022f681238991f7..d7db68d0652b1d59db3d06f4838ba0a9ef12b051 100644
--- a/client/finality-grandpa/src/communication/tests.rs
+++ b/client/finality-grandpa/src/communication/tests.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Tests for the communication portion of the GRANDPA crate.
diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs
index 790be2a22178878dade0e4961193eade7703df41..5e4203b2a40f634ffd8a2179e8d1ff494ccfd402 100644
--- a/client/finality-grandpa/src/environment.rs
+++ b/client/finality-grandpa/src/environment.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/finality_proof.rs b/client/finality-grandpa/src/finality_proof.rs
index bf367ab3f4a55e4d6c5e7c06efec686abd46414a..bd29b18bae12a0f5201283d7080e0102e14896e3 100644
--- a/client/finality-grandpa/src/finality_proof.rs
+++ b/client/finality-grandpa/src/finality_proof.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/import.rs b/client/finality-grandpa/src/import.rs
index 89f9d0c16ad7c6d0b52fb8d08a46b5795d7bf646..d9630e272ef9c0345ce555fbea100cae00f9b5ea 100644
--- a/client/finality-grandpa/src/import.rs
+++ b/client/finality-grandpa/src/import.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -25,7 +25,7 @@ use parking_lot::RwLockWriteGuard;
use sp_blockchain::{BlockStatus, well_known_cache_keys};
use sc_client_api::{backend::Backend, utils::is_descendent_of};
use sp_utils::mpsc::TracingUnboundedSender;
-use sp_api::{TransactionFor};
+use sp_api::TransactionFor;
use sp_consensus::{
BlockImport, Error as ConsensusError,
diff --git a/client/finality-grandpa/src/justification.rs b/client/finality-grandpa/src/justification.rs
index d5ca92d50e9371cf76e80945b69edc3c3f9e3c13..9429acff06d8ce9f160bc78de66bf16032a79918 100644
--- a/client/finality-grandpa/src/justification.rs
+++ b/client/finality-grandpa/src/justification.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs
index 0757a484afb4a624ea35e93c5321907668ac691b..0c38d796197c398bfba578974c1ef1f35375535d 100644
--- a/client/finality-grandpa/src/lib.rs
+++ b/client/finality-grandpa/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/notification.rs b/client/finality-grandpa/src/notification.rs
index 8415583051902330a99f5c4cb723311045844ed8..b545f0d8a637e8948939e02e2c2d8003af624524 100644
--- a/client/finality-grandpa/src/notification.rs
+++ b/client/finality-grandpa/src/notification.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs
index c61998225e32300f542f256f70acdc0aa20102a7..c9db917e1699a89f11c816e6b8edbc7a4f54fc47 100644
--- a/client/finality-grandpa/src/observer.rs
+++ b/client/finality-grandpa/src/observer.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs
index 452b30941de5cb5f5ab9a4d86106df2af76dbc22..1ee71dddc4d4f6fb08e96ca18d3a6cc5e5af85fe 100644
--- a/client/finality-grandpa/src/tests.rs
+++ b/client/finality-grandpa/src/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -1068,7 +1068,7 @@ fn voter_persists_its_votes() {
drop(_block_import);
r
})
- };
+ }
runtime.spawn(alice_voter1);
@@ -1110,7 +1110,7 @@ fn voter_persists_its_votes() {
let runtime_handle = runtime_handle.clone();
async move {
- if state.compare_and_swap(0, 1, Ordering::SeqCst) == 0 {
+ if state.compare_exchange(0, 1, Ordering::SeqCst, Ordering::SeqCst).unwrap() == 0 {
// the first message we receive should be a prevote from alice.
let prevote = match signed.message {
finality_grandpa::Message::Prevote(prevote) => prevote,
@@ -1156,7 +1156,7 @@ fn voter_persists_its_votes() {
// we send in a loop including a delay until items are received, this can be
// ignored for the sake of reduced complexity.
Pin::new(&mut *round_tx.lock()).start_send(finality_grandpa::Message::Prevote(prevote)).unwrap();
- } else if state.compare_and_swap(1, 2, Ordering::SeqCst) == 1 {
+ } else if state.compare_exchange(1, 2, Ordering::SeqCst, Ordering::SeqCst).unwrap() == 1 {
// the next message we receive should be our own prevote
let prevote = match signed.message {
finality_grandpa::Message::Prevote(prevote) => prevote,
@@ -1170,7 +1170,7 @@ fn voter_persists_its_votes() {
// therefore we won't ever receive it again since it will be a
// known message on the gossip layer
- } else if state.compare_and_swap(2, 3, Ordering::SeqCst) == 2 {
+ } else if state.compare_exchange(2, 3, Ordering::SeqCst, Ordering::SeqCst).unwrap() == 2 {
// we then receive a precommit from alice for block 15
// even though we casted a prevote for block 30
let precommit = match signed.message {
diff --git a/client/finality-grandpa/src/until_imported.rs b/client/finality-grandpa/src/until_imported.rs
index 3ac94f3b062f0273f975e714c7318b9539243dae..c27eab5351562557ee1fc1a182b98ba6211d859a 100644
--- a/client/finality-grandpa/src/until_imported.rs
+++ b/client/finality-grandpa/src/until_imported.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/finality-grandpa/src/voting_rule.rs b/client/finality-grandpa/src/voting_rule.rs
index 700b0aeb551cd2a647b8722c4ab148bc7885cd52..a861e792755feaed872caff1cc644ceab751e8b8 100644
--- a/client/finality-grandpa/src/voting_rule.rs
+++ b/client/finality-grandpa/src/voting_rule.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/informant/src/display.rs b/client/informant/src/display.rs
index 5c8f5f8ef84aa4354238cb4d02fa7b53896b96b1..0caef4e5fbae8fabc2c0a9b92ccc272d181b407c 100644
--- a/client/informant/src/display.rs
+++ b/client/informant/src/display.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::OutputFormat;
use ansi_term::Colour;
diff --git a/client/informant/src/lib.rs b/client/informant/src/lib.rs
index d4f34cb488a9789eaa36223dd1a077bf071164c5..c955834c0f111dbcce7850b99cb259666ad79197 100644
--- a/client/informant/src/lib.rs
+++ b/client/informant/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/keystore/src/lib.rs b/client/keystore/src/lib.rs
index 0b6d654bc623ecda634b3612ac0df9350a342a28..9cad56efacfd66eb8aac3af9790957f15d02175b 100644
--- a/client/keystore/src/lib.rs
+++ b/client/keystore/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Keystore (and session key management) for ed25519 based chains like Polkadot.
diff --git a/client/keystore/src/local.rs b/client/keystore/src/local.rs
index a31e3e1f1e402df5bae884de80993d1f1fdcb630..866a50ae4c93ce43f7382db0053006a9dbabe35b 100644
--- a/client/keystore/src/local.rs
+++ b/client/keystore/src/local.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -167,9 +167,7 @@ impl SyncCryptoStore for LocalKeystore {
let all_keys = SyncCryptoStore::keys(self, id)?
.into_iter()
.collect::>();
- Ok(keys.into_iter()
- .filter(|key| all_keys.contains(key))
- .collect::>())
+ Ok(keys.into_iter().filter(|key| all_keys.contains(key)).collect::>())
}
fn sign_with(
diff --git a/client/light/src/backend.rs b/client/light/src/backend.rs
index 74e1d613bcf56ae80b652cef2358fb45927b850c..27e0754eb552e9b29b364e9307436ff5c031af81 100644
--- a/client/light/src/backend.rs
+++ b/client/light/src/backend.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/light/src/blockchain.rs b/client/light/src/blockchain.rs
index 3b5753f2849d51c8199d98debb99bf8e440386f0..f682e6e35b3d098c6d913cc79a96acaf821ded5e 100644
--- a/client/light/src/blockchain.rs
+++ b/client/light/src/blockchain.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/light/src/call_executor.rs b/client/light/src/call_executor.rs
index 458ea2bd6b844b5b430f08823f94f283a785ad87..7115f24a77d67168ecebbced1c52cee9ec1488c1 100644
--- a/client/light/src/call_executor.rs
+++ b/client/light/src/call_executor.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/light/src/fetcher.rs b/client/light/src/fetcher.rs
index 60fce87b8d0c26ecddbdf22d2ebd09e08060a696..b71c4871803da4fa907959cefc924333912c2ef4 100644
--- a/client/light/src/fetcher.rs
+++ b/client/light/src/fetcher.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/light/src/lib.rs b/client/light/src/lib.rs
index 899d1ae31a3dd951a89090a0ed69cc6e5fb71f5f..e647b8743cc0f8865a84b793f9f6fc621dfda8a9 100644
--- a/client/light/src/lib.rs
+++ b/client/light/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs
index 4deaad6d748fd13f7dc11f3f8d41fcfe77976862..9f1813f2224434ae82c7f7da1c35f8469a57c5f7 100644
--- a/client/network-gossip/src/bridge.rs
+++ b/client/network-gossip/src/bridge.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::{Network, Validator};
use crate::state_machine::{ConsensusGossip, TopicNotification, PERIODIC_MAINTENANCE_INTERVAL};
diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs
index 2b333610223e2a19c0c4553b8973eb77e65919ee..81575bdc774e97d83b06262211ad7051ec8f1075 100644
--- a/client/network-gossip/src/lib.rs
+++ b/client/network-gossip/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Polite gossiping.
//!
diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs
index 88f9d48375dec9e7c834651b87666fd2c7ad9717..7ae630a972326a5863215fccdf0ff04205172752 100644
--- a/client/network-gossip/src/state_machine.rs
+++ b/client/network-gossip/src/state_machine.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network-gossip/src/validator.rs b/client/network-gossip/src/validator.rs
index fd29aaddafe6dcd89f2e722bdcfa07854fc04225..4b5440c1a06f3c7d7f6fa38b84a64a87e3543629 100644
--- a/client/network-gossip/src/validator.rs
+++ b/client/network-gossip/src/validator.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs
index 73e5532297c48a41fe7d041fb25010e22d0b2ec3..b3e83a53d64d953652c21f21f0febe3a901c6f68 100644
--- a/client/network/src/behaviour.rs
+++ b/client/network/src/behaviour.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::{
config::{ProtocolId, Role}, light_client_handler, peer_info, request_responses,
diff --git a/client/network/src/chain.rs b/client/network/src/chain.rs
index 61d19c10dae513f109f4b29ee457a21d246b02cd..081d4b0d3ac3d7bc5bf086cd6f3a12f9733acbc6 100644
--- a/client/network/src/chain.rs
+++ b/client/network/src/chain.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/config.rs b/client/network/src/config.rs
index 8b4cf51ec551e57bf10acc73312050c38ecb46f5..b7e47e973a33dafc6593929b238849f0d18bb5e6 100644
--- a/client/network/src/config.rs
+++ b/client/network/src/config.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs
index b2517efb6607e1c78260d2c1dc69419445e0a79b..d9d28569ad30b0aa949c00db3f9163611cd95e87 100644
--- a/client/network/src/discovery.rs
+++ b/client/network/src/discovery.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Discovery mechanisms of Substrate.
//!
diff --git a/client/network/src/error.rs b/client/network/src/error.rs
index 7d7603ce92aab947b5fa581721b9d32dae9a964c..2a226b58b46a5e488e27134c0aeaf2a4c2fd7539 100644
--- a/client/network/src/error.rs
+++ b/client/network/src/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/gossip.rs b/client/network/src/gossip.rs
index 8a46d0701e932ce35b29b67968b6510af9823732..4e6845e3412615543c51df8a131b24ca1ea3dd59 100644
--- a/client/network/src/gossip.rs
+++ b/client/network/src/gossip.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/gossip/tests.rs b/client/network/src/gossip/tests.rs
index 63127f1c6cb282bba49b20db2f6bcb991c7daffe..e621adf0c09e1f058e3af30022e14a80b19cf67e 100644
--- a/client/network/src/gossip/tests.rs
+++ b/client/network/src/gossip/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs
index 4ebffc18af20e700f2ca21078b160d8c31d74ff4..ab7625ff9fe8ae90843428f8276941ebd24cfd0d 100644
--- a/client/network/src/lib.rs
+++ b/client/network/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/light_client_handler.rs b/client/network/src/light_client_handler.rs
index eb74ece82cc028e6e70af585ef7e14deff874107..3ac6e67a23278dd35815cfad30a2ac22b01b2c88 100644
--- a/client/network/src/light_client_handler.rs
+++ b/client/network/src/light_client_handler.rs
@@ -1,18 +1,20 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-//
-// Substrate is free software: you can redistribute it and/or modify
+
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
-// Substrate is distributed in the hope that it will be useful,
+
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! [`NetworkBehaviour`] implementation which handles light client requests.
//!
diff --git a/client/network/src/network_state.rs b/client/network/src/network_state.rs
index db2b6429304bb2b7d351725b907f361fa0ed9ef6..ba3e7cbff4568248f0f63ba82aa2b747768d60bd 100644
--- a/client/network/src/network_state.rs
+++ b/client/network/src/network_state.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/on_demand_layer.rs b/client/network/src/on_demand_layer.rs
index 6e0add18adb02e0237a3df4841f689f219c6f769..9ec1fb7508c3e6a4819250d0643b48cee7c00876 100644
--- a/client/network/src/on_demand_layer.rs
+++ b/client/network/src/on_demand_layer.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs
index 0bf2fe59fa21aeebedf81ba0f456ba4291c5f975..28b913ea4019277934a7ea9d4b9a1fbcd70352b8 100644
--- a/client/network/src/peer_info.rs
+++ b/client/network/src/peer_info.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use fnv::FnvHashMap;
use futures::prelude::*;
diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs
index 545440b6fbd6d4f3faea166e508ac7fb69bb6edb..240d92e51ff58f361418a5cc383306a0e1bfd017 100644
--- a/client/network/src/protocol.rs
+++ b/client/network/src/protocol.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/protocol/event.rs b/client/network/src/protocol/event.rs
index 86cb93bef26dd84cd9fcc0af843f553e2b192208..3fb383040dd27f9f38c5a08680bd50a138386907 100644
--- a/client/network/src/protocol/event.rs
+++ b/client/network/src/protocol/event.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Network event types. These are are not the part of the protocol, but rather
//! events that happen on the network like DHT get/put results received.
diff --git a/client/network/src/protocol/generic_proto.rs b/client/network/src/protocol/generic_proto.rs
index 4d6e607a146e7877e5ab1781f0a4e5b8d2b5d56a..a305fc1f5ea5fc9c5b758035aca94ee64a74ad45 100644
--- a/client/network/src/protocol/generic_proto.rs
+++ b/client/network/src/protocol/generic_proto.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Implementation of libp2p's `NetworkBehaviour` trait that opens a single substream with the
//! remote and then allows any communication with them.
diff --git a/client/network/src/protocol/generic_proto/behaviour.rs b/client/network/src/protocol/generic_proto/behaviour.rs
index b8b4cce0a72c750363ef17a0d79899d63158bb8a..c7bd7ce8cb026adeaaf69e6de92a5cb515444af7 100644
--- a/client/network/src/protocol/generic_proto/behaviour.rs
+++ b/client/network/src/protocol/generic_proto/behaviour.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::config::ProtocolId;
use crate::protocol::generic_proto::{
diff --git a/client/network/src/protocol/generic_proto/handler.rs b/client/network/src/protocol/generic_proto/handler.rs
index e479a34d14f3abd7cd66f9e04b940cfbe4610df2..97417000c20bab772ab653509bd539a5f43ad7a0 100644
--- a/client/network/src/protocol/generic_proto/handler.rs
+++ b/client/network/src/protocol/generic_proto/handler.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Implementations of the `IntoProtocolsHandler` and `ProtocolsHandler` traits for both incoming
//! and outgoing substreams for all gossiping protocols together.
diff --git a/client/network/src/protocol/generic_proto/tests.rs b/client/network/src/protocol/generic_proto/tests.rs
index 9c45c62f8bb4ce853d526f34b070a24f8f850322..fb28bd40d3dd11b956c80eb9edf306937906899f 100644
--- a/client/network/src/protocol/generic_proto/tests.rs
+++ b/client/network/src/protocol/generic_proto/tests.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
#![cfg(test)]
diff --git a/client/network/src/protocol/generic_proto/upgrade.rs b/client/network/src/protocol/generic_proto/upgrade.rs
index 6322a10b572a9fa1e9d60566343e513fc2a6f15a..6917742d8abb81d71e9f77901eaa1834d9598c24 100644
--- a/client/network/src/protocol/generic_proto/upgrade.rs
+++ b/client/network/src/protocol/generic_proto/upgrade.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/protocol/generic_proto/upgrade/collec.rs b/client/network/src/protocol/generic_proto/upgrade/collec.rs
index f8d199974940fb1abe6d41829d728243dd73af23..8531fb8bdfdbff880ea25bfbe08d7c0304526f5f 100644
--- a/client/network/src/protocol/generic_proto/upgrade/collec.rs
+++ b/client/network/src/protocol/generic_proto/upgrade/collec.rs
@@ -1,22 +1,20 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
+// This file is part of Substrate.
+
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
use futures::prelude::*;
use libp2p::core::upgrade::{InboundUpgrade, ProtocolName, UpgradeInfo};
diff --git a/client/network/src/protocol/generic_proto/upgrade/legacy.rs b/client/network/src/protocol/generic_proto/upgrade/legacy.rs
index 91282d0cf57dd9e751a208e81d2720f3cf949bb2..307bfd7ad639bb0c8eca285a934efc818aef459f 100644
--- a/client/network/src/protocol/generic_proto/upgrade/legacy.rs
+++ b/client/network/src/protocol/generic_proto/upgrade/legacy.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/protocol/generic_proto/upgrade/notifications.rs b/client/network/src/protocol/generic_proto/upgrade/notifications.rs
index 64b4b980da002d52dadcbb33f90e516445a5a7f1..ae9839f4f046dbe6d59b3bf36ef7473355c1d4d5 100644
--- a/client/network/src/protocol/generic_proto/upgrade/notifications.rs
+++ b/client/network/src/protocol/generic_proto/upgrade/notifications.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
/// Notifications protocol.
///
diff --git a/client/network/src/protocol/message.rs b/client/network/src/protocol/message.rs
index 4213d56bbf022dbc442778d7bd73d2671f56897c..c0a92629d9000418a115a6c2fc70d9044eb12325 100644
--- a/client/network/src/protocol/message.rs
+++ b/client/network/src/protocol/message.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/protocol/sync.rs b/client/network/src/protocol/sync.rs
index 712c13002883961eb5afb773bbc50cd83b72879c..70f860bdcb33c9240dec973a8961596a80c1ba1f 100644
--- a/client/network/src/protocol/sync.rs
+++ b/client/network/src/protocol/sync.rs
@@ -1,18 +1,20 @@
-// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-//
-// Substrate is free software: you can redistribute it and/or modify
+
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
-// Substrate is distributed in the hope that it will be useful,
+
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Contains the state of the chain synchronization process
//!
@@ -191,9 +193,6 @@ pub struct ChainSync {
/// A set of hashes of blocks that are being downloaded or have been
/// downloaded and are queued for import.
queue_blocks: HashSet,
- /// The best block number that was successfully imported into the chain.
- /// This can not decrease.
- best_imported_number: NumberFor,
/// Fork sync targets.
fork_targets: HashMap>,
/// A set of peers for which there might be potential block requests
@@ -455,7 +454,6 @@ impl ChainSync {
blocks: BlockCollection::new(),
best_queued_hash: info.best_hash,
best_queued_number: info.best_number,
- best_imported_number: info.best_number,
extra_justifications: ExtraRequests::new("justification"),
role,
required_block_attributes,
@@ -1106,10 +1104,6 @@ impl ChainSync {
}
}
- if number > self.best_imported_number {
- self.best_imported_number = number;
- }
-
if let Some(peer) = who.and_then(|p| self.peers.get_mut(&p)) {
peer.update_common_number(number);
}
@@ -1508,7 +1502,7 @@ impl ChainSync {
self.blocks.clear();
let info = self.client.info();
self.best_queued_hash = info.best_hash;
- self.best_queued_number = std::cmp::max(info.best_number, self.best_imported_number);
+ self.best_queued_number = info.best_number;
self.pending_requests.set_all();
debug!(target:"sync", "Restarted with {} ({})", self.best_queued_number, self.best_queued_hash);
let old_peers = std::mem::take(&mut self.peers);
diff --git a/client/network/src/protocol/sync/blocks.rs b/client/network/src/protocol/sync/blocks.rs
index b64c9e053e97b3018562beca4f439d71f17c8edb..60492f24ed8c3a333aa71ff43c2d3da0c03cd011 100644
--- a/client/network/src/protocol/sync/blocks.rs
+++ b/client/network/src/protocol/sync/blocks.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/protocol/sync/extra_requests.rs b/client/network/src/protocol/sync/extra_requests.rs
index 84ad308c61eda8da74ac4d9d5e1a4ae36ec17a36..d0fcfb777b8b0e7a668ddd4cb8f73cd27bbf752f 100644
--- a/client/network/src/protocol/sync/extra_requests.rs
+++ b/client/network/src/protocol/sync/extra_requests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs
index fb0a81814ea475dd571bf1b5246b9107b28133bd..80c57736f4266da94ea2c5598e67504641a71622 100644
--- a/client/network/src/request_responses.rs
+++ b/client/network/src/request_responses.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Collection of request-response protocols.
//!
diff --git a/client/network/src/schema.rs b/client/network/src/schema.rs
index 423d3ef5b41e4d8124138d8cdd0f8c7cf062f90d..5b9a70b0cd5d90be5e450c8c3d2735a1cdbdf32b 100644
--- a/client/network/src/schema.rs
+++ b/client/network/src/schema.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/service.rs b/client/network/src/service.rs
index 497072aa397d8a30d1ba34bff3beebe4d8e6dc83..dafbb247b52074b0df332c45954c8334b343da11 100644
--- a/client/network/src/service.rs
+++ b/client/network/src/service.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/service/metrics.rs b/client/network/src/service/metrics.rs
index 54bab1c1e9251968417b89f64beed40a546ea159..40d65ea45f11128ec3d6155932996b24b5cc08e3 100644
--- a/client/network/src/service/metrics.rs
+++ b/client/network/src/service/metrics.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/service/out_events.rs b/client/network/src/service/out_events.rs
index 976548f6ed44054d2767adf841e96e3117cf4777..eb811d56ab8601b9a19aa8dccbb307ea703acf8e 100644
--- a/client/network/src/service/out_events.rs
+++ b/client/network/src/service/out_events.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/service/tests.rs b/client/network/src/service/tests.rs
index 0ccdc984c71f480d643d9fdc7a29e9a5dca3bf38..2b0405d88e581907c0bf19b70f245662d270cfaf 100644
--- a/client/network/src/service/tests.rs
+++ b/client/network/src/service/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/transport.rs b/client/network/src/transport.rs
index 4bf252d57978e4977c71496a7903270c75b05bed..4d9d4fbde23ad13141d6b5f7e0c571d14756404c 100644
--- a/client/network/src/transport.rs
+++ b/client/network/src/transport.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/src/utils.rs b/client/network/src/utils.rs
index 490e2ced3826676e9384e141b72a54b87f9cb2ea..02673ef49fb4c4d9d98a3b0181af8e66859e7159 100644
--- a/client/network/src/utils.rs
+++ b/client/network/src/utils.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use futures::{stream::unfold, FutureExt, Stream, StreamExt};
use futures_timer::Delay;
diff --git a/client/network/test/src/block_import.rs b/client/network/test/src/block_import.rs
index 5f9064d410e0993bc7f90304e941f75d5c7e40b8..4000e53420b4a8f8f73fe1ffc7c65f99426bb006 100644
--- a/client/network/test/src/block_import.rs
+++ b/client/network/test/src/block_import.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/test/src/lib.rs b/client/network/test/src/lib.rs
index 69e5e9b693506a4ef0f1c94148d4ee711676f12f..b8b230f5d07193e2e072e4dbdc1685785ee87157 100644
--- a/client/network/test/src/lib.rs
+++ b/client/network/test/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/network/test/src/sync.rs b/client/network/test/src/sync.rs
index e04ef060f08c061faf3ca1d6529ff2077ace553f..999f9fe1ee3ac9ec07b42afbe789bc2891710e8c 100644
--- a/client/network/test/src/sync.rs
+++ b/client/network/test/src/sync.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/offchain/src/api.rs b/client/offchain/src/api.rs
index 6fb1da19bf058e8071d77525c656ad20a3ee3bde..6bef7187e450ecb38c70cbffc317a69855bc3add 100644
--- a/client/offchain/src/api.rs
+++ b/client/offchain/src/api.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use std::{
str::FromStr,
diff --git a/client/offchain/src/api/http.rs b/client/offchain/src/api/http.rs
index 1f542b7c11e19b8bd76a39ec3c6555b5c716a866..dbe8e55b3646b19bcca3e4827defad0388d79b5a 100644
--- a/client/offchain/src/api/http.rs
+++ b/client/offchain/src/api/http.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! This module is composed of two structs: [`HttpApi`] and [`HttpWorker`]. Calling the [`http`]
//! function returns a pair of [`HttpApi`] and [`HttpWorker`] that share some state.
diff --git a/client/offchain/src/api/http_dummy.rs b/client/offchain/src/api/http_dummy.rs
index 1c83325c93b2095fe4bc5fca9c7dbfb4e48e3b2a..ff9c2fb2aa0295acc14e909b6394ac63ddcd725b 100644
--- a/client/offchain/src/api/http_dummy.rs
+++ b/client/offchain/src/api/http_dummy.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Contains the same API as the `http` module, except that everything returns an error.
diff --git a/client/offchain/src/api/timestamp.rs b/client/offchain/src/api/timestamp.rs
index 222d3273cb355fa64ac4f52f8dcb568b69be25b8..31370d4f733c157d4c43d1ba9a61b8f92bbc3ce8 100644
--- a/client/offchain/src/api/timestamp.rs
+++ b/client/offchain/src/api/timestamp.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Helper methods dedicated to timestamps.
diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs
index 885294449fb950d1d286dea46ae0dbb4c91d380f..767d2ac5a12d41e51c914b48a93794f022604bb1 100644
--- a/client/offchain/src/lib.rs
+++ b/client/offchain/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Substrate offchain workers.
//!
diff --git a/client/peerset/src/lib.rs b/client/peerset/src/lib.rs
index bb08bdc18e678d3955621ae62b2502978d8a2ab4..141cafc0d12b2c470ce99798fdebd6e08cd10247 100644
--- a/client/peerset/src/lib.rs
+++ b/client/peerset/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/peerset/src/peersstate.rs b/client/peerset/src/peersstate.rs
index 19b2489eff486d7aae042c66771d73733981a3b9..d635f51781c9465291bfbe47bec94413e65ccd0f 100644
--- a/client/peerset/src/peersstate.rs
+++ b/client/peerset/src/peersstate.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Reputation and slots allocation system behind the peerset.
//!
diff --git a/client/peerset/tests/fuzz.rs b/client/peerset/tests/fuzz.rs
index e02742fc40ad4427cdbf037468d05b9f0e63f9ba..6f1bcb653de3741a81a76b373f8b8b1a49dbc04f 100644
--- a/client/peerset/tests/fuzz.rs
+++ b/client/peerset/tests/fuzz.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/proposer-metrics/src/lib.rs b/client/proposer-metrics/src/lib.rs
index 50498d40b62d5e171ec2cd22232b441b9c735db9..8fec9779de472dcad55df85fa0bb430111907fa3 100644
--- a/client/proposer-metrics/src/lib.rs
+++ b/client/proposer-metrics/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Prometheus basic proposer metrics.
diff --git a/client/rpc-api/src/author/error.rs b/client/rpc-api/src/author/error.rs
index 69c036be95fe085bcefeb1f38b8edbe594facaad..4d3a256a1a427fe69f796705d26094fb5375c7dd 100644
--- a/client/rpc-api/src/author/error.rs
+++ b/client/rpc-api/src/author/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/author/hash.rs b/client/rpc-api/src/author/hash.rs
index 4287af8ede5968723a1895efb32b4f9a74afa20d..618159a8ad4d5fe730c17378b83d83d639a73b84 100644
--- a/client/rpc-api/src/author/hash.rs
+++ b/client/rpc-api/src/author/hash.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Extrinsic helpers for author RPC module.
diff --git a/client/rpc-api/src/author/mod.rs b/client/rpc-api/src/author/mod.rs
index 29f5b1d26e84cb9c8644292da26c74e07dd23a39..6ccf1ebab375a29a27ac2af68acde9bf5c369a8a 100644
--- a/client/rpc-api/src/author/mod.rs
+++ b/client/rpc-api/src/author/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/chain/error.rs b/client/rpc-api/src/chain/error.rs
index fd7bd0a43d778bf2a03be96baa5960e15f3dbd47..59a0c0a2f840f222e2f81a4c4754462290fb4a2b 100644
--- a/client/rpc-api/src/chain/error.rs
+++ b/client/rpc-api/src/chain/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/chain/mod.rs b/client/rpc-api/src/chain/mod.rs
index 9bb75216c0186a016b8c69741bdbed29ae61c66d..5e2d4844130478b131c3875e0b8829240a3333e5 100644
--- a/client/rpc-api/src/chain/mod.rs
+++ b/client/rpc-api/src/chain/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/child_state/mod.rs b/client/rpc-api/src/child_state/mod.rs
index d956a7554f8ee798d2fa84c777ae33b591f257ce..7efff7422596988d3b7de81126978c81241a4aba 100644
--- a/client/rpc-api/src/child_state/mod.rs
+++ b/client/rpc-api/src/child_state/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/errors.rs b/client/rpc-api/src/errors.rs
index 4e1a5b10fc5128fbb3e36dfb788a23c0575e965d..8e4883a4cc20cb7b36f9ca8a021e1654b3bc4083 100644
--- a/client/rpc-api/src/errors.rs
+++ b/client/rpc-api/src/errors.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/helpers.rs b/client/rpc-api/src/helpers.rs
index 025fef1102c492adfb142a837d7e2f5e6a262e11..e85c26062b50d24e8a195cacc051f282d56d8825 100644
--- a/client/rpc-api/src/helpers.rs
+++ b/client/rpc-api/src/helpers.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/lib.rs b/client/rpc-api/src/lib.rs
index 7bae75181056ff5d7ad7bfd39139a4252ad0769b..814319add2a3e6b9845d60ce4abb1ab57c1f12c3 100644
--- a/client/rpc-api/src/lib.rs
+++ b/client/rpc-api/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Substrate RPC interfaces.
//!
diff --git a/client/rpc-api/src/metadata.rs b/client/rpc-api/src/metadata.rs
index cffcbf61f54401ee33d584198235c60e67d1fefa..efe090acc621ed57bb11f8c0b1d021d523f504a4 100644
--- a/client/rpc-api/src/metadata.rs
+++ b/client/rpc-api/src/metadata.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/offchain/error.rs b/client/rpc-api/src/offchain/error.rs
index ea5223f1ce7f935aefa8b6629ee2e82eebb48c13..f74d419e54424431daf81fe2a3a9bb310a6178b2 100644
--- a/client/rpc-api/src/offchain/error.rs
+++ b/client/rpc-api/src/offchain/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/offchain/mod.rs b/client/rpc-api/src/offchain/mod.rs
index 427b6a1cc017bfeb09e52a43e14c14fa6ddf8669..7a1f6db9e80be12c2313312d493fb5743846456a 100644
--- a/client/rpc-api/src/offchain/mod.rs
+++ b/client/rpc-api/src/offchain/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/policy.rs b/client/rpc-api/src/policy.rs
index 141dcfbc415f8294d6f140db7ce74012afa200ac..5d56c62bfece315d3506c846c5d3b468a2929ef9 100644
--- a/client/rpc-api/src/policy.rs
+++ b/client/rpc-api/src/policy.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/state/error.rs b/client/rpc-api/src/state/error.rs
index 1c22788062c7b232f783accc1be81899b78ddd12..4f2a2c854ae00cafc463cfe539fd6eeab9b298ee 100644
--- a/client/rpc-api/src/state/error.rs
+++ b/client/rpc-api/src/state/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/state/helpers.rs b/client/rpc-api/src/state/helpers.rs
index 0d176ea67f35be0449bf8bb63c49401260e39070..cb7bd380afa518d9fbeff96e929411c0d5e7fdf6 100644
--- a/client/rpc-api/src/state/helpers.rs
+++ b/client/rpc-api/src/state/helpers.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/state/mod.rs b/client/rpc-api/src/state/mod.rs
index 874fc862a39d25e958ed09f421d2a6b3181172e0..aae2dcb5ae7d3b124d41a0270c464a673566793d 100644
--- a/client/rpc-api/src/state/mod.rs
+++ b/client/rpc-api/src/state/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/system/error.rs b/client/rpc-api/src/system/error.rs
index 4897aa485cbe47591b787e771fda59543d3644c4..a0dfd863ce3aa34d9f055a949ca4903c77fa612f 100644
--- a/client/rpc-api/src/system/error.rs
+++ b/client/rpc-api/src/system/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/system/helpers.rs b/client/rpc-api/src/system/helpers.rs
index c5dddedef95648c741a9dcd35abce3b028bf9a87..b2b793a8ee4004344d2a8262c7ea9ceeb2ee3cc8 100644
--- a/client/rpc-api/src/system/helpers.rs
+++ b/client/rpc-api/src/system/helpers.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-api/src/system/mod.rs b/client/rpc-api/src/system/mod.rs
index f05f1fada901e06da983ed2cc601642d16bcab52..2cf22b9802993c2168a94d7f00debf98516503b1 100644
--- a/client/rpc-api/src/system/mod.rs
+++ b/client/rpc-api/src/system/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-servers/src/lib.rs b/client/rpc-servers/src/lib.rs
index 1f99e8bb0d242496c30ec5dd6bfd036dce709d0a..26d3cb1b7816a075f11571c5797ce023aefdfc31 100644
--- a/client/rpc-servers/src/lib.rs
+++ b/client/rpc-servers/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc-servers/src/middleware.rs b/client/rpc-servers/src/middleware.rs
index 233ceab3cf8a6536cdd97ab911dacf72c01e8efd..2cbc61716c31712bfa402418e0a89d6053f0fbe1 100644
--- a/client/rpc-servers/src/middleware.rs
+++ b/client/rpc-servers/src/middleware.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs
index 1a2d84e4e57272771a8679f5577aa120295b92d2..7cd980544503bcd1ad4322d498699f6ff71dde48 100644
--- a/client/rpc/src/author/mod.rs
+++ b/client/rpc/src/author/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/author/tests.rs b/client/rpc/src/author/tests.rs
index dc553e60dbfbeea20669293d64d6115c2d95d64f..9dd4f1b143fdf4774a884c67a49e5bdede1d64c0 100644
--- a/client/rpc/src/author/tests.rs
+++ b/client/rpc/src/author/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/chain/chain_full.rs b/client/rpc/src/chain/chain_full.rs
index 816dbba8664172a2cf467a5dc723386e689823d3..9687b13d50fc785c30b168c0298bc845ed447f7a 100644
--- a/client/rpc/src/chain/chain_full.rs
+++ b/client/rpc/src/chain/chain_full.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Blockchain API backend for full nodes.
diff --git a/client/rpc/src/chain/chain_light.rs b/client/rpc/src/chain/chain_light.rs
index 8a4afbed71c165708fd5d4b0effca47abe6995f7..41d4d02e33c9d7dba1de99737a2988a2647fcdb5 100644
--- a/client/rpc/src/chain/chain_light.rs
+++ b/client/rpc/src/chain/chain_light.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Blockchain API backend for light nodes.
diff --git a/client/rpc/src/chain/mod.rs b/client/rpc/src/chain/mod.rs
index cb67d9ba23166e36d0c5106f0333e9d4385e850d..d3a28d534335fa8675f31f4b0db9c063467bdbe9 100644
--- a/client/rpc/src/chain/mod.rs
+++ b/client/rpc/src/chain/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/chain/tests.rs b/client/rpc/src/chain/tests.rs
index b36fc4eab1d865f5a3c97e2d615d88cf33955274..80b990a9fbf03a50369708690c0921d88f0b3adb 100644
--- a/client/rpc/src/chain/tests.rs
+++ b/client/rpc/src/chain/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs
index 434859a39c2f4761b9e7553ea05c6fde16bd09ce..7b3af8cb2f3281c4fee110ac11801d7c94238436 100644
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/offchain/mod.rs b/client/rpc/src/offchain/mod.rs
index f8d2bb6a50f9c653491dc0536e019ad99ce20aa1..dbb48a9e519342c9a8ecf42984d932d5ca91f817 100644
--- a/client/rpc/src/offchain/mod.rs
+++ b/client/rpc/src/offchain/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/offchain/tests.rs b/client/rpc/src/offchain/tests.rs
index f65971a7ffe8ae278495dfb80921e979806c187a..b8054d816325f4df20377bc4b7c4449ea091cb50 100644
--- a/client/rpc/src/offchain/tests.rs
+++ b/client/rpc/src/offchain/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs
index 8573b3cf82551dc7dce9975b7d5f1560c3fa0f06..52a4ed1d753b556b636bd40687cc52f4b657743a 100644
--- a/client/rpc/src/state/mod.rs
+++ b/client/rpc/src/state/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs
index a1b9fbc4eebc579c7c47e3e7e65bc91b9f764aef..8d93d445b08cb120e92698d9100ac02d4022ee48 100644
--- a/client/rpc/src/state/state_full.rs
+++ b/client/rpc/src/state/state_full.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! State API backend for full nodes.
diff --git a/client/rpc/src/state/state_light.rs b/client/rpc/src/state/state_light.rs
index 8f4dce08b3fb61478add4218d3c6bd1f73bae47b..c1294dd27b08fa64b32786fdbda81440902aaacb 100644
--- a/client/rpc/src/state/state_light.rs
+++ b/client/rpc/src/state/state_light.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! State API backend for light nodes.
diff --git a/client/rpc/src/state/tests.rs b/client/rpc/src/state/tests.rs
index d145ac5e5510bee20de59fad78d7e3c1403e56cc..87b0fae1d6b3cb594e89088201580a8c6bc75c39 100644
--- a/client/rpc/src/state/tests.rs
+++ b/client/rpc/src/state/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/system/mod.rs b/client/rpc/src/system/mod.rs
index f1ebf5f702a27a3c1ec5ca1e10e5845fce37777c..60a410b805688ee41a28f85ea13ce90b37a18cbc 100644
--- a/client/rpc/src/system/mod.rs
+++ b/client/rpc/src/system/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/rpc/src/system/tests.rs b/client/rpc/src/system/tests.rs
index fa3574e9dae029b1eb89d446829547634a775fa8..c24c7a3faa6ec4bf9f14d93002af7f5606339b65 100644
--- a/client/rpc/src/system/tests.rs
+++ b/client/rpc/src/system/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -344,13 +344,15 @@ fn test_add_reset_log_filter() {
// Enter log generation / filter reload
if std::env::var("TEST_LOG_FILTER").is_ok() {
- sc_cli::init_logger("test_before_add=debug", Default::default(), Default::default(), false).unwrap();
+ sc_cli::init_logger(
+ sc_cli::InitLoggerParams { pattern: "test_before_add=debug".into(), ..Default::default() },
+ ).unwrap();
for line in std::io::stdin().lock().lines() {
let line = line.expect("Failed to read bytes");
if line.contains("add_reload") {
- assert!(api(None).system_add_log_filter("test_after_add".to_owned()).is_ok(), "`system_add_log_filter` failed");
+ api(None).system_add_log_filter("test_after_add".into()).expect("`system_add_log_filter` failed");
} else if line.contains("reset") {
- assert!(api(None).system_reset_log_filter().is_ok(), "`system_reset_log_filter` failed");
+ api(None).system_reset_log_filter().expect("`system_reset_log_filter` failed");
} else if line.contains("exit") {
return;
}
diff --git a/client/rpc/src/testing.rs b/client/rpc/src/testing.rs
index 9530ff0020644813e481f6340d7d6eba2142da31..b69cc7d4b194036d945930395d35f85ccd0a00a2 100644
--- a/client/rpc/src/testing.rs
+++ b/client/rpc/src/testing.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs
index 29e0cf8047f5fd9c2f0011ba86af853f21379d07..e3476e625ca55b85bfad53ac180f588544612fd2 100644
--- a/client/service/src/builder.rs
+++ b/client/service/src/builder.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/chain_ops/check_block.rs b/client/service/src/chain_ops/check_block.rs
index 34baeb55445a88ec41d2e729ecdc4c4eb782c1f6..94f6d25c9eb8f2ed6f2cc9c3e8285da66adef730 100644
--- a/client/service/src/chain_ops/check_block.rs
+++ b/client/service/src/chain_ops/check_block.rs
@@ -1,18 +1,20 @@
-// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::error::Error;
use futures::{future, prelude::*};
diff --git a/client/service/src/chain_ops/export_blocks.rs b/client/service/src/chain_ops/export_blocks.rs
index 3d2dbcbb9d00fecd78d51f366d684bd93645f43a..1d9325d1d7452f3318f73a6935167a5da9ad8ee2 100644
--- a/client/service/src/chain_ops/export_blocks.rs
+++ b/client/service/src/chain_ops/export_blocks.rs
@@ -1,18 +1,20 @@
-// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::error::Error;
use log::info;
diff --git a/client/service/src/chain_ops/export_raw_state.rs b/client/service/src/chain_ops/export_raw_state.rs
index 3fe44dbdb142d29f1737896e21f7a077f1dd68f8..71822cf6275f8d025e3e864a376ca1d6e1472d95 100644
--- a/client/service/src/chain_ops/export_raw_state.rs
+++ b/client/service/src/chain_ops/export_raw_state.rs
@@ -1,18 +1,20 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::error::Error;
use sp_runtime::traits::Block as BlockT;
diff --git a/client/service/src/chain_ops/import_blocks.rs b/client/service/src/chain_ops/import_blocks.rs
index 74a33c6557c9a47e212e6ac6bfd73826d0dd7183..3f918e05120e90bf0abbb47d8a76a768d9bbc4ba 100644
--- a/client/service/src/chain_ops/import_blocks.rs
+++ b/client/service/src/chain_ops/import_blocks.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/chain_ops/mod.rs b/client/service/src/chain_ops/mod.rs
index af6e6f632fc06438f8396c158425d57d30727ecd..c213e745a5d6bbf0d07f01d9118606ccb8b28e37 100644
--- a/client/service/src/chain_ops/mod.rs
+++ b/client/service/src/chain_ops/mod.rs
@@ -1,18 +1,20 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Chain utilities.
diff --git a/client/service/src/chain_ops/revert_chain.rs b/client/service/src/chain_ops/revert_chain.rs
index eaee2c03f9b316b0759ea5add478a32557ccad18..e3301eb2627e2bc2db80d4960e4189639493baff 100644
--- a/client/service/src/chain_ops/revert_chain.rs
+++ b/client/service/src/chain_ops/revert_chain.rs
@@ -1,18 +1,20 @@
-// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
use crate::error::Error;
use log::info;
diff --git a/client/service/src/client/block_rules.rs b/client/service/src/client/block_rules.rs
index be84614c2a5905a322c562daae3df51f0148e8f6..1af06666339ccc49433c59add55c85f73303db06 100644
--- a/client/service/src/client/block_rules.rs
+++ b/client/service/src/client/block_rules.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/client/call_executor.rs b/client/service/src/client/call_executor.rs
index cd01a5877758dad6e7dee6ec1fbc898a85377e46..d6f04d70270410a6e3f3625925ff538d73d1fc69 100644
--- a/client/service/src/client/call_executor.rs
+++ b/client/service/src/client/call_executor.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs
index 84174738b5608d8fbb833178f96c4daec02f27b8..d8884f235f90553fb499eaea8d702df35af68200 100644
--- a/client/service/src/client/client.rs
+++ b/client/service/src/client/client.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -401,7 +401,7 @@ impl Client where
storage: &'a dyn ChangesTrieStorage, NumberFor>,
min: NumberFor,
required_roots_proofs: Mutex, Block::Hash>>,
- };
+ }
impl<'a, Block: BlockT> ChangesTrieRootsStorage, NumberFor> for
AccessedRootsRecorder<'a, Block>
diff --git a/client/service/src/client/genesis.rs b/client/service/src/client/genesis.rs
index 4df08025e38264ab0a5f5b09631c95e4681d1b10..08235f7efb6e3ba4b3bc974e8ab6c83fb291508b 100644
--- a/client/service/src/client/genesis.rs
+++ b/client/service/src/client/genesis.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/client/light.rs b/client/service/src/client/light.rs
index 6d4f9aa1c9d1bbdfcfbb0a07c6e1718f05c49592..5b5c0cb0eb38ffeb87b52f545286ff8cbc363938 100644
--- a/client/service/src/client/light.rs
+++ b/client/service/src/client/light.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/client/mod.rs b/client/service/src/client/mod.rs
index e4d1dc8bd8509f59c7575521d0c2511316dc29ba..06f48048f8f2b54c8fb7c3ee5fb618f73a78f63a 100644
--- a/client/service/src/client/mod.rs
+++ b/client/service/src/client/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/client/wasm_override.rs b/client/service/src/client/wasm_override.rs
index ba76f7a0fcf29ee6b1ae1ab1ba5924fdc08e1d0d..aca29694fca82f007772ca1219192041097e3677 100644
--- a/client/service/src/client/wasm_override.rs
+++ b/client/service/src/client/wasm_override.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/config.rs b/client/service/src/config.rs
index e360e610d490c5dab317eaaff6c281d714ddecb8..e253ed97ff3a53dcab742d2d37dcdd2f993b1897 100644
--- a/client/service/src/config.rs
+++ b/client/service/src/config.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -263,6 +263,13 @@ impl BasePath {
BasePath::Permanenent(path) => path.as_path(),
}
}
+
+ /// Returns the configuration directory inside this base path.
+ ///
+ /// The path looks like `$base_path/chains/$chain_id`
+ pub fn config_dir(&self, chain_id: &str) -> PathBuf {
+ self.path().join("chains").join(chain_id)
+ }
}
impl std::convert::From for BasePath {
diff --git a/client/service/src/error.rs b/client/service/src/error.rs
index 3515df78be876c32fbe1968e5613a9baab0f4465..31c3cea4ef43b019dbf4335bdcff20a3bd19b8fd 100644
--- a/client/service/src/error.rs
+++ b/client/service/src/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs
index cd129de3260789774b2b37fa926ae42ec3f45108..8b26b1a75ddf8d218433b642a71323d212290d93 100644
--- a/client/service/src/lib.rs
+++ b/client/service/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/metrics.rs b/client/service/src/metrics.rs
index d3ad780b5be62fd284ec10a50eea39509fef27d9..446cce952741d641bc470cf623194658fa56bfc3 100644
--- a/client/service/src/metrics.rs
+++ b/client/service/src/metrics.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/src/task_manager/mod.rs b/client/service/src/task_manager/mod.rs
index a0aeba3009dee48b18eb6050f39782df56d590bf..d1ab8c9c2a7ee67f4caeb5b236977f795ddf9ead 100644
--- a/client/service/src/task_manager/mod.rs
+++ b/client/service/src/task_manager/mod.rs
@@ -1,16 +1,21 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
//! Substrate service tasks management module.
use std::{panic, result::Result, pin::Pin};
diff --git a/client/service/src/task_manager/prometheus_future.rs b/client/service/src/task_manager/prometheus_future.rs
index 53bd59aa7a507ed52e240c4f44f718efa1567c6c..6d2a52354d6ca2548a7aa823fda2e71b2dbffd17 100644
--- a/client/service/src/task_manager/prometheus_future.rs
+++ b/client/service/src/task_manager/prometheus_future.rs
@@ -1,16 +1,21 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
//! Wrapper around a `Future` that reports statistics about when the `Future` is polled.
use futures::prelude::*;
diff --git a/client/service/src/task_manager/tests.rs b/client/service/src/task_manager/tests.rs
index 27d9b0b9e9ad9334faa66589002ef10605ee9323..0509392ce38884b7189b863225b4fd6d7c152a5e 100644
--- a/client/service/src/task_manager/tests.rs
+++ b/client/service/src/task_manager/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/test/src/client/db.rs b/client/service/test/src/client/db.rs
index 36d49732246e579d610a707d827c0b5d49c00ea6..a86e8f2de467c35e71f7f26a0998a6e76e3fe830 100644
--- a/client/service/test/src/client/db.rs
+++ b/client/service/test/src/client/db.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/test/src/client/light.rs b/client/service/test/src/client/light.rs
index f38aef008e11c803e5e001a2d077e6b505329628..201b24a6efa299ce03976288eb7278c54bd593dc 100644
--- a/client/service/test/src/client/light.rs
+++ b/client/service/test/src/client/light.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/test/src/client/mod.rs b/client/service/test/src/client/mod.rs
index 23d6a3429732853ea8dc9f98032e3ed4c9c10d63..6bb09981107a0399e9a536f33755ad5f50f4b584 100644
--- a/client/service/test/src/client/mod.rs
+++ b/client/service/test/src/client/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs
index 1f200b4cbeed6dca3dd096663e4ed08ee647767f..c30246e91ca05ab5958366ed49d0aee55f2ee67c 100644
--- a/client/service/test/src/lib.rs
+++ b/client/service/test/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/state-db/src/lib.rs b/client/state-db/src/lib.rs
index 61470894e487e3884bc873301ff17e39345a0877..8fd02ee17b996ffa37fbb536b0bd88912516edc7 100644
--- a/client/state-db/src/lib.rs
+++ b/client/state-db/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/state-db/src/noncanonical.rs b/client/state-db/src/noncanonical.rs
index d77f20c50d05f30916f024666607dc7f3f16d440..551bf5fb860c7e177a414e7b973eaebecd44a2eb 100644
--- a/client/state-db/src/noncanonical.rs
+++ b/client/state-db/src/noncanonical.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/state-db/src/pruning.rs b/client/state-db/src/pruning.rs
index 69b07c285fad8318152611d9473c508367a9f73c..0c682d8954b13623d4a5af81a8d8bed3cc8bae36 100644
--- a/client/state-db/src/pruning.rs
+++ b/client/state-db/src/pruning.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/state-db/src/test.rs b/client/state-db/src/test.rs
index 11ce4ad8226202d0f08a9e77bdddfb8e7772deaa..e1bb6d01c37e458548be82930279a363057b2b61 100644
--- a/client/state-db/src/test.rs
+++ b/client/state-db/src/test.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/sync-state-rpc/src/lib.rs b/client/sync-state-rpc/src/lib.rs
index 573610fb2f6102de728b377a742d864c297b3faa..8466523116440005508a2366c037dbd597a32e19 100644
--- a/client/sync-state-rpc/src/lib.rs
+++ b/client/sync-state-rpc/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! A RPC handler to create sync states for light clients.
//! Currently only usable with BABE + GRANDPA.
diff --git a/client/telemetry/src/lib.rs b/client/telemetry/src/lib.rs
index 6a5ac0e0cb3122925ed0e12e62431742cbe20a02..58c9fe73b28cf0bf6c2af744e8654f2abaddefba 100644
--- a/client/telemetry/src/lib.rs
+++ b/client/telemetry/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/telemetry/src/worker.rs b/client/telemetry/src/worker.rs
index a01ab89e7dde7fb52f9bf61f59f58b2338c2a36c..158781f0433586e628b52307af3a3fe2dc8889c7 100644
--- a/client/telemetry/src/worker.rs
+++ b/client/telemetry/src/worker.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/telemetry/src/worker/node.rs b/client/telemetry/src/worker/node.rs
index eef7ca7e815536aaaa26f8e2d20f17dc67e2f1e5..5fbafde8c941b608a7bff316806cd5c89932bead 100644
--- a/client/telemetry/src/worker/node.rs
+++ b/client/telemetry/src/worker/node.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/tracing/src/lib.rs b/client/tracing/src/lib.rs
index f4017023eff19d3d68389554781d4644e39f0948..639ba56b12e5f4e8bacf3a4fb1433a3458987775 100644
--- a/client/tracing/src/lib.rs
+++ b/client/tracing/src/lib.rs
@@ -1,18 +1,20 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Substrate is distributed in the hope that it will be useful,
+// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// along with this program. If not, see .
//! Instrumentation implementation for substrate.
//!
diff --git a/client/tracing/src/logging.rs b/client/tracing/src/logging.rs
index 370b09f781b4ea92ee053bc5caf5392560a08b07..248c91feb80f10297376b2bcd31bcec30b0fe8be 100644
--- a/client/tracing/src/logging.rs
+++ b/client/tracing/src/logging.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/benches/basics.rs b/client/transaction-pool/graph/benches/basics.rs
index bb10086bd4a558330d8d36e4bf3b92d791fdcae4..f7096b0214403ec23325b667dd11f7a420a9ee65 100644
--- a/client/transaction-pool/graph/benches/basics.rs
+++ b/client/transaction-pool/graph/benches/basics.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/base_pool.rs b/client/transaction-pool/graph/src/base_pool.rs
index 81d8e802c2c9eb536d16f0ad2f192e645d674e78..445ef0adaf7b7313f222ff25e737f94ce7357b31 100644
--- a/client/transaction-pool/graph/src/base_pool.rs
+++ b/client/transaction-pool/graph/src/base_pool.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/future.rs b/client/transaction-pool/graph/src/future.rs
index 80e6825d4ff9d3097f485d8fe86ca388ef0a3197..98d49817e32a8b05f97d50e579bba6c725878091 100644
--- a/client/transaction-pool/graph/src/future.rs
+++ b/client/transaction-pool/graph/src/future.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/lib.rs b/client/transaction-pool/graph/src/lib.rs
index bf220ce22973a97190ad7a0d5da2ba50e9e0acd6..b8d36d0399b9f7214b7728d214f575dad491c289 100644
--- a/client/transaction-pool/graph/src/lib.rs
+++ b/client/transaction-pool/graph/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/listener.rs b/client/transaction-pool/graph/src/listener.rs
index 1bc3720fa6b85e8eea21b75d1a15bffd9f210758..d707c0a0f802f038488012465b3ddd84e5f73bd3 100644
--- a/client/transaction-pool/graph/src/listener.rs
+++ b/client/transaction-pool/graph/src/listener.rs
@@ -1,7 +1,7 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/pool.rs b/client/transaction-pool/graph/src/pool.rs
index 56ff550d7754f67abf170a92d1ab164b75f7d6b8..8255370df55d72bd78aa45c0228f8c6fddcab218 100644
--- a/client/transaction-pool/graph/src/pool.rs
+++ b/client/transaction-pool/graph/src/pool.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/ready.rs b/client/transaction-pool/graph/src/ready.rs
index cbdb25078931ef33a701b8db635ae516f580c594..c2af4f9cb9140e644d2fe5c4690ce78c7ec9d2a2 100644
--- a/client/transaction-pool/graph/src/ready.rs
+++ b/client/transaction-pool/graph/src/ready.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/rotator.rs b/client/transaction-pool/graph/src/rotator.rs
index 65e21d0d4b5068262a6caf00add896ab51f4a710..3d9b359fd365f4349cd161ed96b4409afa18f13b 100644
--- a/client/transaction-pool/graph/src/rotator.rs
+++ b/client/transaction-pool/graph/src/rotator.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/tracked_map.rs b/client/transaction-pool/graph/src/tracked_map.rs
index c799eb0b96ea146b16951d3822502a55940b763b..9cd6ad84b483dd91bb4373820d140d37467afe13 100644
--- a/client/transaction-pool/graph/src/tracked_map.rs
+++ b/client/transaction-pool/graph/src/tracked_map.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs
index 86c2e75832f07fa02343a4e681b5429211adff17..ef689436275af3e21f09a448b0b36f3b0e8fbd07 100644
--- a/client/transaction-pool/graph/src/validated_pool.rs
+++ b/client/transaction-pool/graph/src/validated_pool.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
@@ -286,7 +286,7 @@ impl ValidatedPool {
/// Transactions that are missing from the pool are not submitted.
pub fn resubmit(&self, mut updated_transactions: HashMap, ValidatedTransactionFor>) {
#[derive(Debug, Clone, Copy, PartialEq)]
- enum Status { Future, Ready, Failed, Dropped };
+ enum Status { Future, Ready, Failed, Dropped }
let (mut initial_statuses, final_statuses) = {
let mut pool = self.pool.write();
diff --git a/client/transaction-pool/graph/src/watcher.rs b/client/transaction-pool/graph/src/watcher.rs
index 9d9a91bb23f69acb0ad42a1eba4dcadecc856c66..6f8eb7c6e5668a961dbadcd8aec9328b83d5b836 100644
--- a/client/transaction-pool/graph/src/watcher.rs
+++ b/client/transaction-pool/graph/src/watcher.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/src/api.rs b/client/transaction-pool/src/api.rs
index 853b66f6e74bbd973aa7360a96e0aabe8d8c1c78..fc14a5a0cba6440c2d166f79e3e94c31268e1e51 100644
--- a/client/transaction-pool/src/api.rs
+++ b/client/transaction-pool/src/api.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/src/error.rs b/client/transaction-pool/src/error.rs
index 49fc433e320cc0be9fa3f3d905e77bc1c0369e83..62c812d14704ae4b944cc6fcb7e6eb14442ad9f9 100644
--- a/client/transaction-pool/src/error.rs
+++ b/client/transaction-pool/src/error.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs
index e03c01bd1d816c039b12f51055841bbf7cb28011..e9a1c3906f48f42dc588a54fba88fce2373d2481 100644
--- a/client/transaction-pool/src/lib.rs
+++ b/client/transaction-pool/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/src/metrics.rs b/client/transaction-pool/src/metrics.rs
index 376e6dfe94488611db828fdbce0f5f9294c1747d..e0b70183a86b2c9fb594937085390b4528e20095 100644
--- a/client/transaction-pool/src/metrics.rs
+++ b/client/transaction-pool/src/metrics.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/src/revalidation.rs b/client/transaction-pool/src/revalidation.rs
index 7be8688eaea5db287e05c9e9f56f5d227655664c..69b601484c77a6f124fd891c2bb46bb3b528b8c7 100644
--- a/client/transaction-pool/src/revalidation.rs
+++ b/client/transaction-pool/src/revalidation.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/src/testing/mod.rs b/client/transaction-pool/src/testing/mod.rs
index 350c4137c37b23a5d1fdfde94f0b19acde7cbdb4..9c7f1dfd7f3367987722d93a6f6acb967d552d2d 100644
--- a/client/transaction-pool/src/testing/mod.rs
+++ b/client/transaction-pool/src/testing/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/client/transaction-pool/src/testing/pool.rs b/client/transaction-pool/src/testing/pool.rs
index 8fa742cd419a339657c23783adebf81da2a9fccc..6e00af47602d378024444ef0c7e5b300cbd7752d 100644
--- a/client/transaction-pool/src/testing/pool.rs
+++ b/client/transaction-pool/src/testing/pool.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
diff --git a/docs/Structure.adoc b/docs/Structure.adoc
index c8cd63506a347f3252a8f5d40c9cf3d2dd4db7d8..6c810a83c51b91367203ba67b532935e36c85146 100644
--- a/docs/Structure.adoc
+++ b/docs/Structure.adoc
@@ -33,7 +33,7 @@ In the lowest level, Substrate defines primitives, interfaces and traits to impl
=== Client
* _found in_: `/client`
-* _crates prefix_: `substrate-`
+* _crates prefix_: `sc-`
* _constraints_:
** crates may not (dev-)depend on any `frame-`-crates
diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs
index cecb2ccae58b404bf2b0fa386af2d2d93fad53aa..db98164023d5ceeb6de808fda0dc455fdc95ea4c 100644
--- a/frame/assets/src/benchmarking.rs
+++ b/frame/assets/src/benchmarking.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs
index df1cb87f75b2dee48f97cfac30dcc82581a91221..0455f35e245579f53f62a70cf35a7fdc3d0d0fec 100644
--- a/frame/assets/src/lib.rs
+++ b/frame/assets/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -952,6 +952,7 @@ mod tests {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
parameter_types! {
diff --git a/frame/assets/src/weights.rs b/frame/assets/src/weights.rs
index f6408e527f51b3a1cee059c68d6f2e2ef0543c33..a8e17615d282d234d6c21ddaffcadf293ae5559a 100644
--- a/frame/assets/src/weights.rs
+++ b/frame/assets/src/weights.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs
index ac9b82b0df06798daefeb64f7d066e262bc555dc..e6d44d73c40d23968a696bb327ce7a4d50a50495 100644
--- a/frame/atomic-swap/src/lib.rs
+++ b/frame/atomic-swap/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs
index 47b5102bc568cdc6617684740b2e0abcef10f00b..19f5fc1dff58fc678db4183dccee6bad91fe43f9 100644
--- a/frame/atomic-swap/src/tests.rs
+++ b/frame/atomic-swap/src/tests.rs
@@ -42,6 +42,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs
index 34f216850c675163b3db0c7365d281ddb0d67485..2e32fc61585dd33d07af78954205b1330596ceab 100644
--- a/frame/aura/src/lib.rs
+++ b/frame/aura/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs
index 1fcb1c2340d13c68b0badde2f424e2d8ef168149..69e914a23a1082df444895de576bd9789901152a 100644
--- a/frame/aura/src/mock.rs
+++ b/frame/aura/src/mock.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -66,6 +66,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
impl pallet_timestamp::Config for Test {
diff --git a/frame/aura/src/tests.rs b/frame/aura/src/tests.rs
index ca0fc3de3763809d1f7d4c50d4adf862b8e9305d..b198308282c48bb61db564e79c1c6a65c5f65dae 100644
--- a/frame/aura/src/tests.rs
+++ b/frame/aura/src/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs
index 2d275e01bba24d2c26274fd63d31cc909af4da81..fdc13cd747063ba138cc10a4a0536e584039b86f 100644
--- a/frame/authority-discovery/src/lib.rs
+++ b/frame/authority-discovery/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -164,6 +164,7 @@ mod tests {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
impl_outer_origin! {
diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs
index b991beaaa2b67a3ac0f64b66ead26a614ce93c7c..d31d6866254d778c0bb18d4d3ad7a4bdf55c0635 100644
--- a/frame/authorship/src/lib.rs
+++ b/frame/authorship/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -438,6 +438,7 @@ mod tests {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
parameter_types! {
@@ -582,7 +583,6 @@ mod tests {
&number,
&hash,
&Default::default(),
- &Default::default(),
Default::default()
);
@@ -681,7 +681,6 @@ mod tests {
System::initialize(
&1,
&Default::default(),
- &Default::default(),
header.digest(),
Default::default(),
);
diff --git a/frame/babe/src/benchmarking.rs b/frame/babe/src/benchmarking.rs
index 8ee4a5913c885290bd42f07a094db982937af37c..4d75c36669eab518569c9502daf44d24466f5cb7 100644
--- a/frame/babe/src/benchmarking.rs
+++ b/frame/babe/src/benchmarking.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/babe/src/default_weights.rs b/frame/babe/src/default_weights.rs
index a0e13781961cc0a5ad37c8d5b50801542a582657..c7c87b5837401f7b484abf8a451e325803615641 100644
--- a/frame/babe/src/default_weights.rs
+++ b/frame/babe/src/default_weights.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs
index 55aaedfe082fe61eef176568813022e05d7cb794..e7053f5ac0feddfb6a3df0ebe23d5bcec22b2953 100644
--- a/frame/babe/src/equivocation.rs
+++ b/frame/babe/src/equivocation.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs
index a61f1244cbebde12de74cf7cdd45eac2b65b9915..d7da96a3ddd925e8debac67011312a8734a8c9c0 100644
--- a/frame/babe/src/lib.rs
+++ b/frame/babe/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,7 +43,7 @@ use sp_timestamp::OnTimestampSet;
use sp_consensus_babe::{
digests::{NextConfigDescriptor, NextEpochDescriptor, PreDigest},
inherents::{BabeInherentData, INHERENT_IDENTIFIER},
- BabeAuthorityWeight, ConsensusLog, EquivocationProof, SlotNumber, BABE_ENGINE_ID,
+ BabeAuthorityWeight, ConsensusLog, Epoch, EquivocationProof, SlotNumber, BABE_ENGINE_ID,
};
use sp_consensus_vrf::schnorrkel;
use sp_inherents::{InherentData, InherentIdentifier, MakeFatalError, ProvideInherent};
@@ -486,6 +486,17 @@ impl Module {
(EpochIndex::get() * T::EpochDuration::get()) + GenesisSlot::get()
}
+ /// Produces information about the current epoch.
+ pub fn current_epoch() -> Epoch {
+ Epoch {
+ epoch_index: EpochIndex::get(),
+ start_slot: Self::current_epoch_start(),
+ duration: T::EpochDuration::get(),
+ authorities: Self::authorities(),
+ randomness: Self::randomness(),
+ }
+ }
+
fn deposit_consensus(new: U) {
let log: DigestItem = DigestItem::Consensus(BABE_ENGINE_ID, new.encode());
>::deposit_log(log.into())
diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs
index 8af92c79e91f4e363e60c439c65e8a1fd0840096..d29e467b791946d84059c874d5aa8d2820622a7f 100644
--- a/frame/babe/src/mock.rs
+++ b/frame/babe/src/mock.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -86,6 +86,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
impl frame_system::offchain::SendTransactionTypes for Test
@@ -259,7 +260,7 @@ pub fn go_to_block(n: u64, s: u64) {
let pre_digest = make_secondary_plain_pre_digest(0, s);
- System::initialize(&n, &parent_hash, &Default::default(), &pre_digest, InitKind::Full);
+ System::initialize(&n, &parent_hash, &pre_digest, InitKind::Full);
System::set_block_number(n);
Timestamp::set_timestamp(n);
@@ -447,7 +448,7 @@ pub fn generate_equivocation_proof(
let make_header = || {
let parent_hash = System::parent_hash();
let pre_digest = make_secondary_plain_pre_digest(offender_authority_index, slot_number);
- System::initialize(¤t_block, &parent_hash, &Default::default(), &pre_digest, InitKind::Full);
+ System::initialize(¤t_block, &parent_hash, &pre_digest, InitKind::Full);
System::set_block_number(current_block);
Timestamp::set_timestamp(current_block);
System::finalize()
diff --git a/frame/babe/src/tests.rs b/frame/babe/src/tests.rs
index 29b080493f46b12784ed6a38049ae467dc31c883..0d0536359f61c663ff694ac87ab301faafa04523 100644
--- a/frame/babe/src/tests.rs
+++ b/frame/babe/src/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,7 +77,6 @@ fn first_block_epoch_zero_start() {
System::initialize(
&1,
&Default::default(),
- &Default::default(),
&pre_digest,
Default::default(),
);
@@ -128,7 +127,6 @@ fn author_vrf_output_for_primary() {
System::initialize(
&1,
&Default::default(),
- &Default::default(),
&primary_pre_digest,
Default::default(),
);
@@ -155,7 +153,6 @@ fn author_vrf_output_for_secondary_vrf() {
System::initialize(
&1,
&Default::default(),
- &Default::default(),
&secondary_vrf_pre_digest,
Default::default(),
);
@@ -179,7 +176,6 @@ fn no_author_vrf_output_for_secondary_plain() {
System::initialize(
&1,
&Default::default(),
- &Default::default(),
&secondary_plain_pre_digest,
Default::default(),
);
diff --git a/frame/balances/src/benchmarking.rs b/frame/balances/src/benchmarking.rs
index 078d74006ba2fffe5b7a8673f2ee77171f5adb69..249934a61b4d730bd326d9473ed03b26c3d3d3a7 100644
--- a/frame/balances/src/benchmarking.rs
+++ b/frame/balances/src/benchmarking.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs
index b7d2488bfdd09202f47ade4d1f2bfe148e7a9d15..4fcda02c4fd2d7aeef3030c0edf8069e37eadd72 100644
--- a/frame/balances/src/lib.rs
+++ b/frame/balances/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs
index f47776e0ee6c4555d8e9e790dd4cbd7fa3f2ec59..728bf036bb3b956503090a66675711e6b2e11695 100644
--- a/frame/balances/src/tests.rs
+++ b/frame/balances/src/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs
index 81c2b895273b55d27012a44e3629f950671bf30e..7cb9b9d502ba5e807269edd000d8ad6e1ce93567 100644
--- a/frame/balances/src/tests_composite.rs
+++ b/frame/balances/src/tests_composite.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,6 +77,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
parameter_types! {
pub const TransactionByteFee: u64 = 1;
diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs
index c168e1d8e59e17c6db3006049c3799f1adf40f89..887b280945f1a39843912823ad870aff98b245b2 100644
--- a/frame/balances/src/tests_local.rs
+++ b/frame/balances/src/tests_local.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -78,6 +78,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = Module;
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
parameter_types! {
pub const TransactionByteFee: u64 = 1;
diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs
index 189947003b133d2258c2dd46a6443bb19dfa421f..1f7e1bec080cf3e9df2f419acb5b932e853cfed6 100644
--- a/frame/balances/src/weights.rs
+++ b/frame/balances/src/weights.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/benchmarking/src/analysis.rs b/frame/benchmarking/src/analysis.rs
index dafe42de92e8a24b9a49e615c89128eb9f769c9d..bdfa1cf65c47f95e370cbd9f81bff35de97c80e8 100644
--- a/frame/benchmarking/src/analysis.rs
+++ b/frame/benchmarking/src/analysis.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs
index 6296c000e289f959eea62fc39305b7a5d95cad65..308e5285d3f6192048380c26f22541d5970bb8d7 100644
--- a/frame/benchmarking/src/lib.rs
+++ b/frame/benchmarking/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1072,7 +1072,7 @@ macro_rules! impl_benchmark_test {
#[macro_export]
macro_rules! add_benchmark {
- ( $params:ident, $batches:ident, $name:ident, $( $location:tt )* ) => (
+ ( $params:ident, $batches:ident, $name:path, $( $location:tt )* ) => (
let name_string = stringify!($name).as_bytes();
let instance_string = stringify!( $( $location )* ).as_bytes();
let (config, whitelist) = $params;
diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs
index f86abebbb9287c19b4f383723280d9913f0a0217..7ea6bfd9afa250a6b56146ecf01dd83894dd7f9c 100644
--- a/frame/benchmarking/src/tests.rs
+++ b/frame/benchmarking/src/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -94,6 +94,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
impl Config for Test {
diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs
index 2c2aee910e3641b44118e4871efa5e5fd87718e1..945141345cefe5aa74a961d8217bdfd9072f452d 100644
--- a/frame/benchmarking/src/utils.rs
+++ b/frame/benchmarking/src/utils.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs
index 5a323ff0aafcc8cbd46a797f00e178f065e0f440..0fe479bda7bda88801f308201eab819eddfcc7c7 100644
--- a/frame/bounties/src/benchmarking.rs
+++ b/frame/bounties/src/benchmarking.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,7 +77,7 @@ fn create_bounty() -> Result<(
Ok((curator_lookup, bounty_id))
}
-fn setup_pod_account() {
+fn setup_pot_account() {
let pot_account = Bounties::::account_id();
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
let _ = T::Currency::make_free_balance_be(&pot_account, value);
@@ -109,7 +109,7 @@ benchmarks! {
}: _(RawOrigin::Root, bounty_id)
propose_curator {
- setup_pod_account::();
+ setup_pot_account::();
let (caller, curator, fee, value, reason) = setup_bounty::(0, MAX_BYTES);
let curator_lookup = T::Lookup::unlookup(curator.clone());
Bounties::::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
@@ -120,7 +120,7 @@ benchmarks! {
// Worst case when curator is inactive and any sender unassigns the curator.
unassign_curator {
- setup_pod_account::();
+ setup_pot_account::();
let (curator_lookup, bounty_id) = create_bounty::()?;
Bounties::::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::get() - 1;
@@ -129,7 +129,7 @@ benchmarks! {
}: _(RawOrigin::Signed(caller), bounty_id)
accept_curator {
- setup_pod_account::();
+ setup_pot_account::();
let (caller, curator, fee, value, reason) = setup_bounty::(0, MAX_BYTES);
let curator_lookup = T::Lookup::unlookup(curator.clone());
Bounties::::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
@@ -140,7 +140,7 @@ benchmarks! {
}: _(RawOrigin::Signed(curator), bounty_id)
award_bounty {
- setup_pod_account::();
+ setup_pot_account::();
let (curator_lookup, bounty_id) = create_bounty::()?;
Bounties::::on_initialize(T::BlockNumber::zero());
@@ -150,7 +150,7 @@ benchmarks! {
}: _(RawOrigin::Signed(curator), bounty_id, beneficiary)
claim_bounty {
- setup_pod_account::();
+ setup_pot_account::();
let (curator_lookup, bounty_id) = create_bounty::()?;
Bounties::::on_initialize(T::BlockNumber::zero());
@@ -170,14 +170,14 @@ benchmarks! {
}
close_bounty_proposed {
- setup_pod_account::();
+ setup_pot_account::();
let (caller, curator, fee, value, reason) = setup_bounty::(0, 0);
Bounties::::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::get() - 1;
}: close_bounty(RawOrigin::Root, bounty_id)
close_bounty_active {
- setup_pod_account::();
+ setup_pot_account::();
let (curator_lookup, bounty_id) = create_bounty::()?;
Bounties::::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::get() - 1;
@@ -187,7 +187,7 @@ benchmarks! {
}
extend_bounty_expiry {
- setup_pod_account::();
+ setup_pot_account::();
let (curator_lookup, bounty_id) = create_bounty::()?;
Bounties::::on_initialize(T::BlockNumber::zero());
@@ -200,7 +200,7 @@ benchmarks! {
spend_funds {
let b in 1 .. 100;
- setup_pod_account::();
+ setup_pot_account::();
create_approved_bounties::(b)?;
let mut budget_remaining = BalanceOf::::max_value();
diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs
index 32a377472622ed07933f598db3d52f5bfdade017..a8b97d9e33b856cbab22e5f240e70f76401b50b9 100644
--- a/frame/bounties/src/lib.rs
+++ b/frame/bounties/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs
index 4ebff64b4e4823de5ab5946dcdec42529f5eeb31..2f503f39b94bf3ae4bd5406ba29bbddfae799315 100644
--- a/frame/bounties/src/tests.rs
+++ b/frame/bounties/src/tests.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -82,6 +82,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
diff --git a/frame/bounties/src/weights.rs b/frame/bounties/src/weights.rs
index 6ba1b9d32b103dc0c4b6d7031ef35fb2413d9509..fcbee727abe5a308625fad051dda4e0ef076a467 100644
--- a/frame/bounties/src/weights.rs
+++ b/frame/bounties/src/weights.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs
index 551d6c7856cda3941b850868a28d5bf2cf37f87d..50fab1b3e474e74ee4f0964869b507c4e3f9dbaa 100644
--- a/frame/collective/src/benchmarking.rs
+++ b/frame/collective/src/benchmarking.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs
index efc8626d6892a6675af2e70a183e4cb2125fa82e..7c41b97996a68d75f01c2f7a4a6ec2456afe5147 100644
--- a/frame/collective/src/lib.rs
+++ b/frame/collective/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -996,6 +996,7 @@ mod tests {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
impl Config for Test {
type Origin = Origin;
diff --git a/frame/collective/src/weights.rs b/frame/collective/src/weights.rs
index 8a76ff516ca352932b107a5a60f0232e74b955e1..f8558c833f0162dfe01b3d4c5a138899ae497191 100644
--- a/frame/collective/src/weights.rs
+++ b/frame/collective/src/weights.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/contracts/common/src/lib.rs b/frame/contracts/common/src/lib.rs
index 9da105cf2d80a7f80a9c1cc30960c18931e73f04..2b325d63d628d5dffef806eb87f848ea74b1fe08 100644
--- a/frame/contracts/common/src/lib.rs
+++ b/frame/contracts/common/src/lib.rs
@@ -1,18 +1,19 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! A crate that hosts a common definitions that are relevant for the pallet-contracts.
diff --git a/frame/contracts/fixtures/chain_extension.wat b/frame/contracts/fixtures/chain_extension.wat
new file mode 100644
index 0000000000000000000000000000000000000000..db7e83fd96b42f41dbd44a4f3dc0bf38be11b4f4
--- /dev/null
+++ b/frame/contracts/fixtures/chain_extension.wat
@@ -0,0 +1,46 @@
+;; Call chain extension by passing through input and output of this contract
+(module
+ (import "seal0" "seal_call_chain_extension"
+ (func $seal_call_chain_extension (param i32 i32 i32 i32 i32) (result i32))
+ )
+ (import "seal0" "seal_input" (func $seal_input (param i32 i32)))
+ (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32)))
+ (import "env" "memory" (memory 16 16))
+
+ (func $assert (param i32)
+ (block $ok
+ (br_if $ok (get_local 0))
+ (unreachable)
+ )
+ )
+
+ ;; [0, 4) len of input output
+ (data (i32.const 0) "\02")
+
+ ;; [4, 12) buffer for input
+
+ ;; [12, 16) len of output buffer
+ (data (i32.const 12) "\02")
+
+ ;; [16, inf) buffer for output
+
+ (func (export "deploy"))
+
+ (func (export "call")
+ (call $seal_input (i32.const 4) (i32.const 0))
+
+ ;; the chain extension passes through the input and returns it as output
+ (call $seal_call_chain_extension
+ (i32.load8_u (i32.const 4)) ;; func_id
+ (i32.const 4) ;; input_ptr
+ (i32.load (i32.const 0)) ;; input_len
+ (i32.const 16) ;; output_ptr
+ (i32.const 12) ;; output_len_ptr
+ )
+
+ ;; the chain extension passes through the func_id
+ (call $assert (i32.eq (i32.load8_u (i32.const 4))))
+
+ (call $seal_return (i32.const 0) (i32.const 16) (i32.load (i32.const 12)))
+ )
+)
diff --git a/frame/contracts/fixtures/set_rent.wat b/frame/contracts/fixtures/set_rent.wat
index 1c6b512cc77acfd08f73eb6a29e01908885a462c..4abb7ffe9dbbbe02f52133a470586e459cd1823d 100644
--- a/frame/contracts/fixtures/set_rent.wat
+++ b/frame/contracts/fixtures/set_rent.wat
@@ -84,11 +84,11 @@
)
(i32.store (i32.const 128) (i32.const 64))
(call $seal_input
- (i32.const 104)
- (i32.const 100)
+ (i32.const 132)
+ (i32.const 128)
)
(call $seal_set_rent_allowance
- (i32.const 104)
+ (i32.const 132)
(i32.load (i32.const 128))
)
)
diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs
index 4e38508297d269f43c908c761c1c63edd17c77df..6fc2fbe82e037f462df729e55a9a7b44d59c8745 100644
--- a/frame/contracts/proc-macro/src/lib.rs
+++ b/frame/contracts/proc-macro/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/contracts/rpc/runtime-api/src/lib.rs b/frame/contracts/rpc/runtime-api/src/lib.rs
index 94b9fe7967c08aec6d8e25008e451f5bc82419ec..6f0399586fa221b414d72b0514ea5f12fd3d4e06 100644
--- a/frame/contracts/rpc/runtime-api/src/lib.rs
+++ b/frame/contracts/rpc/runtime-api/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs
index 6d43ea75c035fdfc2893df51358caee930ca26ca..e0a056906f7430fa8a7dcbfad4d20035f866edb9 100644
--- a/frame/contracts/rpc/src/lib.rs
+++ b/frame/contracts/rpc/src/lib.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,7 +33,7 @@ use sp_runtime::{
traits::{Block as BlockT, Header as HeaderT},
DispatchError,
};
-use std::convert::TryInto;
+use std::convert::{TryFrom, TryInto};
use pallet_contracts_primitives::ContractExecResult;
pub use pallet_contracts_rpc_runtime_api::ContractsApi as ContractsRuntimeApi;
@@ -76,10 +76,10 @@ impl From for Error {
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(deny_unknown_fields)]
-pub struct CallRequest {
+pub struct CallRequest {
origin: AccountId,
dest: AccountId,
- value: Balance,
+ value: number::NumberOrHex,
gas_limit: number::NumberOrHex,
input_data: Bytes,
}
@@ -141,7 +141,7 @@ pub trait ContractsApi {
#[rpc(name = "contracts_call")]
fn call(
&self,
- call_request: CallRequest,
+ call_request: CallRequest,
at: Option,
) -> Result;
@@ -201,11 +201,11 @@ where
<::Header as HeaderT>::Number,
>,
AccountId: Codec,
- Balance: Codec,
+ Balance: Codec + TryFrom,
{
fn call(
&self,
- call_request: CallRequest,
+ call_request: CallRequest,
at: Option<::Hash>,
) -> Result {
let api = self.client.runtime_api();
@@ -221,6 +221,13 @@ where
input_data,
} = call_request;
+ // Make sure that value fits into the balance type.
+ let value: Balance = value.try_into().map_err(|_| Error {
+ code: ErrorCode::InvalidParams,
+ message: format!("{:?} doesn't fit into the balance type", value),
+ data: None,
+ })?;
+
// Make sure that gas_limit fits into 64 bits.
let gas_limit: u64 = gas_limit.try_into().map_err(|_| Error {
code: ErrorCode::InvalidParams,
@@ -305,17 +312,18 @@ mod tests {
#[test]
fn call_request_should_serialize_deserialize_properly() {
- type Req = CallRequest;
+ type Req = CallRequest;
let req: Req = serde_json::from_str(r#"
{
"origin": "5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL",
"dest": "5DRakbLVnjVrW6niwLfHGW24EeCEvDAFGEXrtaYS5M4ynoom",
- "value": 0,
+ "value": "0x112210f4B16c1cb1",
"gasLimit": 1000000000000,
"inputData": "0x8c97db39"
}
"#).unwrap();
assert_eq!(req.gas_limit.into_u256(), U256::from(0xe8d4a51000u64));
+ assert_eq!(req.value.into_u256(), U256::from(1234567890987654321u128));
}
#[test]
diff --git a/frame/contracts/src/benchmarking/code.rs b/frame/contracts/src/benchmarking/code.rs
index 847be9b434cba720e6332a162b5311284ee01f81..88e8b265a57e1e46981f339861605e073c1f42fd 100644
--- a/frame/contracts/src/benchmarking/code.rs
+++ b/frame/contracts/src/benchmarking/code.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs
index 4bdd279eb8b2cf856394d55ff366b547d0499edb..d6092f40a67bb824ac765e0937d2eb5d6418c111 100644
--- a/frame/contracts/src/benchmarking/mod.rs
+++ b/frame/contracts/src/benchmarking/mod.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/contracts/src/benchmarking/sandbox.rs b/frame/contracts/src/benchmarking/sandbox.rs
index 61277ebce6780832930bd91d8d079cf6498bca26..a97fcc2b113ecfb290a264b7c2416641d701938a 100644
--- a/frame/contracts/src/benchmarking/sandbox.rs
+++ b/frame/contracts/src/benchmarking/sandbox.rs
@@ -1,6 +1,6 @@
// This file is part of Substrate.
-// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs
new file mode 100644
index 0000000000000000000000000000000000000000..662cfb2053e6ef45ff1ab1c21f9adc166e70df47
--- /dev/null
+++ b/frame/contracts/src/chain_extension.rs
@@ -0,0 +1,393 @@
+// This file is part of Substrate.
+
+// Copyright (C) 2020 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! A mechanism for runtime authors to augment the functionality of contracts.
+//!
+//! The runtime is able to call into any contract and retrieve the result using
+//! [`bare_call`](crate::Module::bare_call). This already allows customization of runtime
+//! behaviour by user generated code (contracts). However, often it is more straightforward
+//! to allow the reverse behaviour: The contract calls into the runtime. We call the latter
+//! one a "chain extension" because it allows the chain to extend the set of functions that are
+//! callable by a contract.
+//!
+//! In order to create a chain extension the runtime author implements the [`ChainExtension`]
+//! trait and declares it in this pallet's [configuration Trait](crate::Config). All types
+//! required for this endeavour are defined or re-exported in this module. There is an
+//! implementation on `()` which can be used to signal that no chain extension is available.
+//!
+//! # Security
+//!
+//! The chain author alone is responsible for the security of the chain extension.
+//! This includes avoiding the exposure of exploitable functions and charging the
+//! appropriate amount of weight. In order to do so benchmarks must be written and the
+//! [`charge_weight`](Environment::charge_weight) function must be called **before**
+//! carrying out any action that causes the consumption of the chargeable weight.
+//! It cannot be overstated how delicate of a process the creation of a chain extension
+//! is. Check whether using [`bare_call`](crate::Module::bare_call) suffices for the
+//! use case at hand.
+//!
+//! # Benchmarking
+//!
+//! The builtin contract callable functions that pallet-contracts provides all have
+//! benchmarks that determine the correct weight that an invocation of these functions
+//! induces. In order to be able to charge the correct weight for the functions defined
+//! by a chain extension benchmarks must be written, too. In the near future this crate
+//! will provide the means for easier creation of those specialized benchmarks.
+
+use crate::{
+ Error,
+ wasm::{Runtime, RuntimeToken},
+};
+use codec::Decode;
+use frame_support::weights::Weight;
+use sp_runtime::DispatchError;
+use sp_std::{
+ marker::PhantomData,
+ vec::Vec,
+};
+
+pub use frame_system::Config as SysConfig;
+pub use pallet_contracts_primitives::ReturnFlags;
+pub use sp_core::crypto::UncheckedFrom;
+pub use crate::exec::Ext;
+pub use state::Init as InitState;
+
+/// Result that returns a [`DispatchError`] on error.
+pub type Result = sp_std::result::Result;
+
+/// A trait used to extend the set of contract callable functions.
+///
+/// In order to create a custom chain extension this trait must be implemented and supplied
+/// to the pallet contracts configuration trait as the associated type of the same name.
+/// Consult the [module documentation](self) for a general explanation of chain extensions.
+pub trait ChainExtension {
+ /// Call the chain extension logic.
+ ///
+ /// This is the only function that needs to be implemented in order to write a
+ /// chain extensions. It is called whenever a contract calls the `seal_call_chain_extension`
+ /// imported wasm function.
+ ///
+ /// # Parameters
+ /// - `func_id`: The first argument to `seal_call_chain_extension`. Usually used to
+ /// determine which function to realize.
+ /// - `env`: Access to the remaining arguments and the execution environment.
+ ///
+ /// # Return
+ ///
+ /// In case of `Err` the contract execution is immediatly suspended and the passed error
+ /// is returned to the caller. Otherwise the value of [`RetVal`] determines the exit
+ /// behaviour.
+ fn call(func_id: u32, env: Environment) -> Result
+ where
+ ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>;
+
+ /// Determines whether chain extensions are enabled for this chain.
+ ///
+ /// The default implementation returns `true`. Therefore it is not necessary to overwrite
+ /// this function when implementing a chain extension. In case of `false` the deployment of
+ /// a contract that references `seal_call_chain_extension` will be denied and calling this
+ /// function will return [`NoChainExtension`](Error::NoChainExtension) without first calling
+ /// into [`call`](Self::call).
+ fn enabled() -> bool {
+ true
+ }
+}
+
+/// Implementation that indicates that no chain extension is available.
+impl ChainExtension for () {
+ fn call(_func_id: u32, mut _env: Environment) -> Result
+ where
+ ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>,
+ {
+ // Never called since [`Self::enabled()`] is set to `false`. Because we want to
+ // avoid panics at all costs we supply a sensible error value here instead
+ // of an `unimplemented!`.
+ Err(Error::::NoChainExtension.into())
+ }
+
+ fn enabled() -> bool {
+ false
+ }
+}
+
+/// Determines the exit behaviour and return value of a chain extension.
+pub enum RetVal {
+ /// The chain extensions returns the supplied value to its calling contract.
+ Converging(u32),
+ /// The control does **not** return to the calling contract.
+ ///
+ /// Use this to stop the execution of the contract when the chain extension returns.
+ /// The semantic is the same as for calling `seal_return`: The control returns to
+ /// the caller of the currently executing contract yielding the supplied buffer and
+ /// flags.
+ Diverging{flags: ReturnFlags, data: Vec},
+}
+
+/// Grants the chain extension access to its parameters and execution environment.
+///
+/// It uses the typestate pattern to enforce the correct usage of the parameters passed
+/// to the chain extension.
+pub struct Environment<'a, 'b, E: Ext, S: state::State> {
+ /// The actual data of this type.
+ inner: Inner<'a, 'b, E>,
+ /// `S` is only used in the type system but never as value.
+ phantom: PhantomData,
+}
+
+/// Functions that are available in every state of this type.
+impl<'a, 'b, E: Ext, S: state::State> Environment<'a, 'b, E, S>
+where
+ ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>,
+{
+ /// Charge the passed `amount` of weight from the overall limit.
+ ///
+ /// It returns `Ok` when there the remaining weight budget is larger than the passed
+ /// `weight`. It returns `Err` otherwise. In this case the chain extension should
+ /// abort the execution and pass through the error.
+ ///
+ /// # Note
+ ///
+ /// Weight is synonymous with gas in substrate.
+ pub fn charge_weight(&mut self, amount: Weight) -> Result<()> {
+ self.inner.runtime.charge_gas(RuntimeToken::ChainExtension(amount)).map(|_| ())
+ }
+
+ /// Grants access to the execution environment of the current contract call.
+ ///
+ /// Consult the functions on the returned type before re-implementing those functions.
+ pub fn ext(&mut self) -> &mut E {
+ self.inner.runtime.ext()
+ }
+}
+
+/// Functions that are only available in the initial state of this type.
+///
+/// Those are the functions that determine how the arguments to the chain extensions
+/// should be consumed.
+impl<'a, 'b, E: Ext> Environment<'a, 'b, E, state::Init> {
+ /// Creates a new environment for consumption by a chain extension.
+ ///
+ /// It is only available to this crate because only the wasm runtime module needs to
+ /// ever create this type. Chain extensions merely consume it.
+ pub(crate) fn new(
+ runtime: &'a mut Runtime::<'b, E>,
+ input_ptr: u32,
+ input_len: u32,
+ output_ptr: u32,
+ output_len_ptr: u32,
+ ) -> Self {
+ Environment {
+ inner: Inner {
+ runtime,
+ input_ptr,
+ input_len,
+ output_ptr,
+ output_len_ptr,
+ },
+ phantom: PhantomData,
+ }
+ }
+
+ /// Use all arguments as integer values.
+ pub fn only_in(self) -> Environment<'a, 'b, E, state::OnlyIn> {
+ Environment {
+ inner: self.inner,
+ phantom: PhantomData,
+ }
+ }
+
+ /// Use input arguments as integer and output arguments as pointer to a buffer.
+ pub fn prim_in_buf_out(self) -> Environment<'a, 'b, E, state::PrimInBufOut> {
+ Environment {
+ inner: self.inner,
+ phantom: PhantomData,
+ }
+ }
+
+ /// Use input and output arguments as pointers to a buffer.
+ pub fn buf_in_buf_out(self) -> Environment<'a, 'b, E, state::BufInBufOut> {
+ Environment {
+ inner: self.inner,
+ phantom: PhantomData,
+ }
+ }
+}
+
+/// Functions to use the input arguments as integers.
+impl<'a, 'b, E: Ext, S: state::PrimIn> Environment<'a, 'b, E, S> {
+ /// The `input_ptr` argument.
+ pub fn val0(&self) -> u32 {
+ self.inner.input_ptr
+ }
+
+ /// The `input_len` argument.
+ pub fn val1(&self) -> u32 {
+ self.inner.input_len
+ }
+}
+
+/// Functions to use the output arguments as integers.
+impl<'a, 'b, E: Ext, S: state::PrimOut> Environment<'a, 'b, E, S> {
+ /// The `output_ptr` argument.
+ pub fn val2(&self) -> u32 {
+ self.inner.output_ptr
+ }
+
+ /// The `output_len_ptr` argument.
+ pub fn val3(&self) -> u32 {
+ self.inner.output_len_ptr
+ }
+}
+
+/// Functions to use the input arguments as pointer to a buffer.
+impl<'a, 'b, E: Ext, S: state::BufIn> Environment<'a, 'b, E, S>
+where
+ ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>,
+{
+ /// Reads `min(max_len, in_len)` from contract memory.
+ ///
+ /// This does **not** charge any weight. The caller must make sure that the an
+ /// appropriate amount of weight is charged **before** reading from contract memory.
+ /// The reason for that is that usually the costs for reading data and processing
+ /// said data cannot be separated in a benchmark. Therefore a chain extension would
+ /// charge the overall costs either using `max_len` (worst case approximation) or using
+ /// [`in_len()`](Self::in_len).
+ pub fn read(&self, max_len: u32) -> Result> {
+ self.inner.runtime.read_sandbox_memory(
+ self.inner.input_ptr,
+ self.inner.input_len.min(max_len),
+ )
+ }
+
+ /// Reads `min(buffer.len(), in_len) from contract memory.
+ ///
+ /// This takes a mutable pointer to a buffer fills it with data and shrinks it to
+ /// the size of the actual data. Apart from supporting pre-allocated buffers it is
+ /// equivalent to to [`read()`](Self::read).
+ pub fn read_into(&self, buffer: &mut &mut [u8]) -> Result<()> {
+ let len = buffer.len();
+ let sliced = {
+ let buffer = core::mem::take(buffer);
+ &mut buffer[..len.min(self.inner.input_len as usize)]
+ };
+ self.inner.runtime.read_sandbox_memory_into_buf(
+ self.inner.input_ptr,
+ sliced,
+ )?;
+ *buffer = sliced;
+ Ok(())
+ }
+
+ /// Reads `in_len` from contract memory and scale decodes it.
+ ///
+ /// This function is secure and recommended for all input types of fixed size
+ /// as long as the cost of reading the memory is included in the overall already charged
+ /// weight of the chain extension. This should usually be the case when fixed input types
+ /// are used. Non fixed size types (like everything using `Vec`) usually need to use
+ /// [`in_len()`](Self::in_len) in order to properly charge the necessary weight.
+ pub fn read_as(&mut self) -> Result {
+ self.inner.runtime.read_sandbox_memory_as(
+ self.inner.input_ptr,
+ self.inner.input_len,
+ )
+ }
+
+ /// The length of the input as passed in as `input_len`.
+ ///
+ /// A chain extension would use this value to calculate the dynamic part of its
+ /// weight. For example a chain extension that calculates the hash of some passed in
+ /// bytes would use `in_len` to charge the costs of hashing that amount of bytes.
+ /// This also subsumes the act of copying those bytes as a benchmarks measures both.
+ pub fn in_len(&self) -> u32 {
+ self.inner.input_len
+ }
+}
+
+/// Functions to use the output arguments as pointer to a buffer.
+impl<'a, 'b, E: Ext, S: state::BufOut> Environment<'a, 'b, E, S>
+where
+ ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>,
+{
+ /// Write the supplied buffer to contract memory.
+ ///
+ /// If the contract supplied buffer is smaller than the passed `buffer` an `Err` is returned.
+ /// If `allow_skip` is set to true the contract is allowed to skip the copying of the buffer
+ /// by supplying the guard value of [`u32::max_value()`] as `out_ptr`. The
+ /// `weight_per_byte` is only charged when the write actually happens and is not skipped or
+ /// failed due to a too small output buffer.
+ pub fn write(
+ &mut self,
+ buffer: &[u8],
+ allow_skip: bool,
+ weight_per_byte: Option,
+ ) -> Result<()> {
+ self.inner.runtime.write_sandbox_output(
+ self.inner.output_ptr,
+ self.inner.output_len_ptr,
+ buffer,
+ allow_skip,
+ |len| {
+ weight_per_byte.map(|w| RuntimeToken::ChainExtension(w.saturating_mul(len.into())))
+ },
+ )
+ }
+}
+
+/// The actual data of an `Environment`.
+///
+/// All data is put into this struct to easily pass it around as part of the typestate
+/// pattern. Also it creates the opportunity to box this struct in the future in case it
+/// gets too large.
+struct Inner<'a, 'b, E: Ext> {
+ /// The runtime contains all necessary functions to interact with the running contract.
+ runtime: &'a mut Runtime::<'b, E>,
+ /// Verbatim argument passed to `seal_call_chain_extension`.
+ input_ptr: u32,
+ /// Verbatim argument passed to `seal_call_chain_extension`.
+ input_len: u32,
+ /// Verbatim argument passed to `seal_call_chain_extension`.
+ output_ptr: u32,
+ /// Verbatim argument passed to `seal_call_chain_extension`.
+ output_len_ptr: u32,
+}
+
+/// Private submodule with public types to prevent other modules from naming them.
+mod state {
+ pub trait State {}
+
+ pub trait PrimIn: State {}
+ pub trait PrimOut: State {}
+ pub trait BufIn: State {}
+ pub trait BufOut: State {}
+
+ pub enum Init {}
+ pub enum OnlyIn {}
+ pub enum PrimInBufOut {}
+ pub enum BufInBufOut {}
+
+ impl State for Init {}
+ impl State for OnlyIn {}
+ impl State for PrimInBufOut {}
+ impl State for BufInBufOut {}
+
+ impl PrimIn for OnlyIn {}
+ impl PrimOut for OnlyIn {}
+ impl PrimIn for PrimInBufOut {}
+ impl BufOut for PrimInBufOut {}
+ impl BufIn for BufInBufOut {}
+ impl BufOut for BufInBufOut {}
+}
diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs
index 8577d04452fa8659abd095984a1fa8daf8507e94..b5f4034b5bff11f2cc40cabbbe9a74498129500d 100644
--- a/frame/contracts/src/exec.rs
+++ b/frame/contracts/src/exec.rs
@@ -1,18 +1,19 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
use crate::{
CodeHash, ConfigCache, Event, RawEvent, Config, Module as Contracts,
diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs
index 18a200fd312cd58748d8be01a02165d2df877ecc..9bb6185e558ac86668fbd46236e7d3b0596758e6 100644
--- a/frame/contracts/src/gas.rs
+++ b/frame/contracts/src/gas.rs
@@ -1,18 +1,19 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
use crate::Config;
use sp_std::marker::PhantomData;
@@ -31,7 +32,7 @@ pub type Gas = frame_support::weights::Weight;
#[must_use]
#[derive(Debug, PartialEq, Eq)]
pub enum GasMeterResult {
- Proceed,
+ Proceed(ChargedAmount),
OutOfGas,
}
@@ -39,11 +40,20 @@ impl GasMeterResult {
pub fn is_out_of_gas(&self) -> bool {
match *self {
GasMeterResult::OutOfGas => true,
- GasMeterResult::Proceed => false,
+ GasMeterResult::Proceed(_) => false,
}
}
}
+#[derive(Debug, PartialEq, Eq)]
+pub struct ChargedAmount(Gas);
+
+impl ChargedAmount {
+ pub fn amount(&self) -> Gas {
+ self.0
+ }
+}
+
#[cfg(not(test))]
pub trait TestAuxiliaries {}
#[cfg(not(test))]
@@ -138,17 +148,18 @@ impl GasMeter {
self.gas_left = new_value.unwrap_or_else(Zero::zero);
match new_value {
- Some(_) => GasMeterResult::Proceed,
+ Some(_) => GasMeterResult::Proceed(ChargedAmount(amount)),
None => GasMeterResult::OutOfGas,
}
}
- // Account for not fully used gas.
- //
- // This can be used after dispatching a runtime call to refund gas that was not
- // used by the dispatchable.
- pub fn refund(&mut self, gas: Gas) {
- self.gas_left = self.gas_left.saturating_add(gas).max(self.gas_limit);
+ /// Refund previously charged gas back to the gas meter.
+ ///
+ /// This can be used if a gas worst case estimation must be charged before
+ /// performing a certain action. This way the difference can be refundend when
+ /// the worst case did not happen.
+ pub fn refund(&mut self, amount: ChargedAmount) {
+ self.gas_left = self.gas_left.saturating_add(amount.0).min(self.gas_limit)
}
/// Allocate some amount of gas and perform some work with
diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs
index f0200fbd15fd490b48c6fae6a8a0fbd26be3e02d..ad694b0c877b28dca523ee9eb5e028730db21a82 100644
--- a/frame/contracts/src/lib.rs
+++ b/frame/contracts/src/lib.rs
@@ -1,18 +1,19 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! # Contract Module
//!
@@ -88,6 +89,8 @@ mod wasm;
mod rent;
mod benchmarking;
mod schedule;
+
+pub mod chain_extension;
pub mod weights;
#[cfg(test)]
@@ -319,6 +322,9 @@ pub trait Config: frame_system::Config {
/// Describes the weights of the dispatchables of this module and is also used to
/// construct a default cost schedule.
type WeightInfo: WeightInfo;
+
+ /// Type that allows the runtime authors to add new host functions for a contract to call.
+ type ChainExtension: chain_extension::ChainExtension;
}
decl_error! {
@@ -378,6 +384,18 @@ decl_error! {
/// on the call stack. Those actions are contract self destruction and restoration
/// of a tombstone.
ReentranceDenied,
+ /// `seal_input` was called twice from the same contract execution context.
+ InputAlreadyRead,
+ /// The subject passed to `seal_random` exceeds the limit.
+ RandomSubjectTooLong,
+ /// The amount of topics passed to `seal_deposit_events` exceeds the limit.
+ TooManyTopics,
+ /// The topics passed to `seal_deposit_events` contains at least one duplicate.
+ DuplicateTopics,
+ /// The chain does not provide a chain extension. Calling the chain extension results
+ /// in this error. Note that this usually shouldn't happen as deploying such contracts
+ /// is rejected.
+ NoChainExtension,
}
}
diff --git a/frame/contracts/src/rent.rs b/frame/contracts/src/rent.rs
index 8b6f81c916bef4f822cb42d50e91566adef49704..d31efd5f55261a1b7249a459ab05e00709037695 100644
--- a/frame/contracts/src/rent.rs
+++ b/frame/contracts/src/rent.rs
@@ -1,18 +1,19 @@
-// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! A module responsible for computing the right amount of weight and charging it.
@@ -451,14 +452,19 @@ where
origin_contract.last_write
};
- let key_values_taken = delta.iter()
+ // We are allowed to eagerly modify storage even though the function can
+ // fail later due to tombstones not matching. This is because the restoration
+ // is always called from a contract and therefore in a storage transaction.
+ // The failure of this function will lead to this transaction's rollback.
+ let bytes_taken: u32 = delta.iter()
.filter_map(|key| {
- child::get_raw(&child_trie_info, &blake2_256(key)).map(|value| {
- child::kill(&child_trie_info, &blake2_256(key));
- (key, value)
+ let key = blake2_256(key);
+ child::get_raw(&child_trie_info, &key).map(|value| {
+ child::kill(&child_trie_info, &key);
+ value.len() as u32
})
})
- .collect::>();
+ .sum();
let tombstone = >::new(
// This operation is cheap enough because last_write (delta not included)
@@ -468,15 +474,10 @@ where
);
if tombstone != dest_tombstone {
- for (key, value) in key_values_taken {
- child::put_raw(&child_trie_info, &blake2_256(key), &value);
- }
return Err(Error::::InvalidTombstone.into());
}
- origin_contract.storage_size -= key_values_taken.iter()
- .map(|(_, value)| value.len() as u32)
- .sum::();
+ origin_contract.storage_size -= bytes_taken;
>::remove(&origin);
>::insert(&dest, ContractInfo::Alive(AliveContractInfo:: {
diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs
index df1ea240630cd26c9a1bd338547b8e3fb327213f..e6902c53b9c7e51adf05e31597f5ccc87330917e 100644
--- a/frame/contracts/src/schedule.rs
+++ b/frame/contracts/src/schedule.rs
@@ -1,18 +1,19 @@
-// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! This module contains the cost schedule and supporting code that constructs a
//! sane default schedule from a `WeightInfo` implementation.
diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs
index ba09adb285b938fd8259ecd7ade37b70c9cf4be1..180ec7237ff0d667bb33b7ef128fb9cdc4adeaf1 100644
--- a/frame/contracts/src/storage.rs
+++ b/frame/contracts/src/storage.rs
@@ -1,18 +1,19 @@
-// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! This module contains routines for accessing and altering a contract related state.
@@ -225,4 +226,4 @@ where
.and_then(|i| i.as_alive().map(|i| i.code_hash))
.ok_or(ContractAbsentError)
}
-}
\ No newline at end of file
+}
diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs
index c0b9b671068d6705e5375b15af41891b86a49f9e..1f069a9b4652be0c296a4dad7251e4d11754b0c1 100644
--- a/frame/contracts/src/tests.rs
+++ b/frame/contracts/src/tests.rs
@@ -1,23 +1,28 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
use crate::{
BalanceOf, ContractInfo, ContractInfoOf, GenesisConfig, Module,
RawAliveContractInfo, RawEvent, Config, Schedule, gas::Gas,
Error, ConfigCache, RuntimeReturnCode, storage::Storage,
+ chain_extension::{
+ Result as ExtensionResult, Environment, ChainExtension, Ext, SysConfig, RetVal,
+ UncheckedFrom, InitState, ReturnFlags,
+ },
exec::AccountIdOf,
};
use assert_matches::assert_matches;
@@ -100,6 +105,85 @@ pub mod test_utils {
}
}
+thread_local! {
+ static TEST_EXTENSION: sp_std::cell::RefCell = Default::default();
+}
+
+pub struct TestExtension {
+ enabled: bool,
+ last_seen_buffer: Vec,
+ last_seen_inputs: (u32, u32, u32, u32),
+}
+
+impl TestExtension {
+ fn disable() {
+ TEST_EXTENSION.with(|e| e.borrow_mut().enabled = false)
+ }
+
+ fn last_seen_buffer() -> Vec {
+ TEST_EXTENSION.with(|e| e.borrow().last_seen_buffer.clone())
+ }
+
+ fn last_seen_inputs() -> (u32, u32, u32, u32) {
+ TEST_EXTENSION.with(|e| e.borrow().last_seen_inputs.clone())
+ }
+}
+
+impl Default for TestExtension {
+ fn default() -> Self {
+ Self {
+ enabled: true,
+ last_seen_buffer: vec![],
+ last_seen_inputs: (0, 0, 0, 0),
+ }
+ }
+}
+
+impl ChainExtension for TestExtension {
+ fn call(func_id: u32, env: Environment) -> ExtensionResult
+ where
+ ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>,
+ {
+ match func_id {
+ 0 => {
+ let mut env = env.buf_in_buf_out();
+ let input = env.read(2)?;
+ env.write(&input, false, None)?;
+ TEST_EXTENSION.with(|e| e.borrow_mut().last_seen_buffer = input);
+ Ok(RetVal::Converging(func_id))
+ },
+ 1 => {
+ let env = env.only_in();
+ TEST_EXTENSION.with(|e|
+ e.borrow_mut().last_seen_inputs = (
+ env.val0(), env.val1(), env.val2(), env.val3()
+ )
+ );
+ Ok(RetVal::Converging(func_id))
+ },
+ 2 => {
+ let mut env = env.buf_in_buf_out();
+ let weight = env.read(2)?[1].into();
+ env.charge_weight(weight)?;
+ Ok(RetVal::Converging(func_id))
+ },
+ 3 => {
+ Ok(RetVal::Diverging{
+ flags: ReturnFlags::REVERT,
+ data: vec![42, 99],
+ })
+ },
+ _ => {
+ panic!("Passed unknown func_id to test chain extension: {}", func_id);
+ }
+ }
+ }
+
+ fn enabled() -> bool {
+ TEST_EXTENSION.with(|e| e.borrow().enabled)
+ }
+}
+
#[derive(Clone, Eq, PartialEq, Debug)]
pub struct Test;
parameter_types! {
@@ -130,6 +214,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
+ type SS58Prefix = ();
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
@@ -186,6 +271,7 @@ impl Config for Test {
type MaxValueSize = MaxValueSize;
type WeightPrice = Self;
type WeightInfo = ();
+ type ChainExtension = TestExtension;
}
type Balances = pallet_balances::Module;
@@ -698,7 +784,6 @@ fn initialize_block(number: u64) {
System::initialize(
&number,
&[0u8; 32].into(),
- &[0u8; 32].into(),
&Default::default(),
Default::default(),
);
@@ -1221,7 +1306,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
30_000,
GAS_LIMIT,
restoration_code_hash.into(),
- ::Balance::from(0u32).encode(),
+ vec![],
vec![],
));
let addr_django = Contracts::contract_address(&CHARLIE, &restoration_code_hash, &[]);
@@ -1253,6 +1338,15 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
)
};
+ // The key that is used in the restorer contract but is not in the target contract.
+ // Is supplied as delta to the restoration. We need it to check whether the key
+ // is properly removed on success but still there on failure.
+ let delta_key = {
+ let mut key = [0u8; 32];
+ key[0] = 1;
+ key
+ };
+
if test_different_storage || test_restore_to_with_dirty_storage {
// Parametrization of the test imply restoration failure. Check that `DJANGO` aka
// restoration contract is still in place and also that `BOB` doesn't exist.
@@ -1263,6 +1357,10 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
assert_eq!(django_contract.storage_size, 8);
assert_eq!(django_contract.trie_id, django_trie_id);
assert_eq!(django_contract.deduct_block, System::block_number());
+ assert_eq!(
+ Storage::::read(&django_trie_id, &delta_key),
+ Some(vec![40, 0, 0, 0]),
+ );
match (test_different_storage, test_restore_to_with_dirty_storage) {
(true, false) => {
assert_err_ignore_postinfo!(
@@ -1321,7 +1419,6 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
// Here we expect that the restoration is succeeded. Check that the restoration
// contract `DJANGO` ceased to exist and that `BOB` returned back.
- println!("{:?}", ContractInfoOf::::get(&addr_bob));
let bob_contract = ContractInfoOf::::get(&addr_bob).unwrap()
.get_alive().unwrap();
assert_eq!(bob_contract.rent_allowance, 50);
@@ -1329,6 +1426,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
assert_eq!(bob_contract.trie_id, django_trie_id);
assert_eq!(bob_contract.deduct_block, System::block_number());
assert!(ContractInfoOf::::get(&addr_django).is_none());
+ assert_matches!(Storage::::read(&django_trie_id, &delta_key), None);
assert_eq!(System::events(), vec![
EventRecord {
phase: Phase::Initialization,
@@ -1919,3 +2017,120 @@ fn instantiate_return_code() {
});
}
+
+#[test]
+fn disabled_chain_extension_wont_deploy() {
+ let (code, _hash) = compile_module::("chain_extension").unwrap();
+ ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
+ let subsistence = ConfigCache::::subsistence_threshold_uncached();
+ let _ = Balances::deposit_creating(&ALICE, 10 * subsistence);
+ TestExtension::disable();
+ assert_eq!(
+ Contracts::put_code(Origin::signed(ALICE), code),
+ Err("module uses chain extensions but chain extensions are disabled".into()),
+ );
+ });
+}
+
+#[test]
+fn disabled_chain_extension_errors_on_call() {
+ let (code, hash) = compile_module::("chain_extension").unwrap();
+ ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
+ let subsistence = ConfigCache::::subsistence_threshold_uncached();
+ let _ = Balances::deposit_creating(&ALICE, 10 * subsistence);
+ assert_ok!(Contracts::put_code(Origin::signed(ALICE), code));
+ TestExtension::disable();
+ assert_ok!(
+ Contracts::instantiate(
+ Origin::signed(ALICE),
+ subsistence,
+ GAS_LIMIT,
+ hash.into(),
+ vec![],
+ vec![],
+ ),
+ );
+ let addr = Contracts::contract_address(&ALICE, &hash, &[]);
+ assert_err_ignore_postinfo!(
+ Contracts::call(
+ Origin::signed(ALICE),
+ addr.clone(),
+ 0,
+ GAS_LIMIT,
+ vec![],
+ ),
+ Error::::NoChainExtension,
+ );
+ });
+}
+
+#[test]
+fn chain_extension_works() {
+ let (code, hash) = compile_module::("chain_extension").unwrap();
+ ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
+ let subsistence = ConfigCache::::subsistence_threshold_uncached();
+ let _ = Balances::deposit_creating(&ALICE, 10 * subsistence);
+ assert_ok!(Contracts::put_code(Origin::signed(ALICE), code));
+ assert_ok!(
+ Contracts::instantiate(
+ Origin::signed(ALICE),
+ subsistence,
+ GAS_LIMIT,
+ hash.into(),
+ vec![],
+ vec![],
+ ),
+ );
+ let addr = Contracts::contract_address(&ALICE, &hash, &[]);
+
+ // The contract takes a up to 2 byte buffer where the first byte passed is used as
+ // as func_id to the chain extension which behaves differently based on the
+ // func_id.
+
+ // 0 = read input buffer and pass it through as output
+ let result = Contracts::bare_call(
+ ALICE,
+ addr.clone(),
+ 0,
+ GAS_LIMIT,
+ vec![0, 99],
+ );
+ let gas_consumed = result.gas_consumed;
+ assert_eq!(TestExtension::last_seen_buffer(), vec![0, 99]);
+ assert_eq!(result.exec_result.unwrap().data, vec![0, 99]);
+
+ // 1 = treat inputs as integer primitives and store the supplied integers
+ Contracts::bare_call(
+ ALICE,
+ addr.clone(),
+ 0,
+ GAS_LIMIT,
+ vec![1],
+ ).exec_result.unwrap();
+ // those values passed in the fixture
+ assert_eq!(TestExtension::last_seen_inputs(), (4, 1, 16, 12));
+
+ // 2 = charge some extra weight (amount supplied in second byte)
+ let result = Contracts::bare_call(
+ ALICE,
+ addr.clone(),
+ 0,
+ GAS_LIMIT,
+ vec![2, 42],
+ );
+ assert_ok!(result.exec_result);
+ assert_eq!(result.gas_consumed, gas_consumed + 42);
+
+ // 3 = diverging chain extension call that sets flags to 0x1 and returns a fixed buffer
+ let result = Contracts::bare_call(
+ ALICE,
+ addr.clone(),
+ 0,
+ GAS_LIMIT,
+ vec![3],
+ ).exec_result.unwrap();
+ assert_eq!(result.flags, ReturnFlags::REVERT);
+ assert_eq!(result.data, vec![42, 99]);
+ });
+}
+
diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs
index d90c7502b85e699b6979cf116254cbdb1e75ffcb..3150ee4b7bde7166e2b1ea2e47f46417480e448b 100644
--- a/frame/contracts/src/wasm/code_cache.rs
+++ b/frame/contracts/src/wasm/code_cache.rs
@@ -1,18 +1,19 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! A module that implements instrumented code cache.
//!
diff --git a/frame/contracts/src/wasm/env_def/macros.rs b/frame/contracts/src/wasm/env_def/macros.rs
index cc61deb074b756a9669f31e22ae7556b8677e7d5..dbb6705e9722d7d257ed034e944932b5dc240297 100644
--- a/frame/contracts/src/wasm/env_def/macros.rs
+++ b/frame/contracts/src/wasm/env_def/macros.rs
@@ -1,18 +1,19 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! Definition of macros that hides boilerplate of defining external environment
//! for a wasm module.
@@ -96,7 +97,7 @@ macro_rules! unmarshall_then_body {
#[inline(always)]
pub fn constrain_closure(f: F) -> F
where
- F: FnOnce() -> Result,
+ F: FnOnce() -> Result,
{
f
}
@@ -109,14 +110,20 @@ macro_rules! unmarshall_then_body_then_marshall {
>(|| {
unmarshall_then_body!($body, $ctx, $args_iter, $( $names : $params ),*)
});
- let r = body()?;
+ let r = body().map_err(|reason| {
+ $ctx.set_trap_reason(reason);
+ sp_sandbox::HostError
+ })?;
return Ok(sp_sandbox::ReturnValue::Value({ use $crate::wasm::env_def::ConvertibleToWasm; r.to_typed_value() }))
});
( $args_iter:ident, $ctx:ident, ( $( $names:ident : $params:ty ),* ) => $body:tt ) => ({
let body = $crate::wasm::env_def::macros::constrain_closure::<(), _>(|| {
unmarshall_then_body!($body, $ctx, $args_iter, $( $names : $params ),*)
});
- body()?;
+ body().map_err(|reason| {
+ $ctx.set_trap_reason(reason);
+ sp_sandbox::HostError
+ })?;
return Ok(sp_sandbox::ReturnValue::Unit)
})
}
@@ -207,15 +214,24 @@ mod tests {
use parity_wasm::elements::ValueType;
use sp_runtime::traits::Zero;
use sp_sandbox::{ReturnValue, Value};
- use crate::wasm::tests::MockExt;
- use crate::wasm::Runtime;
- use crate::exec::Ext;
- use crate::gas::Gas;
+ use crate::{
+ wasm::{Runtime, runtime::TrapReason, tests::MockExt},
+ exec::Ext,
+ gas::Gas,
+ };
+
+ struct TestRuntime {
+ value: u32,
+ }
+
+ impl TestRuntime {
+ fn set_trap_reason(&mut self, _reason: TrapReason) {}
+ }
#[test]
fn macro_unmarshall_then_body_then_marshall_value_or_trap() {
fn test_value(
- _ctx: &mut u32,
+ _ctx: &mut TestRuntime,
args: &[sp_sandbox::Value],
) -> Result {
let mut args = args.iter();
@@ -224,7 +240,7 @@ mod tests {
_ctx,
(a: u32, b: u32) -> u32 => {
if b == 0 {
- Err(sp_sandbox::HostError)
+ Err(crate::wasm::runtime::TrapReason::Termination)
} else {
Ok(a / b)
}
@@ -232,7 +248,7 @@ mod tests {
)
}
- let ctx = &mut 0;
+ let ctx = &mut TestRuntime { value: 0 };
assert_eq!(
test_value(ctx, &[Value::I32(15), Value::I32(3)]).unwrap(),
ReturnValue::Value(Value::I32(5)),
@@ -243,7 +259,7 @@ mod tests {
#[test]
fn macro_unmarshall_then_body_then_marshall_unit() {
fn test_unit(
- ctx: &mut u32,
+ ctx: &mut TestRuntime,
args: &[sp_sandbox::Value],
) -> Result {
let mut args = args.iter();
@@ -251,16 +267,16 @@ mod tests {
args,
ctx,
(a: u32, b: u32) => {
- *ctx = a + b;
+ ctx.value = a + b;
Ok(())
}
)
}
- let ctx = &mut 0;
+ let ctx = &mut TestRuntime { value: 0 };
let result = test_unit(ctx, &[Value::I32(2), Value::I32(3)]).unwrap();
assert_eq!(result, ReturnValue::Unit);
- assert_eq!(*ctx, 5);
+ assert_eq!(ctx.value, 5);
}
#[test]
@@ -270,7 +286,7 @@ mod tests {
if !amount.is_zero() {
Ok(())
} else {
- Err(sp_sandbox::HostError)
+ Err(TrapReason::Termination)
}
});
let _f: fn(&mut Runtime, &[sp_sandbox::Value])
@@ -322,7 +338,7 @@ mod tests {
if !amount.is_zero() {
Ok(())
} else {
- Err(sp_sandbox::HostError)
+ Err(crate::wasm::runtime::TrapReason::Termination)
}
},
);
diff --git a/frame/contracts/src/wasm/env_def/mod.rs b/frame/contracts/src/wasm/env_def/mod.rs
index 7b67f74ec95c8db4495931c9ab1a0318db7e8aa4..0d9ceeee02373ec81c41eb501272741334566f36 100644
--- a/frame/contracts/src/wasm/env_def/mod.rs
+++ b/frame/contracts/src/wasm/env_def/mod.rs
@@ -1,18 +1,19 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
use super::Runtime;
use crate::exec::Ext;
diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs
index 7d7668d5ec6d227dc6a712f2ee175838dae3a22b..e295febb51476158af38e93a668106d145f6c018 100644
--- a/frame/contracts/src/wasm/mod.rs
+++ b/frame/contracts/src/wasm/mod.rs
@@ -1,18 +1,19 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! This module provides a means for executing contracts
//! represented in wasm.
@@ -33,14 +34,13 @@ mod code_cache;
mod prepare;
mod runtime;
-use self::runtime::Runtime;
use self::code_cache::load as load_code;
use pallet_contracts_primitives::ExecResult;
pub use self::code_cache::save as save_code;
#[cfg(feature = "runtime-benchmarks")]
pub use self::code_cache::save_raw as save_code_raw;
-pub use self::runtime::ReturnCode;
+pub use self::runtime::{ReturnCode, Runtime, RuntimeToken};
/// A prepared wasm module ready for execution.
#[derive(Clone, Encode, Decode)]
@@ -1537,7 +1537,7 @@ mod tests {
&mut gas_meter
),
Err(ExecError {
- error: Error::::ContractTrapped.into(),
+ error: Error::::TooManyTopics.into(),
origin: ErrorOrigin::Caller,
})
);
@@ -1582,7 +1582,7 @@ mod tests {
&mut gas_meter
),
Err(ExecError {
- error: Error::::ContractTrapped.into(),
+ error: Error::::DuplicateTopics.into(),
origin: ErrorOrigin::Caller,
})
);
diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs
index 56e21d2ee664cc2377a3c303155fd92f817a75fb..e03eb3d39bc1109b8eaaffc23b8ca87b7e49f74c 100644
--- a/frame/contracts/src/wasm/prepare.rs
+++ b/frame/contracts/src/wasm/prepare.rs
@@ -1,27 +1,29 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! This module takes care of loading, checking and preprocessing of a
//! wasm module before execution. It also extracts some essential information
//! from a module.
-use crate::wasm::env_def::ImportSatisfyCheck;
-use crate::wasm::PrefabWasmModule;
-use crate::{Schedule, Config};
-
+use crate::{
+ Schedule, Config,
+ chain_extension::ChainExtension,
+ wasm::{PrefabWasmModule, env_def::ImportSatisfyCheck},
+};
use parity_wasm::elements::{self, Internal, External, MemoryType, Type, ValueType};
use pwasm_utils;
use sp_std::prelude::*;
@@ -354,6 +356,12 @@ impl<'a, T: Config> ContractModule<'a, T> {
return Err("module imports `seal_println` but debug features disabled");
}
+ if !T::ChainExtension::enabled() &&
+ import.field().as_bytes() == b"seal_call_chain_extension"
+ {
+ return Err("module uses chain extensions but chain extensions are disabled");
+ }
+
if import_fn_banlist.iter().any(|f| import.field().as_bytes() == *f)
|| !C::can_satisfy(import.field().as_bytes(), func_ty)
{
@@ -491,18 +499,24 @@ mod tests {
}
}
- // Define test environment for tests. We need ImportSatisfyCheck
- // implementation from it. So actual implementations doesn't matter.
- define_env!(TestEnv, ,
- panic(_ctx) => { unreachable!(); },
+ /// Using unreachable statements triggers unreachable warnings in the generated code
+ #[allow(unreachable_code)]
+ mod env {
+ use super::*;
- // gas is an implementation defined function and a contract can't import it.
- gas(_ctx, _amount: u32) => { unreachable!(); },
+ // Define test environment for tests. We need ImportSatisfyCheck
+ // implementation from it. So actual implementations doesn't matter.
+ define_env!(Test, ,
+ panic(_ctx) => { unreachable!(); },
- nop(_ctx, _unused: u64) => { unreachable!(); },
+ // gas is an implementation defined function and a contract can't import it.
+ gas(_ctx, _amount: u32) => { unreachable!(); },
- seal_println(_ctx, _ptr: u32, _len: u32) => { unreachable!(); },
- );
+ nop(_ctx, _unused: u64) => { unreachable!(); },
+
+ seal_println(_ctx, _ptr: u32, _len: u32) => { unreachable!(); },
+ );
+ }
macro_rules! prepare_test {
($name:ident, $wat:expr, $($expected:tt)*) => {
@@ -520,7 +534,7 @@ mod tests {
},
.. Default::default()
};
- let r = prepare_contract::(wasm.as_ref(), &schedule);
+ let r = prepare_contract::(wasm.as_ref(), &schedule);
assert_matches!(r, $($expected)*);
}
};
@@ -931,7 +945,7 @@ mod tests {
).unwrap();
let mut schedule = Schedule::default();
schedule.enable_println = true;
- let r = prepare_contract::(wasm.as_ref(), &schedule);
+ let r = prepare_contract::(wasm.as_ref(), &schedule);
assert_matches!(r, Ok(_));
}
}
diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs
index ac1cb1f54d56f2374613f746ec91cd4061c2fb11..41ab3e390aea8c1641f218e3711fa40e30eb8237 100644
--- a/frame/contracts/src/wasm/runtime.rs
+++ b/frame/contracts/src/wasm/runtime.rs
@@ -1,25 +1,26 @@
-// Copyright 2018-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
-// Substrate is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// Copyright (C) 2018-2021 Parity Technologies (UK) Ltd.
+// SPDX-License-Identifier: Apache-2.0
-// Substrate is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Substrate. If not, see .
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
//! Environment definition of the wasm smart-contract runtime.
use crate::{
HostFnWeights, Schedule, Config, CodeHash, BalanceOf, Error,
exec::{Ext, StorageKey, TopicOf},
- gas::{Gas, GasMeter, Token, GasMeterResult},
+ gas::{Gas, GasMeter, Token, GasMeterResult, ChargedAmount},
wasm::env_def::ConvertibleToWasm,
};
use sp_sandbox;
@@ -27,7 +28,7 @@ use parity_wasm::elements::ValueType;
use frame_system;
use frame_support::dispatch::DispatchError;
use sp_std::prelude::*;
-use codec::{Decode, Encode};
+use codec::{Decode, DecodeAll, Encode};
use sp_runtime::traits::SaturatedConversion;
use sp_core::crypto::UncheckedFrom;
use sp_io::hashing::{
@@ -90,7 +91,7 @@ impl From for ReturnCode {
}
/// The data passed through when a contract uses `seal_return`.
-struct ReturnData {
+pub struct ReturnData {
/// The flags as passed through by the contract. They are still unchecked and
/// will later be parsed into a `ReturnFlags` bitflags struct.
flags: u32,
@@ -104,7 +105,7 @@ struct ReturnData {
/// occurred (the SupervisorError variant).
/// The other case is where the trap does not constitute an error but rather was invoked
/// as a quick way to terminate the application (all other variants).
-enum TrapReason {
+pub enum TrapReason {
/// The supervisor trapped the contract because of an error condition occurred during
/// execution in privileged code.
SupervisorError(DispatchError),
@@ -117,6 +118,12 @@ enum TrapReason {
Restoration,
}
+impl> From for TrapReason {
+ fn from(from: T) -> Self {
+ Self::SupervisorError(from.into())
+ }
+}
+
#[cfg_attr(test, derive(Debug, PartialEq, Eq))]
#[derive(Copy, Clone)]
pub enum RuntimeToken {
@@ -191,6 +198,10 @@ pub enum RuntimeToken {
HashBlake256(u32),
/// Weight of calling `seal_hash_blake2_128` for the given input size.
HashBlake128(u32),
+ /// Weight charged by a chain extension through `seal_call_chain_extension`.
+ ChainExtension(u64),
+ /// Weight charged for copying data from the sandbox.
+ CopyIn(u32),
}
impl Token for RuntimeToken
@@ -249,6 +260,8 @@ where
.saturating_add(s.hash_blake2_256_per_byte.saturating_mul(len.into())),
HashBlake128(len) => s.hash_blake2_128
.saturating_add(s.hash_blake2_128_per_byte.saturating_mul(len.into())),
+ ChainExtension(amount) => amount,
+ CopyIn(len) => s.return_per_byte.saturating_mul(len.into()),
}
}
}
@@ -369,21 +382,33 @@ where
}
}
+ /// Get a mutable reference to the inner `Ext`.
+ ///
+ /// This is mainly for the chain extension to have access to the environment the
+ /// contract is executing in.
+ pub fn ext(&mut self) -> &mut E {
+ self.ext
+ }
+
+ /// Store the reason for a host function triggered trap.
+ ///
+ /// This is called by the `define_env` macro in order to store any error returned by
+ /// the host functions defined through the said macro. It should **not** be called
+ /// manually.
+ pub fn set_trap_reason(&mut self, reason: TrapReason) {
+ self.trap_reason = Some(reason);
+ }
+
/// Charge the gas meter with the specified token.
///
/// Returns `Err(HostError)` if there is not enough gas.
- fn charge_gas(&mut self, token: Tok) -> Result<(), sp_sandbox::HostError>
+ pub fn charge_gas(&mut self, token: Tok) -> Result
where
Tok: Token>,
{
match self.gas_meter.charge(&self.schedule.host_fn_weights, token) {
- GasMeterResult::Proceed => Ok(()),
- GasMeterResult::OutOfGas => {
- self.trap_reason = Some(
- TrapReason::SupervisorError(Error::::OutOfGas.into())
- );
- Err(sp_sandbox::HostError)
- },
+ GasMeterResult::Proceed(amount) => Ok(amount),
+ GasMeterResult::OutOfGas => Err(Error::::OutOfGas.into())
}
}
@@ -392,12 +417,12 @@ where
/// Returns `Err` if one of the following conditions occurs:
///
/// - requested buffer is not within the bounds of the sandbox memory.
- fn read_sandbox_memory(&mut self, ptr: u32, len: u32)
- -> Result, sp_sandbox::HostError>
+ pub fn read_sandbox_memory(&self, ptr: u32, len: u32)
+ -> Result, DispatchError>
{
let mut buf = vec![0u8; len as usize];
self.memory.get(ptr, buf.as_mut_slice())
- .map_err(|_| self.store_err(Error::::OutOfBounds))?;
+ .map_err(|_| Error::::OutOfBounds)?;
Ok(buf)
}
@@ -406,10 +431,10 @@ where
/// Returns `Err` if one of the following conditions occurs:
///
/// - requested buffer is not within the bounds of the sandbox memory.
- fn read_sandbox_memory_into_buf(&mut self, ptr: u32, buf: &mut [u8])
- -> Result<(), sp_sandbox::HostError>
+ pub fn read_sandbox_memory_into_buf(&self, ptr: u32, buf: &mut [u8])
+ -> Result<(), DispatchError>
{
- self.memory.get(ptr, buf).map_err(|_| self.store_err(Error::::OutOfBounds))
+ self.memory.get(ptr, buf).map_err(|_| Error::::OutOfBounds.into())
}
/// Read designated chunk from the sandbox memory and attempt to decode into the specified type.
@@ -418,20 +443,29 @@ where
///
/// - requested buffer is not within the bounds of the sandbox memory.
/// - the buffer contents cannot be decoded as the required type.
- fn read_sandbox_memory_as(&mut self, ptr: u32, len: u32)
- -> Result
- {
- let buf = self.read_sandbox_memory(ptr, len)?;
- D::decode(&mut &buf[..]).map_err(|_| self.store_err(Error::::DecodingFailed))
- }
-
- /// Write the given buffer to the designated location in the sandbox memory.
///
- /// Returns `Err` if one of the following conditions occurs:
+ /// # Note
///
- /// - designated area is not within the bounds of the sandbox memory.
- fn write_sandbox_memory(&mut self, ptr: u32, buf: &[u8]) -> Result<(), sp_sandbox::HostError> {
- self.memory.set(ptr, buf).map_err(|_| self.store_err(Error::::OutOfBounds))
+ /// It is safe to forgo benchmarking and charging weight relative to `len` for fixed
+ /// size types (basically everything not containing a heap collection):
+ /// Despite the fact that we are usually about to read the encoding of a fixed size
+ /// type, we cannot know the encoded size of that type. We therefore are required to
+ /// use the length provided by the contract. This length is untrusted and therefore
+ /// we charge weight relative to the provided size upfront that covers the copy costs.
+ /// On success this cost is refunded as the copying was already covered in the
+ /// overall cost of the host function. This is different from `read_sandbox_memory`
+ /// where the size is dynamic and the costs resulting from that dynamic size must
+ /// be charged relative to this dynamic size anyways (before reading) by constructing
+ /// the benchmark for that.
+ pub fn read_sandbox_memory_as(&mut self, ptr: u32, len: u32)
+ -> Result
+ {
+ let amount = self.charge_gas(RuntimeToken::CopyIn(len))?;
+ let buf = self.read_sandbox_memory(ptr, len)?;
+ let decoded = D::decode_all(&mut &buf[..])
+ .map_err(|_| DispatchError::from(Error::::DecodingFailed))?;
+ self.gas_meter.refund(amount);
+ Ok(decoded)
}
/// Write the given buffer and its length to the designated locations in sandbox memory and
@@ -453,14 +487,14 @@ where
///
/// In addition to the error conditions of `write_sandbox_memory` this functions returns
/// `Err` if the size of the buffer located at `out_ptr` is too small to fit `buf`.
- fn write_sandbox_output(
+ pub fn write_sandbox_output(
&mut self,
out_ptr: u32,
out_len_ptr: u32,
buf: &[u8],
allow_skip: bool,
create_token: impl FnOnce(u32) -> Option,
- ) -> Result<(), sp_sandbox::HostError>
+ ) -> Result<(), DispatchError>
{
if allow_skip && out_ptr == u32::max_value() {
return Ok(());
@@ -470,7 +504,7 @@ where
let len: u32 = self.read_sandbox_memory_as(out_len_ptr, 4)?;
if len < buf_len {
- Err(self.store_err(Error::::OutputBufferTooSmall))?
+ Err(Error::::OutputBufferTooSmall)?
}
if let Some(token) = create_token(buf_len) {
@@ -480,11 +514,20 @@ where
self.memory.set(out_ptr, buf).and_then(|_| {
self.memory.set(out_len_ptr, &buf_len.encode())
})
- .map_err(|_| self.store_err(Error::::OutOfBounds))?;
+ .map_err(|_| Error::::OutOfBounds)?;
Ok(())
}
+ /// Write the given buffer to the designated location in the sandbox memory.
+ ///
+ /// Returns `Err` if one of the following conditions occurs:
+ ///
+ /// - designated area is not within the bounds of the sandbox memory.
+ fn write_sandbox_memory(&mut self, ptr: u32, buf: &[u8]) -> Result<(), DispatchError> {
+ self.memory.set(ptr, buf).map_err(|_| Error::::OutOfBounds.into())
+ }
+
/// Computes the given hash function on the supplied input.
///
/// Reads from the sandboxed input buffer into an intermediate buffer.
@@ -503,7 +546,7 @@ where
input_ptr: u32,
input_len: u32,
output_ptr: u32,
- ) -> Result<(), sp_sandbox::HostError>
+ ) -> Result<(), DispatchError>
where
F: FnOnce(&[u8]) -> R,
R: AsRef<[u8]>,
@@ -517,48 +560,6 @@ where
Ok(())
}
- /// Stores a DispatchError returned from an Ext function into the trap_reason.
- ///
- /// This allows through supervisor generated errors to the caller.
- fn store_err(&mut self, err: Error) -> sp_sandbox::HostError
- where
- Error: Into,
- {
- self.trap_reason = Some(TrapReason::SupervisorError(err.into()));
- sp_sandbox::HostError
- }
-
- /// Used by Runtime API that calls into other contracts.
- ///
- /// Those need to transform the the `ExecResult` returned from the execution into
- /// a `ReturnCode`. If this conversion fails because the `ExecResult` constitutes a
- /// a fatal error then this error is stored in the `ExecutionContext` so it can be
- /// extracted for display in the UI.
- fn map_exec_result(&mut self, result: ExecResult) -> Result {
- match Self::exec_into_return_code(result) {
- Ok(code) => Ok(code),
- Err(err) => Err(self.store_err(err)),
- }
- }
-
- /// Try to convert an error into a `ReturnCode`.
- ///
- /// Used to decide between fatal and non-fatal errors.
- fn map_dispatch_result(&mut self, result: Result)
- -> Result
- {
- let err = if let Err(err) = result {
- err
- } else {
- return Ok(ReturnCode::Success)
- };
-
- match Self::err_into_return_code(err) {
- Ok(code) => Ok(code),
- Err(err) => Err(self.store_err(err)),
- }
- }
-
/// Fallible conversion of `DispatchError` to `ReturnCode`.
fn err_into_return_code(from: DispatchError) -> Result {
use ReturnCode::*;
@@ -638,7 +639,7 @@ define_env!(Env, ,
seal_set_storage(ctx, key_ptr: u32, value_ptr: u32, value_len: u32) => {
ctx.charge_gas(RuntimeToken::SetStorage(value_len))?;
if value_len > ctx.ext.max_value_size() {
- Err(ctx.store_err(Error::::ValueTooLarge))?;
+ Err(Error::::ValueTooLarge)?;
}
let mut key: StorageKey = [0; 32];
ctx.read_sandbox_memory_into_buf(key_ptr, &mut key)?;
@@ -715,7 +716,13 @@ define_env!(Env, ,
ctx.read_sandbox_memory_as(value_ptr, value_len)?;
let result = ctx.ext.transfer(&callee, value);
- ctx.map_dispatch_result(result)
+ match result {
+ Ok(()) => Ok(ReturnCode::Success),
+ Err(err) => {
+ let code = Runtime::::err_into_return_code(err)?;
+ Ok(code)
+ }
+ }
},
// Make a call to another contract.
@@ -797,7 +804,7 @@ define_env!(Env, ,
Some(RuntimeToken::CallCopyOut(len))
})?;
}
- ctx.map_exec_result(call_outcome)
+ Ok(Runtime::::exec_into_return_code(call_outcome)?)
},
// Instantiate a contract with the specified code hash.
@@ -899,7 +906,7 @@ define_env!(Env,