mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 22:01:04 +00:00
Convert all UK spelling to US (#2138)
* all the ise * forgot a misspelling * a few more replacements * bump impl * rollback and fixes * bump impl again * Add aliases for RPC * Update on_demand.rs
This commit is contained in:
@@ -177,7 +177,7 @@ impl<Block, C, A> consensus_common::Proposer<<C as AuthoringApi>::Block> for Pro
|
||||
fn propose(&self, inherent_data: InherentData, max_duration: time::Duration)
|
||||
-> Result<<C as AuthoringApi>::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<Block, C, A> Proposer<Block, C, A> 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(
|
||||
|
||||
@@ -28,7 +28,7 @@ decl_runtime_apis! {
|
||||
/// Apply the given extrinsics.
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyResult;
|
||||
/// Finish the current block.
|
||||
fn finalise_block() -> <Block as BlockT>::Header;
|
||||
fn finalize_block() -> <Block as BlockT>::Header;
|
||||
/// Generate inherent extrinsics. The inherent data will vary from chain to chain.
|
||||
fn inherent_extrinsics(inherent: InherentData) -> Vec<<Block as BlockT>::Extrinsic>;
|
||||
/// Check that the inherents are valid. The inherent data will vary from chain to chain.
|
||||
|
||||
@@ -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<Block> {
|
||||
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(),
|
||||
|
||||
@@ -73,7 +73,7 @@ where
|
||||
method: &str,
|
||||
call_data: &[u8],
|
||||
changes: &mut OverlayedChanges,
|
||||
initialised_block: &mut Option<BlockId<B>>,
|
||||
initialized_block: &mut Option<BlockId<B>>,
|
||||
prepare_environment_block: PB,
|
||||
execution_manager: ExecutionManager<EM>,
|
||||
native_call: Option<NC>,
|
||||
@@ -213,14 +213,14 @@ where
|
||||
method: &str,
|
||||
call_data: &[u8],
|
||||
changes: &mut OverlayedChanges,
|
||||
initialised_block: &mut Option<BlockId<Block>>,
|
||||
initialized_block: &mut Option<BlockId<Block>>,
|
||||
prepare_environment_block: PB,
|
||||
execution_manager: ExecutionManager<EM>,
|
||||
native_call: Option<NC>,
|
||||
mut side_effects_handler: Option<&mut O>,
|
||||
) -> Result<NativeOrEncoded<R>, error::Error> where ExecutionManager<EM>: 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)?;
|
||||
|
||||
@@ -285,7 +285,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> 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::<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<B, E, Block, RA> CallRuntimeAt<Block> for Client<B, E, Block, RA> where
|
||||
function: &'static str,
|
||||
args: Vec<u8>,
|
||||
changes: &mut OverlayedChanges,
|
||||
initialised_block: &mut Option<BlockId<Block>>,
|
||||
initialized_block: &mut Option<BlockId<Block>>,
|
||||
native_call: Option<NC>,
|
||||
context: ExecutionContext,
|
||||
) -> error::Result<NativeOrEncoded<R>> {
|
||||
@@ -1373,7 +1373,7 @@ impl<B, E, Block, RA> CallRuntimeAt<Block> for Client<B, E, Block, RA> 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!(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -118,14 +118,14 @@ where
|
||||
method: &str,
|
||||
call_data: &[u8],
|
||||
changes: &mut OverlayedChanges,
|
||||
initialised_block: &mut Option<BlockId<Block>>,
|
||||
initialized_block: &mut Option<BlockId<Block>>,
|
||||
_prepare_environment_block: PB,
|
||||
execution_manager: ExecutionManager<EM>,
|
||||
_native_call: Option<NC>,
|
||||
side_effects_handler: Option<&mut O>,
|
||||
) -> ClientResult<NativeOrEncoded<R>> where ExecutionManager<EM>: 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<Block, B, Remote, Local> CallExecutor<Block, Blake2Hasher> for
|
||||
method: &str,
|
||||
call_data: &[u8],
|
||||
changes: &mut OverlayedChanges,
|
||||
initialised_block: &mut Option<BlockId<Block>>,
|
||||
initialized_block: &mut Option<BlockId<Block>>,
|
||||
prepare_environment_block: PB,
|
||||
_manager: ExecutionManager<EM>,
|
||||
native_call: Option<NC>,
|
||||
@@ -270,7 +270,7 @@ impl<Block, B, Remote, Local> CallExecutor<Block, Blake2Hasher> for
|
||||
method,
|
||||
call_data,
|
||||
changes,
|
||||
initialised_block,
|
||||
initialized_block,
|
||||
prepare_environment_block,
|
||||
ExecutionManager::NativeWhenPossible,
|
||||
native_call,
|
||||
@@ -291,7 +291,7 @@ impl<Block, B, Remote, Local> CallExecutor<Block, Blake2Hasher> for
|
||||
method,
|
||||
call_data,
|
||||
changes,
|
||||
initialised_block,
|
||||
initialized_block,
|
||||
prepare_environment_block,
|
||||
ExecutionManager::NativeWhenPossible,
|
||||
native_call,
|
||||
@@ -388,7 +388,7 @@ pub fn prove_execution<Block, S, E>(
|
||||
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<Header, E, H>(
|
||||
&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);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ pub trait CallRuntimeAt<Block: BlockT> {
|
||||
function: &'static str,
|
||||
args: Vec<u8>,
|
||||
changes: &mut OverlayedChanges,
|
||||
initialised_block: &mut Option<BlockId<Block>>,
|
||||
initialized_block: &mut Option<BlockId<Block>>,
|
||||
native_call: Option<NC>,
|
||||
context: ExecutionContext,
|
||||
) -> error::Result<NativeOrEncoded<R>>;
|
||||
@@ -121,8 +121,8 @@ decl_runtime_apis! {
|
||||
fn authorities() -> Vec<AuthorityIdFor<Block>>;
|
||||
/// Execute the given block.
|
||||
fn execute_block(block: Block);
|
||||
/// Initialise a block with the given header.
|
||||
fn initialise_block(header: &<Block as BlockT>::Header);
|
||||
/// Initialize a block with the given header.
|
||||
fn initialize_block(header: &<Block as BlockT>::Header);
|
||||
}
|
||||
|
||||
/// The `Metadata` api trait that returns metadata for the runtime.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
///
|
||||
|
||||
@@ -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<N> {
|
||||
/// 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!(),
|
||||
|
||||
@@ -125,7 +125,7 @@ impl<Block: BlockT<Hash=H256>, B, E, N, RA> grandpa::Chain<Block::Hash, NumberFo
|
||||
|
||||
fn best_chain_containing(&self, block: Block::Hash) -> Option<(Block::Hash, NumberFor<Block>)> {
|
||||
// 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 {
|
||||
|
||||
@@ -570,7 +570,7 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, PRA> GrandpaBlockImport<B, E, Block, RA
|
||||
match result {
|
||||
Err(CommandOrError::VoterCommand(command)) => {
|
||||
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());
|
||||
|
||||
@@ -297,7 +297,7 @@ impl Core<Block> for RuntimeApi {
|
||||
unimplemented!("Not required for testing!")
|
||||
}
|
||||
|
||||
fn initialise_block_runtime_api_impl(
|
||||
fn initialize_block_runtime_api_impl(
|
||||
&self,
|
||||
_: &BlockId<Block>,
|
||||
_: ExecutionContext,
|
||||
|
||||
@@ -66,7 +66,7 @@ pub type BlockResponse<B> = generic::BlockResponse<
|
||||
/// A set of transactions.
|
||||
pub type Transactions<E> = Vec<E>;
|
||||
|
||||
/// 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 {
|
||||
|
||||
@@ -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<T: OffchainExt + ?Sized> OffchainExt for Box<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Hex-serialised shim for `Vec<u8>`.
|
||||
/// Hex-serialized shim for `Vec<u8>`.
|
||||
#[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<u8>);
|
||||
|
||||
@@ -57,9 +57,9 @@ pub trait ChainApi<Number, Hash, Header, SignedBlock> {
|
||||
#[rpc(name = "chain_getBlockHash", alias("chain_getHead"))]
|
||||
fn block_hash(&self, hash: Option<number::NumberOrHex<Number>>) -> Result<Option<Hash>>;
|
||||
|
||||
/// Get hash of the last finalised block in the canon chain.
|
||||
#[rpc(name = "chain_getFinalisedHead")]
|
||||
fn finalised_head(&self) -> Result<Hash>;
|
||||
/// Get hash of the last finalized block in the canon chain.
|
||||
#[rpc(name = "chain_getFinalizedHead", alias("chain_getFinalisedHead"))]
|
||||
fn finalized_head(&self) -> Result<Hash>;
|
||||
|
||||
/// New head subscription
|
||||
#[pubsub(
|
||||
@@ -81,19 +81,21 @@ pub trait ChainApi<Number, Hash, Header, SignedBlock> {
|
||||
|
||||
/// 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<Header>);
|
||||
fn subscribe_finalized_heads(&self, metadata: Self::Metadata, subscriber: Subscriber<Header>);
|
||||
|
||||
/// 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<Self::Metadata>, id: SubscriptionId) -> RpcResult<bool>;
|
||||
fn unsubscribe_finalized_heads(&self, metadata: Option<Self::Metadata>, id: SubscriptionId) -> RpcResult<bool>;
|
||||
}
|
||||
|
||||
/// Chain API with subscriptions support.
|
||||
@@ -192,7 +194,7 @@ impl<B, E, Block, RA> ChainApi<NumberFor<Block>, Block::Hash, Block::Header, Sig
|
||||
})
|
||||
}
|
||||
|
||||
fn finalised_head(&self) -> Result<Block::Hash> {
|
||||
fn finalized_head(&self) -> Result<Block::Hash> {
|
||||
Ok(self.client.info()?.chain.finalized_hash)
|
||||
}
|
||||
|
||||
@@ -210,7 +212,7 @@ impl<B, E, Block, RA> ChainApi<NumberFor<Block>, Block::Hash, Block::Header, Sig
|
||||
Ok(self.subscriptions.cancel(id))
|
||||
}
|
||||
|
||||
fn subscribe_finalised_heads(&self, _meta: Self::Metadata, subscriber: Subscriber<Block::Header>) {
|
||||
fn subscribe_finalized_heads(&self, _meta: Self::Metadata, subscriber: Subscriber<Block::Header>) {
|
||||
self.subscribe_headers(
|
||||
subscriber,
|
||||
|| Ok(Some(self.client.info()?.chain.finalized_hash)),
|
||||
@@ -219,7 +221,7 @@ impl<B, E, Block, RA> ChainApi<NumberFor<Block>, Block::Hash, Block::Header, Sig
|
||||
)
|
||||
}
|
||||
|
||||
fn unsubscribe_finalised_heads(&self, _metadata: Option<Self::Metadata>, id: SubscriptionId) -> RpcResult<bool> {
|
||||
fn unsubscribe_finalized_heads(&self, _metadata: Option<Self::Metadata>, id: SubscriptionId) -> RpcResult<bool> {
|
||||
Ok(self.subscriptions.cancel(id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -271,7 +271,7 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result<TokenStrea
|
||||
pub struct RuntimeApiImpl<C: #crate_::runtime_api::CallRuntimeAt<#block> + 'static> {
|
||||
call: &'static C,
|
||||
commit_on_success: ::std::cell::RefCell<bool>,
|
||||
initialised_block: ::std::cell::RefCell<Option<#block_id>>,
|
||||
initialized_block: ::std::cell::RefCell<Option<#block_id>>,
|
||||
changes: ::std::cell::RefCell<#crate_::runtime_api::OverlayedChanges>,
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result<TokenStrea
|
||||
RuntimeApiImpl {
|
||||
call: unsafe { ::std::mem::transmute(call) },
|
||||
commit_on_success: true.into(),
|
||||
initialised_block: None.into(),
|
||||
initialized_block: None.into(),
|
||||
changes: Default::default(),
|
||||
}.into()
|
||||
}
|
||||
@@ -345,7 +345,7 @@ fn generate_runtime_api_base_structures(impls: &[ItemImpl]) -> Result<TokenStrea
|
||||
function,
|
||||
args,
|
||||
&mut *self.changes.borrow_mut(),
|
||||
&mut *self.initialised_block.borrow_mut(),
|
||||
&mut *self.initialized_block.borrow_mut(),
|
||||
native_call,
|
||||
context
|
||||
)
|
||||
|
||||
@@ -74,7 +74,7 @@ impl_runtime_apis! {
|
||||
fn execute_block(_: Block) {
|
||||
unimplemented!()
|
||||
}
|
||||
fn initialise_block(_: &<Block as BlockT>::Header) {
|
||||
fn initialize_block(_: &<Block as BlockT>::Header) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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::<Vec<_>>();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -252,23 +252,23 @@ impl<T:
|
||||
rstd::ops::BitAnd<Self, Output = Self>
|
||||
> 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<BlockNumber> {
|
||||
/// The block is being finalised. Implement to have something happen.
|
||||
fn on_finalise(_n: BlockNumber) {}
|
||||
pub trait OnFinalize<BlockNumber> {
|
||||
/// The block is being finalized. Implement to have something happen.
|
||||
fn on_finalize(_n: BlockNumber) {}
|
||||
}
|
||||
|
||||
impl<N> OnFinalise<N> for () {}
|
||||
impl<N> OnFinalize<N> 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<BlockNumber> {
|
||||
/// The block is being initialised. Implement to have something happen.
|
||||
fn on_initialise(_n: BlockNumber) {}
|
||||
pub trait OnInitialize<BlockNumber> {
|
||||
/// The block is being initialized. Implement to have something happen.
|
||||
fn on_initialize(_n: BlockNumber) {}
|
||||
}
|
||||
|
||||
impl<N> OnInitialise<N> for () {}
|
||||
impl<N> OnInitialize<N> for () {}
|
||||
|
||||
/// Off-chain computation trait.
|
||||
///
|
||||
@@ -290,14 +290,14 @@ impl<N> OffchainWorker<N> for () {}
|
||||
|
||||
macro_rules! tuple_impl {
|
||||
($one:ident,) => {
|
||||
impl<Number: Copy, $one: OnFinalise<Number>> OnFinalise<Number> for ($one,) {
|
||||
fn on_finalise(n: Number) {
|
||||
$one::on_finalise(n);
|
||||
impl<Number: Copy, $one: OnFinalize<Number>> OnFinalize<Number> for ($one,) {
|
||||
fn on_finalize(n: Number) {
|
||||
$one::on_finalize(n);
|
||||
}
|
||||
}
|
||||
impl<Number: Copy, $one: OnInitialise<Number>> OnInitialise<Number> for ($one,) {
|
||||
fn on_initialise(n: Number) {
|
||||
$one::on_initialise(n);
|
||||
impl<Number: Copy, $one: OnInitialize<Number>> OnInitialize<Number> for ($one,) {
|
||||
fn on_initialize(n: Number) {
|
||||
$one::on_initialize(n);
|
||||
}
|
||||
}
|
||||
impl<Number: Copy, $one: OffchainWorker<Number>> OffchainWorker<Number> for ($one,) {
|
||||
@@ -309,22 +309,22 @@ macro_rules! tuple_impl {
|
||||
($first:ident, $($rest:ident,)+) => {
|
||||
impl<
|
||||
Number: Copy,
|
||||
$first: OnFinalise<Number>,
|
||||
$($rest: OnFinalise<Number>),+
|
||||
> OnFinalise<Number> for ($first, $($rest),+) {
|
||||
fn on_finalise(n: Number) {
|
||||
$first::on_finalise(n);
|
||||
$($rest::on_finalise(n);)+
|
||||
$first: OnFinalize<Number>,
|
||||
$($rest: OnFinalize<Number>),+
|
||||
> OnFinalize<Number> for ($first, $($rest),+) {
|
||||
fn on_finalize(n: Number) {
|
||||
$first::on_finalize(n);
|
||||
$($rest::on_finalize(n);)+
|
||||
}
|
||||
}
|
||||
impl<
|
||||
Number: Copy,
|
||||
$first: OnInitialise<Number>,
|
||||
$($rest: OnInitialise<Number>),+
|
||||
> OnInitialise<Number> for ($first, $($rest),+) {
|
||||
fn on_initialise(n: Number) {
|
||||
$first::on_initialise(n);
|
||||
$($rest::on_initialise(n);)+
|
||||
$first: OnInitialize<Number>,
|
||||
$($rest: OnInitialize<Number>),+
|
||||
> OnInitialize<Number> for ($first, $($rest),+) {
|
||||
fn on_initialize(n: Number) {
|
||||
$first::on_initialize(n);
|
||||
$($rest::on_initialize(n);)+
|
||||
}
|
||||
}
|
||||
impl<
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ impl<D: Drain> Drain for Multiply<D> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialise telemetry.
|
||||
/// Initialize telemetry.
|
||||
pub fn init_telemetry(config: TelemetryConfig) -> slog_scope::GlobalLoggerGuard {
|
||||
let mut endpoint_drains: Vec<Box<slog::Filter<_, _>>> = Vec::new();
|
||||
let mut out_syncs = Vec::new();
|
||||
|
||||
@@ -167,9 +167,9 @@ pub fn run_tests(mut input: &[u8]) -> Vec<u8> {
|
||||
|
||||
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::<Vec<_>>();
|
||||
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: &<Block as BlockT>::Header) {
|
||||
system::initialise_block(header)
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
system::initialize_block(header)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +319,8 @@ cfg_if! {
|
||||
system::execute_transaction(extrinsic)
|
||||
}
|
||||
|
||||
fn finalise_block() -> <Block as BlockT>::Header {
|
||||
system::finalise_block()
|
||||
fn finalize_block() -> <Block as BlockT>::Header {
|
||||
system::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(_data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
@@ -402,8 +402,8 @@ cfg_if! {
|
||||
system::execute_block(block)
|
||||
}
|
||||
|
||||
fn initialise_block(header: &<Block as BlockT>::Header) {
|
||||
system::initialise_block(header)
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
system::initialize_block(header)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,8 +424,8 @@ cfg_if! {
|
||||
system::execute_transaction(extrinsic)
|
||||
}
|
||||
|
||||
fn finalise_block() -> <Block as BlockT>::Header {
|
||||
system::finalise_block()
|
||||
fn finalize_block() -> <Block as BlockT>::Header {
|
||||
system::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(_data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn authorities() -> Vec<AuthorityId> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn initialise_block(header: &Header) {
|
||||
pub fn initialize_block(header: &Header) {
|
||||
// populate environment.
|
||||
<Number>::put(&header.number);
|
||||
<ParentHash>::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::<Vec<_>>();
|
||||
|
||||
BIN
Binary file not shown.
@@ -93,6 +93,6 @@ impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> {
|
||||
|
||||
/// 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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ pub enum Status<H, H2> {
|
||||
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<H, H2> Watcher<H, H2> {
|
||||
#[derive(Debug)]
|
||||
pub struct Sender<H, H2> {
|
||||
receivers: Vec<mpsc::UnboundedSender<Status<H, H2>>>,
|
||||
finalised: bool,
|
||||
finalized: bool,
|
||||
}
|
||||
|
||||
impl<H, H2> Default for Sender<H, H2> {
|
||||
fn default() -> Self {
|
||||
Sender {
|
||||
receivers: Default::default(),
|
||||
finalised: false,
|
||||
finalized: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,17 +108,17 @@ impl<H: Clone, H2: Clone> Sender<H, H2> {
|
||||
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<H: Clone, H2: Clone> Sender<H, H2> {
|
||||
}
|
||||
|
||||
|
||||
/// 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<H, H2>) {
|
||||
|
||||
@@ -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<u8>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user