From 43ecf47fffb0a582126d24989fa54c08deb064f8 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Thu, 9 Jan 2025 16:28:11 +0000 Subject: [PATCH 01/22] extracting out parentchain primitives to its own crate --- tee-worker/omni-executor/Cargo.lock | 8 +++ tee-worker/omni-executor/Cargo.toml | 1 + .../parentchain/primitives/Cargo.toml | 11 ++++ .../parentchain/primitives/src/lib.rs | 56 +++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 tee-worker/omni-executor/parentchain/primitives/Cargo.toml create mode 100644 tee-worker/omni-executor/parentchain/primitives/src/lib.rs diff --git a/tee-worker/omni-executor/Cargo.lock b/tee-worker/omni-executor/Cargo.lock index cc076f02a6..2a3f549346 100644 --- a/tee-worker/omni-executor/Cargo.lock +++ b/tee-worker/omni-executor/Cargo.lock @@ -4089,6 +4089,7 @@ dependencies = [ "hex", "log", "parentchain-api-interface", + "parentchain-primitives", "parentchain-storage", "parity-scale-codec", "scale-encode 0.7.1", @@ -4098,6 +4099,13 @@ dependencies = [ "tokio", ] +[[package]] +name = "parentchain-primitives" +version = "0.1.0" +dependencies = [ + "executor-core", +] + [[package]] name = "parentchain-storage" version = "0.1.0" diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index 41d4ceb46e..9ca3826373 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -5,6 +5,7 @@ members = [ "parentchain/listener", "parentchain/api-interface", "parentchain/storage", + "parentchain/primitives", "ethereum/intent-executor", "solana/intent-executor", ] diff --git a/tee-worker/omni-executor/parentchain/primitives/Cargo.toml b/tee-worker/omni-executor/parentchain/primitives/Cargo.toml new file mode 100644 index 0000000000..68bcc1b692 --- /dev/null +++ b/tee-worker/omni-executor/parentchain/primitives/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "parentchain-primitives" +version = "0.1.0" +authors = ['Trust Computing GmbH '] +edition.workspace = true + +[dependencies] +executor-core = { path = "../../executor-core" } + +[lints] +workspace = true diff --git a/tee-worker/omni-executor/parentchain/primitives/src/lib.rs b/tee-worker/omni-executor/parentchain/primitives/src/lib.rs new file mode 100644 index 0000000000..70534f9918 --- /dev/null +++ b/tee-worker/omni-executor/parentchain/primitives/src/lib.rs @@ -0,0 +1,56 @@ +// Copyright 2020-2024 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +use executor_core::primitives::GetEventId; + +/// Used to uniquely identify intent event on parentchain. +#[derive(Clone, Debug)] +pub struct EventId { + pub block_num: u64, + pub event_idx: u64, +} + +impl EventId { + pub fn new(block_num: u64, event_idx: u64) -> Self { + Self { block_num, event_idx } + } +} + +pub struct BlockEvent { + pub id: EventId, + pub pallet_name: String, + pub variant_name: String, + pub variant_index: u8, + pub field_bytes: Vec, +} + +impl BlockEvent { + pub fn new( + id: EventId, + pallet_name: String, + variant_name: String, + variant_index: u8, + field_bytes: Vec, + ) -> Self { + Self { id, pallet_name, variant_name, variant_index, field_bytes } + } +} + +impl GetEventId for BlockEvent { + fn get_event_id(&self) -> EventId { + self.id.clone() + } +} From 3a527d6e4d87ea2e2ca09fd5d85ddfb95ee6f50d Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Thu, 9 Jan 2025 16:28:52 +0000 Subject: [PATCH 02/22] extracting rpc-client to its own crate --- tee-worker/omni-executor/Cargo.lock | 14 ++ tee-worker/omni-executor/Cargo.toml | 1 + .../parentchain/rpc-client/Cargo.toml | 22 ++ .../parentchain/rpc-client/src/lib.rs | 224 ++++++++++++++++++ 4 files changed, 261 insertions(+) create mode 100644 tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml create mode 100644 tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs diff --git a/tee-worker/omni-executor/Cargo.lock b/tee-worker/omni-executor/Cargo.lock index 2a3f549346..a7d2c8e667 100644 --- a/tee-worker/omni-executor/Cargo.lock +++ b/tee-worker/omni-executor/Cargo.lock @@ -4090,6 +4090,7 @@ dependencies = [ "log", "parentchain-api-interface", "parentchain-primitives", + "parentchain-rpc-client", "parentchain-storage", "parity-scale-codec", "scale-encode 0.7.1", @@ -4106,6 +4107,19 @@ dependencies = [ "executor-core", ] +[[package]] +name = "parentchain-rpc-client" +version = "0.1.0" +dependencies = [ + "async-trait", + "env_logger", + "log", + "parentchain-primitives", + "parity-scale-codec", + "subxt", + "subxt-core", +] + [[package]] name = "parentchain-storage" version = "0.1.0" diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index 9ca3826373..f7e3ef9cc7 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -4,6 +4,7 @@ members = [ "executor-worker", "parentchain/listener", "parentchain/api-interface", + "parentchain/rpc-client", "parentchain/storage", "parentchain/primitives", "ethereum/intent-executor", diff --git a/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml new file mode 100644 index 0000000000..5930a6bcb5 --- /dev/null +++ b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "parentchain-rpc-client" +version = "0.1.0" +authors = ['Trust Computing GmbH '] +edition.workspace = true + +[dependencies] +async-trait = { workspace = true } +log = { workspace = true } +parity-scale-codec = { workspace = true, features = ["derive"] } +subxt = { workspace = true } +subxt-core = { workspace = true } + +parentchain-primitives = { path = "../primitives" } +# executor-core = { path = "../../executor-core" } +# parentchain-api-interface = { path = "../api-interface" } + +[dev-dependencies] +env_logger = { workspace = true } + +[lints] +workspace = true diff --git a/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs new file mode 100644 index 0000000000..3e21b41b06 --- /dev/null +++ b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs @@ -0,0 +1,224 @@ +// Copyright 2020-2024 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +use async_trait::async_trait; +use log::{error, info}; +use parentchain_primitives::{BlockEvent, EventId}; +use parity_scale_codec::Encode; +use std::marker::PhantomData; +use std::ops::Deref; +use std::thread; +use std::time::Duration; +use subxt::backend::legacy::LegacyRpcMethods; +use subxt::backend::BlockRef; +use subxt::config::Header; +use subxt::events::EventsClient; +use subxt::tx::TxClient; +use subxt::{Config, OnlineClient}; +use subxt_core::utils::AccountId32; + +pub struct RuntimeVersion { + pub spec_version: u32, + pub transaction_version: u32, +} + +/// For fetching data from Substrate RPC node +#[async_trait] +pub trait SubstrateRpcClient { + async fn get_last_finalized_block_num(&mut self) -> Result; + async fn get_block_events(&mut self, block_num: u64) -> Result, ()>; + async fn get_raw_metadata(&mut self, block_num: Option) -> Result, ()>; + async fn submit_tx(&mut self, raw_tx: &[u8]) -> Result<(), ()>; + async fn runtime_version(&mut self) -> Result; + async fn get_genesis_hash(&mut self) -> Result, ()>; + async fn get_account_nonce(&mut self, account_id: &AccountId) -> Result; +} + +pub struct SubxtClient { + legacy: LegacyRpcMethods, + events: EventsClient>, + tx: TxClient>, +} + +impl SubxtClient {} + +#[async_trait] +impl> SubstrateRpcClient + for SubxtClient +{ + async fn get_last_finalized_block_num(&mut self) -> Result { + let finalized_header = self.legacy.chain_get_finalized_head().await.map_err(|_| ())?; + match self.legacy.chain_get_header(Some(finalized_header)).await.map_err(|_| ())? { + Some(header) => Ok(header.number().into()), + None => Err(()), + } + } + async fn get_block_events(&mut self, block_num: u64) -> Result, ()> { + info!("Getting block {} events", block_num); + match self.legacy.chain_get_block_hash(Some(block_num.into())).await.map_err(|e| { + error!("Error getting block {} hash: {:?}", block_num, e); + })? { + Some(hash) => { + let events = self.events.at(BlockRef::from_hash(hash)).await.map_err(|e| { + error!("Error getting block {} events: {:?}", block_num, e); + })?; + Ok(events + .iter() + .enumerate() + .map(|(i, event)| { + let event = event.unwrap(); + BlockEvent::new( + EventId::new(block_num, i as u64), + event.pallet_name().to_string(), + event.variant_name().to_string(), + event.variant_index(), + event.field_bytes().to_vec(), + ) + }) + .collect()) + }, + None => Err(()), + } + } + + async fn get_raw_metadata(&mut self, block_num: Option) -> Result, ()> { + let maybe_hash = self + .legacy + .chain_get_block_hash(block_num.map(|b| b.into())) + .await + .map_err(|_| ())?; + Ok(self.legacy.state_get_metadata(maybe_hash).await.unwrap().deref().encode()) + } + + async fn submit_tx(&mut self, raw_tx: &[u8]) -> Result<(), ()> { + self.legacy.author_submit_extrinsic(raw_tx).await.map(|_| ()).map_err(|e| { + error!("Could not submit tx: {:?}", e); + }) + } + + async fn runtime_version(&mut self) -> Result { + self.legacy + .state_get_runtime_version(None) + .await + .map(|rv| RuntimeVersion { + spec_version: rv.spec_version, + transaction_version: rv.transaction_version, + }) + .map_err(|_| ()) + } + + async fn get_genesis_hash(&mut self) -> Result, ()> { + self.legacy.genesis_hash().await.map(|h| h.encode()).map_err(|_| ()) + } + + async fn get_account_nonce(&mut self, account_id: &ChainConfig::AccountId) -> Result { + self.tx.account_nonce(account_id).await.map_err(|_| ()) + } +} + +pub struct MockedRpcClient { + block_num: u64, +} + +#[async_trait] +impl SubstrateRpcClient for MockedRpcClient { + async fn get_last_finalized_block_num(&mut self) -> Result { + Ok(self.block_num) + } + + async fn get_block_events(&mut self, _block_num: u64) -> Result, ()> { + Ok(vec![]) + } + + async fn get_raw_metadata(&mut self, _block_num: Option) -> Result, ()> { + Ok(vec![]) + } + + async fn submit_tx(&mut self, _raw_tx: &[u8]) -> Result<(), ()> { + Ok(()) + } + + async fn runtime_version(&mut self) -> Result { + Ok(RuntimeVersion { spec_version: 0, transaction_version: 0 }) + } + + async fn get_genesis_hash(&mut self) -> Result, ()> { + Ok(vec![]) + } + + async fn get_account_nonce(&mut self, _account_id: &String) -> Result { + Ok(0) + } +} + +#[async_trait] +pub trait SubstrateRpcClientFactory> { + async fn new_client(&self) -> Result; +} + +pub struct SubxtClientFactory { + url: String, + _phantom: PhantomData, +} + +impl> SubxtClientFactory { + pub fn new(url: &str) -> Self { + Self { url: url.to_string(), _phantom: PhantomData } + } + pub async fn new_client_until_connected(&self) -> SubxtClient { + let mut client: Option> = None; + loop { + if client.is_some() { + break; + } + match self.new_client().await { + Ok(c) => { + client = Some(c); + }, + Err(e) => { + error!("Error creating client: {:?}", e); + }, + }; + thread::sleep(Duration::from_secs(1)) + } + client.unwrap() + } +} + +#[async_trait] +impl> + SubstrateRpcClientFactory> + for SubxtClientFactory +{ + async fn new_client(&self) -> Result, ()> { + let rpc_client = subxt::backend::rpc::RpcClient::from_insecure_url(self.url.clone()) + .await + .map_err(|e| { + log::error!("Could not create RpcClient: {:?}", e); + })?; + let legacy = LegacyRpcMethods::new(rpc_client); + + let online_client = + OnlineClient::from_insecure_url(self.url.clone()).await.map_err(|e| { + log::error!("Could not create OnlineClient: {:?}", e); + })?; + + let events = online_client.events(); + let tx = online_client.tx(); + + Ok(SubxtClient { legacy, events, tx }) + } +} From 2b48647a0334dd21dc167730c7b067ae8a01a19a Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Thu, 9 Jan 2025 16:30:18 +0000 Subject: [PATCH 03/22] moving SyncCheckpoint to its own module --- .../listener/src/sync_checkpoint.rs | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tee-worker/omni-executor/parentchain/listener/src/sync_checkpoint.rs diff --git a/tee-worker/omni-executor/parentchain/listener/src/sync_checkpoint.rs b/tee-worker/omni-executor/parentchain/listener/src/sync_checkpoint.rs new file mode 100644 index 0000000000..ae8e606d81 --- /dev/null +++ b/tee-worker/omni-executor/parentchain/listener/src/sync_checkpoint.rs @@ -0,0 +1,83 @@ +// Copyright 2020-2024 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +use crate::listener::IntentEventId; +use executor_core::sync_checkpoint_repository::Checkpoint; +use parentchain_primitives::EventId; +use parity_scale_codec::{Decode, Encode}; + +/// Represents parentchain sync checkpoint. +#[derive(Clone, Debug, PartialEq, Encode, Decode)] +pub struct SyncCheckpoint { + pub block_num: u64, + pub event_idx: Option, +} + +impl SyncCheckpoint { + pub fn new(block_num: u64, event_idx: Option) -> Self { + Self { block_num, event_idx } + } + + pub fn from_event_id(event_id: &EventId) -> Self { + Self::new(event_id.block_num, Some(event_id.event_idx)) + } + + pub fn from_block_num(block_num: u64) -> Self { + Self::new(block_num, None) + } + + pub fn just_block_num(&self) -> bool { + self.event_idx.is_none() + } +} + +impl Checkpoint for SyncCheckpoint { + fn just_block_num(&self) -> bool { + self.event_idx.is_none() + } + + fn get_block_num(&self) -> u64 { + self.block_num + } +} + +impl From for SyncCheckpoint { + fn from(block_num: u64) -> Self { + Self::from_block_num(block_num) + } +} + +impl From for SyncCheckpoint { + fn from(event_id: IntentEventId) -> Self { + Self::from_event_id(&event_id) + } +} + +impl PartialOrd for SyncCheckpoint { + fn partial_cmp(&self, other: &Self) -> Option { + if self.block_num > other.block_num { + Some(std::cmp::Ordering::Greater) + } else if self.block_num < other.block_num { + Some(std::cmp::Ordering::Less) + } else if self.event_idx > other.event_idx { + Some(std::cmp::Ordering::Greater) + } else if self.event_idx < other.event_idx { + Some(std::cmp::Ordering::Less) + } else { + Some(std::cmp::Ordering::Equal) + } + } +} From a68bbbd2f1dafeffcaa7c6766a44bb112f2e49f4 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Thu, 9 Jan 2025 16:30:49 +0000 Subject: [PATCH 04/22] refactoring parentchain listener to use the new parentchain crates --- .../parentchain/listener/Cargo.toml | 2 + .../parentchain/listener/src/event_handler.rs | 4 +- .../parentchain/listener/src/fetcher.rs | 6 +- .../parentchain/listener/src/lib.rs | 7 +- .../parentchain/listener/src/listener.rs | 4 +- .../parentchain/listener/src/metadata.rs | 2 +- .../parentchain/listener/src/primitives.rs | 122 ---------- .../parentchain/listener/src/rpc_client.rs | 224 ------------------ .../listener/src/transaction_signer.rs | 2 +- 9 files changed, 14 insertions(+), 359 deletions(-) delete mode 100644 tee-worker/omni-executor/parentchain/listener/src/primitives.rs delete mode 100644 tee-worker/omni-executor/parentchain/listener/src/rpc_client.rs diff --git a/tee-worker/omni-executor/parentchain/listener/Cargo.toml b/tee-worker/omni-executor/parentchain/listener/Cargo.toml index 6328de94dd..d8bd753524 100644 --- a/tee-worker/omni-executor/parentchain/listener/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/listener/Cargo.toml @@ -16,6 +16,8 @@ subxt-signer = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } executor-core = { path = "../../executor-core" } +parentchain-primitives = { path = "../primitives" } +parentchain-rpc-client = { path = "../rpc-client" } parentchain-api-interface = { path = "../api-interface" } parentchain-storage = { path = "../storage" } diff --git a/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs b/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs index ac8a023f7a..f76dfe7f66 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs @@ -15,8 +15,6 @@ // along with Litentry. If not, see . use crate::metadata::{MetadataProvider, SubxtMetadataProvider}; -use crate::primitives::BlockEvent; -use crate::rpc_client::{SubstrateRpcClient, SubstrateRpcClientFactory}; use crate::transaction_signer::TransactionSigner; use async_trait::async_trait; use executor_core::event_handler::Error::RecoverableError; @@ -35,6 +33,8 @@ use parentchain_api_interface::{ runtime_types::core_primitives::intent::Intent as RuntimeIntent, tx as parentchain_tx, }; +use parentchain_primitives::BlockEvent; +use parentchain_rpc_client::{SubstrateRpcClient, SubstrateRpcClientFactory}; use std::marker::PhantomData; use std::sync::Arc; use subxt::ext::scale_decode; diff --git a/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs b/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs index c0ef0ffd0b..af0d8047d3 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Litentry. If not, see . -use crate::primitives::{BlockEvent, EventId}; -use crate::rpc_client::SubstrateRpcClient; -use crate::rpc_client::SubstrateRpcClientFactory; use async_trait::async_trait; use executor_core::fetcher::{EventsFetcher, LastFinalizedBlockNumFetcher}; use log::error; +use parentchain_primitives::{BlockEvent, EventId}; +use parentchain_rpc_client::SubstrateRpcClient; +use parentchain_rpc_client::SubstrateRpcClientFactory; use std::marker::PhantomData; use std::sync::Arc; diff --git a/tee-worker/omni-executor/parentchain/listener/src/lib.rs b/tee-worker/omni-executor/parentchain/listener/src/lib.rs index e28ce078dc..1be20ba6b8 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/lib.rs @@ -19,8 +19,7 @@ mod fetcher; mod key_store; mod listener; mod metadata; -mod primitives; -mod rpc_client; +mod sync_checkpoint; mod transaction_signer; use crate::event_handler::EventHandler; @@ -28,8 +27,6 @@ use crate::fetcher::Fetcher; use crate::key_store::SubstrateKeyStore; use crate::listener::ParentchainListener; use crate::metadata::SubxtMetadataProvider; -use crate::rpc_client::SubstrateRpcClient; -use crate::rpc_client::{SubxtClient, SubxtClientFactory}; use crate::transaction_signer::TransactionSigner; use executor_core::intent_executor::IntentExecutor; use executor_core::key_store::KeyStore; @@ -40,6 +37,8 @@ use parentchain_api_interface::{ runtime_types::core_primitives::teebag::types::DcapProvider, teebag::calls::types::register_enclave::{AttestationType, WorkerMode, WorkerType}, }; +use parentchain_rpc_client::SubstrateRpcClient; +use parentchain_rpc_client::{SubxtClient, SubxtClientFactory}; use parentchain_storage::AccountStoreStorage; use scale_encode::EncodeAsType; use std::sync::Arc; diff --git a/tee-worker/omni-executor/parentchain/listener/src/listener.rs b/tee-worker/omni-executor/parentchain/listener/src/listener.rs index 1f9c185417..55b89f46a3 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/listener.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/listener.rs @@ -18,9 +18,9 @@ use crate::event_handler::EventHandler; use crate::fetcher::Fetcher; use crate::key_store::SubstrateKeyStore; use crate::metadata::SubxtMetadataProvider; -use crate::primitives::SyncCheckpoint; -use crate::primitives::{BlockEvent, EventId}; +use crate::sync_checkpoint::SyncCheckpoint; use executor_core::listener::Listener; +use parentchain_primitives::{BlockEvent, EventId}; use subxt::Metadata; use subxt_core::Config; diff --git a/tee-worker/omni-executor/parentchain/listener/src/metadata.rs b/tee-worker/omni-executor/parentchain/listener/src/metadata.rs index d526b196fb..be96555645 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/metadata.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/metadata.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Litentry. If not, see . -use crate::rpc_client::{SubstrateRpcClient, SubstrateRpcClientFactory, SubxtClientFactory}; use async_trait::async_trait; +use parentchain_rpc_client::{SubstrateRpcClient, SubstrateRpcClientFactory, SubxtClientFactory}; use parity_scale_codec::Decode; use subxt::{Config, Metadata}; use subxt_core::utils::AccountId32; diff --git a/tee-worker/omni-executor/parentchain/listener/src/primitives.rs b/tee-worker/omni-executor/parentchain/listener/src/primitives.rs deleted file mode 100644 index 1dd0ef58a4..0000000000 --- a/tee-worker/omni-executor/parentchain/listener/src/primitives.rs +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2020-2024 Trust Computing GmbH. -// This file is part of Litentry. -// -// Litentry is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Litentry is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Litentry. If not, see . - -use crate::listener::IntentEventId; -use executor_core::primitives::GetEventId; -use executor_core::sync_checkpoint_repository::Checkpoint; -use parity_scale_codec::{Decode, Encode}; - -/// Used to uniquely identify intent event on parentchain. -#[derive(Clone, Debug)] -pub struct EventId { - pub block_num: u64, - pub event_idx: u64, -} - -impl EventId { - pub fn new(block_num: u64, event_idx: u64) -> Self { - Self { block_num, event_idx } - } -} - -/// Represents parentchain sync checkpoint. -#[derive(Clone, Debug, PartialEq, Encode, Decode)] -pub struct SyncCheckpoint { - pub block_num: u64, - pub event_idx: Option, -} - -impl SyncCheckpoint { - pub fn new(block_num: u64, event_idx: Option) -> Self { - Self { block_num, event_idx } - } - - pub fn from_event_id(event_id: &EventId) -> Self { - Self::new(event_id.block_num, Some(event_id.event_idx)) - } - - pub fn from_block_num(block_num: u64) -> Self { - Self::new(block_num, None) - } - - pub fn just_block_num(&self) -> bool { - self.event_idx.is_none() - } -} - -impl Checkpoint for SyncCheckpoint { - fn just_block_num(&self) -> bool { - self.event_idx.is_none() - } - - fn get_block_num(&self) -> u64 { - self.block_num - } -} - -impl From for SyncCheckpoint { - fn from(block_num: u64) -> Self { - Self::from_block_num(block_num) - } -} - -impl From for SyncCheckpoint { - fn from(event_id: IntentEventId) -> Self { - Self::from_event_id(&event_id) - } -} - -impl PartialOrd for SyncCheckpoint { - fn partial_cmp(&self, other: &Self) -> Option { - if self.block_num > other.block_num { - Some(std::cmp::Ordering::Greater) - } else if self.block_num < other.block_num { - Some(std::cmp::Ordering::Less) - } else if self.event_idx > other.event_idx { - Some(std::cmp::Ordering::Greater) - } else if self.event_idx < other.event_idx { - Some(std::cmp::Ordering::Less) - } else { - Some(std::cmp::Ordering::Equal) - } - } -} - -pub struct BlockEvent { - pub id: EventId, - pub pallet_name: String, - pub variant_name: String, - pub variant_index: u8, - pub field_bytes: Vec, -} - -impl BlockEvent { - pub fn new( - id: EventId, - pallet_name: String, - variant_name: String, - variant_index: u8, - field_bytes: Vec, - ) -> Self { - Self { id, pallet_name, variant_name, variant_index, field_bytes } - } -} - -impl GetEventId for BlockEvent { - fn get_event_id(&self) -> EventId { - self.id.clone() - } -} diff --git a/tee-worker/omni-executor/parentchain/listener/src/rpc_client.rs b/tee-worker/omni-executor/parentchain/listener/src/rpc_client.rs deleted file mode 100644 index a18b3a08fc..0000000000 --- a/tee-worker/omni-executor/parentchain/listener/src/rpc_client.rs +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright 2020-2024 Trust Computing GmbH. -// This file is part of Litentry. -// -// Litentry is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Litentry is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Litentry. If not, see . - -use crate::primitives::{BlockEvent, EventId}; -use async_trait::async_trait; -use log::{error, info}; -use parity_scale_codec::Encode; -use std::marker::PhantomData; -use std::ops::Deref; -use std::thread; -use std::time::Duration; -use subxt::backend::legacy::LegacyRpcMethods; -use subxt::backend::BlockRef; -use subxt::config::Header; -use subxt::events::EventsClient; -use subxt::tx::TxClient; -use subxt::{Config, OnlineClient}; -use subxt_core::utils::AccountId32; - -pub struct RuntimeVersion { - pub spec_version: u32, - pub transaction_version: u32, -} - -/// For fetching data from Substrate RPC node -#[async_trait] -pub trait SubstrateRpcClient { - async fn get_last_finalized_block_num(&mut self) -> Result; - async fn get_block_events(&mut self, block_num: u64) -> Result, ()>; - async fn get_raw_metadata(&mut self, block_num: Option) -> Result, ()>; - async fn submit_tx(&mut self, raw_tx: &[u8]) -> Result<(), ()>; - async fn runtime_version(&mut self) -> Result; - async fn get_genesis_hash(&mut self) -> Result, ()>; - async fn get_account_nonce(&mut self, account_id: &AccountId) -> Result; -} - -pub struct SubxtClient { - legacy: LegacyRpcMethods, - events: EventsClient>, - tx: TxClient>, -} - -impl SubxtClient {} - -#[async_trait] -impl> SubstrateRpcClient - for SubxtClient -{ - async fn get_last_finalized_block_num(&mut self) -> Result { - let finalized_header = self.legacy.chain_get_finalized_head().await.map_err(|_| ())?; - match self.legacy.chain_get_header(Some(finalized_header)).await.map_err(|_| ())? { - Some(header) => Ok(header.number().into()), - None => Err(()), - } - } - async fn get_block_events(&mut self, block_num: u64) -> Result, ()> { - info!("Getting block {} events", block_num); - match self.legacy.chain_get_block_hash(Some(block_num.into())).await.map_err(|e| { - error!("Error getting block {} hash: {:?}", block_num, e); - })? { - Some(hash) => { - let events = self.events.at(BlockRef::from_hash(hash)).await.map_err(|e| { - error!("Error getting block {} events: {:?}", block_num, e); - })?; - Ok(events - .iter() - .enumerate() - .map(|(i, event)| { - let event = event.unwrap(); - BlockEvent::new( - EventId::new(block_num, i as u64), - event.pallet_name().to_string(), - event.variant_name().to_string(), - event.variant_index(), - event.field_bytes().to_vec(), - ) - }) - .collect()) - }, - None => Err(()), - } - } - - async fn get_raw_metadata(&mut self, block_num: Option) -> Result, ()> { - let maybe_hash = self - .legacy - .chain_get_block_hash(block_num.map(|b| b.into())) - .await - .map_err(|_| ())?; - Ok(self.legacy.state_get_metadata(maybe_hash).await.unwrap().deref().encode()) - } - - async fn submit_tx(&mut self, raw_tx: &[u8]) -> Result<(), ()> { - self.legacy.author_submit_extrinsic(raw_tx).await.map(|_| ()).map_err(|e| { - error!("Could not submit tx: {:?}", e); - }) - } - - async fn runtime_version(&mut self) -> Result { - self.legacy - .state_get_runtime_version(None) - .await - .map(|rv| RuntimeVersion { - spec_version: rv.spec_version, - transaction_version: rv.transaction_version, - }) - .map_err(|_| ()) - } - - async fn get_genesis_hash(&mut self) -> Result, ()> { - self.legacy.genesis_hash().await.map(|h| h.encode()).map_err(|_| ()) - } - - async fn get_account_nonce(&mut self, account_id: &ChainConfig::AccountId) -> Result { - self.tx.account_nonce(account_id).await.map_err(|_| ()) - } -} - -pub struct MockedRpcClient { - block_num: u64, -} - -#[async_trait] -impl SubstrateRpcClient for MockedRpcClient { - async fn get_last_finalized_block_num(&mut self) -> Result { - Ok(self.block_num) - } - - async fn get_block_events(&mut self, _block_num: u64) -> Result, ()> { - Ok(vec![]) - } - - async fn get_raw_metadata(&mut self, _block_num: Option) -> Result, ()> { - Ok(vec![]) - } - - async fn submit_tx(&mut self, _raw_tx: &[u8]) -> Result<(), ()> { - Ok(()) - } - - async fn runtime_version(&mut self) -> Result { - Ok(RuntimeVersion { spec_version: 0, transaction_version: 0 }) - } - - async fn get_genesis_hash(&mut self) -> Result, ()> { - Ok(vec![]) - } - - async fn get_account_nonce(&mut self, _account_id: &String) -> Result { - Ok(0) - } -} - -#[async_trait] -pub trait SubstrateRpcClientFactory> { - async fn new_client(&self) -> Result; -} - -pub struct SubxtClientFactory { - url: String, - _phantom: PhantomData, -} - -impl> SubxtClientFactory { - pub fn new(url: &str) -> Self { - Self { url: url.to_string(), _phantom: PhantomData } - } - pub async fn new_client_until_connected(&self) -> SubxtClient { - let mut client: Option> = None; - loop { - if client.is_some() { - break; - } - match self.new_client().await { - Ok(c) => { - client = Some(c); - }, - Err(e) => { - error!("Error creating client: {:?}", e); - }, - }; - thread::sleep(Duration::from_secs(1)) - } - client.unwrap() - } -} - -#[async_trait] -impl> - SubstrateRpcClientFactory> - for SubxtClientFactory -{ - async fn new_client(&self) -> Result, ()> { - let rpc_client = subxt::backend::rpc::RpcClient::from_insecure_url(self.url.clone()) - .await - .map_err(|e| { - log::error!("Could not create RpcClient: {:?}", e); - })?; - let legacy = LegacyRpcMethods::new(rpc_client); - - let online_client = - OnlineClient::from_insecure_url(self.url.clone()).await.map_err(|e| { - log::error!("Could not create OnlineClient: {:?}", e); - })?; - - let events = online_client.events(); - let tx = online_client.tx(); - - Ok(SubxtClient { legacy, events, tx }) - } -} diff --git a/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs b/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs index c5e7240346..95e0924849 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs @@ -1,7 +1,7 @@ use crate::metadata::{MetadataProvider, SubxtMetadataProvider}; -use crate::rpc_client::{SubstrateRpcClient, SubstrateRpcClientFactory}; use executor_core::key_store::KeyStore; use log::error; +use parentchain_rpc_client::{SubstrateRpcClient, SubstrateRpcClientFactory}; use parity_scale_codec::Decode; use std::marker::PhantomData; use std::sync::Arc; From 3af6423c79c495472ab10b6fad4e3cc5cf75e573 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Thu, 9 Jan 2025 16:45:51 +0000 Subject: [PATCH 05/22] moving CustomConfig to rpc-client --- .../parentchain/listener/Cargo.toml | 1 - .../parentchain/listener/src/lib.rs | 36 +------------------ .../parentchain/rpc-client/Cargo.toml | 1 + .../parentchain/rpc-client/src/lib.rs | 33 +++++++++++++++++ 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/tee-worker/omni-executor/parentchain/listener/Cargo.toml b/tee-worker/omni-executor/parentchain/listener/Cargo.toml index d8bd753524..e2b6deb492 100644 --- a/tee-worker/omni-executor/parentchain/listener/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/listener/Cargo.toml @@ -9,7 +9,6 @@ async-trait = { workspace = true } hex = "0.4.3" log = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive"] } -scale-encode = "0.7.1" subxt = { workspace = true } subxt-core = { workspace = true } subxt-signer = { workspace = true } diff --git a/tee-worker/omni-executor/parentchain/listener/src/lib.rs b/tee-worker/omni-executor/parentchain/listener/src/lib.rs index 1be20ba6b8..a19676ab9d 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/lib.rs @@ -38,49 +38,15 @@ use parentchain_api_interface::{ teebag::calls::types::register_enclave::{AttestationType, WorkerMode, WorkerType}, }; use parentchain_rpc_client::SubstrateRpcClient; -use parentchain_rpc_client::{SubxtClient, SubxtClientFactory}; +use parentchain_rpc_client::{CustomConfig, SubxtClient, SubxtClientFactory}; use parentchain_storage::AccountStoreStorage; -use scale_encode::EncodeAsType; use std::sync::Arc; -use subxt::config::signed_extensions; -use subxt::Config; use subxt_core::utils::AccountId32; use subxt_core::Metadata; use subxt_signer::sr25519::Keypair; use tokio::runtime::Handle; use tokio::sync::oneshot::Receiver; -// We don't need to construct this at runtime, -// so an empty enum is appropriate: -#[derive(EncodeAsType)] -pub enum CustomConfig {} - -//todo: adjust if needed -impl Config for CustomConfig { - type Hash = subxt::utils::H256; - type AccountId = subxt::utils::AccountId32; - type Address = subxt::utils::MultiAddress; - type Signature = subxt::utils::MultiSignature; - type Hasher = subxt::config::substrate::BlakeTwo256; - type Header = subxt::config::substrate::SubstrateHeader; - type ExtrinsicParams = signed_extensions::AnyOf< - Self, - ( - // Load in the existing signed extensions we're interested in - // (if the extension isn't actually needed it'll just be ignored): - signed_extensions::CheckSpecVersion, - signed_extensions::CheckTxVersion, - signed_extensions::CheckNonce, - signed_extensions::CheckGenesis, - signed_extensions::CheckMortality, - signed_extensions::ChargeAssetTxPayment, - signed_extensions::ChargeTransactionPayment, - signed_extensions::CheckMetadataHash, - ), - >; - type AssetId = u32; -} - /// Creates parentchain listener pub async fn create_listener( id: &str, diff --git a/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml index 5930a6bcb5..2537f1ade3 100644 --- a/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml @@ -8,6 +8,7 @@ edition.workspace = true async-trait = { workspace = true } log = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive"] } +scale-encode = { workspace = true } subxt = { workspace = true } subxt-core = { workspace = true } diff --git a/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs index 3e21b41b06..2f1813aaaf 100644 --- a/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs @@ -18,18 +18,51 @@ use async_trait::async_trait; use log::{error, info}; use parentchain_primitives::{BlockEvent, EventId}; use parity_scale_codec::Encode; +use scale_encode::EncodeAsType; use std::marker::PhantomData; use std::ops::Deref; use std::thread; use std::time::Duration; use subxt::backend::legacy::LegacyRpcMethods; use subxt::backend::BlockRef; +use subxt::config::signed_extensions; use subxt::config::Header; use subxt::events::EventsClient; use subxt::tx::TxClient; use subxt::{Config, OnlineClient}; use subxt_core::utils::AccountId32; +// We don't need to construct this at runtime, +// so an empty enum is appropriate: +#[derive(EncodeAsType)] +pub enum CustomConfig {} + +//todo: adjust if needed +impl Config for CustomConfig { + type Hash = subxt::utils::H256; + type AccountId = subxt::utils::AccountId32; + type Address = subxt::utils::MultiAddress; + type Signature = subxt::utils::MultiSignature; + type Hasher = subxt::config::substrate::BlakeTwo256; + type Header = subxt::config::substrate::SubstrateHeader; + type ExtrinsicParams = signed_extensions::AnyOf< + Self, + ( + // Load in the existing signed extensions we're interested in + // (if the extension isn't actually needed it'll just be ignored): + signed_extensions::CheckSpecVersion, + signed_extensions::CheckTxVersion, + signed_extensions::CheckNonce, + signed_extensions::CheckGenesis, + signed_extensions::CheckMortality, + signed_extensions::ChargeAssetTxPayment, + signed_extensions::ChargeTransactionPayment, + signed_extensions::CheckMetadataHash, + ), + >; + type AssetId = u32; +} + pub struct RuntimeVersion { pub spec_version: u32, pub transaction_version: u32, From 2a7faed6976023281ed84e0e057326567c7617c2 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Thu, 9 Jan 2025 16:46:29 +0000 Subject: [PATCH 06/22] updating scale-encode --- tee-worker/omni-executor/Cargo.lock | 155 +++++++++------------------- tee-worker/omni-executor/Cargo.toml | 2 +- 2 files changed, 48 insertions(+), 109 deletions(-) diff --git a/tee-worker/omni-executor/Cargo.lock b/tee-worker/omni-executor/Cargo.lock index a7d2c8e667..7d1c24d0f8 100644 --- a/tee-worker/omni-executor/Cargo.lock +++ b/tee-worker/omni-executor/Cargo.lock @@ -199,7 +199,7 @@ dependencies = [ "itoa", "serde", "serde_json", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -546,7 +546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc85178909a49c8827ffccfc9103a7ce1767ae66a801b69bdc326913870bf8e6" dependencies = [ "serde", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -1681,7 +1681,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -1992,38 +1992,14 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core 0.14.4", - "darling_macro 0.14.4", -] - [[package]] name = "darling" version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.20.10", - "darling_macro 0.20.10", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", + "darling_core", + "darling_macro", ] [[package]] @@ -2036,28 +2012,17 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.89", ] -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core 0.14.4", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling_macro" version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.20.10", + "darling_core", "quote", "syn 2.0.89", ] @@ -2494,7 +2459,7 @@ dependencies = [ "hex", "log", "parentchain-listener", - "scale-encode 0.7.1", + "scale-encode 0.10.0", "serde_json", "solana-intent-executor", "tokio", @@ -4093,7 +4058,6 @@ dependencies = [ "parentchain-rpc-client", "parentchain-storage", "parity-scale-codec", - "scale-encode 0.7.1", "subxt", "subxt-core", "subxt-signer", @@ -4116,6 +4080,7 @@ dependencies = [ "log", "parentchain-primitives", "parity-scale-codec", + "scale-encode 0.10.0", "subxt", "subxt-core", ] @@ -4420,23 +4385,13 @@ dependencies = [ "toml", ] -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - [[package]] name = "proc-macro-crate" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.22.22", + "toml_edit", ] [[package]] @@ -5173,6 +5128,16 @@ dependencies = [ "serde", ] +[[package]] +name = "scale-bits" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27243ab0d2d6235072b017839c5f0cd1a3b1ce45c0f7a715363b0c7d36c76c94" +dependencies = [ + "parity-scale-codec", + "scale-type-resolver", +] + [[package]] name = "scale-decode" version = "0.14.0" @@ -5182,7 +5147,7 @@ dependencies = [ "derive_more 1.0.0", "parity-scale-codec", "primitive-types 0.13.1", - "scale-bits", + "scale-bits 0.6.0", "scale-decode-derive", "scale-type-resolver", "smallvec", @@ -5194,7 +5159,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ed9401effa946b493f9f84dc03714cca98119b230497df6f3df6b84a2b03648" dependencies = [ - "darling 0.20.10", + "darling", "proc-macro2", "quote", "syn 2.0.89", @@ -5202,54 +5167,54 @@ dependencies = [ [[package]] name = "scale-encode" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ba0b9c48dc0eb20c60b083c29447c0c4617cb7c4a4c9fef72aa5c5bc539e15e" +checksum = "5f9271284d05d0749c40771c46180ce89905fd95aa72a2a2fddb4b7c0aa424db" dependencies = [ - "derive_more 0.99.18", + "derive_more 1.0.0", "parity-scale-codec", - "primitive-types 0.12.2", - "scale-bits", - "scale-encode-derive 0.7.1", + "primitive-types 0.13.1", + "scale-bits 0.6.0", + "scale-encode-derive 0.8.0", "scale-type-resolver", "smallvec", ] [[package]] name = "scale-encode" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9271284d05d0749c40771c46180ce89905fd95aa72a2a2fddb4b7c0aa424db" +checksum = "64901733157f9d25ef86843bd783eda439fac7efb0ad5a615d12d2cf3a29464b" dependencies = [ - "derive_more 1.0.0", "parity-scale-codec", "primitive-types 0.13.1", - "scale-bits", - "scale-encode-derive 0.8.0", + "scale-bits 0.7.0", + "scale-encode-derive 0.10.0", "scale-type-resolver", "smallvec", + "thiserror 2.0.6", ] [[package]] name = "scale-encode-derive" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82ab7e60e2d9c8d47105f44527b26f04418e5e624ffc034f6b4a86c0ba19c5bf" +checksum = "102fbc6236de6c53906c0b262f12c7aa69c2bdc604862c12728f5f4d370bc137" dependencies = [ - "darling 0.14.4", - "proc-macro-crate 1.3.1", + "darling", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.89", ] [[package]] name = "scale-encode-derive" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "102fbc6236de6c53906c0b262f12c7aa69c2bdc604862c12728f5f4d370bc137" +checksum = "78a3993a13b4eafa89350604672c8757b7ea84c7c5947d4b3691e3169c96379b" dependencies = [ - "darling 0.20.10", + "darling", "proc-macro-crate 3.2.0", "proc-macro2", "quote", @@ -5316,7 +5281,7 @@ dependencies = [ "derive_more 1.0.0", "either", "parity-scale-codec", - "scale-bits", + "scale-bits 0.6.0", "scale-decode", "scale-encode 0.8.0", "scale-info", @@ -5548,7 +5513,7 @@ version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ - "darling 0.20.10", + "darling", "proc-macro2", "quote", "syn 2.0.89", @@ -7320,12 +7285,6 @@ dependencies = [ "hashbrown 0.14.5", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -7377,7 +7336,7 @@ dependencies = [ "parity-scale-codec", "polkadot-sdk", "primitive-types 0.13.1", - "scale-bits", + "scale-bits 0.6.0", "scale-decode", "scale-encode 0.8.0", "scale-info", @@ -7432,7 +7391,7 @@ dependencies = [ "parity-scale-codec", "polkadot-sdk", "primitive-types 0.13.1", - "scale-bits", + "scale-bits 0.6.0", "scale-decode", "scale-encode 0.8.0", "scale-info", @@ -7466,7 +7425,7 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "228db9a5c95a6d8dc6152b4d6cdcbabc4f60821dd3f482a4f8791e022b7caadb" dependencies = [ - "darling 0.20.10", + "darling", "parity-scale-codec", "proc-macro-error2", "quote", @@ -7858,17 +7817,6 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.22" @@ -7877,7 +7825,7 @@ checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", - "winnow 0.6.20", + "winnow", ] [[package]] @@ -8572,15 +8520,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "0.6.20" diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index f7e3ef9cc7..b41cc05f31 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -21,7 +21,7 @@ log = "0.4.22" tokio = "1.40.0" async-trait = "0.1.82" env_logger = "0.11.5" -scale-encode = "0.7.1" +scale-encode = "0.10.0" parity-scale-codec = "3.6.12" alloy = "0.3.6" clap = "4.5.17" From adfe42c51ed789ffb9ccc48804e69197215c80f0 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 10:57:15 +0000 Subject: [PATCH 07/22] exposing storage from rpc-client --- .../omni-executor/parentchain/rpc-client/src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs index 2f1813aaaf..e8f691326d 100644 --- a/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs @@ -28,6 +28,7 @@ use subxt::backend::BlockRef; use subxt::config::signed_extensions; use subxt::config::Header; use subxt::events::EventsClient; +use subxt::storage::StorageClient; use subxt::tx::TxClient; use subxt::{Config, OnlineClient}; use subxt_core::utils::AccountId32; @@ -84,9 +85,14 @@ pub struct SubxtClient { legacy: LegacyRpcMethods, events: EventsClient>, tx: TxClient>, + storage: StorageClient>, } -impl SubxtClient {} +impl SubxtClient { + pub fn storage(&self) -> &StorageClient> { + &self.storage + } +} #[async_trait] impl> SubstrateRpcClient @@ -251,7 +257,8 @@ impl> let events = online_client.events(); let tx = online_client.tx(); + let storage = online_client.storage(); - Ok(SubxtClient { legacy, events, tx }) + Ok(SubxtClient { legacy, events, tx, storage }) } } From 061c2f58d0681bf8b5afe54050768c3b3e1cf963 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 10:58:11 +0000 Subject: [PATCH 08/22] encoding account_id keys on account_store storage --- .../parentchain/storage/src/account_store.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tee-worker/omni-executor/parentchain/storage/src/account_store.rs b/tee-worker/omni-executor/parentchain/storage/src/account_store.rs index 8b987c9d37..19e58800fa 100644 --- a/tee-worker/omni-executor/parentchain/storage/src/account_store.rs +++ b/tee-worker/omni-executor/parentchain/storage/src/account_store.rs @@ -27,7 +27,7 @@ impl Default for AccountStoreStorage { impl Storage for AccountStoreStorage { fn get(&self, account_id: &AccountId) -> Option { - match self.db.get(account_id) { + match self.db.get(account_id.encode()) { Ok(Some(value)) => AccountStore::decode(&mut &value[..]) .map_err(|e| { log::error!("Error decoding value from storage: {:?}", e); @@ -42,18 +42,18 @@ impl Storage for AccountStoreStorage { } fn insert(&self, account_id: AccountId, account_store: AccountStore) -> Result<(), ()> { - self.db.put(account_id, account_store.encode()).map_err(|e| { + self.db.put(account_id.encode(), account_store.encode()).map_err(|e| { log::error!("Error inserting value into storage: {:?}", e); }) } fn remove(&self, account_id: &AccountId) -> Result<(), ()> { - self.db.delete(account_id).map_err(|e| { + self.db.delete(account_id.encode()).map_err(|e| { log::error!("Error removing value from storage: {:?}", e); }) } fn contains_key(&self, account_id: &AccountId) -> bool { - self.db.key_may_exist(account_id) + self.db.key_may_exist(account_id.encode()) } } From c7b37fac7a3e630bc79c2eada93b0d951c7cdf2a Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 11:02:18 +0000 Subject: [PATCH 09/22] adding rpc-client to parentchain storage --- tee-worker/omni-executor/parentchain/storage/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/tee-worker/omni-executor/parentchain/storage/Cargo.toml b/tee-worker/omni-executor/parentchain/storage/Cargo.toml index 5919952322..5c2333a147 100644 --- a/tee-worker/omni-executor/parentchain/storage/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/storage/Cargo.toml @@ -12,6 +12,7 @@ subxt-core = { workspace = true } executor-core = { path = "../../executor-core" } parentchain-api-interface = { path = "../api-interface" } +parentchain-rpc-client = { path = "../rpc-client" } [dev-dependencies] env_logger = { workspace = true } From 74eb7c54004c0050f1e36c10e82579957a9db1a0 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 11:02:45 +0000 Subject: [PATCH 10/22] adding init_storage --- .../parentchain/storage/src/lib.rs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tee-worker/omni-executor/parentchain/storage/src/lib.rs b/tee-worker/omni-executor/parentchain/storage/src/lib.rs index 9800234267..8a3179c683 100644 --- a/tee-worker/omni-executor/parentchain/storage/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/storage/src/lib.rs @@ -1,4 +1,51 @@ mod account_store; pub use account_store::AccountStoreStorage; +use executor_core::storage::Storage; +use parentchain_rpc_client::{ + CustomConfig, SubstrateRpcClientFactory, SubxtClient, SubxtClientFactory, +}; +use parity_scale_codec::Decode; +use subxt_core::utils::AccountId32 as AccountId; + const STORAGE_PATH: &str = "storage"; + +pub async fn init_storage(ws_rpc_endpoint: &str) -> Result<(), ()> { + let client_factory: SubxtClientFactory = SubxtClientFactory::new(ws_rpc_endpoint); + let client = client_factory.new_client().await.map_err(|e| { + log::error!("Could not create client: {:?}", e); + })?; + + init_account_store_storage(&client).await?; + + Ok(()) +} + +async fn init_account_store_storage(client: &SubxtClient) -> Result<(), ()> { + let storage_query = parentchain_api_interface::storage().omni_account().account_store_iter(); + let mut account_store_iter = client + .storage() + .at_latest() + .await + .map_err(|e| { + log::error!("Could not get storage at latest block: {:?}", e); + })? + .iter(storage_query) + .await + .map_err(|e| { + log::error!("Could not iterate account store: {:?}", e); + })?; + + let account_store_storage = AccountStoreStorage::new(); + + while let Some(Ok(kv)) = account_store_iter.next().await { + let account_id = AccountId::decode(&mut &kv.key_bytes[..]).map_err(|e| { + log::error!("Error decoding account id: {:?}", e); + })?; + account_store_storage.insert(account_id, kv.value).map_err(|e| { + log::error!("Error inserting account store: {:?}", e); + })?; + } + + Ok(()) +} From 659ed2c5b1a0fc75586a051d28d8f28c9a7e599a Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 11:03:13 +0000 Subject: [PATCH 11/22] init storage when running the worker --- tee-worker/omni-executor/Cargo.lock | 2 ++ tee-worker/omni-executor/executor-worker/Cargo.toml | 1 + tee-worker/omni-executor/executor-worker/src/main.rs | 3 +++ 3 files changed, 6 insertions(+) diff --git a/tee-worker/omni-executor/Cargo.lock b/tee-worker/omni-executor/Cargo.lock index 7d1c24d0f8..27ce21d200 100644 --- a/tee-worker/omni-executor/Cargo.lock +++ b/tee-worker/omni-executor/Cargo.lock @@ -2459,6 +2459,7 @@ dependencies = [ "hex", "log", "parentchain-listener", + "parentchain-storage", "scale-encode 0.10.0", "serde_json", "solana-intent-executor", @@ -4093,6 +4094,7 @@ dependencies = [ "executor-core", "log", "parentchain-api-interface", + "parentchain-rpc-client", "parity-scale-codec", "rocksdb", "subxt-core", diff --git a/tee-worker/omni-executor/executor-worker/Cargo.toml b/tee-worker/omni-executor/executor-worker/Cargo.toml index 93096b852e..f88871c506 100644 --- a/tee-worker/omni-executor/executor-worker/Cargo.toml +++ b/tee-worker/omni-executor/executor-worker/Cargo.toml @@ -12,6 +12,7 @@ executor-core = { path = "../executor-core" } hex = "0.4.3" log = { workspace = true } parentchain-listener = { path = "../parentchain/listener" } +parentchain-storage = { path = "../parentchain/storage" } scale-encode = { workspace = true } serde_json = "1.0.127" solana-intent-executor = { path = "../solana/intent-executor" } diff --git a/tee-worker/omni-executor/executor-worker/src/main.rs b/tee-worker/omni-executor/executor-worker/src/main.rs index 6feb4b0721..3a6fe15b8f 100644 --- a/tee-worker/omni-executor/executor-worker/src/main.rs +++ b/tee-worker/omni-executor/executor-worker/src/main.rs @@ -18,6 +18,7 @@ use crate::cli::Cli; use clap::Parser; use ethereum_intent_executor::EthereumIntentExecutor; use log::error; +use parentchain_storage::init_storage; use solana_intent_executor::SolanaIntentExecutor; use std::io::Write; use std::thread::JoinHandle; @@ -50,6 +51,8 @@ async fn main() -> Result<(), ()> { error!("Could not create data dir: {:?}", e); })?; + init_storage(&cli.parentchain_url).await.expect("Could not initialize storage"); + listen_to_parentchain(cli.parentchain_url, cli.ethereum_url, cli.solana_url, cli.start_block) .await .unwrap(); From 88e5350b2a73e7b55234d6fb8eaec3a7b536d063 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 11:09:33 +0000 Subject: [PATCH 12/22] updating rocksdb --- tee-worker/omni-executor/Cargo.lock | 9 ++++----- tee-worker/omni-executor/parentchain/storage/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tee-worker/omni-executor/Cargo.lock b/tee-worker/omni-executor/Cargo.lock index 27ce21d200..e4ed3c8b98 100644 --- a/tee-worker/omni-executor/Cargo.lock +++ b/tee-worker/omni-executor/Cargo.lock @@ -3495,14 +3495,13 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "librocksdb-sys" -version = "0.16.0+8.10.0" +version = "0.17.1+9.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce3d60bc059831dc1c83903fb45c103f75db65c5a7bf22272764d9cc683e348c" +checksum = "2b7869a512ae9982f4d46ba482c2a304f1efd80c6412a3d4bf57bb79a619679f" dependencies = [ "bindgen", "bzip2-sys", "cc", - "glob", "libc", "libz-sys", "lz4-sys", @@ -4828,9 +4827,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bd13e55d6d7b8cd0ea569161127567cd587676c99f4472f779a0279aa60a7a7" +checksum = "26ec73b20525cb235bad420f911473b69f9fe27cc856c5461bccd7e4af037f43" dependencies = [ "libc", "librocksdb-sys", diff --git a/tee-worker/omni-executor/parentchain/storage/Cargo.toml b/tee-worker/omni-executor/parentchain/storage/Cargo.toml index 5c2333a147..dec04ed770 100644 --- a/tee-worker/omni-executor/parentchain/storage/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/storage/Cargo.toml @@ -7,7 +7,7 @@ edition.workspace = true [dependencies] log = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive"] } -rocksdb = "0.22.0" +rocksdb = "0.23.0" subxt-core = { workspace = true } executor-core = { path = "../../executor-core" } From c5dc8b675e705efdd42cc45d72e52411db4bc684 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 11:13:41 +0000 Subject: [PATCH 13/22] cleaning up comments --- tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml index 2537f1ade3..66f0b98b50 100644 --- a/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml @@ -13,8 +13,6 @@ subxt = { workspace = true } subxt-core = { workspace = true } parentchain-primitives = { path = "../primitives" } -# executor-core = { path = "../../executor-core" } -# parentchain-api-interface = { path = "../api-interface" } [dev-dependencies] env_logger = { workspace = true } From da1bdb6377a1e726494d31264789d986db0fca32 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Fri, 10 Jan 2025 11:24:32 +0000 Subject: [PATCH 14/22] fixing fmt issue --- tee-worker/omni-executor/parentchain/listener/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tee-worker/omni-executor/parentchain/listener/Cargo.toml b/tee-worker/omni-executor/parentchain/listener/Cargo.toml index e2b6deb492..8ae72ca59e 100644 --- a/tee-worker/omni-executor/parentchain/listener/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/listener/Cargo.toml @@ -15,9 +15,9 @@ subxt-signer = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } executor-core = { path = "../../executor-core" } +parentchain-api-interface = { path = "../api-interface" } parentchain-primitives = { path = "../primitives" } parentchain-rpc-client = { path = "../rpc-client" } -parentchain-api-interface = { path = "../api-interface" } parentchain-storage = { path = "../storage" } [dev-dependencies] From 308028e5b49bbcd4074b7840652d9c7abe8eb948 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Mon, 13 Jan 2025 08:42:03 +0000 Subject: [PATCH 15/22] using workspace dependencies --- tee-worker/omni-executor/Cargo.toml | 9 +++++++++ .../omni-executor/ethereum/intent-executor/Cargo.toml | 2 +- tee-worker/omni-executor/executor-worker/Cargo.toml | 10 +++++----- .../omni-executor/parentchain/listener/Cargo.toml | 10 +++++----- .../omni-executor/parentchain/primitives/Cargo.toml | 2 +- .../omni-executor/parentchain/rpc-client/Cargo.toml | 2 +- .../omni-executor/parentchain/storage/Cargo.toml | 6 +++--- .../omni-executor/solana/intent-executor/Cargo.toml | 2 +- 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index b41cc05f31..45a44d48dd 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -31,5 +31,14 @@ subxt = "0.38.0" subxt-core = "0.38.0" subxt-signer = { version = "0.38.0", features = ["subxt"] } +executor-core = { path = "executor-core" } +ethereum-intent-executor = { path = "ethereum/intent-executor" } +solana-intent-executor = { path = "solana/intent-executor" } +parentchain-listener = { path = "parentchain/listener" } +parentchain-api-interface = { path = "parentchain/api-interface" } +parentchain-primitives = { path = "parentchain/primitives" } +parentchain-rpc-client = { path = "parentchain/rpc-client" } +parentchain-storage = { path = "parentchain/storage" } + [workspace.lints.clippy] result_unit_err = "allow" diff --git a/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml b/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml index 067bc06543..89a5a74886 100644 --- a/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml +++ b/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml @@ -7,7 +7,7 @@ edition.workspace = true [dependencies] alloy = { workspace = true, features = ["contract", "signer-local", "rpc", "rpc-types"] } async-trait = { workspace = true } -executor-core = { path = "../../executor-core" } +executor-core = { workspace = true } log = { workspace = true } [dev-dependencies] diff --git a/tee-worker/omni-executor/executor-worker/Cargo.toml b/tee-worker/omni-executor/executor-worker/Cargo.toml index f88871c506..b60e35e89c 100644 --- a/tee-worker/omni-executor/executor-worker/Cargo.toml +++ b/tee-worker/omni-executor/executor-worker/Cargo.toml @@ -7,15 +7,15 @@ edition.workspace = true [dependencies] clap = { workspace = true, features = ["derive"] } env_logger = { workspace = true } -ethereum-intent-executor = { path = "../ethereum/intent-executor" } -executor-core = { path = "../executor-core" } +ethereum-intent-executor = { workspace = true } +executor-core = { workspace = true } hex = "0.4.3" log = { workspace = true } -parentchain-listener = { path = "../parentchain/listener" } -parentchain-storage = { path = "../parentchain/storage" } +parentchain-listener = { workspace = true } +parentchain-storage = { workspace = true } scale-encode = { workspace = true } serde_json = "1.0.127" -solana-intent-executor = { path = "../solana/intent-executor" } +solana-intent-executor = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal"] } [lints] diff --git a/tee-worker/omni-executor/parentchain/listener/Cargo.toml b/tee-worker/omni-executor/parentchain/listener/Cargo.toml index 8ae72ca59e..0773cad198 100644 --- a/tee-worker/omni-executor/parentchain/listener/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/listener/Cargo.toml @@ -14,11 +14,11 @@ subxt-core = { workspace = true } subxt-signer = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } -executor-core = { path = "../../executor-core" } -parentchain-api-interface = { path = "../api-interface" } -parentchain-primitives = { path = "../primitives" } -parentchain-rpc-client = { path = "../rpc-client" } -parentchain-storage = { path = "../storage" } +executor-core = { workspace = true } +parentchain-api-interface = { workspace = true } +parentchain-primitives = { workspace = true } +parentchain-rpc-client = { workspace = true } +parentchain-storage = { workspace = true } [dev-dependencies] env_logger = { workspace = true } diff --git a/tee-worker/omni-executor/parentchain/primitives/Cargo.toml b/tee-worker/omni-executor/parentchain/primitives/Cargo.toml index 68bcc1b692..a1886dbbec 100644 --- a/tee-worker/omni-executor/parentchain/primitives/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/primitives/Cargo.toml @@ -5,7 +5,7 @@ authors = ['Trust Computing GmbH '] edition.workspace = true [dependencies] -executor-core = { path = "../../executor-core" } +executor-core = { workspace = true } [lints] workspace = true diff --git a/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml index 66f0b98b50..27535dca6d 100644 --- a/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/rpc-client/Cargo.toml @@ -12,7 +12,7 @@ scale-encode = { workspace = true } subxt = { workspace = true } subxt-core = { workspace = true } -parentchain-primitives = { path = "../primitives" } +parentchain-primitives = { workspace = true } [dev-dependencies] env_logger = { workspace = true } diff --git a/tee-worker/omni-executor/parentchain/storage/Cargo.toml b/tee-worker/omni-executor/parentchain/storage/Cargo.toml index dec04ed770..d9f9fc2219 100644 --- a/tee-worker/omni-executor/parentchain/storage/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/storage/Cargo.toml @@ -10,9 +10,9 @@ parity-scale-codec = { workspace = true, features = ["derive"] } rocksdb = "0.23.0" subxt-core = { workspace = true } -executor-core = { path = "../../executor-core" } -parentchain-api-interface = { path = "../api-interface" } -parentchain-rpc-client = { path = "../rpc-client" } +executor-core = { workspace = true } +parentchain-api-interface = { workspace = true } +parentchain-rpc-client = { workspace = true } [dev-dependencies] env_logger = { workspace = true } diff --git a/tee-worker/omni-executor/solana/intent-executor/Cargo.toml b/tee-worker/omni-executor/solana/intent-executor/Cargo.toml index 4c508966d7..61adb42412 100644 --- a/tee-worker/omni-executor/solana/intent-executor/Cargo.toml +++ b/tee-worker/omni-executor/solana/intent-executor/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true [dependencies] async-trait = { workspace = true } -executor-core = { path = "../../executor-core" } +executor-core = { workspace = true } log = { workspace = true } solana-client = { workspace = true } solana-sdk = { workspace = true } From 1ac8c68abdc235bd586fb44709c6f0420c0ad5c1 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Mon, 13 Jan 2025 08:46:29 +0000 Subject: [PATCH 16/22] fixing fmt issue --- tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml b/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml index 89a5a74886..0f698426ea 100644 --- a/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml +++ b/tee-worker/omni-executor/ethereum/intent-executor/Cargo.toml @@ -7,7 +7,7 @@ edition.workspace = true [dependencies] alloy = { workspace = true, features = ["contract", "signer-local", "rpc", "rpc-types"] } async-trait = { workspace = true } -executor-core = { workspace = true } +executor-core = { workspace = true } log = { workspace = true } [dev-dependencies] From f6f0598fdfb12273746433ae0dff5597ab09c873 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Tue, 14 Jan 2025 11:22:20 +0000 Subject: [PATCH 17/22] extending rpc-client --- .../parentchain/listener/src/event_handler.rs | 18 ++-- .../parentchain/listener/src/fetcher.rs | 36 +++++--- .../parentchain/listener/src/listener.rs | 7 +- .../listener/src/transaction_signer.rs | 8 +- .../parentchain/rpc-client/src/lib.rs | 84 ++++++++++++++++--- 5 files changed, 115 insertions(+), 38 deletions(-) diff --git a/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs b/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs index f76dfe7f66..16cf1e9048 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs @@ -51,8 +51,8 @@ pub struct EventHandler< EthereumIntentExecutorT: IntentExecutor, SolanaIntentExecutorT: IntentExecutor, KeyStoreT: KeyStore, - RpcClient: SubstrateRpcClient, - RpcClientFactory: SubstrateRpcClientFactory, + RpcClient: SubstrateRpcClient, + RpcClientFactory: SubstrateRpcClientFactory, AccountStoreStorage: Storage, > { metadata_provider: Arc, @@ -80,8 +80,8 @@ impl< EthereumIntentExecutorT: IntentExecutor, SolanaIntentExecutorT: IntentExecutor, KeyStoreT: KeyStore, - RpcClient: SubstrateRpcClient, - RpcClientFactory: SubstrateRpcClientFactory, + RpcClient: SubstrateRpcClient, + RpcClientFactory: SubstrateRpcClientFactory, AccountStoreStorage: Storage, > EventHandler< @@ -136,8 +136,10 @@ impl< EthereumIntentExecutorT: IntentExecutor + Send + Sync, SolanaIntentExecutorT: IntentExecutor + Send + Sync, KeyStoreT: KeyStore + Send + Sync, - RpcClient: SubstrateRpcClient + Send + Sync, - RpcClientFactory: SubstrateRpcClientFactory + Send + Sync, + RpcClient: SubstrateRpcClient + Send + Sync, + RpcClientFactory: SubstrateRpcClientFactory + + Send + + Sync, AccountStoreStorage: Storage + Send + Sync, > EventHandlerTrait for EventHandler< @@ -246,8 +248,8 @@ async fn handle_intent_requested_event< EthereumIntentExecutorT: IntentExecutor + Send + Sync, SolanaIntentExecutorT: IntentExecutor + Send + Sync, KeyStoreT: KeyStore + Send + Sync, - RpcClient: SubstrateRpcClient + Send + Sync, - RpcClientFactory: SubstrateRpcClientFactory + Send + Sync, + RpcClient: SubstrateRpcClient + Send + Sync, + RpcClientFactory: SubstrateRpcClientFactory + Send + Sync, >( ethereum_intent_executor: &EthereumIntentExecutorT, solana_intent_executor: &SolanaIntentExecutorT, diff --git a/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs b/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs index af0d8047d3..23d7cb7506 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/fetcher.rs @@ -26,22 +26,30 @@ use std::sync::Arc; /// Used for fetching data from parentchain pub struct Fetcher< AccountId, - RpcClient: SubstrateRpcClient, - RpcClientFactory: SubstrateRpcClientFactory, + Header, + RpcClient: SubstrateRpcClient, + RpcClientFactory: SubstrateRpcClientFactory, > { client_factory: Arc, client: Option, - phantom_data: PhantomData, + phantom_account_id: PhantomData, + phantom_header: PhantomData
, } impl< AccountId, - RpcClient: SubstrateRpcClient, - RpcClientFactory: SubstrateRpcClientFactory, - > Fetcher + Header, + RpcClient: SubstrateRpcClient, + RpcClientFactory: SubstrateRpcClientFactory, + > Fetcher { pub fn new(client_factory: Arc) -> Self { - Self { client: None, client_factory, phantom_data: PhantomData } + Self { + client: None, + client_factory, + phantom_account_id: PhantomData, + phantom_header: PhantomData, + } } async fn connect_if_needed(&mut self) { @@ -57,9 +65,10 @@ impl< #[async_trait] impl< AccountId: Sync + Send, - RpcClient: SubstrateRpcClient + Sync + Send, - RpcClientFactory: SubstrateRpcClientFactory + Sync + Send, - > LastFinalizedBlockNumFetcher for Fetcher + Header: Sync + Send, + RpcClient: SubstrateRpcClient + Sync + Send, + RpcClientFactory: SubstrateRpcClientFactory + Sync + Send, + > LastFinalizedBlockNumFetcher for Fetcher { async fn get_last_finalized_block_num(&mut self) -> Result, ()> { self.connect_if_needed().await; @@ -76,9 +85,10 @@ impl< #[async_trait] impl< AccountId: Sync + Send, - RpcClient: SubstrateRpcClient + Sync + Send, - RpcClientFactory: SubstrateRpcClientFactory + Sync + Send, - > EventsFetcher for Fetcher + Header: Sync + Send, + RpcClient: SubstrateRpcClient + Sync + Send, + RpcClientFactory: SubstrateRpcClientFactory + Sync + Send, + > EventsFetcher for Fetcher { async fn get_block_events(&mut self, block_num: u64) -> Result, ()> { self.connect_if_needed().await; diff --git a/tee-worker/omni-executor/parentchain/listener/src/listener.rs b/tee-worker/omni-executor/parentchain/listener/src/listener.rs index 55b89f46a3..5a94427a04 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/listener.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/listener.rs @@ -35,7 +35,12 @@ pub type ParentchainListener< SolanaIntentExecutor, AccountStoreStorage, > = Listener< - Fetcher<::AccountId, RpcClient, RpcClientFactory>, + Fetcher< + ::AccountId, + ::Header, + RpcClient, + RpcClientFactory, + >, SyncCheckpoint, CheckpointRepository, IntentEventId, diff --git a/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs b/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs index 95e0924849..10c42729e2 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/transaction_signer.rs @@ -13,8 +13,8 @@ use subxt_signer::sr25519::SecretKeyBytes; pub struct TransactionSigner< KeyStoreT, - RpcClient: SubstrateRpcClient, - RpcClientFactory: SubstrateRpcClientFactory, + RpcClient: SubstrateRpcClient, + RpcClientFactory: SubstrateRpcClientFactory, ChainConfig: Config, MetadataT, MetadataProviderT: MetadataProvider, @@ -27,8 +27,8 @@ pub struct TransactionSigner< impl< KeyStoreT: KeyStore, - RpcClient: SubstrateRpcClient, - RpcClientFactory: SubstrateRpcClientFactory, + RpcClient: SubstrateRpcClient, + RpcClientFactory: SubstrateRpcClientFactory, ChainConfig: Config< ExtrinsicParams = DefaultExtrinsicParams, AccountId = AccountId32, diff --git a/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs index e8f691326d..bb2151a581 100644 --- a/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/rpc-client/src/lib.rs @@ -23,6 +23,7 @@ use std::marker::PhantomData; use std::ops::Deref; use std::thread; use std::time::Duration; +use std::vec::Vec; use subxt::backend::legacy::LegacyRpcMethods; use subxt::backend::BlockRef; use subxt::config::signed_extensions; @@ -71,7 +72,8 @@ pub struct RuntimeVersion { /// For fetching data from Substrate RPC node #[async_trait] -pub trait SubstrateRpcClient { +pub trait SubstrateRpcClient { + async fn get_last_finalized_header(&mut self) -> Result, ()>; async fn get_last_finalized_block_num(&mut self) -> Result; async fn get_block_events(&mut self, block_num: u64) -> Result, ()>; async fn get_raw_metadata(&mut self, block_num: Option) -> Result, ()>; @@ -79,6 +81,13 @@ pub trait SubstrateRpcClient { async fn runtime_version(&mut self) -> Result; async fn get_genesis_hash(&mut self) -> Result, ()>; async fn get_account_nonce(&mut self, account_id: &AccountId) -> Result; + async fn get_storage_keys_paged( + &mut self, + key_prefix: Vec, + count: u32, + start_key: Option>, + ) -> Result>, ()>; + async fn get_storage_proof_by_keys(&mut self, keys: Vec>) -> Result>, ()>; } pub struct SubxtClient { @@ -95,14 +104,17 @@ impl SubxtClient { } #[async_trait] -impl> SubstrateRpcClient - for SubxtClient +impl> + SubstrateRpcClient for SubxtClient { - async fn get_last_finalized_block_num(&mut self) -> Result { + async fn get_last_finalized_header(&mut self) -> Result, ()> { let finalized_header = self.legacy.chain_get_finalized_head().await.map_err(|_| ())?; - match self.legacy.chain_get_header(Some(finalized_header)).await.map_err(|_| ())? { - Some(header) => Ok(header.number().into()), - None => Err(()), + self.legacy.chain_get_header(Some(finalized_header)).await.map_err(|_| ()) + } + async fn get_last_finalized_block_num(&mut self) -> Result { + match self.get_last_finalized_header().await { + Ok(Some(header)) => Ok(header.number().into()), + _ => Err(()), } } async fn get_block_events(&mut self, block_num: u64) -> Result, ()> { @@ -166,14 +178,44 @@ impl> SubstrateRpcClient Result { self.tx.account_nonce(account_id).await.map_err(|_| ()) } + + async fn get_storage_keys_paged( + &mut self, + key_prefix: Vec, + count: u32, + start_key: Option>, + ) -> Result>, ()> { + self.legacy + .state_get_keys_paged(key_prefix.as_slice(), count, start_key.as_deref(), None) + .await + .map_err(|_| ()) + } + + async fn get_storage_proof_by_keys(&mut self, keys: Vec>) -> Result>, ()> { + let keys: Vec<&[u8]> = keys.iter().map(|k| k.as_slice()).collect(); + let storage_proof = self + .legacy + .state_get_read_proof(keys, None) + .await + .map(|read_proof| read_proof.proof.into_iter().map(|bytes| bytes.to_vec()).collect()) + .map_err(|_| ())?; + + Ok(storage_proof) + } } -pub struct MockedRpcClient { +pub struct MockedRpcClient { block_num: u64, + _phantom: PhantomData, } #[async_trait] -impl SubstrateRpcClient for MockedRpcClient { +impl> + SubstrateRpcClient for MockedRpcClient +{ + async fn get_last_finalized_header(&mut self) -> Result, ()> { + Ok(None) + } async fn get_last_finalized_block_num(&mut self) -> Result { Ok(self.block_num) } @@ -198,13 +240,31 @@ impl SubstrateRpcClient for MockedRpcClient { Ok(vec![]) } - async fn get_account_nonce(&mut self, _account_id: &String) -> Result { + async fn get_account_nonce(&mut self, _account_id: &ChainConfig::AccountId) -> Result { Ok(0) } + + async fn get_storage_keys_paged( + &mut self, + _key_prefix: Vec, + _count: u32, + _start_key: Option>, + ) -> Result>, ()> { + Ok(vec![]) + } + + async fn get_storage_proof_by_keys(&mut self, _keys: Vec>) -> Result>, ()> { + Ok(vec![]) + } } #[async_trait] -pub trait SubstrateRpcClientFactory> { +pub trait SubstrateRpcClientFactory< + AccountId, + Header, + RpcClient: SubstrateRpcClient, +> +{ async fn new_client(&self) -> Result; } @@ -239,7 +299,7 @@ impl> SubxtClientFactory> - SubstrateRpcClientFactory> + SubstrateRpcClientFactory> for SubxtClientFactory { async fn new_client(&self) -> Result, ()> { From 6fc22a93e2db0a64bdaee79dd8edfb6714ea2e66 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Tue, 14 Jan 2025 11:23:45 +0000 Subject: [PATCH 18/22] installing dependencies to verify storage proofs --- tee-worker/omni-executor/Cargo.lock | 1372 ++++++++++++++++- tee-worker/omni-executor/Cargo.toml | 2 + .../parentchain/storage/Cargo.toml | 2 + 3 files changed, 1342 insertions(+), 34 deletions(-) diff --git a/tee-worker/omni-executor/Cargo.lock b/tee-worker/omni-executor/Cargo.lock index e4ed3c8b98..47a4b16004 100644 --- a/tee-worker/omni-executor/Cargo.lock +++ b/tee-worker/omni-executor/Cargo.lock @@ -666,6 +666,43 @@ version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +[[package]] +name = "aquamarine" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21cc1548309245035eb18aa7f0967da6bc65587005170c56e6ef2788a4cf3f4e" +dependencies = [ + "include_dir", + "itertools 0.10.5", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "ark-bls12-377" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb00293ba84f51ce3bd026bd0de55899c4e68f0a39a5728cebae3a73ffdc0a4f" +dependencies = [ + "ark-ec", + "ark-ff 0.4.2", + "ark-std 0.4.0", +] + +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff 0.4.2", + "ark-serialize 0.4.2", + "ark-std 0.4.0", +] + [[package]] name = "ark-bn254" version = "0.4.0" @@ -843,6 +880,12 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "array-bytes" +version = "6.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5dde061bd34119e902bbb2d9b90c5692635cf59fb91d582c2b68043f1b8293" + [[package]] name = "arrayref" version = "0.3.9" @@ -1173,6 +1216,17 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "binary-merkle-tree" +version = "16.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "181f5380e435b8ba6d901f8b16fc8908c6f0f8bea8973113d1c8718d89bb1809" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", +] + [[package]] name = "bincode" version = "1.3.3" @@ -1442,6 +1496,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "bounded-collections" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d077619e9c237a5d1875166f5e8033e8f6bff0c96f8caf81e1c2d7738c431bf" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "serde", +] + [[package]] name = "brotli" version = "7.0.0" @@ -1591,6 +1657,15 @@ dependencies = [ "nom", ] +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -1731,6 +1806,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -1792,6 +1873,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "tiny-keccak", +] + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -1804,6 +1905,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +[[package]] +name = "constcat" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7e35aee659887cbfb97aaf227ac12cad1a9d7c71e55ff3376839ed4e282d08" + [[package]] name = "convert_case" version = "0.4.0" @@ -2110,6 +2217,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-syn-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "derive-where" version = "1.2.7" @@ -2210,6 +2328,33 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "docify" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a772b62b1837c8f060432ddcc10b17aae1453ef17617a99bc07789252d2a5896" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e6be249b0a462a14784a99b19bf35a667bb5e09de611738bb7362fa4c95ff7" +dependencies = [ + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.89", + "termcolor", + "toml 0.8.19", + "walkdir", +] + [[package]] name = "downcast-rs" version = "1.2.1" @@ -2222,6 +2367,33 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" +[[package]] +name = "dyn-clonable" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "eager" version = "0.1.0" @@ -2238,6 +2410,7 @@ dependencies = [ "digest 0.10.7", "elliptic-curve", "rfc6979", + "serdect", "signature 2.2.0", "spki", ] @@ -2257,6 +2430,7 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ + "pkcs8", "signature 2.2.0", ] @@ -2274,6 +2448,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" +dependencies = [ + "curve25519-dalek 4.1.3", + "ed25519 2.2.3", + "serde", + "sha2 0.10.8", + "subtle", + "zeroize", +] + [[package]] name = "ed25519-dalek-bip32" version = "0.2.0" @@ -2281,7 +2469,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d2be62a4061b872c8c0873ee4fc6f101ce7b889d039f019c5fa2af471a59908" dependencies = [ "derivation-path", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "hmac 0.12.1", "sha2 0.10.8", ] @@ -2322,6 +2510,7 @@ dependencies = [ "pkcs8", "rand_core 0.6.4", "sec1", + "serdect", "subtle", "zeroize", ] @@ -2384,6 +2573,12 @@ dependencies = [ "log", ] +[[package]] +name = "environmental" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" + [[package]] name = "equivalent" version = "1.0.1" @@ -2466,6 +2661,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "expander" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2c470c71d91ecbd179935b24170459e926382eaaa86b590b78814e180d8a8e2" +dependencies = [ + "blake2", + "file-guard", + "fs-err", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "fastrand" version = "2.1.1" @@ -2505,6 +2715,16 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "file-guard" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21ef72acf95ec3d7dbf61275be556299490a245f017cf084bd23b4f68cf9407c" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "five8_const" version = "0.1.3" @@ -2578,7 +2798,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02d3379df61ff3dd871e2dde7d1bcdc0263e613c21c7579b149fd4f0ad9b1dc2" dependencies = [ - "frame-metadata", + "frame-metadata 17.0.0", "parity-scale-codec", "scale-decode", "scale-info", @@ -2598,6 +2818,116 @@ dependencies = [ "serde", ] +[[package]] +name = "frame-metadata" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daaf440c68eb2c3d88e5760fe8c7af3f9fee9181fab6c2f2c4e7cc48dcc40bb8" +dependencies = [ + "cfg-if", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "frame-support" +version = "39.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4547b03c9267b2d545ddddd8967d1d39277a090814da2466176dc65ff489d0a" +dependencies = [ + "aquamarine", + "array-bytes", + "binary-merkle-tree", + "bitflags 1.3.2", + "docify", + "environmental", + "frame-metadata 18.0.0", + "frame-support-procedural", + "impl-trait-for-tuples", + "k256", + "log", + "macro_magic", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "serde_json", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-crypto-hashing-proc-macro", + "sp-debug-derive", + "sp-genesis-builder", + "sp-inherents", + "sp-io", + "sp-metadata-ir", + "sp-runtime", + "sp-staking", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "sp-weights", + "static_assertions", + "tt-call", +] + +[[package]] +name = "frame-support-procedural" +version = "31.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5819d1fcbf6dc177aca405c0b478366527a4763f21457d5ba3a1f4328f656c04" +dependencies = [ + "Inflector", + "cfg-expr", + "derive-syn-parse", + "docify", + "expander", + "frame-support-procedural-tools", + "itertools 0.11.0", + "macro_magic", + "proc-macro-warning", + "proc-macro2", + "quote", + "sp-crypto-hashing", + "syn 2.0.89", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "13.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a088fd6fda5f53ff0c17fc7551ce8bd0ead14ba742228443c8196296a7369b" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "12.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed971c6435503a099bdac99fe4c5bea08981709e5b5a0a8535a1856f48561191" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] + [[package]] name = "funty" version = "2.0.0" @@ -2644,6 +2974,7 @@ dependencies = [ "futures-core", "futures-task", "futures-util", + "num_cpus", ] [[package]] @@ -2838,6 +3169,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "hash-db" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + [[package]] name = "hash32" version = "0.2.1" @@ -3180,6 +3526,17 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "impl-num-traits" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "803d15461ab0dcc56706adf266158acbc44ccf719bf7d0af30705f58b90a4b8c" +dependencies = [ + "integer-sqrt", + "num-traits", + "uint 0.10.0", +] + [[package]] name = "impl-serde" version = "0.5.0" @@ -3200,6 +3557,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "include_dir" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indexmap" version = "2.6.0" @@ -3239,6 +3615,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + [[package]] name = "ipnet" version = "2.10.0" @@ -3260,6 +3645,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" @@ -3427,6 +3821,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", + "serdect", "sha2 0.10.8", ] @@ -3656,6 +4051,63 @@ dependencies = [ "libc", ] +[[package]] +name = "macro_magic" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc33f9f0351468d26fbc53d9ce00a096c8522ecb42f19b50f34f2c422f76d21d" +dependencies = [ + "macro_magic_core", + "macro_magic_macros", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "macro_magic_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1687dc887e42f352865a393acae7cf79d98fab6351cde1f58e9e057da89bf150" +dependencies = [ + "const-random", + "derive-syn-parse", + "macro_magic_core_macros", + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "macro_magic_core_macros" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "macro_magic_macros" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" +dependencies = [ + "macro_magic_core", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.7.4" @@ -3680,6 +4132,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memory-db" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" +dependencies = [ + "hash-db", +] + [[package]] name = "merlin" version = "3.0.0" @@ -3782,6 +4243,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "nom" version = "7.1.3" @@ -3798,6 +4265,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num" version = "0.2.1" @@ -3860,6 +4337,16 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec 0.7.6", + "itoa", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -4037,6 +4524,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parentchain-api-interface" version = "0.1.0" @@ -4091,14 +4584,29 @@ version = "0.1.0" dependencies = [ "env_logger", "executor-core", + "frame-support", "log", "parentchain-api-interface", "parentchain-rpc-client", "parity-scale-codec", "rocksdb", + "sp-state-machine", "subxt-core", ] +[[package]] +name = "parity-bip39" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e69bf016dc406eff7d53a7d3f7cf1c2e72c82b9088aac1118591e36dd2cd3e9" +dependencies = [ + "bitcoin_hashes 0.13.0", + "rand 0.8.5", + "rand_core 0.6.4", + "serde", + "unicode-normalization", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -4108,6 +4616,7 @@ dependencies = [ "arrayvec 0.7.6", "bitvec", "byte-slice-cast", + "bytes", "impl-trait-for-tuples", "parity-scale-codec-derive", "serde", @@ -4125,6 +4634,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "parity-wasm" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" + [[package]] name = "parking" version = "2.2.1" @@ -4294,6 +4809,43 @@ dependencies = [ "sp-crypto-hashing", ] +[[package]] +name = "polkavm-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d9428a5cfcc85c5d7b9fc4b6a18c4b802d0173d768182a51cc7751640f08b92" + +[[package]] +name = "polkavm-derive" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8c4bea6f3e11cd89bb18bcdddac10bd9a24015399bd1c485ad68a985a19606" +dependencies = [ + "polkavm-derive-impl-macro", +] + +[[package]] +name = "polkavm-derive-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fdfc49717fb9a196e74a5d28e0bc764eb394a2c803eb11133a31ac996c60c" +dependencies = [ + "polkavm-common", + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "polkavm-derive-impl-macro" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" +dependencies = [ + "polkavm-derive-impl", + "syn 2.0.89", +] + [[package]] name = "polling" version = "3.7.3" @@ -4353,6 +4905,16 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "prettyplease" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +dependencies = [ + "proc-macro2", + "syn 2.0.89", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -4372,6 +4934,7 @@ checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" dependencies = [ "fixed-hash", "impl-codec 0.7.0", + "impl-num-traits", "impl-serde", "scale-info", "uint 0.10.0", @@ -4383,7 +4946,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] @@ -4395,6 +4958,30 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -4417,6 +5004,17 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "proc-macro-warning" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "proc-macro2" version = "1.0.92" @@ -4440,7 +5038,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -4663,6 +5261,26 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "regex" version = "1.11.1" @@ -4671,8 +5289,17 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -4683,9 +5310,15 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -5300,6 +5933,17 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "schnellru" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" +dependencies = [ + "ahash", + "cfg-if", + "hashbrown 0.13.2", +] + [[package]] name = "schnorrkel" version = "0.11.4" @@ -5363,10 +6007,20 @@ dependencies = [ "der", "generic-array", "pkcs8", + "serdect", "subtle", "zeroize", ] +[[package]] +name = "secp256k1" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +dependencies = [ + "secp256k1-sys 0.9.2", +] + [[package]] name = "secp256k1" version = "0.30.0" @@ -5375,7 +6029,16 @@ checksum = "b50c5943d326858130af85e049f2661ba3c78b26589b8ab98e65e80ae44a1252" dependencies = [ "bitcoin_hashes 0.14.0", "rand 0.8.5", - "secp256k1-sys", + "secp256k1-sys 0.10.1", +] + +[[package]] +name = "secp256k1-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +dependencies = [ + "cc", ] [[package]] @@ -5387,6 +6050,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + [[package]] name = "secrecy" version = "0.10.3" @@ -5485,6 +6157,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -5520,6 +6201,16 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "serdect" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" +dependencies = [ + "base16ct", + "serde", +] + [[package]] name = "sha1" version = "0.10.6" @@ -5575,6 +6266,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -5606,6 +6306,12 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simple-mermaid" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "620a1d43d70e142b1d46a929af51d44f383db9c7a2ec122de2cd992ccfcf3c18" + [[package]] name = "siphasher" version = "0.3.11" @@ -6592,7 +7298,7 @@ dependencies = [ "byteorder", "chrono", "digest 0.10.7", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "ed25519-dalek-bip32", "getrandom 0.1.16", "hmac 0.12.1", @@ -6732,7 +7438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4af26c3f5ce349986fed81fc286f9bfc99438a57943bb67ef2372d06c8fd1c96" dependencies = [ "bs58", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "generic-array", "rand 0.8.5", "serde", @@ -7040,32 +7746,477 @@ dependencies = [ ] [[package]] -name = "sp-crypto-hashing" -version = "0.1.0" +name = "sp-api" +version = "35.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9927a7f81334ed5b8a98a4a978c81324d12bd9713ec76b5c68fd410174c5eb" +checksum = "7538a61120585b0e1e89d9de57448732ea4d3f9d175cab882b3c86e9809612a0" dependencies = [ - "blake2b_simd", - "byteorder", - "digest 0.10.7", - "sha2 0.10.8", - "sha3", - "twox-hash", + "docify", + "hash-db", + "log", + "parity-scale-codec", + "scale-info", + "sp-api-proc-macro", + "sp-core", + "sp-externalities", + "sp-metadata-ir", + "sp-runtime", + "sp-runtime-interface", + "sp-state-machine", + "sp-trie", + "sp-version", + "thiserror 1.0.69", ] [[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "spinning_top" -version = "0.3.0" +name = "sp-api-proc-macro" +version = "21.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" +checksum = "37f8b9621cfa68a45d6f9c124e672b8f6780839a6c95279a7877d244fef8d1dc" dependencies = [ - "lock_api", + "Inflector", + "blake2", + "expander", + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "sp-application-crypto" +version = "39.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f6850bd745fe9c0a200a8e729a82c8036250e1ad1ef24ed7498b2289935c974" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", +] + +[[package]] +name = "sp-arithmetic" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46d0d0a4c591c421d3231ddd5e27d828618c24456d51445d21a1f79fcee97c23" +dependencies = [ + "docify", + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-core" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4532774405a712a366a98080cbb4daa28c38ddff0ec595902ad6ee6a78a809f8" +dependencies = [ + "array-bytes", + "bitflags 1.3.2", + "blake2", + "bounded-collections", + "bs58", + "dyn-clonable", + "ed25519-zebra", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "itertools 0.11.0", + "k256", + "libsecp256k1 0.7.1", + "log", + "merlin", + "parity-bip39", + "parity-scale-codec", + "parking_lot", + "paste", + "primitive-types 0.13.1", + "rand 0.8.5", + "scale-info", + "schnorrkel", + "secp256k1 0.28.2", + "secrecy 0.8.0", + "serde", + "sp-crypto-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "ss58-registry", + "substrate-bip39", + "thiserror 1.0.69", + "tracing", + "w3f-bls", + "zeroize", +] + +[[package]] +name = "sp-crypto-hashing" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc9927a7f81334ed5b8a98a4a978c81324d12bd9713ec76b5c68fd410174c5eb" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.7", + "sha2 0.10.8", + "sha3", + "twox-hash", +] + +[[package]] +name = "sp-crypto-hashing-proc-macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b85d0f1f1e44bd8617eb2a48203ee854981229e3e79e6f468c7175d5fd37489b" +dependencies = [ + "quote", + "sp-crypto-hashing", + "syn 2.0.89", +] + +[[package]] +name = "sp-debug-derive" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "sp-externalities" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30cbf059dce180a8bf8b6c8b08b6290fa3d1c7f069a60f1df038ab5dd5fc0ba6" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-storage", +] + +[[package]] +name = "sp-genesis-builder" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4bd990146f77cdeff46e2a85b160718de021832a3c805c4a44c81f4ebba7999" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde_json", + "sp-api", + "sp-runtime", +] + +[[package]] +name = "sp-inherents" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575142ee4947deb9e5b731efbbfd432b1d28fc26f130f4cfdd3660e851907298" +dependencies = [ + "async-trait", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "thiserror 1.0.69", +] + +[[package]] +name = "sp-io" +version = "39.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86554fd101635b388e41ce83c28754ee30078e6a93480e1310914b4b09a67130" +dependencies = [ + "bytes", + "docify", + "ed25519-dalek 2.1.1", + "libsecp256k1 0.7.1", + "log", + "parity-scale-codec", + "polkavm-derive", + "rustversion", + "secp256k1 0.28.2", + "sp-core", + "sp-crypto-hashing", + "sp-externalities", + "sp-keystore", + "sp-runtime-interface", + "sp-state-machine", + "sp-tracing", + "sp-trie", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keystore" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1d41475fcdf253f9f0da839564c1b7f8a95c6a293ddfffd6e48e3671e76f33b" +dependencies = [ + "parity-scale-codec", + "parking_lot", + "sp-core", + "sp-externalities", +] + +[[package]] +name = "sp-metadata-ir" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427be4e8e6a33cb8ffc8c91f8834b9c6f563daf246e8f0da16e9e0db3db55f5a" +dependencies = [ + "frame-metadata 18.0.0", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "sp-panic-handler" +version = "13.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81478b3740b357fa0ea10fcdc1ee02ebae7734e50f80342c4743476d9f78eeea" +dependencies = [ + "backtrace", + "regex", +] + +[[package]] +name = "sp-runtime" +version = "40.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97c47600a543323cb53d013e2cb8e907d13d972ece014ea0b076700c455071c2" +dependencies = [ + "binary-merkle-tree", + "docify", + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "num-traits", + "parity-scale-codec", + "paste", + "rand 0.8.5", + "scale-info", + "serde", + "simple-mermaid", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-trie", + "sp-weights", + "tracing", + "tuplex", +] + +[[package]] +name = "sp-runtime-interface" +version = "29.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e83d940449837a8b2a01b4d877dd22d896fd14d3d3ade875787982da994a33" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "polkavm-derive", + "primitive-types 0.13.1", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-storage", + "sp-tracing", + "sp-wasm-interface", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0195f32c628fee3ce1dfbbf2e7e52a30ea85f3589da9fe62a8b816d70fc06294" +dependencies = [ + "Inflector", + "expander", + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "sp-staking" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16f953bf2c6702430f3374366b172ab024ee5e9fef5cccf29fa73a29161c2b0" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "sp-state-machine" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bce4ee5ee6c614994077e6e317270eab6fde2bc346b028290286cbf9d0011b7e" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "parking_lot", + "rand 0.8.5", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-trie", + "thiserror 1.0.69", + "tracing", + "trie-db", +] + +[[package]] +name = "sp-std" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8ee986414b0a9ad741776762f4083cd3a5128449b982a3919c4df36874834" + +[[package]] +name = "sp-storage" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee3b70ca340e41cde9d2e069d354508a6e37a6573d66f7cc38f11549002f64ec" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", +] + +[[package]] +name = "sp-tracing" +version = "17.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf641a1d17268c8fcfdb8e0fa51a79c2d4222f4cfda5f3944dbdbc384dced8d5" +dependencies = [ + "parity-scale-codec", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-trie" +version = "38.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1851c4929ae88932c6bcdb9e60f4063e478ca612012af3b6d365c7dc9c591f7f" +dependencies = [ + "ahash", + "hash-db", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot", + "rand 0.8.5", + "scale-info", + "schnellru", + "sp-core", + "sp-externalities", + "thiserror 1.0.69", + "tracing", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-version" +version = "38.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7561e88742bc47b2f5fbdcab77a1cd98cf04117a3e163c1aadd58b9a592a18" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-crypto-hashing-proc-macro", + "sp-runtime", + "sp-std", + "sp-version-proc-macro", + "thiserror 1.0.69", +] + +[[package]] +name = "sp-version-proc-macro" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54cabc8279e835cd9c608d70cb00e693bddec94fe8478e9f3104dad1da5f93ca" +dependencies = [ + "parity-scale-codec", + "proc-macro-warning", + "proc-macro2", + "quote", + "syn 2.0.89", +] + +[[package]] +name = "sp-wasm-interface" +version = "21.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b066baa6d57951600b14ffe1243f54c47f9c23dd89c262e17ca00ae8dca58be9" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", +] + +[[package]] +name = "sp-weights" +version = "31.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93cdaf72a1dad537bbb130ba4d47307ebe5170405280ed1aa31fa712718a400e" +dependencies = [ + "bounded-collections", + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-debug-derive", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spinning_top" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" +dependencies = [ + "lock_api", ] [[package]] @@ -7270,6 +8421,21 @@ dependencies = [ "spl-program-error", ] +[[package]] +name = "ss58-registry" +version = "1.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19409f13998e55816d1c728395af0b52ec066206341d939e22e7766df9b494b8" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -7314,6 +8480,19 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "substrate-bip39" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca58ffd742f693dc13d69bdbb2e642ae239e0053f6aab3b104252892f856700a" +dependencies = [ + "hmac 0.12.1", + "pbkdf2 0.12.2", + "schnorrkel", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "subtle" version = "2.6.1" @@ -7329,7 +8508,7 @@ dependencies = [ "async-trait", "derive-where", "either", - "frame-metadata", + "frame-metadata 17.0.0", "futures", "hex", "impl-serde", @@ -7384,7 +8563,7 @@ dependencies = [ "blake2", "derive-where", "frame-decode", - "frame-metadata", + "frame-metadata 17.0.0", "hashbrown 0.14.5", "hex", "impl-serde", @@ -7443,7 +8622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee13e6862eda035557d9a2871955306aff540d2b89c06e0a62a1136a700aed28" dependencies = [ "frame-decode", - "frame-metadata", + "frame-metadata 17.0.0", "hashbrown 0.14.5", "parity-scale-codec", "polkadot-sdk", @@ -7468,8 +8647,8 @@ dependencies = [ "regex", "schnorrkel", "scrypt", - "secp256k1", - "secrecy", + "secp256k1 0.30.0", + "secrecy 0.10.3", "serde", "serde_json", "sha2 0.10.8", @@ -7598,6 +8777,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -7638,6 +8826,16 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "threadpool" version = "1.8.1" @@ -7812,11 +9010,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -7825,6 +9038,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] @@ -7885,6 +9100,58 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "time", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "trie-db" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c992b4f40c234a074d48a757efeabb1a6be88af84c0c23f7ca158950cb0ae7f" +dependencies = [ + "hash-db", + "log", + "rustc-hex", + "smallvec", +] + +[[package]] +name = "trie-root" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" +dependencies = [ + "hash-db", ] [[package]] @@ -7893,6 +9160,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tt-call" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" + [[package]] name = "tungstenite" version = "0.20.1" @@ -7914,6 +9187,12 @@ dependencies = [ "webpki-roots 0.24.0", ] +[[package]] +name = "tuplex" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "676ac81d5454c4dcf37955d34fa8626ede3490f744b86ca14a7b90168d2a08aa" + [[package]] name = "twox-hash" version = "1.6.3" @@ -7922,6 +9201,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", + "rand 0.8.5", "static_assertions", ] @@ -8094,6 +9374,30 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "w3f-bls" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a3028804c8bbae2a97a15b71ffc0e308c4b01a520994aafa77d56e94e19024" +dependencies = [ + "ark-bls12-377", + "ark-bls12-381", + "ark-ec", + "ark-ff 0.4.2", + "ark-serialize 0.4.2", + "ark-serialize-derive", + "arrayref", + "constcat", + "digest 0.10.7", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "sha2 0.10.8", + "sha3", + "thiserror 1.0.69", + "zeroize", +] + [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index 45a44d48dd..a9eb11040f 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -30,6 +30,8 @@ solana-client = "2.1.5" subxt = "0.38.0" subxt-core = "0.38.0" subxt-signer = { version = "0.38.0", features = ["subxt"] } +sp-state-machine = { version = "0.44.0", features = ["std"] } +frame-support = {version = "39.0.0", features = ["std"]} executor-core = { path = "executor-core" } ethereum-intent-executor = { path = "ethereum/intent-executor" } diff --git a/tee-worker/omni-executor/parentchain/storage/Cargo.toml b/tee-worker/omni-executor/parentchain/storage/Cargo.toml index d9f9fc2219..0dfd231f90 100644 --- a/tee-worker/omni-executor/parentchain/storage/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/storage/Cargo.toml @@ -13,6 +13,8 @@ subxt-core = { workspace = true } executor-core = { workspace = true } parentchain-api-interface = { workspace = true } parentchain-rpc-client = { workspace = true } +sp-state-machine = { workspace = true, features = ["std"] } +frame-support = { workspace = true, features = ["std"] } [dev-dependencies] env_logger = { workspace = true } From b2fcdf837913d7d677412af89e6f9cf1844e5e8f Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Tue, 14 Jan 2025 11:24:21 +0000 Subject: [PATCH 19/22] refactoring init_account_store_storage to verify storage entries --- .../parentchain/storage/src/lib.rs | 116 ++++++++++++++---- 1 file changed, 91 insertions(+), 25 deletions(-) diff --git a/tee-worker/omni-executor/parentchain/storage/src/lib.rs b/tee-worker/omni-executor/parentchain/storage/src/lib.rs index 8a3179c683..49f1e8f373 100644 --- a/tee-worker/omni-executor/parentchain/storage/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/storage/src/lib.rs @@ -2,50 +2,116 @@ mod account_store; pub use account_store::AccountStoreStorage; use executor_core::storage::Storage; +use frame_support::sp_runtime::traits::BlakeTwo256; +use frame_support::storage::storage_prefix; +use parentchain_api_interface::omni_account::storage::types::account_store::AccountStore; use parentchain_rpc_client::{ - CustomConfig, SubstrateRpcClientFactory, SubxtClient, SubxtClientFactory, + CustomConfig, SubstrateRpcClient, SubstrateRpcClientFactory, SubxtClient, SubxtClientFactory, }; use parity_scale_codec::Decode; +use sp_state_machine::{read_proof_check, StorageProof}; use subxt_core::utils::AccountId32 as AccountId; const STORAGE_PATH: &str = "storage"; pub async fn init_storage(ws_rpc_endpoint: &str) -> Result<(), ()> { let client_factory: SubxtClientFactory = SubxtClientFactory::new(ws_rpc_endpoint); - let client = client_factory.new_client().await.map_err(|e| { + let mut client = client_factory.new_client().await.map_err(|e| { log::error!("Could not create client: {:?}", e); })?; - init_account_store_storage(&client).await?; + init_account_store_storage(&mut client).await?; Ok(()) } -async fn init_account_store_storage(client: &SubxtClient) -> Result<(), ()> { - let storage_query = parentchain_api_interface::storage().omni_account().account_store_iter(); - let mut account_store_iter = client - .storage() - .at_latest() - .await - .map_err(|e| { - log::error!("Could not get storage at latest block: {:?}", e); - })? - .iter(storage_query) - .await - .map_err(|e| { - log::error!("Could not iterate account store: {:?}", e); - })?; +async fn init_account_store_storage(client: &mut SubxtClient) -> Result<(), ()> { + let account_store_key_prefix = storage_prefix(b"OmniAccount", b"AccountStore"); + let page_size = 300; + let mut start_key: Option> = None; - let account_store_storage = AccountStoreStorage::new(); - - while let Some(Ok(kv)) = account_store_iter.next().await { - let account_id = AccountId::decode(&mut &kv.key_bytes[..]).map_err(|e| { - log::error!("Error decoding account id: {:?}", e); - })?; - account_store_storage.insert(account_id, kv.value).map_err(|e| { - log::error!("Error inserting account store: {:?}", e); + loop { + let storage_keys_paged = client + .get_storage_keys_paged(account_store_key_prefix.into(), page_size, start_key.clone()) + .await + .map_err(|e| { + log::error!("Could not get storage keys paged: {:?}", e); + })?; + if storage_keys_paged.is_empty() || storage_keys_paged.last().cloned() == start_key { + break; + } + start_key = storage_keys_paged.last().cloned(); + let proof = + client + .get_storage_proof_by_keys(storage_keys_paged.clone()) + .await + .map_err(|e| { + log::error!("Could not get storage proof by keys: {:?}", e); + })?; + let header = match client.get_last_finalized_header().await { + Ok(Some(header)) => header, + _ => { + log::error!("Could not get last finalized header"); + return Err(()); + }, + }; + let storage_proof = StorageProof::new(proof); + let storage_map = read_proof_check::( + header.state_root, + storage_proof, + &storage_keys_paged, + ) + .map_err(|e| { + log::error!("Could not read proof check: {:?}", e); })?; + let account_store_storage = AccountStoreStorage::new(); + for key in storage_keys_paged.iter() { + match storage_map.get(key) { + Some(Some(value)) => { + let account_id: AccountId = extract_account_id_from_storage_key(key)?; + let maybe_storage_value = client + .storage() + .at_latest() + .await + .map_err(|e| { + log::error!("Could not get storage at latest block: {:?}", e); + })? + .fetch_raw(key.clone()) + .await + .map_err(|e| { + log::error!("Could not fetch storage value: {:?}", e); + })?; + let Some(storage_value) = maybe_storage_value else { + log::error!("Storage value not found for account_id: {:?}", account_id); + return Err(()); + }; + if storage_value != *value { + log::error!("Storage value mismatch for account_id: {:?}", account_id); + return Err(()); + } + let account_store = AccountStore::decode(&mut &value[..]).map_err(|e| { + log::error!("Error decoding account store: {:?}", e); + })?; + account_store_storage.insert(account_id, account_store).map_err(|e| { + log::error!("Error inserting account store: {:?}", e); + })?; + }, + _ => { + log::error!("No value found for key: {:?}", key); + }, + } + } } Ok(()) } + +fn extract_account_id_from_storage_key(raw_storage_key: &[u8]) -> Result { + if raw_storage_key.len() < 32 { + return Err(()); + } + let mut raw_key = &raw_storage_key[raw_storage_key.len() - 32..]; + K::decode(&mut raw_key).map_err(|e| { + log::error!("Error decoding account id: {:?}", e); + }) +} From dfe776ee095b81e1049680d08530ae05fd9cd246 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Tue, 14 Jan 2025 11:42:30 +0000 Subject: [PATCH 20/22] fixing fmt issue --- tee-worker/omni-executor/Cargo.toml | 2 +- tee-worker/omni-executor/parentchain/storage/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index a9eb11040f..67f5746e02 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -31,7 +31,7 @@ subxt = "0.38.0" subxt-core = "0.38.0" subxt-signer = { version = "0.38.0", features = ["subxt"] } sp-state-machine = { version = "0.44.0", features = ["std"] } -frame-support = {version = "39.0.0", features = ["std"]} +frame-support = { version = "39.0.0", features = ["std"] } executor-core = { path = "executor-core" } ethereum-intent-executor = { path = "ethereum/intent-executor" } diff --git a/tee-worker/omni-executor/parentchain/storage/Cargo.toml b/tee-worker/omni-executor/parentchain/storage/Cargo.toml index 0dfd231f90..5a074c6cab 100644 --- a/tee-worker/omni-executor/parentchain/storage/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/storage/Cargo.toml @@ -11,10 +11,10 @@ rocksdb = "0.23.0" subxt-core = { workspace = true } executor-core = { workspace = true } +frame-support = { workspace = true, features = ["std"] } parentchain-api-interface = { workspace = true } parentchain-rpc-client = { workspace = true } sp-state-machine = { workspace = true, features = ["std"] } -frame-support = { workspace = true, features = ["std"] } [dev-dependencies] env_logger = { workspace = true } From 3e4a22547dc32587c3b4ee29ed44dcb59ade20e7 Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Tue, 14 Jan 2025 14:01:38 +0000 Subject: [PATCH 21/22] updating storage path --- tee-worker/omni-executor/parentchain/storage/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tee-worker/omni-executor/parentchain/storage/src/lib.rs b/tee-worker/omni-executor/parentchain/storage/src/lib.rs index 49f1e8f373..2b53ddacac 100644 --- a/tee-worker/omni-executor/parentchain/storage/src/lib.rs +++ b/tee-worker/omni-executor/parentchain/storage/src/lib.rs @@ -12,7 +12,7 @@ use parity_scale_codec::Decode; use sp_state_machine::{read_proof_check, StorageProof}; use subxt_core::utils::AccountId32 as AccountId; -const STORAGE_PATH: &str = "storage"; +const STORAGE_PATH: &str = "storage_db"; pub async fn init_storage(ws_rpc_endpoint: &str) -> Result<(), ()> { let client_factory: SubxtClientFactory = SubxtClientFactory::new(ws_rpc_endpoint); From 02ff1726c5291773b1b814eeac5769f75e85853a Mon Sep 17 00:00:00 2001 From: Francisco J Silva Date: Tue, 14 Jan 2025 14:02:00 +0000 Subject: [PATCH 22/22] adjusting manifest template --- tee-worker/omni-executor/omni-executor.manifest.template | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tee-worker/omni-executor/omni-executor.manifest.template b/tee-worker/omni-executor/omni-executor.manifest.template index c1b702710d..24e867ed0d 100644 --- a/tee-worker/omni-executor/omni-executor.manifest.template +++ b/tee-worker/omni-executor/omni-executor.manifest.template @@ -21,6 +21,7 @@ fs.mounts = [ { path = "/data", uri = "file:data", type="encrypted", key_name="{{'_sgx_mrsigner' if env.get('SGX', '0') == '1' else 'fake_sgx_mrsigner'}}" }, { path = "/etc", uri = "file:/etc" }, { path = "/usr", uri = "file:/usr" }, + { path = "/storage_db", uri = "file:storage_db" }, ] sgx.debug = true @@ -39,6 +40,10 @@ sgx.trusted_files = [ "file:/usr/lib/ssl/certs/ca-certificates.crt", ] +sgx.allowed_files = [ + "file:storage_db/", +] + # The maximum number of threads in a single process needs to be declared in advance. # You need to account for: # - one main thread @@ -54,4 +59,4 @@ sgx.remote_attestation = "dcap" loader.insecure__use_cmdline_argv = true loader.insecure__use_host_env = true -fs.insecure__keys.fake_sgx_mrsigner = "ffeeddccbbaa99887766554433221100" \ No newline at end of file +fs.insecure__keys.fake_sgx_mrsigner = "ffeeddccbbaa99887766554433221100"