mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 01:07:57 +00:00
Scale trait and move to u32 blocknumbers (#3357)
* Scale trait and move to u32 blocknumbers. * Fixes * Cleanups * Update node/runtime/src/lib.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Fix up some of the factory stuff. * Update core/sr-primitives/src/traits.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Move Nonce/Index to u32 (#3361) * Force a non-borked version of upstream crate * Line lengths and runtime version bump
This commit is contained in:
@@ -39,11 +39,11 @@ pub struct FactoryState<N> {
|
||||
block_no: N,
|
||||
|
||||
mode: Mode,
|
||||
start_number: u64,
|
||||
rounds: u64,
|
||||
round: u64,
|
||||
block_in_round: u64,
|
||||
num: u64,
|
||||
start_number: u32,
|
||||
rounds: u32,
|
||||
round: u32,
|
||||
block_in_round: u32,
|
||||
num: u32,
|
||||
}
|
||||
|
||||
type Number = <<node_primitives::Block as BlockT>::Header as HeaderT>::Number;
|
||||
@@ -77,9 +77,9 @@ impl RuntimeAdapter for FactoryState<Number> {
|
||||
) -> FactoryState<Self::Number> {
|
||||
FactoryState {
|
||||
mode,
|
||||
num: num,
|
||||
num: num as u32,
|
||||
round: 0,
|
||||
rounds,
|
||||
rounds: rounds as u32,
|
||||
block_in_round: 0,
|
||||
block_no: 0,
|
||||
start_number: 0,
|
||||
@@ -150,7 +150,7 @@ impl RuntimeAdapter for FactoryState<Number> {
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(&self) -> InherentData {
|
||||
let timestamp = self.block_no * MINIMUM_PERIOD;
|
||||
let timestamp = self.block_no as u64 * MINIMUM_PERIOD;
|
||||
|
||||
let mut inherent = InherentData::new();
|
||||
inherent.put_data(timestamp::INHERENT_IDENTIFIER, ×tamp)
|
||||
@@ -194,12 +194,12 @@ impl RuntimeAdapter for FactoryState<Number> {
|
||||
// This currently prevents the factory from being used
|
||||
// without a preceding purge of the database.
|
||||
if self.mode == Mode::MasterToN || self.mode == Mode::MasterTo1 {
|
||||
self.block_no()
|
||||
self.block_no() as Self::Index
|
||||
} else {
|
||||
match self.round() {
|
||||
0 =>
|
||||
// if round is 0 all transactions will be done with master as a sender
|
||||
self.block_no(),
|
||||
self.block_no() as Self::Index,
|
||||
_ =>
|
||||
// if round is e.g. 1 every sender account will be new and not yet have
|
||||
// any transactions done
|
||||
@@ -215,12 +215,12 @@ impl RuntimeAdapter for FactoryState<Number> {
|
||||
// TODO get correct phase via api. See #2587.
|
||||
// This currently prevents the factory from being used
|
||||
// without a preceding purge of the database.
|
||||
self.block_no
|
||||
self.block_no() as Self::Phase
|
||||
}
|
||||
}
|
||||
|
||||
fn gen_seed_bytes(seed: u64) -> [u8; 32] {
|
||||
let mut rng: StdRng = SeedableRng::seed_from_u64(seed);
|
||||
fn gen_seed_bytes(seed: u32) -> [u8; 32] {
|
||||
let mut rng: StdRng = SeedableRng::seed_from_u64(seed as u64);
|
||||
|
||||
let mut seed_bytes = [0u8; 32];
|
||||
for i in 0..32 {
|
||||
|
||||
@@ -88,19 +88,32 @@ construct_service_factory! {
|
||||
RuntimeApi = RuntimeApi,
|
||||
NetworkProtocol = NodeProtocol { |config| Ok(NodeProtocol::new()) },
|
||||
RuntimeDispatch = node_executor::Executor,
|
||||
FullTransactionPoolApi = transaction_pool::ChainApi<client::Client<FullBackend<Self>, FullExecutor<Self>, Block, RuntimeApi>, Block>
|
||||
{ |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) },
|
||||
LightTransactionPoolApi = transaction_pool::ChainApi<client::Client<LightBackend<Self>, LightExecutor<Self>, Block, RuntimeApi>, Block>
|
||||
{ |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) },
|
||||
FullTransactionPoolApi =
|
||||
transaction_pool::ChainApi<
|
||||
client::Client<FullBackend<Self>, FullExecutor<Self>, Block, RuntimeApi>,
|
||||
Block
|
||||
> {
|
||||
|config, client|
|
||||
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
|
||||
},
|
||||
LightTransactionPoolApi =
|
||||
transaction_pool::ChainApi<
|
||||
client::Client<LightBackend<Self>, LightExecutor<Self>, Block, RuntimeApi>,
|
||||
Block
|
||||
> {
|
||||
|config, client|
|
||||
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
|
||||
},
|
||||
Genesis = GenesisConfig,
|
||||
Configuration = NodeConfig<Self>,
|
||||
FullService = FullComponents<Self>
|
||||
{ |config: FactoryFullConfiguration<Self>|
|
||||
FullComponents::<Factory>::new(config) },
|
||||
FullService = FullComponents<Self> {
|
||||
|config: FactoryFullConfiguration<Self>| FullComponents::<Factory>::new(config)
|
||||
},
|
||||
AuthoritySetup = {
|
||||
|mut service: Self::FullService| {
|
||||
let (block_import, link_half, babe_link) = service.config_mut().custom.import_setup.take()
|
||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||
let (block_import, link_half, babe_link) =
|
||||
service.config_mut().custom.import_setup.take()
|
||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||
|
||||
// spawn any futures that were created in the previous setup steps
|
||||
if let Some(tasks) = service.config_mut().custom.tasks_to_spawn.take() {
|
||||
@@ -120,7 +133,8 @@ construct_service_factory! {
|
||||
};
|
||||
|
||||
let client = service.client();
|
||||
let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?;
|
||||
let select_chain = service.select_chain()
|
||||
.ok_or(ServiceError::SelectChainRequired)?;
|
||||
|
||||
let babe_config = babe::BabeParams {
|
||||
config: Config::get_or_compute(&*client)?,
|
||||
@@ -130,7 +144,8 @@ construct_service_factory! {
|
||||
block_import,
|
||||
env: proposer,
|
||||
sync_oracle: service.network(),
|
||||
inherent_data_providers: service.config().custom.inherent_data_providers.clone(),
|
||||
inherent_data_providers: service.config()
|
||||
.custom.inherent_data_providers.clone(),
|
||||
force_authoring: service.config().force_authoring,
|
||||
time_source: babe_link,
|
||||
};
|
||||
@@ -167,7 +182,8 @@ construct_service_factory! {
|
||||
config: config,
|
||||
link: link_half,
|
||||
network: service.network(),
|
||||
inherent_data_providers: service.config().custom.inherent_data_providers.clone(),
|
||||
inherent_data_providers:
|
||||
service.config().custom.inherent_data_providers.clone(),
|
||||
on_exit: service.on_exit(),
|
||||
telemetry_on_connect: Some(telemetry_on_connect),
|
||||
};
|
||||
@@ -187,8 +203,12 @@ construct_service_factory! {
|
||||
},
|
||||
LightService = LightComponents<Self>
|
||||
{ |config| <LightComponents<Factory>>::new(config) },
|
||||
FullImportQueue = BabeImportQueue<Self::Block>
|
||||
{ |config: &mut FactoryFullConfiguration<Self> , client: Arc<FullClient<Self>>, select_chain: Self::SelectChain| {
|
||||
FullImportQueue = BabeImportQueue<Self::Block> {
|
||||
|
|
||||
config: &mut FactoryFullConfiguration<Self>,
|
||||
client: Arc<FullClient<Self>>,
|
||||
select_chain: Self::SelectChain
|
||||
| {
|
||||
let (block_import, link_half) =
|
||||
grandpa::block_import::<_, _, _, RuntimeApi, FullClient<Self>, _>(
|
||||
client.clone(), client.clone(), select_chain
|
||||
@@ -222,7 +242,8 @@ construct_service_factory! {
|
||||
)?;
|
||||
|
||||
let finality_proof_import = block_import.clone();
|
||||
let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
|
||||
let (import_queue, ..) = import_queue(
|
||||
@@ -254,7 +275,9 @@ construct_service_factory! {
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use babe::CompatibleDigestItem;
|
||||
use consensus_common::{Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy};
|
||||
use consensus_common::{
|
||||
Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy
|
||||
};
|
||||
use node_primitives::DigestItem;
|
||||
use node_runtime::{BalancesCall, Call, UncheckedExtrinsic};
|
||||
use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION};
|
||||
@@ -306,7 +329,9 @@ mod tests {
|
||||
auxiliary: Vec::new(),
|
||||
}
|
||||
};
|
||||
let extrinsic_factory = |service: &SyncService<<Factory as service::ServiceFactory>::FullService>| {
|
||||
let extrinsic_factory =
|
||||
|service: &SyncService<<Factory as service::ServiceFactory>::FullService>|
|
||||
{
|
||||
let payload = (
|
||||
0,
|
||||
Call::Balances(BalancesCall::transfer(RawAddress::Id(bob.public().0.into()), 69.into())),
|
||||
@@ -333,7 +358,8 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_sync() {
|
||||
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
|
||||
let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
|
||||
let keystore = keystore::Store::open(keystore_path.path(), None)
|
||||
.expect("Creates keystore");
|
||||
let alice = keystore.write().insert_ephemeral_from_seed::<babe::AuthorityPair>("//Alice")
|
||||
.expect("Creates authority pair");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user