Skip to content

Commit

Permalink
Move top pool and top pool author crates to core primitives (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Müller authored Apr 12, 2022
1 parent cefe0e5 commit a83cd2a
Show file tree
Hide file tree
Showing 53 changed files with 285 additions and 287 deletions.
122 changes: 59 additions & 63 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,6 @@ dependencies = [
"itp-teerex-storage",
"itp-time-utils",
"itp-types",
"its-top-pool",
"jsonrpc-core 16.1.0",
"jsonrpc-core 18.0.0",
"parity-scale-codec",
Expand All @@ -2808,6 +2807,62 @@ dependencies = [
"sgx_tstd",
]

[[package]]
name = "itp-top-pool"
version = "0.8.0"
dependencies = [
"byteorder 1.4.3",
"derive_more",
"ita-stf",
"itc-direct-rpc-server",
"itp-types",
"its-primitives",
"jsonrpc-core 16.1.0",
"jsonrpc-core 18.0.0",
"linked-hash-map 0.5.2",
"linked-hash-map 0.5.4",
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec",
"parity-util-mem",
"retain_mut",
"serde 1.0.136",
"sgx_tstd",
"sgx_types",
"sp-application-crypto",
"sp-core",
"sp-runtime",
"thiserror 1.0.30",
"thiserror 1.0.9",
]

[[package]]
name = "itp-top-pool-author"
version = "0.8.0"
dependencies = [
"derive_more",
"ita-stf",
"itc-direct-rpc-server",
"itc-tls-websocket-server",
"itp-enclave-metrics",
"itp-ocall-api",
"itp-sgx-crypto",
"itp-stf-state-handler",
"itp-test",
"itp-top-pool",
"itp-types",
"jsonrpc-core 16.1.0",
"jsonrpc-core 18.0.0",
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec",
"sgx_tcrypto_helper",
"sgx_tstd",
"sgx_types",
"sp-core",
"sp-runtime",
"thiserror 1.0.30",
"thiserror 1.0.9",
]

[[package]]
name = "itp-types"
version = "0.8.0"
Expand Down Expand Up @@ -2835,10 +2890,10 @@ dependencies = [
"itp-sgx-crypto",
"itp-stf-executor",
"itp-time-utils",
"itp-top-pool-author",
"itp-types",
"its-primitives",
"its-state",
"its-top-pool-rpc-author",
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec",
"sgx-externalities",
Expand Down Expand Up @@ -2969,9 +3024,9 @@ dependencies = [
name = "its-rpc-handler"
version = "0.8.0"
dependencies = [
"itp-top-pool-author",
"itp-types",
"its-primitives",
"its-top-pool-rpc-author",
"jsonrpc-core 16.1.0",
"jsonrpc-core 18.0.0",
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
Expand All @@ -2994,9 +3049,7 @@ dependencies = [
"its-primitives",
"its-rpc-handler",
"its-state",
"its-top-pool",
"its-top-pool-executor",
"its-top-pool-rpc-author",
"its-validateer-fetch",
]

Expand Down Expand Up @@ -3048,45 +3101,17 @@ dependencies = [
"sp-core",
]

[[package]]
name = "its-top-pool"
version = "0.8.0"
dependencies = [
"byteorder 1.4.3",
"derive_more",
"ita-stf",
"itc-direct-rpc-server",
"itp-types",
"its-primitives",
"jsonrpc-core 16.1.0",
"jsonrpc-core 18.0.0",
"linked-hash-map 0.5.2",
"linked-hash-map 0.5.4",
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec",
"parity-util-mem",
"retain_mut",
"serde 1.0.136",
"sgx_tstd",
"sgx_types",
"sp-application-crypto",
"sp-core",
"sp-runtime",
"thiserror 1.0.30",
"thiserror 1.0.9",
]

[[package]]
name = "its-top-pool-executor"
version = "0.8.0"
dependencies = [
"ita-stf",
"itp-stf-executor",
"itp-time-utils",
"itp-top-pool-author",
"itp-types",
"its-primitives",
"its-state",
"its-top-pool-rpc-author",
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec",
"sgx-externalities",
Expand All @@ -3098,35 +3123,6 @@ dependencies = [
"thiserror 1.0.9",
]

[[package]]
name = "its-top-pool-rpc-author"
version = "0.8.0"
dependencies = [
"derive_more",
"ita-stf",
"itc-direct-rpc-server",
"itc-tls-websocket-server",
"itp-component-container",
"itp-enclave-metrics",
"itp-ocall-api",
"itp-sgx-crypto",
"itp-stf-state-handler",
"itp-test",
"itp-types",
"its-top-pool",
"jsonrpc-core 16.1.0",
"jsonrpc-core 18.0.0",
"log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec",
"sgx_tcrypto_helper",
"sgx_tstd",
"sgx_types",
"sp-core",
"sp-runtime",
"thiserror 1.0.30",
"thiserror 1.0.9",
]

[[package]]
name = "its-validateer-fetch"
version = "0.8.0"
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ members = [
"core-primitives/teerex-storage",
"core-primitives/test",
"core-primitives/time-utils",
"core-primitives/top-pool",
"core-primitives/top-pool-author",
"core-primitives/types",
"service",
"sidechain/block-composer",
Expand All @@ -44,9 +46,7 @@ members = [
"sidechain/rpc-handler",
"sidechain/sidechain-crate",
"sidechain/state",
"sidechain/top-pool",
"sidechain/top-pool-executor",
"sidechain/top-pool-rpc-author",
"sidechain/validateer-fetch",
]

Expand Down
3 changes: 0 additions & 3 deletions core-primitives/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ itp-types = { path = "../types", default-features = false }
itp-ocall-api = { path = "../ocall-api", default-features = false }
itp-storage-verifier = { path = "../storage-verified", default-features = false }
itp-storage = { path = "../storage", default-features = false, features = ["test"] }
its-top-pool = { path = "../../sidechain/top-pool", default-features = false }

[features]
default = ["std"]
Expand All @@ -50,7 +49,6 @@ std = [
"itp-types/std",
"itp-ocall-api/std",
"itp-storage-verifier/std",
"its-top-pool/std",
"jsonrpc-core",
]
sgx = [
Expand All @@ -60,7 +58,6 @@ sgx = [
"itp-time-utils/sgx",
"itp-sgx-crypto/sgx",
"itp-stf-state-handler/sgx",
"its-top-pool/sgx",
"jsonrpc-core_sgx",
"sgx-externalities/sgx",
]
1 change: 0 additions & 1 deletion core-primitives/test/src/mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub mod handle_state_mock;
pub mod metrics_ocall_mock;
pub mod onchain_mock;
pub mod sidechain_ocall_api_mock;
pub mod trusted_operation_pool_mock;

#[cfg(feature = "sgx")]
pub mod shielding_crypto_mock;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "its-top-pool-rpc-author"
name = "itp-top-pool-author"
version = "0.8.0"
authors = ["Integritee AG <[email protected]>"]
edition = "2018"
Expand All @@ -14,12 +14,11 @@ std = [
"itp-sgx-crypto/std",
"itc-direct-rpc-server/std",
"itc-tls-websocket-server/std",
"itp-component-container/std",
"itp-enclave-metrics/std",
"itp-ocall-api/std",
"itp-stf-state-handler/std",
"itp-top-pool/std",
"itp-types/std",
"its-top-pool/std",
"jsonrpc-core",
"log/std",
"thiserror",
Expand All @@ -31,15 +30,14 @@ sgx = [
"ita-stf/sgx",
"itc-direct-rpc-server/sgx",
"itc-tls-websocket-server/sgx",
"itp-component-container/sgx",
"itp-enclave-metrics/sgx",
"itp-sgx-crypto/sgx",
"itp-stf-state-handler/sgx",
"itp-top-pool/sgx",
"itp-types/sgx",
"its-top-pool/sgx",
"thiserror_sgx",
]
test = [ "itp-test/sgx" ]
test = [ "itp-test/sgx", "itp-top-pool/mocks" ]

[dependencies]
# sgx dependencies
Expand All @@ -51,14 +49,13 @@ sgx-crypto-helper = { branch = "master", git = "https://github.com/apache/teacla
ita-stf = { path = "../../app-libs/stf", default-features = false }
itc-direct-rpc-server = { path = "../../core/direct-rpc-server", default-features = false }
itc-tls-websocket-server = { path = "../../core/tls-websocket-server", default-features = false }
itp-component-container = { path = "../../core-primitives/component-container", default-features = false }
itp-enclave-metrics = { path = "../../core-primitives/enclave-metrics", default-features = false }
itp-ocall-api = { path = "../../core-primitives/ocall-api", default-features = false }
itp-sgx-crypto = { path = "../../core-primitives/sgx/crypto", default-features = false }
itp-stf-state-handler = { path = "../../core-primitives/stf-state-handler", default-features = false }
itp-test = { path = "../../core-primitives/test", default-features = false, optional = true }
itp-types = { path = "../../core-primitives/types", default-features = false }
its-top-pool = { path = "../top-pool", default-features = false }
itp-enclave-metrics = { path = "../enclave-metrics", default-features = false }
itp-ocall-api = { path = "../ocall-api", default-features = false }
itp-sgx-crypto = { path = "../sgx/crypto", default-features = false }
itp-stf-state-handler = { path = "../stf-state-handler", default-features = false }
itp-test = { path = "../test", default-features = false, optional = true }
itp-top-pool = { path = "../top-pool", default-features = false }
itp-types = { path = "../types", default-features = false }

# sgx enabled external libraries
jsonrpc-core_sgx = { package = "jsonrpc-core", git = "https://github.com/scs/jsonrpc", branch = "no_std", default-features = false, optional = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use crate::sgx_reexport_prelude::*;
use crate::error;
use codec::Encode;
use ita_stf::{Getter, ShardIdentifier, TrustedOperation as StfTrustedOperation};
use itp_types::BlockHash as SidechainBlockHash;
use its_top_pool::{
use itp_top_pool::{
pool::{ChainApi, ExtrinsicHash, NumberFor},
primitives::TrustedOperationSource,
};
use itp_types::BlockHash as SidechainBlockHash;
use jsonrpc_core::futures::future::{ready, Future, Ready};
use log::*;
use sp_runtime::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ use itp_enclave_metrics::EnclaveMetric;
use itp_ocall_api::EnclaveMetricsOCallApi;
use itp_sgx_crypto::ShieldingCrypto;
use itp_stf_state_handler::query_shard_state::QueryShardState;
use itp_types::{BlockHash as SidechainBlockHash, ShardIdentifier};
use its_top_pool::{
use itp_top_pool::{
error::{Error as PoolError, IntoPoolError},
primitives::{
BlockHash, InPoolOperation, PoolFuture, TrustedOperationPool, TrustedOperationSource,
TxHash,
},
};
use itp_types::{BlockHash as SidechainBlockHash, ShardIdentifier};
use jsonrpc_core::{
futures::future::{ready, TryFutureExt},
Error as RpcError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use itp_stf_state_handler::handle_state::HandleState;
use itp_test::mock::{
handle_state_mock::HandleStateMock, metrics_ocall_mock::MetricsOCallMock,
shielding_crypto_mock::ShieldingCryptoMock,
trusted_operation_pool_mock::TrustedOperationPoolMock,
};
use itp_top_pool::mocks::trusted_operation_pool_mock::TrustedOperationPoolMock;
use sgx_crypto_helper::{rsa3072::Rsa3072KeyPair, RsaKeyPair};
use sp_core::{ed25519, Pair, H256};
use sp_runtime::traits::{BlakeTwo256, Hash};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum Error {
Client(Box<dyn std::error::Error + Sync + Send + 'static>),
/// TrustedOperation pool error,
#[display(fmt = "TrustedOperation pool error: {}", _0)]
Pool(its_top_pool::error::Error),
Pool(itp_top_pool::error::Error),
/// Verification error
#[display(fmt = "Extrinsic verification error")]
#[from(ignore)]
Expand Down Expand Up @@ -107,7 +107,7 @@ const UNSUPPORTED_KEY_TYPE: i64 = POOL_INVALID_TX + 7;

impl From<Error> for rpc_core::Error {
fn from(e: Error) -> Self {
use its_top_pool::error::Error as PoolError;
use itp_top_pool::error::Error as PoolError;

match e {
Error::BadFormat => rpc_core::Error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::sgx_reexport_prelude::*;
use crate::client_error::Error as ClientError;
use core::pin::Pin;
use derive_more::{Display, From};
use its_top_pool::error::{Error as PoolError, IntoPoolError};
use itp_top_pool::error::{Error as PoolError, IntoPoolError};
use jsonrpc_core as rpc;
use std::{boxed::Box, error, format, string::String};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ use itc_direct_rpc_server::rpc_responder::RpcResponder;
use itp_ocall_api::EnclaveMetricsOCallApi;
use itp_sgx_crypto::ShieldingCrypto;
use itp_stf_state_handler::query_shard_state::QueryShardState;
use its_top_pool::pool::Options as PoolOptions;
use itp_top_pool::pool::Options as PoolOptions;
use std::sync::Arc;

pub type SidechainRpcAuthor<StateHandler, ShieldingCrypto, OCallApi> =
pub type TopPoolAuthor<StateHandler, ShieldingCrypto, OCallApi> =
Author<BPool, AuthorTopFilter, StateHandler, ShieldingCrypto, OCallApi>;

/// Initialize the author components.
/// Initialize the TOP pool author component.
///
/// Creates and initializes the global author container from which the
/// RPC author can be accessed. We do this in a centralized manner, to allow
/// TOP pool author can be accessed. We do this in a centralized manner, to allow
/// easy feature-gating of the entire sidechain/top-pool feature.
pub fn create_top_pool_rpc_author<StateHandler, ShieldingKey, OCallApi>(
pub fn create_top_pool_author<StateHandler, ShieldingKey, OCallApi>(
connection_registry: Arc<EnclaveRpcConnectionRegistry>,
state_handler: Arc<StateHandler>,
ocall_api: Arc<OCallApi>,
shielding_crypto: ShieldingKey,
) -> Arc<SidechainRpcAuthor<StateHandler, ShieldingKey, OCallApi>>
) -> Arc<TopPoolAuthor<StateHandler, ShieldingKey, OCallApi>>
where
StateHandler: QueryShardState,
ShieldingKey: ShieldingCrypto,
Expand Down
File renamed without changes.
Loading

0 comments on commit a83cd2a

Please sign in to comment.