mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Update Cumulus for Parachains V1 (#224)
* Start with something * Whatever * Update * MOARE * Make cumulus-network compile and tests work * Update more and fixes * More stuff * More fixes * Make collator build * Make test almost work * Remove contracts runtime * More test work * Make service compile * Fix test-service * Fix test client * More fixes * Fix collator test * Fix network tests (again) * Make everything compile, finally * Fix tests * Update to latest masters * Remove ignore * Switch to different branch in polkadot for now * Update reference * Make it compile with latest changes * Update collator/src/lib.rs Co-authored-by: Robert Habermeier <rphmeier@gmail.com> * Update to latest upstream * Update to latest master * Fix test Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -15,34 +15,39 @@
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::Client;
|
||||
use cumulus_primitives::{
|
||||
inherents::VALIDATION_FUNCTION_PARAMS_IDENTIFIER,
|
||||
validation_function_params::ValidationFunctionParams,
|
||||
};
|
||||
use runtime::GetLastTimestamp;
|
||||
use cumulus_primitives::{inherents::VALIDATION_DATA_IDENTIFIER, ValidationData};
|
||||
use cumulus_test_runtime::GetLastTimestamp;
|
||||
use polkadot_primitives::v1::BlockNumber as PBlockNumber;
|
||||
use sc_block_builder::BlockBuilderApi;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_core::ExecutionContext;
|
||||
use sp_runtime::generic::BlockId;
|
||||
|
||||
/// Generate the inherents to a block so you don't have to.
|
||||
pub fn generate_block_inherents(client: &Client) -> Vec<runtime::UncheckedExtrinsic> {
|
||||
let mut inherent_data = sp_consensus::InherentData::new();
|
||||
/// Generate the inherents required by the test runtime.
|
||||
///
|
||||
/// - `validation_data`: The [`ValidationData`] that will be passed as inherent
|
||||
/// data into the runtime when building the inherents. If
|
||||
/// `None` is passed, the default value will be used.
|
||||
pub fn generate_block_inherents(
|
||||
client: &Client,
|
||||
validation_data: Option<ValidationData<PBlockNumber>>,
|
||||
) -> Vec<cumulus_test_runtime::UncheckedExtrinsic> {
|
||||
let mut inherent_data = sp_inherents::InherentData::new();
|
||||
let block_id = BlockId::Hash(client.info().best_hash);
|
||||
let last_timestamp = client
|
||||
.runtime_api()
|
||||
.get_last_timestamp(&block_id)
|
||||
.expect("Get last timestamp");
|
||||
let timestamp = last_timestamp + runtime::MinimumPeriod::get();
|
||||
let timestamp = last_timestamp + cumulus_test_runtime::MinimumPeriod::get();
|
||||
|
||||
inherent_data
|
||||
.put_data(sp_timestamp::INHERENT_IDENTIFIER, ×tamp)
|
||||
.expect("Put timestamp failed");
|
||||
inherent_data
|
||||
.put_data(
|
||||
VALIDATION_FUNCTION_PARAMS_IDENTIFIER,
|
||||
&ValidationFunctionParams::default(),
|
||||
VALIDATION_DATA_IDENTIFIER,
|
||||
&validation_data.unwrap_or_default(),
|
||||
)
|
||||
.expect("Put validation function params failed");
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ mod block_builder;
|
||||
pub use block_builder::*;
|
||||
|
||||
use codec::Encode;
|
||||
pub use runtime;
|
||||
pub use cumulus_test_runtime as runtime;
|
||||
use runtime::{
|
||||
Balance, Block, BlockHashCount, Call, GenesisConfig, Runtime, Signature, SignedExtra,
|
||||
SignedPayload, UncheckedExtrinsic, VERSION,
|
||||
@@ -35,14 +35,14 @@ use sp_runtime::{
|
||||
BuildStorage, SaturatedConversion,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
pub use test_client::*;
|
||||
pub use substrate_test_client::*;
|
||||
|
||||
mod local_executor {
|
||||
use test_client::sc_executor::native_executor_instance;
|
||||
use substrate_test_client::sc_executor::native_executor_instance;
|
||||
native_executor_instance!(
|
||||
pub LocalExecutor,
|
||||
runtime::api::dispatch,
|
||||
runtime::native_version,
|
||||
cumulus_test_runtime::api::dispatch,
|
||||
cumulus_test_runtime::native_version,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ mod local_executor {
|
||||
pub use local_executor::LocalExecutor;
|
||||
|
||||
/// Test client database backend.
|
||||
pub type Backend = test_client::Backend<Block>;
|
||||
pub type Backend = substrate_test_client::Backend<Block>;
|
||||
|
||||
/// Test client executor.
|
||||
pub type Executor = client::LocalCallExecutor<Backend, sc_executor::NativeExecutor<LocalExecutor>>;
|
||||
|
||||
/// Test client builder for Cumulus
|
||||
pub type TestClientBuilder =
|
||||
test_client::TestClientBuilder<Block, Executor, Backend, GenesisParameters>;
|
||||
substrate_test_client::TestClientBuilder<Block, Executor, Backend, GenesisParameters>;
|
||||
|
||||
/// LongestChain type for the test runtime/client.
|
||||
pub type LongestChain = sc_consensus::LongestChain<Backend, Block>;
|
||||
@@ -71,7 +71,7 @@ pub struct GenesisParameters {
|
||||
support_changes_trie: bool,
|
||||
}
|
||||
|
||||
impl test_client::GenesisInit for GenesisParameters {
|
||||
impl substrate_test_client::GenesisInit for GenesisParameters {
|
||||
fn genesis_storage(&self) -> Storage {
|
||||
let changes_trie_config: Option<ChangesTrieConfiguration> = if self.support_changes_trie {
|
||||
Some(sp_test_primitives::changes_trie_config())
|
||||
|
||||
Reference in New Issue
Block a user