diff --git a/core-primitives/top-pool-author/src/author.rs b/core-primitives/top-pool-author/src/author.rs index 0a5a12f004..7ec09f66cd 100644 --- a/core-primitives/top-pool-author/src/author.rs +++ b/core-primitives/top-pool-author/src/author.rs @@ -45,7 +45,7 @@ use jsonrpc_core::{ }; use log::*; use sp_runtime::generic; -use std::{boxed::Box, sync::Arc, vec::Vec}; +use std::{boxed::Box, sync::Arc, vec, vec::Vec}; /// Define type of TOP filter that is used in the Author #[cfg(feature = "sidechain")] @@ -319,6 +319,10 @@ where self.top_pool.shards() } + fn list_handled_shards(&self) -> Vec { + self.state_facade.list_shards().unwrap_or(vec![]) + } + fn remove_calls_from_pool( &self, shard: ShardIdentifier, diff --git a/core-primitives/top-pool-author/src/mocks.rs b/core-primitives/top-pool-author/src/mocks.rs index 154502245b..693c27f8a4 100644 --- a/core-primitives/top-pool-author/src/mocks.rs +++ b/core-primitives/top-pool-author/src/mocks.rs @@ -168,6 +168,11 @@ impl AuthorApi for AuthorApiMock { self.tops.read().unwrap().keys().cloned().collect() } + fn list_handled_shards(&self) -> Vec { + //dummy + self.tops.read().unwrap().keys().cloned().collect() + } + fn remove_calls_from_pool( &self, shard: ShardIdentifier, diff --git a/core-primitives/top-pool-author/src/traits.rs b/core-primitives/top-pool-author/src/traits.rs index 692431c910..b2e490423f 100644 --- a/core-primitives/top-pool-author/src/traits.rs +++ b/core-primitives/top-pool-author/src/traits.rs @@ -53,8 +53,12 @@ pub trait AuthorApi { account: &AccountId, ) -> Vec; + /// returns all shards which are currently present in the tops in the pool fn get_shards(&self) -> Vec; + /// returns all shards which are handled by our worker + fn list_handled_shards(&self) -> Vec; + /// Remove a collection of trusted operations from the pool. /// Return operations that were not successfully removed. fn remove_calls_from_pool( diff --git a/core/parentchain/indirect-calls-executor/src/executor.rs b/core/parentchain/indirect-calls-executor/src/executor.rs index 0d3b45d8c8..5dbfc3e7e9 100644 --- a/core/parentchain/indirect-calls-executor/src/executor.rs +++ b/core/parentchain/indirect-calls-executor/src/executor.rs @@ -191,16 +191,13 @@ impl< meta_data.confirm_processed_parentchain_block_call_indexes() })??; let root: H256 = merkle_root::(extrinsics); - let mrenclave = self.stf_enclave_signer.ocall_api.get_mr - let shard = self.top_pool_author.get_shards().get(0).unwrap_or(), + //todo: really use mrenclave here + let mrenclave = ShardIdentifier::default(); + let handled_shards = self.top_pool_author.list_handled_shards(); + trace!("got handled shards: {:?}", handled_shards); + let shard = handled_shards.get(0).unwrap_or(&mrenclave); trace!("prepared confirm_processed_parentchain_block() call for block {:?} with index {:?} and merkle root {}", block_number, call, root); - Ok(OpaqueCall::from_tuple(&( - call, - shard, - block_hash, - block_number, - root, - ))) + Ok(OpaqueCall::from_tuple(&(call, shard, block_hash, block_number, root))) } } diff --git a/service/src/setup.rs b/service/src/setup.rs index e5f38b7a0b..6535091f26 100644 --- a/service/src/setup.rs +++ b/service/src/setup.rs @@ -17,6 +17,7 @@ */ use crate::error::{Error, ServiceResult}; +use base58::ToBase58; use codec::Encode; use itp_enclave_api::{enclave_base::EnclaveBase, Enclave}; use itp_settings::files::{ @@ -54,10 +55,10 @@ pub(crate) fn initialize_shard_and_keys( pub(crate) fn init_shard(enclave: &Enclave, shard_identifier: &ShardIdentifier) { match enclave.init_shard(shard_identifier.encode()) { Err(e) => { - println!("Failed to initialize shard {:?}: {:?}", shard_identifier.to_base58(), e); + println!("Failed to initialize shard {:?}: {:?}", shard_identifier.0.to_base58(), e); }, Ok(_) => { - println!("Successfully initialized shard {:?}", shard_identifier.to_base58()); + println!("Successfully initialized shard {:?}", shard_identifier.0.to_base58()); }, } }