mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 16:51:03 +00:00
[big refactor] Remove crate aliasing. (#4395)
* Rename: Phase 1. * Unify codec. * Fixing: Phase 2 * Fixing: Phase 3. * Fixing: Phase 4. * Fixing: Phase 5. * Fixing: Phase 6. * Fixing: Phase 7. * Fixing: Phase 8. Tests * Fixing: Phase 9. Tests!!! * Fixing: Phase 10. Moar tests! * Finally done! * More fixes. * Rename primitives:: to sp_core:: * Apply renames in finality-grandpa. * Fix benches. * Fix benches 2. * Revert node-template. * Fix frame-system in our modules.
This commit is contained in:
committed by
Gavin Wood
parent
f14d98a439
commit
8778ca7dc8
@@ -7,11 +7,11 @@ edition = "2018"
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
sp-api-proc-macro = { path = "proc-macro" }
|
||||
primitives = { package = "sp-core", path = "../core", default-features = false }
|
||||
sp-core = { path = "../core", default-features = false }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
sp-runtime = { path = "../runtime", default-features = false }
|
||||
sp-version = { path = "../version", default-features = false }
|
||||
state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true }
|
||||
sp-state-machine = { path = "../../primitives/state-machine", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-test-primitives = { path = "../test-primitives" }
|
||||
@@ -20,9 +20,9 @@ sp-test-primitives = { path = "../test-primitives" }
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"sp-runtime/std",
|
||||
"state-machine",
|
||||
"sp-state-machine",
|
||||
"sp-version/std",
|
||||
]
|
||||
|
||||
@@ -35,13 +35,13 @@ extern crate self as sp_api;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "std")]
|
||||
pub use state_machine::{OverlayedChanges, StorageProof};
|
||||
pub use sp_state_machine::{OverlayedChanges, StorageProof};
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "std")]
|
||||
pub use primitives::NativeOrEncoded;
|
||||
pub use sp_core::NativeOrEncoded;
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use primitives::to_substrate_wasm_fn_return_value;
|
||||
pub use sp_core::to_substrate_wasm_fn_return_value;
|
||||
#[doc(hidden)]
|
||||
pub use sp_runtime::{
|
||||
traits::{
|
||||
@@ -51,7 +51,7 @@ pub use sp_runtime::{
|
||||
generic::BlockId, transaction_validity::TransactionValidity,
|
||||
};
|
||||
#[doc(hidden)]
|
||||
pub use primitives::{offchain, ExecutionContext};
|
||||
pub use sp_core::{offchain, ExecutionContext};
|
||||
#[doc(hidden)]
|
||||
pub use sp_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec};
|
||||
#[doc(hidden)]
|
||||
@@ -60,7 +60,7 @@ pub use sp_std::{slice, mem};
|
||||
use sp_std::result;
|
||||
#[doc(hidden)]
|
||||
pub use codec::{Encode, Decode};
|
||||
use primitives::OpaqueMetadata;
|
||||
use sp_core::OpaqueMetadata;
|
||||
#[cfg(feature = "std")]
|
||||
use std::{panic::UnwindSafe, cell::RefCell};
|
||||
|
||||
@@ -223,7 +223,7 @@ pub use sp_api_proc_macro::impl_runtime_apis;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
/// A type that records all accessed trie nodes and generates a proof out of it.
|
||||
pub type ProofRecorder<B> = state_machine::ProofRecorder<
|
||||
pub type ProofRecorder<B> = sp_state_machine::ProofRecorder<
|
||||
<<<B as BlockT>::Header as HeaderT>::Hashing as HashT>::Hasher
|
||||
>;
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
sp-api = { path = "../" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" }
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
|
||||
sp-version = { path = "../../version" }
|
||||
sp-runtime = { path = "../../runtime" }
|
||||
sp-blockchain = { path = "../../blockchain" }
|
||||
consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
state-machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" }
|
||||
sp-state-machine = { path = "../../../primitives/state-machine" }
|
||||
trybuild = "1.0.17"
|
||||
rustversion = "1.0.0"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3.0"
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" }
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
|
||||
|
||||
[[bench]]
|
||||
name = "bench"
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use test_client::{
|
||||
use substrate_test_runtime_client::{
|
||||
DefaultTestClientBuilderExt, TestClientBuilder,
|
||||
TestClientBuilderExt, runtime::TestAPI,
|
||||
};
|
||||
use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi};
|
||||
use state_machine::ExecutionStrategy;
|
||||
use sp_state_machine::ExecutionStrategy;
|
||||
|
||||
fn sp_api_benchmark(c: &mut Criterion) {
|
||||
c.bench_function("add one with same runtime api", |b| {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().chain.best_number);
|
||||
|
||||
@@ -32,14 +32,14 @@ fn sp_api_benchmark(c: &mut Criterion) {
|
||||
});
|
||||
|
||||
c.bench_function("add one with recreating runtime api", |b| {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
let block_id = BlockId::Number(client.info().chain.best_number);
|
||||
|
||||
b.iter(|| client.runtime_api().benchmark_add_one(&block_id, &1))
|
||||
});
|
||||
|
||||
c.bench_function("vector add one with same runtime api", |b| {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().chain.best_number);
|
||||
let data = vec![0; 1000];
|
||||
@@ -48,7 +48,7 @@ fn sp_api_benchmark(c: &mut Criterion) {
|
||||
});
|
||||
|
||||
c.bench_function("vector add one with recreating runtime api", |b| {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
let block_id = BlockId::Number(client.info().chain.best_number);
|
||||
let data = vec![0; 1000];
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use sp_api::{RuntimeApiInfo, decl_runtime_apis, impl_runtime_apis};
|
||||
|
||||
use sp_runtime::{traits::{GetNodeBlockType, Block as BlockT}, generic::BlockId};
|
||||
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
use sp_blockchain::Result;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
@@ -81,8 +81,11 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
type TestClient = test_client::client::Client<
|
||||
test_client::Backend, test_client::Executor, Block, RuntimeApi
|
||||
type TestClient = substrate_test_runtime_client::sc_client::Client<
|
||||
substrate_test_runtime_client::Backend,
|
||||
substrate_test_runtime_client::Executor,
|
||||
Block,
|
||||
RuntimeApi,
|
||||
>;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use test_client::{
|
||||
use substrate_test_runtime_client::{
|
||||
prelude::*,
|
||||
DefaultTestClientBuilderExt, TestClientBuilder,
|
||||
runtime::{TestAPI, DecodeFails, Transfer, Header},
|
||||
@@ -23,12 +23,12 @@ use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{ProvideRuntimeApi, Header as HeaderT, Hash as HashT},
|
||||
};
|
||||
use state_machine::{
|
||||
use sp_state_machine::{
|
||||
ExecutionStrategy, create_proof_check_backend,
|
||||
execution_proof_check_on_trie_backend,
|
||||
};
|
||||
|
||||
use consensus_common::SelectChain;
|
||||
use sp_consensus::SelectChain;
|
||||
use codec::Encode;
|
||||
|
||||
fn calling_function_with_strat(strat: ExecutionStrategy) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sp_runtime::traits::GetNodeBlockType;
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sp_runtime::traits::GetNodeBlockType;
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sp_runtime::traits::{GetNodeBlockType, Block as BlockT};
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sp_runtime::traits::GetNodeBlockType;
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sp_runtime::traits::GetNodeBlockType;
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sp_runtime::traits::GetNodeBlockType;
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use sp_runtime::traits::{GetNodeBlockType, Block as BlockT};
|
||||
use test_client::runtime::Block;
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
|
||||
/// trait are done by the `construct_runtime!` macro in a real runtime.
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
description = "Provides facilities for generating application specific crypto wrapper types."
|
||||
|
||||
[dependencies]
|
||||
primitives = { package = "sp-core", path = "../core", default-features = false }
|
||||
sp-core = { path = "../core", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
@@ -14,11 +14,11 @@ sp-io = { path = "../../primitives/io", default-features = false }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [ "full_crypto", "primitives/std", "codec/std", "serde", "sp-std/std", "sp-io/std" ]
|
||||
std = [ "full_crypto", "sp-core/std", "codec/std", "serde", "sp-std/std", "sp-io/std" ]
|
||||
|
||||
# This feature enables all crypto primitives for `no_std` builds like microcontrollers
|
||||
# or Intel SGX.
|
||||
# For the regular wasm runtime builds this should not be used.
|
||||
full_crypto = [
|
||||
"primitives/full_crypto"
|
||||
"sp-core/full_crypto"
|
||||
]
|
||||
|
||||
@@ -20,10 +20,10 @@ use crate::{RuntimePublic, KeyTypeId};
|
||||
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
pub use primitives::ed25519::*;
|
||||
pub use sp_core::ed25519::*;
|
||||
|
||||
mod app {
|
||||
use primitives::testing::ED25519;
|
||||
use sp_core::testing::ED25519;
|
||||
crate::app_crypto!(super, ED25519);
|
||||
|
||||
impl crate::traits::BoundToRuntimeAppPublic for Public {
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use primitives::{self, crypto::{CryptoType, Public, Derive, IsWrappedBy, Wraps}, RuntimeDebug};
|
||||
pub use sp_core::{self, crypto::{CryptoType, Public, Derive, IsWrappedBy, Wraps}, RuntimeDebug};
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "full_crypto")]
|
||||
pub use primitives::crypto::{SecretStringError, DeriveJunction, Ss58Codec, Pair};
|
||||
pub use primitives::{crypto::{KeyTypeId, key_types}};
|
||||
pub use sp_core::crypto::{SecretStringError, DeriveJunction, Ss58Codec, Pair};
|
||||
pub use sp_core::{crypto::{KeyTypeId, key_types}};
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use codec;
|
||||
|
||||
@@ -20,10 +20,10 @@ use crate::{RuntimePublic, KeyTypeId};
|
||||
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
pub use primitives::sr25519::*;
|
||||
pub use sp_core::sr25519::*;
|
||||
|
||||
mod app {
|
||||
use primitives::testing::SR25519;
|
||||
use sp_core::testing::SR25519;
|
||||
crate::app_crypto!(super, SR25519);
|
||||
|
||||
impl crate::traits::BoundToRuntimeAppPublic for Public {
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#[cfg(feature = "full_crypto")]
|
||||
use primitives::crypto::Pair;
|
||||
use sp_core::crypto::Pair;
|
||||
|
||||
use codec::Codec;
|
||||
use primitives::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public};
|
||||
use sp_core::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public};
|
||||
use sp_std::{fmt::Debug, vec::Vec};
|
||||
|
||||
/// An application-specific key.
|
||||
|
||||
@@ -7,6 +7,7 @@ description = "Integration tests for application-crypto"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
primitives = { package = "sp-core", path = "../../core", default-features = false }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" }
|
||||
sp-runtime = { path = "../../runtime" }
|
||||
sp-core = { path = "../../core", default-features = false }
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
|
||||
sp-runtime = { path = "../../runtime" }
|
||||
sp-application-crypto = { path = "../" }
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
//! Integration tests for ed25519
|
||||
|
||||
use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi};
|
||||
use primitives::{testing::{KeyStore, ED25519}, crypto::Pair};
|
||||
use test_client::{
|
||||
use sp_core::{testing::{KeyStore, ED25519}, crypto::Pair};
|
||||
use substrate_test_runtime_client::{
|
||||
TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt,
|
||||
runtime::{TestAPI, app_crypto::ed25519::{AppPair, AppPublic}},
|
||||
runtime::TestAPI,
|
||||
};
|
||||
use sp_application_crypto::ed25519::{AppPair, AppPublic};
|
||||
|
||||
#[test]
|
||||
fn ed25519_works_in_runtime() {
|
||||
@@ -35,4 +36,4 @@ fn ed25519_works_in_runtime() {
|
||||
.expect("There should be at a `ed25519` key in the keystore for the given public key.");
|
||||
|
||||
assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(key_pair.public())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
|
||||
use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi};
|
||||
use primitives::{testing::{KeyStore, SR25519}, crypto::Pair};
|
||||
use test_client::{
|
||||
use sp_core::{testing::{KeyStore, SR25519}, crypto::Pair};
|
||||
use substrate_test_runtime_client::{
|
||||
TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt,
|
||||
runtime::{TestAPI, app_crypto::sr25519::{AppPair, AppPublic}},
|
||||
runtime::TestAPI,
|
||||
};
|
||||
use sp_application_crypto::sr25519::{AppPair, AppPublic};
|
||||
|
||||
#[test]
|
||||
fn sr25519_works_in_runtime() {
|
||||
@@ -36,4 +37,4 @@ fn sr25519_works_in_runtime() {
|
||||
.expect("There should be at a `sr25519` key in the keystore for the given public key.");
|
||||
|
||||
assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(key_pair.public())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ description = "Authority discovery primitives"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false }
|
||||
sp-application-crypto = { path = "../application-crypto", default-features = false }
|
||||
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
sp-api = { path = "../api", default-features = false }
|
||||
@@ -15,7 +15,7 @@ sp-runtime = { path = "../runtime", default-features = false }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"sp-application-crypto/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"sp-api/std",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
mod app {
|
||||
use app_crypto::{app_crypto, key_types::AUTHORITY_DISCOVERY, sr25519};
|
||||
use sp_application_crypto::{app_crypto, key_types::AUTHORITY_DISCOVERY, sr25519};
|
||||
app_crypto!(sr25519, AUTHORITY_DISCOVERY);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ sp-runtime = { path = "../runtime", default-features = false }
|
||||
sp-api = { path = "../api", default-features = false }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false }
|
||||
inherents = { package = "sp-inherents", path = "../inherents", default-features = false }
|
||||
sp-inherents = { path = "../inherents", default-features = false }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"sp-runtime/std",
|
||||
"codec/std",
|
||||
"inherents/std",
|
||||
"sp-inherents/std",
|
||||
"sp-api/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
use sp_runtime::{traits::Block as BlockT, ApplyExtrinsicResult};
|
||||
|
||||
use inherents::{InherentData, CheckInherentsResult};
|
||||
use sp_inherents::{InherentData, CheckInherentsResult};
|
||||
|
||||
/// Definitions for supporting the older version of API: v3
|
||||
///
|
||||
|
||||
@@ -9,8 +9,8 @@ log = "0.4.8"
|
||||
lru = "0.4.0"
|
||||
parking_lot = "0.9.0"
|
||||
derive_more = "0.99.2"
|
||||
parity-scale-codec = { version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp_consensus = { package = "sp-consensus", path = "../consensus/common" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp-consensus = { path = "../consensus/common" }
|
||||
sp-runtime = { path = "../runtime" }
|
||||
sp-block-builder-runtime-api = { package = "sp-block-builder", path = "../block-builder" }
|
||||
sp-state-machine = { package = "sp-state-machine", path = "../state-machine" }
|
||||
sp-block-builder = { path = "../block-builder" }
|
||||
sp-state-machine = { path = "../state-machine" }
|
||||
|
||||
@@ -20,10 +20,10 @@ use std::{self, error, result};
|
||||
use sp_state_machine;
|
||||
use sp_runtime::transaction_validity::TransactionValidityError;
|
||||
#[allow(deprecated)]
|
||||
use sp_block_builder_runtime_api::compatability_v3;
|
||||
use sp_block_builder::compatability_v3;
|
||||
use sp_consensus;
|
||||
use derive_more::{Display, From};
|
||||
use parity_scale_codec::Error as CodecError;
|
||||
use codec::Error as CodecError;
|
||||
|
||||
/// Client Result type alias
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
@@ -6,22 +6,22 @@ description = "Primitives for Aura consensus"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../application-crypto", default-features = false }
|
||||
sp-application-crypto = { path = "../../application-crypto", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
sp-std = { path = "../../std", default-features = false }
|
||||
sp-api = { path = "../../api", default-features = false }
|
||||
sp-runtime = { path = "../../runtime", default-features = false }
|
||||
inherents = { package = "sp-inherents", path = "../../inherents", default-features = false }
|
||||
sp-inherents = { path = "../../inherents", default-features = false }
|
||||
sp-timestamp = { path = "../../timestamp", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"sp-application-crypto/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"sp-api/std",
|
||||
"sp-runtime/std",
|
||||
"inherents/std",
|
||||
"sp-inherents/std",
|
||||
"sp-timestamp/std",
|
||||
]
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
/// Contains the inherents for the AURA module
|
||||
|
||||
use inherents::{InherentIdentifier, InherentData, Error};
|
||||
use sp_inherents::{InherentIdentifier, InherentData, Error};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use inherents::{InherentDataProviders, ProvideInherentData};
|
||||
use sp_inherents::{InherentDataProviders, ProvideInherentData};
|
||||
|
||||
/// The Aura inherent identifier.
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"auraslot";
|
||||
@@ -93,6 +93,6 @@ impl ProvideInherentData for InherentDataProvider {
|
||||
fn error_to_string(&self, error: &[u8]) -> Option<String> {
|
||||
use codec::Decode;
|
||||
|
||||
inherents::Error::decode(&mut &error[..]).map(|e| e.into_string()).ok()
|
||||
sp_inherents::Error::decode(&mut &error[..]).map(|e| e.into_string()).ok()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ pub mod inherents;
|
||||
|
||||
pub mod sr25519 {
|
||||
mod app_sr25519 {
|
||||
use app_crypto::{app_crypto, key_types::AURA, sr25519};
|
||||
use sp_application_crypto::{app_crypto, key_types::AURA, sr25519};
|
||||
app_crypto!(sr25519, AURA);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ pub mod sr25519 {
|
||||
|
||||
pub mod ed25519 {
|
||||
mod app_ed25519 {
|
||||
use app_crypto::{app_crypto, key_types::AURA, ed25519};
|
||||
use sp_application_crypto::{app_crypto, key_types::AURA, ed25519};
|
||||
app_crypto!(ed25519, AURA);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@ description = "Primitives for BABE consensus"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../application-crypto", default-features = false }
|
||||
sp-application-crypto = { path = "../../application-crypto", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
sp-std = { path = "../../std", default-features = false }
|
||||
schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true }
|
||||
sp-api = { path = "../../api", default-features = false }
|
||||
sp-consensus = { path = "../common", optional = true }
|
||||
sp-inherents = { package = "sp-inherents", path = "../../inherents", default-features = false }
|
||||
sp-inherents = { path = "../../inherents", default-features = false }
|
||||
sp-runtime = { path = "../../runtime", default-features = false }
|
||||
sp-timestamp = { path = "../../timestamp", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"sp-application-crypto/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"schnorrkel",
|
||||
|
||||
@@ -31,7 +31,7 @@ pub use digest::{BabePreDigest, CompatibleDigestItem};
|
||||
pub use digest::{BABE_VRF_PREFIX, RawBabePreDigest, NextEpochDescriptor};
|
||||
|
||||
mod app {
|
||||
use app_crypto::{app_crypto, key_types::BABE, sr25519};
|
||||
use sp_application_crypto::{app_crypto, key_types::BABE, sr25519};
|
||||
app_crypto!(sr25519, BABE);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ edition = "2018"
|
||||
derive_more = "0.99.2"
|
||||
libp2p = { version = "0.13.0", default-features = false }
|
||||
log = "0.4.8"
|
||||
primitives = { package = "sp-core", path= "../../core" }
|
||||
inherents = { package = "sp-inherents", path = "../../inherents" }
|
||||
sp-core = { path= "../../core" }
|
||||
sp-inherents = { path = "../../inherents" }
|
||||
futures = { version = "0.3.1", features = ["thread-pool"] }
|
||||
futures-timer = "0.4.0"
|
||||
sp-std = { path = "../../std" }
|
||||
runtime_version = { package = "sp-version", path = "../../version" }
|
||||
sp-version = { path = "../../version" }
|
||||
sp-runtime = { path = "../../runtime" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
|
||||
parking_lot = "0.9.0"
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Error types in Consensus
|
||||
use runtime_version::RuntimeVersion;
|
||||
use primitives::ed25519::{Public, Signature};
|
||||
use sp_version::RuntimeVersion;
|
||||
use sp_core::ed25519::{Public, Signature};
|
||||
use std::error;
|
||||
|
||||
/// Result type alias.
|
||||
@@ -36,7 +36,7 @@ pub enum Error {
|
||||
FaultyTimer(std::io::Error),
|
||||
/// Error while working with inherent data.
|
||||
#[display(fmt="InherentData error: {}", _0)]
|
||||
InherentData(inherents::Error),
|
||||
InherentData(sp_inherents::Error),
|
||||
/// Unable to propose a block.
|
||||
#[display(fmt="Unable to create block proposal.")]
|
||||
CannotPropose,
|
||||
|
||||
@@ -33,7 +33,7 @@ use std::time::Duration;
|
||||
|
||||
use sp_runtime::{traits::{Block as BlockT, DigestFor}, generic::BlockId};
|
||||
use futures::prelude::*;
|
||||
pub use inherents::InherentData;
|
||||
pub use sp_inherents::InherentData;
|
||||
|
||||
pub mod block_validation;
|
||||
pub mod offline_tracker;
|
||||
@@ -146,7 +146,7 @@ pub trait CanAuthorWith<Block: BlockT> {
|
||||
}
|
||||
|
||||
/// Checks if the node can author blocks by using
|
||||
/// [`NativeVersion::can_author_with`](runtime_version::NativeVersion::can_author_with).
|
||||
/// [`NativeVersion::can_author_with`](sp_version::NativeVersion::can_author_with).
|
||||
pub struct CanAuthorWithNativeVersion<T>(T);
|
||||
|
||||
impl<T> CanAuthorWithNativeVersion<T> {
|
||||
@@ -156,7 +156,7 @@ impl<T> CanAuthorWithNativeVersion<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: runtime_version::GetRuntimeVersion<Block>, Block: BlockT> CanAuthorWith<Block>
|
||||
impl<T: sp_version::GetRuntimeVersion<Block>, Block: BlockT> CanAuthorWith<Block>
|
||||
for CanAuthorWithNativeVersion<T>
|
||||
{
|
||||
fn can_author_with(&self, at: &BlockId<Block>) -> Result<(), String> {
|
||||
|
||||
@@ -9,7 +9,7 @@ edition = "2018"
|
||||
sp-api = { path = "../../api", default-features = false }
|
||||
sp-std = { path = "../../std", default-features = false }
|
||||
sp-runtime = { path = "../../runtime", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../core", default-features = false }
|
||||
sp-core = { path = "../../core", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
|
||||
[features]
|
||||
@@ -18,6 +18,6 @@ std = [
|
||||
"sp-std/std",
|
||||
"sp-api/std",
|
||||
"sp-runtime/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"codec/std",
|
||||
]
|
||||
|
||||
@@ -33,7 +33,7 @@ pub trait TotalDifficulty {
|
||||
fn increment(&mut self, other: Self);
|
||||
}
|
||||
|
||||
impl TotalDifficulty for primitives::U256 {
|
||||
impl TotalDifficulty for sp_core::U256 {
|
||||
fn increment(&mut self, other: Self) {
|
||||
let ret = self.saturating_add(other);
|
||||
*self = ret;
|
||||
|
||||
@@ -26,8 +26,8 @@ zeroize = { version = "1.0.0", default-features = false }
|
||||
lazy_static = { version = "1.4.0", default-features = false, optional = true }
|
||||
parking_lot = { version = "0.9.0", optional = true }
|
||||
sp-debug-derive = { version = "2.0.0", path = "../debug-derive" }
|
||||
externalities = { package = "sp-externalities", path = "../externalities", optional = true }
|
||||
primitives-storage = { package = "sp-storage", path = "../storage", default-features = false }
|
||||
sp-externalities = { path = "../externalities", optional = true }
|
||||
sp-storage = { path = "../storage", default-features = false }
|
||||
|
||||
# full crypto
|
||||
ed25519-dalek = { version = "1.0.0-pre.3", default-features = false, features = ["u64_backend", "alloc"], optional = true }
|
||||
@@ -39,7 +39,7 @@ sha2 = { version = "0.8.0", default-features = false, optional = true }
|
||||
hex = { version = "0.4", default-features = false, optional = true }
|
||||
twox-hash = { version = "1.5.0", default-features = false, optional = true }
|
||||
|
||||
runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false }
|
||||
sp-runtime-interface = { path = "../runtime-interface", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-serializer = { path = "../serializer" }
|
||||
@@ -93,9 +93,9 @@ std = [
|
||||
"libsecp256k1",
|
||||
"tiny-keccak",
|
||||
"sp-debug-derive/std",
|
||||
"externalities",
|
||||
"primitives-storage/std",
|
||||
"runtime-interface/std",
|
||||
"sp-externalities",
|
||||
"sp-storage/std",
|
||||
"sp-runtime-interface/std",
|
||||
"zeroize/alloc"
|
||||
]
|
||||
|
||||
@@ -111,5 +111,5 @@ full_crypto = [
|
||||
"hex",
|
||||
"sha2",
|
||||
"twox-hash",
|
||||
"runtime-interface/disable_target_static_assertions",
|
||||
"sp-runtime-interface/disable_target_static_assertions",
|
||||
]
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
#[macro_use]
|
||||
extern crate criterion;
|
||||
|
||||
use sp_core as primitives;
|
||||
use criterion::{Criterion, black_box, Bencher, Fun};
|
||||
use std::time::Duration;
|
||||
use primitives::crypto::Pair as _;
|
||||
use primitives::hashing::{twox_128, blake2_128};
|
||||
use sp_core::crypto::Pair as _;
|
||||
use sp_core::hashing::{twox_128, blake2_128};
|
||||
|
||||
const MAX_KEY_SIZE: u32 = 32;
|
||||
|
||||
@@ -72,7 +71,7 @@ fn bench_ed25519(c: &mut Criterion) {
|
||||
let msg = (0..msg_size)
|
||||
.map(|_| rand::random::<u8>())
|
||||
.collect::<Vec<_>>();
|
||||
let key = primitives::ed25519::Pair::generate().0;
|
||||
let key = sp_core::ed25519::Pair::generate().0;
|
||||
b.iter(|| key.sign(&msg))
|
||||
}, vec![32, 1024, 1024 * 1024]);
|
||||
|
||||
@@ -80,10 +79,10 @@ fn bench_ed25519(c: &mut Criterion) {
|
||||
let msg = (0..msg_size)
|
||||
.map(|_| rand::random::<u8>())
|
||||
.collect::<Vec<_>>();
|
||||
let key = primitives::ed25519::Pair::generate().0;
|
||||
let key = sp_core::ed25519::Pair::generate().0;
|
||||
let sig = key.sign(&msg);
|
||||
let public = key.public();
|
||||
b.iter(|| primitives::ed25519::Pair::verify(&sig, &msg, &public))
|
||||
b.iter(|| sp_core::ed25519::Pair::verify(&sig, &msg, &public))
|
||||
}, vec![32, 1024, 1024 * 1024]);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ use base58::{FromBase58, ToBase58};
|
||||
use zeroize::Zeroize;
|
||||
#[doc(hidden)]
|
||||
pub use sp_std::ops::Deref;
|
||||
use runtime_interface::pass_by::PassByInner;
|
||||
use sp_runtime_interface::pass_by::PassByInner;
|
||||
|
||||
/// The root phrase for our publicly known keys.
|
||||
pub const DEV_PHRASE: &str = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
|
||||
|
||||
@@ -39,7 +39,7 @@ use crate::crypto::Ss58Codec;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{de, Serializer, Serialize, Deserializer, Deserialize};
|
||||
use crate::{crypto::{Public as TraitPublic, UncheckedFrom, CryptoType, Derive}};
|
||||
use runtime_interface::pass_by::PassByInner;
|
||||
use sp_runtime_interface::pass_by::PassByInner;
|
||||
use sp_std::ops::Deref;
|
||||
|
||||
/// A secret seed. It's not called a "secret key" because ring doesn't expose the secret keys
|
||||
|
||||
@@ -84,7 +84,7 @@ pub use hash_db::Hasher;
|
||||
// pub use self::hasher::blake::BlakeHasher;
|
||||
pub use self::hasher::blake2::Blake2Hasher;
|
||||
|
||||
pub use primitives_storage as storage;
|
||||
pub use sp_storage as storage;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use sp_std;
|
||||
@@ -236,7 +236,7 @@ pub trait TypeId {
|
||||
/// A log level matching the one from `log` crate.
|
||||
///
|
||||
/// Used internally by `sp_io::log` method.
|
||||
#[derive(Encode, Decode, runtime_interface::pass_by::PassByEnum, Copy, Clone)]
|
||||
#[derive(Encode, Decode, sp_runtime_interface::pass_by::PassByEnum, Copy, Clone)]
|
||||
pub enum LogLevel {
|
||||
/// `Error` log level.
|
||||
Error = 1,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use codec::{Encode, Decode};
|
||||
use sp_std::{prelude::{Vec, Box}, convert::TryFrom};
|
||||
use crate::RuntimeDebug;
|
||||
use runtime_interface::pass_by::{PassByCodec, PassByInner, PassByEnum};
|
||||
use sp_runtime_interface::pass_by::{PassByCodec, PassByInner, PassByEnum};
|
||||
|
||||
pub use crate::crypto::KeyTypeId;
|
||||
|
||||
@@ -669,7 +669,7 @@ impl<T: Externalities> Externalities for LimitedExternalities<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
externalities::decl_extension! {
|
||||
sp_externalities::decl_extension! {
|
||||
/// The offchain extension that will be registered at the Substrate externalities.
|
||||
pub struct OffchainExt(Box<dyn Externalities>);
|
||||
}
|
||||
@@ -696,7 +696,7 @@ pub trait TransactionPool {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
externalities::decl_extension! {
|
||||
sp_externalities::decl_extension! {
|
||||
/// An externalities extension to submit transactions to the pool.
|
||||
pub struct TransactionPoolExt(Box<dyn TransactionPool + Send>);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ use sp_std::ops::Deref;
|
||||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||
#[cfg(feature = "full_crypto")]
|
||||
use schnorrkel::keys::{MINI_SECRET_KEY_LENGTH, SECRET_KEY_LENGTH};
|
||||
use runtime_interface::pass_by::PassByInner;
|
||||
use sp_runtime_interface::pass_by::PassByInner;
|
||||
|
||||
// signing context
|
||||
#[cfg(feature = "full_crypto")]
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub use externalities::{Externalities, ExternalitiesExt};
|
||||
pub use sp_externalities::{Externalities, ExternalitiesExt};
|
||||
|
||||
/// Something that generates, stores and provides access to keys.
|
||||
pub trait BareCryptoStore: Send + Sync {
|
||||
@@ -74,7 +74,7 @@ pub trait BareCryptoStore: Send + Sync {
|
||||
/// A pointer to the key store.
|
||||
pub type BareCryptoStorePtr = Arc<parking_lot::RwLock<dyn BareCryptoStore>>;
|
||||
|
||||
externalities::decl_extension! {
|
||||
sp_externalities::decl_extension! {
|
||||
/// The keystore extension to register/retrieve from the externalities.
|
||||
pub struct KeystoreExt(BareCryptoStorePtr);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
primitives-storage = { package = "sp-storage", path = "../storage" }
|
||||
sp-storage = { path = "../storage" }
|
||||
sp-std = { path = "../std" }
|
||||
environmental = { version = "1.0.2" }
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
use std::any::{Any, TypeId};
|
||||
|
||||
use primitives_storage::{ChildStorageKey, ChildInfo};
|
||||
use sp_storage::{ChildStorageKey, ChildInfo};
|
||||
|
||||
pub use scope_limited::{set_and_run_with_externalities, with_externalities};
|
||||
pub use extensions::{Extension, Extensions, ExtensionStore};
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
|
||||
sp-inherents = { path = "../../primitives/inherents", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
|
||||
[features]
|
||||
@@ -14,5 +14,5 @@ default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"inherents/std",
|
||||
"sp-inherents/std",
|
||||
]
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use inherents::{InherentIdentifier, InherentData, Error};
|
||||
use sp_inherents::{InherentIdentifier, InherentData, Error};
|
||||
use codec::Decode;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
@@ -55,7 +55,7 @@ impl<F, N> InherentDataProvider<F, N> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<F, N: Encode> inherents::ProvideInherentData for InherentDataProvider<F, N>
|
||||
impl<F, N: Encode> sp_inherents::ProvideInherentData for InherentDataProvider<F, N>
|
||||
where F: Fn() -> Result<N, Error>
|
||||
{
|
||||
fn inherent_identifier(&self) -> &'static InherentIdentifier {
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
parking_lot = { version = "0.9.0", optional = true }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../core", default-features = false }
|
||||
sp-core = { path = "../core", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] }
|
||||
derive_more = { version = "0.99.2", optional = true }
|
||||
|
||||
@@ -17,6 +17,6 @@ std = [
|
||||
"parking_lot",
|
||||
"sp-std/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"derive_more",
|
||||
]
|
||||
|
||||
@@ -64,7 +64,7 @@ impl Error {
|
||||
}
|
||||
|
||||
/// An error that can occur within the inherent data system.
|
||||
#[derive(Encode, primitives::RuntimeDebug)]
|
||||
#[derive(Encode, sp_core::RuntimeDebug)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub struct Error(&'static str);
|
||||
|
||||
|
||||
@@ -7,27 +7,27 @@ edition = "2018"
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false }
|
||||
hash-db = { version = "0.15.2", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../core", default-features = false }
|
||||
sp-core = { path = "../core", default-features = false }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
libsecp256k1 = { version = "0.3.0", optional = true }
|
||||
sp-state-machine = { path = "../../primitives/state-machine", optional = true }
|
||||
runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false }
|
||||
trie = { package = "sp-trie", path = "../../primitives/trie", optional = true }
|
||||
externalities = { package = "sp-externalities", path = "../externalities", optional = true }
|
||||
sp-runtime-interface = { path = "../runtime-interface", default-features = false }
|
||||
sp-trie = { path = "../../primitives/trie", optional = true }
|
||||
sp-externalities = { path = "../externalities", optional = true }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"hash-db/std",
|
||||
"trie",
|
||||
"sp-trie",
|
||||
"sp-state-machine",
|
||||
"libsecp256k1",
|
||||
"runtime-interface/std",
|
||||
"externalities",
|
||||
"sp-runtime-interface/std",
|
||||
"sp-externalities",
|
||||
"log",
|
||||
]
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ use sp_std::vec::Vec;
|
||||
use sp_std::ops::Deref;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
crypto::Pair,
|
||||
traits::KeystoreExt,
|
||||
offchain::{OffchainExt, TransactionPoolExt},
|
||||
@@ -42,7 +42,7 @@ use primitives::{
|
||||
storage::{ChildStorageKey, ChildInfo},
|
||||
};
|
||||
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
crypto::KeyTypeId, ed25519, sr25519, H256, LogLevel,
|
||||
offchain::{
|
||||
Timestamp, HttpRequestId, HttpRequestStatus, HttpError, StorageKind, OpaqueNetworkState,
|
||||
@@ -50,14 +50,14 @@ use primitives::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use ::trie::{TrieConfiguration, trie_types::Layout};
|
||||
use ::sp_trie::{TrieConfiguration, trie_types::Layout};
|
||||
|
||||
use runtime_interface::{runtime_interface, Pointer};
|
||||
use sp_runtime_interface::{runtime_interface, Pointer};
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use externalities::{ExternalitiesExt, Externalities};
|
||||
use sp_externalities::{ExternalitiesExt, Externalities};
|
||||
|
||||
/// Error verifying ECDSA signature
|
||||
#[derive(Encode, Decode)]
|
||||
@@ -318,12 +318,12 @@ pub trait Storage {
|
||||
pub trait Trie {
|
||||
/// A trie root formed from the iterated items.
|
||||
fn blake2_256_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> H256 {
|
||||
Layout::<primitives::Blake2Hasher>::trie_root(input)
|
||||
Layout::<sp_core::Blake2Hasher>::trie_root(input)
|
||||
}
|
||||
|
||||
/// A trie root formed from the enumerated items.
|
||||
fn blake2_256_ordered_root(input: Vec<Vec<u8>>) -> H256 {
|
||||
Layout::<primitives::Blake2Hasher>::ordered_trie_root(input)
|
||||
Layout::<sp_core::Blake2Hasher>::ordered_trie_root(input)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ pub trait Trie {
|
||||
pub trait Misc {
|
||||
/// The current relay chain identifier.
|
||||
fn chain_id(&self) -> u64 {
|
||||
externalities::Externalities::chain_id(*self)
|
||||
sp_externalities::Externalities::chain_id(*self)
|
||||
}
|
||||
|
||||
/// Print a number.
|
||||
@@ -496,37 +496,37 @@ pub trait Crypto {
|
||||
pub trait Hashing {
|
||||
/// Conduct a 256-bit Keccak hash.
|
||||
fn keccak_256(data: &[u8]) -> [u8; 32] {
|
||||
primitives::hashing::keccak_256(data)
|
||||
sp_core::hashing::keccak_256(data)
|
||||
}
|
||||
|
||||
/// Conduct a 256-bit Sha2 hash.
|
||||
fn sha2_256(data: &[u8]) -> [u8; 32] {
|
||||
primitives::hashing::sha2_256(data)
|
||||
sp_core::hashing::sha2_256(data)
|
||||
}
|
||||
|
||||
/// Conduct a 128-bit Blake2 hash.
|
||||
fn blake2_128(data: &[u8]) -> [u8; 16] {
|
||||
primitives::hashing::blake2_128(data)
|
||||
sp_core::hashing::blake2_128(data)
|
||||
}
|
||||
|
||||
/// Conduct a 256-bit Blake2 hash.
|
||||
fn blake2_256(data: &[u8]) -> [u8; 32] {
|
||||
primitives::hashing::blake2_256(data)
|
||||
sp_core::hashing::blake2_256(data)
|
||||
}
|
||||
|
||||
/// Conduct four XX hashes to give a 256-bit result.
|
||||
fn twox_256(data: &[u8]) -> [u8; 32] {
|
||||
primitives::hashing::twox_256(data)
|
||||
sp_core::hashing::twox_256(data)
|
||||
}
|
||||
|
||||
/// Conduct two XX hashes to give a 128-bit result.
|
||||
fn twox_128(data: &[u8]) -> [u8; 16] {
|
||||
primitives::hashing::twox_128(data)
|
||||
sp_core::hashing::twox_128(data)
|
||||
}
|
||||
|
||||
/// Conduct two XX hashes to give a 64-bit result.
|
||||
fn twox_64(data: &[u8]) -> [u8; 8] {
|
||||
primitives::hashing::twox_64(data)
|
||||
sp_core::hashing::twox_64(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,7 +881,7 @@ pub fn oom(_: core::alloc::Layout) -> ! {
|
||||
|
||||
/// Type alias for Externalities implementation used in tests.
|
||||
#[cfg(feature = "std")]
|
||||
pub type TestExternalities = sp_state_machine::TestExternalities<primitives::Blake2Hasher, u64>;
|
||||
pub type TestExternalities = sp_state_machine::TestExternalities<sp_core::Blake2Hasher, u64>;
|
||||
|
||||
/// The host functions Substrate provides for the Wasm runtime environment.
|
||||
///
|
||||
@@ -902,9 +902,9 @@ pub type SubstrateHostFunctions = (
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::map;
|
||||
use sp_core::map;
|
||||
use sp_state_machine::BasicExternalities;
|
||||
use primitives::storage::Storage;
|
||||
use sp_core::storage::Storage;
|
||||
|
||||
#[test]
|
||||
fn storage_works() {
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
primitives = { package = "sp-core", path = "../core" }
|
||||
sp-core = { path = "../core" }
|
||||
sp-runtime = { path = "../runtime" }
|
||||
lazy_static = "1.4.0"
|
||||
strum = { version = "0.16.0", features = ["derive"] }
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
use std::{collections::HashMap, ops::Deref};
|
||||
use lazy_static::lazy_static;
|
||||
use primitives::{ed25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256};
|
||||
pub use primitives::ed25519;
|
||||
use sp_core::{ed25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256};
|
||||
pub use sp_core::ed25519;
|
||||
use sp_runtime::AccountId32;
|
||||
|
||||
/// Set of test accounts.
|
||||
@@ -180,7 +180,7 @@ impl Deref for Keyring {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::{ed25519::Pair, Pair as PairT};
|
||||
use sp_core::{ed25519::Pair, Pair as PairT};
|
||||
|
||||
#[test]
|
||||
fn should_work() {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Deref;
|
||||
use lazy_static::lazy_static;
|
||||
use primitives::{sr25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256};
|
||||
pub use primitives::sr25519;
|
||||
use sp_core::{sr25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256};
|
||||
pub use sp_core::sr25519;
|
||||
use sp_runtime::AccountId32;
|
||||
|
||||
/// Set of test accounts.
|
||||
@@ -181,7 +181,7 @@ impl Deref for Keyring {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::{sr25519::Pair, Pair as PairT};
|
||||
use sp_core::{sr25519::Pair, Pair as PairT};
|
||||
|
||||
#[test]
|
||||
fn should_work() {
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", features = ["derive"] }
|
||||
primitives = { package = "sp-core", path = "../core" }
|
||||
sp-core = { path = "../core" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.41"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
use std::{convert::TryFrom, fmt::Debug};
|
||||
use primitives::U256;
|
||||
use sp_core::U256;
|
||||
|
||||
/// RPC Block number type
|
||||
///
|
||||
|
||||
@@ -5,19 +5,19 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasm-interface = { package = "sp-wasm-interface", path = "../wasm-interface", optional = true }
|
||||
sp-wasm-interface = { path = "../wasm-interface", optional = true }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
sp-runtime-interface-proc-macro = { path = "proc-macro" }
|
||||
externalities = { package = "sp-externalities", path = "../externalities", optional = true }
|
||||
sp-externalities = { path = "../externalities", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false }
|
||||
environmental = { version = "1.0.2", optional = true }
|
||||
static_assertions = "1.0.0"
|
||||
primitive-types = { version = "0.6.1", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
test-wasm = { package = "sp-runtime-interface-test-wasm", path = "test-wasm" }
|
||||
state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
primitives = { package = "sp-core", path = "../core" }
|
||||
sp-runtime-interface-test-wasm = { path = "test-wasm" }
|
||||
sp-state-machine = { path = "../../primitives/state-machine" }
|
||||
sp-core = { path = "../core" }
|
||||
sp-io = { path = "../io" }
|
||||
rustversion = "1.0.0"
|
||||
trybuild = "1.0.17"
|
||||
@@ -25,10 +25,10 @@ trybuild = "1.0.17"
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"wasm-interface",
|
||||
"sp-wasm-interface",
|
||||
"sp-std/std",
|
||||
"codec/std",
|
||||
"externalities",
|
||||
"sp-externalities",
|
||||
"environmental",
|
||||
"primitive-types/std",
|
||||
]
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ fn function_std_impl(
|
||||
if is_wasm_only {
|
||||
Some(
|
||||
parse_quote!(
|
||||
mut __function_context__: &mut dyn #crate_::wasm_interface::FunctionContext
|
||||
mut __function_context__: &mut dyn #crate_::sp_wasm_interface::FunctionContext
|
||||
)
|
||||
)
|
||||
} else {
|
||||
@@ -164,7 +164,7 @@ fn generate_call_to_trait(
|
||||
} else {
|
||||
// The name of the trait the interface trait is implemented for
|
||||
let impl_trait_name = if is_wasm_only {
|
||||
quote!( #crate_::wasm_interface::FunctionContext )
|
||||
quote!( #crate_::sp_wasm_interface::FunctionContext )
|
||||
} else {
|
||||
quote!( #crate_::Externalities )
|
||||
};
|
||||
|
||||
+13
-13
@@ -174,8 +174,8 @@ fn generate_host_functions_struct(trait_def: &ItemTrait, is_wasm_only: bool) ->
|
||||
pub struct HostFunctions;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl #crate_::wasm_interface::HostFunctions for HostFunctions {
|
||||
fn host_functions() -> Vec<&'static dyn #crate_::wasm_interface::Function> {
|
||||
impl #crate_::sp_wasm_interface::HostFunctions for HostFunctions {
|
||||
fn host_functions() -> Vec<&'static dyn #crate_::sp_wasm_interface::Function> {
|
||||
vec![ #( #host_functions ),* ]
|
||||
}
|
||||
}
|
||||
@@ -212,20 +212,20 @@ fn generate_host_function_implementation(
|
||||
struct #struct_name;
|
||||
|
||||
#[allow(unused)]
|
||||
impl #crate_::wasm_interface::Function for #struct_name {
|
||||
impl #crate_::sp_wasm_interface::Function for #struct_name {
|
||||
fn name(&self) -> &str {
|
||||
#name
|
||||
}
|
||||
|
||||
fn signature(&self) -> #crate_::wasm_interface::Signature {
|
||||
fn signature(&self) -> #crate_::sp_wasm_interface::Signature {
|
||||
#signature
|
||||
}
|
||||
|
||||
fn execute(
|
||||
&self,
|
||||
__function_context__: &mut dyn #crate_::wasm_interface::FunctionContext,
|
||||
args: &mut dyn Iterator<Item = #crate_::wasm_interface::Value>,
|
||||
) -> std::result::Result<Option<#crate_::wasm_interface::Value>, String> {
|
||||
__function_context__: &mut dyn #crate_::sp_wasm_interface::FunctionContext,
|
||||
args: &mut dyn Iterator<Item = #crate_::sp_wasm_interface::Value>,
|
||||
) -> std::result::Result<Option<#crate_::sp_wasm_interface::Value>, String> {
|
||||
#( #wasm_to_ffi_values )*
|
||||
#( #ffi_to_host_values )*
|
||||
#host_function_call
|
||||
@@ -234,7 +234,7 @@ fn generate_host_function_implementation(
|
||||
}
|
||||
}
|
||||
|
||||
&#struct_name as &dyn #crate_::wasm_interface::Function
|
||||
&#struct_name as &dyn #crate_::sp_wasm_interface::Function
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -246,18 +246,18 @@ fn generate_wasm_interface_signature_for_host_function(sig: &Signature) -> Resul
|
||||
let return_value = match &sig.output {
|
||||
ReturnType::Type(_, ty) =>
|
||||
quote! {
|
||||
Some( <<#ty as #crate_::RIType>::FFIType as #crate_::wasm_interface::IntoValue>::VALUE_TYPE )
|
||||
Some( <<#ty as #crate_::RIType>::FFIType as #crate_::sp_wasm_interface::IntoValue>::VALUE_TYPE )
|
||||
},
|
||||
ReturnType::Default => quote!( None ),
|
||||
};
|
||||
let arg_types = get_function_argument_types_without_ref(sig)
|
||||
.map(|ty| quote! {
|
||||
<<#ty as #crate_::RIType>::FFIType as #crate_::wasm_interface::IntoValue>::VALUE_TYPE
|
||||
<<#ty as #crate_::RIType>::FFIType as #crate_::sp_wasm_interface::IntoValue>::VALUE_TYPE
|
||||
});
|
||||
|
||||
Ok(
|
||||
quote! {
|
||||
#crate_::wasm_interface::Signature {
|
||||
#crate_::sp_wasm_interface::Signature {
|
||||
args: std::borrow::Cow::Borrowed(&[ #( #arg_types ),* ][..]),
|
||||
return_value: #return_value,
|
||||
}
|
||||
@@ -292,7 +292,7 @@ fn generate_wasm_to_ffi_values<'a>(
|
||||
Ok(quote! {
|
||||
let val = args.next().ok_or_else(|| #error_message)?;
|
||||
let #var_name = <
|
||||
<#ty as #crate_::RIType>::FFIType as #crate_::wasm_interface::TryFromValue
|
||||
<#ty as #crate_::RIType>::FFIType as #crate_::sp_wasm_interface::TryFromValue
|
||||
>::try_from_value(val).ok_or_else(|| #try_from_error)?;
|
||||
})
|
||||
})
|
||||
@@ -408,7 +408,7 @@ fn generate_return_value_into_wasm_value(sig: &Signature) -> TokenStream {
|
||||
<#ty as #crate_::host::IntoFFIValue>::into_ffi_value(
|
||||
#result_var_name,
|
||||
__function_context__,
|
||||
).map(#crate_::wasm_interface::IntoValue::into_value).map(Some)
|
||||
).map(#crate_::sp_wasm_interface::IntoValue::into_value).map(Some)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ fn impl_trait_for_externalities(trait_def: &ItemTrait, is_wasm_only: bool) -> Re
|
||||
});
|
||||
|
||||
let impl_type = if is_wasm_only {
|
||||
quote!( &mut dyn #crate_::wasm_interface::FunctionContext )
|
||||
quote!( &mut dyn #crate_::sp_wasm_interface::FunctionContext )
|
||||
} else {
|
||||
quote!( &mut dyn #crate_::Externalities )
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::RIType;
|
||||
|
||||
use wasm_interface::{FunctionContext, Result};
|
||||
use sp_wasm_interface::{FunctionContext, Result};
|
||||
|
||||
/// Something that can be converted into a ffi value.
|
||||
pub trait IntoFFIValue: RIType {
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::wasm::*;
|
||||
use static_assertions::assert_eq_size;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use wasm_interface::{FunctionContext, Result};
|
||||
use sp_wasm_interface::{FunctionContext, Result};
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
@@ -448,7 +448,7 @@ impl IntoFFIValue for str {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: wasm_interface::PointerType> RIType for Pointer<T> {
|
||||
impl<T: sp_wasm_interface::PointerType> RIType for Pointer<T> {
|
||||
type FFIType = u32;
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ impl<T> FromFFIValue for Pointer<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: wasm_interface::PointerType> FromFFIValue for Pointer<T> {
|
||||
impl<T: sp_wasm_interface::PointerType> FromFFIValue for Pointer<T> {
|
||||
type SelfInstance = Self;
|
||||
|
||||
fn from_ffi_value(_: &mut dyn FunctionContext, arg: u32) -> Result<Self> {
|
||||
@@ -484,7 +484,7 @@ impl<T: wasm_interface::PointerType> FromFFIValue for Pointer<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: wasm_interface::PointerType> IntoFFIValue for Pointer<T> {
|
||||
impl<T: sp_wasm_interface::PointerType> IntoFFIValue for Pointer<T> {
|
||||
fn into_ffi_value(self, _: &mut dyn FunctionContext) -> Result<u32> {
|
||||
Ok(self.into())
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ extern crate self as sp_runtime_interface;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "std")]
|
||||
pub use wasm_interface;
|
||||
pub use sp_wasm_interface;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use sp_std;
|
||||
@@ -130,7 +130,7 @@ pub use sp_std;
|
||||
/// fn set_or_clear(&mut self, optional: Option<Vec<u8>>);
|
||||
/// }
|
||||
///
|
||||
/// impl Interface for &mut dyn externalities::Externalities {
|
||||
/// impl Interface for &mut dyn sp_externalities::Externalities {
|
||||
/// fn call_some_complex_code(data: &[u8]) -> Vec<u8> { Vec::new() }
|
||||
/// fn set_or_clear(&mut self, optional: Option<Vec<u8>>) {
|
||||
/// match optional {
|
||||
@@ -141,11 +141,11 @@ pub use sp_std;
|
||||
/// }
|
||||
///
|
||||
/// pub fn call_some_complex_code(data: &[u8]) -> Vec<u8> {
|
||||
/// <&mut dyn externalities::Externalities as Interface>::call_some_complex_code(data)
|
||||
/// <&mut dyn sp_externalities::Externalities as Interface>::call_some_complex_code(data)
|
||||
/// }
|
||||
///
|
||||
/// pub fn set_or_clear(optional: Option<Vec<u8>>) {
|
||||
/// externalities::with_externalities(|mut ext| Interface::set_or_clear(&mut ext, optional))
|
||||
/// sp_externalities::with_externalities(|mut ext| Interface::set_or_clear(&mut ext, optional))
|
||||
/// .expect("`set_or_clear` called outside of an Externalities-provided environment.")
|
||||
/// }
|
||||
///
|
||||
@@ -227,7 +227,7 @@ pub use sp_runtime_interface_proc_macro::runtime_interface;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "std")]
|
||||
pub use externalities::{
|
||||
pub use sp_externalities::{
|
||||
set_and_run_with_externalities, with_externalities, Externalities, ExternalitiesExt, ExtensionStore,
|
||||
};
|
||||
|
||||
@@ -249,7 +249,7 @@ pub mod pass_by;
|
||||
pub trait RIType {
|
||||
/// The ffi type that is used to represent `Self`.
|
||||
#[cfg(feature = "std")]
|
||||
type FFIType: wasm_interface::IntoValue + wasm_interface::TryFromValue;
|
||||
type FFIType: sp_wasm_interface::IntoValue + sp_wasm_interface::TryFromValue;
|
||||
#[cfg(not(feature = "std"))]
|
||||
type FFIType;
|
||||
}
|
||||
@@ -260,4 +260,4 @@ pub type Pointer<T> = *mut T;
|
||||
|
||||
/// A pointer that can be used in a runtime interface function signature.
|
||||
#[cfg(feature = "std")]
|
||||
pub type Pointer<T> = wasm_interface::Pointer<T>;
|
||||
pub type Pointer<T> = sp_wasm_interface::Pointer<T>;
|
||||
@@ -28,7 +28,7 @@ use crate::host::*;
|
||||
use crate::wasm::*;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use wasm_interface::{FunctionContext, Pointer, Result};
|
||||
use sp_wasm_interface::{FunctionContext, Pointer, Result};
|
||||
|
||||
use sp_std::{marker::PhantomData, convert::TryFrom};
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
runtime-interface = { package = "sp-runtime-interface", path = "../", default-features = false }
|
||||
sp-runtime-interface = { path = "../", default-features = false }
|
||||
sp-std = { path = "../../std", default-features = false }
|
||||
sp-io = { path = "../../io", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../core", default-features = false }
|
||||
sp-core = { path = "../../core", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3", path = "../../../utils/wasm-builder-runner" }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [ "runtime-interface/std", "sp-std/std", "primitives/std", "sp-io/std" ]
|
||||
std = [ "sp-runtime-interface/std", "sp-std/std", "sp-core/std", "sp-io/std" ]
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use runtime_interface::runtime_interface;
|
||||
use sp_runtime_interface::runtime_interface;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use sp_std::{vec, vec::Vec, mem, convert::TryFrom};
|
||||
|
||||
use primitives::{sr25519::Public, wasm_export_functions};
|
||||
use sp_core::{sr25519::Public, wasm_export_functions};
|
||||
|
||||
// Inlucde the WASM binary
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -7,8 +7,8 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
sp-runtime-interface = { path = "../" }
|
||||
executor = { package = "sc-executor", path = "../../../client/executor" }
|
||||
test-wasm = { package = "sp-runtime-interface-test-wasm", path = "../test-wasm" }
|
||||
state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" }
|
||||
primitives = { package = "sp-core", path = "../../core" }
|
||||
sc-executor = { path = "../../../client/executor" }
|
||||
sp-runtime-interface-test-wasm = { path = "../test-wasm" }
|
||||
sp-state-machine = { path = "../../../primitives/state-machine" }
|
||||
sp-core = { path = "../../core" }
|
||||
sp-io = { path = "../../io" }
|
||||
|
||||
@@ -17,26 +17,26 @@
|
||||
//! Integration tests for runtime interface primitives
|
||||
|
||||
use sp_runtime_interface::*;
|
||||
use test_wasm::{WASM_BINARY, test_api::HostFunctions};
|
||||
use wasm_interface::HostFunctions as HostFunctionsT;
|
||||
use sp_runtime_interface_test_wasm::{WASM_BINARY, test_api::HostFunctions};
|
||||
use sp_wasm_interface::HostFunctions as HostFunctionsT;
|
||||
|
||||
type TestExternalities = state_machine::TestExternalities<primitives::Blake2Hasher, u64>;
|
||||
type TestExternalities = sp_state_machine::TestExternalities<sp_core::Blake2Hasher, u64>;
|
||||
|
||||
fn call_wasm_method<HF: HostFunctionsT>(method: &str) -> TestExternalities {
|
||||
let mut ext = TestExternalities::default();
|
||||
let mut ext_ext = ext.ext();
|
||||
|
||||
executor::call_in_wasm::<
|
||||
sc_executor::call_in_wasm::<
|
||||
_,
|
||||
(
|
||||
HF,
|
||||
sp_io::SubstrateHostFunctions,
|
||||
executor::deprecated_host_interface::SubstrateExternals
|
||||
sc_executor::deprecated_host_interface::SubstrateExternals
|
||||
)
|
||||
>(
|
||||
method,
|
||||
&[],
|
||||
executor::WasmExecutionMethod::Interpreted,
|
||||
sc_executor::WasmExecutionMethod::Interpreted,
|
||||
&mut ext_ext,
|
||||
&WASM_BINARY[..],
|
||||
8,
|
||||
|
||||
@@ -7,16 +7,16 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "sp-core", path = "../core", default-features = false }
|
||||
app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false }
|
||||
arithmetic = { package = "sp-arithmetic", path = "../arithmetic", default-features = false }
|
||||
sp-core = { path = "../core", default-features = false }
|
||||
sp-application-crypto = { path = "../application-crypto", default-features = false }
|
||||
sp-arithmetic = { path = "../arithmetic", default-features = false }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
sp-io = { path = "../io", default-features = false }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
paste = "0.1.6"
|
||||
rand = { version = "0.7.2", optional = true }
|
||||
impl-trait-for-tuples = "0.1.3"
|
||||
inherents = { package = "sp-inherents", path = "../inherents", default-features = false }
|
||||
sp-inherents = { path = "../inherents", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.41"
|
||||
@@ -26,14 +26,14 @@ rand = "0.7.2"
|
||||
bench = []
|
||||
default = ["std"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"arithmetic/std",
|
||||
"sp-application-crypto/std",
|
||||
"sp-arithmetic/std",
|
||||
"codec/std",
|
||||
"log",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"rand",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"serde",
|
||||
"inherents/std",
|
||||
"sp-inherents/std",
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::{Perbill, traits::{SimpleArithmetic, SaturatedConversion}};
|
||||
use core::ops::Sub;
|
||||
|
||||
/// Piecewise Linear function in [0, 1] -> [0, 1].
|
||||
#[derive(PartialEq, Eq, primitives::RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, sp_core::RuntimeDebug)]
|
||||
pub struct PiecewiseLinear<'a> {
|
||||
/// Array of points. Must be in order from the lowest abscissas to the highest.
|
||||
pub points: &'a [(Perbill, Perbill)],
|
||||
|
||||
@@ -23,7 +23,7 @@ use std::fmt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use primitives::RuntimeDebug;
|
||||
use sp_core::RuntimeDebug;
|
||||
use crate::codec::{Codec, Encode, Decode};
|
||||
use crate::traits::{self, Member, Block as BlockT, Header as HeaderT, MaybeSerialize};
|
||||
use crate::Justification;
|
||||
|
||||
@@ -27,7 +27,7 @@ use crate::transaction_validity::TransactionValidity;
|
||||
/// Definition of something that the external world might want to say; its
|
||||
/// existence implies that it has been checked and is good, particularly with
|
||||
/// regards to the signature.
|
||||
#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Clone, sp_core::RuntimeDebug)]
|
||||
pub struct CheckedExtrinsic<AccountId, Call, Extra> {
|
||||
/// Who this purports to be from and the number of extrinsics have come before
|
||||
/// from the same signer, if anyone (note this is not a signature).
|
||||
|
||||
@@ -23,7 +23,7 @@ use sp_std::prelude::*;
|
||||
|
||||
use crate::ConsensusEngineId;
|
||||
use crate::codec::{Decode, Encode, Input, Error};
|
||||
use primitives::RuntimeDebug;
|
||||
use sp_core::RuntimeDebug;
|
||||
|
||||
/// Generic header digest.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
@@ -105,7 +105,7 @@ pub enum DigestItem<Hash> {
|
||||
impl<Hash: Encode> serde::Serialize for DigestItem<Hash> {
|
||||
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
|
||||
self.using_encoded(|bytes| {
|
||||
primitives::bytes::serialize(bytes, seq)
|
||||
sp_core::bytes::serialize(bytes, seq)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ impl<'a, Hash: Decode> serde::Deserialize<'a> for DigestItem<Hash> {
|
||||
fn deserialize<D>(de: D) -> Result<Self, D::Error> where
|
||||
D: serde::Deserializer<'a>,
|
||||
{
|
||||
let r = primitives::bytes::deserialize(de)?;
|
||||
let r = sp_core::bytes::deserialize(de)?;
|
||||
Decode::decode(&mut &r[..])
|
||||
.map_err(|e| serde::de::Error::custom(format!("Decode error: {}", e)))
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub type Period = u64;
|
||||
pub type Phase = u64;
|
||||
|
||||
/// An era to describe the longevity of a transaction.
|
||||
#[derive(PartialEq, Eq, Clone, Copy, primitives::RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, sp_core::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub enum Era {
|
||||
/// The transaction is valid forever. The genesis hash must be present in the signed content.
|
||||
|
||||
@@ -24,14 +24,14 @@ use crate::traits::{
|
||||
MaybeSerializeDeserialize, MaybeSerialize, MaybeDisplay,
|
||||
};
|
||||
use crate::generic::Digest;
|
||||
use primitives::U256;
|
||||
use sp_core::U256;
|
||||
use sp_std::{
|
||||
convert::TryFrom,
|
||||
fmt::Debug,
|
||||
};
|
||||
|
||||
/// Abstraction over a block header for a substrate chain.
|
||||
#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Clone, sp_core::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Tests for the generic implementations of Extrinsic/Header/Block.
|
||||
|
||||
use crate::codec::{Decode, Encode};
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use super::DigestItem;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -35,14 +35,14 @@ pub use sp_std;
|
||||
pub use paste;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use app_crypto;
|
||||
pub use sp_application_crypto as app_crypto;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use primitives::storage::{Storage, StorageChild};
|
||||
pub use sp_core::storage::{Storage, StorageChild};
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::convert::TryFrom;
|
||||
use primitives::{crypto, ed25519, sr25519, ecdsa, hash::{H256, H512}};
|
||||
use sp_core::{crypto, ed25519, sr25519, ecdsa, hash::{H256, H512}};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
pub mod curve;
|
||||
@@ -58,18 +58,18 @@ pub mod random_number_generator;
|
||||
pub use generic::{DigestItem, Digest};
|
||||
|
||||
/// Re-export this since it's part of the API of this crate.
|
||||
pub use primitives::{TypeId, crypto::{key_types, KeyTypeId, CryptoType, AccountId32}};
|
||||
pub use app_crypto::{RuntimeAppPublic, BoundToRuntimeAppPublic};
|
||||
pub use sp_core::{TypeId, crypto::{key_types, KeyTypeId, CryptoType, AccountId32}};
|
||||
pub use sp_application_crypto::{RuntimeAppPublic, BoundToRuntimeAppPublic};
|
||||
|
||||
/// Re-export `RuntimeDebug`, to avoid dependency clutter.
|
||||
pub use primitives::RuntimeDebug;
|
||||
pub use sp_core::RuntimeDebug;
|
||||
|
||||
/// Re-export top-level arithmetic stuff.
|
||||
pub use arithmetic::{Perquintill, Perbill, Permill, Percent, Rational128, Fixed64};
|
||||
pub use sp_arithmetic::{Perquintill, Perbill, Permill, Percent, Rational128, Fixed64};
|
||||
/// Re-export 128 bit helpers.
|
||||
pub use arithmetic::helpers_128bit;
|
||||
pub use sp_arithmetic::helpers_128bit;
|
||||
/// Re-export big_uint stuff.
|
||||
pub use arithmetic::biguint;
|
||||
pub use sp_arithmetic::biguint;
|
||||
|
||||
pub use random_number_generator::RandomNumberGenerator;
|
||||
|
||||
@@ -121,7 +121,7 @@ use crate::traits::IdentifyAccount;
|
||||
#[cfg(feature = "std")]
|
||||
pub trait BuildStorage: Sized {
|
||||
/// Build the storage out of this builder.
|
||||
fn build_storage(&self) -> Result<primitives::storage::Storage, String> {
|
||||
fn build_storage(&self) -> Result<sp_core::storage::Storage, String> {
|
||||
let mut storage = Default::default();
|
||||
self.assimilate_storage(&mut storage)?;
|
||||
Ok(storage)
|
||||
@@ -129,7 +129,7 @@ pub trait BuildStorage: Sized {
|
||||
/// Assimilate the storage for this module into pre-existing overlays.
|
||||
fn assimilate_storage(
|
||||
&self,
|
||||
storage: &mut primitives::storage::Storage,
|
||||
storage: &mut sp_core::storage::Storage,
|
||||
) -> Result<(), String>;
|
||||
}
|
||||
|
||||
@@ -139,15 +139,15 @@ pub trait BuildModuleGenesisStorage<T, I>: Sized {
|
||||
/// Create the module genesis storage into the given `storage` and `child_storage`.
|
||||
fn build_module_genesis_storage(
|
||||
&self,
|
||||
storage: &mut primitives::storage::Storage,
|
||||
storage: &mut sp_core::storage::Storage,
|
||||
) -> Result<(), String>;
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl BuildStorage for primitives::storage::Storage {
|
||||
impl BuildStorage for sp_core::storage::Storage {
|
||||
fn assimilate_storage(
|
||||
&self,
|
||||
storage: &mut primitives::storage::Storage,
|
||||
storage: &mut sp_core::storage::Storage,
|
||||
)-> Result<(), String> {
|
||||
storage.top.extend(self.top.iter().map(|(k, v)| (k.clone(), v.clone())));
|
||||
for (k, other_map) in self.children.iter() {
|
||||
@@ -304,7 +304,7 @@ impl std::fmt::Display for MultiSigner {
|
||||
impl Verify for MultiSignature {
|
||||
type Signer = MultiSigner;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &AccountId32) -> bool {
|
||||
use primitives::crypto::Public;
|
||||
use sp_core::crypto::Public;
|
||||
match (self, signer) {
|
||||
(MultiSignature::Ed25519(ref sig), who) => sig.verify(msg, &ed25519::Public::from_slice(who.as_ref())),
|
||||
(MultiSignature::Sr25519(ref sig), who) => sig.verify(msg, &sr25519::Public::from_slice(who.as_ref())),
|
||||
@@ -329,7 +329,7 @@ pub struct AnySignature(H512);
|
||||
impl Verify for AnySignature {
|
||||
type Signer = sr25519::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &sr25519::Public) -> bool {
|
||||
use primitives::crypto::Public;
|
||||
use sp_core::crypto::Public;
|
||||
let msg = msg.get();
|
||||
sr25519::Signature::try_from(self.0.as_fixed_bytes().as_ref())
|
||||
.map(|s| s.verify(msg, signer))
|
||||
@@ -619,7 +619,7 @@ pub struct OpaqueExtrinsic(pub Vec<u8>);
|
||||
impl sp_std::fmt::Debug for OpaqueExtrinsic {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
||||
write!(fmt, "{}", primitives::hexdisplay::HexDisplay::from(&self.0))
|
||||
write!(fmt, "{}", sp_core::hexdisplay::HexDisplay::from(&self.0))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
@@ -632,14 +632,14 @@ impl sp_std::fmt::Debug for OpaqueExtrinsic {
|
||||
#[cfg(feature = "std")]
|
||||
impl ::serde::Serialize for OpaqueExtrinsic {
|
||||
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error> where S: ::serde::Serializer {
|
||||
codec::Encode::using_encoded(&self.0, |bytes| ::primitives::bytes::serialize(bytes, seq))
|
||||
codec::Encode::using_encoded(&self.0, |bytes| ::sp_core::bytes::serialize(bytes, seq))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<'a> ::serde::Deserialize<'a> for OpaqueExtrinsic {
|
||||
fn deserialize<D>(de: D) -> Result<Self, D::Error> where D: ::serde::Deserializer<'a> {
|
||||
let r = ::primitives::bytes::deserialize(de)?;
|
||||
let r = ::sp_core::bytes::deserialize(de)?;
|
||||
Decode::decode(&mut &r[..])
|
||||
.map_err(|e| ::serde::de::Error::custom(format!("Decode error: {}", e)))
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ use sp_std::str;
|
||||
use sp_std::prelude::Vec;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use sp_std::prelude::vec;
|
||||
use primitives::RuntimeDebug;
|
||||
use primitives::offchain::{
|
||||
use sp_core::RuntimeDebug;
|
||||
use sp_core::offchain::{
|
||||
Timestamp,
|
||||
HttpRequestId as RequestId,
|
||||
HttpRequestStatus as RequestStatus,
|
||||
@@ -516,7 +516,7 @@ impl<'a> HeadersIterator<'a> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sp_io::TestExternalities;
|
||||
use primitives::offchain::{
|
||||
use sp_core::offchain::{
|
||||
OffchainExt,
|
||||
testing,
|
||||
};
|
||||
|
||||
@@ -26,8 +26,8 @@ use crate::traits::{
|
||||
#[allow(deprecated)]
|
||||
use crate::traits::ValidateUnsigned;
|
||||
use crate::{generic, KeyTypeId, ApplyExtrinsicResult};
|
||||
pub use primitives::{H256, sr25519};
|
||||
use primitives::{crypto::{CryptoType, Dummy, key_types, Public}, U256};
|
||||
pub use sp_core::{H256, sr25519};
|
||||
use sp_core::{crypto::{CryptoType, Dummy, key_types, Public}, U256};
|
||||
use crate::transaction_validity::{TransactionValidity, TransactionValidityError};
|
||||
|
||||
/// Authority Id
|
||||
@@ -80,7 +80,7 @@ impl UintAuthorityId {
|
||||
}
|
||||
}
|
||||
|
||||
impl app_crypto::RuntimeAppPublic for UintAuthorityId {
|
||||
impl sp_application_crypto::RuntimeAppPublic for UintAuthorityId {
|
||||
const ID: KeyTypeId = key_types::DUMMY;
|
||||
|
||||
type Signature = u64;
|
||||
|
||||
@@ -23,18 +23,18 @@ use sp_io;
|
||||
use std::fmt::Display;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Deserialize, de::DeserializeOwned};
|
||||
use primitives::{self, Hasher, Blake2Hasher, TypeId};
|
||||
use sp_core::{self, Hasher, Blake2Hasher, TypeId};
|
||||
use crate::codec::{Codec, Encode, Decode};
|
||||
use crate::transaction_validity::{
|
||||
ValidTransaction, TransactionValidity, TransactionValidityError, UnknownTransaction,
|
||||
};
|
||||
use crate::generic::{Digest, DigestItem};
|
||||
pub use arithmetic::traits::{
|
||||
pub use sp_arithmetic::traits::{
|
||||
SimpleArithmetic, UniqueSaturatedInto, UniqueSaturatedFrom, Saturating, SaturatedConversion,
|
||||
Zero, One, Bounded, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv,
|
||||
CheckedShl, CheckedShr, IntegerSquareRoot
|
||||
};
|
||||
use app_crypto::AppKey;
|
||||
use sp_application_crypto::AppKey;
|
||||
use impl_trait_for_tuples::impl_for_tuples;
|
||||
|
||||
/// A lazy value.
|
||||
@@ -58,17 +58,17 @@ pub trait IdentifyAccount {
|
||||
fn into_account(self) -> Self::AccountId;
|
||||
}
|
||||
|
||||
impl IdentifyAccount for primitives::ed25519::Public {
|
||||
impl IdentifyAccount for sp_core::ed25519::Public {
|
||||
type AccountId = Self;
|
||||
fn into_account(self) -> Self { self }
|
||||
}
|
||||
|
||||
impl IdentifyAccount for primitives::sr25519::Public {
|
||||
impl IdentifyAccount for sp_core::sr25519::Public {
|
||||
type AccountId = Self;
|
||||
fn into_account(self) -> Self { self }
|
||||
}
|
||||
|
||||
impl IdentifyAccount for primitives::ecdsa::Public {
|
||||
impl IdentifyAccount for sp_core::ecdsa::Public {
|
||||
type AccountId = Self;
|
||||
fn into_account(self) -> Self { self }
|
||||
}
|
||||
@@ -81,23 +81,23 @@ pub trait Verify {
|
||||
fn verify<L: Lazy<[u8]>>(&self, msg: L, signer: &<Self::Signer as IdentifyAccount>::AccountId) -> bool;
|
||||
}
|
||||
|
||||
impl Verify for primitives::ed25519::Signature {
|
||||
type Signer = primitives::ed25519::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &primitives::ed25519::Public) -> bool {
|
||||
impl Verify for sp_core::ed25519::Signature {
|
||||
type Signer = sp_core::ed25519::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &sp_core::ed25519::Public) -> bool {
|
||||
sp_io::crypto::ed25519_verify(self, msg.get(), signer)
|
||||
}
|
||||
}
|
||||
|
||||
impl Verify for primitives::sr25519::Signature {
|
||||
type Signer = primitives::sr25519::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &primitives::sr25519::Public) -> bool {
|
||||
impl Verify for sp_core::sr25519::Signature {
|
||||
type Signer = sp_core::sr25519::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &sp_core::sr25519::Public) -> bool {
|
||||
sp_io::crypto::sr25519_verify(self, msg.get(), signer)
|
||||
}
|
||||
}
|
||||
|
||||
impl Verify for primitives::ecdsa::Signature {
|
||||
type Signer = primitives::ecdsa::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &primitives::ecdsa::Public) -> bool {
|
||||
impl Verify for sp_core::ecdsa::Signature {
|
||||
type Signer = sp_core::ecdsa::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &sp_core::ecdsa::Public) -> bool {
|
||||
match sp_io::crypto::secp256k1_ecdsa_recover_compressed(
|
||||
self.as_ref(),
|
||||
&sp_io::hashing::blake2_256(msg.get()),
|
||||
@@ -117,19 +117,19 @@ pub trait AppVerify {
|
||||
}
|
||||
|
||||
impl<
|
||||
S: Verify<Signer=<<T as AppKey>::Public as app_crypto::AppPublic>::Generic> + From<T>,
|
||||
T: app_crypto::Wraps<Inner=S> + app_crypto::AppKey + app_crypto::AppSignature +
|
||||
S: Verify<Signer=<<T as AppKey>::Public as sp_application_crypto::AppPublic>::Generic> + From<T>,
|
||||
T: sp_application_crypto::Wraps<Inner=S> + sp_application_crypto::AppKey + sp_application_crypto::AppSignature +
|
||||
AsRef<S> + AsMut<S> + From<S>,
|
||||
> AppVerify for T where
|
||||
<S as Verify>::Signer: IdentifyAccount<AccountId = <S as Verify>::Signer>,
|
||||
<<T as AppKey>::Public as app_crypto::AppPublic>::Generic:
|
||||
IdentifyAccount<AccountId = <<T as AppKey>::Public as app_crypto::AppPublic>::Generic>,
|
||||
<<T as AppKey>::Public as sp_application_crypto::AppPublic>::Generic:
|
||||
IdentifyAccount<AccountId = <<T as AppKey>::Public as sp_application_crypto::AppPublic>::Generic>,
|
||||
{
|
||||
type AccountId = <T as AppKey>::Public;
|
||||
fn verify<L: Lazy<[u8]>>(&self, msg: L, signer: &<T as AppKey>::Public) -> bool {
|
||||
use app_crypto::IsWrappedBy;
|
||||
use sp_application_crypto::IsWrappedBy;
|
||||
let inner: &S = self.as_ref();
|
||||
let inner_pubkey = <<T as AppKey>::Public as app_crypto::AppPublic>::Generic::from_ref(&signer);
|
||||
let inner_pubkey = <<T as AppKey>::Public as sp_application_crypto::AppPublic>::Generic::from_ref(&signer);
|
||||
Verify::verify(inner, msg, inner_pubkey)
|
||||
}
|
||||
}
|
||||
@@ -391,12 +391,12 @@ pub trait Hash: 'static + MaybeSerializeDeserialize + Debug + Clone + Eq + Parti
|
||||
}
|
||||
|
||||
/// Blake2-256 Hash implementation.
|
||||
#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Clone, sp_core::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub struct BlakeTwo256;
|
||||
|
||||
impl Hash for BlakeTwo256 {
|
||||
type Output = primitives::H256;
|
||||
type Output = sp_core::H256;
|
||||
type Hasher = Blake2Hasher;
|
||||
fn hash(s: &[u8]) -> Self::Output {
|
||||
sp_io::hashing::blake2_256(s).into()
|
||||
@@ -417,10 +417,10 @@ pub trait CheckEqual {
|
||||
fn check_equal(&self, other: &Self);
|
||||
}
|
||||
|
||||
impl CheckEqual for primitives::H256 {
|
||||
impl CheckEqual for sp_core::H256 {
|
||||
#[cfg(feature = "std")]
|
||||
fn check_equal(&self, other: &Self) {
|
||||
use primitives::hexdisplay::HexDisplay;
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
if self != other {
|
||||
println!(
|
||||
"Hash: given={}, expected={}",
|
||||
@@ -1281,8 +1281,8 @@ mod tests {
|
||||
use crate::codec::{Encode, Decode, Input};
|
||||
|
||||
mod t {
|
||||
use primitives::crypto::KeyTypeId;
|
||||
use app_crypto::{app_crypto, sr25519};
|
||||
use sp_core::crypto::KeyTypeId;
|
||||
use sp_application_crypto::{app_crypto, sr25519};
|
||||
app_crypto!(sr25519, KeyTypeId(*b"test"));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmi = { version = "0.6.2", optional = true }
|
||||
primitives = { package = "sp-core", path = "../core", default-features = false }
|
||||
sp-core = { path = "../core", default-features = false }
|
||||
sp-std = { path = "../std", default-features = false }
|
||||
sp-io = { path = "../io", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
@@ -19,7 +19,7 @@ assert_matches = "1.3.0"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"wasmi",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"codec/std",
|
||||
"sp-io/std",
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
|
||||
pub use primitives::sandbox::{TypedValue, ReturnValue, HostError};
|
||||
pub use sp_core::sandbox::{TypedValue, ReturnValue, HostError};
|
||||
|
||||
mod imp {
|
||||
#[cfg(feature = "std")]
|
||||
@@ -51,7 +51,7 @@ mod imp {
|
||||
}
|
||||
|
||||
/// Error that can occur while using this crate.
|
||||
#[derive(primitives::RuntimeDebug)]
|
||||
#[derive(sp_core::RuntimeDebug)]
|
||||
pub enum Error {
|
||||
/// Module is not valid, couldn't be instantiated.
|
||||
Module,
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use sp_std::{prelude::*, slice, marker, mem, vec, rc::Rc};
|
||||
use codec::{Decode, Encode};
|
||||
use primitives::sandbox as sandbox_primitives;
|
||||
use super::{Error, TypedValue, ReturnValue, HostFuncType};
|
||||
use sp_core::sandbox as sandbox_primitives;
|
||||
use sp_io::sandbox;
|
||||
use sp_std::{prelude::*, slice, marker, mem, vec, rc::Rc};
|
||||
use super::{Error, TypedValue, ReturnValue, HostFuncType};
|
||||
|
||||
mod ffi {
|
||||
use sp_std::mem;
|
||||
|
||||
@@ -11,13 +11,13 @@ parking_lot = "0.9.0"
|
||||
hash-db = "0.15.2"
|
||||
trie-db = "0.16.0"
|
||||
trie-root = "0.15.2"
|
||||
trie = { package = "sp-trie", path = "../trie" }
|
||||
primitives = { package = "sp-core", path = "../core" }
|
||||
panic-handler = { package = "sp-panic-handler", path = "../panic-handler" }
|
||||
sp-trie = { path = "../trie" }
|
||||
sp-core = { path = "../core" }
|
||||
sp-panic-handler = { path = "../panic-handler" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
num-traits = "0.2.8"
|
||||
rand = "0.7.2"
|
||||
externalities = { package = "sp-externalities", path = "../externalities" }
|
||||
sp-externalities = { path = "../externalities" }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.2.1"
|
||||
|
||||
@@ -21,12 +21,12 @@ use log::warn;
|
||||
use hash_db::Hasher;
|
||||
use crate::trie_backend::TrieBackend;
|
||||
use crate::trie_backend_essence::TrieBackendStorage;
|
||||
use trie::{
|
||||
use sp_trie::{
|
||||
TrieMut, MemoryDB, child_trie_root, default_child_trie_root, TrieConfiguration,
|
||||
trie_types::{TrieDBMut, Layout},
|
||||
};
|
||||
use codec::{Encode, Codec};
|
||||
use primitives::storage::{ChildInfo, OwnedChildInfo, Storage};
|
||||
use sp_core::storage::{ChildInfo, OwnedChildInfo, Storage};
|
||||
|
||||
/// A state backend is used to read state data and can have changes committed
|
||||
/// to it.
|
||||
@@ -311,9 +311,9 @@ impl Consolidate for Vec<(
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: Hasher, KF: trie::KeyFunction<H>> Consolidate for trie::GenericMemoryDB<H, KF> {
|
||||
impl<H: Hasher, KF: sp_trie::KeyFunction<H>> Consolidate for sp_trie::GenericMemoryDB<H, KF> {
|
||||
fn consolidate(&mut self, other: Self) {
|
||||
trie::GenericMemoryDB::consolidate(self, other)
|
||||
sp_trie::GenericMemoryDB::consolidate(self, other)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ impl<H: Hasher> Backend<H> for InMemory<H> where H::Out: Codec {
|
||||
let storage_key = storage_key.to_vec();
|
||||
let child_info = Some((storage_key.clone(), child_info.to_owned()));
|
||||
|
||||
|
||||
|
||||
let existing_pairs = self.inner.get(&child_info)
|
||||
.into_iter()
|
||||
.flat_map(|map| map.iter().map(|(k, v)| (k.clone(), Some(v.clone()))));
|
||||
@@ -667,7 +667,7 @@ mod tests {
|
||||
/// Assert in memory backend with only child trie keys works as trie backend.
|
||||
#[test]
|
||||
fn in_memory_with_child_trie_only() {
|
||||
let storage = InMemory::<primitives::Blake2Hasher>::default();
|
||||
let storage = InMemory::<sp_core::Blake2Hasher>::default();
|
||||
let child_info = OwnedChildInfo::new_default(b"unique_id_1".to_vec());
|
||||
let mut storage = storage.update(
|
||||
vec![(
|
||||
|
||||
@@ -21,9 +21,9 @@ use std::{
|
||||
};
|
||||
use crate::backend::{Backend, InMemory};
|
||||
use hash_db::Hasher;
|
||||
use trie::{TrieConfiguration, default_child_trie_root};
|
||||
use trie::trie_types::Layout;
|
||||
use primitives::{
|
||||
use sp_trie::{TrieConfiguration, default_child_trie_root};
|
||||
use sp_trie::trie_types::Layout;
|
||||
use sp_core::{
|
||||
storage::{
|
||||
well_known_keys::is_child_storage_key, ChildStorageKey, Storage,
|
||||
ChildInfo, StorageChild,
|
||||
@@ -59,7 +59,7 @@ impl BasicExternalities {
|
||||
///
|
||||
/// Returns the result of the closure and updates `storage` with all changes.
|
||||
pub fn execute_with_storage<R>(
|
||||
storage: &mut primitives::storage::Storage,
|
||||
storage: &mut sp_core::storage::Storage,
|
||||
f: impl FnOnce() -> R,
|
||||
) -> R {
|
||||
let mut ext = Self { inner: Storage {
|
||||
@@ -78,7 +78,7 @@ impl BasicExternalities {
|
||||
///
|
||||
/// Returns the result of the given closure.
|
||||
pub fn execute_with<R>(&mut self, f: impl FnOnce() -> R) -> R {
|
||||
externalities::set_and_run_with_externalities(self, f)
|
||||
sp_externalities::set_and_run_with_externalities(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ impl Externalities for BasicExternalities {
|
||||
}
|
||||
}
|
||||
|
||||
impl externalities::ExtensionStore for BasicExternalities {
|
||||
impl sp_externalities::ExtensionStore for BasicExternalities {
|
||||
fn extension_by_type_id(&mut self, _: TypeId) -> Option<&mut dyn Any> {
|
||||
warn!("Extensions are not supported by `BasicExternalities`.");
|
||||
None
|
||||
@@ -310,9 +310,9 @@ impl externalities::ExtensionStore for BasicExternalities {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::map;
|
||||
use primitives::storage::{Storage, StorageChild};
|
||||
use primitives::storage::well_known_keys::CODE;
|
||||
use sp_core::map;
|
||||
use sp_core::storage::{Storage, StorageChild};
|
||||
use sp_core::storage::well_known_keys::CODE;
|
||||
use hex_literal::hex;
|
||||
|
||||
const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1");
|
||||
|
||||
@@ -153,7 +153,7 @@ fn prepare_extrinsics_input_inner<'a, B, H, Number>(
|
||||
// AND are not in storage at the beginning of operation
|
||||
if let Some(sk) = storage_key.as_ref() {
|
||||
if !changes.child_storage(sk, k).map(|v| v.is_some()).unwrap_or_default() {
|
||||
if let Some(child_info) = child_info.as_ref() {
|
||||
if let Some(child_info) = child_info.as_ref() {
|
||||
if !backend.exists_child_storage(sk, child_info.as_ref(), k)
|
||||
.map_err(|e| format!("{}", e))? {
|
||||
return Ok(map);
|
||||
@@ -338,9 +338,9 @@ fn prepare_digest_input<'a, H, Number>(
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use codec::Encode;
|
||||
use primitives::Blake2Hasher;
|
||||
use primitives::storage::well_known_keys::{EXTRINSIC_INDEX};
|
||||
use primitives::storage::ChildInfo;
|
||||
use sp_core::Blake2Hasher;
|
||||
use sp_core::storage::well_known_keys::{EXTRINSIC_INDEX};
|
||||
use sp_core::storage::ChildInfo;
|
||||
use crate::backend::InMemory;
|
||||
use crate::changes_trie::{RootsStorage, Configuration, storage::InMemoryStorage};
|
||||
use crate::changes_trie::build_cache::{IncompleteCacheAction, IncompleteCachedBuildData};
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::collections::VecDeque;
|
||||
use codec::{Decode, Encode, Codec};
|
||||
use hash_db::Hasher;
|
||||
use num_traits::Zero;
|
||||
use trie::Recorder;
|
||||
use sp_trie::Recorder;
|
||||
use crate::changes_trie::{AnchorBlockId, ConfigurationRange, RootsStorage, Storage, BlockNumber};
|
||||
use crate::changes_trie::input::{DigestIndex, ExtrinsicIndex, DigestIndexValue, ExtrinsicIndexValue};
|
||||
use crate::changes_trie::storage::{TrieBackendAdapter, InMemoryStorage};
|
||||
@@ -376,7 +376,7 @@ impl<'a, H, Number> Iterator for ProvingDrilldownIterator<'a, H, Number>
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::iter::FromIterator;
|
||||
use primitives::Blake2Hasher;
|
||||
use sp_core::Blake2Hasher;
|
||||
use crate::changes_trie::Configuration;
|
||||
use crate::changes_trie::input::InputPair;
|
||||
use crate::changes_trie::storage::InMemoryStorage;
|
||||
|
||||
@@ -71,12 +71,12 @@ use hash_db::{Hasher, Prefix};
|
||||
use crate::backend::Backend;
|
||||
use num_traits::{One, Zero};
|
||||
use codec::{Decode, Encode};
|
||||
use primitives;
|
||||
use sp_core;
|
||||
use crate::changes_trie::build::prepare_input;
|
||||
use crate::changes_trie::build_cache::{IncompleteCachedBuildData, IncompleteCacheAction};
|
||||
use crate::overlayed_changes::OverlayedChanges;
|
||||
use trie::{MemoryDB, DBValue, TrieMut};
|
||||
use trie::trie_types::TrieDBMut;
|
||||
use sp_trie::{MemoryDB, DBValue, TrieMut};
|
||||
use sp_trie::trie_types::TrieDBMut;
|
||||
|
||||
/// Changes that are made outside of extrinsics are marked with this index;
|
||||
pub const NO_EXTRINSIC_INDEX: u32 = 0xffffffff;
|
||||
@@ -149,7 +149,7 @@ pub trait Storage<H: Hasher, Number: BlockNumber>: RootsStorage<H, Number> {
|
||||
pub struct TrieBackendStorageAdapter<'a, H: Hasher, Number: BlockNumber>(pub &'a dyn Storage<H, Number>);
|
||||
|
||||
impl<'a, H: Hasher, N: BlockNumber> crate::TrieBackendStorage<H> for TrieBackendStorageAdapter<'a, H, N> {
|
||||
type Overlay = trie::MemoryDB<H>;
|
||||
type Overlay = sp_trie::MemoryDB<H>;
|
||||
|
||||
fn get(&self, key: &H::Out, prefix: Prefix) -> Result<Option<DBValue>, String> {
|
||||
self.0.get(key, prefix)
|
||||
@@ -157,7 +157,7 @@ impl<'a, H: Hasher, N: BlockNumber> crate::TrieBackendStorage<H> for TrieBackend
|
||||
}
|
||||
|
||||
/// Changes trie configuration.
|
||||
pub type Configuration = primitives::ChangesTrieConfiguration;
|
||||
pub type Configuration = sp_core::ChangesTrieConfiguration;
|
||||
|
||||
/// Blocks range where configuration has been constant.
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Changes trie pruning-related functions.
|
||||
|
||||
use hash_db::Hasher;
|
||||
use trie::Recorder;
|
||||
use sp_trie::Recorder;
|
||||
use log::warn;
|
||||
use num_traits::{One, Zero};
|
||||
use crate::proving_backend::ProvingBackendRecorder;
|
||||
@@ -202,8 +202,8 @@ fn max_digest_intervals_to_keep<Number: BlockNumber>(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::HashSet;
|
||||
use trie::MemoryDB;
|
||||
use primitives::Blake2Hasher;
|
||||
use sp_trie::MemoryDB;
|
||||
use sp_core::Blake2Hasher;
|
||||
use crate::backend::insert_into_memory_db;
|
||||
use crate::changes_trie::storage::InMemoryStorage;
|
||||
use codec::Encode;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
use std::collections::{BTreeMap, HashSet, HashMap};
|
||||
use hash_db::{Hasher, Prefix, EMPTY_PREFIX};
|
||||
use trie::DBValue;
|
||||
use trie::MemoryDB;
|
||||
use sp_trie::DBValue;
|
||||
use sp_trie::MemoryDB;
|
||||
use parking_lot::RwLock;
|
||||
use crate::changes_trie::{BuildCache, RootsStorage, Storage, AnchorBlockId, BlockNumber};
|
||||
use crate::trie_backend_essence::TrieBackendStorage;
|
||||
|
||||
@@ -24,12 +24,12 @@ use crate::{
|
||||
};
|
||||
|
||||
use hash_db::Hasher;
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
storage::{ChildStorageKey, well_known_keys::is_child_storage_key, ChildInfo},
|
||||
traits::Externalities, hexdisplay::HexDisplay, hash::H256,
|
||||
};
|
||||
use trie::{trie_types::Layout, MemoryDB, default_child_trie_root};
|
||||
use externalities::Extensions;
|
||||
use sp_trie::{trie_types::Layout, MemoryDB, default_child_trie_root};
|
||||
use sp_externalities::Extensions;
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
use std::{error, fmt, any::{Any, TypeId}};
|
||||
@@ -179,7 +179,7 @@ where
|
||||
N: crate::changes_trie::BlockNumber,
|
||||
{
|
||||
fn storage(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(||
|
||||
self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL));
|
||||
trace!(target: "state-trace", "{:04x}: Get {}={:?}",
|
||||
@@ -191,7 +191,7 @@ where
|
||||
}
|
||||
|
||||
fn storage_hash(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.overlay
|
||||
.storage(key)
|
||||
.map(|x| x.map(|x| H::hash(x)))
|
||||
@@ -206,7 +206,7 @@ where
|
||||
}
|
||||
|
||||
fn original_storage(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL);
|
||||
|
||||
trace!(target: "state-trace", "{:04x}: GetOriginal {}={:?}",
|
||||
@@ -218,7 +218,7 @@ where
|
||||
}
|
||||
|
||||
fn original_storage_hash(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.backend.storage_hash(key).expect(EXT_NOT_ALLOWED_TO_FAIL);
|
||||
|
||||
trace!(target: "state-trace", "{:04x}: GetOriginalHash {}={:?}",
|
||||
@@ -235,7 +235,7 @@ where
|
||||
child_info: ChildInfo,
|
||||
key: &[u8],
|
||||
) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.overlay
|
||||
.child_storage(storage_key.as_ref(), key)
|
||||
.map(|x| x.map(|x| x.to_vec()))
|
||||
@@ -260,7 +260,7 @@ where
|
||||
_child_info: ChildInfo,
|
||||
key: &[u8],
|
||||
) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.overlay
|
||||
.child_storage(storage_key.as_ref(), key)
|
||||
.map(|x| x.map(|x| H::hash(x)))
|
||||
@@ -284,7 +284,7 @@ where
|
||||
child_info: ChildInfo,
|
||||
key: &[u8],
|
||||
) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.backend
|
||||
.child_storage(storage_key.as_ref(), child_info, key)
|
||||
.expect(EXT_NOT_ALLOWED_TO_FAIL);
|
||||
@@ -304,7 +304,7 @@ where
|
||||
child_info: ChildInfo,
|
||||
key: &[u8],
|
||||
) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = self.backend
|
||||
.child_storage_hash(storage_key.as_ref(), child_info, key)
|
||||
.expect(EXT_NOT_ALLOWED_TO_FAIL);
|
||||
@@ -319,7 +319,7 @@ where
|
||||
}
|
||||
|
||||
fn exists_storage(&self, key: &[u8]) -> bool {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
let result = match self.overlay.storage(key) {
|
||||
Some(x) => x.is_some(),
|
||||
_ => self.backend.exists_storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL),
|
||||
@@ -340,7 +340,7 @@ where
|
||||
child_info: ChildInfo,
|
||||
key: &[u8],
|
||||
) -> bool {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
|
||||
let result = match self.overlay.child_storage(storage_key.as_ref(), key) {
|
||||
Some(x) => x.is_some(),
|
||||
@@ -408,7 +408,7 @@ where
|
||||
HexDisplay::from(&key),
|
||||
value.as_ref().map(HexDisplay::from)
|
||||
);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
if is_child_storage_key(&key) {
|
||||
warn!(target: "trie", "Refuse to directly set child storage key");
|
||||
return;
|
||||
@@ -431,7 +431,7 @@ where
|
||||
HexDisplay::from(&key),
|
||||
value.as_ref().map(HexDisplay::from)
|
||||
);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
|
||||
self.mark_dirty();
|
||||
self.overlay.set_child_storage(storage_key.into_owned(), child_info, key, value);
|
||||
@@ -446,7 +446,7 @@ where
|
||||
self.id,
|
||||
HexDisplay::from(&storage_key.as_ref()),
|
||||
);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
|
||||
self.mark_dirty();
|
||||
self.overlay.clear_child_storage(storage_key.as_ref(), child_info);
|
||||
@@ -460,7 +460,7 @@ where
|
||||
self.id,
|
||||
HexDisplay::from(&prefix),
|
||||
);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
if is_child_storage_key(prefix) {
|
||||
warn!(target: "trie", "Refuse to directly clear prefix that is part of child storage key");
|
||||
return;
|
||||
@@ -484,7 +484,7 @@ where
|
||||
HexDisplay::from(&storage_key.as_ref()),
|
||||
HexDisplay::from(&prefix),
|
||||
);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
|
||||
self.mark_dirty();
|
||||
self.overlay.clear_child_prefix(storage_key.as_ref(), child_info, prefix);
|
||||
@@ -498,7 +498,7 @@ where
|
||||
}
|
||||
|
||||
fn storage_root(&mut self) -> Vec<u8> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
if let Some((_, ref root)) = self.storage_transaction {
|
||||
trace!(target: "state-trace", "{:04x}: Root (cached) {}",
|
||||
self.id,
|
||||
@@ -543,7 +543,7 @@ where
|
||||
&mut self,
|
||||
storage_key: ChildStorageKey,
|
||||
) -> Vec<u8> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
if self.storage_transaction.is_some() {
|
||||
let root = self
|
||||
.storage(storage_key.as_ref())
|
||||
@@ -611,7 +611,7 @@ where
|
||||
}
|
||||
|
||||
fn storage_changes_root(&mut self, parent_hash: &[u8]) -> Result<Option<Vec<u8>>, ()> {
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_abort();
|
||||
|
||||
self.changes_trie_transaction = build_changes_trie::<_, T, H, N>(
|
||||
self.backend,
|
||||
@@ -638,7 +638,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, H, B, T, N> externalities::ExtensionStore for Ext<'a, H, N, B, T>
|
||||
impl<'a, H, B, T, N> sp_externalities::ExtensionStore for Ext<'a, H, N, B, T>
|
||||
where
|
||||
H: Hasher<Out=H256>,
|
||||
B: 'a + Backend<H>,
|
||||
@@ -655,14 +655,14 @@ mod tests {
|
||||
use super::*;
|
||||
use hex_literal::hex;
|
||||
use codec::Encode;
|
||||
use primitives::{Blake2Hasher, storage::well_known_keys::EXTRINSIC_INDEX, map};
|
||||
use sp_core::{Blake2Hasher, storage::well_known_keys::EXTRINSIC_INDEX, map};
|
||||
use crate::{
|
||||
changes_trie::{
|
||||
Configuration as ChangesTrieConfiguration,
|
||||
InMemoryStorage as InMemoryChangesTrieStorage,
|
||||
}, backend::InMemory, overlayed_changes::OverlayedValue,
|
||||
};
|
||||
use primitives::storage::{Storage, StorageChild};
|
||||
use sp_core::storage::{Storage, StorageChild};
|
||||
|
||||
type TestBackend = InMemory<Blake2Hasher>;
|
||||
type TestChangesTrieStorage = InMemoryChangesTrieStorage<Blake2Hasher, u64>;
|
||||
|
||||
@@ -22,12 +22,12 @@ use std::{fmt, result, collections::HashMap, panic::UnwindSafe, marker::PhantomD
|
||||
use log::{warn, trace};
|
||||
use hash_db::Hasher;
|
||||
use codec::{Decode, Encode, Codec};
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
storage::{well_known_keys, ChildInfo}, NativeOrEncoded, NeverNativeValue,
|
||||
traits::CodeExecutor, hexdisplay::HexDisplay, hash::H256,
|
||||
};
|
||||
use overlayed_changes::OverlayedChangeSet;
|
||||
use externalities::Extensions;
|
||||
use sp_externalities::Extensions;
|
||||
|
||||
pub mod backend;
|
||||
mod changes_trie;
|
||||
@@ -40,7 +40,7 @@ mod proving_backend;
|
||||
mod trie_backend;
|
||||
mod trie_backend_essence;
|
||||
|
||||
pub use trie::{trie_types::{Layout, TrieDBMut}, TrieMut, DBValue, MemoryDB};
|
||||
pub use sp_trie::{trie_types::{Layout, TrieDBMut}, TrieMut, DBValue, MemoryDB};
|
||||
pub use testing::TestExternalities;
|
||||
pub use basic::BasicExternalities;
|
||||
pub use ext::Ext;
|
||||
@@ -424,7 +424,7 @@ impl<'a, B, H, N, T, Exec> StateMachine<'a, B, H, N, T, Exec> where
|
||||
ExecutionManager::AlwaysWasm(trust_level) => {
|
||||
let _abort_guard = match trust_level {
|
||||
BackendTrustLevel::Trusted => None,
|
||||
BackendTrustLevel::Untrusted => Some(panic_handler::AbortGuard::never_abort()),
|
||||
BackendTrustLevel::Untrusted => Some(sp_panic_handler::AbortGuard::never_abort()),
|
||||
};
|
||||
let res = self.execute_aux(compute_tx, false, native_call);
|
||||
(res.0, res.2, res.3)
|
||||
@@ -745,7 +745,7 @@ mod tests {
|
||||
InMemoryStorage as InMemoryChangesTrieStorage,
|
||||
Configuration as ChangesTrieConfig,
|
||||
};
|
||||
use primitives::{Blake2Hasher, map, traits::Externalities, storage::ChildStorageKey};
|
||||
use sp_core::{Blake2Hasher, map, traits::Externalities, storage::ChildStorageKey};
|
||||
|
||||
struct DummyCodeExecutor {
|
||||
change_changes_trie_config: bool,
|
||||
|
||||
@@ -21,7 +21,7 @@ use std::iter::FromIterator;
|
||||
use std::collections::{HashMap, BTreeMap, BTreeSet};
|
||||
use codec::Decode;
|
||||
use crate::changes_trie::{NO_EXTRINSIC_INDEX, Configuration as ChangesTrieConfig};
|
||||
use primitives::storage::{well_known_keys::EXTRINSIC_INDEX, OwnedChildInfo, ChildInfo};
|
||||
use sp_core::storage::{well_known_keys::EXTRINSIC_INDEX, OwnedChildInfo, ChildInfo};
|
||||
use std::{mem, ops};
|
||||
|
||||
/// The overlayed changes to state to be queried on top of the backend.
|
||||
@@ -442,7 +442,7 @@ impl From<Option<Vec<u8>>> for OverlayedValue {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hex_literal::hex;
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
Blake2Hasher, traits::Externalities, storage::well_known_keys::EXTRINSIC_INDEX,
|
||||
};
|
||||
use crate::backend::InMemory;
|
||||
|
||||
@@ -21,18 +21,18 @@ use parking_lot::RwLock;
|
||||
use codec::{Decode, Encode, Codec};
|
||||
use log::debug;
|
||||
use hash_db::{Hasher, HashDB, EMPTY_PREFIX, Prefix};
|
||||
use trie::{
|
||||
use sp_trie::{
|
||||
MemoryDB, PrefixedMemoryDB, default_child_trie_root,
|
||||
read_trie_value_with, read_child_trie_value_with, record_all_keys
|
||||
};
|
||||
pub use trie::Recorder;
|
||||
pub use trie::trie_types::{Layout, TrieError};
|
||||
pub use sp_trie::Recorder;
|
||||
pub use sp_trie::trie_types::{Layout, TrieError};
|
||||
use crate::trie_backend::TrieBackend;
|
||||
use crate::trie_backend_essence::{Ephemeral, TrieBackendEssence, TrieBackendStorage};
|
||||
use crate::{Error, ExecutionError, Backend};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use crate::DBValue;
|
||||
use primitives::storage::ChildInfo;
|
||||
use sp_core::storage::ChildInfo;
|
||||
|
||||
/// Patricia trie-based backend specialized in get value proofs.
|
||||
pub struct ProvingBackendRecorder<'a, S: 'a + TrieBackendStorage<H>, H: 'a + Hasher> {
|
||||
@@ -394,7 +394,7 @@ mod tests {
|
||||
use crate::backend::{InMemory};
|
||||
use crate::trie_backend::tests::test_trie;
|
||||
use super::*;
|
||||
use primitives::{Blake2Hasher, storage::ChildStorageKey};
|
||||
use sp_core::{Blake2Hasher, storage::ChildStorageKey};
|
||||
use crate::proving_backend::create_proof_check_backend;
|
||||
|
||||
const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1");
|
||||
@@ -422,7 +422,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn proof_is_invalid_when_does_not_contains_root() {
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
let result = create_proof_check_backend::<Blake2Hasher>(
|
||||
H256::from_low_u64_be(1),
|
||||
StorageProof::empty()
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::{
|
||||
},
|
||||
ext::Ext,
|
||||
};
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
storage::{
|
||||
well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES, is_child_storage_key},
|
||||
Storage,
|
||||
@@ -34,7 +34,7 @@ use primitives::{
|
||||
hash::H256, Blake2Hasher,
|
||||
};
|
||||
use codec::Encode;
|
||||
use externalities::{Extensions, Extension};
|
||||
use sp_externalities::{Extensions, Extension};
|
||||
|
||||
/// Simple HashMap-based Externalities impl.
|
||||
pub struct TestExternalities<H: Hasher<Out=H256>=Blake2Hasher, N: ChangesTrieBlockNumber=u64> {
|
||||
@@ -125,7 +125,7 @@ impl<H: Hasher<Out=H256>, N: ChangesTrieBlockNumber> TestExternalities<H, N> {
|
||||
/// Returns the result of the given closure.
|
||||
pub fn execute_with<R>(&mut self, execute: impl FnOnce() -> R) -> R {
|
||||
let mut ext = self.ext();
|
||||
externalities::set_and_run_with_externalities(&mut ext, execute)
|
||||
sp_externalities::set_and_run_with_externalities(&mut ext, execute)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ impl<H: Hasher<Out=H256>, N: ChangesTrieBlockNumber> From<Storage> for TestExter
|
||||
}
|
||||
}
|
||||
|
||||
impl<H, N> externalities::ExtensionStore for TestExternalities<H, N> where
|
||||
impl<H, N> sp_externalities::ExtensionStore for TestExternalities<H, N> where
|
||||
H: Hasher<Out=H256>,
|
||||
N: ChangesTrieBlockNumber,
|
||||
{
|
||||
@@ -165,7 +165,7 @@ impl<H, N> externalities::ExtensionStore for TestExternalities<H, N> where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::traits::Externalities;
|
||||
use sp_core::traits::Externalities;
|
||||
use hex_literal::hex;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
use log::{warn, debug};
|
||||
use hash_db::Hasher;
|
||||
use trie::{Trie, delta_trie_root, default_child_trie_root, child_delta_trie_root};
|
||||
use trie::trie_types::{TrieDB, TrieError, Layout};
|
||||
use sp_trie::{Trie, delta_trie_root, default_child_trie_root, child_delta_trie_root};
|
||||
use sp_trie::trie_types::{TrieDB, TrieError, Layout};
|
||||
use crate::trie_backend_essence::{TrieBackendEssence, TrieBackendStorage, Ephemeral};
|
||||
use crate::Backend;
|
||||
use primitives::storage::ChildInfo;
|
||||
use sp_core::storage::ChildInfo;
|
||||
use codec::{Codec, Decode};
|
||||
|
||||
/// Patricia trie-based backend. Transaction type is an overlay of changes to commit.
|
||||
@@ -243,9 +243,9 @@ impl<S: TrieBackendStorage<H>, H: Hasher> Backend<H> for TrieBackend<S, H> where
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use std::collections::HashSet;
|
||||
use primitives::{Blake2Hasher, H256};
|
||||
use sp_core::{Blake2Hasher, H256};
|
||||
use codec::Encode;
|
||||
use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut};
|
||||
use sp_trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut};
|
||||
use super::*;
|
||||
|
||||
const CHILD_KEY_1: &[u8] = b":child_storage:default:sub1";
|
||||
|
||||
@@ -21,12 +21,12 @@ use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
use log::{debug, warn};
|
||||
use hash_db::{self, Hasher, EMPTY_PREFIX, Prefix};
|
||||
use trie::{Trie, MemoryDB, PrefixedMemoryDB, DBValue,
|
||||
use sp_trie::{Trie, MemoryDB, PrefixedMemoryDB, DBValue,
|
||||
default_child_trie_root, read_trie_value, read_child_trie_value,
|
||||
for_keys_in_child_trie, KeySpacedDB};
|
||||
use trie::trie_types::{TrieDB, TrieError, Layout};
|
||||
use sp_trie::trie_types::{TrieDB, TrieError, Layout};
|
||||
use crate::backend::Consolidate;
|
||||
use primitives::storage::ChildInfo;
|
||||
use sp_core::storage::ChildInfo;
|
||||
use codec::Encode;
|
||||
|
||||
/// Patricia trie-based storage trait.
|
||||
@@ -250,7 +250,7 @@ impl<S: TrieBackendStorage<H>, H: Hasher> TrieBackendEssence<S, H> where H::Out:
|
||||
storage: &self.storage,
|
||||
overlay: &mut read_overlay,
|
||||
};
|
||||
|
||||
|
||||
let mut iter = move |db| -> Result<(), Box<TrieError<H::Out>>> {
|
||||
let trie = TrieDB::<H>::new(db, root)?;
|
||||
let mut iter = trie.iter()?;
|
||||
@@ -448,8 +448,8 @@ impl<H: Hasher> TrieBackendStorage<H> for MemoryDB<H> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use primitives::{Blake2Hasher, H256};
|
||||
use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut};
|
||||
use sp_core::{Blake2Hasher, H256};
|
||||
use sp_trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut};
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user