diff --git a/CODE_OF_CONDUCT.adoc b/CODE_OF_CONDUCT.adoc index 811e83e9fa973..7cb0210e8efac 100644 --- a/CODE_OF_CONDUCT.adoc +++ b/CODE_OF_CONDUCT.adoc @@ -24,7 +24,7 @@ Examples of unacceptable behavior by participants include: === Facilitation, Not Strongarming -We recognise that this software is merely a tool for users to create and maintain their blockchain of preference. We see that blockchains are naturally community platforms with users being the ultimate decision makers. We assert that good software will maximise user agency by facilitate user-expression on the network. As such: +We recognize that this software is merely a tool for users to create and maintain their blockchain of preference. We see that blockchains are naturally community platforms with users being the ultimate decision makers. We assert that good software will maximize user agency by facilitate user-expression on the network. As such: * This project will strive to give users as much choice as is both reasonable and possible over what protocol they adhere to; but * use of the project's technical forums, commenting systems, pull requests and issue trackers as a means to express individual protocol preferences is forbidden. diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 7098869dcc4a0..b797e72e82b54 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -33,10 +33,10 @@ Merging pull requests once CI is successful: When reviewing a pull request, the end-goal is to suggest useful changes to the author. Reviews should finish with approval unless there are issues that would result in: -. Buggy behaviour. +. Buggy behavior. . Undue maintenance burden. . Breaking with house coding style. -. Pessimisation (i.e. reduction of speed as measured in the projects benchmarks). +. Pessimization (i.e. reduction of speed as measured in the projects benchmarks). . Feature reduction (i.e. it removes some aspect of functionality that a significant minority of users rely on). . Uselessness (i.e. it does not strictly add a feature or fix a known issue). @@ -47,7 +47,7 @@ When reviewing a pull request, the end-goal is to suggest useful changes to the == Helping out -We use https://github.com/paritytech/substrate/labels[labels] to manage PRs and issues and communicate state of a PR. Please familiarize yourself with them. Furthermore we are organising issues in https://github.com/paritytech/substrate/milestones[milestones]. Best way to get started is to a pick a ticket from the current milestone tagged https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ2-easy[`easy`] or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ3-medium[`medium`] and get going or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AX1-mentor[`mentor`] and get in contact with the mentor offering their support on that larger task. +We use https://github.com/paritytech/substrate/labels[labels] to manage PRs and issues and communicate state of a PR. Please familiarize yourself with them. Furthermore we are organizing issues in https://github.com/paritytech/substrate/milestones[milestones]. Best way to get started is to a pick a ticket from the current milestone tagged https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ2-easy[`easy`] or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AQ3-medium[`medium`] and get going or https://github.com/paritytech/substrate/issues?q=is%3Aissue+is%3Aopen+label%3AX1-mentor[`mentor`] and get in contact with the mentor offering their support on that larger task. == Releases diff --git a/README.adoc b/README.adoc index 90961cbb0f495..cf0e1970a7f59 100644 --- a/README.adoc +++ b/README.adoc @@ -10,9 +10,9 @@ Substrate is a next-generation framework for blockchain innovation. == Description -At its heart, Substrate is a combination of three technologies: https://webassembly.org/[WebAssembly], https://libp2p.io/[Libp2p] and GRANDPA Consensus. About GRANDPA, see this https://hackmd.io/Jd0byWX0RiqFiXUVC78Bdw?view#GRANDPA[definition], https://medium.com/polkadot-network/grandpa-block-finality-in-polkadot-an-introduction-part-1-d08a24a021b5[introduction] and https://github.com/w3f/consensus/blob/master/pdf/grandpa.pdf[formal specification]. It is both a library for building new blockchains and a "skeleton key" of a blockchain client, able to synchronise to any Substrate-based chain. +At its heart, Substrate is a combination of three technologies: https://webassembly.org/[WebAssembly], https://libp2p.io/[Libp2p] and GRANDPA Consensus. About GRANDPA, see this https://hackmd.io/Jd0byWX0RiqFiXUVC78Bdw?view#GRANDPA[definition], https://medium.com/polkadot-network/grandpa-block-finality-in-polkadot-an-introduction-part-1-d08a24a021b5[introduction] and https://github.com/w3f/consensus/blob/master/pdf/grandpa.pdf[formal specification]. It is both a library for building new blockchains and a "skeleton key" of a blockchain client, able to synchronize to any Substrate-based chain. -Substrate chains have three distinct features that make them "next-generation": a dynamic, self-defining state-transition function; light-client functionality from day one; and a progressive consensus algorithm with fast block production and adaptive, definite finality. The STF, encoded in WebAssembly, is known as the "runtime". This defines the `execute_block` function, and can specify everything from the staking algorithm, transaction semantics, logging mechanisms and procedures for replacing any aspect of itself or of the blockchain's state ("governance"). Because the runtime is entirely dynamic all of these can be switched out or upgraded at any time. A Substrate chain is very much a "living organism". +Substrate chains have three distinct features that make them "next-generation": a dynamic, self-defining state-transition function; light-client functionality from day one; and a progressive consensus algorithm with fast block production and adaptive, definite finality. The STF, encoded in WebAssembly, is known as the "runtime". This defines the `execute_block` function, and can specify everything from the staking algorithm, transaction semantics, logging mechanisms and procedures for replacing any aspect of itself or of the blockchain's state ("governance"). Because the runtime is entirely dynamic all of these can be switched out or upgraded at any time. A Substrate chain is very much a "living organizm". See also https://www.parity.io/what-is-substrate/. @@ -39,7 +39,7 @@ Block := Header + Extrinsics + Justifications === Extrinsics -Extrinsics in Substrate are pieces of information from "the outside world" that are contained in the blocks of the chain. You might think "ahh, that means *transactions*": in fact, no. Extrinsics fall into two broad categories of which only one is *transactions*. The other is known as *inherents*. The difference between these two is that transactions are signed and gossipped on the network and can be deemed useful *per se*. This fits the mould of what you would call transactions in Bitcoin or Ethereum. +Extrinsics in Substrate are pieces of information from "the outside world" that are contained in the blocks of the chain. You might think "ahh, that means *transactions*": in fact, no. Extrinsics fall into two broad categories of which only one is *transactions*. The other is known as *inherents*. The difference between these two is that transactions are signed and gossipped on the network and can be deemed useful *per se*. This fits the mold of what you would call transactions in Bitcoin or Ethereum. Inherents, meanwhile, are not passed on the network and are not signed. They represent data which describes the environment but which cannot call upon anything to prove it such as a signature. Rather they are assumed to be "true" simply because a sufficiently large number of validators have agreed on them being reasonable. @@ -71,8 +71,8 @@ impl_runtime_apis! { Executive::execute_block(block) } - fn initialise_block(header: ::Header) { - Executive::initialise_block(&header) + fn initialize_block(header: ::Header) { + Executive::initialize_block(&header) } } // ---snip--- @@ -86,9 +86,9 @@ The Substrate Runtime Module Library includes functionality for timestamps and s === Block-authoring Logic -In Substrate, there is a major distinction between blockchain *syncing* and block *authoring* ("authoring" is a more general term for what is called "mining" in Bitcoin). The first case might be referred to as a "full node" (or "light node" - Substrate supports both): authoring necessarily requires a synced node and, therefore, all authoring clients must necessarily be able to synchronise. However, the reverse is not true. The primary functionality that authoring nodes have which is not in "sync nodes" is threefold: transaction queue logic, inherent transaction knowledge and BFT consensus logic. BFT consensus logic is provided as a core element of Substrate and can be ignored since it is only exposed in the SDK under the `authorities()` API entry. +In Substrate, there is a major distinction between blockchain *syncing* and block *authoring* ("authoring" is a more general term for what is called "mining" in Bitcoin). The first case might be referred to as a "full node" (or "light node" - Substrate supports both): authoring necessarily requires a synced node and, therefore, all authoring clients must necessarily be able to synchronize. However, the reverse is not true. The primary functionality that authoring nodes have which is not in "sync nodes" is threefold: transaction queue logic, inherent transaction knowledge and BFT consensus logic. BFT consensus logic is provided as a core element of Substrate and can be ignored since it is only exposed in the SDK under the `authorities()` API entry. -Transaction queue logic in Substrate is designed to be as generic as possible, allowing a runtime to express which transactions are fit for inclusion in a block through the `initialize_block` and `apply_extrinsic` calls. However, more subtle aspects like prioritisation and replacement policy must currently be expressed "hard coded" as part of the blockchain's authoring code. That said, Substrate's reference implementation for a transaction queue should be sufficient for an initial chain implementation. +Transaction queue logic in Substrate is designed to be as generic as possible, allowing a runtime to express which transactions are fit for inclusion in a block through the `initialize_block` and `apply_extrinsic` calls. However, more subtle aspects like prioritization and replacement policy must currently be expressed "hard coded" as part of the blockchain's authoring code. That said, Substrate's reference implementation for a transaction queue should be sufficient for an initial chain implementation. Inherent extrinsic knowledge is again somewhat generic, and the actual construction of the extrinsics is, by convention, delegated to the "soft code" in the runtime. If ever there needs to be additional extrinsic information in the chain, then both the block authoring logic will need to be altered to provide it into the runtime and the runtime's `inherent_extrinsics` call will need to use this extra information in order to construct any additional extrinsic transactions for inclusion in the block. @@ -167,7 +167,7 @@ It won't do much until you start producing blocks though, so to do that you'll n substrate --chain ~/mychain.json --validator --key ... ---- -You can distribute `mychain.json` so that everyone can synchronise and (depending on your authorities list) validate on your chain. +You can distribute `mychain.json` so that everyone can synchronize and (depending on your authorities list) validate on your chain. == Building diff --git a/core/basic-authorship/src/basic_authorship.rs b/core/basic-authorship/src/basic_authorship.rs index 55b45c1c4502d..e9b6c909ad41f 100644 --- a/core/basic-authorship/src/basic_authorship.rs +++ b/core/basic-authorship/src/basic_authorship.rs @@ -177,7 +177,7 @@ impl consensus_common::Proposer<::Block> for Pro fn propose(&self, inherent_data: InherentData, max_duration: time::Duration) -> Result<::Block, error::Error> { - // leave some time for evaluation and block finalisation (33%) + // leave some time for evaluation and block finalization (33%) let deadline = (self.now)() + max_duration - max_duration / 3; self.propose_with(inherent_data, deadline) } @@ -197,7 +197,7 @@ impl Proposer where /// If the block is full we will attempt to push at most /// this number of transactions before quitting for real. - /// It allows us to increase block utilisation. + /// It allows us to increase block utilization. const MAX_SKIPPED_TRANSACTIONS: usize = 8; let block = self.client.build_block( diff --git a/core/client/src/block_builder/api.rs b/core/client/src/block_builder/api.rs index 8aad262777381..48abb38024175 100644 --- a/core/client/src/block_builder/api.rs +++ b/core/client/src/block_builder/api.rs @@ -28,7 +28,7 @@ decl_runtime_apis! { /// Apply the given extrinsics. fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyResult; /// Finish the current block. - fn finalise_block() -> ::Header; + fn finalize_block() -> ::Header; /// Generate inherent extrinsics. The inherent data will vary from chain to chain. fn inherent_extrinsics(inherent: InherentData) -> Vec<::Extrinsic>; /// Check that the inherents are valid. The inherent data will vary from chain to chain. diff --git a/core/client/src/block_builder/block_builder.rs b/core/client/src/block_builder/block_builder.rs index 63e18e827984e..fd1ce4aefbf85 100644 --- a/core/client/src/block_builder/block_builder.rs +++ b/core/client/src/block_builder/block_builder.rs @@ -64,7 +64,7 @@ where Default::default() ); let api = api.runtime_api(); - api.initialise_block_with_context(block_id, ExecutionContext::BlockConstruction, &header)?; + api.initialize_block_with_context(block_id, ExecutionContext::BlockConstruction, &header)?; Ok(BlockBuilder { header, extrinsics: Vec::new(), @@ -97,7 +97,7 @@ where /// Consume the builder to return a valid `Block` containing all pushed extrinsics. pub fn bake(mut self) -> error::Result { - self.header = self.api.finalise_block_with_context(&self.block_id, ExecutionContext::BlockConstruction)?; + self.header = self.api.finalize_block_with_context(&self.block_id, ExecutionContext::BlockConstruction)?; debug_assert_eq!( self.header.extrinsics_root().clone(), diff --git a/core/client/src/call_executor.rs b/core/client/src/call_executor.rs index 0dad56be07403..20460f72add74 100644 --- a/core/client/src/call_executor.rs +++ b/core/client/src/call_executor.rs @@ -73,7 +73,7 @@ where method: &str, call_data: &[u8], changes: &mut OverlayedChanges, - initialised_block: &mut Option>, + initialized_block: &mut Option>, prepare_environment_block: PB, execution_manager: ExecutionManager, native_call: Option, @@ -213,14 +213,14 @@ where method: &str, call_data: &[u8], changes: &mut OverlayedChanges, - initialised_block: &mut Option>, + initialized_block: &mut Option>, prepare_environment_block: PB, execution_manager: ExecutionManager, native_call: Option, mut side_effects_handler: Option<&mut O>, ) -> Result, error::Error> where ExecutionManager: Clone { let state = self.backend.state_at(*at)?; - if method != "Core_initialise_block" && initialised_block.map(|id| id != *at).unwrap_or(true) { + if method != "Core_initialize_block" && initialized_block.map(|id| id != *at).unwrap_or(true) { let header = prepare_environment_block()?; state_machine::new( &state, @@ -228,14 +228,14 @@ where side_effects_handler.as_mut().map(|x| &mut **x), changes, &self.executor, - "Core_initialise_block", + "Core_initialize_block", &header.encode(), ).execute_using_consensus_failure_handler::<_, R, fn() -> _>( execution_manager.clone(), false, None, )?; - *initialised_block = Some(*at); + *initialized_block = Some(*at); } let result = state_machine::new( @@ -252,9 +252,9 @@ where native_call, ).map(|(result, _, _)| result)?; - // If the method is `initialise_block` we need to set the `initialised_block` - if method == "Core_initialise_block" { - *initialised_block = Some(*at); + // If the method is `initialize_block` we need to set the `initialized_block` + if method == "Core_initialize_block" { + *initialized_block = Some(*at); } self.backend.destroy_state(state)?; diff --git a/core/client/src/client.rs b/core/client/src/client.rs index 699bbcad8dfe1..86d643d3b786e 100644 --- a/core/client/src/client.rs +++ b/core/client/src/client.rs @@ -285,7 +285,7 @@ impl Client where backend.begin_state_operation(&mut op, BlockId::Hash(Default::default()))?; let state_root = op.reset_storage(genesis_storage, children_genesis_storage)?; let genesis_block = genesis::construct_genesis_block::(state_root.into()); - info!("Initialising Genesis block/state (state: {}, header-hash: {})", genesis_block.header().state_root(), genesis_block.header().hash()); + info!("Initializing Genesis block/state (state: {}, header-hash: {})", genesis_block.header().state_root(), genesis_block.header().hash()); op.set_block_data( genesis_block.deconstruct().0, Some(vec![]), @@ -1351,7 +1351,7 @@ impl CallRuntimeAt for Client where function: &'static str, args: Vec, changes: &mut OverlayedChanges, - initialised_block: &mut Option>, + initialized_block: &mut Option>, native_call: Option, context: ExecutionContext, ) -> error::Result> { @@ -1373,7 +1373,7 @@ impl CallRuntimeAt for Client where function, &args, changes, - initialised_block, + initialized_block, || self.prepare_environment_block(at), manager, native_call, @@ -1630,7 +1630,7 @@ pub(crate) mod tests { } #[test] - fn client_initialises_from_genesis_ok() { + fn client_initializes_from_genesis_ok() { let client = test_client::new(); assert_eq!( diff --git a/core/client/src/genesis.rs b/core/client/src/genesis.rs index 7ebae4c558895..eea0a251cac79 100644 --- a/core/client/src/genesis.rs +++ b/core/client/src/genesis.rs @@ -93,7 +93,7 @@ mod tests { state_machine::NeverOffchainExt::new(), &mut overlay, &executor(), - "Core_initialise_block", + "Core_initialize_block", &header.encode(), ).execute( ExecutionStrategy::NativeElseWasm, @@ -119,7 +119,7 @@ mod tests { state_machine::NeverOffchainExt::new(), &mut overlay, &executor(), - "BlockBuilder_finalise_block", + "BlockBuilder_finalize_block", &[], ).execute( ExecutionStrategy::NativeElseWasm, diff --git a/core/client/src/light/call_executor.rs b/core/client/src/light/call_executor.rs index 00a3d8895beb1..b2e4c45a7d45f 100644 --- a/core/client/src/light/call_executor.rs +++ b/core/client/src/light/call_executor.rs @@ -118,14 +118,14 @@ where method: &str, call_data: &[u8], changes: &mut OverlayedChanges, - initialised_block: &mut Option>, + initialized_block: &mut Option>, _prepare_environment_block: PB, execution_manager: ExecutionManager, _native_call: Option, side_effects_handler: Option<&mut O>, ) -> ClientResult> where ExecutionManager: Clone { // it is only possible to execute contextual call if changes are empty - if !changes.is_empty() || initialised_block.is_some() { + if !changes.is_empty() || initialized_block.is_some() { return Err(ClientErrorKind::NotAvailableOnLightClient.into()); } @@ -245,7 +245,7 @@ impl CallExecutor for method: &str, call_data: &[u8], changes: &mut OverlayedChanges, - initialised_block: &mut Option>, + initialized_block: &mut Option>, prepare_environment_block: PB, _manager: ExecutionManager, native_call: Option, @@ -270,7 +270,7 @@ impl CallExecutor for method, call_data, changes, - initialised_block, + initialized_block, prepare_environment_block, ExecutionManager::NativeWhenPossible, native_call, @@ -291,7 +291,7 @@ impl CallExecutor for method, call_data, changes, - initialised_block, + initialized_block, prepare_environment_block, ExecutionManager::NativeWhenPossible, native_call, @@ -388,7 +388,7 @@ pub fn prove_execution( let (_, init_proof) = executor.prove_at_trie_state( &trie_state, &mut changes, - "Core_initialise_block", + "Core_initialize_block", &header.encode(), )?; @@ -435,7 +435,7 @@ pub fn check_execution_proof( &trie_backend, &mut changes, executor, - "Core_initialise_block", + "Core_initialize_block", &next_block.encode(), )?; @@ -516,12 +516,12 @@ mod tests { assert_eq!(remote, local); // check method that requires environment - let (_, block) = execute(&remote_client, 0, "BlockBuilder_finalise_block"); + let (_, block) = execute(&remote_client, 0, "BlockBuilder_finalize_block"); let local_block: Header = Decode::decode(&mut &block[..]).unwrap(); assert_eq!(local_block.number, 1); // check method that requires environment - let (_, block) = execute(&remote_client, 2, "BlockBuilder_finalise_block"); + let (_, block) = execute(&remote_client, 2, "BlockBuilder_finalize_block"); let local_block: Header = Decode::decode(&mut &block[..]).unwrap(); assert_eq!(local_block.number, 3); } diff --git a/core/client/src/runtime_api.rs b/core/client/src/runtime_api.rs index 77d733f64ed5c..a912b8c5767e2 100644 --- a/core/client/src/runtime_api.rs +++ b/core/client/src/runtime_api.rs @@ -102,7 +102,7 @@ pub trait CallRuntimeAt { function: &'static str, args: Vec, changes: &mut OverlayedChanges, - initialised_block: &mut Option>, + initialized_block: &mut Option>, native_call: Option, context: ExecutionContext, ) -> error::Result>; @@ -121,8 +121,8 @@ decl_runtime_apis! { fn authorities() -> Vec>; /// Execute the given block. fn execute_block(block: Block); - /// Initialise a block with the given header. - fn initialise_block(header: &::Header); + /// Initialize a block with the given header. + fn initialize_block(header: &::Header); } /// The `Metadata` api trait that returns metadata for the runtime. diff --git a/core/consensus/rhd/src/lib.rs b/core/consensus/rhd/src/lib.rs index e42083a40b309..cbdf95d987578 100644 --- a/core/consensus/rhd/src/lib.rs +++ b/core/consensus/rhd/src/lib.rs @@ -66,7 +66,7 @@ pub use rhododendron::{ }; pub use self::error::{Error, ErrorKind}; -// pub mod misbehaviour_check; +// pub mod misbehavior_check; mod error; mod service; diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 92bd0e4584c83..7016a708bd62b 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -58,8 +58,8 @@ decl_runtime_apis! { /// This should be implemented on the runtime side. /// /// This is primarily used for negotiating authority-set changes for the - /// gadget. GRANDPA uses a signalling model of changing authority sets: - /// changes should be signalled with a delay of N blocks, and then automatically + /// gadget. GRANDPA uses a signaling model of changing authority sets: + /// changes should be signaled with a delay of N blocks, and then automatically /// applied in the runtime after those N blocks have passed. /// /// The consensus protocol will coordinate the handoff externally. @@ -83,7 +83,7 @@ decl_runtime_apis! { /// Check a digest for forced changes. /// Return `None` if there are no forced changes. Otherwise, return a /// tuple containing the pending change and the median last finalized - /// block number at the time the change was signalled. + /// block number at the time the change was signaled. /// /// Added in version 2. /// diff --git a/core/finality-grandpa/src/authorities.rs b/core/finality-grandpa/src/authorities.rs index 49917ae1c2702..ffded9a1ab355 100644 --- a/core/finality-grandpa/src/authorities.rs +++ b/core/finality-grandpa/src/authorities.rs @@ -136,7 +136,7 @@ where let hash = pending.canon_hash.clone(); let number = pending.canon_height.clone(); - debug!(target: "afg", "Inserting potential standard set change signalled at block {:?} \ + debug!(target: "afg", "Inserting potential standard set change signaled at block {:?} \ (delayed by {:?} blocks).", (&number, &hash), pending.delay); @@ -257,7 +257,7 @@ where .take_while(|c| c.effective_number() <= best_number) // to prevent iterating too far .filter(|c| c.effective_number() == best_number) { - // check if the given best block is in the same branch as the block that signalled the change. + // check if the given best block is in the same branch as the block that signaled the change. if is_descendent_of(&change.canon_hash, &best_hash)? { // apply this change: make the set canonical info!(target: "finality", "Applying authority set change forced at block #{:?}", @@ -381,7 +381,7 @@ pub(crate) enum DelayKind { /// Depth in finalized chain. Finalized, /// Depth in best chain. The median last finalized block is calculated at the time the - /// change was signalled. + /// change was signaled. Best { median_last_finalized: N }, } @@ -550,7 +550,7 @@ mod tests { vec![&change_b, &change_a], ); - // finalizing "hash_c" won't enact the change signalled at "hash_a" but it will prune out "hash_b" + // finalizing "hash_c" won't enact the change signaled at "hash_a" but it will prune out "hash_b" let status = authorities.apply_standard_changes("hash_c", 11, &is_descendent_of(|base, hash| match (*base, *hash) { ("hash_a", "hash_c") => true, ("hash_b", "hash_c") => false, @@ -564,7 +564,7 @@ mod tests { vec![&change_a], ); - // finalizing "hash_d" will enact the change signalled at "hash_a" + // finalizing "hash_d" will enact the change signaled at "hash_a" let status = authorities.apply_standard_changes("hash_d", 15, &is_descendent_of(|base, hash| match (*base, *hash) { ("hash_a", "hash_d") => true, _ => unreachable!(), diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 685337a311b40..587762b608e0e 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -125,7 +125,7 @@ impl, B, E, N, RA> grandpa::Chain Option<(Block::Hash, NumberFor)> { // NOTE: when we finalize an authority set change through the sync protocol the voter is - // signalled asynchronously. therefore the voter could still vote in the next round + // signaled asynchronously. therefore the voter could still vote in the next round // before activating the new set. the `authority_set` is updated immediately thus we // restrict the voter based on that. if self.set_id != self.authority_set.inner().read().current().0 { diff --git a/core/finality-grandpa/src/import.rs b/core/finality-grandpa/src/import.rs index 0c59bd60fe09a..9afbe443f9c78 100644 --- a/core/finality-grandpa/src/import.rs +++ b/core/finality-grandpa/src/import.rs @@ -570,7 +570,7 @@ impl, RA, PRA> GrandpaBlockImport { info!(target: "finality", "Imported justification for block #{} that triggers \ - command {}, signalling voter.", number, command); + command {}, signaling voter.", number, command); if let Err(e) = self.send_voter_commands.unbounded_send(command) { return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()); diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 7e0537ed7b09a..582439419e758 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -297,7 +297,7 @@ impl Core for RuntimeApi { unimplemented!("Not required for testing!") } - fn initialise_block_runtime_api_impl( + fn initialize_block_runtime_api_impl( &self, _: &BlockId, _: ExecutionContext, diff --git a/core/network/src/message.rs b/core/network/src/message.rs index 221a867c6750f..d0f697b8ab406 100644 --- a/core/network/src/message.rs +++ b/core/network/src/message.rs @@ -66,7 +66,7 @@ pub type BlockResponse = generic::BlockResponse< /// A set of transactions. pub type Transactions = Vec; -/// Bits of block data and associated artefacts to request. +/// Bits of block data and associated artifacts to request. bitflags! { /// Node roles bitmask. pub struct BlockAttributes: u8 { diff --git a/core/primitives/src/lib.rs b/core/primitives/src/lib.rs index 38ecec0fa4e06..f078b5446f53b 100644 --- a/core/primitives/src/lib.rs +++ b/core/primitives/src/lib.rs @@ -21,7 +21,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), feature(alloc))] -/// Initalise a key-value collection from array. +/// Initialize a key-value collection from array. /// /// Creates a vector of given pairs and calls `collect` on the iterator from it. /// Can be used to create a `HashMap`. @@ -105,7 +105,7 @@ impl OffchainExt for Box { } } -/// Hex-serialised shim for `Vec`. +/// Hex-serialized shim for `Vec`. #[derive(PartialEq, Eq, Clone)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug, Hash, PartialOrd, Ord))] pub struct Bytes(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec); diff --git a/core/rpc/src/chain/mod.rs b/core/rpc/src/chain/mod.rs index 9b7f5a909e449..de7ad3faad8d8 100644 --- a/core/rpc/src/chain/mod.rs +++ b/core/rpc/src/chain/mod.rs @@ -57,9 +57,9 @@ pub trait ChainApi { #[rpc(name = "chain_getBlockHash", alias("chain_getHead"))] fn block_hash(&self, hash: Option>) -> Result>; - /// Get hash of the last finalised block in the canon chain. - #[rpc(name = "chain_getFinalisedHead")] - fn finalised_head(&self) -> Result; + /// Get hash of the last finalized block in the canon chain. + #[rpc(name = "chain_getFinalizedHead", alias("chain_getFinalisedHead"))] + fn finalized_head(&self) -> Result; /// New head subscription #[pubsub( @@ -81,19 +81,21 @@ pub trait ChainApi { /// New head subscription #[pubsub( - subscription = "chain_finalisedHead", + subscription = "chain_finalizedHead", subscribe, - name = "chain_subscribeFinalisedHeads" + name = "chain_subscribeFinalizedHeads", + alias("chain_subscribeFinalisedHeads") )] - fn subscribe_finalised_heads(&self, metadata: Self::Metadata, subscriber: Subscriber
); + fn subscribe_finalized_heads(&self, metadata: Self::Metadata, subscriber: Subscriber
); /// Unsubscribe from new head subscription. #[pubsub( - subscription = "chain_finalisedHead", + subscription = "chain_finalizedHead", unsubscribe, - name = "chain_unsubscribeFinalisedHeads" + name = "chain_unsubscribeFinalizedHeads", + alias("chain_unsubscribeFinalisedHeads") )] - fn unsubscribe_finalised_heads(&self, metadata: Option, id: SubscriptionId) -> RpcResult; + fn unsubscribe_finalized_heads(&self, metadata: Option, id: SubscriptionId) -> RpcResult; } /// Chain API with subscriptions support. @@ -192,7 +194,7 @@ impl ChainApi, Block::Hash, Block::Header, Sig }) } - fn finalised_head(&self) -> Result { + fn finalized_head(&self) -> Result { Ok(self.client.info()?.chain.finalized_hash) } @@ -210,7 +212,7 @@ impl ChainApi, Block::Hash, Block::Header, Sig Ok(self.subscriptions.cancel(id)) } - fn subscribe_finalised_heads(&self, _meta: Self::Metadata, subscriber: Subscriber) { + fn subscribe_finalized_heads(&self, _meta: Self::Metadata, subscriber: Subscriber) { self.subscribe_headers( subscriber, || Ok(Some(self.client.info()?.chain.finalized_hash)), @@ -219,7 +221,7 @@ impl ChainApi, Block::Hash, Block::Header, Sig ) } - fn unsubscribe_finalised_heads(&self, _metadata: Option, id: SubscriptionId) -> RpcResult { + fn unsubscribe_finalized_heads(&self, _metadata: Option, id: SubscriptionId) -> RpcResult { Ok(self.subscriptions.cancel(id)) } } diff --git a/core/rpc/src/chain/tests.rs b/core/rpc/src/chain/tests.rs index bad3c5aeb8735..26b7202305b16 100644 --- a/core/rpc/src/chain/tests.rs +++ b/core/rpc/src/chain/tests.rs @@ -157,7 +157,7 @@ fn should_return_block_hash() { #[test] -fn should_return_finalised_hash() { +fn should_return_finalized_hash() { let core = ::tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); @@ -167,23 +167,23 @@ fn should_return_finalised_hash() { }; assert_matches!( - client.finalised_head(), + client.finalized_head(), Ok(ref x) if x == &client.client.genesis_hash() ); // import new block let builder = client.client.new_block().unwrap(); client.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap(); - // no finalisation yet + // no finalization yet assert_matches!( - client.finalised_head(), + client.finalized_head(), Ok(ref x) if x == &client.client.genesis_hash() ); - // finalise + // finalize client.client.finalize_block(BlockId::number(1), None, true).unwrap(); assert_matches!( - client.finalised_head(), + client.finalized_head(), Ok(ref x) if x == &client.client.block_hash(1).unwrap().unwrap() ); } @@ -220,7 +220,7 @@ fn should_notify_about_latest_block() { } #[test] -fn should_notify_about_finalised_block() { +fn should_notify_about_finalized_block() { let mut core = ::tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); let (subscriber, id, transport) = Subscriber::new_test("test"); @@ -231,7 +231,7 @@ fn should_notify_about_finalised_block() { subscriptions: Subscriptions::new(remote), }; - api.subscribe_finalised_heads(Default::default(), subscriber); + api.subscribe_finalized_heads(Default::default(), subscriber); // assert id assigned assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1)))); diff --git a/core/service/src/components.rs b/core/service/src/components.rs index e89921742bca7..eb37a69a14ca2 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -356,7 +356,7 @@ pub trait ServiceFactory: 'static + Sized { } } -/// A collection of types and function to generalise over full / light client type. +/// A collection of types and function to generalize over full / light client type. pub trait Components: Sized + 'static { /// Associated service factory. type Factory: ServiceFactory; diff --git a/core/sr-api-macros/src/impl_runtime_apis.rs b/core/sr-api-macros/src/impl_runtime_apis.rs index 8bdf977303bcd..b5dd3f21c5c46 100644 --- a/core/sr-api-macros/src/impl_runtime_apis.rs +++ b/core/sr-api-macros/src/impl_runtime_apis.rs @@ -271,7 +271,7 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result + 'static> { call: &'static C, commit_on_success: ::std::cell::RefCell, - initialised_block: ::std::cell::RefCell>, + initialized_block: ::std::cell::RefCell>, changes: ::std::cell::RefCell<#crate_::runtime_api::OverlayedChanges>, } @@ -320,7 +320,7 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result Result::Header) { + fn initialize_block(_: &::Header) { unimplemented!() } } diff --git a/core/sr-io/build.rs b/core/sr-io/build.rs index 62ddacbbf4f99..5b5d06b65a253 100644 --- a/core/sr-io/build.rs +++ b/core/sr-io/build.rs @@ -3,7 +3,7 @@ use rustc_version::{version, version_meta, Channel}; fn main() { - // Assert we haven't travelled back in time + // Assert we haven't traveled back in time assert!(version().unwrap().major >= 1); // Set cfg flags depending on release channel diff --git a/core/sr-io/without_std.rs b/core/sr-io/without_std.rs index a4d62df30b16c..e4e32bd17d581 100644 --- a/core/sr-io/without_std.rs +++ b/core/sr-io/without_std.rs @@ -297,7 +297,7 @@ pub trait ExternTrieCrypto { fn enumerated_trie_root(values: &[&[u8]]) -> [u8; 32]; } -// Ensures we use a Blake2_256-flavoured Hasher when calling into native +// Ensures we use a Blake2_256-flavored Hasher when calling into native impl ExternTrieCrypto for Blake2Hasher { fn enumerated_trie_root(values: &[&[u8]]) -> [u8; 32] { let lengths = values.iter().map(|v| (v.len() as u32).to_le()).collect::>(); diff --git a/core/sr-primitives/src/generic/era.rs b/core/sr-primitives/src/generic/era.rs index 037013b4feaa9..e5a7b24f0cc5f 100644 --- a/core/sr-primitives/src/generic/era.rs +++ b/core/sr-primitives/src/generic/era.rs @@ -166,7 +166,7 @@ mod tests { } #[test] - fn era_initialisation_works() { + fn era_initialization_works() { assert_eq!(Era::mortal(64, 42), Era::Mortal(64, 42)); assert_eq!(Era::mortal(32768, 20000), Era::Mortal(32768, 20000)); assert_eq!(Era::mortal(200, 513), Era::Mortal(256, 1)); @@ -175,8 +175,8 @@ mod tests { } #[test] - fn quantised_clamped_era_initialisation_works() { - // clamp 1000000 to 65536, quantise 1000001 % 65536 to the nearest 4 + fn quantized_clamped_era_initialization_works() { + // clamp 1000000 to 65536, quantize 1000001 % 65536 to the nearest 4 assert_eq!(Era::mortal(1000000, 1000001), Era::Mortal(65536, 1000001 % 65536 / 4 * 4)); } diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index ef3f133df6b85..0454b74f6f36e 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -252,23 +252,23 @@ impl > SimpleBitOps for T {} -/// The block finalisation trait. Implementing this lets you express what should happen +/// The block finalization trait. Implementing this lets you express what should happen /// for your module when the block is ending. -pub trait OnFinalise { - /// The block is being finalised. Implement to have something happen. - fn on_finalise(_n: BlockNumber) {} +pub trait OnFinalize { + /// The block is being finalized. Implement to have something happen. + fn on_finalize(_n: BlockNumber) {} } -impl OnFinalise for () {} +impl OnFinalize for () {} -/// The block initialisation trait. Implementing this lets you express what should happen +/// The block initialization trait. Implementing this lets you express what should happen /// for your module when the block is beginning (right before the first extrinsic is executed). -pub trait OnInitialise { - /// The block is being initialised. Implement to have something happen. - fn on_initialise(_n: BlockNumber) {} +pub trait OnInitialize { + /// The block is being initialized. Implement to have something happen. + fn on_initialize(_n: BlockNumber) {} } -impl OnInitialise for () {} +impl OnInitialize for () {} /// Off-chain computation trait. /// @@ -290,14 +290,14 @@ impl OffchainWorker for () {} macro_rules! tuple_impl { ($one:ident,) => { - impl> OnFinalise for ($one,) { - fn on_finalise(n: Number) { - $one::on_finalise(n); + impl> OnFinalize for ($one,) { + fn on_finalize(n: Number) { + $one::on_finalize(n); } } - impl> OnInitialise for ($one,) { - fn on_initialise(n: Number) { - $one::on_initialise(n); + impl> OnInitialize for ($one,) { + fn on_initialize(n: Number) { + $one::on_initialize(n); } } impl> OffchainWorker for ($one,) { @@ -309,22 +309,22 @@ macro_rules! tuple_impl { ($first:ident, $($rest:ident,)+) => { impl< Number: Copy, - $first: OnFinalise, - $($rest: OnFinalise),+ - > OnFinalise for ($first, $($rest),+) { - fn on_finalise(n: Number) { - $first::on_finalise(n); - $($rest::on_finalise(n);)+ + $first: OnFinalize, + $($rest: OnFinalize),+ + > OnFinalize for ($first, $($rest),+) { + fn on_finalize(n: Number) { + $first::on_finalize(n); + $($rest::on_finalize(n);)+ } } impl< Number: Copy, - $first: OnInitialise, - $($rest: OnInitialise),+ - > OnInitialise for ($first, $($rest),+) { - fn on_initialise(n: Number) { - $first::on_initialise(n); - $($rest::on_initialise(n);)+ + $first: OnInitialize, + $($rest: OnInitialize),+ + > OnInitialize for ($first, $($rest),+) { + fn on_initialize(n: Number) { + $first::on_initialize(n); + $($rest::on_initialize(n);)+ } } impl< diff --git a/core/sr-sandbox/build.rs b/core/sr-sandbox/build.rs index 62ddacbbf4f99..5b5d06b65a253 100755 --- a/core/sr-sandbox/build.rs +++ b/core/sr-sandbox/build.rs @@ -3,7 +3,7 @@ use rustc_version::{version, version_meta, Channel}; fn main() { - // Assert we haven't travelled back in time + // Assert we haven't traveled back in time assert!(version().unwrap().major >= 1); // Set cfg flags depending on release channel diff --git a/core/sr-std/build.rs b/core/sr-std/build.rs index 3cac76831607b..af9c91db877dd 100644 --- a/core/sr-std/build.rs +++ b/core/sr-std/build.rs @@ -3,7 +3,7 @@ use rustc_version::{version, version_meta, Channel}; fn main() { - // Assert we haven't travelled back in time + // Assert we haven't traveled back in time assert!(version().unwrap().major >= 1); // Set cfg flags depending on release channel diff --git a/core/sr-version/src/lib.rs b/core/sr-version/src/lib.rs index 71a4c5149d393..3d1dfb4313638 100644 --- a/core/sr-version/src/lib.rs +++ b/core/sr-version/src/lib.rs @@ -91,7 +91,7 @@ pub struct RuntimeVersion { /// serves only as an indication that the code is different; as long as the other two versions /// are the same then while the actual code may be different, it is nonetheless required to /// do the same thing. - /// Non-consensus-breaking optimisations are about the only changes that could be made which + /// Non-consensus-breaking optimizations are about the only changes that could be made which /// would result in only the `impl_version` changing. pub impl_version: u32, diff --git a/core/telemetry/src/lib.rs b/core/telemetry/src/lib.rs index 21289459c6241..fba75c196aa36 100644 --- a/core/telemetry/src/lib.rs +++ b/core/telemetry/src/lib.rs @@ -93,7 +93,7 @@ impl Drain for Multiply { } } -/// Initialise telemetry. +/// Initialize telemetry. pub fn init_telemetry(config: TelemetryConfig) -> slog_scope::GlobalLoggerGuard { let mut endpoint_drains: Vec>> = Vec::new(); let mut out_syncs = Vec::new(); diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index 74ec56240c8c0..744bdd7fea494 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -167,9 +167,9 @@ pub fn run_tests(mut input: &[u8]) -> Vec { print("run_tests..."); let block = Block::decode(&mut input).unwrap(); - print("deserialised block."); + print("deserialized block."); let stxs = block.extrinsics.iter().map(Encode::encode).collect::>(); - print("reserialised transactions."); + print("reserialized transactions."); [stxs.len() as u8].encode() } @@ -297,8 +297,8 @@ cfg_if! { system::execute_block(block) } - fn initialise_block(header: &::Header) { - system::initialise_block(header) + fn initialize_block(header: &::Header) { + system::initialize_block(header) } } @@ -319,8 +319,8 @@ cfg_if! { system::execute_transaction(extrinsic) } - fn finalise_block() -> ::Header { - system::finalise_block() + fn finalize_block() -> ::Header { + system::finalize_block() } fn inherent_extrinsics(_data: InherentData) -> Vec<::Extrinsic> { @@ -402,8 +402,8 @@ cfg_if! { system::execute_block(block) } - fn initialise_block(header: &::Header) { - system::initialise_block(header) + fn initialize_block(header: &::Header) { + system::initialize_block(header) } } @@ -424,8 +424,8 @@ cfg_if! { system::execute_transaction(extrinsic) } - fn finalise_block() -> ::Header { - system::finalise_block() + fn finalize_block() -> ::Header { + system::finalize_block() } fn inherent_extrinsics(_data: InherentData) -> Vec<::Extrinsic> { diff --git a/core/test-runtime/src/system.rs b/core/test-runtime/src/system.rs index ffc01182d47fd..a119c8b62db40 100644 --- a/core/test-runtime/src/system.rs +++ b/core/test-runtime/src/system.rs @@ -63,7 +63,7 @@ pub fn authorities() -> Vec { .collect() } -pub fn initialise_block(header: &Header) { +pub fn initialize_block(header: &Header) { // populate environment. ::put(&header.number); ::put(&header.parent_hash); @@ -201,8 +201,8 @@ pub fn execute_transaction(utx: Extrinsic) -> ApplyResult { result } -/// Finalise the block. -pub fn finalise_block() -> Header { +/// Finalize the block. +pub fn finalize_block() -> Header { let extrinsic_index: u32 = storage::unhashed::take(well_known_keys::EXTRINSIC_INDEX).unwrap(); let txs: Vec<_> = (0..extrinsic_index).map(ExtrinsicData::take).collect(); let txs = txs.iter().map(Vec::as_slice).collect::>(); diff --git a/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index afdd492c6aafc..cd36b9f405d78 100644 Binary files a/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/core/transaction-pool/graph/src/listener.rs b/core/transaction-pool/graph/src/listener.rs index ac59b4c57e102..335ff8a0537e9 100644 --- a/core/transaction-pool/graph/src/listener.rs +++ b/core/transaction-pool/graph/src/listener.rs @@ -93,6 +93,6 @@ impl Listener { /// Transaction was pruned from the pool. pub fn pruned(&mut self, header_hash: H2, tx: &H) { - self.fire(tx, |watcher| watcher.finalised(header_hash)) + self.fire(tx, |watcher| watcher.finalized(header_hash)) } } diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index 9c3478d3d7831..91ded26630cf1 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -728,7 +728,7 @@ mod tests { use super::*; #[test] - fn should_trigger_ready_and_finalised() { + fn should_trigger_ready_and_finalized() { // given let pool = pool(); let watcher = pool.submit_and_watch(&BlockId::Number(0), uxt(Transfer { @@ -748,12 +748,12 @@ mod tests { // then let mut stream = watcher.into_stream().wait(); assert_eq!(stream.next(), Some(Ok(watcher::Status::Ready))); - assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalised(H256::from_low_u64_be(2).into())))); + assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalized(H256::from_low_u64_be(2).into())))); assert_eq!(stream.next(), None); } #[test] - fn should_trigger_ready_and_finalised_when_pruning_via_hash() { + fn should_trigger_ready_and_finalized_when_pruning_via_hash() { // given let pool = pool(); let watcher = pool.submit_and_watch(&BlockId::Number(0), uxt(Transfer { @@ -773,7 +773,7 @@ mod tests { // then let mut stream = watcher.into_stream().wait(); assert_eq!(stream.next(), Some(Ok(watcher::Status::Ready))); - assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalised(H256::from_low_u64_be(2).into())))); + assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalized(H256::from_low_u64_be(2).into())))); assert_eq!(stream.next(), None); } diff --git a/core/transaction-pool/graph/src/watcher.rs b/core/transaction-pool/graph/src/watcher.rs index 419a98ca79230..5516d8c43c749 100644 --- a/core/transaction-pool/graph/src/watcher.rs +++ b/core/transaction-pool/graph/src/watcher.rs @@ -30,8 +30,8 @@ pub enum Status { Future, /// Extrinsic is part of the ready queue. Ready, - /// Extrinsic has been finalised in block with given hash. - Finalised(H2), + /// Extrinsic has been finalized in block with given hash. + Finalized(H2), /// Some state change (perhaps another extrinsic was included) rendered this extrinsic invalid. Usurped(H), /// The extrinsic has been broadcast to the given peers. @@ -70,14 +70,14 @@ impl Watcher { #[derive(Debug)] pub struct Sender { receivers: Vec>>, - finalised: bool, + finalized: bool, } impl Default for Sender { fn default() -> Self { Sender { receivers: Default::default(), - finalised: false, + finalized: false, } } } @@ -108,17 +108,17 @@ impl Sender { self.send(Status::Usurped(hash)) } - /// Extrinsic has been finalised in block with given hash. - pub fn finalised(&mut self, hash: H2) { - self.send(Status::Finalised(hash)); - self.finalised = true; + /// Extrinsic has been finalized in block with given hash. + pub fn finalized(&mut self, hash: H2) { + self.send(Status::Finalized(hash)); + self.finalized = true; } /// Extrinsic has been marked as invalid by the block builder. pub fn invalid(&mut self) { self.send(Status::Invalid); - // we mark as finalised as there are no more notifications - self.finalised = true; + // we mark as finalized as there are no more notifications + self.finalized = true; } /// Transaction has been dropped from the pool because of the limit. @@ -132,9 +132,9 @@ impl Sender { } - /// Returns true if the are no more listeners for this extrinsic or it was finalised. + /// Returns true if the are no more listeners for this extrinsic or it was finalized. pub fn is_done(&self) -> bool { - self.finalised || self.receivers.is_empty() + self.finalized || self.receivers.is_empty() } fn send(&mut self, status: Status) { diff --git a/core/trie/src/trie_stream.rs b/core/trie/src/trie_stream.rs index e97516103d715..e283a512bb509 100644 --- a/core/trie/src/trie_stream.rs +++ b/core/trie/src/trie_stream.rs @@ -24,7 +24,7 @@ use codec::Encode; use super::{EMPTY_TRIE, LEAF_NODE_OFFSET, LEAF_NODE_BIG, EXTENSION_NODE_OFFSET, EXTENSION_NODE_BIG, branch_node}; -/// Codec-flavoured TrieStream +/// Codec-flavored TrieStream pub struct TrieStream { buffer: Vec, } diff --git a/node-template/init.sh b/node-template/init.sh index 5dde6d42418b5..cf5ecf97926fe 100755 --- a/node-template/init.sh +++ b/node-template/init.sh @@ -2,7 +2,7 @@ set -e -echo "*** Initialising WASM build environment" +echo "*** Initializing WASM build environment" if [ -z $CI_PROJECT_NAME ] ; then rustup update nightly diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index a82f8ce585958..c5c3b0d01d72b 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -242,8 +242,8 @@ impl_runtime_apis! { Executive::execute_block(block) } - fn initialise_block(header: &::Header) { - Executive::initialise_block(header) + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) } } @@ -258,8 +258,8 @@ impl_runtime_apis! { Executive::apply_extrinsic(extrinsic) } - fn finalise_block() -> ::Header { - Executive::finalise_block() + fn finalize_block() -> ::Header { + Executive::finalize_block() } fn inherent_extrinsics(data: InherentData) -> Vec<::Extrinsic> { diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index ca314ba001b57..3cb8d21d5d0da 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -10,7 +10,7 @@ use ed25519::Public as AuthorityId; // Note this is the URL for the telemetry server //const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; -/// Specialised `ChainSpec`. This is a specialisation of the general Substrate ChainSpec type. +/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. pub type ChainSpec = substrate_service::ChainSpec; /// The chain specification option. This is expected to come in from the CLI and diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 818a194f99276..a45b25249fbe3 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -28,7 +28,7 @@ use substrate_telemetry::TelemetryEndpoints; const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; -/// Specialised `ChainSpec`. +/// Specialized `ChainSpec`. pub type ChainSpec = substrate_service::ChainSpec; /// Dried Danta testnet generator diff --git a/node/executor/src/lib.rs b/node/executor/src/lib.rs index 22bf1a9b799af..c855a4e6f00c5 100644 --- a/node/executor/src/lib.rs +++ b/node/executor/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! A `CodeExecutor` specialisation which uses natively compiled runtime when the wasm to be +//! A `CodeExecutor` specialization which uses natively compiled runtime when the wasm to be //! executed is equivalent to the natively compiled code. #![cfg_attr(feature = "benchmarks", feature(test))] @@ -132,7 +132,7 @@ mod tests { let r = executor().call::<_, NeverNativeValue, fn() -> _>( &mut t, - "Core_initialise_block", + "Core_initialize_block", &vec![].and(&from_block_number(1u64)), true, None, @@ -165,7 +165,7 @@ mod tests { let r = executor().call::<_, NeverNativeValue, fn() -> _>( &mut t, - "Core_initialise_block", + "Core_initialize_block", &vec![].and(&from_block_number(1u64)), true, None, @@ -198,7 +198,7 @@ mod tests { let r = executor().call::<_, NeverNativeValue, fn() -> _>( &mut t, - "Core_initialise_block", + "Core_initialize_block", &vec![].and(&from_block_number(1u64)), true, None, @@ -235,7 +235,7 @@ mod tests { let r = executor().call::<_, NeverNativeValue, fn() -> _>( &mut t, - "Core_initialise_block", + "Core_initialize_block", &vec![].and(&from_block_number(1u64)), true, None, @@ -353,7 +353,7 @@ mod tests { // execute the block to get the real header. Executor::new(None).call::<_, NeverNativeValue, fn() -> _>( env, - "Core_initialise_block", + "Core_initialize_block", &header.encode(), true, None, @@ -371,7 +371,7 @@ mod tests { let header = match Executor::new(None).call::<_, NeverNativeValue, fn() -> _>( env, - "BlockBuilder_finalise_block", + "BlockBuilder_finalize_block", &[0u8;0], true, None, @@ -807,7 +807,7 @@ mod tests { twox_128(>::key()).to_vec() => vec![0u8; 16] ]); - let r = WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "Core_initialise_block", &vec![].and(&from_block_number(1u64))); + let r = WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "Core_initialize_block", &vec![].and(&from_block_number(1u64))); assert!(r.is_ok()); let r = WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "BlockBuilder_apply_extrinsic", &vec![].and(&xt())).unwrap(); let r = ApplyResult::decode(&mut &r[..]).unwrap(); @@ -829,7 +829,7 @@ mod tests { twox_128(>::key()).to_vec() => vec![0u8; 16] ]); - let r = WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "Core_initialise_block", &vec![].and(&from_block_number(1u64))); + let r = WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "Core_initialize_block", &vec![].and(&from_block_number(1u64))); assert!(r.is_ok()); let r = WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "BlockBuilder_apply_extrinsic", &vec![].and(&xt())).unwrap(); let r = ApplyResult::decode(&mut &r[..]).unwrap(); diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index ad31c082969cc..cb128aa184db2 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -58,7 +58,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("node"), impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, - spec_version: 49, + spec_version: 50, impl_version: 50, apis: RUNTIME_API_VERSIONS, }; @@ -250,8 +250,8 @@ impl_runtime_apis! { Executive::execute_block(block) } - fn initialise_block(header: &::Header) { - Executive::initialise_block(header) + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) } } @@ -266,8 +266,8 @@ impl_runtime_apis! { Executive::apply_extrinsic(extrinsic) } - fn finalise_block() -> ::Header { - Executive::finalise_block() + fn finalize_block() -> ::Header { + Executive::finalize_block() } fn inherent_extrinsics(data: InherentData) -> Vec<::Extrinsic> { diff --git a/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index fef986a4f7864..8aa08585ecbfc 100644 Binary files a/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ diff --git a/scripts/gitlab/check_runtime.sh b/scripts/gitlab/check_runtime.sh index 61068e7eb8885..fe8cbf450fc59 100755 --- a/scripts/gitlab/check_runtime.sh +++ b/scripts/gitlab/check_runtime.sh @@ -18,7 +18,7 @@ VERSIONS_FILE="node/runtime/src/lib.rs" github_label () { echo - echo "# run github-api job for labelling it ${1}" + echo "# run github-api job for labeling it ${1}" curl -sS -X POST \ -F "token=${CI_JOB_TOKEN}" \ -F "ref=master" \ diff --git a/scripts/init.sh b/scripts/init.sh index 5dde6d42418b5..cf5ecf97926fe 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -2,7 +2,7 @@ set -e -echo "*** Initialising WASM build environment" +echo "*** Initializing WASM build environment" if [ -z $CI_PROJECT_NAME ] ; then rustup update nightly diff --git a/scripts/kubernetes/values.yaml b/scripts/kubernetes/values.yaml index f56cea29934dc..89a6445e00a2f 100644 --- a/scripts/kubernetes/values.yaml +++ b/scripts/kubernetes/values.yaml @@ -31,13 +31,13 @@ nodes: - --ws-external # - --log # - sub-libp2p=trace - + validator: {} # providing 'keys' string via --set commandline parameter will run the nodes # in validator mode (--validator). # - # name, key and node-key can be given in a base64 encoded keyfile string (at + # name, key and node-key can be given in a base64 encoded keyfile string (at # validator.keys) which has the following format: # # substrate-0-name @@ -47,8 +47,8 @@ validator: {} # substrate-1-key # substrate-1-node-key # - # pod names are canonical. changing these or providing different amount of - # keys than the replicas count will lead to behaviour noone ever has + # pod names are canonical. changing these or providing different amount of + # keys than the replicas count will lead to behavior noone ever has # experienced before. diff --git a/srml/assets/Cargo.toml b/srml/assets/Cargo.toml index f274661e6c84e..129f884bd9cad 100644 --- a/srml/assets/Cargo.toml +++ b/srml/assets/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", optional = true } parity-codec = { version = "3.2", default-features = false } -# Needed for various traits. In our case, `OnFinalise`. +# Needed for various traits. In our case, `OnFinalize`. primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } # Needed for type-safe access to storage DB. srml-support = { path = "../support", default-features = false } diff --git a/srml/aura/src/tests.rs b/srml/aura/src/tests.rs index 98b57a1251248..e74c7dace2ff3 100644 --- a/srml/aura/src/tests.rs +++ b/srml/aura/src/tests.rs @@ -73,18 +73,18 @@ fn aura_reports_offline() { } with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); let slot_duration = Aura::slot_duration(); Aura::on_timestamp_set::(5 * slot_duration, slot_duration); - let header = System::finalise(); + let header = System::finalize(); // no slashing when last step was 0. assert_eq!(SLASH_COUNTS.lock().as_slice(), &[0, 0, 0, 0]); - System::initialise(&2, &header.hash(), &Default::default()); + System::initialize(&2, &header.hash(), &Default::default()); Aura::on_timestamp_set::(8 * slot_duration, slot_duration); - let _header = System::finalise(); + let _header = System::finalize(); // Steps 6 and 7 were skipped. assert_eq!(SLASH_COUNTS.lock().as_slice(), &[0, 0, 1, 1]); diff --git a/srml/consensus/src/lib.rs b/srml/consensus/src/lib.rs index 985a32bd6c3b6..dfcc6805dc8de 100644 --- a/srml/consensus/src/lib.rs +++ b/srml/consensus/src/lib.rs @@ -183,7 +183,7 @@ decl_storage! { decl_module! { pub struct Module for enum Call where origin: T::Origin { - /// Report some misbehaviour. + /// Report some misbehavior. fn report_misbehavior(origin, _report: Vec) { ensure_signed(origin)?; } @@ -224,7 +224,7 @@ decl_module! { } } - fn on_finalise() { + fn on_finalize() { if let Some(original_authorities) = >::take() { let current_authorities = AuthorityStorageVec::::items(); if current_authorities != original_authorities { diff --git a/srml/consensus/src/tests.rs b/srml/consensus/src/tests.rs index 0145094a7674d..ff60660b0a475 100644 --- a/srml/consensus/src/tests.rs +++ b/srml/consensus/src/tests.rs @@ -18,7 +18,7 @@ #![cfg(test)] -use primitives::{generic, testing::{self, UintAuthorityId}, traits::OnFinalise}; +use primitives::{generic, testing::{self, UintAuthorityId}, traits::OnFinalize}; use runtime_io::with_externalities; use crate::mock::{Consensus, System, new_test_ext}; use inherents::{InherentData, ProvideInherent}; @@ -26,10 +26,10 @@ use inherents::{InherentData, ProvideInherent}; #[test] fn authorities_change_logged() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); Consensus::set_authorities(&[UintAuthorityId(4), UintAuthorityId(5), UintAuthorityId(6)]); - Consensus::on_finalise(1); - let header = System::finalise(); + Consensus::on_finalize(1); + let header = System::finalize(); assert_eq!(header.digest, testing::Digest { logs: vec![ generic::DigestItem::AuthoritiesChange( @@ -47,9 +47,9 @@ fn authorities_change_logged() { #[test] fn authorities_change_is_not_logged_when_not_changed() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialise(&1, &Default::default(), &Default::default()); - Consensus::on_finalise(1); - let header = System::finalise(); + System::initialize(&1, &Default::default(), &Default::default()); + Consensus::on_finalize(1); + let header = System::finalize(); assert_eq!(header.digest, testing::Digest { logs: vec![], }); @@ -59,11 +59,11 @@ fn authorities_change_is_not_logged_when_not_changed() { #[test] fn authorities_change_is_not_logged_when_changed_back_to_original() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); Consensus::set_authorities(&[UintAuthorityId(4), UintAuthorityId(5), UintAuthorityId(6)]); Consensus::set_authorities(&[UintAuthorityId(1), UintAuthorityId(2), UintAuthorityId(3)]); - Consensus::on_finalise(1); - let header = System::finalise(); + Consensus::on_finalize(1); + let header = System::finalize(); assert_eq!(header.digest, testing::Digest { logs: vec![], }); @@ -73,7 +73,7 @@ fn authorities_change_is_not_logged_when_changed_back_to_original() { #[test] fn offline_report_can_be_excluded() { with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); assert!(Consensus::create_inherent(&InherentData::new()).is_none()); let offline_report: Vec = vec![0]; @@ -89,7 +89,7 @@ fn set_and_kill_storage_work() { use srml_support::storage; with_externalities(&mut new_test_ext(vec![1, 2, 3]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); let item = (vec![42u8], vec![42u8]); diff --git a/srml/contract/src/exec.rs b/srml/contract/src/exec.rs index 6c04a2e1d0a1f..afd5159fced84 100644 --- a/srml/contract/src/exec.rs +++ b/srml/contract/src/exec.rs @@ -44,7 +44,7 @@ pub struct CallReceipt { /// An interface that provides access to the external environment in which the /// smart-contract is executed. /// -/// This interface is specialised to an account of the executing code, so all +/// This interface is specialized to an account of the executing code, so all /// operations are implicitly performed on that account. pub trait Ext { type T: Trait; diff --git a/srml/contract/src/lib.rs b/srml/contract/src/lib.rs index 6fbd502f01175..da3fe4dbf0be3 100644 --- a/srml/contract/src/lib.rs +++ b/srml/contract/src/lib.rs @@ -15,70 +15,70 @@ // along with Substrate. If not, see . //! # Contract Module -//! +//! //! The contract module provides functionality for the runtime to deploy and execute WebAssembly smart-contracts. //! The supported dispatchable functions are documented as part of the [`Call`](./enum.Call.html) enum. -//! +//! //! ## Overview -//! +//! //! This module extends accounts (see `Balances` module) to have smart-contract functionality. -//! These "smart-contract accounts" have the ability to create smart-contracts and make calls to other contract +//! These "smart-contract accounts" have the ability to create smart-contracts and make calls to other contract //! and non-contract accounts. -//! +//! //! The smart-contract code is stored once in a `code_cache`, and later retrievable via its `code_hash`. -//! This means that multiple smart-contracts can be instantiated from the same `code_cache`, without replicating +//! This means that multiple smart-contracts can be instantiated from the same `code_cache`, without replicating //! the code each time. -//! +//! //! When a smart-contract is called, its associated code is retrieved via the code hash and gets executed. //! This call can alter the storage entries of the smart-contract account, create new smart-contracts, //! or call other smart-contracts. -//! +//! //! Finally, when the `Balances` module determines an account is dead (i.e. account balance fell below the -//! existential deposit), it reaps the account. This will delete the associated code and storage of the +//! existential deposit), it reaps the account. This will delete the associated code and storage of the //! smart-contract account. -//! +//! //! ### Gas -//! +//! //! Senders must specify a gas limit with every call, as all instructions invoked by the smart-contract require gas. //! Unused gas is refunded after the call, regardless of the execution outcome. -//! +//! //! If the gas limit is reached, then all calls and state changes (including balance transfers) are only //! reverted at the current call's contract level. For example, if contract A calls B and B runs out of gas mid-call, -//! then all of B's calls are reverted. Assuming correct error handling by contract A, A's other calls and state -//! changes still persist. -//! +//! then all of B's calls are reverted. Assuming correct error handling by contract A, A's other calls and state +//! changes still persist. +//! //! ### Notable Scenarios -//! +//! //! Contract call failures are not always cascading. When failures occur in a sub-call, they do not "bubble up", //! and the call will only revert at the specific contract level. For example, if contract A calls contract B, and B //! fails, A can decide how to handle that failure, either proceeding or reverting A's changes. -//! +//! //! ## Interface -//! +//! //! ### Dispatchable functions -//! +//! //! * `put_code` - Stores the given binary Wasm code into the chains storage and returns its `code_hash`. -//! -//! * `create` - Deploys a new contract from the given `code_hash`, optionally transferring some balance. +//! +//! * `create` - Deploys a new contract from the given `code_hash`, optionally transferring some balance. //! This creates a new smart contract account and calls its contract deploy handler to initialize the contract. -//! +//! //! * `call` - Makes a call to an account, optionally transferring some balance. //! //! ### Public functions -//! +//! //! See the [module](./struct.Module.html) for details on publicly available functions. -//! +//! //! ## Usage -//! -//! The contract module is a work in progress. The following examples show how this contract module can be +//! +//! The contract module is a work in progress. The following examples show how this contract module can be //! used to create and call contracts. -//! -//! * [`pDSL`](https://github.com/Robbepop/pdsl) is a domain specific language which enables writing +//! +//! * [`pDSL`](https://github.com/Robbepop/pdsl) is a domain specific language which enables writing //! WebAssembly based smart contracts in the Rust programming language. This is a work in progress. -//! +//! //! ## Related Modules //! * [`Balances`](https://crates.parity.io/srml_balances/index.html) -//! +//! #![cfg_attr(not(feature = "std"), no_std)] @@ -136,7 +136,7 @@ pub struct AccountInfo { /// property (being a proper uniqueid). pub trait TrieIdGenerator { /// get a trie id for an account, using reference to parent account trie id to ensure - /// uniqueness of trie id + /// uniqueness of trie id /// The implementation must ensure every new trie id is unique: two consecutive call with the /// same parameter needs to return different trie id values. fn trie_id(account_id: &AccountId) -> TrieId; @@ -248,7 +248,7 @@ decl_module! { Ok(()) } - /// Stores the given binary Wasm code into the chains storage and returns its `codehash`. + /// Stores the given binary Wasm code into the chains storage and returns its `codehash`. /// You can instantiate contracts only with stored code. fn put_code( origin, @@ -272,10 +272,10 @@ decl_module! { /// Makes a call to an account, optionally transferring some balance. /// - /// * If the account is a smart-contract account, the associated code will be + /// * If the account is a smart-contract account, the associated code will be /// executed and any value will be transferred. /// * If the account is a regular account, any value will be transferred. - /// * If no account exists and the call value is not less than `existential_deposit`, + /// * If no account exists and the call value is not less than `existential_deposit`, /// a regular account will be created and any value will be transferred. fn call( origin, @@ -377,7 +377,7 @@ decl_module! { result.map(|_| ()) } - fn on_finalise() { + fn on_finalize() { >::kill(); } } diff --git a/srml/council/src/seats.rs b/srml/council/src/seats.rs index 867efe4ca186e..f005cc6ecf0f1 100644 --- a/srml/council/src/seats.rs +++ b/srml/council/src/seats.rs @@ -242,7 +242,7 @@ decl_module! { let candidate = T::Lookup::lookup(candidate)?; ensure!(index == Self::vote_index(), "index not current"); - let (_, _, expiring) = Self::next_finalise().ok_or("cannot present outside of presentation period")?; + let (_, _, expiring) = Self::next_finalize().ok_or("cannot present outside of presentation period")?; let stakes = Self::snapshoted_stakes(); let voters = Self::voters(); let bad_presentation_punishment = Self::present_slash_per_voter() * BalanceOf::::sa(voters.len() as u64); @@ -303,18 +303,18 @@ decl_module! { } /// Set the presentation duration. If there is currently a vote being presented for, will - /// invoke `finalise_vote`. + /// invoke `finalize_vote`. fn set_presentation_duration(#[compact] count: T::BlockNumber) { >::put(count); } /// Set the presentation duration. If there is current a vote being presented for, will - /// invoke `finalise_vote`. + /// invoke `finalize_vote`. fn set_term_duration(#[compact] count: T::BlockNumber) { >::put(count); } - fn on_finalise(n: T::BlockNumber) { + fn on_finalize(n: T::BlockNumber) { if let Err(e) = Self::end_block(n) { print("Guru meditation"); print(e); @@ -347,7 +347,7 @@ decl_storage! { /// Number of accounts that should be sitting on the council. pub DesiredSeats get(desired_seats) config(): u32; - // permanent state (always relevant, changes only at the finalisation of voting) + // permanent state (always relevant, changes only at the finalization of voting) /// The current council. When there's a vote going on, this should still be used for executive /// matters. The block number (second element in the tuple) is the block that their position is /// active until (calculated by the sum of the block number when the council member was elected @@ -371,9 +371,9 @@ decl_storage! { pub Candidates get(candidates): Vec; // has holes pub CandidateCount get(candidate_count): u32; - // temporary state (only relevant during finalisation/presentation) + // temporary state (only relevant during finalization/presentation) /// The accounts holding the seats that will become free on the next tally. - pub NextFinalise get(next_finalise): Option<(T::BlockNumber, u32, Vec)>; + pub NextFinalize get(next_finalize): Option<(T::BlockNumber, u32, Vec)>; /// The stakes as they were at the point that the vote ended. pub SnapshotedStakes get(snapshoted_stakes): Vec>; /// Get the leaderboard if we;re in the presentation phase. @@ -390,7 +390,7 @@ decl_event!( /// A tally (for approval votes of council seat(s)) has started. TallyStarted(u32), /// A tally (for approval votes of council seat(s)) has ended (with one or more new members). - TallyFinalised(Vec, Vec), + TallyFinalized(Vec, Vec), } ); @@ -399,7 +399,7 @@ impl Module { /// True if we're currently in a presentation period. pub fn presentation_active() -> bool { - >::exists() + >::exists() } /// If `who` a candidate at the moment? @@ -422,7 +422,7 @@ impl Module { } else { let c = Self::active_council(); let (next_possible, count, coming) = - if let Some((tally_end, comers, leavers)) = Self::next_finalise() { + if let Some((tally_end, comers, leavers)) = Self::next_finalize() { // if there's a tally in progress, then next tally can begin immediately afterwards (tally_end, c.len() - leavers.len() + comers as usize, comers) } else { @@ -453,9 +453,9 @@ impl Module { } } } - if let Some((number, _, _)) = Self::next_finalise() { + if let Some((number, _, _)) = Self::next_finalize() { if block_number == number { - Self::finalise_tally()? + Self::finalize_tally()? } } Ok(()) @@ -477,13 +477,13 @@ impl Module { let retaining_seats = active_council.len() - expiring.len(); if retaining_seats < desired_seats { let empty_seats = desired_seats - retaining_seats; - >::put((number + Self::presentation_duration(), empty_seats as u32, expiring)); + >::put((number + Self::presentation_duration(), empty_seats as u32, expiring)); let voters = Self::voters(); let votes = voters.iter().map(T::Currency::total_balance).collect::>(); >::put(votes); - // initialise leaderboard. + // initialize leaderboard. let leaderboard_size = empty_seats + Self::carry_count() as usize; >::put(vec![(BalanceOf::::zero(), T::AccountId::default()); leaderboard_size]); @@ -491,14 +491,14 @@ impl Module { } } - /// Finalise the vote, removing each of the `removals` and inserting `seats` of the most approved + /// Finalize the vote, removing each of the `removals` and inserting `seats` of the most approved /// candidates in their place. If the total council members is less than the desired membership /// a new vote is started. /// Clears all presented candidates, returning the bond of the elected ones. - fn finalise_tally() -> Result { + fn finalize_tally() -> Result { >::kill(); let (_, coming, expiring): (T::BlockNumber, u32, Vec) = - >::take().ok_or("finalise can only be called after a tally is started.")?; + >::take().ok_or("finalize can only be called after a tally is started.")?; let leaderboard: Vec<(BalanceOf, T::AccountId)> = >::take().unwrap_or_default(); let new_expiry = >::block_number() + Self::term_duration(); @@ -548,7 +548,7 @@ impl Module { new_candidates.truncate(last_index + 1); } - Self::deposit_event(RawEvent::TallyFinalised(incoming, outgoing)); + Self::deposit_event(RawEvent::TallyFinalized(incoming, outgoing)); >::put(new_candidates); >::put(count); @@ -584,7 +584,7 @@ mod tests { assert_eq!(Council::active_council(), vec![]); assert_eq!(Council::next_tally(), Some(4)); assert_eq!(Council::presentation_active(), false); - assert_eq!(Council::next_finalise(), None); + assert_eq!(Council::next_finalize(), None); assert_eq!(Council::candidates(), Vec::::new()); assert_eq!(Council::is_a_candidate(&1), false); diff --git a/srml/council/src/voting.rs b/srml/council/src/voting.rs index 4c5c62dc838b5..37c1444a74ee8 100644 --- a/srml/council/src/voting.rs +++ b/srml/council/src/voting.rs @@ -102,7 +102,7 @@ decl_module! { >::put(blocks); } - fn on_finalise(n: T::BlockNumber) { + fn on_finalize(n: T::BlockNumber) { if let Err(e) = Self::end_block(n) { print("Guru meditation"); print(e); diff --git a/srml/democracy/src/lib.rs b/srml/democracy/src/lib.rs index c6e87e29c4276..2673e4346071a 100644 --- a/srml/democracy/src/lib.rs +++ b/srml/democracy/src/lib.rs @@ -153,7 +153,7 @@ decl_module! { Ok(()) } - fn on_finalise(n: T::BlockNumber) { + fn on_finalize(n: T::BlockNumber) { if let Err(e) = Self::end_block(n) { runtime_io::print(e); } @@ -306,7 +306,7 @@ impl Module { } /// Get the delegated voters for the current proposal. - /// I think this goes into a worker once https://github.com/paritytech/substrate/issues/1458 is done. + /// I think this goes into a worker once https://github.com/paritytech/substrate/issues/1458 is done. fn tally_delegation(ref_index: ReferendumIndex) -> (BalanceOf, BalanceOf, BalanceOf) { Self::voters_for(ref_index).iter() .fold((Zero::zero(), Zero::zero(), Zero::zero()), |(approve_acc, against_acc, capital_acc), voter| { @@ -625,7 +625,7 @@ mod tests { assert_eq!(Democracy::voters_for(r), vec![1]); assert_eq!(Democracy::vote_of((r, 1)), AYE); assert_eq!(Democracy::tally(r), (10, 0, 10)); - + assert_eq!(Democracy::end_block(System::block_number()), Ok(())); assert_eq!(Balances::free_balance(&42), 2); }); @@ -671,11 +671,11 @@ mod tests { System::set_block_number(2); let r = 0; - // Check behaviour with cycle. + // Check behavior with cycle. assert_ok!(Democracy::delegate(Origin::signed(2), 1, 100)); assert_ok!(Democracy::delegate(Origin::signed(3), 2, 100)); assert_ok!(Democracy::delegate(Origin::signed(1), 3, 100)); - + assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_eq!(Democracy::referendum_count(), 1); diff --git a/srml/democracy/src/vote_threshold.rs b/srml/democracy/src/vote_threshold.rs index d436757539d47..5d9b2b742e679 100644 --- a/srml/democracy/src/vote_threshold.rs +++ b/srml/democracy/src/vote_threshold.rs @@ -37,7 +37,7 @@ pub enum VoteThreshold { pub trait Approved { /// Given `approve` votes for and `against` votes against from a total electorate size of /// `electorate` (`electorate - (approve + against)` are abstainers), then returns true if the - /// overall outcome is in favour of approval. + /// overall outcome is in favor of approval. fn approved(&self, approve: Balance, against: Balance, voters: Balance, electorate: Balance) -> bool; } @@ -72,7 +72,7 @@ fn compare_rationals + Div + Rem + Mul + Div + Rem + Copy> Approved for VoteThreshold { /// Given `approve` votes for and `against` votes against from a total electorate size of /// `electorate` of whom `voters` voted (`electorate - voters` are abstainers) then returns true if the - /// overall outcome is in favour of approval. + /// overall outcome is in favor of approval. /// /// We assume each *voter* may cast more than one *vote*, hence `voters` is not necessarily equal to /// `approve + against`. diff --git a/srml/example/src/lib.rs b/srml/example/src/lib.rs index 6ceb6da236d63..8ba83bfd88d51 100644 --- a/srml/example/src/lib.rs +++ b/srml/example/src/lib.rs @@ -201,14 +201,14 @@ decl_module! { >::put(new_value); } - // The signature could also look like: `fn on_initialise()` - fn on_initialise(_n: T::BlockNumber) { + // The signature could also look like: `fn on_initialize()` + fn on_initialize(_n: T::BlockNumber) { // Anything that needs to be done at the start of the block. // We don't do anything here. } - // The signature could also look like: `fn on_finalise()` - fn on_finalise(_n: T::BlockNumber) { + // The signature could also look like: `fn on_finalize()` + fn on_finalize(_n: T::BlockNumber) { // Anything that needs to be done at the end of the block. // We just kill our dummy storage item. >::kill(); @@ -258,7 +258,7 @@ mod tests { // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. use sr_primitives::{ - BuildStorage, traits::{BlakeTwo256, OnInitialise, OnFinalise, IdentityLookup}, + BuildStorage, traits::{BlakeTwo256, OnInitialize, OnFinalize, IdentityLookup}, testing::{Digest, DigestItem, Header} }; @@ -323,12 +323,12 @@ mod tests { assert_ok!(Example::accumulate_dummy(Origin::signed(1), 27)); assert_eq!(Example::dummy(), Some(69)); - // Check that finalising the block removes Dummy from storage. - >::on_finalise(1); + // Check that finalizing the block removes Dummy from storage. + >::on_finalize(1); assert_eq!(Example::dummy(), None); // Check that accumulate works when we Dummy has None in it. - >::on_initialise(2); + >::on_initialize(2); assert_ok!(Example::accumulate_dummy(Origin::signed(1), 42)); assert_eq!(Example::dummy(), Some(42)); }); diff --git a/srml/executive/src/lib.rs b/srml/executive/src/lib.rs index 0fe4b9e33d772..48908a01b316f 100644 --- a/srml/executive/src/lib.rs +++ b/srml/executive/src/lib.rs @@ -22,8 +22,8 @@ use rstd::prelude::*; use rstd::marker::PhantomData; use rstd::result; use primitives::traits::{ - self, Header, Zero, One, Checkable, Applyable, CheckEqual, OnFinalise, - OnInitialise, Hash, As, Digest, NumberFor, Block as BlockT, OffchainWorker + self, Header, Zero, One, Checkable, Applyable, CheckEqual, OnFinalize, + OnInitialize, Hash, As, Digest, NumberFor, Block as BlockT, OffchainWorker }; use srml_support::{Dispatchable, traits::MakePayment}; use parity_codec::{Codec, Encode}; @@ -65,7 +65,7 @@ impl< Block: traits::Block, Context: Default, Payment: MakePayment, - AllModules: OnInitialise + OnFinalise + OffchainWorker, + AllModules: OnInitialize + OnFinalize + OffchainWorker, > ExecuteBlock for Executive where Block::Extrinsic: Checkable + Codec, >::Checked: Applyable, @@ -86,7 +86,7 @@ impl< Block: traits::Block, Context: Default, Payment: MakePayment, - AllModules: OnInitialise + OnFinalise + OffchainWorker, + AllModules: OnInitialize + OnFinalize + OffchainWorker, > Executive where Block::Extrinsic: Checkable + Codec, >::Checked: Applyable, @@ -94,13 +94,13 @@ impl< <<>::Checked as Applyable>::Call as Dispatchable>::Origin: From> { /// Start the execution of a particular block. - pub fn initialise_block(header: &System::Header) { - Self::initialise_block_impl(header.number(), header.parent_hash(), header.extrinsics_root()); + pub fn initialize_block(header: &System::Header) { + Self::initialize_block_impl(header.number(), header.parent_hash(), header.extrinsics_root()); } - fn initialise_block_impl(block_number: &System::BlockNumber, parent_hash: &System::Hash, extrinsics_root: &System::Hash) { - >::initialise(block_number, parent_hash, extrinsics_root); - >::on_initialise(*block_number); + fn initialize_block_impl(block_number: &System::BlockNumber, parent_hash: &System::Hash, extrinsics_root: &System::Hash) { + >::initialize(block_number, parent_hash, extrinsics_root); + >::on_initialize(*block_number); } fn initial_checks(block: &Block) { @@ -121,7 +121,7 @@ impl< /// Actually execute all transitioning for `block`. pub fn execute_block(block: Block) { - Self::initialise_block(block.header()); + Self::initialize_block(block.header()); // any initial checks Self::initial_checks(&block); @@ -140,7 +140,7 @@ impl< let parent_hash = ::Hashing::hash(b"parent_hash"); let extrinsics_root = ::Hashing::hash(b"extrinsics_root"); - Self::initialise_block_impl(&block_number, &parent_hash, &extrinsics_root); + Self::initialize_block_impl(&block_number, &parent_hash, &extrinsics_root); // execute extrinsics Self::execute_extrinsics_with_book_keeping(extrinsics, block_number); @@ -152,18 +152,18 @@ impl< // post-extrinsics book-keeping. >::note_finished_extrinsics(); - >::on_finalise(block_number); + >::on_finalize(block_number); } - /// Finalise the block - it is up the caller to ensure that all header fields are valid + /// Finalize the block - it is up the caller to ensure that all header fields are valid /// except state-root. - pub fn finalise_block() -> System::Header { + pub fn finalize_block() -> System::Header { >::note_finished_extrinsics(); - >::on_finalise(>::block_number()); + >::on_finalize(>::block_number()); // setup extrinsics >::derive_extrinsics(); - >::finalise() + >::finalize() } /// Apply extrinsic outside of the block execution function. @@ -241,7 +241,7 @@ impl< fn final_checks(header: &System::Header) { // remove temporaries. - let new_header = >::finalise(); + let new_header = >::finalize(); // check digest. assert_eq!( @@ -394,7 +394,7 @@ mod tests { let xt = primitives::testing::TestXt(Some(1), 0, Call::transfer(2, 69)); let mut t = runtime_io::TestExternalities::::new(t); with_externalities(&mut t, || { - Executive::initialise_block(&Header::new(1, H256::default(), H256::default(), + Executive::initialize_block(&Header::new(1, H256::default(), H256::default(), [69u8; 32].into(), Digest::default())); Executive::apply_extrinsic(xt).unwrap(); assert_eq!(>::total_balance(&1), 32); @@ -463,7 +463,7 @@ mod tests { let mut t = new_test_ext(); let xt = primitives::testing::TestXt(Some(1), 42, Call::transfer(33, 69)); with_externalities(&mut t, || { - Executive::initialise_block(&Header::new(1, H256::default(), H256::default(), [69u8; 32].into(), Digest::default())); + Executive::initialize_block(&Header::new(1, H256::default(), H256::default(), [69u8; 32].into(), Digest::default())); assert!(Executive::apply_extrinsic(xt).is_err()); assert_eq!(>::extrinsic_index(), Some(0)); }); @@ -478,7 +478,7 @@ mod tests { let encoded = xt2.encode(); let len = if should_fail { (internal::MAX_TRANSACTIONS_SIZE - 1) as usize } else { encoded.len() }; with_externalities(&mut t, || { - Executive::initialise_block(&Header::new(1, H256::default(), H256::default(), [69u8; 32].into(), Digest::default())); + Executive::initialize_block(&Header::new(1, H256::default(), H256::default(), [69u8; 32].into(), Digest::default())); assert_eq!(>::all_extrinsics_len(), 0); Executive::apply_extrinsic(xt).unwrap(); diff --git a/srml/finality-tracker/src/lib.rs b/srml/finality-tracker/src/lib.rs index 5f417881f7482..34be4ea66a590 100644 --- a/srml/finality-tracker/src/lib.rs +++ b/srml/finality-tracker/src/lib.rs @@ -126,7 +126,7 @@ decl_module! { ::Update::put(hint); } - fn on_finalise() { + fn on_finalize() { Self::update_hint(::Update::take()) } } @@ -262,7 +262,7 @@ mod tests { use sr_io::{with_externalities, TestExternalities}; use substrate_primitives::H256; use primitives::BuildStorage; - use primitives::traits::{BlakeTwo256, IdentityLookup, OnFinalise, Header as HeaderT}; + use primitives::traits::{BlakeTwo256, IdentityLookup, OnFinalize, Header as HeaderT}; use primitives::testing::{Digest, DigestItem, Header}; use srml_support::impl_outer_origin; use srml_system as system; @@ -344,9 +344,9 @@ mod tests { with_externalities(&mut TestExternalities::new(t), || { let mut parent_hash = System::parent_hash(); for i in 2..106 { - System::initialise(&i, &parent_hash, &Default::default()); - FinalityTracker::on_finalise(i); - let hdr = System::finalise(); + System::initialize(&i, &parent_hash, &Default::default()); + FinalityTracker::on_finalize(i); + let hdr = System::finalize(); parent_hash = hdr.hash(); } @@ -369,13 +369,13 @@ mod tests { with_externalities(&mut TestExternalities::new(t), || { let mut parent_hash = System::parent_hash(); for i in 2..106 { - System::initialise(&i, &parent_hash, &Default::default()); + System::initialize(&i, &parent_hash, &Default::default()); assert_ok!(FinalityTracker::dispatch( Call::final_hint(i-1), Origin::INHERENT, )); - FinalityTracker::on_finalise(i); - let hdr = System::finalise(); + FinalityTracker::on_finalize(i); + let hdr = System::finalize(); parent_hash = hdr.hash(); } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 3c85756e96ba6..e9b00662d6e52 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -73,7 +73,7 @@ pub trait GrandpaChangeSignal { #[cfg_attr(feature = "std", derive(Serialize, Debug))] #[derive(Encode, Decode, PartialEq, Eq, Clone)] pub enum RawLog { - /// Authorities set change has been signalled. Contains the new set of authorities + /// Authorities set change has been signaled. Contains the new set of authorities /// and the delay in blocks _to finalize_ before applying. AuthoritiesChangeSignal(N, Vec<(SessionKey, u64)>), /// A forced authorities set change. Contains in this order: the median last @@ -185,7 +185,7 @@ decl_event!( decl_storage! { trait Store for Module as GrandpaFinality { - // Pending change: (signalled at, scheduled change). + // Pending change: (signaled at, scheduled change). PendingChange get(pending_change): Option>; // next block number where we can force a change. NextForced get(next_forced): Option; @@ -215,13 +215,13 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; - /// Report some misbehaviour. + /// Report some misbehavior. fn report_misbehavior(origin, _report: Vec) { ensure_signed(origin)?; // FIXME: https://github.com/paritytech/substrate/issues/1112 } - fn on_finalise(block_number: T::BlockNumber) { + fn on_finalize(block_number: T::BlockNumber) { if let Some(pending_change) = >::get() { if block_number == pending_change.scheduled_at { if let Some(median) = pending_change.forced { @@ -268,7 +268,7 @@ impl Module { /// indicates the median last finalized block number and it should be used /// as the canon block when starting the new grandpa voter. /// - /// No change should be signalled while any change is pending. Returns + /// No change should be signaled while any change is pending. Returns /// an error if a change is already pending. pub fn schedule_change( next_authorities: Vec<(T::SessionKey, u64)>, diff --git a/srml/grandpa/src/tests.rs b/srml/grandpa/src/tests.rs index 37902cfb17d8c..3050b6a572e0d 100644 --- a/srml/grandpa/src/tests.rs +++ b/srml/grandpa/src/tests.rs @@ -18,7 +18,7 @@ #![cfg(test)] -use primitives::{testing, traits::OnFinalise}; +use primitives::{testing, traits::OnFinalize}; use primitives::traits::Header; use runtime_io::with_externalities; use crate::mock::{Grandpa, System, new_test_ext}; @@ -30,13 +30,13 @@ use super::*; #[test] fn authorities_change_logged() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); Grandpa::schedule_change(vec![(4, 1), (5, 1), (6, 1)], 0, None).unwrap(); System::note_finished_extrinsics(); - Grandpa::on_finalise(1); + Grandpa::on_finalize(1); - let header = System::finalise(); + let header = System::finalize(); assert_eq!(header.digest, testing::Digest { logs: vec![ RawLog::AuthoritiesChangeSignal(0, vec![(4, 1), (5, 1), (6, 1)]).into(), @@ -55,10 +55,10 @@ fn authorities_change_logged() { #[test] fn authorities_change_logged_after_delay() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); Grandpa::schedule_change(vec![(4, 1), (5, 1), (6, 1)], 1, None).unwrap(); - Grandpa::on_finalise(1); - let header = System::finalise(); + Grandpa::on_finalize(1); + let header = System::finalize(); assert_eq!(header.digest, testing::Digest { logs: vec![ RawLog::AuthoritiesChangeSignal(1, vec![(4, 1), (5, 1), (6, 1)]).into(), @@ -68,11 +68,11 @@ fn authorities_change_logged_after_delay() { // no change at this height. assert_eq!(System::events(), vec![]); - System::initialise(&2, &header.hash(), &Default::default()); + System::initialize(&2, &header.hash(), &Default::default()); System::note_finished_extrinsics(); - Grandpa::on_finalise(2); + Grandpa::on_finalize(2); - let _header = System::finalise(); + let _header = System::finalize(); assert_eq!(System::events(), vec![ EventRecord { phase: Phase::Finalization, @@ -85,27 +85,27 @@ fn authorities_change_logged_after_delay() { #[test] fn cannot_schedule_change_when_one_pending() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); Grandpa::schedule_change(vec![(4, 1), (5, 1), (6, 1)], 1, None).unwrap(); assert!(Grandpa::pending_change().is_some()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); - Grandpa::on_finalise(1); - let header = System::finalise(); + Grandpa::on_finalize(1); + let header = System::finalize(); - System::initialise(&2, &header.hash(), &Default::default()); + System::initialize(&2, &header.hash(), &Default::default()); assert!(Grandpa::pending_change().is_some()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); - Grandpa::on_finalise(2); - let header = System::finalise(); + Grandpa::on_finalize(2); + let header = System::finalize(); - System::initialise(&3, &header.hash(), &Default::default()); + System::initialize(&3, &header.hash(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_ok()); - Grandpa::on_finalise(3); - let _header = System::finalise(); + Grandpa::on_finalize(3); + let _header = System::finalize(); }); } @@ -128,7 +128,7 @@ fn new_decodes_from_old() { #[test] fn dispatch_forced_change() { with_externalities(&mut new_test_ext(vec![(1, 1), (2, 1), (3, 1)]), || { - System::initialise(&1, &Default::default(), &Default::default()); + System::initialize(&1, &Default::default(), &Default::default()); Grandpa::schedule_change( vec![(4, 1), (5, 1), (6, 1)], 5, @@ -138,60 +138,60 @@ fn dispatch_forced_change() { assert!(Grandpa::pending_change().is_some()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, Some(0)).is_err()); - Grandpa::on_finalise(1); - let mut header = System::finalise(); + Grandpa::on_finalize(1); + let mut header = System::finalize(); for i in 2..7 { - System::initialise(&i, &header.hash(), &Default::default()); + System::initialize(&i, &header.hash(), &Default::default()); assert!(Grandpa::pending_change().unwrap().forced.is_some()); assert_eq!(Grandpa::next_forced(), Some(11)); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, Some(0)).is_err()); - Grandpa::on_finalise(i); - header = System::finalise(); + Grandpa::on_finalize(i); + header = System::finalize(); } // change has been applied at the end of block 6. // add a normal change. { - System::initialise(&7, &header.hash(), &Default::default()); + System::initialize(&7, &header.hash(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert_eq!(Grandpa::grandpa_authorities(), vec![(4, 1), (5, 1), (6, 1)]); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_ok()); - Grandpa::on_finalise(7); - header = System::finalise(); + Grandpa::on_finalize(7); + header = System::finalize(); } // run the normal change. { - System::initialise(&8, &header.hash(), &Default::default()); + System::initialize(&8, &header.hash(), &Default::default()); assert!(Grandpa::pending_change().is_some()); assert_eq!(Grandpa::grandpa_authorities(), vec![(4, 1), (5, 1), (6, 1)]); assert!(Grandpa::schedule_change(vec![(5, 1)], 1, None).is_err()); - Grandpa::on_finalise(8); - header = System::finalise(); + Grandpa::on_finalize(8); + header = System::finalize(); } // normal change applied. but we can't apply a new forced change for some // time. for i in 9..11 { - System::initialise(&i, &header.hash(), &Default::default()); + System::initialize(&i, &header.hash(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert_eq!(Grandpa::grandpa_authorities(), vec![(5, 1)]); assert_eq!(Grandpa::next_forced(), Some(11)); assert!(Grandpa::schedule_change(vec![(5, 1), (6, 1)], 5, Some(0)).is_err()); - Grandpa::on_finalise(i); - header = System::finalise(); + Grandpa::on_finalize(i); + header = System::finalize(); } { - System::initialise(&11, &header.hash(), &Default::default()); + System::initialize(&11, &header.hash(), &Default::default()); assert!(Grandpa::pending_change().is_none()); assert!(Grandpa::schedule_change(vec![(5, 1), (6, 1), (7, 1)], 5, Some(0)).is_ok()); assert_eq!(Grandpa::next_forced(), Some(21)); - Grandpa::on_finalise(11); - header = System::finalise(); + Grandpa::on_finalize(11); + header = System::finalize(); } let _ = header; }); diff --git a/srml/session/src/lib.rs b/srml/session/src/lib.rs index 9143931b98f9b..3d07b53e2e444 100644 --- a/srml/session/src/lib.rs +++ b/srml/session/src/lib.rs @@ -78,7 +78,7 @@ decl_module! { Self::apply_force_new_session(apply_rewards) } - fn on_finalise(n: T::BlockNumber) { + fn on_finalize(n: T::BlockNumber) { Self::check_rotate_session(n); } } diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 21cc6cbf9dc50..018be8f5c8ca0 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -414,7 +414,7 @@ decl_storage! { /// The length of the bonding duration in blocks. pub BondingDuration get(bonding_duration) config(): T::BlockNumber = T::BlockNumber::sa(1000); - /// Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialise + /// Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize /// and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets. pub Invulnerables get(invulnerables) config(): Vec; @@ -915,7 +915,7 @@ impl Module { Self::slashable_balance_of, min_validator_count, ElectionConfig::> { - equalise: false, + equalize: false, tolerance: >::sa(10 as u64), iterations: 10, } @@ -960,7 +960,7 @@ impl Module { } /// Call when a validator is determined to be offline. `count` is the - /// number of offences the validator has committed. + /// number of offenses the validator has committed. /// /// NOTE: This is called with the controller (not the stash) account id. pub fn on_offline_validator(controller: T::AccountId, count: usize) { diff --git a/srml/staking/src/phragmen.rs b/srml/staking/src/phragmen.rs index 9c388e5184af9..8d59562f69c26 100644 --- a/srml/staking/src/phragmen.rs +++ b/srml/staking/src/phragmen.rs @@ -26,11 +26,11 @@ use crate::{Exposure, BalanceOf, Trait, ValidatorPrefs, IndividualExposure}; /// Configure the behavior of the Phragmen election. /// Might be deprecated. pub struct ElectionConfig { - /// Perform equalise?. - pub equalise: bool, - /// Number of equalise iterations. + /// Perform equalize?. + pub equalize: bool, + /// Number of equalize iterations. pub iterations: usize, - /// Tolerance of max change per equalise iteration. + /// Tolerance of max change per equalize iteration. pub tolerance: Balance, } @@ -48,7 +48,7 @@ pub struct Candidate { approval_stake: Balance, /// Flag for being elected. elected: bool, - /// This is most often equal to `Exposure.total` but not always. Needed for [`equalise`] + /// This is most often equal to `Exposure.total` but not always. Needed for [`equalize`] backing_stake: Balance } @@ -78,9 +78,9 @@ pub struct Edge { backing_stake: Balance, /// Index of the candidate stored in the 'candidates' vector candidate_index: usize, - /// Index of the candidate stored in the 'elected_candidates' vector. Used only with equalise. + /// Index of the candidate stored in the 'elected_candidates' vector. Used only with equalize. elected_idx: usize, - /// Indicates if this edge is a vote for an elected candidate. Used only with equalise. + /// Indicates if this edge is a vote for an elected candidate. Used only with equalize. elected: bool, } @@ -223,10 +223,10 @@ pub fn elect( } } - // Optionally perform equalise post-processing. - if config.equalise { + // Optionally perform equalize post-processing. + if config.equalize { let tolerance = config.tolerance; - let equalise_iterations = config.iterations; + let equalize_iterations = config.iterations; // Fix indexes nominators.iter_mut().for_each(|n| { @@ -237,10 +237,10 @@ pub fn elect( }); }); - for _i in 0..equalise_iterations { + for _i in 0..equalize_iterations { let mut max_diff = >::zero(); nominators.iter_mut().for_each(|mut n| { - let diff = equalise::(&mut n, &mut elected_candidates, tolerance); + let diff = equalize::(&mut n, &mut elected_candidates, tolerance); if diff > max_diff { max_diff = diff; } @@ -274,7 +274,7 @@ pub fn elect( Some(elected_candidates) } -pub fn equalise( +pub fn equalize( nominator: &mut Nominator>, elected_candidates: &mut Vec>>, tolerance: BalanceOf diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index e8716c13fb426..6f3d504c06c29 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1525,7 +1525,7 @@ fn phragmen_election_works_example_2() { Staking::slashable_balance_of, min_validator_count, ElectionConfig::> { - equalise: true, + equalize: true, tolerance: >::sa(10 as u64), iterations: 10, } @@ -1806,7 +1806,7 @@ fn bond_with_little_staked_value() { #[test] #[ignore] // Enable this once post-processing is on. -fn phragmen_linear_worse_case_equalise() { +fn phragmen_linear_worse_case_equalize() { with_externalities(&mut ExtBuilder::default() .nominate(false) .validator_pool(true) diff --git a/srml/support/src/dispatch.rs b/srml/support/src/dispatch.rs index c85415b25cf64..64ea5938c48c0 100644 --- a/srml/support/src/dispatch.rs +++ b/srml/support/src/dispatch.rs @@ -89,7 +89,7 @@ impl Parameter for T where T: Codec + Clone + Eq {} /// corresponding to a function of the module. This enum implements Callable and thus its values /// can be used as an extrinsic's payload. /// -/// The `on_initialise` and `on_finalise` functions are special, since it can either take no +/// The `on_initialize` and `on_finalize` functions are special, since it can either take no /// parameters, or one parameter, which has the runtime's block number type. /// /// ### Module with instances @@ -147,8 +147,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident {} - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* @@ -160,8 +160,8 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $vis fn deposit_event $(<$dpeg $(, $dpeg_instance)?>)* () = default; } - { $( $on_initialise )* } - { $( $on_finalise )* } + { $( $on_initialize )* } + { $( $on_finalize )* } { $( $offchain )* } [ $($t)* ] $($rest)* @@ -172,8 +172,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident {} - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* @@ -187,8 +187,8 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $vis fn deposit_event $(<$dpeg $(, $dpeg_instance)?>)* ($( $param_name: $param ),* ) { $( $impl )* } } - { $( $on_initialise )* } - { $( $on_finalise )* } + { $( $on_initialize )* } + { $( $on_finalize )* } { $( $offchain )* } [ $($t)* ] $($rest)* @@ -199,12 +199,12 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } + { $( $on_initialize:tt )* } {} { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* - fn on_finalise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } + fn on_finalize($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } $($rest:tt)* ) => { $crate::decl_module!(@normalize @@ -212,8 +212,8 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } - { $( $on_initialise )* } - { fn on_finalise( $( $param_name : $param ),* ) { $( $impl )* } } + { $( $on_initialize )* } + { fn on_finalize( $( $param_name : $param ),* ) { $( $impl )* } } { $( $offchain )* } [ $($t)* ] $($rest)* @@ -225,11 +225,11 @@ macro_rules! decl_module { for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } {} - { $( $on_finalise:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* - fn on_initialise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } + fn on_initialize($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } $($rest:tt)* ) => { $crate::decl_module!(@normalize @@ -237,8 +237,8 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } - { fn on_initialise( $( $param_name : $param ),* ) { $( $impl )* } } - { $( $on_finalise )* } + { fn on_initialize( $( $param_name : $param ),* ) { $( $impl )* } } + { $( $on_finalize )* } { $( $offchain )* } [ $($t)* ] $($rest)* @@ -249,8 +249,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* @@ -262,8 +262,8 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } - { $( $on_initialise )* } - { $( $on_finalise )* } + { $( $on_initialize )* } + { $( $on_finalize )* } { fn offchain_worker( $( $param_name : $param ),* ) { $( $impl )* } } [ $($t)* ] $($rest)* @@ -274,8 +274,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* @@ -289,8 +289,8 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name$(, $instance: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } - { $( $on_initialise )* } - { $( $on_finalise )* } + { $( $on_initialize )* } + { $( $on_finalize )* } { $( $offchain )* } [ $($t)* @@ -308,8 +308,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* @@ -329,8 +329,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* @@ -350,8 +350,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* @@ -365,8 +365,8 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name$(, $instance: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } - { $( $on_initialise )* } - { $( $on_finalise )* } + { $( $on_initialize )* } + { $( $on_finalize )* } { $( $offchain )* } [ $($t)* @@ -384,8 +384,8 @@ macro_rules! decl_module { pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } [ $($t:tt)* ] ) => { @@ -396,8 +396,8 @@ macro_rules! decl_module { $($t)* } { $( $deposit_event )* } - { $( $on_initialise )* } - { $( $on_finalise )* } + { $( $on_initialize )* } + { $( $on_finalize )* } { $( $offchain )* } ); }; @@ -453,68 +453,68 @@ macro_rules! decl_module { } }; - (@impl_on_initialise + (@impl_on_initialize $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; - fn on_initialise() { $( $impl:tt )* } + fn on_initialize() { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::runtime_primitives::traits::OnInitialise<$trait_instance::BlockNumber> + $crate::runtime_primitives::traits::OnInitialize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> { - fn on_initialise(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } + fn on_initialize(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } } }; - (@impl_on_initialise + (@impl_on_initialize $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; - fn on_initialise($param:ident : $param_ty:ty) { $( $impl:tt )* } + fn on_initialize($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::runtime_primitives::traits::OnInitialise<$trait_instance::BlockNumber> + $crate::runtime_primitives::traits::OnInitialize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> { - fn on_initialise($param: $param_ty) { $( $impl )* } + fn on_initialize($param: $param_ty) { $( $impl )* } } }; - (@impl_on_initialise + (@impl_on_initialize $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::runtime_primitives::traits::OnInitialise<$trait_instance::BlockNumber> + $crate::runtime_primitives::traits::OnInitialize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> {} }; - (@impl_on_finalise + (@impl_on_finalize $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; - fn on_finalise() { $( $impl:tt )* } + fn on_finalize() { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::runtime_primitives::traits::OnFinalise<$trait_instance::BlockNumber> + $crate::runtime_primitives::traits::OnFinalize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> { - fn on_finalise(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } + fn on_finalize(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } } }; - (@impl_on_finalise + (@impl_on_finalize $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; - fn on_finalise($param:ident : $param_ty:ty) { $( $impl:tt )* } + fn on_finalize($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::runtime_primitives::traits::OnFinalise<$trait_instance::BlockNumber> + $crate::runtime_primitives::traits::OnFinalize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> { - fn on_finalise($param: $param_ty) { $( $impl )* } + fn on_finalize($param: $param_ty) { $( $impl )* } } }; - (@impl_on_finalise + (@impl_on_finalize $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::runtime_primitives::traits::OnFinalise<$trait_instance::BlockNumber> + $crate::runtime_primitives::traits::OnFinalize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> { } @@ -630,8 +630,8 @@ macro_rules! decl_module { )* } { $( $deposit_event:tt )* } - { $( $on_initialise:tt )* } - { $( $on_finalise:tt )* } + { $( $on_initialize:tt )* } + { $( $on_finalize:tt )* } { $( $offchain:tt )* } ) => { // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. @@ -650,15 +650,15 @@ macro_rules! decl_module { pub struct $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable $( = $module_default_instance)?)?>(::core::marker::PhantomData<($trait_instance $(, $instance)?)>); $crate::decl_module! { - @impl_on_initialise + @impl_on_initialize $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; - $( $on_initialise )* + $( $on_initialize )* } $crate::decl_module! { - @impl_on_finalise + @impl_on_finalize $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; - $( $on_finalise )* + $( $on_finalize )* } $crate::decl_module! { @@ -1143,7 +1143,7 @@ macro_rules! __function_to_metadata { #[allow(dead_code)] mod tests { use super::*; - use crate::runtime_primitives::traits::{OnInitialise, OnFinalise}; + use crate::runtime_primitives::traits::{OnInitialize, OnFinalize}; pub trait Trait { type Origin; @@ -1167,8 +1167,8 @@ mod tests { fn aux_3() -> Result { unreachable!() } fn aux_4(_data: i32) -> Result { unreachable!() } - fn on_initialise(n: T::BlockNumber) { if n.into() == 42 { panic!("on_initialise") } } - fn on_finalise(n: T::BlockNumber) { if n.into() == 42 { panic!("on_finalise") } } + fn on_initialize(n: T::BlockNumber) { if n.into() == 42 { panic!("on_initialize") } } + fn on_finalize(n: T::BlockNumber) { if n.into() == 42 { panic!("on_finalize") } } fn offchain_worker() {} } } @@ -1243,14 +1243,14 @@ mod tests { } #[test] - #[should_panic(expected = "on_initialise")] - fn on_initialise_should_work() { - as OnInitialise>::on_initialise(42); + #[should_panic(expected = "on_initialize")] + fn on_initialize_should_work() { + as OnInitialize>::on_initialize(42); } #[test] - #[should_panic(expected = "on_finalise")] - fn on_finalise_should_work() { - as OnFinalise>::on_finalise(42); + #[should_panic(expected = "on_finalize")] + fn on_finalize_should_work() { + as OnFinalize>::on_finalize(42); } } diff --git a/srml/support/src/lib.rs b/srml/support/src/lib.rs index cbbdcc7e4c186..d20af28f5b65d 100644 --- a/srml/support/src/lib.rs +++ b/srml/support/src/lib.rs @@ -193,7 +193,7 @@ mod tests { #[test] fn linked_map_basic_insert_remove_should_work() { with_externalities(&mut new_test_ext(), || { - // initialised during genesis + // initialized during genesis assert_eq!(Map::get(&15u32), 42u64); // get / insert / take @@ -272,7 +272,7 @@ mod tests { fn double_map_basic_insert_remove_remove_prefix_should_work() { with_externalities(&mut new_test_ext(), || { type DoubleMap = DataDM; - // initialised during genesis + // initialized during genesis assert_eq!(DoubleMap::get(&15u32, &16u32), 42u64); // get / insert / take diff --git a/srml/support/src/storage/generator.rs b/srml/support/src/storage/generator.rs index 18bc769d829da..97bfc6dc200ec 100644 --- a/srml/support/src/storage/generator.rs +++ b/srml/support/src/storage/generator.rs @@ -227,7 +227,7 @@ pub trait EnumerableStorageMap: StorageMap(storage: &'a S) -> Box + 'a> where K: 'a, V: 'a; } -// FIXME #1466 Remove this in favour of `decl_storage` macro. +// FIXME #1466 Remove this in favor of `decl_storage` macro. /// Declares strongly-typed wrappers around codec-compatible types in storage. #[macro_export] macro_rules! storage_items { diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index cf4dedbca63ad..f226fcb7d1855 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -380,7 +380,7 @@ impl Module { } /// Start the execution of a particular block. - pub fn initialise(number: &T::BlockNumber, parent_hash: &T::Hash, txs_root: &T::Hash) { + pub fn initialize(number: &T::BlockNumber, parent_hash: &T::Hash, txs_root: &T::Hash) { // populate environment. storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32); >::put(number); @@ -392,7 +392,7 @@ impl Module { } /// Remove temporary "environment" entries in storage. - pub fn finalise() -> T::Header { + pub fn finalize() -> T::Header { >::kill(); >::kill(); >::kill(); @@ -448,7 +448,7 @@ impl Module { } /// Set the block number to something in particular. Can be used as an alternative to - /// `initialise` for tests that don't need to bother with the other environment entries. + /// `initialize` for tests that don't need to bother with the other environment entries. #[cfg(any(feature = "std", test))] pub fn set_block_number(n: T::BlockNumber) { >::put(n); @@ -461,14 +461,14 @@ impl Module { } /// Set the parent hash number to something in particular. Can be used as an alternative to - /// `initialise` for tests that don't need to bother with the other environment entries. + /// `initialize` for tests that don't need to bother with the other environment entries. #[cfg(any(feature = "std", test))] pub fn set_parent_hash(n: T::Hash) { >::put(n); } /// Set the random seed to something in particular. Can be used as an alternative to - /// `initialise` for tests that don't need to bother with the other environment entries. + /// `initialize` for tests that don't need to bother with the other environment entries. #[cfg(any(feature = "std", test))] pub fn set_random_seed(seed: T::Hash) { >::put(seed); @@ -595,19 +595,19 @@ mod tests { #[test] fn deposit_event_should_work() { with_externalities(&mut new_test_ext(), || { - System::initialise(&1, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&1, &[0u8; 32].into(), &[0u8; 32].into()); System::note_finished_extrinsics(); System::deposit_event(1u16); - System::finalise(); + System::finalize(); assert_eq!(System::events(), vec![EventRecord { phase: Phase::Finalization, event: 1u16 }]); - System::initialise(&2, &[0u8; 32].into(), &[0u8; 32].into()); + System::initialize(&2, &[0u8; 32].into(), &[0u8; 32].into()); System::deposit_event(42u16); System::note_applied_extrinsic(&Ok(()), 0); System::note_applied_extrinsic(&Err(""), 0); System::note_finished_extrinsics(); System::deposit_event(3u16); - System::finalise(); + System::finalize(); assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), event: 42u16 }, EventRecord { phase: Phase::ApplyExtrinsic(0), event: 100u16 }, diff --git a/srml/timestamp/src/lib.rs b/srml/timestamp/src/lib.rs index 7511d5bf2fc0d..43cf669e7e701 100644 --- a/srml/timestamp/src/lib.rs +++ b/srml/timestamp/src/lib.rs @@ -229,7 +229,7 @@ decl_module! { // Manage upgrade. Remove after all networks upgraded. // TODO: #2133 - fn on_initialise() { + fn on_initialize() { if let Some(period) = >::take() { if !>::exists() { >::put(period) @@ -237,7 +237,7 @@ decl_module! { } } - fn on_finalise() { + fn on_finalize() { assert!(::DidUpdate::take(), "Timestamp must be updated once in the block"); } } diff --git a/srml/treasury/src/lib.rs b/srml/treasury/src/lib.rs index 6cb257f0344e3..b96928d7f8a85 100644 --- a/srml/treasury/src/lib.rs +++ b/srml/treasury/src/lib.rs @@ -117,7 +117,7 @@ decl_module! { >::mutate(|v| v.push(proposal_id)); } - fn on_finalise(n: T::BlockNumber) { + fn on_finalize(n: T::BlockNumber) { // Check to see if we should spend some funds! if (n % Self::spend_period()).is_zero() { Self::spend_funds(); @@ -264,7 +264,7 @@ mod tests { use srml_support::{impl_outer_origin, assert_ok, assert_noop}; use substrate_primitives::{H256, Blake2Hasher}; use runtime_primitives::BuildStorage; - use runtime_primitives::traits::{BlakeTwo256, OnFinalise, IdentityLookup}; + use runtime_primitives::traits::{BlakeTwo256, OnFinalize, IdentityLookup}; use runtime_primitives::testing::{Digest, DigestItem, Header}; impl_outer_origin! { @@ -380,7 +380,7 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3)); assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0)); - >::on_finalise(1); + >::on_finalize(1); assert_eq!(Balances::free_balance(&3), 0); assert_eq!(Treasury::pot(), 100); }); @@ -391,7 +391,7 @@ mod tests { with_externalities(&mut new_test_ext(), || { Treasury::on_dilution(100, 100); - >::on_finalise(2); + >::on_finalize(2); assert_eq!(Treasury::pot(), 50); }); } @@ -404,7 +404,7 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3)); assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0)); - >::on_finalise(2); + >::on_finalize(2); assert_eq!(Balances::free_balance(&3), 0); assert_eq!(Treasury::pot(), 50); }); @@ -454,7 +454,7 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3)); assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0)); - >::on_finalise(2); + >::on_finalize(2); assert_eq!(Balances::free_balance(&3), 100); assert_eq!(Treasury::pot(), 0); }); @@ -468,11 +468,11 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 150, 3)); assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0)); - >::on_finalise(2); + >::on_finalize(2); assert_eq!(Treasury::pot(), 100); Treasury::on_dilution(100, 100); - >::on_finalise(4); + >::on_finalize(4); assert_eq!(Balances::free_balance(&3), 150); assert_eq!(Treasury::pot(), 25); });