From 203fa166c47aa4c58f8560480a906eb9b1e93cfc Mon Sep 17 00:00:00 2001 From: Serhii Temchenko Date: Mon, 24 Jul 2023 09:59:01 -0700 Subject: [PATCH 01/91] feat(847): Downgraded self-hosted runner instance type --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cb53c52d..1752bf7d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: branches: [Develop, main-net-runtime] env: - RUNNER_INSTANCE_TYPE: c5d.9xlarge + RUNNER_INSTANCE_TYPE: c5d.4xlarge jobs: start-runner: From 0c20e4a1aed9637b1f7560525d831fdea5773231 Mon Sep 17 00:00:00 2001 From: Serhii Temchenko Date: Mon, 24 Jul 2023 09:59:42 -0700 Subject: [PATCH 02/91] feat(847): Added condition to run the CI only on proper event or label assigned --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1752bf7d4..bfbc60aab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,8 @@ name: Continuous Integration on: - pull_request: [] + pull_request: + types: [labeled] push: branches: [Develop, main-net-runtime] @@ -11,6 +12,10 @@ env: jobs: start-runner: name: Start self-hosted EC2 runner + # Run the job only if it has proper label or it is triggered by the push to the dev or main branch. + if: | + contains(github.event.pull_request.labels.*.name, 'A0-PleaseReview') || + contains(github.event_name, 'push') runs-on: ubuntu-latest outputs: label: ${{ steps.start-ec2-runner.outputs.label }} From 81a68eedef2a36548bfe476e4aa2cac6296603bb Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Tue, 25 Jul 2023 15:08:10 +0200 Subject: [PATCH 03/91] initial ocex rpc server and traits declarations --- Cargo.lock | 42 ++++++-- Cargo.toml | 4 + pallets/ocex/rpc/Cargo.toml | 16 ++++ pallets/ocex/rpc/runtime-api/Cargo.toml | 16 ++++ pallets/ocex/rpc/runtime-api/src/lib.rs | 30 ++++++ pallets/ocex/rpc/src/lib.rs | 122 ++++++++++++++++++++++++ primitives/orderbook/src/recovery.rs | 3 +- primitives/orderbook/src/types.rs | 4 +- 8 files changed, 227 insertions(+), 10 deletions(-) create mode 100644 pallets/ocex/rpc/Cargo.toml create mode 100644 pallets/ocex/rpc/runtime-api/Cargo.toml create mode 100644 pallets/ocex/rpc/runtime-api/src/lib.rs create mode 100644 pallets/ocex/rpc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index c281ddf2d..e8a0055a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4600,7 +4600,7 @@ dependencies = [ [[package]] name = "node-polkadex-runtime" -version = "5.1.1" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5289,7 +5289,7 @@ dependencies = [ [[package]] name = "pallet-ocex-lmp" -version = "5.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5317,6 +5317,34 @@ dependencies = [ "trie-db", ] +[[package]] +name = "pallet-ocex-rpc" +version = "0.1.0" +dependencies = [ + "jsonrpsee", + "orderbook-primitives", + "pallet-ocex-runtime-api", + "parity-scale-codec", + "serde", + "serde_json", + "sp-api", + "sp-blockchain", + "sp-rpc", + "sp-runtime", +] + +[[package]] +name = "pallet-ocex-runtime-api" +version = "0.1.0" +dependencies = [ + "orderbook-primitives", + "parity-scale-codec", + "sp-api", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-offences" version = "4.0.0-dev" @@ -5945,7 +5973,7 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "polkadex-client" -version = "1.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "node-polkadex-runtime", @@ -5954,7 +5982,7 @@ dependencies = [ [[package]] name = "polkadex-node" -version = "5.2.0" +version = "5.3.0" dependencies = [ "clap 4.3.5", "frame-benchmarking-cli", @@ -9711,7 +9739,7 @@ dependencies = [ [[package]] name = "thea" -version = "1.1.0" +version = "5.3.0" dependencies = [ "env_logger", "frame-benchmarking", @@ -9739,7 +9767,7 @@ dependencies = [ [[package]] name = "thea-executor" -version = "1.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -9764,7 +9792,7 @@ dependencies = [ [[package]] name = "thea-message-handler" -version = "1.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/Cargo.toml b/Cargo.toml index 6cbb9d2db..9a9859e8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,8 @@ members = [ "rpc/assets/runtime-api", "pallets/pdex-migration", "pallets/ocex", + "pallets/ocex/rpc", + "pallets/ocex/rpc/runtime-api", "pallets/rewards", "primitives/orderbook", "primitives/polkadex", @@ -50,6 +52,8 @@ default-members = [ "pallets/pdex-migration", "pallets/pdex-migration", "pallets/ocex", + "pallets/ocex/rpc", + "pallets/ocex/rpc/runtime-api", "pallets/rewards", "primitives/orderbook", "primitives/polkadex", diff --git a/pallets/ocex/rpc/Cargo.toml b/pallets/ocex/rpc/Cargo.toml new file mode 100644 index 000000000..545c8884b --- /dev/null +++ b/pallets/ocex/rpc/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "pallet-ocex-rpc" +version = "0.1.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0.136" } +parity-scale-codec = { workspace = true, features = ["derive"] } +jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] } +sp-rpc = { workspace = true } +sp-blockchain = { workspace = true } +sp-api = { workspace = true } +sp-runtime = { workspace = true } +orderbook-primitives = { path = "../../../primitives/orderbook" } +pallet-ocex-runtime-api = { path = "runtime-api" } +serde_json = "1.0.96" diff --git a/pallets/ocex/rpc/runtime-api/Cargo.toml b/pallets/ocex/rpc/runtime-api/Cargo.toml new file mode 100644 index 000000000..7233ecc57 --- /dev/null +++ b/pallets/ocex/rpc/runtime-api/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "pallet-ocex-runtime-api" +version = "0.1.0" +edition = "2021" + +[dependencies] +parity-scale-codec = { workspace = true, default-features = false, features = ["derive"] } +sp-api = { workspace = true, default-features = false } +sp-runtime = { workspace = true, default-features = false } +sp-std = { workspace = true, default-features = false } +orderbook-primitives = { path = "../../../../primitives/orderbook" } +sp-core = { workspace = true, default-features = false } + +[features] +default = ["std"] +std = ["parity-scale-codec/std", "sp-api/std", "sp-runtime/std", "sp-std/std", "orderbook-primitives/std", "sp-core/std"] diff --git a/pallets/ocex/rpc/runtime-api/src/lib.rs b/pallets/ocex/rpc/runtime-api/src/lib.rs new file mode 100644 index 000000000..087d6e71d --- /dev/null +++ b/pallets/ocex/rpc/runtime-api/src/lib.rs @@ -0,0 +1,30 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] + +use orderbook_primitives::recovery::ObRecoveryState; +use parity_scale_codec::Codec; + +sp_api::decl_runtime_apis! { + pub trait PolkadexOcexRuntimeApi where AccountId: Codec, Hash : Codec { + fn get_ob_recover_state() -> Result; + // gets balance from given account of given asset + fn get_balance(from: AccountId, of: u64) -> Result; + } +} diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs new file mode 100644 index 000000000..82371bee8 --- /dev/null +++ b/pallets/ocex/rpc/src/lib.rs @@ -0,0 +1,122 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + +//! This crate provides an RPC methods for OCEX pallet - balances state and onchain/offchain +//! recovery data. + +use jsonrpsee::{ + core::{async_trait, Error as JsonRpseeError, RpcResult}, + proc_macros::rpc, + types::error::{CallError, ErrorObject}, +}; +use orderbook_primitives::recovery::ObRecoveryState; +pub use pallet_ocex_runtime_api::PolkadexOcexRuntimeApi; +use parity_scale_codec::Codec; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_runtime::traits::Block as BlockT; +use std::sync::Arc; + +const RUNTIME_ERROR: i32 = 1; + +#[rpc(client, server)] +pub trait PolkadexOcexRpcApi { + #[method(name = "ob_getRecoverState")] + fn get_ob_recover_state(&self, at: Option) -> RpcResult; + + #[method(name = "ob_getBalance")] + fn get_balance( + &self, + account_id: AccountId, + of: u64, + at: Option, + ) -> RpcResult; +} + +/// A structure that represents the Polkadex Rewards RPC, which allows querying +/// rewards-related information through remote procedure calls. +/// +/// # Type Parameters +/// +/// * `Client`: The client API used to interact with the Substrate runtime. +/// * `Block`: The block type of the Substrate runtime. +pub struct PolkadexOcexRpc { + /// An `Arc` reference to the client API for accessing runtime functionality. + client: Arc, + + /// A marker for the `Block` type parameter, used to ensure the struct + /// is covariant with respect to the block type. + _marker: std::marker::PhantomData, +} + +impl PolkadexOcexRpc { + pub fn new(client: Arc) -> Self { + Self { client, _marker: Default::default() } + } +} + +#[async_trait] +impl + PolkadexOcexRpcApiServer<::Hash, AccountId, Hash> + for PolkadexOcexRpc +where + Block: BlockT, + Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, + Client::Api: PolkadexOcexRuntimeApi, + AccountId: Codec, + Hash: Codec, +{ + fn get_ob_recover_state( + &self, + at: Option<::Hash>, + ) -> RpcResult { + let api = self.client.runtime_api(); + let at = match at { + Some(at) => at, + None => self.client.info().best_hash, + }; + Ok(api + .get_ob_recover_state(at) + .map_err(runtime_error_into_rpc_err)? + .map_err(runtime_error_into_rpc_err)?) + } + + fn get_balance( + &self, + account_id: AccountId, + of: u64, + at: Option<::Hash>, + ) -> RpcResult { + let api = self.client.runtime_api(); + let at = match at { + Some(at) => at, + None => self.client.info().best_hash, + }; + let runtime_api_result = + api.get_balance(at, account_id, of).map_err(runtime_error_into_rpc_err)?; + let json = + serde_json::to_string(&runtime_api_result).map_err(runtime_error_into_rpc_err)?; + Ok(json) + } +} + +/// Converts a runtime trap into an RPC error. +fn runtime_error_into_rpc_err(err: impl std::fmt::Debug) -> JsonRpseeError { + CallError::Custom(ErrorObject::owned(RUNTIME_ERROR, "Runtime error", Some(format!("{err:?}")))) + .into() +} diff --git a/primitives/orderbook/src/recovery.rs b/primitives/orderbook/src/recovery.rs index b0108a25f..2b438e180 100644 --- a/primitives/orderbook/src/recovery.rs +++ b/primitives/orderbook/src/recovery.rs @@ -20,12 +20,13 @@ use crate::types::AccountAsset; use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::{AccountId, BlockNumber}; use rust_decimal::Decimal; +use scale_info::TypeInfo; use serde_with::{json::JsonString, serde_as}; use std::collections::BTreeMap; /// A struct representing the recovery state of an Order Book. #[serde_as] -#[derive(Clone, Debug, Encode, Decode, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Encode, Decode, Default, serde::Serialize, serde::Deserialize, TypeInfo)] pub struct ObRecoveryState { /// The snapshot ID of the order book recovery state. pub snapshot_id: u64, diff --git a/primitives/orderbook/src/types.rs b/primitives/orderbook/src/types.rs index 0452cca0e..8e35ef225 100644 --- a/primitives/orderbook/src/types.rs +++ b/primitives/orderbook/src/types.rs @@ -24,6 +24,7 @@ use polkadex_primitives::{ ocex::TradingPairConfig, withdrawal::Withdrawal, AccountId, AssetId, Signature, }; use rust_decimal::{prelude::Zero, Decimal, RoundingStrategy}; +use scale_info::TypeInfo; use sp_core::H256; use sp_runtime::traits::Verify; use sp_std::cmp::Ordering; @@ -50,7 +51,7 @@ pub struct AccountInfo { } /// Defines account to asset map DTO to be used in the "Orderbook" client. -#[derive(Clone, Debug, Encode, Decode, Ord, PartialOrd, PartialEq, Eq)] +#[derive(Clone, Debug, Encode, Decode, Ord, PartialOrd, PartialEq, Eq, TypeInfo)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct AccountAsset { /// Main account identifier. @@ -130,7 +131,6 @@ impl Trade { #[cfg(feature = "std")] use chrono::Utc; use rust_decimal::prelude::FromPrimitive; -use scale_info::TypeInfo; impl Trade { /// Constructor. From 994be5cbd1eeb14571560c4dee19b520b2c225c2 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Tue, 25 Jul 2023 15:54:35 +0200 Subject: [PATCH 04/91] ocex api runtime mapping and get_balance implementation --- pallets/ocex/rpc/runtime-api/src/lib.rs | 2 +- pallets/ocex/rpc/src/lib.rs | 4 ++-- pallets/ocex/src/lib.rs | 26 ++++++++++++++++--------- runtime/src/lib.rs | 19 +++++++++++------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/pallets/ocex/rpc/runtime-api/src/lib.rs b/pallets/ocex/rpc/runtime-api/src/lib.rs index 087d6e71d..1bf511e7e 100644 --- a/pallets/ocex/rpc/runtime-api/src/lib.rs +++ b/pallets/ocex/rpc/runtime-api/src/lib.rs @@ -25,6 +25,6 @@ sp_api::decl_runtime_apis! { pub trait PolkadexOcexRuntimeApi where AccountId: Codec, Hash : Codec { fn get_ob_recover_state() -> Result; // gets balance from given account of given asset - fn get_balance(from: AccountId, of: u64) -> Result; + fn get_balance(from: AccountId, of: u128) -> Result; } } diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 82371bee8..6d6f4bc51 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -43,7 +43,7 @@ pub trait PolkadexOcexRpcApi { fn get_balance( &self, account_id: AccountId, - of: u64, + of: u128, at: Option, ) -> RpcResult; } @@ -99,7 +99,7 @@ where fn get_balance( &self, account_id: AccountId, - of: u64, + of: u128, at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 3eaa33a5b..49af9479c 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -36,7 +36,6 @@ use frame_support::{ }, BoundedVec, }; - use frame_system::ensure_signed; use pallet_timestamp as timestamp; use parity_scale_codec::Encode; @@ -49,7 +48,15 @@ use sp_runtime::{ }; use sp_std::prelude::*; // Re-export pallet items so that they can be accessed from the crate namespace. +use orderbook_primitives::{ + recovery::ObRecoveryState, types::TradingPair, SnapshotSummary, ValidatorSet, + GENESIS_AUTHORITY_SET_ID, +}; pub use pallet::*; +use polkadex_primitives::ocex::TradingPairConfig; +#[cfg(feature = "runtime-benchmarks")] +use sp_runtime::traits::One; +use sp_std::vec::Vec; #[cfg(test)] mod mock; @@ -58,14 +65,6 @@ mod tests; pub mod weights; -use orderbook_primitives::{ - types::TradingPair, SnapshotSummary, ValidatorSet, GENESIS_AUTHORITY_SET_ID, -}; -use polkadex_primitives::ocex::TradingPairConfig; -#[cfg(feature = "runtime-benchmarks")] -use sp_runtime::traits::One; -use sp_std::vec::Vec; - pub const OCEX: KeyTypeId = KeyTypeId(*b"ocex"); pub mod sr25519 { @@ -1233,6 +1232,15 @@ pub mod pallet { false } } + + pub fn get_ob_recover_state() -> Result { + ObRecoveryState {} + } + + pub fn get_balance(from: T::AccountId, of: u128) -> Result { + Ok(serde_json::to_string(&T::OtherAssets::balance(of, &from)) + .unwrap_or_else(|_| "failed to fetch proper balance for serialization".into())) + } } /// Events are a simple means of reporting specific conditions and diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ae1cb9198..5acee9c65 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -39,9 +39,6 @@ use frame_support::{ }, PalletId, RuntimeDebug, }; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use sp_std::vec; - #[cfg(any(feature = "std", test))] pub use frame_system::Call as SystemCall; use frame_system::{ @@ -59,6 +56,7 @@ use pallet_session::historical as pallet_session_historical; pub use pallet_staking::StakerStatus; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; pub use polkadex_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; @@ -66,6 +64,8 @@ use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_inherents::{CheckInherentsResult, InherentData}; +use sp_runtime::DispatchError; +use sp_std::vec; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -1566,19 +1566,24 @@ impl_runtime_apis! { } } - impl pallet_rewards_runtime_api::PolkadexRewardsRuntimeApi for Runtime { - fn account_info(account_id : AccountId, reward_id: u32) -> Result, sp_runtime::DispatchError> { - Rewards::account_info(account_id,reward_id) + impl pallet_rewards_runtime_api::PolkadexRewardsRuntimeApi for Runtime { + fn account_info(account_id : AccountId, reward_id: u32) -> Result, DispatchError> { + Rewards::account_info(account_id, reward_id) } } + impl pallet_ocex_runtime_api::PolkadexOcexRuntimeApi for Runtime { + fn get_ob_recover_state() -> Result { OCEX::get_ob_recover_state() } + fn get_balance(from: AccountId, of: u128) -> Result { OCEX::get_balance(from, of) } + } + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, block_hash: ::Hash, ) -> TransactionValidity { - Executive::validate_transaction(source, tx,block_hash) + Executive::validate_transaction(source, tx, block_hash) } } From 67b2cf6be960833852dc81febf37b158b1392182 Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 26 Jul 2023 10:10:58 +0300 Subject: [PATCH 05/91] Generate thea auth change message before era ends. --- Cargo.lock | 14 +++++++------- pallets/thea/src/lib.rs | 17 +++++++++++------ runtime/src/lib.rs | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c281ddf2d..55aa3e5f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4600,7 +4600,7 @@ dependencies = [ [[package]] name = "node-polkadex-runtime" -version = "5.1.1" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5289,7 +5289,7 @@ dependencies = [ [[package]] name = "pallet-ocex-lmp" -version = "5.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5945,7 +5945,7 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "polkadex-client" -version = "1.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "node-polkadex-runtime", @@ -5954,7 +5954,7 @@ dependencies = [ [[package]] name = "polkadex-node" -version = "5.2.0" +version = "5.3.0" dependencies = [ "clap 4.3.5", "frame-benchmarking-cli", @@ -9711,7 +9711,7 @@ dependencies = [ [[package]] name = "thea" -version = "1.1.0" +version = "5.3.0" dependencies = [ "env_logger", "frame-benchmarking", @@ -9739,7 +9739,7 @@ dependencies = [ [[package]] name = "thea-executor" -version = "1.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -9764,7 +9764,7 @@ dependencies = [ [[package]] name = "thea-message-handler" -version = "1.1.0" +version = "5.3.0" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index fd2cb7220..32bd4bfe1 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -358,18 +358,20 @@ impl Pallet { } fn change_authorities( - incoming: BoundedVec, - queued: BoundedVec, - ) { + incoming: BoundedVec, // n+1th set + queued: BoundedVec, // n+ 2th set + ) { // ( outgoing) -> (validators/incoming) -> (queued) + // nth epoch -> n+1th epoch -> n+2nd epoch let id = Self::validator_set_id(); - let outgoing = >::get(id); + let outgoing = >::get(id); // nth set ( active ,current ) let new_id = id + 1u64; // We need to issue a new message if the validator set is changing, // that is, the incoming set is has different session keys from outgoing set. // This last message should be signed by the outgoing set // Similar to how Grandpa's session change works. - if outgoing != incoming { + if incoming != queued { + // This should happen at the beginning of the last epoch let active_networks = >::get(); for network in active_networks { let message = Self::generate_payload(true, network, incoming.encode()); @@ -377,9 +379,12 @@ impl Pallet { >::insert(message.network, message.nonce); >::insert(message.network, message.nonce, message); } + >::put(queued); + } + if incoming != outgoing { + // This will happen when new era starts, or end of the last epoch >::insert(new_id, incoming); >::put(new_id); - >::put(queued); } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ae1cb9198..2c2d62da7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 289, + spec_version: 290, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From fd5ee0ae6e414783d9f371ae6293bee5bcc7a236 Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 26 Jul 2023 10:24:28 +0300 Subject: [PATCH 06/91] cargo fmt --- pallets/thea/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index 32bd4bfe1..575caca18 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -359,8 +359,9 @@ impl Pallet { fn change_authorities( incoming: BoundedVec, // n+1th set - queued: BoundedVec, // n+ 2th set - ) { // ( outgoing) -> (validators/incoming) -> (queued) + queued: BoundedVec, // n+ 2th set + ) { + // ( outgoing) -> (validators/incoming) -> (queued) // nth epoch -> n+1th epoch -> n+2nd epoch let id = Self::validator_set_id(); let outgoing = >::get(id); // nth set ( active ,current ) From 07cf3775a20ddd1f1ba5dd8ae89585c1b3e6788c Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 26 Jul 2023 15:17:17 +0300 Subject: [PATCH 07/91] Fix the payload generated --- pallets/thea/src/lib.rs | 8 ++++++-- runtime/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index 575caca18..4e378d475 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -38,7 +38,7 @@ use sp_runtime::{ Percent, RuntimeAppPublic, SaturatedConversion, }; use sp_std::prelude::*; -use thea_primitives::{types::Message, Network, GENESIS_AUTHORITY_SET_ID}; +use thea_primitives::{types::Message, Network, ValidatorSet, GENESIS_AUTHORITY_SET_ID}; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; @@ -375,7 +375,11 @@ impl Pallet { // This should happen at the beginning of the last epoch let active_networks = >::get(); for network in active_networks { - let message = Self::generate_payload(true, network, incoming.encode()); + let message = Self::generate_payload( + true, + network, + ValidatorSet::new(incoming.clone(), new_id).encode(), + ); // Update nonce >::insert(message.network, message.nonce); >::insert(message.network, message.nonce, message); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2c2d62da7..299598cce 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 290, + spec_version: 291, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From b0259af15ce92ac41755263f565f5e38e9340aa7 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Wed, 26 Jul 2023 17:08:21 +0200 Subject: [PATCH 08/91] ocex runtime api pallet implementation with data collection --- pallets/ocex/src/lib.rs | 71 ++++++++++++++++++++++++---- pallets/ocex/src/validator.rs | 29 ++++++++++-- primitives/orderbook/src/recovery.rs | 2 - 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 49af9479c..9075ffeb1 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -39,7 +39,7 @@ use frame_support::{ use frame_system::ensure_signed; use pallet_timestamp as timestamp; use parity_scale_codec::Encode; -use polkadex_primitives::assets::AssetId; +use polkadex_primitives::{assets::AssetId, AccountId}; use sp_application_crypto::RuntimeAppPublic; use sp_core::crypto::KeyTypeId; use sp_runtime::{ @@ -49,8 +49,8 @@ use sp_runtime::{ use sp_std::prelude::*; // Re-export pallet items so that they can be accessed from the crate namespace. use orderbook_primitives::{ - recovery::ObRecoveryState, types::TradingPair, SnapshotSummary, ValidatorSet, - GENESIS_AUTHORITY_SET_ID, + types::{AccountAsset, TradingPair}, + SnapshotSummary, ValidatorSet, GENESIS_AUTHORITY_SET_ID, }; pub use pallet::*; use polkadex_primitives::ocex::TradingPairConfig; @@ -1233,13 +1233,68 @@ pub mod pallet { } } - pub fn get_ob_recover_state() -> Result { - ObRecoveryState {} + pub fn get_ob_recover_state() -> Result< + ( + BTreeMap>, + BTreeMap, + u64, + u32, + u64, + u64, + ), + DispatchError, + > { + let account_id = + >::iter().fold(vec![], |mut ids_accum, (acc, acc_info)| { + ids_accum.push((acc.clone(), acc_info.proxies)); + ids_accum + }); + + let mut balances: BTreeMap = BTreeMap::new(); + let mut account_ids: BTreeMap> = BTreeMap::new(); + // all offchain balances for main accounts + for account in account_id { + let main = Self::transform_account(account.0)?; + let b = Self::get_offchain_balance(&main)?; + for (asset, balance) in b.into_iter() { + balances.insert(AccountAsset { main: main.clone(), asset }, balance); + } + let proxies = account.1.into_iter().try_fold(vec![], |mut accum, proxy| { + accum.push(Self::transform_account(proxy)?); + Ok::, DispatchError>(accum) + })?; + account_ids.insert(main, proxies); + } + + let state_info = Self::get_state_info(); + let last_processed_block_number = state_info.last_block; + let worker_nonce = state_info.worker_nonce; + let snapshot_id = state_info.snapshot_id; + let state_change_id = state_info.stid; + + Ok(( + account_ids, + balances, + snapshot_id, + last_processed_block_number, + state_change_id, + worker_nonce, + )) + } + + pub fn get_balance(from: T::AccountId, of: AssetId) -> Result { + Ok(Self::get_offchain_balance(&Self::transform_account(from)?) + .unwrap_or_else(|_| BTreeMap::new()) + .get(&of) + .unwrap_or_else(|| &Decimal::ZERO) + .to_owned()) } - pub fn get_balance(from: T::AccountId, of: u128) -> Result { - Ok(serde_json::to_string(&T::OtherAssets::balance(of, &from)) - .unwrap_or_else(|_| "failed to fetch proper balance for serialization".into())) + fn transform_account( + account: T::AccountId, + ) -> Result { + Decode::decode(&mut &account.encode()[..]) + .map_err(|_| Error::::AccountIdCannotBeDecoded.into()) } } diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 6a3c51521..fadfa43f3 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -5,16 +5,17 @@ use crate::{ storage::store_trie_root, Config, Pallet, SnapshotNonce, }; - use orderbook_primitives::{ types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, SnapshotSummary, }; use parity_scale_codec::{Decode, Encode}; -use polkadex_primitives::{ingress::IngressMessages, withdrawal::Withdrawal}; +use polkadex_primitives::{ingress::IngressMessages, withdrawal::Withdrawal, AssetId}; +use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; use sp_application_crypto::RuntimeAppPublic; use sp_core::{ + crypto::ByteArray, offchain::{Duration, HttpError}, H256, }; @@ -27,7 +28,7 @@ use sp_runtime::{ traits::BlakeTwo256, SaturatedConversion, }; -use sp_std::{boxed::Box, vec::Vec}; +use sp_std::{boxed::Box, collections::btree_map::BTreeMap, vec::Vec}; use sp_trie::{LayoutV1, TrieDBMut}; use trie_db::{TrieError, TrieMut}; @@ -318,6 +319,28 @@ impl Pallet { } auth_index } + + pub(crate) fn get_offchain_balance( + account: &polkadex_primitives::AccountId, + ) -> Result, &'static str> { + let mut root = crate::storage::load_trie_root(); + let mut storage = crate::storage::State; + let state = crate::storage::get_state_trie(&mut storage, &mut root); + let balance: BTreeMap = + match state.get(account.as_slice()).map_err(crate::validator::map_trie_error)? { + None => BTreeMap::new(), + Some(encoded) => BTreeMap::decode(&mut &encoded[..]) + .map_err(|_| "Unable to decode balances for account")?, + }; + Ok(balance) + } + + pub(crate) fn get_state_info() -> StateInfo { + let mut root = crate::storage::load_trie_root(); + let mut storage = crate::storage::State; + let state = crate::storage::get_state_trie(&mut storage, &mut root); + Self::load_state_info(&state) + } } use parity_scale_codec::alloc::string::ToString; diff --git a/primitives/orderbook/src/recovery.rs b/primitives/orderbook/src/recovery.rs index 2b438e180..abd198cc5 100644 --- a/primitives/orderbook/src/recovery.rs +++ b/primitives/orderbook/src/recovery.rs @@ -42,6 +42,4 @@ pub struct ObRecoveryState { pub state_change_id: u64, /// worker nonce pub worker_nonce: u64, - /// State version - pub state_version: u16, } From 18e8f0d15bb3f29a887f09105cab91e6f265e7ba Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Wed, 26 Jul 2023 18:22:19 +0200 Subject: [PATCH 09/91] full integration of rpc data propagation with decode hack --- Cargo.lock | 5 +++++ pallets/ocex/rpc/Cargo.toml | 1 + pallets/ocex/rpc/runtime-api/Cargo.toml | 6 ++++-- pallets/ocex/rpc/runtime-api/src/lib.rs | 8 +++++--- pallets/ocex/rpc/src/lib.rs | 21 ++++++++++++++------- runtime/Cargo.toml | 4 ++++ runtime/src/lib.rs | 23 +++++++++++------------ 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8a0055a1..42425e2ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4632,6 +4632,7 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-ocex-lmp", + "pallet-ocex-runtime-api", "pallet-offences", "pallet-preimage", "pallet-proxy", @@ -4652,6 +4653,7 @@ dependencies = [ "pdex-migration", "polkadex-primitives", "rpc-assets-runtime-api", + "rust_decimal", "scale-info", "sp-api", "sp-authority-discovery", @@ -5325,6 +5327,7 @@ dependencies = [ "orderbook-primitives", "pallet-ocex-runtime-api", "parity-scale-codec", + "polkadex-primitives", "serde", "serde_json", "sp-api", @@ -5339,6 +5342,8 @@ version = "0.1.0" dependencies = [ "orderbook-primitives", "parity-scale-codec", + "polkadex-primitives", + "rust_decimal", "sp-api", "sp-core", "sp-runtime", diff --git a/pallets/ocex/rpc/Cargo.toml b/pallets/ocex/rpc/Cargo.toml index 545c8884b..3df54f0c9 100644 --- a/pallets/ocex/rpc/Cargo.toml +++ b/pallets/ocex/rpc/Cargo.toml @@ -14,3 +14,4 @@ sp-runtime = { workspace = true } orderbook-primitives = { path = "../../../primitives/orderbook" } pallet-ocex-runtime-api = { path = "runtime-api" } serde_json = "1.0.96" +polkadex-primitives = { workspace = true } diff --git a/pallets/ocex/rpc/runtime-api/Cargo.toml b/pallets/ocex/rpc/runtime-api/Cargo.toml index 7233ecc57..d50531096 100644 --- a/pallets/ocex/rpc/runtime-api/Cargo.toml +++ b/pallets/ocex/rpc/runtime-api/Cargo.toml @@ -8,9 +8,11 @@ parity-scale-codec = { workspace = true, default-features = false, features = [" sp-api = { workspace = true, default-features = false } sp-runtime = { workspace = true, default-features = false } sp-std = { workspace = true, default-features = false } -orderbook-primitives = { path = "../../../../primitives/orderbook" } +orderbook-primitives = { path = "../../../../primitives/orderbook", default-features = false } sp-core = { workspace = true, default-features = false } +rust_decimal = { workspace = true, features = ["scale-codec"], default-features = false } +polkadex-primitives = { workspace = true, default-features = false } [features] default = ["std"] -std = ["parity-scale-codec/std", "sp-api/std", "sp-runtime/std", "sp-std/std", "orderbook-primitives/std", "sp-core/std"] +std = ["parity-scale-codec/std", "sp-api/std", "sp-runtime/std", "sp-std/std", "orderbook-primitives/std", "sp-core/std", "polkadex-primitives/std", "rust_decimal/std"] diff --git a/pallets/ocex/rpc/runtime-api/src/lib.rs b/pallets/ocex/rpc/runtime-api/src/lib.rs index 1bf511e7e..12398b8c2 100644 --- a/pallets/ocex/rpc/runtime-api/src/lib.rs +++ b/pallets/ocex/rpc/runtime-api/src/lib.rs @@ -18,13 +18,15 @@ #![cfg_attr(not(feature = "std"), no_std)] -use orderbook_primitives::recovery::ObRecoveryState; use parity_scale_codec::Codec; +use polkadex_primitives::AssetId; +use rust_decimal::Decimal; +use sp_std::vec::Vec; sp_api::decl_runtime_apis! { pub trait PolkadexOcexRuntimeApi where AccountId: Codec, Hash : Codec { - fn get_ob_recover_state() -> Result; + fn get_ob_recover_state() -> Result, sp_runtime::DispatchError>; // gets balance from given account of given asset - fn get_balance(from: AccountId, of: u128) -> Result; + fn get_balance(from: AccountId, of: AssetId) -> Result; } } diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 6d6f4bc51..10d1521f5 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -26,7 +26,8 @@ use jsonrpsee::{ }; use orderbook_primitives::recovery::ObRecoveryState; pub use pallet_ocex_runtime_api::PolkadexOcexRuntimeApi; -use parity_scale_codec::Codec; +use parity_scale_codec::{Codec, Decode}; +use polkadex_primitives::AssetId; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::traits::Block as BlockT; @@ -43,7 +44,7 @@ pub trait PolkadexOcexRpcApi { fn get_balance( &self, account_id: AccountId, - of: u128, + of: AssetId, at: Option, ) -> RpcResult; } @@ -90,16 +91,22 @@ where Some(at) => at, None => self.client.info().best_hash, }; - Ok(api - .get_ob_recover_state(at) - .map_err(runtime_error_into_rpc_err)? - .map_err(runtime_error_into_rpc_err)?) + // WARN: this is a hack on beating the boundry of runtime -> node + // with decoding tuple of underlying data into solid std type + Ok(Decode::decode( + &mut api + .get_ob_recover_state(at) + .map_err(runtime_error_into_rpc_err)? + .map_err(runtime_error_into_rpc_err)? + .as_ref(), + ) + .map_err(runtime_error_into_rpc_err)?) } fn get_balance( &self, account_id: AccountId, - of: u128, + of: AssetId, at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 948d7d8a7..2d9f41069 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -16,6 +16,7 @@ scale-info = { workspace = true, default-features = false, features = ["derive"] hex-literal = { version = "0.3.1", optional = true } static_assertions = { workspace = true } log = { workspace = true, default-features = false } +rust_decimal = { workspace = true, features = ["scale-codec"], default-features = false } #pallets #added pallet-authorship = { default-features = false, workspace = true } @@ -109,6 +110,7 @@ frame-try-runtime = { workspace = true, optional = true, default-features = fals rpc-assets-runtime-api = { path = "../rpc/assets/runtime-api", default-features = false } pallet-rewards-runtime-api = { path = "../pallets/rewards/rpc/runtime-api", default-features = false } +pallet-ocex-runtime-api = { path = "../pallets/ocex/rpc/runtime-api", default-features = false } [build-dependencies] substrate-wasm-builder = { workspace = true } @@ -116,6 +118,7 @@ substrate-wasm-builder = { workspace = true } [features] default = ["std"] std = [ + "rust_decimal/std", "parity-scale-codec/std", "scale-info/std", "log/std", @@ -174,6 +177,7 @@ std = [ "polkadex-primitives/std", "pdex-migration/std", "pallet-ocex-lmp/std", + "pallet-ocex-runtime-api/std", "rpc-assets-runtime-api/std", "pallet-rewards-runtime-api/std", "thea/std", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5acee9c65..8136c20f8 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -22,6 +22,7 @@ #![recursion_limit = "256"] #![deny(unused_crate_dependencies)] +use constants::{currency::*, time::*}; use frame_election_provider_support::{onchain, ElectionDataProvider, SequentialPhragmen}; use frame_support::{ construct_runtime, @@ -34,8 +35,10 @@ use frame_support::{ LockIdentifier, OnUnbalanced, U128CurrencyToVote, }, weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, - ConstantMultiplier, Weight, + constants::{ + BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, + }, + ConstantMultiplier, IdentityFee, Weight, }, PalletId, RuntimeDebug, }; @@ -57,16 +60,15 @@ pub use pallet_staking::StakerStatus; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use polkadex_primitives::AssetId; pub use polkadex_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; +use rust_decimal::Decimal; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_inherents::{CheckInherentsResult, InherentData}; -use sp_runtime::DispatchError; -use sp_std::vec; - #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::{ @@ -78,17 +80,14 @@ use sp_runtime::{ OpaqueKeys, SaturatedConversion, StaticLookup, }, transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill, + ApplyExtrinsicResult, DispatchError, FixedPointNumber, Perbill, Percent, Permill, Perquintill, }; -use sp_std::prelude::*; +use sp_std::{prelude::*, vec}; #[cfg(any(feature = "std", test))] use sp_version::NativeVersion; use sp_version::RuntimeVersion; use static_assertions::const_assert; -use constants::{currency::*, time::*}; -use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee}; - /// Implementations of some helper traits passed into runtime modules as associated types. pub mod impls; @@ -1573,8 +1572,8 @@ impl_runtime_apis! { } impl pallet_ocex_runtime_api::PolkadexOcexRuntimeApi for Runtime { - fn get_ob_recover_state() -> Result { OCEX::get_ob_recover_state() } - fn get_balance(from: AccountId, of: u128) -> Result { OCEX::get_balance(from, of) } + fn get_ob_recover_state() -> Result, DispatchError> { Ok(OCEX::get_ob_recover_state()?.encode()) } + fn get_balance(from: AccountId, of: AssetId) -> Result { OCEX::get_balance(from, of) } } impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { From fd0557fb2c2240ee51a58567f502061eedc8a126 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Wed, 26 Jul 2023 18:33:12 +0200 Subject: [PATCH 10/91] node rpc integration --- Cargo.lock | 1 + node/Cargo.toml | 1 + node/src/rpc.rs | 11 ++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42425e2ac..9ce2aa6dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6001,6 +6001,7 @@ dependencies = [ "node-polkadex-runtime", "pallet-im-online", "pallet-ocex-lmp", + "pallet-ocex-rpc", "pallet-rewards-rpc", "pallet-transaction-payment", "pallet-transaction-payment-rpc", diff --git a/node/Cargo.toml b/node/Cargo.toml index 260f0c049..55a69856c 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -29,6 +29,7 @@ jsonrpsee = { version = "0.16.2", features = ["server"] } node-polkadex-runtime = { path = "../runtime" } rpc-assets = { path = "../rpc/assets" } pallet-rewards-rpc = { path = "../pallets/rewards/rpc" } +pallet-ocex-rpc = { path = "../pallets/ocex/rpc" } polkadex-client = { path = "../client" } thea = { path = "../pallets/thea" } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 43c1ec136..759d7575f 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -30,14 +30,13 @@ #![warn(missing_docs)] -use std::sync::Arc; - use jsonrpsee::RpcModule; +use pallet_ocex_rpc::PolkadexOcexRpc; +use pallet_rewards_rpc::PolkadexRewardsRpc; use polkadex_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index}; use rpc_assets::{PolkadexAssetHandlerRpc, PolkadexAssetHandlerRpcApiServer}; use sc_client_api::{AuxStore, BlockchainEvents}; use sc_consensus_babe::BabeWorkerHandle; - use sc_consensus_grandpa::{ FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState, }; @@ -50,6 +49,7 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_consensus::SelectChain; use sp_consensus_babe::BabeApi; use sp_keystore::KeystorePtr; +use std::sync::Arc; /// Extra dependencies for BABE. pub struct BabeDeps { @@ -73,8 +73,6 @@ pub struct GrandpaDeps { pub finality_provider: Arc>, } -use pallet_rewards_rpc::PolkadexRewardsRpc; - /// Full client dependencies. pub struct FullDeps { /// The client instance to use. @@ -116,8 +114,10 @@ where B::State: sc_client_api::backend::StateBackend>, C::Api: rpc_assets::PolkadexAssetHandlerRuntimeApi, C::Api: pallet_rewards_rpc::PolkadexRewardsRuntimeApi, + C::Api: pallet_ocex_rpc::PolkadexOcexRuntimeApi, C: BlockchainEvents, { + use pallet_ocex_rpc::PolkadexOcexRpcApiServer; use pallet_rewards_rpc::PolkadexRewardsRpcApiServer; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_babe_rpc::{Babe, BabeApiServer}; @@ -164,6 +164,7 @@ where // io.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; io.merge(PolkadexAssetHandlerRpc::new(client.clone()).into_rpc())?; io.merge(PolkadexRewardsRpc::new(client.clone()).into_rpc())?; + io.merge(PolkadexOcexRpc::new(client.clone()).into_rpc())?; io.merge(Dev::new(client, deny_unsafe).into_rpc())?; Ok(io) From cdc9d1e894dd9a747fe45a3c1cd35323638a360e Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Wed, 26 Jul 2023 21:47:49 +0200 Subject: [PATCH 11/91] taplo format --- pallets/ocex/rpc/runtime-api/Cargo.toml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pallets/ocex/rpc/runtime-api/Cargo.toml b/pallets/ocex/rpc/runtime-api/Cargo.toml index d50531096..3198f361b 100644 --- a/pallets/ocex/rpc/runtime-api/Cargo.toml +++ b/pallets/ocex/rpc/runtime-api/Cargo.toml @@ -15,4 +15,13 @@ polkadex-primitives = { workspace = true, default-features = false } [features] default = ["std"] -std = ["parity-scale-codec/std", "sp-api/std", "sp-runtime/std", "sp-std/std", "orderbook-primitives/std", "sp-core/std", "polkadex-primitives/std", "rust_decimal/std"] +std = [ + "parity-scale-codec/std", + "sp-api/std", + "sp-runtime/std", + "sp-std/std", + "orderbook-primitives/std", + "sp-core/std", + "polkadex-primitives/std", + "rust_decimal/std", +] From 7979eb24c019df853458638ac15f6c5d469a6f98 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Wed, 26 Jul 2023 21:52:21 +0200 Subject: [PATCH 12/91] cargo lib fixes --- node/src/chain_spec.rs | 6 +++--- node/src/service.rs | 6 +++--- pallets/ocex/rpc/src/lib.rs | 4 ++-- pallets/ocex/src/lib.rs | 2 +- pallets/thea-executor/src/tests.rs | 8 ++++---- pallets/thea/src/tests.rs | 16 ++++++++-------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 6456d25c8..7476b3902 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1271,16 +1271,16 @@ pub(crate) mod tests { #[test] fn test_create_development_chain_spec() { - assert!(!development_config().build_storage().is_err()); + assert!(development_config().build_storage().is_ok()); } #[test] fn test_create_soba_testnet_chain_spec() { - assert!(!soba_testnet_config().build_storage().is_err()); + assert!(soba_testnet_config().build_storage().is_ok()); } #[test] fn test_staging_test_net_chain_spec() { - assert!(!udon_testnet_config().build_storage().is_err()); + assert!(udon_testnet_config().build_storage().is_ok()); } } diff --git a/node/src/service.rs b/node/src/service.rs index ee9314cfa..d88f4100d 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -605,7 +605,7 @@ mod tests { traits::{Block as BlockT, Header as HeaderT, IdentifyAccount, Verify}, RuntimeAppPublic, }; - use sp_timestamp; + use std::{borrow::Cow, sync::Arc}; type AccountPublic = ::Signer; @@ -777,7 +777,7 @@ mod tests { let signer = charlie.clone(); let function = RuntimeCall::Balances(BalancesCall::transfer { - dest: to.into(), + dest: to, value: amount, }); @@ -804,7 +804,7 @@ mod tests { let signature = raw_payload.using_encoded(|payload| signer.sign(payload)); let (function, extra, _) = raw_payload.deconstruct(); index += 1; - UncheckedExtrinsic::new_signed(function, from.into(), signature.into(), extra) + UncheckedExtrinsic::new_signed(function, from, signature.into(), extra) .into() }, ); diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 10d1521f5..24f359929 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -93,14 +93,14 @@ where }; // WARN: this is a hack on beating the boundry of runtime -> node // with decoding tuple of underlying data into solid std type - Ok(Decode::decode( + Decode::decode( &mut api .get_ob_recover_state(at) .map_err(runtime_error_into_rpc_err)? .map_err(runtime_error_into_rpc_err)? .as_ref(), ) - .map_err(runtime_error_into_rpc_err)?) + .map_err(runtime_error_into_rpc_err) } fn get_balance( diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 9075ffeb1..2d6d40450 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -1286,7 +1286,7 @@ pub mod pallet { Ok(Self::get_offchain_balance(&Self::transform_account(from)?) .unwrap_or_else(|_| BTreeMap::new()) .get(&of) - .unwrap_or_else(|| &Decimal::ZERO) + .unwrap_or(&Decimal::ZERO) .to_owned()) } diff --git a/pallets/thea-executor/src/tests.rs b/pallets/thea-executor/src/tests.rs index 6c5cb6a54..897c15024 100644 --- a/pallets/thea-executor/src/tests.rs +++ b/pallets/thea-executor/src/tests.rs @@ -214,7 +214,7 @@ fn test_set_withdrawal_fee_full() { fn test_parachain_withdraw_full() { new_test_ext().execute_with(|| { // setup code - let asset_id: ::AssetId = 100u128.into(); + let asset_id: ::AssetId = 100u128; let admin = 1u64; let network_id = 1; Balances::set_balance(&admin, 100_000_000_000_000_000_000u128.saturated_into()); @@ -245,7 +245,7 @@ fn test_parachain_withdraw_full() { ) .unwrap(); Assets::mint_into( - asset_id.into(), + asset_id, &account, 100_000_000_000_000_000_000u128.saturated_into(), ) @@ -294,7 +294,7 @@ fn test_parachain_withdraw_full() { assert_noop!( TheaExecutor::parachain_withdraw( RuntimeOrigin::signed(admin), - asset_id.into(), + asset_id, 1_000_000_000, beneficiary.clone(), false @@ -304,7 +304,7 @@ fn test_parachain_withdraw_full() { // proper case assert_ok!(TheaExecutor::parachain_withdraw( RuntimeOrigin::signed(account), - asset_id.into(), + asset_id, 1_000_000_000, beneficiary.clone(), false diff --git a/pallets/thea/src/tests.rs b/pallets/thea/src/tests.rs index f7ff27805..b520687e6 100644 --- a/pallets/thea/src/tests.rs +++ b/pallets/thea/src/tests.rs @@ -25,7 +25,7 @@ use sp_runtime::DispatchError::BadOrigin; const WELL_KNOWN: &str = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"; use sp_std::collections::btree_set::BTreeSet; -const PAYLOAD: [u8; 10_485_760] = [u8::MAX; 10_485_760]; +static PAYLOAD: [u8; 10_485_760] = [u8::MAX; 10_485_760]; fn any_signature() -> ::Signature { ::Signature::decode(&mut [1u8; 65].as_ref()).unwrap() @@ -42,7 +42,7 @@ fn set_200_validators() -> [Pair; 200] { validators .clone() .into_iter() - .for_each(|v| bv.try_push(v.public().into()).unwrap()); + .for_each(|v| bv.try_push(v.public()).unwrap()); >::insert(0, bv); validators .try_into() @@ -76,7 +76,7 @@ fn test_session_change() { validators .clone() .into_iter() - .for_each(|bls| authorities.push((&1, bls.public().into()))); + .for_each(|bls| authorities.push((&1, bls.public()))); let mut networks = BTreeSet::new(); networks.insert(1); >::put(networks); @@ -115,7 +115,7 @@ fn test_incoming_messages_bad_inputs() { Thea::incoming_message( RuntimeOrigin::signed(1), message.clone(), - vec![(0, proper_sig.clone().into())] + vec![(0, proper_sig.clone())] ), BadOrigin ); @@ -123,7 +123,7 @@ fn test_incoming_messages_bad_inputs() { assert_err!( Thea::validate_incoming_message( &message.clone(), - &vec![(0, proper_sig.clone().into())] + &vec![(0, proper_sig.clone())] ), InvalidTransaction::Custom(4) ); @@ -132,7 +132,7 @@ fn test_incoming_messages_bad_inputs() { assert_err!( Thea::validate_incoming_message( &message_for_nonce(u64::MAX), - &vec![(0, proper_sig.clone().into())] + &vec![(0, proper_sig.clone())] ), InvalidTransaction::Custom(1) ); @@ -140,7 +140,7 @@ fn test_incoming_messages_bad_inputs() { assert_err!( Thea::validate_incoming_message( &message_for_nonce(u64::MIN), - &vec![(0, proper_sig.clone().into())] + &vec![(0, proper_sig.clone())] ), InvalidTransaction::Custom(1) ); @@ -149,7 +149,7 @@ fn test_incoming_messages_bad_inputs() { bad_message.block_no = 1; // changing bit let bad_message_call = Call::::incoming_message { payload: bad_message, - signatures: vec![(0, proper_sig.clone().into())], + signatures: vec![(0, proper_sig.clone())], }; assert!(Thea::validate_unsigned(TransactionSource::Local, &bad_message_call).is_err()); // bad signature From f8837f6ecca91319c4c9a944daad959b9d4a37c9 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Wed, 26 Jul 2023 21:55:18 +0200 Subject: [PATCH 13/91] post fix fmt --- node/src/service.rs | 11 ++++------- pallets/thea-executor/src/tests.rs | 8 ++------ pallets/thea/src/tests.rs | 10 ++-------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/node/src/service.rs b/node/src/service.rs index d88f4100d..c393e9cc7 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -605,7 +605,7 @@ mod tests { traits::{Block as BlockT, Header as HeaderT, IdentifyAccount, Verify}, RuntimeAppPublic, }; - + use std::{borrow::Cow, sync::Arc}; type AccountPublic = ::Signer; @@ -776,10 +776,8 @@ mod tests { }; let signer = charlie.clone(); - let function = RuntimeCall::Balances(BalancesCall::transfer { - dest: to, - value: amount, - }); + let function = + RuntimeCall::Balances(BalancesCall::transfer { dest: to, value: amount }); let tip = 0; let extra: node_polkadex_runtime::SignedExtra = ( @@ -804,8 +802,7 @@ mod tests { let signature = raw_payload.using_encoded(|payload| signer.sign(payload)); let (function, extra, _) = raw_payload.deconstruct(); index += 1; - UncheckedExtrinsic::new_signed(function, from, signature.into(), extra) - .into() + UncheckedExtrinsic::new_signed(function, from, signature.into(), extra).into() }, ); } diff --git a/pallets/thea-executor/src/tests.rs b/pallets/thea-executor/src/tests.rs index 897c15024..6a268b8ab 100644 --- a/pallets/thea-executor/src/tests.rs +++ b/pallets/thea-executor/src/tests.rs @@ -244,12 +244,8 @@ fn test_parachain_withdraw_full() { 100_000_000_000_000_000_000u128.saturated_into(), ) .unwrap(); - Assets::mint_into( - asset_id, - &account, - 100_000_000_000_000_000_000u128.saturated_into(), - ) - .unwrap(); + Assets::mint_into(asset_id, &account, 100_000_000_000_000_000_000u128.saturated_into()) + .unwrap(); ::Currency::mint_into(&account, 100_000_000_000_000u128.saturated_into()) .unwrap(); Balances::set_balance(&account, 100_000_000_000_000u128.saturated_into()); diff --git a/pallets/thea/src/tests.rs b/pallets/thea/src/tests.rs index b520687e6..493852d00 100644 --- a/pallets/thea/src/tests.rs +++ b/pallets/thea/src/tests.rs @@ -39,10 +39,7 @@ fn set_200_validators() -> [Pair; 200] { } let mut bv: BoundedVec<::TheaId, ::MaxAuthorities> = BoundedVec::with_max_capacity(); - validators - .clone() - .into_iter() - .for_each(|v| bv.try_push(v.public()).unwrap()); + validators.clone().into_iter().for_each(|v| bv.try_push(v.public()).unwrap()); >::insert(0, bv); validators .try_into() @@ -121,10 +118,7 @@ fn test_incoming_messages_bad_inputs() { ); // bad threshold assert_err!( - Thea::validate_incoming_message( - &message.clone(), - &vec![(0, proper_sig.clone())] - ), + Thea::validate_incoming_message(&message.clone(), &vec![(0, proper_sig.clone())]), InvalidTransaction::Custom(4) ); From cc460a41a28dbc8355f5e2fd435d10bc0d482ae7 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 27 Jul 2023 10:08:37 +0300 Subject: [PATCH 14/91] Update unit test --- pallets/thea/src/lib.rs | 17 ++++++------ pallets/thea/src/tests.rs | 57 +++++++++++++++++++++++++++------------ runtime/src/lib.rs | 2 +- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index 4e378d475..a63e25b3b 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -374,15 +374,14 @@ impl Pallet { if incoming != queued { // This should happen at the beginning of the last epoch let active_networks = >::get(); - for network in active_networks { - let message = Self::generate_payload( - true, - network, - ValidatorSet::new(incoming.clone(), new_id).encode(), - ); - // Update nonce - >::insert(message.network, message.nonce); - >::insert(message.network, message.nonce, message); + if let Some(validator_set) = ValidatorSet::new(queued.clone(), new_id) { + let payload = validator_set.encode(); + for network in active_networks { + let message = Self::generate_payload(true, network, payload.clone()); + // Update nonce + >::insert(message.network, message.nonce); + >::insert(message.network, message.nonce, message); + } } >::put(queued); } diff --git a/pallets/thea/src/tests.rs b/pallets/thea/src/tests.rs index f7ff27805..d28b8b39f 100644 --- a/pallets/thea/src/tests.rs +++ b/pallets/thea/src/tests.rs @@ -65,32 +65,55 @@ use frame_support::traits::OneSessionHandler; #[test] fn test_session_change() { new_test_ext().execute_with(|| { - let mut validators = Vec::with_capacity(200); - for i in 0..200 { - validators.push( - Pair::generate_with_phrase(Some(format!("{}//{}", WELL_KNOWN, i).as_str())).0, - ); + let mut authorities: Vec<(&u64, ::TheaId)> = Vec::with_capacity(200); + for i in 0..200u64 { + authorities.push(( + &1, + Pair::generate_with_phrase(Some(format!("{}//{}", WELL_KNOWN, i).as_str())) + .0 + .public() + .into(), + )); + } + + let mut queued: Vec<(&u64, ::TheaId)> = Vec::with_capacity(200); + for i in 0..200u64 { + queued.push(( + &1, + Pair::generate_with_phrase(Some(format!("{}//{}", WELL_KNOWN, i).as_str())) + .0 + .public() + .into(), + )); } - let mut authorities = Vec::new(); - validators - .clone() - .into_iter() - .for_each(|bls| authorities.push((&1, bls.public().into()))); let mut networks = BTreeSet::new(); networks.insert(1); >::put(networks); assert!(Thea::validator_set_id() == 0); assert!(Thea::outgoing_nonce(1) == 0); - let authorities_cloned: Vec<(&u64, ::TheaId)> = authorities.clone(); - let auth_len = authorities_cloned.len(); - Thea::on_new_session(false, authorities.into_iter(), authorities_cloned.into_iter()); + let current_authorities: Vec<::TheaId> = + authorities.iter().map(|(_, public)| public.clone()).collect(); + >::put(0); + >::insert(0, BoundedVec::truncate_from(current_authorities)); + // Simulating the on_new_session to last epoch of an era. + Thea::on_new_session(false, authorities.into_iter(), queued.clone().into_iter()); + assert!(Thea::validator_set_id() == 0); + assert!(Thea::outgoing_nonce(1) == 1); // Thea validator session change message is generated here + + let message = Thea::get_outgoing_messages(1, 1).unwrap(); + assert_eq!(message.nonce, 1); + let validator_set: ValidatorSet<::TheaId> = + ValidatorSet::decode(&mut &message.data[..]).unwrap(); + let queued_validators: Vec<::TheaId> = + queued.iter().map(|(_, public)| public.clone()).collect(); + assert_eq!(validator_set.set_id, 1); + assert_eq!(validator_set.validators, queued_validators); + + // Simulating the on_new_session to the first epoch of the next era. + Thea::on_new_session(false, queued.clone().into_iter(), queued.clone().into_iter()); assert!(Thea::validator_set_id() == 1); assert!(Thea::outgoing_nonce(1) == 1); - let message = Thea::get_outgoing_messages(1, 1).unwrap(); - let bounded_vec: BoundedVec<::TheaId, ::MaxAuthorities> = - BoundedVec::decode(&mut &message.data[..]).unwrap(); - assert_eq!(bounded_vec.to_vec().len(), auth_len); }) } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 299598cce..2d2acb11a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 291, + spec_version: 292, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 434b825220cc620ab0dad0c8904e07bfc42a92a7 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Thu, 27 Jul 2023 10:48:20 +0200 Subject: [PATCH 15/91] workspace dependencies and doc comments --- pallets/ocex/rpc/Cargo.toml | 4 ++-- pallets/ocex/src/lib.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pallets/ocex/rpc/Cargo.toml b/pallets/ocex/rpc/Cargo.toml index 3df54f0c9..ddd0fe46b 100644 --- a/pallets/ocex/rpc/Cargo.toml +++ b/pallets/ocex/rpc/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -serde = { version = "1.0.136" } +serde = { workspace = true, default-features = true } parity-scale-codec = { workspace = true, features = ["derive"] } jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] } sp-rpc = { workspace = true } @@ -13,5 +13,5 @@ sp-api = { workspace = true } sp-runtime = { workspace = true } orderbook-primitives = { path = "../../../primitives/orderbook" } pallet-ocex-runtime-api = { path = "runtime-api" } -serde_json = "1.0.96" +serde_json = { workspace = true, default-features = true } polkadex-primitives = { workspace = true } diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 2d6d40450..731a944cb 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -1233,6 +1233,11 @@ pub mod pallet { } } + /// Collects onchain registered main and proxy accounts + /// for each of main accounts collects balances from offchain storage + /// adds other required for recovery properties + /// Returned tuple resembles `orderbook_primitives::recovery::ObRecoveryState` + /// FIXME: use solid type here instead of tuple pub fn get_ob_recover_state() -> Result< ( BTreeMap>, @@ -1282,6 +1287,8 @@ pub mod pallet { )) } + /// Fetches balance of given `AssetId` for given `AccountId` from offchain storage + /// If nothing found - returns `Decimal::Zero` pub fn get_balance(from: T::AccountId, of: AssetId) -> Result { Ok(Self::get_offchain_balance(&Self::transform_account(from)?) .unwrap_or_else(|_| BTreeMap::new()) @@ -1290,6 +1297,7 @@ pub mod pallet { .to_owned()) } + // Converts `T::AccountId` into `polkadex_primitives::AccountId` fn transform_account( account: T::AccountId, ) -> Result { From 87eff77adb77f4e4fff362f0f7097f136e3545ae Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Thu, 27 Jul 2023 17:03:02 +0200 Subject: [PATCH 16/91] comment correction for ocex rpc --- pallets/ocex/rpc/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 24f359929..76ef94504 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -49,8 +49,8 @@ pub trait PolkadexOcexRpcApi { ) -> RpcResult; } -/// A structure that represents the Polkadex Rewards RPC, which allows querying -/// rewards-related information through remote procedure calls. +/// A structure that represents the Polkadex OCEX pallet RPC, which allows querying +/// individual balances and recovery state data. /// /// # Type Parameters /// From fbab844b33f5ef2abdbdbdc13ce886b06c869bf0 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 27 Jul 2023 18:34:22 +0300 Subject: [PATCH 17/91] Update validator set id check --- pallets/thea-message-handler/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/thea-message-handler/src/lib.rs b/pallets/thea-message-handler/src/lib.rs index e42ce7f32..faf21c69e 100644 --- a/pallets/thea-message-handler/src/lib.rs +++ b/pallets/thea-message-handler/src/lib.rs @@ -257,7 +257,7 @@ impl Pallet { return InvalidTransaction::Custom(1).into() } - if >::get() < payload.validator_set_id { + if >::get() < payload.validator_set_id && (!payload.is_key_change) { log::error!(target:"thea","Future validator set: Stored: {:?}, Given: {:?}",>::get(), payload.validator_set_id); // Reject message from future validator sets return InvalidTransaction::Custom(2).into() From 9a2df60e0104bbda27b60ed4f9290bdfc0428cd6 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Thu, 27 Jul 2023 18:42:13 +0200 Subject: [PATCH 18/91] get_balance tests --- pallets/ocex/src/tests.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pallets/ocex/src/tests.rs b/pallets/ocex/src/tests.rs index 037ed686e..0370ec00b 100644 --- a/pallets/ocex/src/tests.rs +++ b/pallets/ocex/src/tests.rs @@ -125,6 +125,10 @@ fn test_add_balance_new_account() { let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &amount.into()); + // test get_balance() + state.commit(); + let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); + assert_eq!(from_fn, amount.into()); }); } @@ -154,6 +158,10 @@ fn test_add_balance_existing_account_with_balance() { let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &(amount + amount2).into()); + // test get_balance() + state.commit(); + let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); + assert_eq!(from_fn, (amount + amount2).into()); }); } @@ -175,6 +183,10 @@ fn test_sub_balance_new_account() { Ok(_) => assert!(false), Err(e) => assert_eq!(e, "Account not found in trie"), } + // test get_balance() + state.commit(); + let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); + assert_eq!(from_fn, amount.into()); }); } @@ -213,6 +225,10 @@ fn test_sub_balance_existing_account_with_balance() { let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(amount - amount2 - amount3, 0); assert_eq!(account_info.get(&asset_id).unwrap(), &Decimal::from(0)); + // test get_balance() + state.commit(); + let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); + assert_eq!(from_fn, (amount - amount2 - amount3).into()); }); } From 4f4b850586f3acabd2400636fb9aba788456eb9e Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 27 Jul 2023 19:52:27 +0300 Subject: [PATCH 19/91] Remove validator set id check --- pallets/thea-message-handler/src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pallets/thea-message-handler/src/lib.rs b/pallets/thea-message-handler/src/lib.rs index faf21c69e..d947215dd 100644 --- a/pallets/thea-message-handler/src/lib.rs +++ b/pallets/thea-message-handler/src/lib.rs @@ -257,11 +257,7 @@ impl Pallet { return InvalidTransaction::Custom(1).into() } - if >::get() < payload.validator_set_id && (!payload.is_key_change) { - log::error!(target:"thea","Future validator set: Stored: {:?}, Given: {:?}",>::get(), payload.validator_set_id); - // Reject message from future validator sets - return InvalidTransaction::Custom(2).into() - } + let authorities = >::get(payload.validator_set_id).to_vec(); // Check for super majority const MAJORITY: u8 = 67; @@ -270,18 +266,18 @@ impl Pallet { if signatures.len() < threshold { log::error!(target:"thea","Threshold: {:?}, Signs len: {:?}",threshold, signatures.len()); - return InvalidTransaction::Custom(3).into() + return InvalidTransaction::Custom(2).into() } let encoded_payload = sp_io::hashing::sha2_256(&payload.encode()); for (index, signature) in signatures { log::debug!(target:"thea", "Get auth of index: {:?}",index); match authorities.get(*index as usize) { - None => return InvalidTransaction::Custom(4).into(), + None => return InvalidTransaction::Custom(3).into(), Some(auth) => if !auth.verify(&encoded_payload, &((*signature).clone().into())) { log::debug!(target:"thea", "signature of index: {:?} -> {:?}, Failed",index,auth); - return InvalidTransaction::Custom(5).into() + return InvalidTransaction::Custom(4).into() }, } } From daacadf6070ac11d64bc4ef3ff2294a6dcb2a570 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 27 Jul 2023 19:52:44 +0300 Subject: [PATCH 20/91] Remove validator set id check --- pallets/thea-message-handler/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/thea-message-handler/src/lib.rs b/pallets/thea-message-handler/src/lib.rs index d947215dd..7e76529df 100644 --- a/pallets/thea-message-handler/src/lib.rs +++ b/pallets/thea-message-handler/src/lib.rs @@ -257,7 +257,6 @@ impl Pallet { return InvalidTransaction::Custom(1).into() } - let authorities = >::get(payload.validator_set_id).to_vec(); // Check for super majority const MAJORITY: u8 = 67; From 2cdb00c6d5faa202fc7cbd7c5acc0f52e900c66d Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Thu, 27 Jul 2023 20:56:50 +0200 Subject: [PATCH 21/91] tests for get_ob_recover_state --- pallets/ocex/src/tests.rs | 70 ++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/pallets/ocex/src/tests.rs b/pallets/ocex/src/tests.rs index 0370ec00b..0a813da60 100644 --- a/pallets/ocex/src/tests.rs +++ b/pallets/ocex/src/tests.rs @@ -18,9 +18,8 @@ //! Tests for pallet-ocex. -use crate::*; +use crate::{storage::store_trie_root, *}; use frame_support::{assert_noop, assert_ok, bounded_vec}; - use polkadex_primitives::{assets::AssetId, withdrawal::Withdrawal, Signature, UNIT_BALANCE}; use rust_decimal::prelude::{FromPrimitive, ToPrimitive}; use sp_std::collections::btree_map::BTreeMap; @@ -115,6 +114,11 @@ fn test_add_balance_new_account() { register_offchain_ext(&mut ext); ext.execute_with(|| { let account_id = create_account_id(); + assert_ok!(OCEX::set_exchange_state(RuntimeOrigin::root(), true)); + assert_ok!(OCEX::register_main_account( + RuntimeOrigin::signed(account_id.clone()), + account_id.clone() + )); let asset_id = AssetId::Polkadex; let amount = 1000000; let mut root = crate::storage::load_trie_root(); @@ -127,8 +131,22 @@ fn test_add_balance_new_account() { assert_eq!(account_info.get(&asset_id).unwrap(), &amount.into()); // test get_balance() state.commit(); - let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); + drop(state); + store_trie_root(root); + let from_fn = OCEX::get_balance(account_id.clone(), asset_id).unwrap(); assert_eq!(from_fn, amount.into()); + // test get_ob_recover_state() + let rs = OCEX::get_ob_recover_state().unwrap(); + assert!(!rs.0.is_empty()); + assert!(!rs.1.is_empty()); + // account present + assert!(rs.0.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); + // balance present and correct + let expected: Decimal = amount.into(); + assert_eq!( + rs.1.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), + &expected + ); }); } @@ -140,6 +158,11 @@ fn test_add_balance_existing_account_with_balance() { register_offchain_ext(&mut ext); ext.execute_with(|| { let account_id = create_account_id(); + assert_ok!(OCEX::set_exchange_state(RuntimeOrigin::root(), true)); + assert_ok!(OCEX::register_main_account( + RuntimeOrigin::signed(account_id.clone()), + account_id.clone() + )); let asset_id = AssetId::Polkadex; let amount = 1000000; let mut root = crate::storage::load_trie_root(); @@ -160,8 +183,22 @@ fn test_add_balance_existing_account_with_balance() { assert_eq!(account_info.get(&asset_id).unwrap(), &(amount + amount2).into()); // test get_balance() state.commit(); - let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); + drop(state); + store_trie_root(root); + let from_fn = OCEX::get_balance(account_id.clone(), asset_id).unwrap(); assert_eq!(from_fn, (amount + amount2).into()); + // test get_ob_recover_state() + let rs = OCEX::get_ob_recover_state().unwrap(); + assert!(!rs.0.is_empty()); + assert!(!rs.1.is_empty()); + // account present + assert!(rs.0.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); + // balance present and correct + let expected: Decimal = (amount + amount2).into(); + assert_eq!( + rs.1.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), + &expected + ); }); } @@ -183,10 +220,6 @@ fn test_sub_balance_new_account() { Ok(_) => assert!(false), Err(e) => assert_eq!(e, "Account not found in trie"), } - // test get_balance() - state.commit(); - let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); - assert_eq!(from_fn, amount.into()); }); } @@ -198,6 +231,11 @@ fn test_sub_balance_existing_account_with_balance() { register_offchain_ext(&mut ext); ext.execute_with(|| { let account_id = create_account_id(); + assert_ok!(OCEX::set_exchange_state(RuntimeOrigin::root(), true)); + assert_ok!(OCEX::register_main_account( + RuntimeOrigin::signed(account_id.clone()), + account_id.clone() + )); let asset_id = AssetId::Polkadex; let amount = 3000000; let mut root = crate::storage::load_trie_root(); @@ -227,8 +265,22 @@ fn test_sub_balance_existing_account_with_balance() { assert_eq!(account_info.get(&asset_id).unwrap(), &Decimal::from(0)); // test get_balance() state.commit(); - let from_fn = OCEX::get_balance(account_id, asset_id).unwrap(); + drop(state); + store_trie_root(root); + let from_fn = OCEX::get_balance(account_id.clone(), asset_id).unwrap(); assert_eq!(from_fn, (amount - amount2 - amount3).into()); + // test get_ob_recover_state() + let rs = OCEX::get_ob_recover_state().unwrap(); + assert!(!rs.0.is_empty()); + assert!(!rs.1.is_empty()); + // account present + assert!(rs.0.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); + // balance present and correct + let expected: Decimal = (amount - amount2 - amount3).into(); + assert_eq!( + rs.1.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), + &expected + ); }); } From 1eadf70848a3646804b15685ad6c84838a06a3e0 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Thu, 27 Jul 2023 22:49:56 +0200 Subject: [PATCH 22/91] thea-message-handler test fix --- pallets/thea-message-handler/src/test.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/thea-message-handler/src/test.rs b/pallets/thea-message-handler/src/test.rs index 5c2149715..b9616ef66 100644 --- a/pallets/thea-message-handler/src/test.rs +++ b/pallets/thea-message-handler/src/test.rs @@ -21,7 +21,6 @@ use crate::{ TransactionSource, *, }; use frame_support::{assert_noop, assert_ok}; -use frame_system::EventRecord; use parity_scale_codec::{Decode, Encode}; use sp_core::{ByteArray, Pair}; use sp_runtime::traits::BadOrigin; @@ -132,7 +131,7 @@ fn test_incoming_message_full() { &vs.clone(), &vec![(0, signature.clone().into())] ), - InvalidTransaction::Custom(2) + InvalidTransaction::Custom(3) ); }) } From 2d87340418301d9ef443bdda4d2d97d170d290a7 Mon Sep 17 00:00:00 2001 From: 35359595 <35359595i@gmail.com> Date: Fri, 28 Jul 2023 00:39:16 +0200 Subject: [PATCH 23/91] encode/decode border test and bug fix --- pallets/ocex/src/lib.rs | 4 ++-- pallets/ocex/src/tests.rs | 35 +++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 731a944cb..c664f0022 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -1240,9 +1240,9 @@ pub mod pallet { /// FIXME: use solid type here instead of tuple pub fn get_ob_recover_state() -> Result< ( + u64, BTreeMap>, BTreeMap, - u64, u32, u64, u64, @@ -1278,9 +1278,9 @@ pub mod pallet { let state_change_id = state_info.stid; Ok(( + snapshot_id, account_ids, balances, - snapshot_id, last_processed_block_number, state_change_id, worker_nonce, diff --git a/pallets/ocex/src/tests.rs b/pallets/ocex/src/tests.rs index 0a813da60..d5bf2c569 100644 --- a/pallets/ocex/src/tests.rs +++ b/pallets/ocex/src/tests.rs @@ -36,7 +36,6 @@ use sp_core::{ offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWorkerExt}, ByteArray, Pair, H256, }; - use sp_keystore::{testing::MemoryKeystore, Keystore}; use sp_runtime::{AccountId32, DispatchError::BadOrigin, SaturatedConversion, TokenError}; use sp_std::default::Default; @@ -137,14 +136,14 @@ fn test_add_balance_new_account() { assert_eq!(from_fn, amount.into()); // test get_ob_recover_state() let rs = OCEX::get_ob_recover_state().unwrap(); - assert!(!rs.0.is_empty()); assert!(!rs.1.is_empty()); + assert!(!rs.2.is_empty()); // account present - assert!(rs.0.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); + assert!(rs.1.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); // balance present and correct let expected: Decimal = amount.into(); assert_eq!( - rs.1.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), + rs.2.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), &expected ); }); @@ -189,16 +188,31 @@ fn test_add_balance_existing_account_with_balance() { assert_eq!(from_fn, (amount + amount2).into()); // test get_ob_recover_state() let rs = OCEX::get_ob_recover_state().unwrap(); - assert!(!rs.0.is_empty()); assert!(!rs.1.is_empty()); + assert!(!rs.2.is_empty()); // account present - assert!(rs.0.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); + assert!(rs.1.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); // balance present and correct let expected: Decimal = (amount + amount2).into(); assert_eq!( - rs.1.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), + rs.2.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), &expected ); + // conversion test + let created = ObRecoveryState { + snapshot_id: rs.0, + account_ids: rs.1.clone(), + balances: rs.2.clone(), + last_processed_block_number: rs.3, + state_change_id: rs.4, + worker_nonce: rs.5, + }; + let c_encoded = created.encode(); + let encoded = rs.encode(); + assert_eq!(c_encoded, encoded); + let decoded = ObRecoveryState::decode(&mut encoded.as_ref()).unwrap(); + assert_eq!(decoded.account_ids, rs.1); + assert_eq!(decoded.balances, rs.2); }); } @@ -271,14 +285,14 @@ fn test_sub_balance_existing_account_with_balance() { assert_eq!(from_fn, (amount - amount2 - amount3).into()); // test get_ob_recover_state() let rs = OCEX::get_ob_recover_state().unwrap(); - assert!(!rs.0.is_empty()); assert!(!rs.1.is_empty()); + assert!(!rs.2.is_empty()); // account present - assert!(rs.0.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); + assert!(rs.1.get(&account_id).is_some_and(|v| !v.is_empty() && v[0] == account_id)); // balance present and correct let expected: Decimal = (amount - amount2 - amount3).into(); assert_eq!( - rs.1.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), + rs.2.get(&AccountAsset { main: account_id, asset: asset_id }).unwrap(), &expected ); }); @@ -2236,6 +2250,7 @@ fn test_withdrawal() { } use orderbook_primitives::{ + recovery::ObRecoveryState, types::{Order, OrderPayload, OrderSide, OrderStatus, OrderType, Trade}, Fees, }; From 0854cea7e5b63a93588bfda065074e0b755f3fc8 Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 28 Jul 2023 10:27:50 +0300 Subject: [PATCH 24/91] Bug fixes --- pallets/thea-executor/src/lib.rs | 7 ++++--- pallets/thea/src/lib.rs | 12 +++++++++--- runtime/src/lib.rs | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index a5d05e3d9..019a731c9 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -386,9 +386,10 @@ pub mod pallet { // User is ready to pay for remaining pending withdrawal for quick withdrawal let extra_withdrawals_available = T::WithdrawalSize::get().saturating_sub(pending_withdrawals.len() as u32); - total_fees = total_fees.saturating_add( - total_fees.saturating_mul(extra_withdrawals_available.saturated_into()), - ) + total_fees = + total_fees.saturating_add(total_fees.saturating_mul( + extra_withdrawals_available.saturating_sub(1).saturated_into(), + )) } // Pay the fees diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index a63e25b3b..ea26e52e5 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -313,7 +313,9 @@ impl Pallet { return InvalidTransaction::Custom(1).into() } - let authorities = >::get(payload.validator_set_id).to_vec(); + // Incoming messages are always signed by the current validators. + let current_set_id = >::get(); + let authorities = >::get(current_set_id).to_vec(); // Check for super majority const MAJORITY: u8 = 67; @@ -366,14 +368,13 @@ impl Pallet { let id = Self::validator_set_id(); let outgoing = >::get(id); // nth set ( active ,current ) let new_id = id + 1u64; - + let active_networks = >::get(); // We need to issue a new message if the validator set is changing, // that is, the incoming set is has different session keys from outgoing set. // This last message should be signed by the outgoing set // Similar to how Grandpa's session change works. if incoming != queued { // This should happen at the beginning of the last epoch - let active_networks = >::get(); if let Some(validator_set) = ValidatorSet::new(queued.clone(), new_id) { let payload = validator_set.encode(); for network in active_networks { @@ -389,6 +390,11 @@ impl Pallet { // This will happen when new era starts, or end of the last epoch >::insert(new_id, incoming); >::put(new_id); + for network in active_networks { + // TODO: Optimize this by checking if there is already another transfer + // that took place, so this dummy is unnecessary + Self::generate_payload(false, network, Vec::new()) + } } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2d2acb11a..f0879ba18 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 292, + spec_version: 293, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 87767e800d5affcb23e7052227ae16822c44b41a Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 28 Jul 2023 10:29:03 +0300 Subject: [PATCH 25/91] Bug fixes --- pallets/thea/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index ea26e52e5..d6cdbc7ae 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -391,8 +391,6 @@ impl Pallet { >::insert(new_id, incoming); >::put(new_id); for network in active_networks { - // TODO: Optimize this by checking if there is already another transfer - // that took place, so this dummy is unnecessary Self::generate_payload(false, network, Vec::new()) } } From 0d68a71387d4b6c194b75c92fd579a6e9d64188b Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 28 Jul 2023 10:49:10 +0300 Subject: [PATCH 26/91] Update session change test case --- pallets/thea/src/lib.rs | 8 +++++--- pallets/thea/src/tests.rs | 5 ++++- runtime/src/lib.rs | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index d6cdbc7ae..c7e93cb70 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -377,8 +377,8 @@ impl Pallet { // This should happen at the beginning of the last epoch if let Some(validator_set) = ValidatorSet::new(queued.clone(), new_id) { let payload = validator_set.encode(); - for network in active_networks { - let message = Self::generate_payload(true, network, payload.clone()); + for network in &active_networks { + let message = Self::generate_payload(true, *network, payload.clone()); // Update nonce >::insert(message.network, message.nonce); >::insert(message.network, message.nonce, message); @@ -391,7 +391,9 @@ impl Pallet { >::insert(new_id, incoming); >::put(new_id); for network in active_networks { - Self::generate_payload(false, network, Vec::new()) + let message = Self::generate_payload(false, network, Vec::new()); + >::insert(network, message.nonce); + >::insert(network, message.nonce, message); } } } diff --git a/pallets/thea/src/tests.rs b/pallets/thea/src/tests.rs index d28b8b39f..4a5b38373 100644 --- a/pallets/thea/src/tests.rs +++ b/pallets/thea/src/tests.rs @@ -113,7 +113,10 @@ fn test_session_change() { // Simulating the on_new_session to the first epoch of the next era. Thea::on_new_session(false, queued.clone().into_iter(), queued.clone().into_iter()); assert!(Thea::validator_set_id() == 1); - assert!(Thea::outgoing_nonce(1) == 1); + assert!(Thea::outgoing_nonce(1) == 2); + let message = Thea::get_outgoing_messages(1, 2).unwrap(); + assert_eq!(message.nonce, 2); + assert!(message.data.is_empty()); }) } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f0879ba18..3f499bbd9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 293, + spec_version: 294, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From cabc17cc3a77468338fefca935ae737f766aa26c Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 28 Jul 2023 11:31:03 +0300 Subject: [PATCH 27/91] Update test case --- pallets/thea-message-handler/src/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/thea-message-handler/src/test.rs b/pallets/thea-message-handler/src/test.rs index 5c2149715..dd48396c3 100644 --- a/pallets/thea-message-handler/src/test.rs +++ b/pallets/thea-message-handler/src/test.rs @@ -132,7 +132,7 @@ fn test_incoming_message_full() { &vs.clone(), &vec![(0, signature.clone().into())] ), - InvalidTransaction::Custom(2) + InvalidTransaction::Custom(3) ); }) } From 7b7ce58503057ac89e656dadb78ee1ef619e69d6 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 1 Aug 2023 10:36:22 +0300 Subject: [PATCH 28/91] Comment out proxy check --- pallets/ocex/src/validator.rs | 14 ++++++++------ runtime/src/lib.rs | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index fadfa43f3..54f235ec1 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -1,5 +1,5 @@ use crate::{ - pallet::{Accounts, ValidatorSetId}, + pallet::ValidatorSetId, settlement::{add_balance, process_trade, sub_balance}, snapshot::StateInfo, storage::store_trie_root, @@ -242,12 +242,14 @@ impl Pallet { ) -> Result, &'static str> { log::info!(target:"ocex","Settling withdraw request..."); let amount = request.amount().map_err(|_| "decimal conversion error")?; - let account_info = >::get(&request.main).ok_or("Main account not found")?; + // FIXME: Don't remove these comments, will be reintroduced after fixing the race condition + // let account_info = >::get(&request.main).ok_or("Main account not found")?; + + // if !account_info.proxies.contains(&request.proxy) { + // // TODO: Check Race condition + // return Err("Proxy not found") + // } - if !account_info.proxies.contains(&request.proxy) { - // TODO: Check Race condition - return Err("Proxy not found") - } if !request.verify() { return Err("SignatureVerificationFailed") } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 013f74606..dd1304782 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 294, + spec_version: 295, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 5203b170987f9f5aabd93a4c7a780c094478fca6 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 1 Aug 2023 15:12:02 +0300 Subject: [PATCH 29/91] Fullnodes should store data and stid should be stored in state info --- pallets/ocex/src/validator.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 54f235ec1..f195c374b 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -140,15 +140,16 @@ impl Pallet { log::info!(target:"ocex","Processing user actions for nonce: {:?}",next_nonce); let withdrawals = Self::process_batch(&mut state, &batch, &mut state_info)?; - if sp_io::offchain::is_validator() { - // Create state hash. - state_info.snapshot_id = batch.snapshot_id; // Store the processed nonce - Self::store_state_info(state_info.clone(), &mut state)?; - state.commit(); - let state_hash: H256 = *state.root(); - store_trie_root(state_hash); - log::info!(target:"ocex","updated trie root: {:?}", state.root()); + // Create state hash and store it + state_info.stid = batch.stid; + state_info.snapshot_id = batch.snapshot_id; // Store the processed nonce + Self::store_state_info(state_info.clone(), &mut state)?; + state.commit(); + let state_hash: H256 = *state.root(); + store_trie_root(state_hash); + log::info!(target:"ocex","updated trie root: {:?}", state.root()); + if sp_io::offchain::is_validator() { match available_keys.get(0) { None => return Err("No active keys found"), Some(key) => { @@ -348,7 +349,7 @@ impl Pallet { use parity_scale_codec::alloc::string::ToString; use sp_std::borrow::ToOwned; -fn get_user_action_batch(id: u64) -> Option> { +pub fn get_user_action_batch(id: u64) -> Option> { let body = serde_json::json!({ "id": id }).to_string(); let result = match send_request("user_actions_batch", &(AGGREGATOR.to_owned() + "/snapshots"), &body) { @@ -489,7 +490,7 @@ fn map_http_err(err: HttpError) -> &'static str { #[derive(Serialize, Deserialize)] pub struct JSONRPCResponse { jsonrpc: serde_json::Value, - result: Vec, + pub(crate) result: Vec, id: u64, } From 52ca9e13a48d1167b72007d9071fb59d756273c8 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 1 Aug 2023 17:02:10 +0300 Subject: [PATCH 30/91] Increase spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index dd1304782..7917d1898 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 295, + spec_version: 296, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From dc359ecdf43d945a7ea06c721b7771679c32a724 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 1 Aug 2023 18:41:11 +0300 Subject: [PATCH 31/91] re-introduce Sequential block import check --- pallets/ocex/src/validator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index f195c374b..6421d2df0 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -198,7 +198,7 @@ impl Pallet { ) -> Result<(), &'static str> { log::debug!(target:"ocex","Importing block: {:?}",blk); - if blk <= state_info.last_block.saturated_into() { + if blk != state_info.last_block.saturating_add(1) { return Err("BlockOutofSequence") } From aee4f228cf5585ebb1e8410b4a114790500c839c Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 1 Aug 2023 18:44:29 +0300 Subject: [PATCH 32/91] re-introduce Sequential block import check --- pallets/ocex/src/validator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 6421d2df0..3918a7d32 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -198,7 +198,7 @@ impl Pallet { ) -> Result<(), &'static str> { log::debug!(target:"ocex","Importing block: {:?}",blk); - if blk != state_info.last_block.saturating_add(1) { + if blk != state_info.last_block.saturating_add(1).into() { return Err("BlockOutofSequence") } From e3ea96d120d3a6ac0cb2a7b8334bf3702523bc5d Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 1 Aug 2023 19:03:46 +0300 Subject: [PATCH 33/91] starting block --- pallets/ocex/src/snapshot.rs | 8 +++++++- pallets/ocex/src/validator.rs | 6 +++++- runtime/src/lib.rs | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pallets/ocex/src/snapshot.rs b/pallets/ocex/src/snapshot.rs index fb59ff6f5..38eb1b661 100644 --- a/pallets/ocex/src/snapshot.rs +++ b/pallets/ocex/src/snapshot.rs @@ -20,7 +20,7 @@ use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::BlockNumber; // Accounts storage -#[derive(Encode, Decode, PartialEq, Debug, Clone, Default)] +#[derive(Encode, Decode, PartialEq, Debug, Clone)] pub struct StateInfo { /// Last block processed pub last_block: BlockNumber, @@ -31,3 +31,9 @@ pub struct StateInfo { /// Last processed snapshot id pub snapshot_id: u64, } + +impl Default for StateInfo { + fn default() -> Self { + Self { last_block: 4768083, worker_nonce: 0, stid: 0, snapshot_id: 0 } + } +} diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 3918a7d32..460e72719 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -104,8 +104,12 @@ impl Pallet { log::info!(target:"ocex","last_processed_nonce: {:?}, next_nonce: {:?}",last_processed_nonce, next_nonce); if next_nonce.saturating_sub(last_processed_nonce) > 2 { - // We need to sync our offchain state + if state_info.last_block == 0 { + state_info.last_block = 4768083; // This is hard coded as the starting point + } + // We need to sync our off chain state for nonce in last_processed_nonce.saturating_add(1)..next_nonce { + log::info!(target:"ocex","Syncing batch: {:?}",nonce); // Load the next ObMessages let batch = match get_user_action_batch::(nonce) { None => { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7917d1898..eda61dc77 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 296, + spec_version: 297, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From a4ed85201a364d1c7a8efe84e575ae892c8f4aa4 Mon Sep 17 00:00:00 2001 From: Gautham Date: Tue, 1 Aug 2023 22:18:52 +0300 Subject: [PATCH 34/91] Update worker status handling --- pallets/ocex/src/lib.rs | 13 +++++++++++-- pallets/ocex/src/validator.rs | 12 ++++++------ runtime/src/lib.rs | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index c664f0022..993e785ca 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -376,8 +376,17 @@ pub mod pallet { fn offchain_worker(block_number: T::BlockNumber) { log::debug!(target:"ocex", "offchain worker started"); - if let Err(err) = Self::run_on_chain_validation(block_number) { - log::error!(target:"ocex","OCEX worker error: {}",err) + + match Self::run_on_chain_validation(block_number) { + Ok(exit_flag) => { + // If exit flag is false, then another worker is online + if !exit_flag { + return + } + }, + Err(err) => { + log::error!(target:"ocex","OCEX worker error: {}",err); + }, } // Set worker status to false let s_info = StorageValueRef::persistent(&WORKER_STATUS); diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 460e72719..614acedcb 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -45,7 +45,7 @@ pub const AGGREGATOR: &str = "https://ob.aggregator.polkadex.trade"; impl Pallet { /// Runs the offchain worker computes the next batch of user actions and /// submits snapshot summary to aggregator endpoint - pub fn run_on_chain_validation(_block_num: T::BlockNumber) -> Result<(), &'static str> { + pub fn run_on_chain_validation(_block_num: T::BlockNumber) -> Result { let local_keys = T::AuthorityId::all(); let authorities = Self::validator_set().validators; let mut available_keys = authorities @@ -74,7 +74,7 @@ impl Pallet { Some(true) => { // Another worker is online, so exit log::info!(target:"ocex", "Another worker is online, so exit"); - return Ok(()) + return Ok(false) }, None => {}, Some(false) => {}, @@ -98,7 +98,7 @@ impl Pallet { log::debug!(target:"ocex","Submitting last processed snapshot: {:?}",next_nonce); // resubmit the summary to aggregator load_signed_summary_and_send::(next_nonce); - return Ok(()) + return Ok(true) } log::info!(target:"ocex","last_processed_nonce: {:?}, next_nonce: {:?}",last_processed_nonce, next_nonce); @@ -114,7 +114,7 @@ impl Pallet { let batch = match get_user_action_batch::(nonce) { None => { log::error!(target:"ocex","No user actions found for nonce: {:?}",nonce); - return Ok(()) + return Ok(true) }, Some(batch) => batch, }; @@ -136,7 +136,7 @@ impl Pallet { state.commit(); store_trie_root(*state.root()); log::debug!(target:"ocex","Stored state root: {:?}",state.root()); - return Ok(()) + return Ok(true) }, Some(batch) => batch, }; @@ -192,7 +192,7 @@ impl Pallet { } } - Ok(()) + Ok(true) } fn import_blk( diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index eda61dc77..af970f322 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 297, + spec_version: 298, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 273e2d9312a5d11a474fcdc1e8004c7f97d0878f Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 2 Aug 2023 11:35:41 +0300 Subject: [PATCH 35/91] Added a caching layer for Offchain state --- Cargo.lock | 5 +- pallets/ocex/src/settlement.rs | 42 ++++++------ pallets/ocex/src/storage.rs | 104 +++++++++++++++++++++++----- pallets/ocex/src/tests.rs | 120 +++++++++++++++++++++++---------- pallets/ocex/src/validator.rs | 50 ++++++-------- 5 files changed, 215 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ce2aa6dd..f88b80325 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9982,11 +9982,12 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.2" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", "mio", diff --git a/pallets/ocex/src/settlement.rs b/pallets/ocex/src/settlement.rs index b550f0840..78f59bb8e 100644 --- a/pallets/ocex/src/settlement.rs +++ b/pallets/ocex/src/settlement.rs @@ -18,17 +18,14 @@ //! Helper functions for updating the balance -use crate::validator::map_trie_error; +use crate::storage::OffchainState; use log::{error, info}; use orderbook_primitives::types::Trade; use parity_scale_codec::{alloc::string::ToString, Decode, Encode}; use polkadex_primitives::{ocex::TradingPairConfig, AccountId, AssetId}; use rust_decimal::{prelude::ToPrimitive, Decimal}; use sp_core::crypto::ByteArray; -use sp_runtime::traits::BlakeTwo256; use sp_std::collections::btree_map::BTreeMap; -use sp_trie::LayoutV1; -use trie_db::{TrieDBMut, TrieMut}; /// Updates provided trie db with a new balance entry if it is does not contain item for specific /// account or asset yet, or increments existing item balance. @@ -40,25 +37,24 @@ use trie_db::{TrieDBMut, TrieMut}; /// * `asset`: Asset to look for /// * `balance`: Amount on which balance should be added. pub fn add_balance( - state: &mut TrieDBMut>, + state: &mut OffchainState, account: &AccountId, asset: AssetId, balance: Decimal, ) -> Result<(), &'static str> { - log::info!(target:"ocex", "adding {:?} asset {:?} from account {:?}", balance.to_f64().unwrap(), asset.to_string(), account.as_slice()); - let mut balances: BTreeMap = - match state.get(account.as_slice()).map_err(map_trie_error)? { - None => BTreeMap::new(), - Some(encoded) => BTreeMap::decode(&mut &encoded[..]) - .map_err(|_| "Unable to decode balances for account")?, - }; + log::info!(target:"ocex", "adding {:?} asset {:?} from account {:?}", balance.to_f64().unwrap(), asset.to_string(), account); + let mut balances: BTreeMap = match state.get(&account.to_raw_vec())? { + None => BTreeMap::new(), + Some(encoded) => BTreeMap::decode(&mut &encoded[..]) + .map_err(|_| "Unable to decode balances for account")?, + }; balances .entry(asset) .and_modify(|total| *total = total.saturating_add(balance)) .or_insert(balance); - state.insert(account.as_slice(), &balances.encode()).map_err(map_trie_error)?; + state.insert(account.to_raw_vec(), balances.encode()); Ok(()) } @@ -74,27 +70,27 @@ pub fn add_balance( /// * `asset`: Asset to look for /// * `balance`: Amount on which balance should be reduced. pub fn sub_balance( - state: &mut TrieDBMut>, + state: &mut OffchainState, account: &AccountId, asset: AssetId, balance: Decimal, ) -> Result<(), &'static str> { - log::info!(target:"ocex", "subtracting {:?} asset {:?} from account {:?}", balance.to_f64().unwrap(), asset.to_string(), account.as_slice()); - let mut balances: BTreeMap = - match state.get(account.as_slice()).map_err(map_trie_error)? { - None => return Err("Account not found in trie"), - Some(encoded) => BTreeMap::decode(&mut &encoded[..]) - .map_err(|_| "Unable to decode balances for account")?, - }; + log::info!(target:"ocex", "subtracting {:?} asset {:?} from account {:?}", balance.to_f64().unwrap(), asset.to_string(), account); + let mut balances: BTreeMap = match state.get(&account.to_raw_vec())? { + None => return Err("Account not found in trie"), + Some(encoded) => BTreeMap::decode(&mut &encoded[..]) + .map_err(|_| "Unable to decode balances for account")?, + }; let account_balance = balances.get_mut(&asset).ok_or("NotEnoughBalance")?; if *account_balance < balance { + log::error!(target:"ocex","Asset found but balance low for asset: {:?}, of account: {:?}",asset, account); return Err("NotEnoughBalance") } *account_balance = account_balance.saturating_sub(balance); - state.insert(account.as_slice(), &balances.encode()).map_err(map_trie_error)?; + state.insert(account.to_raw_vec(), balances.encode()); Ok(()) } @@ -112,7 +108,7 @@ pub fn sub_balance( /// /// A `Result<(), Error>` indicating whether the trade was successfully processed or not. pub fn process_trade( - state: &mut TrieDBMut>, + state: &mut OffchainState, trade: &Trade, config: TradingPairConfig, ) -> Result<(), &'static str> { diff --git a/pallets/ocex/src/storage.rs b/pallets/ocex/src/storage.rs index 4bb55ac2d..83499453b 100644 --- a/pallets/ocex/src/storage.rs +++ b/pallets/ocex/src/storage.rs @@ -1,9 +1,10 @@ +use crate::validator::map_trie_error; use hash_db::{AsHashDB, HashDB, Prefix}; use sp_core::{Hasher, H256}; use sp_runtime::{offchain::storage::StorageValueRef, sp_std, traits::BlakeTwo256}; use sp_std::vec::Vec; use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1}; -use trie_db::{DBValue, TrieDBMut}; +use trie_db::{DBValue, TrieDBMut, TrieMut}; pub struct State; @@ -12,6 +13,54 @@ const NULL_NODE_DATA: [u8; 29] = *b"offchain-ocex::null_node_data"; const KEY_PREFIX: [u8; 15] = *b"offchain-ocex::"; const TRIE_ROOT: [u8; 24] = *b"offchain-ocex::trie_root"; +pub struct OffchainState<'a> { + cache: sp_std::collections::btree_map::BTreeMap, Vec>, + trie: TrieDBMut<'a, LayoutV1>, +} + +impl<'a> OffchainState<'a> { + pub fn load(storage: &'a mut State, root: &'a mut H256) -> Self { + let trie = crate::storage::get_state_trie(storage, root); + Self { cache: Default::default(), trie } + } + + pub fn is_empty(&self) -> bool { + self.cache.is_empty() && self.trie.is_empty() + } + + pub fn get(&mut self, key: &Vec) -> Result>, &'static str> { + match self.cache.get(key) { + Some(value) => Ok(Some(value.clone())), + None => match self.trie.get(key) { + Err(err) => { + log::error!(target:"ocex","Trie returned an error while get operation"); + Err(map_trie_error(err)) + }, + Ok(option) => match option { + None => Ok(None), + Some(value) => { + self.cache.insert(key.clone(), value.clone()); + Ok(Some(value)) + }, + }, + }, + } + } + + pub fn insert(&mut self, key: Vec, value: Vec) { + self.cache.insert(key, value); + } + + pub fn commit(&mut self) -> Result { + for (key, value) in self.cache.iter() { + self.trie.insert(key, value).map_err(map_trie_error)?; + } + + self.trie.commit(); + Ok(*self.trie.root()) + } +} + impl State { fn hashed_null_node(&self) -> ::Out { let s_r = StorageValueRef::persistent(&HASHED_NULL_NODE); @@ -43,8 +92,9 @@ impl State { } } - fn db_get(&self, key: &::Out) -> Option<(DBValue, i32)> { - let derive_key = self.derive_storage_key(*key); + fn db_get(&self, key: &Vec) -> Option<(DBValue, i32)> { + log::trace!(target:"ocex","Getting key: {:?}", key); + let derive_key = self.derive_storage_key(key); let s_ref = StorageValueRef::persistent(derive_key.as_slice()); match s_ref.get::<(DBValue, i32)>() { Ok(d) => d, @@ -52,15 +102,17 @@ impl State { } } - fn db_insert(&self, key: ::Out, value: (DBValue, i32)) { - let derive_key = self.derive_storage_key(key); + fn db_insert(&self, key: Vec, value: (DBValue, i32)) { + let derive_key = self.derive_storage_key(&key); + log::trace!(target:"ocex","Inserting key: {:?}, derived: {:?}, value: {:?}", key, derive_key, value); let s_ref = StorageValueRef::persistent(derive_key.as_slice()); s_ref.set(&value); } - fn derive_storage_key(&self, key: ::Out) -> Vec { + fn derive_storage_key(&self, key: &[u8]) -> Vec { let mut derived = KEY_PREFIX.to_vec(); - derived.append(&mut key.0.to_vec()); + let mut cloned_key = key.to_owned(); + derived.append(&mut cloned_key); derived } } @@ -76,26 +128,31 @@ impl AsHashDB for State { } impl HashDB for State { - fn get(&self, key: &::Out, _: Prefix) -> Option { + fn get(&self, key: &::Out, prefix: Prefix) -> Option { + log::trace!(target:"ocex","HashDb get, key: {:?}, prefix: {:?}", key,prefix); if key == &self.hashed_null_node() { return Some(self.null_node_data()) } - match self.db_get(key) { + let key = prefixed_key(key, prefix); + match self.db_get(&key) { Some((ref d, rc)) if rc > 0 => Some(d.clone()), _ => None, } } - fn contains(&self, key: &::Out, _: Prefix) -> bool { + fn contains(&self, key: &::Out, prefix: Prefix) -> bool { + log::trace!(target:"ocex","HashDb contains, key: {:?}, prefix: {:?}", key,prefix); if key == &self.hashed_null_node() { return true } - matches!(self.db_get(key), Some((_, x)) if x > 0) + let key = prefixed_key(key, prefix); + matches!(self.db_get(&key), Some((_, x)) if x > 0) } fn insert(&mut self, prefix: Prefix, value: &[u8]) -> ::Out { + log::trace!(target:"ocex","HashDb insert, prefix: {:?}",prefix); if *value == self.null_node_data() { return self.hashed_null_node() } @@ -104,11 +161,13 @@ impl HashDB for State { key } - fn emplace(&mut self, key: ::Out, _: Prefix, value: DBValue) { + fn emplace(&mut self, key: ::Out, prefix: Prefix, value: DBValue) { + log::trace!(target:"ocex","HashDb emplace, key: {:?}, prefix: {:?}", key,prefix); if value == self.null_node_data() { return } + let key = prefixed_key(&key, prefix); match self.db_get(&key) { Some((mut old_value, mut rc)) => { if rc <= 0 { @@ -123,24 +182,37 @@ impl HashDB for State { } } - fn remove(&mut self, key: &::Out, _: Prefix) { + fn remove(&mut self, key: &::Out, prefix: Prefix) { + log::trace!(target:"ocex","HashDb remove, key: {:?}, prefix: {:?}", key,prefix); if key == &self.hashed_null_node() { return } - match self.db_get(key) { + let key = prefixed_key(key, prefix); + match self.db_get(&key) { Some((value, mut rc)) => { rc -= 1; - self.db_insert(*key, (value, rc)); + self.db_insert(key, (value, rc)); }, None => { let value = DBValue::default(); - self.db_insert(*key, (value, -1)); + self.db_insert(key, (value, -1)); }, } } } +/// Derive a database key from hash value of the node (key) and the node prefix. +pub fn prefixed_key(key: &::Out, prefix: Prefix) -> Vec { + let mut prefixed_key = Vec::with_capacity(key.as_ref().len() + prefix.0.len() + 1); + prefixed_key.extend_from_slice(prefix.0); + if let Some(last) = prefix.1 { + prefixed_key.push(last); + } + prefixed_key.extend_from_slice(key.as_ref()); + prefixed_key +} + pub(crate) fn load_trie_root() -> ::Out { let root_ref = StorageValueRef::persistent(&TRIE_ROOT); match root_ref.get::<::Out>() { diff --git a/pallets/ocex/src/tests.rs b/pallets/ocex/src/tests.rs index d5bf2c569..b8c618662 100644 --- a/pallets/ocex/src/tests.rs +++ b/pallets/ocex/src/tests.rs @@ -122,14 +122,14 @@ fn test_add_balance_new_account() { let amount = 1000000; let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); let result = add_balance(&mut state, &account_id, asset_id, amount.into()); assert_eq!(result, Ok(())); - let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&account_id.to_raw_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &amount.into()); // test get_balance() - state.commit(); + state.commit().unwrap(); drop(state); store_trie_root(root); let from_fn = OCEX::get_balance(account_id.clone(), asset_id).unwrap(); @@ -166,10 +166,10 @@ fn test_add_balance_existing_account_with_balance() { let amount = 1000000; let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); let result = add_balance(&mut state, &account_id, asset_id, amount.into()); assert_eq!(result, Ok(())); - let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&account_id.to_raw_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &amount.into()); @@ -177,11 +177,11 @@ fn test_add_balance_existing_account_with_balance() { let amount2 = 2000000; let result = add_balance(&mut state, &account_id, asset_id, amount2.into()); assert_eq!(result, Ok(())); - let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&account_id.to_raw_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &(amount + amount2).into()); // test get_balance() - state.commit(); + state.commit().unwrap(); drop(state); store_trie_root(root); let from_fn = OCEX::get_balance(account_id.clone(), asset_id).unwrap(); @@ -216,6 +216,52 @@ fn test_add_balance_existing_account_with_balance() { }); } +#[test] +fn test_two_assets() { + let mut ext = new_test_ext(); + ext.persist_offchain_overlay(); + register_offchain_ext(&mut ext); + ext.execute_with(|| { + let account_bytes = [1u8; 32]; + let pablo_main = AccountId::from(account_bytes); + + let account_bytes = [2u8; 32]; + let coinalpha = AccountId::from(account_bytes); + + let account_id = pablo_main.clone(); + let asset1 = AssetId::Asset(123); + let amount1 = Decimal::from_str("0.05").unwrap(); + + let asset2 = AssetId::Asset(456); + let amount2 = Decimal::from_str("0.1").unwrap(); + let mut root = crate::storage::load_trie_root(); + let mut trie_state = crate::storage::State; + let mut state = OffchainState::load(&mut trie_state, &mut root); + add_balance(&mut state, &account_id, asset1, amount1.into()).unwrap(); + add_balance(&mut state, &account_id, asset2, amount2.into()).unwrap(); + let asset123 = AssetId::Asset(123); + let amount123 = Decimal::from_str("25.0").unwrap(); + + let asset456 = AssetId::Asset(456); + let amount456 = Decimal::from_str("10.0").unwrap(); + // works + sub_balance(&mut state, &account_id, asset1, Decimal::from_str("0.01").unwrap().into()) + .unwrap(); + add_balance(&mut state, &coinalpha, asset123, amount123.into()).unwrap(); + add_balance(&mut state, &coinalpha, asset456, amount456.into()).unwrap(); + let root = state.commit().unwrap(); + store_trie_root(root); + drop(state); + let mut root = crate::storage::load_trie_root(); + let mut trie_state = crate::storage::State; + let mut state = OffchainState::load(&mut trie_state, &mut root); + sub_balance(&mut state, &account_id, asset1, Decimal::from_str("0.01").unwrap().into()) + .unwrap(); + sub_balance(&mut state, &account_id, asset1, Decimal::from_str("0.01").unwrap().into()) + .unwrap(); + }); +} + #[test] // check if balance can be subtracted from a new account fn test_sub_balance_new_account() { @@ -228,7 +274,7 @@ fn test_sub_balance_new_account() { let amount = 1000000; let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); let result = sub_balance(&mut state, &account_id, asset_id, amount.into()); match result { Ok(_) => assert!(false), @@ -254,10 +300,10 @@ fn test_sub_balance_existing_account_with_balance() { let amount = 3000000; let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); let result = add_balance(&mut state, &account_id, asset_id, amount.into()); assert_eq!(result, Ok(())); - let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&account_id.to_raw_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &amount.into()); @@ -265,7 +311,7 @@ fn test_sub_balance_existing_account_with_balance() { let amount2 = 2000000; let result = sub_balance(&mut state, &account_id, asset_id, amount2.into()); assert_eq!(result, Ok(())); - let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&account_id.to_raw_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &(amount - amount2).into()); @@ -273,12 +319,12 @@ fn test_sub_balance_existing_account_with_balance() { let amount3 = amount - amount2; let result = sub_balance(&mut state, &account_id, asset_id, amount3.into()); assert_eq!(result, Ok(())); - let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&account_id.to_raw_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(amount - amount2 - amount3, 0); assert_eq!(account_info.get(&asset_id).unwrap(), &Decimal::from(0)); // test get_balance() - state.commit(); + state.commit().unwrap(); drop(state); store_trie_root(root); let from_fn = OCEX::get_balance(account_id.clone(), asset_id).unwrap(); @@ -306,24 +352,24 @@ fn test_trie_update() { ext.execute_with(|| { let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); assert!(state.is_empty()); - state.insert(b"a", b"1").unwrap(); - state.insert(b"b", b"2").unwrap(); - state.insert(b"c", b"3").unwrap(); + state.insert(b"a".to_vec(), b"1".to_vec()); + state.insert(b"b".to_vec(), b"2".to_vec()); + state.insert(b"c".to_vec(), b"3".to_vec()); assert!(!state.is_empty()); - let root = state.root(); // This should flush everything to db. - crate::storage::store_trie_root(*root); + let root = state.commit().unwrap(); // This should flush everything to db. + crate::storage::store_trie_root(root); let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); - assert_eq!(state.get(b"a").unwrap().unwrap(), b"1"); - assert_eq!(state.get(b"b").unwrap().unwrap(), b"2"); - assert_eq!(state.get(b"c").unwrap().unwrap(), b"3"); + assert_eq!(state.get(&b"a".to_vec()).unwrap().unwrap(), b"1"); + assert_eq!(state.get(&b"b".to_vec()).unwrap().unwrap(), b"2"); + assert_eq!(state.get(&b"c".to_vec()).unwrap().unwrap(), b"3"); - state.insert(b"d", b"4").unwrap(); // This will not be in DB, as neither root() or commit() is called + state.insert(b"d".to_vec(), b"4".to_vec()); // This will not be in DB, as neither root() or commit() is called let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; @@ -346,7 +392,7 @@ fn test_balance_update_depost_first_then_trade() { let amount = 20; let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); let result = add_balance( &mut state, @@ -380,10 +426,10 @@ fn test_sub_more_than_available_balance_from_existing_account_with_balance() { let amount = 3000000; let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); let result = add_balance(&mut state, &account_id, asset_id, amount.into()); assert_eq!(result, Ok(())); - let encoded = state.get(account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&account_id.to_raw_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&asset_id).unwrap(), &amount.into()); @@ -406,7 +452,7 @@ fn test_trade_between_two_accounts_without_balance() { ext.execute_with(|| { let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); let config = get_trading_pair_config(); let amount = Decimal::from_str("20").unwrap(); let price = Decimal::from_str("2").unwrap(); @@ -428,7 +474,7 @@ fn test_trade_between_two_accounts_with_balance() { ext.execute_with(|| { let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); // add balance to alice let alice_account_id = get_alice_key_pair().public(); @@ -466,12 +512,12 @@ fn test_trade_between_two_accounts_with_balance() { assert_ok!(result); //check has 20 pdex now - let encoded = state.get(alice_account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&alice_account_id.0.to_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!(account_info.get(&AssetId::Polkadex).unwrap(), &20.into()); //check if bob has 20 less pdex - let encoded = state.get(bob_account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&bob_account_id.0.to_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!( account_info.get(&AssetId::Polkadex).unwrap(), @@ -479,7 +525,7 @@ fn test_trade_between_two_accounts_with_balance() { ); //check if bob has 40 more asset_1 - let encoded = state.get(bob_account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&bob_account_id.0.to_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!( account_info.get(&AssetId::Asset(1)).unwrap(), @@ -487,7 +533,7 @@ fn test_trade_between_two_accounts_with_balance() { ); //check if alice has 40 less asset_1 - let encoded = state.get(alice_account_id.as_slice()).unwrap().unwrap(); + let encoded = state.get(&alice_account_id.0.to_vec()).unwrap().unwrap(); let account_info: BTreeMap = BTreeMap::decode(&mut &encoded[..]).unwrap(); assert_eq!( account_info.get(&AssetId::Asset(1)).unwrap(), @@ -505,7 +551,7 @@ fn test_trade_between_two_accounts_insuffient_bidder_balance() { ext.execute_with(|| { let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); // add balance to alice let alice_account_id = get_alice_key_pair().public(); @@ -539,7 +585,7 @@ fn test_trade_between_two_accounts_insuffient_asker_balance() { ext.execute_with(|| { let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); // add balance to alice let alice_account_id = get_alice_key_pair().public(); @@ -573,7 +619,7 @@ fn test_trade_between_two_accounts_invalid_signature() { ext.execute_with(|| { let mut root = crate::storage::load_trie_root(); let mut trie_state = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut trie_state, &mut root); + let mut state = OffchainState::load(&mut trie_state, &mut root); // add balance to alice let alice_account_id = get_alice_key_pair().public(); @@ -2255,6 +2301,7 @@ use orderbook_primitives::{ Fees, }; use sp_runtime::traits::{BlockNumberProvider, One}; + use trie_db::TrieMut; #[test] @@ -2303,6 +2350,7 @@ pub fn test_allowlist_with_limit_reaching_returns_error() { use crate::{ settlement::{add_balance, process_trade, sub_balance}, sr25519::AuthorityId, + storage::OffchainState, }; use polkadex_primitives::ingress::{HandleBalance, HandleBalanceLimit}; diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 614acedcb..902e9c7f0 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -25,11 +25,10 @@ use sp_runtime::{ http::{Error, PendingRequest, Response}, storage::StorageValueRef, }, - traits::BlakeTwo256, SaturatedConversion, }; use sp_std::{boxed::Box, collections::btree_map::BTreeMap, vec::Vec}; -use sp_trie::{LayoutV1, TrieDBMut}; + use trie_db::{TrieError, TrieMut}; /// Key of the storage that stores the status of an offchain worker @@ -87,9 +86,9 @@ impl Pallet { let mut root = crate::storage::load_trie_root(); log::info!(target:"ocex","block: {:?}, state_root {:?}", _block_num, root); let mut storage = crate::storage::State; - let mut state = crate::storage::get_state_trie(&mut storage, &mut root); + let mut state = OffchainState::load(&mut storage, &mut root); - let mut state_info = Self::load_state_info(&state); + let mut state_info = Self::load_state_info(&mut state); let last_processed_nonce = state_info.snapshot_id; @@ -132,10 +131,10 @@ impl Pallet { // Store the last processed nonce // We need to -1 from next_nonce, as it is not yet processed state_info.snapshot_id = next_nonce.saturating_sub(1); - Self::store_state_info(state_info, &mut state)?; - state.commit(); - store_trie_root(*state.root()); - log::debug!(target:"ocex","Stored state root: {:?}",state.root()); + Self::store_state_info(state_info, &mut state); + let root = state.commit()?; + store_trie_root(root); + log::debug!(target:"ocex","Stored state root: {:?}",root); return Ok(true) }, Some(batch) => batch, @@ -147,11 +146,10 @@ impl Pallet { // Create state hash and store it state_info.stid = batch.stid; state_info.snapshot_id = batch.snapshot_id; // Store the processed nonce - Self::store_state_info(state_info.clone(), &mut state)?; - state.commit(); - let state_hash: H256 = *state.root(); + Self::store_state_info(state_info.clone(), &mut state); + let state_hash: H256 = state.commit()?; store_trie_root(state_hash); - log::info!(target:"ocex","updated trie root: {:?}", state.root()); + log::info!(target:"ocex","updated trie root: {:?}", state_hash); if sp_io::offchain::is_validator() { match available_keys.get(0) { @@ -197,7 +195,7 @@ impl Pallet { fn import_blk( blk: T::BlockNumber, - state: &mut TrieDBMut>, + state: &mut OffchainState, state_info: &mut StateInfo, ) -> Result<(), &'static str> { log::debug!(target:"ocex","Importing block: {:?}",blk); @@ -226,10 +224,7 @@ impl Pallet { Ok(()) } - fn trades( - trades: &Vec, - state: &mut TrieDBMut>, - ) -> Result<(), &'static str> { + fn trades(trades: &Vec, state: &mut OffchainState) -> Result<(), &'static str> { log::info!(target:"ocex","Settling trades..."); for trade in trades { let config = Self::trading_pairs(trade.maker.pair.base, trade.maker.pair.quote) @@ -242,7 +237,7 @@ impl Pallet { fn withdraw( request: &WithdrawalRequest, - state: &mut TrieDBMut>, + state: &mut OffchainState, stid: u64, ) -> Result, &'static str> { log::info!(target:"ocex","Settling withdraw request..."); @@ -271,7 +266,7 @@ impl Pallet { } fn process_batch( - state: &mut TrieDBMut>, + state: &mut OffchainState, batch: &UserActionBatch, state_info: &mut StateInfo, ) -> Result>, &'static str> { @@ -297,20 +292,16 @@ impl Pallet { Ok(withdrawals) } - fn load_state_info(state: &TrieDBMut>) -> StateInfo { - match state.get(&STATE_INFO) { + fn load_state_info(state: &mut OffchainState) -> StateInfo { + match state.get(&STATE_INFO.to_vec()) { Ok(Some(data)) => StateInfo::decode(&mut &data[..]).unwrap_or_default(), Ok(None) => StateInfo::default(), Err(_) => StateInfo::default(), } } - fn store_state_info( - state_info: StateInfo, - state: &mut TrieDBMut>, - ) -> Result<(), &'static str> { - let _ = state.insert(&STATE_INFO, &state_info.encode()).map_err(map_trie_error)?; - Ok(()) + fn store_state_info(state_info: StateInfo, state: &mut OffchainState) { + state.insert(STATE_INFO.to_vec(), state_info.encode()); } fn calculate_signer_index( @@ -345,11 +336,12 @@ impl Pallet { pub(crate) fn get_state_info() -> StateInfo { let mut root = crate::storage::load_trie_root(); let mut storage = crate::storage::State; - let state = crate::storage::get_state_trie(&mut storage, &mut root); - Self::load_state_info(&state) + let mut state = OffchainState::load(&mut storage, &mut root); + Self::load_state_info(&mut state) } } +use crate::storage::OffchainState; use parity_scale_codec::alloc::string::ToString; use sp_std::borrow::ToOwned; From 64ac0eb7ab5a6947a65dde57610cf3238fd2c338 Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 2 Aug 2023 11:37:53 +0300 Subject: [PATCH 36/91] Increase spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index af970f322..34ac31648 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 298, + spec_version: 299, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 3c576df24de62350d0705fee649977a9a6dd3fe5 Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 2 Aug 2023 12:55:37 +0300 Subject: [PATCH 37/91] Reset DB/Trie on trie errors --- pallets/ocex/src/lib.rs | 2 +- pallets/ocex/src/storage.rs | 2 +- pallets/ocex/src/validator.rs | 20 +++++++++++++------- runtime/src/lib.rs | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 993e785ca..04378f187 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -1280,7 +1280,7 @@ pub mod pallet { account_ids.insert(main, proxies); } - let state_info = Self::get_state_info(); + let state_info = Self::get_state_info().map_err(|_err| DispatchError::Corruption)?; let last_processed_block_number = state_info.last_block; let worker_nonce = state_info.worker_nonce; let snapshot_id = state_info.snapshot_id; diff --git a/pallets/ocex/src/storage.rs b/pallets/ocex/src/storage.rs index 83499453b..352b6a1c6 100644 --- a/pallets/ocex/src/storage.rs +++ b/pallets/ocex/src/storage.rs @@ -2,7 +2,7 @@ use crate::validator::map_trie_error; use hash_db::{AsHashDB, HashDB, Prefix}; use sp_core::{Hasher, H256}; use sp_runtime::{offchain::storage::StorageValueRef, sp_std, traits::BlakeTwo256}; -use sp_std::vec::Vec; +use sp_std::{prelude::ToOwned, vec::Vec}; use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1}; use trie_db::{DBValue, TrieDBMut, TrieMut}; diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 902e9c7f0..ed35914f2 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -88,7 +88,14 @@ impl Pallet { let mut storage = crate::storage::State; let mut state = OffchainState::load(&mut storage, &mut root); - let mut state_info = Self::load_state_info(&mut state); + let mut state_info = match Self::load_state_info(&mut state) { + Ok(info) => info, + Err(err) => { + log::error!(target:"ocex","Err loading state info from storage: {:?}",err); + store_trie_root(H256::zero()); + return Err(err) + }, + }; let last_processed_nonce = state_info.snapshot_id; @@ -292,11 +299,10 @@ impl Pallet { Ok(withdrawals) } - fn load_state_info(state: &mut OffchainState) -> StateInfo { - match state.get(&STATE_INFO.to_vec()) { - Ok(Some(data)) => StateInfo::decode(&mut &data[..]).unwrap_or_default(), - Ok(None) => StateInfo::default(), - Err(_) => StateInfo::default(), + fn load_state_info(state: &mut OffchainState) -> Result { + match state.get(&STATE_INFO.to_vec())? { + Some(data) => Ok(StateInfo::decode(&mut &data[..]).unwrap_or_default()), + None => Ok(StateInfo::default()), } } @@ -333,7 +339,7 @@ impl Pallet { Ok(balance) } - pub(crate) fn get_state_info() -> StateInfo { + pub(crate) fn get_state_info() -> Result { let mut root = crate::storage::load_trie_root(); let mut storage = crate::storage::State; let mut state = OffchainState::load(&mut storage, &mut root); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 34ac31648..f89b34762 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 299, + spec_version: 300, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 5edad96d3a24aaf12114669de5caa0d53bb89b02 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 3 Aug 2023 20:55:06 +0300 Subject: [PATCH 38/91] Disable on_idle --- pallets/ocex/src/lib.rs | 80 +++++++++++++++++++++++++---------------- runtime/src/lib.rs | 2 +- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 04378f187..bc5b2cb0e 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -328,37 +328,55 @@ pub mod pallet { impl Hooks> for Pallet { /// On idle, use the remaining weight to withdraw finalization /// Automated (but much delayed) `claim_withdraw()` extrinsic - fn on_idle(_n: BlockNumberFor, mut remaining_weight: Weight) -> Weight { - let snapshot_id = >::get(); - while remaining_weight.ref_time() > - ::WeightInfo::claim_withdraw(1).ref_time() - { - >::mutate(snapshot_id, |btree_map| { - // Get mutable reference to the withdrawals vector - if let Some(account) = btree_map.clone().keys().nth(1) { - let mut accounts_to_clean = vec![]; - if let Some(withdrawal_vector) = btree_map.get_mut(account) { - if let Some(withdrawal) = withdrawal_vector.pop() { - if !Self::on_idle_withdrawal_processor(withdrawal.clone()) { - withdrawal_vector.push(withdrawal.clone()); - Self::deposit_event(Event::WithdrawalFailed(withdrawal)); - } - } else { - // this user has no withdrawals left - remove from map - accounts_to_clean.push(account.clone()); - } - } - for user in accounts_to_clean { - btree_map.remove(&user); - } - } - // we drain weight ALWAYS - remaining_weight = remaining_weight - .saturating_sub(::WeightInfo::claim_withdraw(1)); - }); - } - remaining_weight - } + // fn on_idle(_n: BlockNumberFor, mut remaining_weight: Weight) -> Weight { + // let snapshot_id = >::get(); + // while remaining_weight.ref_time() > + // ::WeightInfo::claim_withdraw(1).ref_time() + // { + // >::mutate(snapshot_id, |btree_map| { + // // Get mutable reference to the withdrawals vector + // if let Some(account) = btree_map.clone().keys().nth(1) { + // let mut accounts_to_clean = vec![]; + // if let Some(withdrawal_vector) = btree_map.get_mut(account) { + // if let Some(withdrawal) = withdrawal_vector.pop() { + // if !Self::on_idle_withdrawal_processor(withdrawal.clone()) { + // withdrawal_vector.push(withdrawal.clone()); + // Self::deposit_event(Event::WithdrawalFailed(withdrawal)); + // }else{ + // // TODO: enable this only after testing + // // Update events on successful withdrawal + // // let processed_withdrawls = + // // // Deposit event about successful withdraw + // // Self::deposit_event(Event::WithdrawalClaimed { + // // main: account.clone(), + // // withdrawals: processed_withdrawals.clone(), + // // }); + // // >::mutate(|onchain_events| { + // // onchain_events.push( + // // polkadex_primitives::ocex::OnChainEvents::OrderBookWithdrawalClaimed( + // // snapshot_id, + // // account.clone(), + // // processed_withdrawals, + // // ), + // // ); + // // }); + // } + // } else { + // // this user has no withdrawals left - remove from map + // accounts_to_clean.push(account.clone()); + // } + // } + // for user in accounts_to_clean { + // btree_map.remove(&user); + // } + // } + // // we drain weight ALWAYS + // remaining_weight = remaining_weight + // .saturating_sub(::WeightInfo::claim_withdraw(1)); + // }); + // } + // remaining_weight + // } /// What to do at the end of each block. /// /// Clean OnCHainEvents diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f89b34762..ae45522dd 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 300, + spec_version: 301, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From de2711a1a3152cf19ecfa771d6b8bcb79e2496a2 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 3 Aug 2023 21:37:11 +0300 Subject: [PATCH 39/91] Implement URL fallback for Thea --- pallets/thea/src/validation.rs | 94 ++++++++++++++++++++++++++-------- primitives/thea/src/types.rs | 1 + runtime/src/lib.rs | 2 +- 3 files changed, 76 insertions(+), 21 deletions(-) diff --git a/pallets/thea/src/validation.rs b/pallets/thea/src/validation.rs index 063dd0d17..d0bde64c2 100644 --- a/pallets/thea/src/validation.rs +++ b/pallets/thea/src/validation.rs @@ -121,15 +121,19 @@ fn submit_message_to_aggregator( log::error!(target:"thea","Error serializing approved message: {:?}",err); "Error serializing approved message" })?; - send_request("thea_aggregator_link", AGGREGRATOR_URL, body.as_str())?; + send_request("thea_aggregator_link", Destination::Aggregator, body.as_str())?; Ok(()) } fn get_latest_incoming_nonce_parachain() -> u64 { let storage_key = create_para_incoming_nonce_key(); - get_storage_at_latest_finalized_head::("para_incoming_nonce", PARACHAIN_URL, storage_key) - .unwrap_or_default() - .unwrap_or_default() + get_storage_at_latest_finalized_head::( + "para_incoming_nonce", + Destination::Parachain, + storage_key, + ) + .unwrap_or_default() + .unwrap_or_default() } fn get_payload_for_nonce( @@ -142,22 +146,36 @@ fn get_payload_for_nonce( Destination::Solochain => { // Get the outgoing message with nonce: `nonce` for network: `network` let key = create_solo_outgoing_message_key(nonce, network); - get_storage_at_latest_finalized_head::( + match get_storage_at_latest_finalized_head::( "solo_outgoing_message", - MAINNET_URL, + destination, key, - ) - .unwrap() + ) { + Ok(message) => message, + Err(err) => { + log::error!(target:"thea","Unable to get finalized solo head: {:?}",err); + None + }, + } }, Destination::Parachain => { // Get the outgoing message with nonce: `nonce` from network let key = create_para_outgoing_message_key(nonce); - get_storage_at_latest_finalized_head::( + match get_storage_at_latest_finalized_head::( "para_outgoing_message", - PARACHAIN_URL, + destination, key, - ) - .unwrap() + ) { + Ok(message) => message, + Err(err) => { + log::error!(target:"thea","Unable to get finalized solo head: {:?}",err); + None + }, + } + }, + _ => { + log::warn!(target:"thea","Invalid destination provided"); + None }, } } @@ -195,12 +213,12 @@ pub fn create_para_outgoing_message_key(nonce: u64) -> Vec { fn get_storage_at_latest_finalized_head( log_target: &str, - url: &str, + destination: Destination, storage_key: Vec, ) -> Result, &'static str> { log::debug!(target:"thea","getting storage for {}",log_target); // 1. Get finalized head ( Fh ) - let finalized_head = get_finalized_head(url)?; + let finalized_head = get_finalized_head(destination)?; let storage_key = "0x".to_owned() + &hex::encode(storage_key); @@ -213,7 +231,7 @@ fn get_storage_at_latest_finalized_head( }) .to_string(); - let storage_bytes = send_request(log_target, url, body.as_str())?; + let storage_bytes = send_request(log_target, destination, body.as_str())?; if storage_bytes.is_null() { log::debug!(target:"thea","Storage query returned null response"); @@ -228,7 +246,8 @@ fn get_storage_at_latest_finalized_head( Ok(Some(Decode::decode(&mut &storage_bytes[..]).map_err(|_| "Decode failure")?)) } use scale_info::prelude::string::String; -fn get_finalized_head(url: &str) -> Result { + +fn get_finalized_head(destination: Destination) -> Result { // This body will work for most substrate chains let body = serde_json::json!({ "id":1, @@ -237,16 +256,51 @@ fn get_finalized_head(url: &str) -> Result { "params": [] }); let mut result = - send_request("get_finalized_head", url, body.to_string().as_str())?.to_string(); + send_request("get_finalized_head", destination, body.to_string().as_str())?.to_string(); result = result.replace('\"', ""); log::debug!(target:"thea","Finalized head: {:?}",result); Ok(result) } +pub fn resolve_destination_url(destination: Destination, counter: i32) -> String { + if destination == Destination::Aggregator { + return AGGREGRATOR_URL.to_string() + } + let url = match (destination, counter) { + (Destination::Solochain, 0) => "http://localhost:9944", + (Destination::Solochain, 1) => MAINNET_URL, + (Destination::Parachain, 0) => "http://localhost:8844", + (Destination::Parachain, 1) => PARACHAIN_URL, + _ => AGGREGRATOR_URL, + }; + log::debug!(target:"thea","Resolving {:?}: {:?} to {:?}",destination,counter,url); + url.to_string() +} + pub fn send_request( log_target: &str, - url: &str, + destination: Destination, body: &str, +) -> Result { + for try_counter in 0..2 { + match create_and_send_request( + log_target, + body, + &resolve_destination_url(destination, try_counter), + ) { + Ok(value) => return Ok(value), + Err(err) => { + log::error!(target:"thea","Error querying {:?}: {:?}",log_target, err); + }, + } + } + return Err("request failed") +} + +fn create_and_send_request( + log_target: &str, + body: &str, + url: &str, ) -> Result { let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(12_000)); @@ -270,7 +324,7 @@ pub fn send_request( if response.code != 200u16 { log::warn!(target:"thea","Unexpected status code for {}: {:?}",log_target,response.code); - return Err("request failed") + return Err("Unexpected status code") } let body = response.body().collect::>(); @@ -283,7 +337,7 @@ pub fn send_request( log::debug!(target:"thea","{} response: {:?}",log_target,body_str); let response: JSONRPCResponse = serde_json::from_str::(body_str) .map_err(|_| "Response failed deserialize")?; - Ok(response.result) + return Ok(response.result) } fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { diff --git a/primitives/thea/src/types.rs b/primitives/thea/src/types.rs index b5d3f0316..5069a342c 100644 --- a/primitives/thea/src/types.rs +++ b/primitives/thea/src/types.rs @@ -67,6 +67,7 @@ pub struct Message { pub enum Destination { Solochain, Parachain, + Aggregator, } /// Defines structure of the deposit. diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ae45522dd..7f76a0174 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 301, + spec_version: 302, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 6e49c0c97757e8e282e1e6aa3c9a02ae319c1146 Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 4 Aug 2023 11:43:03 +0300 Subject: [PATCH 40/91] Add docs --- pallets/thea/src/validation.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/thea/src/validation.rs b/pallets/thea/src/validation.rs index d0bde64c2..fca6d76fe 100644 --- a/pallets/thea/src/validation.rs +++ b/pallets/thea/src/validation.rs @@ -262,6 +262,10 @@ fn get_finalized_head(destination: Destination) -> Result Ok(result) } +/// Returns the url based on destination and counter +/// +/// Counter value 0 means return the local address +/// Counter value 1 means returns the fallback address. pub fn resolve_destination_url(destination: Destination, counter: i32) -> String { if destination == Destination::Aggregator { return AGGREGRATOR_URL.to_string() From 74966a4584e612baab1c77e2ce344236b0e3e782 Mon Sep 17 00:00:00 2001 From: Gautham Date: Sun, 6 Aug 2023 22:37:22 +0300 Subject: [PATCH 41/91] RPC initial commits --- pallets/ocex/rpc/runtime-api/src/lib.rs | 3 + pallets/ocex/rpc/src/lib.rs | 24 +++++ pallets/ocex/src/lib.rs | 27 ++++- pallets/ocex/src/rpc.rs | 130 ++++++++++++++++++++++++ pallets/ocex/src/validator.rs | 23 ++--- primitives/orderbook/src/types.rs | 4 +- runtime/src/lib.rs | 2 + 7 files changed, 190 insertions(+), 23 deletions(-) create mode 100644 pallets/ocex/src/rpc.rs diff --git a/pallets/ocex/rpc/runtime-api/src/lib.rs b/pallets/ocex/rpc/runtime-api/src/lib.rs index 12398b8c2..7f5de0d9f 100644 --- a/pallets/ocex/rpc/runtime-api/src/lib.rs +++ b/pallets/ocex/rpc/runtime-api/src/lib.rs @@ -22,11 +22,14 @@ use parity_scale_codec::Codec; use polkadex_primitives::AssetId; use rust_decimal::Decimal; use sp_std::vec::Vec; +use sp_std::collections::btree_map::BTreeMap; sp_api::decl_runtime_apis! { pub trait PolkadexOcexRuntimeApi where AccountId: Codec, Hash : Codec { fn get_ob_recover_state() -> Result, sp_runtime::DispatchError>; // gets balance from given account of given asset fn get_balance(from: AccountId, of: AssetId) -> Result; + // Returns the asset inventory deviation in the offchain State + fn calculate_inventory_deviation() -> Result, sp_runtime::DispatchError>; } } diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 76ef94504..d9f8501fe 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -47,6 +47,12 @@ pub trait PolkadexOcexRpcApi { of: AssetId, at: Option, ) -> RpcResult; + + #[method(name = "ob_inventoryDeviation")] + fn calculate_inventory_deviation( + &self, + at: Option, + ) -> RpcResult; } /// A structure that represents the Polkadex OCEX pallet RPC, which allows querying @@ -120,6 +126,24 @@ where serde_json::to_string(&runtime_api_result).map_err(runtime_error_into_rpc_err)?; Ok(json) } + + fn calculate_inventory_deviation( + &self, + at: Option<::Hash>, + ) -> RpcResult { + let api = self.client.runtime_api(); + let at = match at { + Some(at) => at, + None => self.client.info().best_hash, + }; + let runtime_api_result = + api.calculate_inventory_deviation(at) + .map_err(runtime_error_into_rpc_err)?; + let json = + serde_json::to_string(&runtime_api_result) + .map_err(runtime_error_into_rpc_err)?; + Ok(json) + } } /// Converts a runtime trap into an RPC error. diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index bc5b2cb0e..1b99615bb 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -31,22 +31,25 @@ use frame_support::{ dispatch::DispatchResult, pallet_prelude::{InvalidTransaction, TransactionValidity, ValidTransaction, Weight}, traits::{ - fungibles::Mutate, tokens::Preservation, Currency, ExistenceRequirement, Get, - OneSessionHandler, + fungibles::{Inspect, Mutate}, + tokens::{Fortitude, Preservation}, + Currency, ExistenceRequirement, Get, OneSessionHandler, }, BoundedVec, }; use frame_system::ensure_signed; use pallet_timestamp as timestamp; use parity_scale_codec::Encode; -use polkadex_primitives::{assets::AssetId, AccountId}; +use polkadex_primitives::{assets::AssetId, AccountId, UNIT_BALANCE}; +use rust_decimal::Decimal; use sp_application_crypto::RuntimeAppPublic; use sp_core::crypto::KeyTypeId; use sp_runtime::{ traits::{AccountIdConversion, UniqueSaturatedInto}, - Percent, + Percent, SaturatedConversion, }; use sp_std::prelude::*; +use std::ops::{Div, DivAssign}; // Re-export pallet items so that they can be accessed from the crate namespace. use orderbook_primitives::{ types::{AccountAsset, TradingPair}, @@ -88,6 +91,7 @@ pub mod sr25519 { #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +pub mod rpc; mod settlement; mod snapshot; pub mod storage; @@ -1619,6 +1623,21 @@ impl>> Pallet Decimal { + let balance = match asset { + AssetId::Polkadex => T::NativeCurrency::free_balance(Self::get_pallet_account()), + AssetId::Asset(id) => T::OtherAssets::reducible_balance( + id, + Self::get_pallet_account(), + Preservation::Expendable, + Fortitude::Force, + ), + }; + + // div will not panic since denominator is a constant + Decimal::from(balance.saturated_into::()).div(&mut Decimal::from(UNIT_BALANCE)) + } } impl sp_application_crypto::BoundToRuntimeAppPublic for Pallet { diff --git a/pallets/ocex/src/rpc.rs b/pallets/ocex/src/rpc.rs new file mode 100644 index 000000000..06caafd24 --- /dev/null +++ b/pallets/ocex/src/rpc.rs @@ -0,0 +1,130 @@ +use crate::{ + pallet::{Accounts, AllowlistedToken, IngressMessages}, + storage::OffchainState, + validator::WORKER_STATUS, + Config, Pallet, +}; +use parity_scale_codec::{Decode, Encode}; +use polkadex_primitives::{AccountId, AssetId}; +use rust_decimal::Decimal; +use sp_core::ByteArray; +use sp_runtime::{offchain::storage::StorageValueRef, traits::BlockNumberProvider, DispatchError, Saturating, SaturatedConversion}; +use sp_std::collections::btree_map::BTreeMap; + +impl Pallet { + /// Returns Some(()), if lock is acquired else, None. + pub fn acquire_offchain_lock() -> Option<()> { + // Check if another worker is already running or not + let s_info = StorageValueRef::persistent(&WORKER_STATUS); + match s_info.get::().map_err(|err| { + log::error!(target:"ocex","Error while loading worker status: {:?}",err); + "Unable to load worker status" + }).ok()? { + Some(true) => { + // Another worker is online, so exit + log::info!(target:"ocex", "Another worker is online, so exit"); + return None + }, + None => {}, + Some(false) => {}, + } + s_info.set(&true); // Set WORKER_STATUS to true + Some(()) + } + + /// Release offchain lock + pub fn release_offchain_lock() { + // Check if another worker is already running or not + let s_info = StorageValueRef::persistent(&WORKER_STATUS); + s_info.set(&false); // Set WORKER_STATUS to true + } + + pub fn get_balances( + state: &mut OffchainState, + account: &AccountId, + ) -> Result, &'static str> { + match state.get(&account.to_raw_vec())? { + None => Ok(BTreeMap::new()), + Some(encoded) => BTreeMap::decode(&mut &encoded[..]) + .map_err(|_| "Unable to decode balances for account"), + } + } + + /// Calculates the deviation of all assets with Offchain and On-chain data. + /// + /// This is a blocking call for offchain worker. + pub fn calculate_inventory_deviation() -> Result, DispatchError> { + // Acquire the lock to run off-chain worker + if let Some(_) = Self::acquire_offchain_lock() { + // 2. Load last processed blk + let mut root = crate::storage::load_trie_root(); + log::info!(target:"ocex-rpc","state_root {:?}", root); + let mut storage = crate::storage::State; + let mut state = OffchainState::load(&mut storage, &mut root); + let mut state_info = Self::load_state_info(&mut state)?; + let last_processed_blk = state_info.last_block; + // 3. Load all main accounts and registered assets from on-chain + let mut offchain_inventory = BTreeMap::new(); + for (main, acc_info) in >::iter() { + // 4. Compute sum of all balances of all assets + let balances: BTreeMap = Self::get_balances(&mut state, &Decode::decode(&mut &main.encode()[..]).unwrap())?; + for (asset, balance) in balances { + offchain_inventory + .entry(asset) + .and_modify(|total: &mut Decimal| { + *total = (*total).saturating_add(balance); + }) + .or_insert(balance); + } + } + // 5. Load assets pallet balances of registered assets + let assets = >::get(); + let mut onchain_inventory = BTreeMap::new(); + for asset in assets { + let total = Self::get_onchain_balance(asset); + onchain_inventory + .entry(asset) + .and_modify(|total_balance: &mut Decimal| { + *total_balance = (*total_balance).saturating_add(total) + }) + .or_insert(total); + } + // 6. Compute the sum of new balances on-chain using ingress messages + let current_blk = frame_system::Pallet::::current_block_number().saturated_into(); + if current_blk > last_processed_blk { + for blk in last_processed_blk.saturating_add(1)..=current_blk { + let ingress_msgs = >::get(blk); + for msg in ingress_msgs { + match msg { + polkadex_primitives::ingress::IngressMessages::Deposit( + _, + asset, + amt, + ) => { + onchain_inventory + .entry(asset) + .and_modify(|total_balance| { + *total_balance = (*total_balance).saturating_add(amt) + }) + .or_insert(amt); + }, + _ => {}, + } + } + } + } + // 7. Compute deviation and return it + let mut deviation = BTreeMap::new(); + for asset in assets { + let diff = onchain_inventory + .get(&asset) + .unwrap_or_default() + .saturating_sub(*offchain_inventory.get(&asset).unwrap_or_default()); + deviation.insert(asset, diff); + } + return Ok(deviation) + } + Self::release_offchain_lock(); + Err(DispatchError::Other("Unable to calculate deviation")) + } +} diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index ed35914f2..a9531771b 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -65,21 +65,10 @@ impl Pallet { } // Check if another worker is already running or not - let s_info = StorageValueRef::persistent(&WORKER_STATUS); - match s_info.get::().map_err(|err| { - log::error!(target:"ocex","Error while loading worker status: {:?}",err); - "Unable to load worker status" - })? { - Some(true) => { - // Another worker is online, so exit - log::info!(target:"ocex", "Another worker is online, so exit"); - return Ok(false) - }, - None => {}, - Some(false) => {}, + if let None = Self::acquire_offchain_lock() { + return Ok(false) } - s_info.set(&true); // Set WORKER_STATUS to true - // Check the next batch to process + // Check the next batch to process let next_nonce = >::get().saturating_add(1); // Load the state to memory @@ -286,8 +275,8 @@ impl Pallet { for action in &batch.actions { match action { UserActions::Trade(trades) => Self::trades(trades, state)?, - UserActions::Withdraw(request) => { - let withdrawal = Self::withdraw(request, state, batch.stid)?; + UserActions::Withdraw(request,stid) => { + let withdrawal = Self::withdraw(request, state, stid)?; withdrawals.push(withdrawal); }, UserActions::BlockImport(blk) => @@ -299,7 +288,7 @@ impl Pallet { Ok(withdrawals) } - fn load_state_info(state: &mut OffchainState) -> Result { + pub(crate) fn load_state_info(state: &mut OffchainState) -> Result { match state.get(&STATE_INFO.to_vec())? { Some(data) => Ok(StateInfo::decode(&mut &data[..]).unwrap_or_default()), None => Ok(StateInfo::default()), diff --git a/primitives/orderbook/src/types.rs b/primitives/orderbook/src/types.rs index 8e35ef225..a325c4b9d 100644 --- a/primitives/orderbook/src/types.rs +++ b/primitives/orderbook/src/types.rs @@ -231,8 +231,8 @@ impl ObMessage { pub enum UserActions { /// Trade operation requested. Trade(Vec), - /// Withdraw operation requested. - Withdraw(WithdrawalRequest), + /// Withdraw operation requested. ( payload, stid) + Withdraw(WithdrawalRequest, u64), /// Block import requested. BlockImport(u32), /// Reset Flag diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7f76a0174..488c62dcd 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1574,6 +1574,8 @@ impl_runtime_apis! { impl pallet_ocex_runtime_api::PolkadexOcexRuntimeApi for Runtime { fn get_ob_recover_state() -> Result, DispatchError> { Ok(OCEX::get_ob_recover_state()?.encode()) } fn get_balance(from: AccountId, of: AssetId) -> Result { OCEX::get_balance(from, of) } + fn calculate_inventory_deviation() -> Result, + DispatchError> { OCEX::calculate_inventory_deviation() } } impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { From cf39e0061cea6695eebaceda04cb64a525bbea44 Mon Sep 17 00:00:00 2001 From: Gautham Date: Mon, 7 Aug 2023 08:10:58 +0300 Subject: [PATCH 42/91] Add a new withdrawal variant with stid --- pallets/ocex/src/validator.rs | 4 ++++ primitives/orderbook/src/types.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index ed35914f2..62fc3d4eb 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -293,6 +293,10 @@ impl Pallet { UserActions::BlockImport(blk) => Self::import_blk((*blk).saturated_into(), state, state_info)?, UserActions::Reset => {}, // Not for offchain worker + UserActions::WithdrawV1(request,stid) => { + let withdrawal = Self::withdraw(request, state, stid)?; + withdrawals.push(withdrawal); + } } } diff --git a/primitives/orderbook/src/types.rs b/primitives/orderbook/src/types.rs index 8e35ef225..a94c62213 100644 --- a/primitives/orderbook/src/types.rs +++ b/primitives/orderbook/src/types.rs @@ -231,12 +231,15 @@ impl ObMessage { pub enum UserActions { /// Trade operation requested. Trade(Vec), + #[deprecated(note = "This variant will be removed in the future, use WithdrawV1")] /// Withdraw operation requested. Withdraw(WithdrawalRequest), /// Block import requested. BlockImport(u32), /// Reset Flag Reset, + /// Withdraw operation requested.( request, stid) + WithdrawV1(WithdrawalRequest, u64), } /// Defines withdraw request DTO. From f52fe3466ba516c096dfea1522e45d6c2b916a82 Mon Sep 17 00:00:00 2001 From: Gautham Date: Mon, 7 Aug 2023 08:24:12 +0300 Subject: [PATCH 43/91] Cargo clippy --- pallets/ocex/src/validator.rs | 6 +++--- pallets/thea/src/validation.rs | 4 ++-- primitives/orderbook/src/types.rs | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 62fc3d4eb..394de8a79 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -293,10 +293,10 @@ impl Pallet { UserActions::BlockImport(blk) => Self::import_blk((*blk).saturated_into(), state, state_info)?, UserActions::Reset => {}, // Not for offchain worker - UserActions::WithdrawV1(request,stid) => { - let withdrawal = Self::withdraw(request, state, stid)?; + UserActions::WithdrawV1(request, stid) => { + let withdrawal = Self::withdraw(request, state, *stid)?; withdrawals.push(withdrawal); - } + }, } } diff --git a/pallets/thea/src/validation.rs b/pallets/thea/src/validation.rs index fca6d76fe..473bba451 100644 --- a/pallets/thea/src/validation.rs +++ b/pallets/thea/src/validation.rs @@ -298,7 +298,7 @@ pub fn send_request( }, } } - return Err("request failed") + Err("request failed") } fn create_and_send_request( @@ -341,7 +341,7 @@ fn create_and_send_request( log::debug!(target:"thea","{} response: {:?}",log_target,body_str); let response: JSONRPCResponse = serde_json::from_str::(body_str) .map_err(|_| "Response failed deserialize")?; - return Ok(response.result) + Ok(response.result) } fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { diff --git a/primitives/orderbook/src/types.rs b/primitives/orderbook/src/types.rs index a94c62213..25f2a3124 100644 --- a/primitives/orderbook/src/types.rs +++ b/primitives/orderbook/src/types.rs @@ -231,7 +231,6 @@ impl ObMessage { pub enum UserActions { /// Trade operation requested. Trade(Vec), - #[deprecated(note = "This variant will be removed in the future, use WithdrawV1")] /// Withdraw operation requested. Withdraw(WithdrawalRequest), /// Block import requested. From 9e2b48be42b95fe54f4fb6ff23fac5aaaac94677 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 7 Aug 2023 12:48:35 +0530 Subject: [PATCH 44/91] Added user_action test case --- pallets/ocex/src/tests.rs | 40 +++++++++++++++++++++++++++++++++++ pallets/ocex/src/validator.rs | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/pallets/ocex/src/tests.rs b/pallets/ocex/src/tests.rs index b8c618662..7e1de7800 100644 --- a/pallets/ocex/src/tests.rs +++ b/pallets/ocex/src/tests.rs @@ -2302,6 +2302,7 @@ use orderbook_primitives::{ }; use sp_runtime::traits::{BlockNumberProvider, One}; +use orderbook_primitives::types::{UserActionBatch, UserActions}; use trie_db::TrieMut; #[test] @@ -2561,6 +2562,21 @@ fn test_whitelist_orderbook_operator_full() { }) } +#[test] +fn test_old_user_action_enum_payload_with_new_enum_returns_ok() { + let payload = r#"{"actions":[{"BlockImport":4842070},{"BlockImport":4842071},{"BlockImport":4842072},{"Withdraw":{"signature":{"Sr25519":"1ce02504db86d6c40826737a0616248570274d6fc880d1294585da3663efb41a8cd7f66db1666edbf0037e193ddf9597ec567e875ccb84b1187bbe6e5d1b5c88"},"payload":{"asset_id":{"asset":"95930534000017180603917534864279132680"},"amount":"0.01","timestamp":1690900017685},"main":"5GLQUnNXayJGG6AZ6ht2MFigMHLKPWZjZqbko2tYQ7GJxi6A","proxy":"5GeYN9KaGkxEzaP2gpefqpCp18a9MEMosPCintz83CGRpKGa"}},{"BlockImport":4842073},{"BlockImport":4842074},{"BlockImport":4842075},{"BlockImport":4842076},{"BlockImport":4842077},{"BlockImport":4842078},{"Withdraw":{"signature":{"Sr25519":"b8a7bb383882379a5cb3796c1fb362a9efca5c224c60e2bb91bfed7a9f94bb620620e32dcecbc7e64011e3d3d073b1290e46b3cb97cf0b96c49ba5b0e9e1548f"},"payload":{"asset_id":{"asset":"123"},"amount":"10","timestamp":1690900085111},"main":"5GLFKUxSXTf8MDDKM1vqEFb5TuV1q642qpQT964mrmjeKz4w","proxy":"5ExtoLVQaef9758mibzLhaxK4GBk7qoysSWo7FKt2nrV26i8"}},{"BlockImport":4842079},{"BlockImport":4842080},{"BlockImport":4842081},{"BlockImport":4842082},{"Withdraw":{"signature":{"Sr25519":"4e589e61b18815abcc3fe50626e54844d1e2fd9bb0575fce8eabb5af1ba4b42fba060ad3067bef341e8d5973d932f30d9113c0abbbd65e96e2dd5cbaf94d4581"},"payload":{"asset_id":{"asset":"456"},"amount":"4","timestamp":1690900140296},"main":"5GLFKUxSXTf8MDDKM1vqEFb5TuV1q642qpQT964mrmjeKz4w","proxy":"5ExtoLVQaef9758mibzLhaxK4GBk7qoysSWo7FKt2nrV26i8"}},{"BlockImport":4842083},{"BlockImport":4842084},{"BlockImport":4842085},{"BlockImport":4842086},{"BlockImport":4842087},{"BlockImport":4842088},{"BlockImport":4842089},{"BlockImport":4842090},{"BlockImport":4842091},{"BlockImport":4842092},{"BlockImport":4842093},{"BlockImport":4842094},{"BlockImport":4842095},{"BlockImport":4842096},{"BlockImport":4842097},{"BlockImport":4842098},{"BlockImport":4842099},{"BlockImport":4842100},{"BlockImport":4842101}],"stid":74132,"snapshot_id":10147,"signature":"901dc6972f94d69f253b9ca5a83410a5bc729e5c30c68cba3e68ea4860ca73e447d06c41d3bad05aca4e031f0fa46b1f64fac70159cec68151fef534e48515de00"}"#; + let payload: Result, serde_json::error::Error> = + serde_json::from_str(payload); + assert!(payload.is_ok()); +} + +#[test] +fn test_scale_encode_with_old_user_action_enum_with_new_returns_ok() { + let actual_payload = fixture_old_user_action::get_old_user_action_fixture(); + let expected_payload: UserActions = UserActions::BlockImport(24); + assert_eq!(actual_payload, expected_payload.encode()); +} + fn allowlist_token(token: AssetId) { let mut allowlisted_token = >::get(); allowlisted_token.try_insert(token).unwrap(); @@ -2724,3 +2740,27 @@ fn create_max_fees() -> Fees { let fees: Fees = Fees { asset: AssetId::Polkadex, amount: Decimal::MAX }; return fees } + +pub mod fixture_old_user_action { + use orderbook_primitives::types::{Trade, WithdrawalRequest}; + use parity_scale_codec::{Codec, Decode, Encode}; + use polkadex_primitives::AccountId; + use scale_info::TypeInfo; + + #[derive(Clone, Debug, Encode, Decode, TypeInfo, PartialEq)] + pub enum UserActions { + /// Trade operation requested. + Trade(Vec), + /// Withdraw operation requested. + Withdraw(WithdrawalRequest), + /// Block import requested. + BlockImport(u32), + /// Reset Flag + Reset, + } + + pub fn get_old_user_action_fixture() -> Vec { + let block_import: UserActions = UserActions::BlockImport(24); + block_import.encode() + } +} diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 394de8a79..87dc59dce 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -425,7 +425,7 @@ fn store_summary( summay_ref.set(&(summary, signature, auth_index)); } -fn send_request(log_target: &str, url: &str, body: &str) -> Result, &'static str> { +pub fn send_request(log_target: &str, url: &str, body: &str) -> Result, &'static str> { let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(12_000)); let body_len = From 985e4debfeb64835cbf7ee6fba1c748e286452c6 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 7 Aug 2023 14:54:27 +0530 Subject: [PATCH 45/91] Removed pub --- pallets/ocex/src/validator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 87dc59dce..4ffb0e27a 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -355,7 +355,7 @@ use crate::storage::OffchainState; use parity_scale_codec::alloc::string::ToString; use sp_std::borrow::ToOwned; -pub fn get_user_action_batch(id: u64) -> Option> { +fn get_user_action_batch(id: u64) -> Option> { let body = serde_json::json!({ "id": id }).to_string(); let result = match send_request("user_actions_batch", &(AGGREGATOR.to_owned() + "/snapshots"), &body) { From f2ae12af6f4425b2005d800e0ecf120945dc72bc Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 9 Aug 2023 09:48:48 +0300 Subject: [PATCH 46/91] Update spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7f76a0174..2640f8b2f 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 302, + spec_version: 303, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 8329aa3534611ec44dc0a62e0bf20961abf77642 Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 9 Aug 2023 10:32:59 +0300 Subject: [PATCH 47/91] Update impl version --- pallets/ocex/src/validator.rs | 1 + runtime/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 4ffb0e27a..20c0599c7 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -208,6 +208,7 @@ impl Pallet { log::debug!(target:"ocex","Importing block: {:?}",blk); if blk != state_info.last_block.saturating_add(1).into() { + log::error!(target:"ocex","Last processed blk: {:?}, given: {:?}",state_info.last_block, blk); return Err("BlockOutofSequence") } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2640f8b2f..609e54fc3 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. spec_version: 303, - impl_version: 0, + impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, state_version: 0, From e8a4948306ceef17defd805dae2f941ef2cda04d Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 9 Aug 2023 10:38:02 +0300 Subject: [PATCH 48/91] Update impl didn't work --- runtime/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 609e54fc3..8cc61933e 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,8 +117,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 303, - impl_version: 1, + spec_version: 304, + impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, state_version: 0, From 0bde2299a3600c3011a4b797b8867d6519efa542 Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 9 Aug 2023 10:59:00 +0300 Subject: [PATCH 49/91] Update sync condition --- pallets/ocex/src/validator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 20c0599c7..18c479080 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -109,7 +109,7 @@ impl Pallet { log::info!(target:"ocex","last_processed_nonce: {:?}, next_nonce: {:?}",last_processed_nonce, next_nonce); - if next_nonce.saturating_sub(last_processed_nonce) > 2 { + if next_nonce.saturating_sub(last_processed_nonce) >= 2 { if state_info.last_block == 0 { state_info.last_block = 4768083; // This is hard coded as the starting point } From 9e98aceb7b5972c286d84c040a56ca6a1deca5c0 Mon Sep 17 00:00:00 2001 From: Gautham Date: Wed, 9 Aug 2023 10:59:25 +0300 Subject: [PATCH 50/91] Update runtime spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 8cc61933e..4e5336ab3 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 304, + spec_version: 305, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From bf579c6d6b943caf4160793ecf5b522a06887c90 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 10 Aug 2023 09:42:12 +0300 Subject: [PATCH 51/91] feature: Incremental Sync --- pallets/ocex/src/snapshot.rs | 2 +- pallets/ocex/src/storage.rs | 38 +++++++++++++++++++++++++++++++++-- pallets/ocex/src/validator.rs | 23 +++++++++++++++++++-- runtime/src/lib.rs | 2 +- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/pallets/ocex/src/snapshot.rs b/pallets/ocex/src/snapshot.rs index 38eb1b661..fe6ba0e08 100644 --- a/pallets/ocex/src/snapshot.rs +++ b/pallets/ocex/src/snapshot.rs @@ -20,7 +20,7 @@ use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::BlockNumber; // Accounts storage -#[derive(Encode, Decode, PartialEq, Debug, Clone)] +#[derive(Encode, Decode, PartialEq, Debug, Clone, Copy)] pub struct StateInfo { /// Last block processed pub last_block: BlockNumber, diff --git a/pallets/ocex/src/storage.rs b/pallets/ocex/src/storage.rs index 352b6a1c6..007a539d0 100644 --- a/pallets/ocex/src/storage.rs +++ b/pallets/ocex/src/storage.rs @@ -55,7 +55,7 @@ impl<'a> OffchainState<'a> { for (key, value) in self.cache.iter() { self.trie.insert(key, value).map_err(map_trie_error)?; } - + self.cache.clear(); self.trie.commit(); Ok(*self.trie.root()) } @@ -244,10 +244,44 @@ mod tests { use crate::{ mock::new_test_ext, - storage::{get_state_trie, load_trie_root, store_trie_root, State}, + storage::{get_state_trie, load_trie_root, store_trie_root, OffchainState, State}, tests::register_offchain_ext, }; + #[test] + pub fn test_commit_change_revert_pattern() { + let mut ext = new_test_ext(); + register_offchain_ext(&mut ext); + log::trace!(target:"ocex","test_trie_storage test starting.."); + ext.execute_with(|| { + let mut root = load_trie_root(); + { + let mut storage = State; + + let mut state = OffchainState::load(&mut storage, &mut root); + + state.insert(b"1".to_vec(), b"a".to_vec()); + state.insert(b"2".to_vec(), b"b".to_vec()); + state.insert(b"3".to_vec(), b"c".to_vec()); + + state.commit().unwrap(); + state.insert(b"4".to_vec(), b"d".to_vec()); + state.commit().unwrap(); + state.insert(b"5".to_vec(), b"e".to_vec()); + } + { + let mut storage = State; + + let mut state = OffchainState::load(&mut storage, &mut root); + state.get(&b"1".to_vec()).unwrap().unwrap(); + state.get(&b"2".to_vec()).unwrap().unwrap(); + state.get(&b"3".to_vec()).unwrap().unwrap(); + state.get(&b"4".to_vec()).unwrap().unwrap(); + assert!(state.get(&b"5".to_vec()).unwrap().is_none()); + } + }); + } + #[test] pub fn test_trie_storage() { let mut ext = new_test_ext(); diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 18c479080..78be09add 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -3,7 +3,7 @@ use crate::{ settlement::{add_balance, process_trade, sub_balance}, snapshot::StateInfo, storage::store_trie_root, - Config, Pallet, SnapshotNonce, + Config, Pallet, SnapshotNonce, Snapshots, }; use orderbook_primitives::{ types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, @@ -126,7 +126,26 @@ impl Pallet { }; sp_runtime::print("Processing nonce"); sp_runtime::print(nonce); - Self::process_batch(&mut state, &batch, &mut state_info)?; + match Self::process_batch(&mut state, &batch, &mut state_info) { + Ok(_) => { + Self::store_state_info(state_info, &mut state); + let computed_root = state.commit()?; + let expected_root = >::get(batch.snapshot_id) + .ok_or("Unable to load snapshot summary from runtime")? + .state_hash; + if computed_root != expected_root { + log::error!(target:"ocex","Computed: {:?}, expected: {:?}, batch: {:?}",computed_root,expected_root,batch.snapshot_id); + return Err("Sync failed") + } else { + store_trie_root(computed_root); + log::debug!(target:"ocex","Stored state root: {:?}",computed_root); + } + }, + Err(err) => { + log::error!(target:"ocex","Error processing batch: {:?}: {:?}",batch.snapshot_id,err); + return Err("Sync failed") + }, + } } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4e5336ab3..45c705d7a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 305, + spec_version: 306, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 8d9475b44499f35a9aa9d4e5f1c47f2e469bbd71 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 10 Aug 2023 10:09:42 +0300 Subject: [PATCH 52/91] clippy --- pallets/ocex/src/validator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 78be09add..50b89a9c3 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -172,7 +172,7 @@ impl Pallet { // Create state hash and store it state_info.stid = batch.stid; state_info.snapshot_id = batch.snapshot_id; // Store the processed nonce - Self::store_state_info(state_info.clone(), &mut state); + Self::store_state_info(state_info, &mut state); let state_hash: H256 = state.commit()?; store_trie_root(state_hash); log::info!(target:"ocex","updated trie root: {:?}", state_hash); From 5a3acbdfbb3665570001f652cac97286e113ce93 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 10 Aug 2023 10:33:08 +0300 Subject: [PATCH 53/91] remove state hash check, this is not valid for first few batches because of state_info not being stored internally --- pallets/ocex/src/validator.rs | 13 ++----------- runtime/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 50b89a9c3..0e80ba07c 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -3,7 +3,7 @@ use crate::{ settlement::{add_balance, process_trade, sub_balance}, snapshot::StateInfo, storage::store_trie_root, - Config, Pallet, SnapshotNonce, Snapshots, + Config, Pallet, SnapshotNonce, }; use orderbook_primitives::{ types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, @@ -130,16 +130,7 @@ impl Pallet { Ok(_) => { Self::store_state_info(state_info, &mut state); let computed_root = state.commit()?; - let expected_root = >::get(batch.snapshot_id) - .ok_or("Unable to load snapshot summary from runtime")? - .state_hash; - if computed_root != expected_root { - log::error!(target:"ocex","Computed: {:?}, expected: {:?}, batch: {:?}",computed_root,expected_root,batch.snapshot_id); - return Err("Sync failed") - } else { - store_trie_root(computed_root); - log::debug!(target:"ocex","Stored state root: {:?}",computed_root); - } + store_trie_root(computed_root); }, Err(err) => { log::error!(target:"ocex","Error processing batch: {:?}: {:?}",batch.snapshot_id,err); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 45c705d7a..535b4463e 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 306, + spec_version: 307, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 3f84ef0e11c32ac464f374115dec6fc963a823b5 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 10 Aug 2023 11:01:34 +0300 Subject: [PATCH 54/91] Update state info correctly --- pallets/ocex/src/validator.rs | 2 ++ runtime/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 0e80ba07c..ab1f9060a 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -128,6 +128,8 @@ impl Pallet { sp_runtime::print(nonce); match Self::process_batch(&mut state, &batch, &mut state_info) { Ok(_) => { + state_info.stid = batch.stid; + state_info.snapshot_id = batch.snapshot_id; Self::store_state_info(state_info, &mut state); let computed_root = state.commit()?; store_trie_root(computed_root); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 535b4463e..d4e03659b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 307, + spec_version: 308, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 2cf3f7c0472ef1c21323e0d958814b2bed83de5c Mon Sep 17 00:00:00 2001 From: zktony Date: Thu, 17 Aug 2023 23:35:01 +0530 Subject: [PATCH 55/91] Reorg offchain worker code --- pallets/ocex/src/aggregator.rs | 141 +++++++++++++ pallets/ocex/src/lib.rs | 1 + pallets/ocex/src/validator.rs | 198 ++++--------------- pallets/thea/src/aggregator.rs | 143 ++++++++++++++ pallets/thea/src/lib.rs | 3 + pallets/thea/src/resolver.rs | 188 ++++++++++++++++++ pallets/thea/src/validation.rs | 349 +++------------------------------ 7 files changed, 540 insertions(+), 483 deletions(-) create mode 100644 pallets/ocex/src/aggregator.rs create mode 100644 pallets/thea/src/aggregator.rs create mode 100644 pallets/thea/src/resolver.rs diff --git a/pallets/ocex/src/aggregator.rs b/pallets/ocex/src/aggregator.rs new file mode 100644 index 000000000..edd875475 --- /dev/null +++ b/pallets/ocex/src/aggregator.rs @@ -0,0 +1,141 @@ +use crate::{ + validator::{JSONRPCResponse, AGGREGATOR, LAST_PROCESSED_SNAPSHOT}, + Config, +}; +use orderbook_primitives::{ + types::{ApprovedSnapshot, UserActionBatch}, + SnapshotSummary, +}; +use parity_scale_codec::{alloc::string::ToString, Decode, Encode}; +use sp_application_crypto::RuntimeAppPublic; +use sp_core::offchain::{Duration, HttpError}; +use sp_runtime::{ + offchain::{ + http, + http::{Error, PendingRequest, Response}, + storage::StorageValueRef, + }, + SaturatedConversion, +}; +use sp_std::{marker::PhantomData, prelude::ToOwned, vec::Vec}; + +pub struct AggregatorClient(PhantomData); + +impl AggregatorClient { + pub(crate) fn load_signed_summary_and_send(snapshot_id: u64) { + let mut key = LAST_PROCESSED_SNAPSHOT.to_vec(); + key.append(&mut snapshot_id.encode()); + + let summay_ref = StorageValueRef::persistent(&key); + match summay_ref.get::<( + SnapshotSummary, + <::AuthorityId as RuntimeAppPublic>::Signature, + u16, + )>() { + Ok(Some((summary, signature, index))) => { + match serde_json::to_string(&ApprovedSnapshot { + summary: summary.encode(), + index: index.saturated_into(), + signature: signature.encode(), + }) { + Ok(body) => { + if let Err(err) = Self::send_request( + "submit_snapshot_api", + &(AGGREGATOR.to_owned() + "/submit_snapshot"), + body.as_str(), + ) { + log::error!(target:"ocex","Error submitting signature: {:?}",err); + } + }, + Err(err) => { + log::error!(target:"ocex","Error serializing ApprovedSnapshot: {:?}",err); + }, + } + }, + Ok(None) => { + log::error!(target:"ocex"," signed summary for: nonce {:?} not found",snapshot_id); + }, + Err(err) => { + log::error!(target:"ocex","Error loading signed summary for: nonce {:?}, {:?}",snapshot_id,err); + }, + } + } + + pub fn get_user_action_batch(id: u64) -> Option> { + let body = serde_json::json!({ "id": id }).to_string(); + let result = match Self::send_request( + "user_actions_batch", + &(AGGREGATOR.to_owned() + "/snapshots"), + &body, + ) { + Ok(encoded_batch) => encoded_batch, + Err(err) => { + log::error!(target:"ocex","Error fetching user actions batch for {:?}: {:?}",id,err); + return None + }, + }; + + match UserActionBatch::::decode(&mut &result[..]) { + Ok(batch) => Some(batch), + Err(_) => { + log::error!(target:"ocex","Unable to decode batch"); + None + }, + } + } + + pub fn send_request(log_target: &str, url: &str, body: &str) -> Result, &'static str> { + let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(12_000)); + + let body_len = + serde_json::to_string(&body.as_bytes().len()).map_err(|_| "Unable to serialize")?; + log::debug!(target:"ocex","Sending {} request with body len {}...",log_target,body_len); + let request = http::Request::post(url, [body]); + let pending: PendingRequest = request + .add_header("Content-Type", "application/json") + .add_header("Content-Length", body_len.as_str()) + .deadline(deadline) + .send() + .map_err(Self::map_http_err)?; + + log::debug!(target:"ocex","Waiting for {} response...",log_target); + let response: Response = pending + .try_wait(deadline) + .map_err(|_pending| "deadline reached")? + .map_err(Self::map_sp_runtime_http_err)?; + + if response.code != 200u16 { + log::warn!(target:"ocex","Unexpected status code for {}: {:?}",log_target,response.code); + return Err("request failed") + } + + let body = response.body().collect::>(); + + // Create a str slice from the body. + let body_str = sp_std::str::from_utf8(body.as_slice()).map_err(|_| { + log::warn!("No UTF8 body"); + "no UTF8 body in response" + })?; + log::debug!(target:"ocex","{} response: {:?}",log_target,body_str); + let response: JSONRPCResponse = serde_json::from_str::(body_str) + .map_err(|_| "Response failed deserialize")?; + + Ok(response.result) + } + + fn map_http_err(err: HttpError) -> &'static str { + match err { + HttpError::DeadlineReached => "Deadline Reached", + HttpError::IoError => "Io Error", + HttpError::Invalid => "Invalid request", + } + } + + fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { + match err { + Error::DeadlineReached => "Deadline Reached", + Error::IoError => "Io Error", + Error::Unknown => "Unknown error", + } + } +} diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index bc5b2cb0e..fdba7d709 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -86,6 +86,7 @@ pub mod sr25519 { pub type AuthorityId = app_sr25519::Public; } +pub mod aggregator; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; mod settlement; diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 18c479080..9cc207dc3 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -1,8 +1,9 @@ use crate::{ + aggregator::AggregatorClient, pallet::ValidatorSetId, settlement::{add_balance, process_trade, sub_balance}, snapshot::StateInfo, - storage::store_trie_root, + storage::{store_trie_root, OffchainState}, Config, Pallet, SnapshotNonce, }; use orderbook_primitives::{ @@ -14,27 +15,15 @@ use polkadex_primitives::{ingress::IngressMessages, withdrawal::Withdrawal, Asse use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; use sp_application_crypto::RuntimeAppPublic; -use sp_core::{ - crypto::ByteArray, - offchain::{Duration, HttpError}, - H256, -}; -use sp_runtime::{ - offchain::{ - http, - http::{Error, PendingRequest, Response}, - storage::StorageValueRef, - }, - SaturatedConversion, -}; -use sp_std::{boxed::Box, collections::btree_map::BTreeMap, vec::Vec}; - +use sp_core::{crypto::ByteArray, H256}; +use sp_runtime::{offchain::storage::StorageValueRef, SaturatedConversion}; +use sp_std::{borrow::ToOwned, boxed::Box, collections::btree_map::BTreeMap, vec::Vec}; use trie_db::{TrieError, TrieMut}; /// Key of the storage that stores the status of an offchain worker pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status"; const STATE_INFO: [u8; 25] = *b"offchain-ocex::state_info"; -const LAST_PROCESSED_SNAPSHOT: [u8; 26] = *b"offchain-ocex::snapshot_id"; +pub const LAST_PROCESSED_SNAPSHOT: [u8; 26] = *b"offchain-ocex::snapshot_id"; /// Aggregator endpoint: Even though it is centralized for now, it is trustless /// as it verifies the signature and and relays them to destination. /// As a future improvment, we can make it decentralized, by having the community run @@ -44,7 +33,7 @@ pub const AGGREGATOR: &str = "https://ob.aggregator.polkadex.trade"; impl Pallet { /// Runs the offchain worker computes the next batch of user actions and /// submits snapshot summary to aggregator endpoint - pub fn run_on_chain_validation(_block_num: T::BlockNumber) -> Result { + pub fn run_on_chain_validation(block_num: T::BlockNumber) -> Result { let local_keys = T::AuthorityId::all(); let authorities = Self::validator_set().validators; let mut available_keys = authorities @@ -65,29 +54,20 @@ impl Pallet { } // Check if another worker is already running or not - let s_info = StorageValueRef::persistent(&WORKER_STATUS); - match s_info.get::().map_err(|err| { - log::error!(target:"ocex","Error while loading worker status: {:?}",err); - "Unable to load worker status" - })? { - Some(true) => { - // Another worker is online, so exit - log::info!(target:"ocex", "Another worker is online, so exit"); - return Ok(false) + match Self::check_worker_status() { + Ok(false) => return Ok(false), + Err(err) => return Err(err), + _ => { + log::info!(target:"ocex", "Checked worker status"); }, - None => {}, - Some(false) => {}, } - s_info.set(&true); // Set WORKER_STATUS to true - // Check the next batch to process let next_nonce = >::get().saturating_add(1); - // Load the state to memory let mut root = crate::storage::load_trie_root(); - log::info!(target:"ocex","block: {:?}, state_root {:?}", _block_num, root); + log::info!(target:"ocex","block: {:?}, state_root {:?}", block_num, root); let mut storage = crate::storage::State; let mut state = OffchainState::load(&mut storage, &mut root); - + // Load the state to memory let mut state_info = match Self::load_state_info(&mut state) { Ok(info) => info, Err(err) => { @@ -103,7 +83,7 @@ impl Pallet { if last_processed_nonce == next_nonce { log::debug!(target:"ocex","Submitting last processed snapshot: {:?}",next_nonce); // resubmit the summary to aggregator - load_signed_summary_and_send::(next_nonce); + AggregatorClient::::load_signed_summary_and_send(next_nonce); return Ok(true) } @@ -117,7 +97,7 @@ impl Pallet { for nonce in last_processed_nonce.saturating_add(1)..next_nonce { log::info!(target:"ocex","Syncing batch: {:?}",nonce); // Load the next ObMessages - let batch = match get_user_action_batch::(nonce) { + let batch = match AggregatorClient::::get_user_action_batch(nonce) { None => { log::error!(target:"ocex","No user actions found for nonce: {:?}",nonce); return Ok(true) @@ -130,9 +110,9 @@ impl Pallet { } } - // Load the next ObMessages + // Load the next ObMessages¡ log::info!(target:"ocex","Loading user actions for nonce: {:?}",next_nonce); - let batch = match get_user_action_batch::(next_nonce) { + let batch = match AggregatorClient::::get_user_action_batch(next_nonce) { None => { log::debug!(target:"ocex","No user actions found for nonce: {:?}",next_nonce); // Store the last processed nonce @@ -185,7 +165,7 @@ impl Pallet { }) .map_err(|_| "ApprovedSnapshot serialization failed")?; - if let Err(err) = send_request( + if let Err(err) = AggregatorClient::::send_request( "submit_snapshot_api", &(AGGREGATOR.to_owned() + "/submit_snapshot"), body.as_str(), @@ -200,6 +180,24 @@ impl Pallet { Ok(true) } + fn check_worker_status() -> Result { + let s_info = StorageValueRef::persistent(&WORKER_STATUS); + match s_info.get::().map_err(|err| { + log::error!(target:"ocex","Error while loading worker status: {:?}",err); + "Unable to load worker status" + })? { + Some(true) => { + // Another worker is online, so exit + log::info!(target:"ocex", "Another worker is online, so exit"); + return Ok(false) + }, + None => {}, + Some(false) => {}, + } + s_info.set(&true); // Set WORKER_STATUS to true + Ok(true) + } + fn import_blk( blk: T::BlockNumber, state: &mut OffchainState, @@ -228,7 +226,6 @@ impl Pallet { } state_info.last_block = blk.saturated_into(); - Ok(()) } @@ -239,7 +236,6 @@ impl Pallet { .ok_or("TradingPairNotFound")?; process_trade(state, trade, config)? } - Ok(()) } @@ -329,7 +325,7 @@ impl Pallet { auth_index } - pub(crate) fn get_offchain_balance( + pub fn get_offchain_balance( account: &polkadex_primitives::AccountId, ) -> Result, &'static str> { let mut root = crate::storage::load_trie_root(); @@ -352,69 +348,6 @@ impl Pallet { } } -use crate::storage::OffchainState; -use parity_scale_codec::alloc::string::ToString; -use sp_std::borrow::ToOwned; - -fn get_user_action_batch(id: u64) -> Option> { - let body = serde_json::json!({ "id": id }).to_string(); - let result = - match send_request("user_actions_batch", &(AGGREGATOR.to_owned() + "/snapshots"), &body) { - Ok(encoded_batch) => encoded_batch, - Err(err) => { - log::error!(target:"ocex","Error fetching user actions batch for {:?}: {:?}",id,err); - return None - }, - }; - - match UserActionBatch::::decode(&mut &result[..]) { - Ok(batch) => Some(batch), - Err(_) => { - log::error!(target:"ocex","Unable to decode batch"); - None - }, - } -} - -fn load_signed_summary_and_send(snapshot_id: u64) { - let mut key = LAST_PROCESSED_SNAPSHOT.to_vec(); - key.append(&mut snapshot_id.encode()); - - let summay_ref = StorageValueRef::persistent(&key); - match summay_ref.get::<( - SnapshotSummary, - <::AuthorityId as RuntimeAppPublic>::Signature, - u16, - )>() { - Ok(Some((summary, signature, index))) => { - match serde_json::to_string(&ApprovedSnapshot { - summary: summary.encode(), - index: index.saturated_into(), - signature: signature.encode(), - }) { - Ok(body) => { - if let Err(err) = send_request( - "submit_snapshot_api", - &(AGGREGATOR.to_owned() + "/submit_snapshot"), - body.as_str(), - ) { - log::error!(target:"ocex","Error submitting signature: {:?}",err); - } - }, - Err(err) => { - log::error!(target:"ocex","Error serializing ApprovedSnapshot: {:?}",err); - }, - } - }, - Ok(None) => { - log::error!(target:"ocex"," signed summary for: nonce {:?} not found",snapshot_id); - }, - Err(err) => { - log::error!(target:"ocex","Error loading signed summary for: nonce {:?}, {:?}",snapshot_id,err); - }, - } -} - fn store_summary( summary: SnapshotSummary, signature: <::AuthorityId as RuntimeAppPublic>::Signature, @@ -426,45 +359,6 @@ fn store_summary( summay_ref.set(&(summary, signature, auth_index)); } -pub fn send_request(log_target: &str, url: &str, body: &str) -> Result, &'static str> { - let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(12_000)); - - let body_len = - serde_json::to_string(&body.as_bytes().len()).map_err(|_| "Unable to serialize")?; - log::debug!(target:"ocex","Sending {} request with body len {}...",log_target,body_len); - let request = http::Request::post(url, [body]); - let pending: PendingRequest = request - .add_header("Content-Type", "application/json") - .add_header("Content-Length", body_len.as_str()) - .deadline(deadline) - .send() - .map_err(map_http_err)?; - - log::debug!(target:"ocex","Waiting for {} response...",log_target); - let response: Response = pending - .try_wait(deadline) - .map_err(|_pending| "deadline reached")? - .map_err(map_sp_runtime_http_err)?; - - if response.code != 200u16 { - log::warn!(target:"ocex","Unexpected status code for {}: {:?}",log_target,response.code); - return Err("request failed") - } - - let body = response.body().collect::>(); - - // Create a str slice from the body. - let body_str = sp_std::str::from_utf8(body.as_slice()).map_err(|_| { - log::warn!("No UTF8 body"); - "no UTF8 body in response" - })?; - log::debug!(target:"ocex","{} response: {:?}",log_target,body_str); - let response: JSONRPCResponse = serde_json::from_str::(body_str) - .map_err(|_| "Response failed deserialize")?; - - Ok(response.result) -} - /// Helper function to map trie error to a static str #[allow(clippy::boxed_local)] pub fn map_trie_error(err: Box>) -> &'static str { @@ -477,22 +371,6 @@ pub fn map_trie_error(err: Box>) -> &'static str { } } -fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { - match err { - Error::DeadlineReached => "Deadline Reached", - Error::IoError => "Io Error", - Error::Unknown => "Unknown error", - } -} - -fn map_http_err(err: HttpError) -> &'static str { - match err { - HttpError::DeadlineReached => "Deadline Reached", - HttpError::IoError => "Io Error", - HttpError::Invalid => "Invalid request", - } -} - /// Http Resposne body #[derive(Serialize, Deserialize)] pub struct JSONRPCResponse { diff --git a/pallets/thea/src/aggregator.rs b/pallets/thea/src/aggregator.rs new file mode 100644 index 000000000..727638752 --- /dev/null +++ b/pallets/thea/src/aggregator.rs @@ -0,0 +1,143 @@ +use crate::{resolver::Resolver, Config}; +use parity_scale_codec::{alloc::string::ToString, Decode, Encode}; +use scale_info::prelude::string::String; +use sp_std::{marker::PhantomData, prelude::ToOwned, vec, vec::Vec}; +use thea_primitives::{types::Destination, Message, Network}; + +pub struct AggregatorClient(pub PhantomData<(S, T)>); + +impl AggregatorClient { + pub fn get_latest_incoming_nonce_parachain() -> u64 { + let storage_key = Self::create_para_incoming_nonce_key(); + Self::get_storage_at_latest_finalized_head::( + "para_incoming_nonce", + Destination::Parachain, + storage_key, + ) + .unwrap_or_default() + .unwrap_or_default() + } + + pub fn get_payload_for_nonce( + nonce: u64, + network: Network, + destination: Destination, + ) -> Option { + log::debug!(target:"thea","Getting payload for nonce {} for network: {} ,dest: {:?}",nonce,network,destination); + match destination { + Destination::Solochain => { + // Get the outgoing message with nonce: `nonce` for network: `network` + let key = Self::create_solo_outgoing_message_key(nonce, network); + match Self::get_storage_at_latest_finalized_head::( + "solo_outgoing_message", + destination, + key, + ) { + Ok(message) => message, + Err(err) => { + log::error!(target:"thea","Unable to get finalized solo head: {:?}",err); + None + }, + } + }, + Destination::Parachain => { + // Get the outgoing message with nonce: `nonce` from network + let key = Self::create_para_outgoing_message_key(nonce); + match Self::get_storage_at_latest_finalized_head::( + "para_outgoing_message", + destination, + key, + ) { + Ok(message) => message, + Err(err) => { + log::error!(target:"thea","Unable to get finalized solo head: {:?}",err); + None + }, + } + }, + _ => { + log::warn!(target:"thea","Invalid destination provided"); + None + }, + } + } + + fn create_solo_outgoing_message_key(nonce: u64, network: Network) -> Vec { + let module_name = sp_io::hashing::twox_128(b"Thea"); + let storage_prefix = sp_io::hashing::twox_128(b"OutgoingMessages"); + let mut key = Vec::new(); + key.append(&mut module_name.to_vec()); + key.append(&mut storage_prefix.to_vec()); + key.append(&mut network.encode()); + key.append(&mut nonce.encode()); + key + } + + /// Returns the encoded key for outgoing message for given nonce in TheaMessageHandler pallet + pub fn create_para_outgoing_message_key(nonce: u64) -> Vec { + let module_name = sp_io::hashing::twox_128(b"TheaMessageHandler"); + let storage_prefix = sp_io::hashing::twox_128(b"OutgoingMessages"); + let mut key = Vec::new(); + key.append(&mut module_name.to_vec()); + key.append(&mut storage_prefix.to_vec()); + key.append(&mut nonce.encode()); + key + } + + fn create_para_incoming_nonce_key() -> Vec { + let module_name = sp_io::hashing::twox_128(b"TheaMessageHandler"); + let storage_prefix = sp_io::hashing::twox_128(b"IncomingNonce"); + let mut key = Vec::new(); + key.append(&mut module_name.to_vec()); + key.append(&mut storage_prefix.to_vec()); + key + } + + fn get_storage_at_latest_finalized_head( + log_target: &str, + destination: Destination, + storage_key: Vec, + ) -> Result, &'static str> { + log::debug!(target:"thea","getting storage for {}",log_target); + // 1. Get finalized head ( Fh ) + let finalized_head = Self::get_finalized_head(destination)?; + let storage_key = "0x".to_owned() + &hex::encode(storage_key); + let body = serde_json::json!({ + "id":1, + "jsonrpc":"2.0", + "method": "state_getStorage", + "params": [storage_key,finalized_head] + }) + .to_string(); + let storage_bytes = Resolver::::send_request(log_target, destination, body.as_str())?; + if storage_bytes.is_null() { + log::debug!(target:"thea","Storage query returned null response"); + return Ok(None) + } + + let storage_bytes = storage_bytes.to_string().replace('\"', ""); // Remove unwanted \" + let storage_bytes = storage_bytes.replace("0x", ""); // Remove unwanted 0x for decoding + let storage_bytes = + hex::decode(storage_bytes).map_err(|_| "Unable to hex decode storage value bytes")?; + + Ok(Some(Decode::decode(&mut &storage_bytes[..]).map_err(|_| "Decode failure")?)) + } + + fn get_finalized_head(destination: Destination) -> Result { + let body = serde_json::json!({ + "id":1, + "jsonrpc":"2.0", + "method": "chain_getFinalizedHead", + "params": [] + }); + let mut result = Resolver::::send_request( + "get_finalized_head", + destination, + body.to_string().as_str(), + )? + .to_string(); + result = result.replace('\"', ""); + log::debug!(target:"thea","Finalized head: {:?}",result); + Ok(result) + } +} diff --git a/pallets/thea/src/lib.rs b/pallets/thea/src/lib.rs index c7e93cb70..005b4ba52 100644 --- a/pallets/thea/src/lib.rs +++ b/pallets/thea/src/lib.rs @@ -48,6 +48,8 @@ mod session; #[cfg(test)] mod tests; +pub mod aggregator; +pub mod resolver; pub mod validation; /// Export of auto-generated weights pub mod weights; @@ -87,6 +89,7 @@ pub trait TheaWeightInfo { #[frame_support::pallet] pub mod pallet { use super::*; + use frame_support::transactional; use frame_system::offchain::SendTransactionTypes; use sp_std::collections::btree_set::BTreeSet; diff --git a/pallets/thea/src/resolver.rs b/pallets/thea/src/resolver.rs new file mode 100644 index 000000000..624a462cf --- /dev/null +++ b/pallets/thea/src/resolver.rs @@ -0,0 +1,188 @@ +use crate::{validation::JSONRPCResponse, Authorities, Config, ValidatorSetId}; +use parity_scale_codec::{alloc::string::ToString, Encode}; +use scale_info::prelude::string::String; +use sp_application_crypto::RuntimeAppPublic; +use sp_core::offchain::{Duration, HttpError}; +use sp_runtime::offchain::{ + http, + http::{Error, PendingRequest, Response}, +}; +use sp_std::{marker::PhantomData, vec::Vec}; +use thea_primitives::{ + types::{ApprovedMessage, Destination}, + Message, +}; + +const MAINNET_URL: &str = "https://mainnet.polkadex.trade"; +const PARACHAIN_URL: &str = "https://parachain.polkadex.trade"; +const AGGREGRATOR_URL: &str = "https://thea.aggregator.polkadex.trade"; + +pub struct Resolver(pub PhantomData); + +impl Resolver { + pub fn send_request( + log_target: &str, + destination: Destination, + body: &str, + ) -> Result { + for try_counter in 0..2 { + match Self::create_and_send_request( + log_target, + body, + &Self::resolve_destination_url(destination, try_counter), + ) { + Ok(value) => return Ok(value), + Err(err) => { + log::error!(target:"thea","Error querying {:?}: {:?}",log_target, err); + }, + } + } + Err("request failed") + } + + pub(crate) fn compute_signer_and_submit( + message: Message, + destination: Destination, + ) -> Result<(), &'static str> { + log::debug!(target:"thea","signing and submitting {:?} to {:?}",message, destination); + // We use SHA256 as it is available across many networks + let msg_hash = sp_io::hashing::sha2_256(message.encode().as_slice()); + + let id = >::get(); + let authorities = >::get(id).to_vec(); + + let local_keys = T::TheaId::all(); + + let mut available_keys = authorities + .iter() + .enumerate() + .filter_map(move |(_index, authority)| { + local_keys + .binary_search(authority) + .ok() + .map(|location| local_keys[location].clone()) + }) + .collect::>(); + available_keys.sort(); + + if available_keys.is_empty() { + return Err("No active keys available") + } + + let signer = available_keys.get(0).ok_or("Key not avaialble")?; + let mut auth_index = -1; + for (index, auth) in authorities.iter().enumerate() { + if auth == signer { + auth_index = index as i32 + } + } + if auth_index < 0 { + return Err("Unable to calculate auth index") + } + // Note: this is a double hash signing + let signature = signer.sign(&msg_hash).ok_or("Expected signature to be returned")?; + + Self::submit_message_to_aggregator( + message, + signature.into(), + destination, + auth_index as u16, + )?; + Ok(()) + } + + fn submit_message_to_aggregator( + message: Message, + signature: T::Signature, + destination: Destination, + auth_index: u16, + ) -> Result<(), &'static str> { + log::debug!(target:"thea","submitting ({:?},{:?}) to aggregator",message.nonce,destination); + let approved_message = ApprovedMessage { + message, + index: auth_index, + signature: signature.encode(), + destination, + }; + let body = serde_json::to_string(&approved_message).map_err(|err| { + log::error!(target:"thea","Error serializing approved message: {:?}",err); + "Error serializing approved message" + })?; + Self::send_request("thea_aggregator_link", Destination::Aggregator, body.as_str())?; + Ok(()) + } + + fn create_and_send_request( + log_target: &str, + body: &str, + url: &str, + ) -> Result { + let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(12_000)); + + let body_len = serde_json::to_string(&body.as_bytes().len()) + .map_err(|_| "Unable to to string body len")?; + log::debug!(target:"thea","Sending {} request with body len {}...",log_target,body_len); + log::debug!(target:"thea","Sending {} request with body {}",log_target,body); + let request = http::Request::post(url, [body]); + let pending: PendingRequest = request + .add_header("Content-Type", "application/json") + .add_header("Content-Length", body_len.as_str()) + .deadline(deadline) + .send() + .map_err(Self::map_http_err)?; + + log::debug!(target:"thea","Waiting for {} response...",log_target); + let response: Response = pending + .try_wait(deadline) + .map_err(|_pending| "deadline reached")? + .map_err(Self::map_sp_runtime_http_err)?; + + if response.code != 200u16 { + log::warn!(target:"thea","Unexpected status code for {}: {:?}",log_target,response.code); + return Err("Unexpected status code") + } + + let body = response.body().collect::>(); + + // Create a str slice from the body. + let body_str = sp_std::str::from_utf8(body.as_slice()).map_err(|_| { + log::warn!("No UTF8 body"); + "no UTF8 body in response" + })?; + log::debug!(target:"thea","{} response: {:?}",log_target,body_str); + let response: JSONRPCResponse = serde_json::from_str::(body_str) + .map_err(|_| "Response failed deserialize")?; + Ok(response.result) + } + + pub fn resolve_destination_url(destination: Destination, counter: i32) -> String { + if destination == Destination::Aggregator { + return AGGREGRATOR_URL.to_string() + } + let url = match (destination, counter) { + (Destination::Solochain, 0) => "http://localhost:9944", + (Destination::Solochain, 1) => MAINNET_URL, + (Destination::Parachain, 0) => "http://localhost:8844", + (Destination::Parachain, 1) => PARACHAIN_URL, + _ => AGGREGRATOR_URL, + }; + log::debug!(target:"thea","Resolving {:?}: {:?} to {:?}",destination,counter,url); + url.to_string() + } + + fn map_http_err(err: HttpError) -> &'static str { + match err { + HttpError::DeadlineReached => "Deadline Reached", + HttpError::IoError => "Io Error", + HttpError::Invalid => "Invalid request", + } + } + + fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { + match err { + Error::DeadlineReached => "Deadline Reached", + Error::IoError => "Io Error", + Error::Unknown => "Unknown error", + } + } +} diff --git a/pallets/thea/src/validation.rs b/pallets/thea/src/validation.rs index 473bba451..ae4b663c0 100644 --- a/pallets/thea/src/validation.rs +++ b/pallets/thea/src/validation.rs @@ -1,29 +1,18 @@ use crate::{ - pallet::{ActiveNetworks, Authorities, IncomingNonce, ValidatorSetId}, + aggregator::AggregatorClient, + pallet::{ActiveNetworks, IncomingNonce}, + resolver::Resolver, Config, Pallet, }; -use parity_scale_codec::{alloc::string::ToString, Decode, Encode}; use serde::{Deserialize, Serialize}; -use sp_core::offchain::{Duration, HttpError}; -use sp_runtime::offchain::{ - http, - http::{Error, PendingRequest, Response}, -}; -use sp_std::{borrow::ToOwned, vec, vec::Vec}; -use thea_primitives::{Message, Network}; - -use sp_application_crypto::RuntimeAppPublic; - -use thea_primitives::types::{ApprovedMessage, Destination}; - -const MAINNET_URL: &str = "https://mainnet.polkadex.trade"; -const PARACHAIN_URL: &str = "https://parachain.polkadex.trade"; -const AGGREGRATOR_URL: &str = "https://thea.aggregator.polkadex.trade"; +use sp_std::vec::Vec; +use thea_primitives::types::Destination; impl Pallet { /// Starts the offchain worker instance that checks for finalized next incoming messages /// for both solochain and parachain, signs it and submits to aggregator pub fn run_thea_validation(_blk: T::BlockNumber) -> Result<(), &'static str> { + //TODO: Find better way to replace u64 if !sp_io::offchain::is_validator() { return Ok(()) } @@ -35,24 +24,35 @@ impl Pallet { // a. Read the next nonce (N) to process at source and destination on its finalized // state let next_incoming_nonce = >::get(network).saturating_add(1); - let next_outgoing_nonce = get_latest_incoming_nonce_parachain().saturating_add(1); + let next_outgoing_nonce = + AggregatorClient::::get_latest_incoming_nonce_parachain().saturating_add(1); //TODO: Replace with Parachain Struct object log::debug!(target:"thea","Next Incoming nonce: {:?}, Outgoing nonce: {:?} for network: {:?}", next_incoming_nonce,next_outgoing_nonce,network); // b. Check if payload for N is available at source and destination on its finalized // state - let next_incoming_message = - get_payload_for_nonce(next_incoming_nonce, network, Destination::Parachain); - let next_outgoing_message = - get_payload_for_nonce(next_outgoing_nonce, network, Destination::Solochain); - // c. Compute who should sign this and if its us then sign the payload + let next_incoming_message = AggregatorClient::::get_payload_for_nonce( + next_incoming_nonce, + network, + Destination::Parachain, + ); //TODO: Replace with Parachain Struct object + let next_outgoing_message = AggregatorClient::::get_payload_for_nonce( + next_outgoing_nonce, + network, + Destination::Solochain, + ); //TODO: Replace with Parachain Struct object + // c. Compute who should sign this and if its us then sign the payload if let Some(message) = next_incoming_message { // d. store the signed payload on-chain for relayers to relay it to destination - compute_signer_and_submit::(message, Destination::Solochain)?; + Resolver::::compute_signer_and_submit(message, Destination::Solochain)?; //TODO: Replace with + // Resolver Struct + // object } else { log::debug!(target:"thea","No incoming message with nonce: {:?} from network: {:?}",next_incoming_nonce,network); } if let Some(message) = next_outgoing_message { - compute_signer_and_submit::(message, Destination::Parachain)?; + Resolver::::compute_signer_and_submit(message, Destination::Parachain)?; //TODO: Replace with + // Resolver Struct + // object } else { log::debug!(target:"thea","No outgoing message with nonce: {:?} to network: {:?}",next_outgoing_nonce,network); } @@ -62,308 +62,11 @@ impl Pallet { } } -fn compute_signer_and_submit( - message: Message, - destination: Destination, -) -> Result<(), &'static str> { - log::debug!(target:"thea","signing and submitting {:?} to {:?}",message, destination); - // We use SHA256 as it is available across many networks - let msg_hash = sp_io::hashing::sha2_256(message.encode().as_slice()); - - let id = >::get(); - let authorities = >::get(id).to_vec(); - - let local_keys = T::TheaId::all(); - - let mut available_keys = authorities - .iter() - .enumerate() - .filter_map(move |(_index, authority)| { - local_keys - .binary_search(authority) - .ok() - .map(|location| local_keys[location].clone()) - }) - .collect::>(); - available_keys.sort(); - - if available_keys.is_empty() { - return Err("No active keys available") - } - - let signer = available_keys.get(0).ok_or("Key not avaialble")?; - let mut auth_index = -1; - for (index, auth) in authorities.iter().enumerate() { - if auth == signer { - auth_index = index as i32 - } - } - if auth_index < 0 { - return Err("Unable to calculate auth index") - } - // Note: this is a double hash signing - let signature = signer.sign(&msg_hash).ok_or("Expected signature to be returned")?; - - submit_message_to_aggregator::(message, signature.into(), destination, auth_index as u16)?; - Ok(()) -} - -fn submit_message_to_aggregator( - message: Message, - signature: T::Signature, - destination: Destination, - auth_index: u16, -) -> Result<(), &'static str> { - log::debug!(target:"thea","submitting ({:?},{:?}) to aggregator",message.nonce,destination); - let approved_message = - ApprovedMessage { message, index: auth_index, signature: signature.encode(), destination }; - let body = serde_json::to_string(&approved_message).map_err(|err| { - log::error!(target:"thea","Error serializing approved message: {:?}",err); - "Error serializing approved message" - })?; - send_request("thea_aggregator_link", Destination::Aggregator, body.as_str())?; - Ok(()) -} - -fn get_latest_incoming_nonce_parachain() -> u64 { - let storage_key = create_para_incoming_nonce_key(); - get_storage_at_latest_finalized_head::( - "para_incoming_nonce", - Destination::Parachain, - storage_key, - ) - .unwrap_or_default() - .unwrap_or_default() -} - -fn get_payload_for_nonce( - nonce: u64, - network: Network, - destination: Destination, -) -> Option { - log::debug!(target:"thea","Getting payload for nonce {} for network: {} ,dest: {:?}",nonce,network,destination); - match destination { - Destination::Solochain => { - // Get the outgoing message with nonce: `nonce` for network: `network` - let key = create_solo_outgoing_message_key(nonce, network); - match get_storage_at_latest_finalized_head::( - "solo_outgoing_message", - destination, - key, - ) { - Ok(message) => message, - Err(err) => { - log::error!(target:"thea","Unable to get finalized solo head: {:?}",err); - None - }, - } - }, - Destination::Parachain => { - // Get the outgoing message with nonce: `nonce` from network - let key = create_para_outgoing_message_key(nonce); - match get_storage_at_latest_finalized_head::( - "para_outgoing_message", - destination, - key, - ) { - Ok(message) => message, - Err(err) => { - log::error!(target:"thea","Unable to get finalized solo head: {:?}",err); - None - }, - } - }, - _ => { - log::warn!(target:"thea","Invalid destination provided"); - None - }, - } -} - -/// Returns the encoded key of the storage that stores incoming nonce on TheaMessageHandler pallet -fn create_para_incoming_nonce_key() -> Vec { - let module_name = sp_io::hashing::twox_128(b"TheaMessageHandler"); - let storage_prefix = sp_io::hashing::twox_128(b"IncomingNonce"); - let mut key = Vec::new(); - key.append(&mut module_name.to_vec()); - key.append(&mut storage_prefix.to_vec()); - key -} -/// Returns the encoded key of the storage that stores outgoing nonce on Thea pallet -pub fn create_solo_outgoing_message_key(nonce: u64, network: Network) -> Vec { - let module_name = sp_io::hashing::twox_128(b"Thea"); - let storage_prefix = sp_io::hashing::twox_128(b"OutgoingMessages"); - let mut key = Vec::new(); - key.append(&mut module_name.to_vec()); - key.append(&mut storage_prefix.to_vec()); - key.append(&mut network.encode()); - key.append(&mut nonce.encode()); - key -} -/// Returns the encoded key for outgoing message for given nonce in TheaMessageHandler pallet -pub fn create_para_outgoing_message_key(nonce: u64) -> Vec { - let module_name = sp_io::hashing::twox_128(b"TheaMessageHandler"); - let storage_prefix = sp_io::hashing::twox_128(b"OutgoingMessages"); - let mut key = Vec::new(); - key.append(&mut module_name.to_vec()); - key.append(&mut storage_prefix.to_vec()); - key.append(&mut nonce.encode()); - key -} - -fn get_storage_at_latest_finalized_head( - log_target: &str, - destination: Destination, - storage_key: Vec, -) -> Result, &'static str> { - log::debug!(target:"thea","getting storage for {}",log_target); - // 1. Get finalized head ( Fh ) - let finalized_head = get_finalized_head(destination)?; - - let storage_key = "0x".to_owned() + &hex::encode(storage_key); - - // 2. Get the storage at Fh - let body = serde_json::json!({ - "id":1, - "jsonrpc":"2.0", - "method": "state_getStorage", - "params": [storage_key,finalized_head] - }) - .to_string(); - - let storage_bytes = send_request(log_target, destination, body.as_str())?; - - if storage_bytes.is_null() { - log::debug!(target:"thea","Storage query returned null response"); - return Ok(None) - } - - let storage_bytes = storage_bytes.to_string().replace('\"', ""); // Remove unwanted \" - let storage_bytes = storage_bytes.replace("0x", ""); // Remove unwanted 0x for decoding - let storage_bytes = - hex::decode(storage_bytes).map_err(|_| "Unable to hex decode storage value bytes")?; - - Ok(Some(Decode::decode(&mut &storage_bytes[..]).map_err(|_| "Decode failure")?)) -} -use scale_info::prelude::string::String; - -fn get_finalized_head(destination: Destination) -> Result { - // This body will work for most substrate chains - let body = serde_json::json!({ - "id":1, - "jsonrpc":"2.0", - "method": "chain_getFinalizedHead", - "params": [] - }); - let mut result = - send_request("get_finalized_head", destination, body.to_string().as_str())?.to_string(); - result = result.replace('\"', ""); - log::debug!(target:"thea","Finalized head: {:?}",result); - Ok(result) -} - -/// Returns the url based on destination and counter -/// -/// Counter value 0 means return the local address -/// Counter value 1 means returns the fallback address. -pub fn resolve_destination_url(destination: Destination, counter: i32) -> String { - if destination == Destination::Aggregator { - return AGGREGRATOR_URL.to_string() - } - let url = match (destination, counter) { - (Destination::Solochain, 0) => "http://localhost:9944", - (Destination::Solochain, 1) => MAINNET_URL, - (Destination::Parachain, 0) => "http://localhost:8844", - (Destination::Parachain, 1) => PARACHAIN_URL, - _ => AGGREGRATOR_URL, - }; - log::debug!(target:"thea","Resolving {:?}: {:?} to {:?}",destination,counter,url); - url.to_string() -} - -pub fn send_request( - log_target: &str, - destination: Destination, - body: &str, -) -> Result { - for try_counter in 0..2 { - match create_and_send_request( - log_target, - body, - &resolve_destination_url(destination, try_counter), - ) { - Ok(value) => return Ok(value), - Err(err) => { - log::error!(target:"thea","Error querying {:?}: {:?}",log_target, err); - }, - } - } - Err("request failed") -} - -fn create_and_send_request( - log_target: &str, - body: &str, - url: &str, -) -> Result { - let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(12_000)); - - let body_len = serde_json::to_string(&body.as_bytes().len()) - .map_err(|_| "Unable to to string body len")?; - log::debug!(target:"thea","Sending {} request with body len {}...",log_target,body_len); - log::debug!(target:"thea","Sending {} request with body {}",log_target,body); - let request = http::Request::post(url, [body]); - let pending: PendingRequest = request - .add_header("Content-Type", "application/json") - .add_header("Content-Length", body_len.as_str()) - .deadline(deadline) - .send() - .map_err(map_http_err)?; - - log::debug!(target:"thea","Waiting for {} response...",log_target); - let response: Response = pending - .try_wait(deadline) - .map_err(|_pending| "deadline reached")? - .map_err(map_sp_runtime_http_err)?; - - if response.code != 200u16 { - log::warn!(target:"thea","Unexpected status code for {}: {:?}",log_target,response.code); - return Err("Unexpected status code") - } - - let body = response.body().collect::>(); - - // Create a str slice from the body. - let body_str = sp_std::str::from_utf8(body.as_slice()).map_err(|_| { - log::warn!("No UTF8 body"); - "no UTF8 body in response" - })?; - log::debug!(target:"thea","{} response: {:?}",log_target,body_str); - let response: JSONRPCResponse = serde_json::from_str::(body_str) - .map_err(|_| "Response failed deserialize")?; - Ok(response.result) -} - -fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { - match err { - Error::DeadlineReached => "Deadline Reached", - Error::IoError => "Io Error", - Error::Unknown => "Unknown error", - } -} -fn map_http_err(err: HttpError) -> &'static str { - match err { - HttpError::DeadlineReached => "Deadline Reached", - HttpError::IoError => "Io Error", - HttpError::Invalid => "Invalid request", - } -} - /// Http Resposne body #[derive(Serialize, Deserialize)] pub struct JSONRPCResponse { jsonrpc: serde_json::Value, - result: serde_json::Value, + pub(crate) result: serde_json::Value, id: u64, } From 6d1a5169ab851bfdcebc4a0975b18f23a805f79f Mon Sep 17 00:00:00 2001 From: zktony Date: Fri, 18 Aug 2023 10:45:24 +0530 Subject: [PATCH 56/91] refactor JsonRpcStruct --- pallets/ocex/src/validator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 9cc207dc3..8a5cda024 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -375,7 +375,7 @@ pub fn map_trie_error(err: Box>) -> &'static str { #[derive(Serialize, Deserialize)] pub struct JSONRPCResponse { jsonrpc: serde_json::Value, - pub(crate) result: Vec, + pub result: Vec, id: u64, } From 5baf86fcfae0486cbd169630f0ef8e6c273cad11 Mon Sep 17 00:00:00 2001 From: zktony Date: Fri, 25 Aug 2023 12:59:54 +0530 Subject: [PATCH 57/91] Impl checkpoints --- Cargo.lock | 11 ++++ node/Cargo.toml | 2 + node/src/main.rs | 2 +- node/src/rpc.rs | 76 +++++++++++++++++++++++-- node/src/service.rs | 2 + pallets/ocex/rpc/Cargo.toml | 8 +++ pallets/ocex/rpc/runtime-api/src/lib.rs | 2 + pallets/ocex/rpc/src/lib.rs | 70 +++++++++++++++++++---- pallets/ocex/rpc/src/offchain.rs | 37 ++++++++++++ pallets/ocex/src/aggregator.rs | 27 ++++++++- pallets/ocex/src/checkpoint_handler.rs | 27 +++++++++ pallets/ocex/src/lib.rs | 37 +++++++++++- pallets/ocex/src/validator.rs | 38 ++++++++++++- pallets/thea/src/aggregator.rs | 28 ++++++++- pallets/thea/src/resolver.rs | 38 +++++++++++++ primitives/orderbook/src/lib.rs | 53 ++++++++++++++++- primitives/orderbook/src/recovery.rs | 14 +++++ runtime/Cargo.toml | 2 + runtime/src/lib.rs | 2 + 19 files changed, 452 insertions(+), 24 deletions(-) create mode 100644 pallets/ocex/rpc/src/offchain.rs create mode 100644 pallets/ocex/src/checkpoint_handler.rs diff --git a/Cargo.lock b/Cargo.lock index f88b80325..c984c171f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4613,6 +4613,7 @@ dependencies = [ "hex-literal 0.3.4", "liquidity", "log", + "orderbook-primitives", "orml-vesting", "pallet-assets", "pallet-authority-discovery", @@ -5323,17 +5324,25 @@ dependencies = [ name = "pallet-ocex-rpc" version = "0.1.0" dependencies = [ + "hash-db", "jsonrpsee", "orderbook-primitives", "pallet-ocex-runtime-api", "parity-scale-codec", + "parking_lot 0.12.1", "polkadex-primitives", + "sc-rpc", + "sc-rpc-api", "serde", "serde_json", "sp-api", "sp-blockchain", + "sp-core", + "sp-offchain", "sp-rpc", "sp-runtime", + "sp-trie", + "trie-db", ] [[package]] @@ -6006,6 +6015,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc", "parity-scale-codec", + "parking_lot 0.12.1", "polkadex-client", "polkadex-primitives", "rpc-assets", @@ -6048,6 +6058,7 @@ dependencies = [ "sp-inherents", "sp-keyring", "sp-keystore", + "sp-offchain", "sp-runtime", "sp-timestamp", "sp-tracing", diff --git a/node/Cargo.toml b/node/Cargo.toml index 55a69856c..0fea04b21 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -86,6 +86,8 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkad sp-transaction-storage-proof = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } frame-try-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43", optional = true } try-runtime-cli = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43", optional = true } +sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" } +parking_lot = "0.12.1" ## Force 0.9.2 as snow release to fix the compilation. diff --git a/node/src/main.rs b/node/src/main.rs index 79c595f9c..4ea6eec3c 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#![deny(unused_crate_dependencies)] +//#![deny(unused_crate_dependencies)] //! Substrate Node Template CLI library. #![warn(missing_docs)] mod chain_spec; diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 759d7575f..3c014c4c6 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -30,9 +30,14 @@ #![warn(missing_docs)] -use jsonrpsee::RpcModule; +use self::error::Error; +use jsonrpsee::{ + core::{async_trait, Error as JsonRpseeError, RpcResult}, + RpcModule, +}; use pallet_ocex_rpc::PolkadexOcexRpc; use pallet_rewards_rpc::PolkadexRewardsRpc; +use parking_lot::RwLock; use polkadex_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index}; use rpc_assets::{PolkadexAssetHandlerRpc, PolkadexAssetHandlerRpcApiServer}; use sc_client_api::{AuxStore, BlockchainEvents}; @@ -40,7 +45,9 @@ use sc_consensus_babe::BabeWorkerHandle; use sc_consensus_grandpa::{ FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState, }; -use sc_rpc::SubscriptionTaskExecutor; +use sc_rpc::{offchain::OffchainApiServer, SubscriptionTaskExecutor}; +/// Re-export the API for backward compatibility. +pub use sc_rpc_api::offchain::*; pub use sc_rpc_api::DenyUnsafe; use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; @@ -48,6 +55,10 @@ use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_consensus::SelectChain; use sp_consensus_babe::BabeApi; +use sp_core::{ + offchain::{OffchainStorage, StorageKind}, + Bytes, +}; use sp_keystore::KeystorePtr; use std::sync::Arc; @@ -89,6 +100,8 @@ pub struct FullDeps { pub babe: BabeDeps, /// GRANDPA specific dependencies. pub grandpa: GrandpaDeps, + /// The backend used by the node. + pub backend: Arc, } /// Instantiate all Full RPC extensions. @@ -128,7 +141,8 @@ where // use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut io = RpcModule::new(()); - let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa } = deps; + let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa, backend } = + deps; let BabeDeps { keystore, babe_worker_handle } = babe; let GrandpaDeps { @@ -164,8 +178,58 @@ where // io.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; io.merge(PolkadexAssetHandlerRpc::new(client.clone()).into_rpc())?; io.merge(PolkadexRewardsRpc::new(client.clone()).into_rpc())?; - io.merge(PolkadexOcexRpc::new(client.clone()).into_rpc())?; - io.merge(Dev::new(client, deny_unsafe).into_rpc())?; - + io.merge( + PolkadexOcexRpc::new( + client.clone(), + backend + .offchain_storage() + .ok_or_else(|| "Backend doesn't provide an offchain storage")?, + deny_unsafe, + ) + .into_rpc(), + )?; + io.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?; + //io.merge(Offchain::new(backend.offchain_storage().ok_or_else(|| "Backend doesn't provide an + // offchain storage")?, deny_unsafe).into_rpc())?; Ok(io) } + +/// Offchain API +#[derive(Debug)] +pub struct Offchain { + /// Offchain storage + storage: Arc>, + deny_unsafe: DenyUnsafe, +} + +impl Offchain { + /// Create new instance of Offchain API. + pub fn new(storage: T, deny_unsafe: DenyUnsafe) -> Self { + Offchain { storage: Arc::new(RwLock::new(storage)), deny_unsafe } + } +} + +#[async_trait] +impl OffchainApiServer for Offchain { + fn set_local_storage(&self, kind: StorageKind, key: Bytes, value: Bytes) -> RpcResult<()> { + self.deny_unsafe.check_if_safe()?; + + let prefix = match kind { + StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, + StorageKind::LOCAL => return Err(JsonRpseeError::from(Error::UnavailableStorageKind)), + }; + self.storage.write().set(prefix, &key, &value); + Ok(()) + } + + fn get_local_storage(&self, kind: StorageKind, key: Bytes) -> RpcResult> { + self.deny_unsafe.check_if_safe()?; + + let prefix = match kind { + StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, + StorageKind::LOCAL => return Err(JsonRpseeError::from(Error::UnavailableStorageKind)), + }; + + Ok(self.storage.read().get(prefix, &key).map(Into::into)) + } +} diff --git a/node/src/service.rs b/node/src/service.rs index c393e9cc7..9b889d7e7 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -244,6 +244,7 @@ pub fn new_partial( let select_chain = select_chain.clone(); let keystore = keystore_container.keystore(); let chain_spec = config.chain_spec.cloned_box(); + let rpc_backend = backend.clone(); let rpc_extensions_builder = move |deny_unsafe, subscription_executor| { let deps = node_rpc::FullDeps { client: client.clone(), @@ -262,6 +263,7 @@ pub fn new_partial( subscription_executor, finality_provider: finality_proof_provider.clone(), }, + backend: rpc_backend.clone(), }; node_rpc::create_full(deps).map_err(Into::into) diff --git a/pallets/ocex/rpc/Cargo.toml b/pallets/ocex/rpc/Cargo.toml index ddd0fe46b..0c80c8edf 100644 --- a/pallets/ocex/rpc/Cargo.toml +++ b/pallets/ocex/rpc/Cargo.toml @@ -11,7 +11,15 @@ sp-rpc = { workspace = true } sp-blockchain = { workspace = true } sp-api = { workspace = true } sp-runtime = { workspace = true } +sp-core = { workspace = true } orderbook-primitives = { path = "../../../primitives/orderbook" } pallet-ocex-runtime-api = { path = "runtime-api" } serde_json = { workspace = true, default-features = true } polkadex-primitives = { workspace = true } +sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } +sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } +sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" } +parking_lot = "0.12.1" +hash-db = { workspace = true } +trie-db = { workspace = true } +sp-trie = { workspace = true } diff --git a/pallets/ocex/rpc/runtime-api/src/lib.rs b/pallets/ocex/rpc/runtime-api/src/lib.rs index 12398b8c2..28b826b18 100644 --- a/pallets/ocex/rpc/runtime-api/src/lib.rs +++ b/pallets/ocex/rpc/runtime-api/src/lib.rs @@ -18,6 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +use orderbook_primitives::ObCheckpointRaw; use parity_scale_codec::Codec; use polkadex_primitives::AssetId; use rust_decimal::Decimal; @@ -28,5 +29,6 @@ sp_api::decl_runtime_apis! { fn get_ob_recover_state() -> Result, sp_runtime::DispatchError>; // gets balance from given account of given asset fn get_balance(from: AccountId, of: AssetId) -> Result; + fn fetch_checkpoint() -> Result; } } diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 76ef94504..9d62f68d0 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -19,21 +19,39 @@ //! This crate provides an RPC methods for OCEX pallet - balances state and onchain/offchain //! recovery data. +pub mod offchain; + use jsonrpsee::{ core::{async_trait, Error as JsonRpseeError, RpcResult}, proc_macros::rpc, types::error::{CallError, ErrorObject}, }; -use orderbook_primitives::recovery::ObRecoveryState; +use orderbook_primitives::{ + recovery::{ObCheckpoint, ObRecoveryState}, + ObCheckpointRaw, +}; pub use pallet_ocex_runtime_api::PolkadexOcexRuntimeApi; use parity_scale_codec::{Codec, Decode}; -use polkadex_primitives::AssetId; +use parking_lot::RwLock; +use polkadex_primitives::{AccountId, AssetId, Balance, Block, BlockNumber, Hash, Index}; +use sc_rpc::offchain::OffchainApiServer; +use sc_rpc_api::offchain::error::Error; +pub use sc_rpc_api::DenyUnsafe; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; -use sp_runtime::traits::Block as BlockT; +use sp_core::{ + offchain::{OffchainStorage, StorageKind}, + Bytes, Hasher, +}; +use sp_runtime::{ + offchain::storage::StorageValueRef, + traits::{BlakeTwo256, Block as BlockT}, +}; use std::sync::Arc; +use crate::offchain::OffchainStorageAdapter; const RUNTIME_ERROR: i32 = 1; +pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status"; #[rpc(client, server)] pub trait PolkadexOcexRpcApi { @@ -47,6 +65,9 @@ pub trait PolkadexOcexRpcApi { of: AssetId, at: Option, ) -> RpcResult; + + #[method(name = "ob_fetchCheckpoint")] + fn fetch_checkpoint(&self, at: Option) -> RpcResult; } /// A structure that represents the Polkadex OCEX pallet RPC, which allows querying @@ -56,31 +77,39 @@ pub trait PolkadexOcexRpcApi { /// /// * `Client`: The client API used to interact with the Substrate runtime. /// * `Block`: The block type of the Substrate runtime. -pub struct PolkadexOcexRpc { +pub struct PolkadexOcexRpc { /// An `Arc` reference to the client API for accessing runtime functionality. client: Arc, - + /// Offchain storage + storage: Arc>, + deny_unsafe: DenyUnsafe, /// A marker for the `Block` type parameter, used to ensure the struct /// is covariant with respect to the block type. _marker: std::marker::PhantomData, } -impl PolkadexOcexRpc { - pub fn new(client: Arc) -> Self { - Self { client, _marker: Default::default() } +impl PolkadexOcexRpc { + pub fn new(client: Arc, storage: T, deny_unsafe: DenyUnsafe) -> Self { + Self { + client, + storage: Arc::new(RwLock::new(storage)), + deny_unsafe, + _marker: Default::default(), + } } } #[async_trait] -impl +impl PolkadexOcexRpcApiServer<::Hash, AccountId, Hash> - for PolkadexOcexRpc + for PolkadexOcexRpc where Block: BlockT, Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, Client::Api: PolkadexOcexRuntimeApi, AccountId: Codec, Hash: Codec, + T: OffchainStorage + 'static, { fn get_ob_recover_state( &self, @@ -120,6 +149,27 @@ where serde_json::to_string(&runtime_api_result).map_err(runtime_error_into_rpc_err)?; Ok(json) } + + fn fetch_checkpoint(&self, at: Option<::Hash>) -> RpcResult { + let api = self.client.runtime_api(); + let at = match at { + Some(at) => at, + None => self.client.info().best_hash, + }; + let offchain_worker = OffchainStorageAdapter::new(self.storage.clone()); + while offchain_worker.get_worker_status() { + std::thread::sleep(std::time::Duration::from_millis(100)); + } + offchain_worker.update_worker_status(true); + return if let Ok(Ok(ob_checkpoint_raw)) = api.fetch_checkpoint(at) { + let ob_checkpoint = ob_checkpoint_raw.to_checkpoint(); + offchain_worker.update_worker_status(false); + Ok(ob_checkpoint) + } else { + offchain_worker.update_worker_status(false); + Err(JsonRpseeError::from(Error::UnavailableStorageKind)) + } + } } /// Converts a runtime trap into an RPC error. diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs new file mode 100644 index 000000000..867e04549 --- /dev/null +++ b/pallets/ocex/rpc/src/offchain.rs @@ -0,0 +1,37 @@ +use parity_scale_codec::{Decode, Encode}; +use parking_lot::RwLock; +use sp_core::{offchain::OffchainStorage, Bytes}; +use std::sync::Arc; + +pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status"; + +pub struct OffchainStorageAdapter { + storage: Arc>, +} + +impl OffchainStorageAdapter { + pub fn new(storage: Arc>) -> Self { + Self { storage } + } + + pub fn get_worker_status(&self) -> bool { + let prefix = sp_offchain::STORAGE_PREFIX; + let bytes: Option = self.storage.read().get(prefix, &WORKER_STATUS).map(Into::into); + match bytes { + Some(encoded_bytes) => { + let encoded_value = encoded_bytes.to_vec(); + match Decode::decode(&mut &encoded_value[..]) { + Ok(worker_status) => worker_status, + Err(_) => false, + } + }, + None => false, + } + } + + pub fn update_worker_status(&self, status: bool) { + let prefix = sp_offchain::STORAGE_PREFIX; + let encoded_value = Encode::encode(&status); + self.storage.write().set(prefix, &WORKER_STATUS, &encoded_value); + } +} diff --git a/pallets/ocex/src/aggregator.rs b/pallets/ocex/src/aggregator.rs index edd875475..8c3d3aeff 100644 --- a/pallets/ocex/src/aggregator.rs +++ b/pallets/ocex/src/aggregator.rs @@ -22,7 +22,10 @@ use sp_std::{marker::PhantomData, prelude::ToOwned, vec::Vec}; pub struct AggregatorClient(PhantomData); impl AggregatorClient { - pub(crate) fn load_signed_summary_and_send(snapshot_id: u64) { + /// Load signed summary and send it to the aggregator + /// # Parameters + /// * `snapshot_id`: Snapshot id for which signed summary should be loaded and sent + pub fn load_signed_summary_and_send(snapshot_id: u64) { let mut key = LAST_PROCESSED_SNAPSHOT.to_vec(); key.append(&mut snapshot_id.encode()); @@ -61,6 +64,11 @@ impl AggregatorClient { } } + /// Load user action batch from aggregator + /// # Parameters + /// * `id`: Batch id to load + /// # Returns + /// * `Option>`: Loaded batch or None if error occured pub fn get_user_action_batch(id: u64) -> Option> { let body = serde_json::json!({ "id": id }).to_string(); let result = match Self::send_request( @@ -84,6 +92,13 @@ impl AggregatorClient { } } + /// Send request to aggregator + /// # Parameters + /// * `log_target`: Log target for debug logs + /// * `url`: Url to send request to + /// * `body`: Body of the request + /// # Returns + /// * `Result, &'static str>`: Response body or error message pub fn send_request(log_target: &str, url: &str, body: &str) -> Result, &'static str> { let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(12_000)); @@ -123,6 +138,11 @@ impl AggregatorClient { Ok(response.result) } + /// Map http error to static string + /// # Parameters + /// * `err`: Http error to map + /// # Returns + /// * `&'static str`: Mapped error fn map_http_err(err: HttpError) -> &'static str { match err { HttpError::DeadlineReached => "Deadline Reached", @@ -131,6 +151,11 @@ impl AggregatorClient { } } + /// Map sp_runtime http error to static string + /// # Parameters + /// * `err`: Http error to map + /// # Returns + /// * `&'static str`: Mapped error fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { match err { Error::DeadlineReached => "Deadline Reached", diff --git a/pallets/ocex/src/checkpoint_handler.rs b/pallets/ocex/src/checkpoint_handler.rs new file mode 100644 index 000000000..80406c6f6 --- /dev/null +++ b/pallets/ocex/src/checkpoint_handler.rs @@ -0,0 +1,27 @@ +use sp_runtime::offchain::storage::StorageValueRef; + +const CHECKPOINT_FLAG: [u8; 30] = *b"offchain-ocex::checkpoint_flag"; + +struct CheckpointHandler; + +impl CheckpointHandler { + fn get_checkpoint_flag() -> bool { + let s_r = StorageValueRef::persistent(&CHECKPOINT_FLAG); + match s_r.get::() { + Ok(Some(x)) => x, + Ok(None) => { + log::trace!(target:"ocex","checkpoint_flag not found"); + false + }, + Err(_) => { + log::error!(target:"ocex","Failed to get checkpoint_flag"); + false + }, + } + } + + fn set_checkpoint_flag(flag: bool) { + let mut s_w = StorageValueRef::persistent(&CHECKPOINT_FLAG); + s_w.set(&flag); + } +} diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index fdba7d709..23002c443 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -89,6 +89,7 @@ pub mod sr25519 { pub mod aggregator; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +mod checkpoint_handler; mod settlement; mod snapshot; pub mod storage; @@ -143,7 +144,7 @@ pub mod pallet { }; use frame_system::{offchain::SendTransactionTypes, pallet_prelude::*}; use liquidity::LiquidityModifier; - use orderbook_primitives::{Fees, SnapshotSummary}; + use orderbook_primitives::{Fees, ObCheckpointRaw, SnapshotSummary}; use polkadex_primitives::{ assets::AssetId, ocex::{AccountInfo, TradingPairConfig}, @@ -323,6 +324,8 @@ pub mod pallet { CannotFindCloseBlockForSnapshot, /// Dispute Interval not set DisputeIntervalNotSet, + /// Worker not Idle + WorkerNotIdle } #[pallet::hooks] @@ -1315,6 +1318,38 @@ pub mod pallet { )) } + pub fn fetch_checkpoint() -> Result { + let account_id = + >::iter().fold(vec![], |mut ids_accum, (acc, acc_info)| { + ids_accum.push((acc.clone(), acc_info.proxies)); + ids_accum + }); + + let mut balances: BTreeMap = BTreeMap::new(); + // all offchain balances for main accounts + for account in account_id { + let main = Self::transform_account(account.0)?; + // Check if worker is active or not + if !Self::get_worker_status().is_idle() { + return Err(Error::::WorkerNotIdle.into()); + } + let b = Self::get_offchain_balance(&main)?; + for (asset, balance) in b.into_iter() { + balances.insert(AccountAsset { main: main.clone(), asset }, balance); + } + } + let state_info = Self::get_state_info().map_err(|_err| DispatchError::Corruption)?; + let last_processed_block_number = state_info.last_block; + let snapshot_id = state_info.snapshot_id; + let state_change_id = state_info.stid; + Ok(ObCheckpointRaw::new( + snapshot_id, + balances, + last_processed_block_number, + state_change_id, + )) + } + /// Fetches balance of given `AssetId` for given `AccountId` from offchain storage /// If nothing found - returns `Decimal::Zero` pub fn get_balance(from: T::AccountId, of: AssetId) -> Result { diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 8a5cda024..3125ad8e6 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -8,7 +8,7 @@ use crate::{ }; use orderbook_primitives::{ types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, - SnapshotSummary, + OrderbookWorkerStatus, SnapshotSummary, }; use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::{ingress::IngressMessages, withdrawal::Withdrawal, AssetId}; @@ -180,7 +180,29 @@ impl Pallet { Ok(true) } - fn check_worker_status() -> Result { + pub fn get_worker_status() -> OrderbookWorkerStatus { + let s_info = StorageValueRef::persistent(&WORKER_STATUS); + match s_info + .get::() + .map_err(|err| { + log::error!(target:"ocex","Error while loading worker status: {:?}",err); + "Unable to load worker status" + }) + .unwrap() + { + //TODO: Fix this unwrap + Some(true) => { + // Another worker is online, so exit + log::info!(target:"ocex", "Another worker is online, so exit"); + return OrderbookWorkerStatus::InProgress + }, + None => OrderbookWorkerStatus::NotStarted, + Some(false) => OrderbookWorkerStatus::Idle, + } + } + + /// Checks if another worker is already running or not + pub fn check_worker_status() -> Result { let s_info = StorageValueRef::persistent(&WORKER_STATUS); match s_info.get::().map_err(|err| { log::error!(target:"ocex","Error while loading worker status: {:?}",err); @@ -198,6 +220,7 @@ impl Pallet { Ok(true) } + /// Imports a block into the offchain state and handles the deposits fn import_blk( blk: T::BlockNumber, state: &mut OffchainState, @@ -229,6 +252,7 @@ impl Pallet { Ok(()) } + /// Processes a trade between a maker and a taker, updating their order states and balances fn trades(trades: &Vec, state: &mut OffchainState) -> Result<(), &'static str> { log::info!(target:"ocex","Settling trades..."); for trade in trades { @@ -239,6 +263,7 @@ impl Pallet { Ok(()) } + /// Processes a withdrawal request, updating the account balances accordingly. fn withdraw( request: &WithdrawalRequest, state: &mut OffchainState, @@ -269,6 +294,7 @@ impl Pallet { Ok(withdrawal) } + /// Processes a batch of user actions, updating the offchain state accordingly. fn process_batch( state: &mut OffchainState, batch: &UserActionBatch, @@ -300,6 +326,7 @@ impl Pallet { Ok(withdrawals) } + /// Loads the state info from the offchain state fn load_state_info(state: &mut OffchainState) -> Result { match state.get(&STATE_INFO.to_vec())? { Some(data) => Ok(StateInfo::decode(&mut &data[..]).unwrap_or_default()), @@ -307,10 +334,12 @@ impl Pallet { } } + /// Stores the state info in the offchain state fn store_state_info(state_info: StateInfo, state: &mut OffchainState) { state.insert(STATE_INFO.to_vec(), state_info.encode()); } + /// Calculates the index of the signer in the authorities array fn calculate_signer_index( authorities: &[T::AuthorityId], expected_signer: &T::AuthorityId, @@ -325,6 +354,7 @@ impl Pallet { auth_index } + /// Returns the offchain state pub fn get_offchain_balance( account: &polkadex_primitives::AccountId, ) -> Result, &'static str> { @@ -340,7 +370,8 @@ impl Pallet { Ok(balance) } - pub(crate) fn get_state_info() -> Result { + /// Returns the offchain state + pub fn get_state_info() -> Result { let mut root = crate::storage::load_trie_root(); let mut storage = crate::storage::State; let mut state = OffchainState::load(&mut storage, &mut root); @@ -348,6 +379,7 @@ impl Pallet { } } +/// Stores the summary in the storage fn store_summary( summary: SnapshotSummary, signature: <::AuthorityId as RuntimeAppPublic>::Signature, diff --git a/pallets/thea/src/aggregator.rs b/pallets/thea/src/aggregator.rs index 727638752..ac1a2a119 100644 --- a/pallets/thea/src/aggregator.rs +++ b/pallets/thea/src/aggregator.rs @@ -7,6 +7,9 @@ use thea_primitives::{types::Destination, Message, Network}; pub struct AggregatorClient(pub PhantomData<(S, T)>); impl AggregatorClient { + /// Returns the latest incoming nonce for parachain + /// # Returns + /// * `u64`: Latest incoming nonce for parachain pub fn get_latest_incoming_nonce_parachain() -> u64 { let storage_key = Self::create_para_incoming_nonce_key(); Self::get_storage_at_latest_finalized_head::( @@ -18,6 +21,9 @@ impl AggregatorClient { .unwrap_or_default() } + /// Returns the latest incoming nonce for solochain + /// # Returns + /// * `u64`: Latest incoming nonce for solochain pub fn get_payload_for_nonce( nonce: u64, network: Network, @@ -62,6 +68,12 @@ impl AggregatorClient { } } + /// Returns the encoded key for outgoing message for given nonce + /// # Parameters + /// * `nonce`: Nonce of the outgoing message + /// * `network`: Network of the outgoing message + /// # Returns + /// * `Vec`: Encoded key for outgoing message for given nonce fn create_solo_outgoing_message_key(nonce: u64, network: Network) -> Vec { let module_name = sp_io::hashing::twox_128(b"Thea"); let storage_prefix = sp_io::hashing::twox_128(b"OutgoingMessages"); @@ -73,7 +85,11 @@ impl AggregatorClient { key } - /// Returns the encoded key for outgoing message for given nonce in TheaMessageHandler pallet + /// Returns the encoded key for outgoing message for given nonce for parachain + /// # Parameters + /// * `nonce`: Nonce of the outgoing message + /// # Returns + /// * `Vec`: Encoded key for outgoing message for given nonce for parachain pub fn create_para_outgoing_message_key(nonce: u64) -> Vec { let module_name = sp_io::hashing::twox_128(b"TheaMessageHandler"); let storage_prefix = sp_io::hashing::twox_128(b"OutgoingMessages"); @@ -84,6 +100,9 @@ impl AggregatorClient { key } + /// Returns the encoded key for incoming nonce for parachain + /// # Returns + /// * `Vec`: Encoded key for incoming nonce for parachain fn create_para_incoming_nonce_key() -> Vec { let module_name = sp_io::hashing::twox_128(b"TheaMessageHandler"); let storage_prefix = sp_io::hashing::twox_128(b"IncomingNonce"); @@ -93,6 +112,10 @@ impl AggregatorClient { key } + /// Returns the storage value for given key at latest finalized head + /// # Parameters + /// * `log_target`: Log target for debug logs + /// * `destination`: Message destination fn get_storage_at_latest_finalized_head( log_target: &str, destination: Destination, @@ -123,6 +146,9 @@ impl AggregatorClient { Ok(Some(Decode::decode(&mut &storage_bytes[..]).map_err(|_| "Decode failure")?)) } + /// Returns the latest finalized head + /// # Parameters + /// * `destination`: Message destination fn get_finalized_head(destination: Destination) -> Result { let body = serde_json::json!({ "id":1, diff --git a/pallets/thea/src/resolver.rs b/pallets/thea/src/resolver.rs index 624a462cf..40b25a5d1 100644 --- a/pallets/thea/src/resolver.rs +++ b/pallets/thea/src/resolver.rs @@ -20,6 +20,11 @@ const AGGREGRATOR_URL: &str = "https://thea.aggregator.polkadex.trade"; pub struct Resolver(pub PhantomData); impl Resolver { + /// Generate request body for the given message and send it to the destination + /// # Parameters + /// * `log_target`: Log target for the request + /// * `destination`: Destination to which request should be sent + /// * `body`: Body of the request pub fn send_request( log_target: &str, destination: Destination, @@ -40,6 +45,7 @@ impl Resolver { Err("request failed") } + /// pub(crate) fn compute_signer_and_submit( message: Message, destination: Destination, @@ -91,6 +97,15 @@ impl Resolver { Ok(()) } + /// Submit message to aggregator + /// # Parameters + /// * `message`: Message to submit + /// * `signature`: Signed Message + /// * `destination`: Destination to which request should be sent + /// * `auth_index`: Index of the signer in the authorities + /// # Returns + /// * `Result<(), &'static str>`: Ok if message was submitted successfully, error message + /// otherwise fn submit_message_to_aggregator( message: Message, signature: T::Signature, @@ -112,6 +127,13 @@ impl Resolver { Ok(()) } + /// Create and send request to the given url + /// # Parameters + /// * `log_target`: Log target for the request + /// * `body`: Body of the request + /// * `url`: Url to send request to + /// # Returns + /// * `Result`: Response body or error message fn create_and_send_request( log_target: &str, body: &str, @@ -155,6 +177,12 @@ impl Resolver { Ok(response.result) } + /// Resolve destination url for the given destination + /// # Parameters + /// * `destination`: Destination to resolve + /// * `counter`: Counter to resolve + /// # Returns + /// * `String`: Resolved url pub fn resolve_destination_url(destination: Destination, counter: i32) -> String { if destination == Destination::Aggregator { return AGGREGRATOR_URL.to_string() @@ -170,6 +198,11 @@ impl Resolver { url.to_string() } + /// Map http error to static string + /// # Parameters + /// * `err`: Http error to map + /// # Returns + /// * `&'static str`: Mapped error fn map_http_err(err: HttpError) -> &'static str { match err { HttpError::DeadlineReached => "Deadline Reached", @@ -178,6 +211,11 @@ impl Resolver { } } + /// Map sp_runtime http error to static string + /// # Parameters + /// * `err`: Http error to map + /// # Returns + /// * `&'static str`: Mapped error fn map_sp_runtime_http_err(err: sp_runtime::offchain::http::Error) -> &'static str { match err { Error::DeadlineReached => "Deadline Reached", diff --git a/primitives/orderbook/src/lib.rs b/primitives/orderbook/src/lib.rs index ac28e4511..243b1fc7c 100644 --- a/primitives/orderbook/src/lib.rs +++ b/primitives/orderbook/src/lib.rs @@ -24,6 +24,7 @@ #![feature(int_roundings)] #![cfg_attr(not(feature = "std"), no_std)] +use crate::types::AccountAsset; use parity_scale_codec::{Codec, Decode, Encode}; use polkadex_primitives::{withdrawal::Withdrawal, AssetId, BlockNumber}; pub use primitive_types::H128; @@ -31,7 +32,9 @@ use rust_decimal::Decimal; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_core::H256; -use sp_std::vec::Vec; +use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; +#[cfg(feature = "std")] +use crate::recovery::ObCheckpoint; pub mod constants; pub mod types; @@ -125,3 +128,51 @@ impl SnapshotSummary { fees } } + +#[derive(Clone, Debug, Encode, Decode, Default, TypeInfo)] +pub struct ObCheckpointRaw { + /// The snapshot ID of the order book recovery state. + pub snapshot_id: u64, + /// A `BTreeMap` that maps `AccountAsset`s to `Decimal` balances. + pub balances: BTreeMap, + /// The last block number that was processed by validator. + pub last_processed_block_number: BlockNumber, + /// State change id + pub state_change_id: u64, +} + +impl ObCheckpointRaw { + pub fn new( + snapshot_id: u64, + balances: BTreeMap, + last_processed_block_number: BlockNumber, + state_change_id: u64, + ) -> Self { + Self { snapshot_id, balances, last_processed_block_number, state_change_id } + } + + #[cfg(feature = "std")] + pub fn to_checkpoint(&self) -> ObCheckpoint { + ObCheckpoint { + snapshot_id: self.snapshot_id, + balances: self.balances.clone(), + last_processed_block_number: self.last_processed_block_number, + state_change_id: self.state_change_id, + } + } +} + +pub enum OrderbookWorkerStatus { + Idle, + InProgress, + NotStarted, +} + +impl OrderbookWorkerStatus { + pub fn is_idle(&self) -> bool { + match self { + OrderbookWorkerStatus::Idle => true, + _ => false, + } + } +} diff --git a/primitives/orderbook/src/recovery.rs b/primitives/orderbook/src/recovery.rs index abd198cc5..396f2f8e8 100644 --- a/primitives/orderbook/src/recovery.rs +++ b/primitives/orderbook/src/recovery.rs @@ -43,3 +43,17 @@ pub struct ObRecoveryState { /// worker nonce pub worker_nonce: u64, } + +#[serde_as] +#[derive(Clone, Debug, Encode, Decode, Default, serde::Serialize, serde::Deserialize, TypeInfo)] +pub struct ObCheckpoint { + /// The snapshot ID of the order book recovery state. + pub snapshot_id: u64, + /// A `BTreeMap` that maps `AccountAsset`s to `Decimal` balances. + #[serde_as(as = "JsonString>")] + pub balances: BTreeMap, + /// The last block number that was processed by validator. + pub last_processed_block_number: BlockNumber, + /// State change id + pub state_change_id: u64, +} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 2d9f41069..3776364b5 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -90,6 +90,7 @@ orml-vesting = { workspace = true, default-features = false } # Local Dependecies polkadex-primitives = { workspace = true, default-features = false } +orderbook-primitives = { path = "../primitives/orderbook", default-features = false } pdex-migration = { path = "../pallets/pdex-migration", default-features = false } # Orderbook @@ -186,6 +187,7 @@ std = [ "thea-executor/std", "frame-try-runtime?/std", "thea-message-handler?/std", + "orderbook-primitives/std" ] runtime-benchmarks = [ #theirs diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4e5336ab3..ec5577470 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1504,6 +1504,7 @@ pub type Executive = frame_executive::Executive< >; use crate::sp_api_hidden_includes_construct_runtime::hidden_include::traits::fungible::Inspect; +use orderbook_primitives::ObCheckpointRaw; impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { @@ -1574,6 +1575,7 @@ impl_runtime_apis! { impl pallet_ocex_runtime_api::PolkadexOcexRuntimeApi for Runtime { fn get_ob_recover_state() -> Result, DispatchError> { Ok(OCEX::get_ob_recover_state()?.encode()) } fn get_balance(from: AccountId, of: AssetId) -> Result { OCEX::get_balance(from, of) } + fn fetch_checkpoint() -> Result { OCEX::fetch_checkpoint() } } impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { From 9978d15b148215b5ceaf6f42fa281290c79b6abf Mon Sep 17 00:00:00 2001 From: zktony Date: Fri, 25 Aug 2023 19:17:08 +0530 Subject: [PATCH 58/91] Fixed formatting --- Cargo.lock | 2 - node/Cargo.toml | 2 - node/src/main.rs | 2 +- node/src/rpc.rs | 57 ++------------------------ pallets/ocex/rpc/src/lib.rs | 21 +++------- pallets/ocex/src/checkpoint_handler.rs | 2 +- pallets/ocex/src/lib.rs | 4 +- primitives/orderbook/src/lib.rs | 4 +- 8 files changed, 16 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c984c171f..2d6b02027 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6015,7 +6015,6 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc", "parity-scale-codec", - "parking_lot 0.12.1", "polkadex-client", "polkadex-primitives", "rpc-assets", @@ -6058,7 +6057,6 @@ dependencies = [ "sp-inherents", "sp-keyring", "sp-keystore", - "sp-offchain", "sp-runtime", "sp-timestamp", "sp-tracing", diff --git a/node/Cargo.toml b/node/Cargo.toml index 0fea04b21..55a69856c 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -86,8 +86,6 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkad sp-transaction-storage-proof = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } frame-try-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43", optional = true } try-runtime-cli = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43", optional = true } -sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" } -parking_lot = "0.12.1" ## Force 0.9.2 as snow release to fix the compilation. diff --git a/node/src/main.rs b/node/src/main.rs index 4ea6eec3c..79c595f9c 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//#![deny(unused_crate_dependencies)] +#![deny(unused_crate_dependencies)] //! Substrate Node Template CLI library. #![warn(missing_docs)] mod chain_spec; diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 3c014c4c6..b965dd910 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -30,14 +30,10 @@ #![warn(missing_docs)] -use self::error::Error; -use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError, RpcResult}, - RpcModule, -}; +use jsonrpsee::RpcModule; use pallet_ocex_rpc::PolkadexOcexRpc; use pallet_rewards_rpc::PolkadexRewardsRpc; -use parking_lot::RwLock; + use polkadex_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index}; use rpc_assets::{PolkadexAssetHandlerRpc, PolkadexAssetHandlerRpcApiServer}; use sc_client_api::{AuxStore, BlockchainEvents}; @@ -45,7 +41,7 @@ use sc_consensus_babe::BabeWorkerHandle; use sc_consensus_grandpa::{ FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState, }; -use sc_rpc::{offchain::OffchainApiServer, SubscriptionTaskExecutor}; +use sc_rpc::SubscriptionTaskExecutor; /// Re-export the API for backward compatibility. pub use sc_rpc_api::offchain::*; pub use sc_rpc_api::DenyUnsafe; @@ -55,10 +51,7 @@ use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_consensus::SelectChain; use sp_consensus_babe::BabeApi; -use sp_core::{ - offchain::{OffchainStorage, StorageKind}, - Bytes, -}; + use sp_keystore::KeystorePtr; use std::sync::Arc; @@ -189,47 +182,5 @@ where .into_rpc(), )?; io.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?; - //io.merge(Offchain::new(backend.offchain_storage().ok_or_else(|| "Backend doesn't provide an - // offchain storage")?, deny_unsafe).into_rpc())?; Ok(io) } - -/// Offchain API -#[derive(Debug)] -pub struct Offchain { - /// Offchain storage - storage: Arc>, - deny_unsafe: DenyUnsafe, -} - -impl Offchain { - /// Create new instance of Offchain API. - pub fn new(storage: T, deny_unsafe: DenyUnsafe) -> Self { - Offchain { storage: Arc::new(RwLock::new(storage)), deny_unsafe } - } -} - -#[async_trait] -impl OffchainApiServer for Offchain { - fn set_local_storage(&self, kind: StorageKind, key: Bytes, value: Bytes) -> RpcResult<()> { - self.deny_unsafe.check_if_safe()?; - - let prefix = match kind { - StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, - StorageKind::LOCAL => return Err(JsonRpseeError::from(Error::UnavailableStorageKind)), - }; - self.storage.write().set(prefix, &key, &value); - Ok(()) - } - - fn get_local_storage(&self, kind: StorageKind, key: Bytes) -> RpcResult> { - self.deny_unsafe.check_if_safe()?; - - let prefix = match kind { - StorageKind::PERSISTENT => sp_offchain::STORAGE_PREFIX, - StorageKind::LOCAL => return Err(JsonRpseeError::from(Error::UnavailableStorageKind)), - }; - - Ok(self.storage.read().get(prefix, &key).map(Into::into)) - } -} diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 9d62f68d0..0e3552e35 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -26,29 +26,20 @@ use jsonrpsee::{ proc_macros::rpc, types::error::{CallError, ErrorObject}, }; -use orderbook_primitives::{ - recovery::{ObCheckpoint, ObRecoveryState}, - ObCheckpointRaw, -}; +use orderbook_primitives::recovery::{ObCheckpoint, ObRecoveryState}; pub use pallet_ocex_runtime_api::PolkadexOcexRuntimeApi; use parity_scale_codec::{Codec, Decode}; use parking_lot::RwLock; -use polkadex_primitives::{AccountId, AssetId, Balance, Block, BlockNumber, Hash, Index}; -use sc_rpc::offchain::OffchainApiServer; +use polkadex_primitives::AssetId; + +use crate::offchain::OffchainStorageAdapter; use sc_rpc_api::offchain::error::Error; pub use sc_rpc_api::DenyUnsafe; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; -use sp_core::{ - offchain::{OffchainStorage, StorageKind}, - Bytes, Hasher, -}; -use sp_runtime::{ - offchain::storage::StorageValueRef, - traits::{BlakeTwo256, Block as BlockT}, -}; +use sp_core::offchain::OffchainStorage; +use sp_runtime::traits::Block as BlockT; use std::sync::Arc; -use crate::offchain::OffchainStorageAdapter; const RUNTIME_ERROR: i32 = 1; pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status"; diff --git a/pallets/ocex/src/checkpoint_handler.rs b/pallets/ocex/src/checkpoint_handler.rs index 80406c6f6..cae8cb59f 100644 --- a/pallets/ocex/src/checkpoint_handler.rs +++ b/pallets/ocex/src/checkpoint_handler.rs @@ -21,7 +21,7 @@ impl CheckpointHandler { } fn set_checkpoint_flag(flag: bool) { - let mut s_w = StorageValueRef::persistent(&CHECKPOINT_FLAG); + let s_w = StorageValueRef::persistent(&CHECKPOINT_FLAG); s_w.set(&flag); } } diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 23002c443..083884d0a 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -325,7 +325,7 @@ pub mod pallet { /// Dispute Interval not set DisputeIntervalNotSet, /// Worker not Idle - WorkerNotIdle + WorkerNotIdle, } #[pallet::hooks] @@ -1331,7 +1331,7 @@ pub mod pallet { let main = Self::transform_account(account.0)?; // Check if worker is active or not if !Self::get_worker_status().is_idle() { - return Err(Error::::WorkerNotIdle.into()); + return Err(Error::::WorkerNotIdle.into()) } let b = Self::get_offchain_balance(&main)?; for (asset, balance) in b.into_iter() { diff --git a/primitives/orderbook/src/lib.rs b/primitives/orderbook/src/lib.rs index 243b1fc7c..c07b743b2 100644 --- a/primitives/orderbook/src/lib.rs +++ b/primitives/orderbook/src/lib.rs @@ -24,6 +24,8 @@ #![feature(int_roundings)] #![cfg_attr(not(feature = "std"), no_std)] +#[cfg(feature = "std")] +use crate::recovery::ObCheckpoint; use crate::types::AccountAsset; use parity_scale_codec::{Codec, Decode, Encode}; use polkadex_primitives::{withdrawal::Withdrawal, AssetId, BlockNumber}; @@ -33,8 +35,6 @@ use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_core::H256; use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; -#[cfg(feature = "std")] -use crate::recovery::ObCheckpoint; pub mod constants; pub mod types; From 3ad363fb7e02f6fa433ea50944bcf269c6ac433c Mon Sep 17 00:00:00 2001 From: Gautham Date: Mon, 28 Aug 2023 12:15:43 +0300 Subject: [PATCH 59/91] Implement a common mutex api for offchain storage --- Cargo.lock | 1711 ++++++++++++++++++++--------------- pallets/ocex/rpc/src/lib.rs | 11 +- pallets/ocex/src/rpc.rs | 46 +- 3 files changed, 1024 insertions(+), 744 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f88b80325..07c85b714 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,16 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli", + "gimli 0.27.3", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli 0.28.0", ] [[package]] @@ -163,18 +172,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "aho-corasick" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" dependencies = [ "memchr", ] @@ -205,24 +205,23 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle-parse" @@ -244,9 +243,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -254,9 +253,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "approx" @@ -316,7 +315,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.28", ] [[package]] @@ -332,7 +331,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.28", ] [[package]] @@ -372,9 +371,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -395,7 +394,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.20", + "rustix 0.37.23", "slab", "socket2 0.4.9", "waker-fn", @@ -403,9 +402,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ "event-listener", ] @@ -418,31 +417,31 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "asynchronous-codec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" dependencies = [ "bytes", "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", ] [[package]] @@ -470,16 +469,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ - "addr2line", + "addr2line 0.21.0", "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object", + "miniz_oxide", + "object 0.32.0", "rustc-demangle", ] @@ -509,9 +508,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -531,7 +530,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "hash-db", "log", @@ -558,13 +557,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.9", + "prettyplease 0.2.12", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -575,9 +574,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbe3c979c178231552ecba20214a8272df4e09f232a87aef4320cf06539aded" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bitvec" @@ -608,7 +607,7 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq", + "constant_time_eq 0.2.6", ] [[package]] @@ -619,20 +618,20 @@ checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq", + "constant_time_eq 0.2.6", ] [[package]] name = "blake3" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" dependencies = [ "arrayref", "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq", + "constant_time_eq 0.3.0", ] [[package]] @@ -690,6 +689,51 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive", + "hashbrown 0.13.2", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bounded-collections" version = "0.1.8" @@ -710,9 +754,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", "serde", @@ -745,6 +789,28 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +[[package]] +name = "bytecheck" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bytemuck" version = "1.13.1" @@ -776,18 +842,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" dependencies = [ "serde", ] @@ -800,7 +866,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.17", + "semver 1.0.18", "serde", "serde_json", "thiserror", @@ -808,11 +874,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -837,9 +904,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.3" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "215c0072ecc28f92eeb0eea38ba63ddfcb65c2828c46311d646f1a3ff5f9841c" +checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9" dependencies = [ "smallvec", ] @@ -975,9 +1042,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.5" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2686c4115cb0810d9a984776e197823d08ec94f176549a89a9efded477c456dc" +checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" dependencies = [ "clap_builder", "clap_derive", @@ -986,34 +1053,33 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.5" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae" +checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" dependencies = [ "anstream", "anstyle", - "bitflags 1.3.2", "clap_lex", "strsim 0.10.0", ] [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "codespan-reporting" @@ -1066,9 +1132,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "constant_time_eq" @@ -1076,6 +1142,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + [[package]] name = "core-foundation" version = "0.9.3" @@ -1112,9 +1184,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -1140,7 +1212,7 @@ dependencies = [ "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli", + "gimli 0.27.3", "hashbrown 0.13.2", "log", "regalloc2", @@ -1288,7 +1360,7 @@ dependencies = [ name = "crowdloan-verifier" version = "0.1.0" dependencies = [ - "clap 4.3.5", + "clap 4.4.0", "csv", "pallet-rewards", "polkadex-primitives", @@ -1378,16 +1450,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "ctr" version = "0.8.0" @@ -1434,23 +1496,37 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-rc.1" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +checksum = "f711ade317dd348950a9910f81c5947e3d8907ebd2b83f76203ff1807e6a2bc2" dependencies = [ "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", "fiat-crypto", - "packed_simd_2", "platforms 3.0.2", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + [[package]] name = "cxx" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88abab2f5abbe4c56e8f1fb431b784d710b709888f35755a160e62e33fe38e8" +checksum = "28403c86fc49e3401fdf45499ba37fad6493d9329449d6449d7f0e10f4654d28" dependencies = [ "cc", "cxxbridge-flags", @@ -1460,9 +1536,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0c11acd0e63bae27dcd2afced407063312771212b7a823b4fd72d633be30fb" +checksum = "78da94fef01786dc3e0c76eafcd187abcaa9972c78e05ff4041e24fdf059c285" dependencies = [ "cc", "codespan-reporting", @@ -1470,24 +1546,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "cxxbridge-flags" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3816ed957c008ccd4728485511e3d9aaf7db419aa321e3d2c5a2f3411e36c8" +checksum = "e2a6f5e1dfb4b34292ad4ea1facbfdaa1824705b231610087b00b17008641809" [[package]] name = "cxxbridge-macro" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26acccf6f445af85ea056362561a24ef56cdc15fcc685f03aec50b9c702cb6d" +checksum = "50c49547d73ba8dcfd4ad7325d64c6d5391ff4224d498fc39a6f3f49825a530d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -1502,12 +1578,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.1" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ - "darling_core 0.20.1", - "darling_macro 0.20.1", + "darling_core 0.20.3", + "darling_macro 0.20.3", ] [[package]] @@ -1526,16 +1602,16 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.1" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -1551,13 +1627,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.1" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ - "darling_core 0.20.1", + "darling_core 0.20.3", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -1599,9 +1675,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", "zeroize", @@ -1635,6 +1711,15 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +dependencies = [ + "serde", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1790,7 +1875,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -1807,9 +1892,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" @@ -1834,9 +1919,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "ecdsa" @@ -1852,11 +1937,11 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.7" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ - "der 0.7.6", + "der 0.7.8", "digest 0.10.7", "elliptic-curve 0.13.5", "rfc6979 0.4.0", @@ -1873,6 +1958,16 @@ dependencies = [ "signature 1.6.4", ] +[[package]] +name = "ed25519" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +dependencies = [ + "pkcs8 0.10.2", + "signature 2.1.0", +] + [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -1880,13 +1975,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", - "ed25519", - "rand 0.7.3", - "serde", + "ed25519 1.5.3", "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek 4.0.0", + "ed25519 2.2.2", + "rand_core 0.6.4", + "serde", + "sha2 0.10.7", + "zeroize", +] + [[package]] name = "ed25519-zebra" version = "3.1.0" @@ -1903,9 +2010,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" @@ -1943,7 +2050,7 @@ dependencies = [ "group 0.13.0", "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1 0.7.2", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -1983,7 +2090,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -2005,11 +2112,17 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", @@ -2075,6 +2188,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + [[package]] name = "fdlimit" version = "0.2.1" @@ -2122,13 +2241,13 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "windows-sys 0.48.0", ] @@ -2168,13 +2287,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2195,7 +2314,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", ] @@ -2218,7 +2337,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-support-procedural", @@ -2243,12 +2362,12 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "Inflector", "array-bytes 4.2.0", "chrono", - "clap 4.3.5", + "clap 4.4.0", "comfy-table", "frame-benchmarking", "frame-support", @@ -2290,18 +2409,18 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2318,7 +2437,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -2347,7 +2466,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-recursion", "futures 0.3.28", @@ -2368,7 +2487,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "bitflags 1.3.2", "environmental", @@ -2402,7 +2521,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "Inflector", "cfg-expr", @@ -2412,35 +2531,35 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support-procedural-tools-derive", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "cfg-if", "frame-support", @@ -2459,7 +2578,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -2474,7 +2593,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "sp-api", @@ -2483,7 +2602,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "parity-scale-codec", @@ -2510,11 +2629,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" +checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.37.20", + "rustix 0.38.9", "windows-sys 0.48.0", ] @@ -2585,12 +2704,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "waker-fn", ] @@ -2602,7 +2721,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -2648,7 +2767,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "pin-utils", "slab", ] @@ -2741,10 +2860,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 1.9.3", "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + [[package]] name = "glob" version = "0.3.1" @@ -2753,11 +2878,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", "fnv", "log", @@ -2788,9 +2913,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -2798,7 +2923,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -2852,6 +2977,12 @@ dependencies = [ "ahash 0.8.3", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.3.3" @@ -2878,18 +3009,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -2988,14 +3110,14 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", ] [[package]] name = "http-range-header" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" @@ -3005,9 +3127,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -3017,9 +3139,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.26" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -3031,7 +3153,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "socket2 0.4.9", "tokio", "tower-service", @@ -3051,8 +3173,24 @@ dependencies = [ "rustls 0.20.8", "rustls-native-certs", "tokio", - "tokio-rustls", - "webpki-roots", + "tokio-rustls 0.23.4", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +dependencies = [ + "futures-util", + "http", + "hyper", + "log", + "rustls 0.21.6", + "rustls-native-certs", + "tokio", + "tokio-rustls 0.24.1", + "webpki-roots 0.23.1", ] [[package]] @@ -3174,11 +3312,21 @@ dependencies = [ "serde", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + [[package]] name = "indicatif" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057" +checksum = "0b297dc40733f23a0e52728a58fa9489a5b7638a324932de16b41adc3ef80730" dependencies = [ "console", "instant", @@ -3239,7 +3387,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys 0.48.0", ] @@ -3264,19 +3412,18 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.7.2" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix 0.37.20", + "hermit-abi 0.3.2", + "rustix 0.38.9", "windows-sys 0.48.0", ] @@ -3291,9 +3438,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" @@ -3315,9 +3462,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" +checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", @@ -3330,9 +3477,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb" +checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" dependencies = [ "futures-util", "http", @@ -3343,17 +3490,17 @@ dependencies = [ "soketto", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.25.2", ] [[package]] name = "jsonrpsee-core" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" +checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", "arrayvec 0.7.4", @@ -3379,13 +3526,13 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc345b0a43c6bc49b947ebeb936e886a419ee3d894421790c969cc56040542ad" +checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" dependencies = [ "async-trait", "hyper", - "hyper-rustls", + "hyper-rustls 0.24.1", "jsonrpsee-core", "jsonrpsee-types", "rustc-hash", @@ -3398,12 +3545,12 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa6da1e4199c10d7b1d0a6e5e8bd8e55f351163b6f4b3cbb044672a69bd4c1c" +checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" dependencies = [ "heck 0.4.1", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -3411,9 +3558,9 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb69dad85df79527c019659a992498d03f8495390496da2f07e6c24c2b356fc" +checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" dependencies = [ "futures-channel", "futures-util", @@ -3433,9 +3580,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c" +checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" dependencies = [ "anyhow", "beef", @@ -3447,9 +3594,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b83daeecfc6517cfe210df24e570fb06213533dfb990318fae781f4c7119dd9" +checksum = "4e1b3975ed5d73f456478681a417128597acd6a2487855fdb7b4a3d4d195bf5e" dependencies = [ "http", "jsonrpsee-client-transport", @@ -3464,7 +3611,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.7", + "ecdsa 0.16.8", "elliptic-curve 0.13.5", "once_cell", "sha2 0.10.7", @@ -3529,9 +3676,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.146" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libloading" @@ -3543,12 +3690,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - [[package]] name = "libm" version = "0.2.7" @@ -3669,7 +3810,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm", "log", - "lru 0.10.0", + "lru 0.10.1", "quick-protobuf", "quick-protobuf-codec", "smallvec", @@ -3679,12 +3820,12 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek", + "ed25519-dalek 2.0.0", "log", "multiaddr", "multihash 0.17.0", @@ -3964,7 +4105,7 @@ dependencies = [ "rw-stream-sink", "soketto", "url", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -4045,9 +4186,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.9" +version = "1.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" dependencies = [ "cc", "pkg-config", @@ -4056,9 +4197,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" dependencies = [ "cc", ] @@ -4080,9 +4221,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" dependencies = [ "nalgebra", ] @@ -4099,6 +4240,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + [[package]] name = "liquidity" version = "1.1.0" @@ -4144,9 +4291,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" @@ -4159,9 +4306,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" +checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" dependencies = [ "hashbrown 0.13.2", ] @@ -4222,7 +4369,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -4262,7 +4409,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.20", + "rustix 0.37.23", ] [[package]] @@ -4334,15 +4481,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -4456,7 +4594,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro-error", "proc-macro2", "quote", @@ -4486,9 +4624,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.2" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" +checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" dependencies = [ "approx", "matrixmultiply", @@ -4502,9 +4640,9 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" dependencies = [ "proc-macro2", "quote", @@ -4701,9 +4839,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -4712,9 +4850,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ "num-traits", ] @@ -4753,20 +4891,20 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.2", "libc", ] @@ -4784,7 +4922,16 @@ checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", "hashbrown 0.13.2", - "indexmap", + "indexmap 1.9.3", + "memchr", +] + +[[package]] +name = "object" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +dependencies = [ "memchr", ] @@ -4869,15 +5016,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "output_vt100" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" -dependencies = [ - "winapi", -] - [[package]] name = "p256" version = "0.11.1" @@ -4900,20 +5038,10 @@ dependencies = [ "sha2 0.10.7", ] -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if", - "libm 0.1.4", -] - [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -4928,7 +5056,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -4944,7 +5072,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -4958,7 +5086,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -4982,7 +5110,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -4997,7 +5125,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -5016,7 +5144,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "binary-merkle-tree", @@ -5040,7 +5168,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5058,7 +5186,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5077,7 +5205,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5094,7 +5222,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5112,7 +5240,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5135,7 +5263,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5148,7 +5276,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5166,7 +5294,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5189,7 +5317,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5205,7 +5333,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5225,7 +5353,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5242,7 +5370,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5259,7 +5387,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5276,7 +5404,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5353,7 +5481,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -5370,7 +5498,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5387,7 +5515,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5402,7 +5530,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5464,7 +5592,7 @@ dependencies = [ [[package]] name = "pallet-root-testing" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -5479,7 +5607,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5496,7 +5624,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -5517,7 +5645,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5539,18 +5667,18 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5565,7 +5693,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5583,7 +5711,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-support", "frame-system", @@ -5599,7 +5727,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -5615,7 +5743,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5627,7 +5755,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5644,7 +5772,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-benchmarking", "frame-support", @@ -5659,9 +5787,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" +checksum = "78f19d20a0d2cc52327a88d131fa1c4ea81ea4a04714aedcfeca2dd410049cf8" dependencies = [ "blake2", "crc32fast", @@ -5679,9 +5807,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.1" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -5694,11 +5822,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.1" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" +checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -5767,7 +5895,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -5778,9 +5906,9 @@ checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" @@ -5848,9 +5976,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.6.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16833386b02953ca926d19f64af613b9bf742c48dcd5e09b32fbfc9740bf84e2" +checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" dependencies = [ "thiserror", "ucd-trie", @@ -5858,9 +5986,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.6.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7763190f9406839f99e5197afee8c9e759969f7dbfa40ad3b8dbee8757b745b5" +checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" dependencies = [ "pest", "pest_generator", @@ -5868,22 +5996,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.6.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "249061b22e99973da1f5f5f1410284419e283bb60b79255bf5f42a94b66a2e00" +checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "pest_meta" -version = "2.6.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457c310cfc9cf3f22bc58901cc7f0d3410ac5d6298e432a4f9a6138565cb6df6" +checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" dependencies = [ "once_cell", "pest", @@ -5892,32 +6020,32 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.0.0", ] [[package]] name = "pin-project" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -5928,9 +6056,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -5954,7 +6082,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.6", + "der 0.7.8", "spki 0.7.2", ] @@ -5989,7 +6117,7 @@ dependencies = [ name = "polkadex-node" version = "5.3.0" dependencies = [ - "clap 4.3.5", + "clap 4.4.0", "frame-benchmarking-cli", "frame-support", "frame-system", @@ -6092,7 +6220,7 @@ dependencies = [ "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "windows-sys 0.48.0", ] @@ -6133,9 +6261,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.3.3" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" +checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" [[package]] name = "ppv-lite86" @@ -6175,13 +6303,11 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ - "ctor", "diff", - "output_vt100", "yansi", ] @@ -6197,12 +6323,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" +checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" dependencies = [ "proc-macro2", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -6218,6 +6344,15 @@ dependencies = [ "uint", ] +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml 0.5.11", +] + [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -6260,7 +6395,7 @@ checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -6300,13 +6435,13 @@ dependencies = [ [[package]] name = "prometheus-client-derive-encode" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] @@ -6372,6 +6507,26 @@ dependencies = [ "cc", ] +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -6413,9 +6568,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" +checksum = "f31999cfc7927c4e212e60fd50934ab40e8e8bfd2d493d6095d2d306bc0764d9" dependencies = [ "bytes", "rand 0.8.5", @@ -6431,9 +6586,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -6560,7 +6715,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.22", + "time 0.3.28", "x509-parser 0.13.2", "yasna", ] @@ -6573,7 +6728,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.22", + "time 0.3.28", "yasna", ] @@ -6608,22 +6763,22 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.16" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.16" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -6640,13 +6795,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.4" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", - "regex-syntax 0.7.2", + "regex-automata 0.3.7", + "regex-syntax 0.7.5", ] [[package]] @@ -6658,6 +6814,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.5", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -6666,9 +6833,18 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "rend" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +dependencies = [ + "bytecheck", +] [[package]] name = "resolv-conf" @@ -6716,6 +6892,34 @@ dependencies = [ "winapi", ] +[[package]] +name = "rkyv" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +dependencies = [ + "bitvec", + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "rocksdb" version = "0.21.0" @@ -6816,15 +7020,22 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.26.1" -source = "git+https://github.com/Polkadex-Substrate/rust-decimal.git?branch=master#610096f3e5b70d58b64f4e93e8a8d50822938ac6" +version = "1.30.0" +source = "git+https://github.com/Polkadex-Substrate/rust-decimal.git?branch=master#25f084996a7c941593aa1d2d8711e8218c391563" dependencies = [ "arrayvec 0.7.4", + "borsh", + "bytecheck", + "byteorder", + "bytes", "num-traits", "parity-scale-codec", "parity-scale-codec-derive", + "rand 0.8.5", + "rkyv", "scale-info", "serde", + "serde_json", ] [[package]] @@ -6851,7 +7062,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.17", + "semver 1.0.18", ] [[package]] @@ -6865,9 +7076,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.14" +version = "0.36.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" dependencies = [ "bitflags 1.3.2", "errno", @@ -6879,9 +7090,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.20" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ "bitflags 1.3.2", "errno", @@ -6891,6 +7102,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.5", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.19.1" @@ -6916,6 +7140,18 @@ dependencies = [ "webpki 0.22.0", ] +[[package]] +name = "rustls" +version = "0.21.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" +dependencies = [ + "log", + "ring", + "rustls-webpki 0.101.4", + "sct 0.7.0", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -6930,18 +7166,38 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.3", +] + +[[package]] +name = "rustls-webpki" +version = "0.100.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" dependencies = [ - "base64 0.21.2", + "ring", + "untrusted", ] [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "rw-stream-sink" @@ -6956,15 +7212,15 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safe_arch" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" dependencies = [ "bytemuck", ] @@ -6981,7 +7237,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "log", "sp-core", @@ -6992,7 +7248,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "futures 0.3.28", @@ -7021,7 +7277,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "futures-timer", @@ -7044,7 +7300,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -7059,7 +7315,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -7078,22 +7334,22 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "chrono", - "clap 4.3.5", + "clap 4.4.0", "fdlimit", "futures 0.3.28", "libp2p-identity", @@ -7129,7 +7385,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "fnv", "futures 0.3.28", @@ -7156,7 +7412,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "hash-db", "kvdb", @@ -7182,7 +7438,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "futures 0.3.28", @@ -7207,7 +7463,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "fork-tree", @@ -7243,7 +7499,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "jsonrpsee", @@ -7265,7 +7521,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "fork-tree", "parity-scale-codec", @@ -7278,7 +7534,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "ahash 0.8.3", "array-bytes 4.2.0", @@ -7318,7 +7574,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "finality-grandpa", "futures 0.3.28", @@ -7338,7 +7594,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "futures 0.3.28", @@ -7361,7 +7617,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "lru 0.8.1", "parity-scale-codec", @@ -7383,7 +7639,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -7395,14 +7651,14 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "anyhow", "cfg-if", "libc", "log", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -7413,7 +7669,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "ansi_term", "futures 0.3.28", @@ -7429,7 +7685,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "parking_lot 0.12.1", @@ -7443,7 +7699,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -7488,7 +7744,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-channel", "cid", @@ -7509,7 +7765,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -7537,7 +7793,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "ahash 0.8.3", "futures 0.3.28", @@ -7556,7 +7812,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -7579,7 +7835,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -7614,7 +7870,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "futures 0.3.28", @@ -7634,7 +7890,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "bytes", @@ -7642,7 +7898,7 @@ dependencies = [ "futures 0.3.28", "futures-timer", "hyper", - "hyper-rustls", + "hyper-rustls 0.23.2", "libp2p", "num_cpus", "once_cell", @@ -7665,7 +7921,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "libp2p-identity", @@ -7681,7 +7937,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -7690,7 +7946,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "jsonrpsee", @@ -7721,7 +7977,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -7740,7 +7996,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "http", "jsonrpsee", @@ -7755,7 +8011,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "futures 0.3.28", @@ -7781,7 +8037,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "directories", @@ -7847,7 +8103,7 @@ dependencies = [ [[package]] name = "sc-service-test" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -7885,7 +8141,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "log", "parity-scale-codec", @@ -7896,9 +8152,9 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "clap 4.3.5", + "clap 4.4.0", "fs4", "futures 0.3.28", "log", @@ -7912,7 +8168,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -7931,7 +8187,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "libc", @@ -7950,7 +8206,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "chrono", "futures 0.3.28", @@ -7969,7 +8225,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "ansi_term", "atty", @@ -8000,18 +8256,18 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "futures 0.3.28", @@ -8038,7 +8294,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "futures 0.3.28", @@ -8052,7 +8308,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-channel", "futures 0.3.28", @@ -8066,9 +8322,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" dependencies = [ "bitvec", "cfg-if", @@ -8080,11 +8336,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -8092,11 +8348,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -8130,15 +8386,15 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scratch" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" @@ -8172,6 +8428,12 @@ dependencies = [ "url", ] +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + [[package]] name = "sec1" version = "0.3.0" @@ -8188,12 +8450,12 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct 0.2.0", - "der 0.7.6", + "der 0.7.8", "generic-array 0.14.7", "pkcs8 0.10.2", "subtle", @@ -8229,9 +8491,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -8242,9 +8504,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -8261,9 +8523,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" dependencies = [ "serde", ] @@ -8276,29 +8538,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.173" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91f70896d6720bc714a4a57d22fc91f1db634680e65c8efe13323f1fa38d53f" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.173" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6250dde8342e0232232be9ca3db7aa40aceb5a3e5dd9bddbc00d99a007cde49" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "serde_json" -version = "1.0.103" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -8307,9 +8569,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -8323,11 +8585,11 @@ dependencies = [ "base64 0.13.1", "chrono", "hex", - "indexmap", + "indexmap 1.9.3", "serde", "serde_json", "serde_with_macros", - "time 0.3.22", + "time 0.3.28", ] [[package]] @@ -8336,10 +8598,10 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ - "darling 0.20.1", + "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -8469,17 +8731,23 @@ dependencies = [ "wide", ] +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -8492,9 +8760,9 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "snap" @@ -8504,14 +8772,14 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" +checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" dependencies = [ "aes-gcm 0.9.4", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", + "curve25519-dalek 4.0.0", "rand_core 0.6.4", "ring", "rustc_version", @@ -8559,7 +8827,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "hash-db", "log", @@ -8579,21 +8847,21 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "Inflector", "blake2", "expander", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "scale-info", @@ -8606,7 +8874,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "integer-sqrt", "num-traits", @@ -8620,7 +8888,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "scale-info", @@ -8633,7 +8901,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "sp-api", @@ -8645,7 +8913,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "log", @@ -8663,7 +8931,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "futures 0.3.28", @@ -8678,7 +8946,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "parity-scale-codec", @@ -8696,7 +8964,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "parity-scale-codec", @@ -8717,7 +8985,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "lazy_static", "parity-scale-codec", @@ -8736,7 +9004,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "finality-grandpa", "log", @@ -8754,7 +9022,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "scale-info", @@ -8766,7 +9034,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "bitflags 1.3.2", @@ -8810,7 +9078,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "blake2b_simd", "byteorder", @@ -8824,18 +9092,18 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -8844,17 +9112,17 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "environmental", "parity-scale-codec", @@ -8865,7 +9133,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -8880,11 +9148,11 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "bytes", - "ed25519", - "ed25519-dalek", + "ed25519 1.5.3", + "ed25519-dalek 1.0.1", "futures 0.3.28", "libsecp256k1", "log", @@ -8906,7 +9174,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "lazy_static", "sp-core", @@ -8917,7 +9185,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "parity-scale-codec", @@ -8931,16 +9199,16 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "thiserror", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -8951,7 +9219,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -8969,7 +9237,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "scale-info", @@ -8983,7 +9251,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "sp-api", "sp-core", @@ -8993,7 +9261,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "backtrace", "lazy_static", @@ -9003,7 +9271,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "rustc-hash", "serde", @@ -9013,7 +9281,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "either", "hash256-std-hasher", @@ -9035,7 +9303,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -9053,19 +9321,19 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "Inflector", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "scale-info", @@ -9079,7 +9347,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "scale-info", @@ -9092,7 +9360,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "hash-db", "log", @@ -9112,7 +9380,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "log", "parity-scale-codec", @@ -9130,12 +9398,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9148,7 +9416,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "futures-timer", @@ -9163,7 +9431,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "sp-std", @@ -9175,7 +9443,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "sp-api", "sp-runtime", @@ -9184,7 +9452,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "log", @@ -9200,7 +9468,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "ahash 0.8.3", "hash-db", @@ -9223,7 +9491,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9240,18 +9508,18 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -9265,7 +9533,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "parity-scale-codec", "scale-info", @@ -9311,14 +9579,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.6", + "der 0.7.8", ] [[package]] name = "ss58-registry" -version = "1.40.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" +checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" dependencies = [ "Inflector", "num-format", @@ -9471,7 +9739,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.28", @@ -9490,7 +9758,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "hyper", "log", @@ -9502,7 +9770,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", "jsonrpsee", @@ -9515,7 +9783,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9541,7 +9809,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "array-bytes 6.1.0", "frame-executive", @@ -9589,7 +9857,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "futures 0.3.28", "parity-scale-codec", @@ -9609,7 +9877,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "ansi_term", "build-helper", @@ -9618,7 +9886,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.4", + "toml 0.7.6", "walkdir", "wasm-opt", ] @@ -9651,9 +9919,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.26" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -9701,21 +9969,20 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.8" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "tempfile" -version = "3.6.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "autocfg", "cfg-if", - "fastrand", + "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix 0.37.20", + "rustix 0.38.9", "windows-sys 0.48.0", ] @@ -9845,22 +10112,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -9890,9 +10157,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.3+5.3.0-patched" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ "cc", "libc", @@ -9911,10 +10178,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.22" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ + "deranged", "itoa", "serde", "time-core", @@ -9929,9 +10197,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -9982,20 +10250,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2 0.4.9", + "socket2 0.5.3", "tokio-macros", "windows-sys 0.48.0", ] @@ -10008,7 +10275,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -10033,6 +10300,16 @@ dependencies = [ "webpki 0.22.0", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.6", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.14" @@ -10040,7 +10317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tokio", "tokio-util", ] @@ -10055,7 +10332,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tokio", "tracing", ] @@ -10071,9 +10348,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -10083,20 +10360,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -10116,18 +10393,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8bd22a874a2d0b70452d5597b12c537331d49060824a95f49f108994f94aa4c" +checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" dependencies = [ - "bitflags 2.3.2", + "bitflags 2.4.0", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tower-layer", "tower-service", ] @@ -10152,20 +10429,20 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8803eee176538f94ae9a14b55b2804eb7e1441f8210b1c31290b3bccdccff73b" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -10309,10 +10586,10 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#a2037bdedef0aa812017efee1d0fa63d4f5fcbae" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", - "clap 4.3.5", + "clap 4.4.0", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -10340,7 +10617,7 @@ dependencies = [ "sp-version", "sp-weights", "substrate-rpc-client", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] @@ -10388,9 +10665,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -10412,9 +10689,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -10500,9 +10777,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.4" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa2982af2eec27de306107c027578ff7f423d65f7250e40ce0fea8f45248b81" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ "getrandom 0.2.10", ] @@ -10610,7 +10887,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -10644,7 +10921,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -10746,7 +11023,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" dependencies = [ "downcast-rs", - "libm 0.2.7", + "libm", "memory_units", "num-rational", "num-traits", @@ -10758,7 +11035,7 @@ version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "url", ] @@ -10771,10 +11048,10 @@ dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", - "object", + "object 0.30.4", "once_cell", "paste", "psm", @@ -10806,12 +11083,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.2", + "base64 0.21.3", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.14", + "rustix 0.36.15", "serde", "sha2 0.10.7", "toml 0.5.11", @@ -10831,9 +11108,9 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.27.3", "log", - "object", + "object 0.30.4", "target-lexicon", "thiserror", "wasmparser", @@ -10850,8 +11127,8 @@ dependencies = [ "anyhow", "cranelift-codegen", "cranelift-native", - "gimli", - "object", + "gimli 0.27.3", + "object 0.30.4", "target-lexicon", "wasmtime-environ", ] @@ -10864,10 +11141,10 @@ checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" dependencies = [ "anyhow", "cranelift-entity", - "gimli", - "indexmap", + "gimli 0.27.3", + "indexmap 1.9.3", "log", - "object", + "object 0.30.4", "serde", "target-lexicon", "thiserror", @@ -10881,14 +11158,14 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line", + "addr2line 0.19.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli", + "gimli 0.27.3", "log", - "object", + "object 0.30.4", "rustc-demangle", "serde", "target-lexicon", @@ -10905,9 +11182,9 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object", + "object 0.30.4", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", ] [[package]] @@ -10930,7 +11207,7 @@ dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", "mach", @@ -10938,7 +11215,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.14", + "rustix 0.36.15", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -10996,6 +11273,21 @@ dependencies = [ "webpki 0.22.0", ] +[[package]] +name = "webpki-roots" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" +dependencies = [ + "rustls-webpki 0.100.2", +] + +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + [[package]] name = "webrtc" version = "0.6.0" @@ -11022,7 +11314,7 @@ dependencies = [ "sha2 0.10.7", "stun", "thiserror", - "time 0.3.22", + "time 0.3.28", "tokio", "turn", "url", @@ -11054,9 +11346,9 @@ dependencies = [ [[package]] name = "webrtc-dtls" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" +checksum = "c4a00f4242f2db33307347bd5be53263c52a0331c96c14292118c9a6bb48d267" dependencies = [ "aes 0.6.0", "aes-gcm 0.10.2", @@ -11071,12 +11363,11 @@ dependencies = [ "hkdf", "hmac 0.12.1", "log", - "oid-registry 0.6.1", "p256", "p384", "rand 0.8.5", "rand_core 0.6.4", - "rcgen 0.9.3", + "rcgen 0.10.0", "ring", "rustls 0.19.1", "sec1 0.3.0", @@ -11089,7 +11380,7 @@ dependencies = [ "tokio", "webpki 0.21.4", "webrtc-util", - "x25519-dalek 2.0.0-pre.1", + "x25519-dalek 2.0.0", "x509-parser 0.13.2", ] @@ -11218,9 +11509,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" +checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" dependencies = [ "bytemuck", "safe_arch", @@ -11282,22 +11573,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.48.5", ] [[package]] @@ -11315,7 +11591,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -11335,17 +11611,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -11356,9 +11632,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -11374,9 +11650,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -11392,9 +11668,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -11410,9 +11686,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -11428,9 +11704,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -11440,9 +11716,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -11458,15 +11734,15 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.7" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] @@ -11503,12 +11779,13 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "2.0.0-pre.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek 4.0.0", "rand_core 0.6.4", + "serde", "zeroize", ] @@ -11528,7 +11805,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.28", ] [[package]] @@ -11546,7 +11823,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.28", ] [[package]] @@ -11573,7 +11850,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -11602,7 +11879,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.22", + "time 0.3.28", ] [[package]] @@ -11622,7 +11899,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.29", ] [[package]] @@ -11636,11 +11913,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.12.3+zstd.1.5.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" dependencies = [ - "zstd-safe 6.0.5+zstd.1.5.4", + "zstd-safe 6.0.6", ] [[package]] @@ -11655,9 +11932,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.5+zstd.1.5.4" +version = "6.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" dependencies = [ "libc", "zstd-sys", diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index d9f8501fe..b688dcc5f 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -49,10 +49,7 @@ pub trait PolkadexOcexRpcApi { ) -> RpcResult; #[method(name = "ob_inventoryDeviation")] - fn calculate_inventory_deviation( - &self, - at: Option, - ) -> RpcResult; + fn calculate_inventory_deviation(&self, at: Option) -> RpcResult; } /// A structure that represents the Polkadex OCEX pallet RPC, which allows querying @@ -137,11 +134,9 @@ where None => self.client.info().best_hash, }; let runtime_api_result = - api.calculate_inventory_deviation(at) - .map_err(runtime_error_into_rpc_err)?; + api.calculate_inventory_deviation(at).map_err(runtime_error_into_rpc_err)?; let json = - serde_json::to_string(&runtime_api_result) - .map_err(runtime_error_into_rpc_err)?; + serde_json::to_string(&runtime_api_result).map_err(runtime_error_into_rpc_err)?; Ok(json) } } diff --git a/pallets/ocex/src/rpc.rs b/pallets/ocex/src/rpc.rs index 06caafd24..bb38cc281 100644 --- a/pallets/ocex/src/rpc.rs +++ b/pallets/ocex/src/rpc.rs @@ -9,30 +9,36 @@ use polkadex_primitives::{AccountId, AssetId}; use rust_decimal::Decimal; use sp_core::ByteArray; use sp_runtime::{offchain::storage::StorageValueRef, traits::BlockNumberProvider, DispatchError, Saturating, SaturatedConversion}; +use sp_runtime::offchain::storage::StorageRetrievalError; use sp_std::collections::btree_map::BTreeMap; impl Pallet { - /// Returns Some(()), if lock is acquired else, None. - pub fn acquire_offchain_lock() -> Option<()> { + /// Try to acquire the offchain storage lock ( tries for 3 times ) + /// Return OK(()) if lock is acquired else , Err(()) + pub fn acquire_offchain_lock() -> Result<(),()> { // Check if another worker is already running or not let s_info = StorageValueRef::persistent(&WORKER_STATUS); - match s_info.get::().map_err(|err| { - log::error!(target:"ocex","Error while loading worker status: {:?}",err); - "Unable to load worker status" - }).ok()? { - Some(true) => { - // Another worker is online, so exit - log::info!(target:"ocex", "Another worker is online, so exit"); - return None - }, - None => {}, - Some(false) => {}, + for _ in 0..3{ + if let Ok(_) = s_info.mutate(|value: Result,StorageRetrievalError>| -> Result{ + match value { + Ok(Some(true)) => { + log::warn!(target:"ocex","Another worker is online, retrying after 1 sec"); + Err(()) + }, + Ok(Some(false)) | Ok(None) => Ok(true), + Err(x) => { + log::error!(target:"ocex","Error while acquiring lock: {:?}",x); + Err(()) + } + } + }){ + return Ok(()) + } } - s_info.set(&true); // Set WORKER_STATUS to true - Some(()) + Err(()) } - /// Release offchain lock + /// Release offchain storage lock pub fn release_offchain_lock() { // Check if another worker is already running or not let s_info = StorageValueRef::persistent(&WORKER_STATUS); @@ -55,7 +61,7 @@ impl Pallet { /// This is a blocking call for offchain worker. pub fn calculate_inventory_deviation() -> Result, DispatchError> { // Acquire the lock to run off-chain worker - if let Some(_) = Self::acquire_offchain_lock() { + if let Ok(_) = Self::acquire_offchain_lock() { // 2. Load last processed blk let mut root = crate::storage::load_trie_root(); log::info!(target:"ocex-rpc","state_root {:?}", root); @@ -81,6 +87,7 @@ impl Pallet { let assets = >::get(); let mut onchain_inventory = BTreeMap::new(); for asset in assets { + // There is no race condition here, as it will be computed for a given block let total = Self::get_onchain_balance(asset); onchain_inventory .entry(asset) @@ -122,9 +129,10 @@ impl Pallet { .saturating_sub(*offchain_inventory.get(&asset).unwrap_or_default()); deviation.insert(asset, diff); } + Self::release_offchain_lock(); return Ok(deviation) + }else{ + return Err(DispatchError::Other("Unable to acquire offchain storage lock")) } - Self::release_offchain_lock(); - Err(DispatchError::Other("Unable to calculate deviation")) } } From 03edc783c73fa1b33c9517e7a008e91d9c00094d Mon Sep 17 00:00:00 2001 From: Gautham Date: Mon, 28 Aug 2023 12:39:01 +0300 Subject: [PATCH 60/91] Fix clippy --- pallets/ocex/rpc/runtime-api/src/lib.rs | 3 +- pallets/ocex/src/lib.rs | 9 ++-- pallets/ocex/src/rpc.rs | 71 ++++++++++++++----------- pallets/ocex/src/validator.rs | 6 +-- 4 files changed, 48 insertions(+), 41 deletions(-) diff --git a/pallets/ocex/rpc/runtime-api/src/lib.rs b/pallets/ocex/rpc/runtime-api/src/lib.rs index 7f5de0d9f..7b7bce16a 100644 --- a/pallets/ocex/rpc/runtime-api/src/lib.rs +++ b/pallets/ocex/rpc/runtime-api/src/lib.rs @@ -21,8 +21,7 @@ use parity_scale_codec::Codec; use polkadex_primitives::AssetId; use rust_decimal::Decimal; -use sp_std::vec::Vec; -use sp_std::collections::btree_map::BTreeMap; +use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; sp_api::decl_runtime_apis! { pub trait PolkadexOcexRuntimeApi where AccountId: Codec, Hash : Codec { diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 1b99615bb..3a35b1545 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -48,8 +48,7 @@ use sp_runtime::{ traits::{AccountIdConversion, UniqueSaturatedInto}, Percent, SaturatedConversion, }; -use sp_std::prelude::*; -use std::ops::{Div, DivAssign}; +use sp_std::{ops::Div, prelude::*}; // Re-export pallet items so that they can be accessed from the crate namespace. use orderbook_primitives::{ types::{AccountAsset, TradingPair}, @@ -1626,17 +1625,17 @@ impl>> Pallet Decimal { let balance = match asset { - AssetId::Polkadex => T::NativeCurrency::free_balance(Self::get_pallet_account()), + AssetId::Polkadex => T::NativeCurrency::free_balance(&Self::get_pallet_account()), AssetId::Asset(id) => T::OtherAssets::reducible_balance( id, - Self::get_pallet_account(), + &Self::get_pallet_account(), Preservation::Expendable, Fortitude::Force, ), }; // div will not panic since denominator is a constant - Decimal::from(balance.saturated_into::()).div(&mut Decimal::from(UNIT_BALANCE)) + Decimal::from(balance.saturated_into::()).div(Decimal::from(UNIT_BALANCE)) } } diff --git a/pallets/ocex/src/rpc.rs b/pallets/ocex/src/rpc.rs index bb38cc281..e70ea7bd1 100644 --- a/pallets/ocex/src/rpc.rs +++ b/pallets/ocex/src/rpc.rs @@ -7,31 +7,36 @@ use crate::{ use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::{AccountId, AssetId}; use rust_decimal::Decimal; -use sp_core::ByteArray; -use sp_runtime::{offchain::storage::StorageValueRef, traits::BlockNumberProvider, DispatchError, Saturating, SaturatedConversion}; -use sp_runtime::offchain::storage::StorageRetrievalError; +use sp_application_crypto::ByteArray; +use sp_runtime::{ + offchain::storage::{StorageRetrievalError, StorageValueRef}, + traits::BlockNumberProvider, + DispatchError, SaturatedConversion, +}; use sp_std::collections::btree_map::BTreeMap; impl Pallet { /// Try to acquire the offchain storage lock ( tries for 3 times ) /// Return OK(()) if lock is acquired else , Err(()) - pub fn acquire_offchain_lock() -> Result<(),()> { + pub fn acquire_offchain_lock() -> Result<(), ()> { // Check if another worker is already running or not let s_info = StorageValueRef::persistent(&WORKER_STATUS); - for _ in 0..3{ - if let Ok(_) = s_info.mutate(|value: Result,StorageRetrievalError>| -> Result{ - match value { - Ok(Some(true)) => { - log::warn!(target:"ocex","Another worker is online, retrying after 1 sec"); - Err(()) - }, - Ok(Some(false)) | Ok(None) => Ok(true), - Err(x) => { - log::error!(target:"ocex","Error while acquiring lock: {:?}",x); - Err(()) + for _ in 0..3 { + if let Ok(_) = s_info.mutate( + |value: Result, StorageRetrievalError>| -> Result { + match value { + Ok(Some(true)) => { + log::warn!(target:"ocex","Another worker is online, retrying after 1 sec"); + Err(()) + }, + Ok(Some(false)) | Ok(None) => Ok(true), + Err(x) => { + log::error!(target:"ocex","Error while acquiring lock: {:?}",x); + Err(()) + }, } - } - }){ + }, + ) { return Ok(()) } } @@ -67,13 +72,16 @@ impl Pallet { log::info!(target:"ocex-rpc","state_root {:?}", root); let mut storage = crate::storage::State; let mut state = OffchainState::load(&mut storage, &mut root); - let mut state_info = Self::load_state_info(&mut state)?; + let state_info = Self::load_state_info(&mut state)?; let last_processed_blk = state_info.last_block; // 3. Load all main accounts and registered assets from on-chain let mut offchain_inventory = BTreeMap::new(); - for (main, acc_info) in >::iter() { + for (main, _) in >::iter() { // 4. Compute sum of all balances of all assets - let balances: BTreeMap = Self::get_balances(&mut state, &Decode::decode(&mut &main.encode()[..]).unwrap())?; + let balances: BTreeMap = Self::get_balances( + &mut state, + &Decode::decode(&mut &main.encode()[..]).unwrap(), + )?; for (asset, balance) in balances { offchain_inventory .entry(asset) @@ -86,11 +94,11 @@ impl Pallet { // 5. Load assets pallet balances of registered assets let assets = >::get(); let mut onchain_inventory = BTreeMap::new(); - for asset in assets { + for asset in &assets { // There is no race condition here, as it will be computed for a given block - let total = Self::get_onchain_balance(asset); + let total = Self::get_onchain_balance(*asset); onchain_inventory - .entry(asset) + .entry(*asset) .and_modify(|total_balance: &mut Decimal| { *total_balance = (*total_balance).saturating_add(total) }) @@ -100,7 +108,8 @@ impl Pallet { let current_blk = frame_system::Pallet::::current_block_number().saturated_into(); if current_blk > last_processed_blk { for blk in last_processed_blk.saturating_add(1)..=current_blk { - let ingress_msgs = >::get(blk); + let ingress_msgs = + >::get(blk.saturated_into::()); for msg in ingress_msgs { match msg { polkadex_primitives::ingress::IngressMessages::Deposit( @@ -122,16 +131,16 @@ impl Pallet { } // 7. Compute deviation and return it let mut deviation = BTreeMap::new(); - for asset in assets { - let diff = onchain_inventory - .get(&asset) - .unwrap_or_default() - .saturating_sub(*offchain_inventory.get(&asset).unwrap_or_default()); - deviation.insert(asset, diff); + for asset in &assets { + let diff = + onchain_inventory.get(asset).cloned().unwrap_or_default().saturating_sub( + offchain_inventory.get(&asset).cloned().unwrap_or_default(), + ); + deviation.insert(*asset, diff); } Self::release_offchain_lock(); return Ok(deviation) - }else{ + } else { return Err(DispatchError::Other("Unable to acquire offchain storage lock")) } } diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 3e6876f99..101148aa5 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -65,7 +65,7 @@ impl Pallet { } // Check if another worker is already running or not - if let None = Self::acquire_offchain_lock() { + if let Err(_) = Self::acquire_offchain_lock() { return Ok(false) } // Check the next batch to process @@ -288,8 +288,8 @@ impl Pallet { for action in &batch.actions { match action { UserActions::Trade(trades) => Self::trades(trades, state)?, - UserActions::Withdraw(request,stid) => { - let withdrawal = Self::withdraw(request, state, stid)?; + UserActions::Withdraw(request, stid) => { + let withdrawal = Self::withdraw(request, state, *stid)?; withdrawals.push(withdrawal); }, UserActions::BlockImport(blk) => From 0118f01d415f89d76d9236f2c51747ffb37e2ce4 Mon Sep 17 00:00:00 2001 From: Gautham Date: Mon, 28 Aug 2023 13:15:22 +0300 Subject: [PATCH 61/91] Handle mutex properly --- pallets/ocex/src/rpc.rs | 138 ++++++++++++++---------------- pallets/ocex/src/tests.rs | 4 +- pallets/ocex/src/validator.rs | 4 +- primitives/orderbook/src/types.rs | 2 +- runtime/src/lib.rs | 8 +- 5 files changed, 75 insertions(+), 81 deletions(-) diff --git a/pallets/ocex/src/rpc.rs b/pallets/ocex/src/rpc.rs index e70ea7bd1..3c5f41548 100644 --- a/pallets/ocex/src/rpc.rs +++ b/pallets/ocex/src/rpc.rs @@ -1,5 +1,6 @@ use crate::{ pallet::{Accounts, AllowlistedToken, IngressMessages}, + snapshot::StateInfo, storage::OffchainState, validator::WORKER_STATUS, Config, Pallet, @@ -18,7 +19,7 @@ use sp_std::collections::btree_map::BTreeMap; impl Pallet { /// Try to acquire the offchain storage lock ( tries for 3 times ) /// Return OK(()) if lock is acquired else , Err(()) - pub fn acquire_offchain_lock() -> Result<(), ()> { + pub fn acquire_offchain_lock() -> Result<(), DispatchError> { // Check if another worker is already running or not let s_info = StorageValueRef::persistent(&WORKER_STATUS); for _ in 0..3 { @@ -40,7 +41,7 @@ impl Pallet { return Ok(()) } } - Err(()) + Err(DispatchError::Other("Offchain storage mutex error")) } /// Release offchain storage lock @@ -65,83 +66,72 @@ impl Pallet { /// /// This is a blocking call for offchain worker. pub fn calculate_inventory_deviation() -> Result, DispatchError> { - // Acquire the lock to run off-chain worker - if let Ok(_) = Self::acquire_offchain_lock() { - // 2. Load last processed blk - let mut root = crate::storage::load_trie_root(); - log::info!(target:"ocex-rpc","state_root {:?}", root); - let mut storage = crate::storage::State; - let mut state = OffchainState::load(&mut storage, &mut root); - let state_info = Self::load_state_info(&mut state)?; - let last_processed_blk = state_info.last_block; - // 3. Load all main accounts and registered assets from on-chain - let mut offchain_inventory = BTreeMap::new(); - for (main, _) in >::iter() { - // 4. Compute sum of all balances of all assets - let balances: BTreeMap = Self::get_balances( - &mut state, - &Decode::decode(&mut &main.encode()[..]).unwrap(), - )?; - for (asset, balance) in balances { - offchain_inventory - .entry(asset) - .and_modify(|total: &mut Decimal| { - *total = (*total).saturating_add(balance); - }) - .or_insert(balance); - } - } - // 5. Load assets pallet balances of registered assets - let assets = >::get(); - let mut onchain_inventory = BTreeMap::new(); - for asset in &assets { - // There is no race condition here, as it will be computed for a given block - let total = Self::get_onchain_balance(*asset); - onchain_inventory - .entry(*asset) - .and_modify(|total_balance: &mut Decimal| { - *total_balance = (*total_balance).saturating_add(total) + // 1. Load last processed blk + let mut root = crate::storage::load_trie_root(); + log::info!(target:"ocex-rpc","state_root {:?}", root); + let mut storage = crate::storage::State; + let mut state = OffchainState::load(&mut storage, &mut root); + let state_info = Self::load_state_info(&mut state)?; + let last_processed_blk = state_info.last_block; + // 2. Load all main accounts and registered assets from on-chain + let mut offchain_inventory = BTreeMap::new(); + for (main, _) in >::iter() { + // 3. Compute sum of all balances of all assets + let balances: BTreeMap = + Self::get_balances(&mut state, &Decode::decode(&mut &main.encode()[..]).unwrap())?; + for (asset, balance) in balances { + offchain_inventory + .entry(asset) + .and_modify(|total: &mut Decimal| { + *total = (*total).saturating_add(balance); }) - .or_insert(total); + .or_insert(balance); } - // 6. Compute the sum of new balances on-chain using ingress messages - let current_blk = frame_system::Pallet::::current_block_number().saturated_into(); - if current_blk > last_processed_blk { - for blk in last_processed_blk.saturating_add(1)..=current_blk { - let ingress_msgs = - >::get(blk.saturated_into::()); - for msg in ingress_msgs { - match msg { - polkadex_primitives::ingress::IngressMessages::Deposit( - _, - asset, - amt, - ) => { - onchain_inventory - .entry(asset) - .and_modify(|total_balance| { - *total_balance = (*total_balance).saturating_add(amt) - }) - .or_insert(amt); - }, - _ => {}, - } + } + // 4. Load assets pallet balances of registered assets + let assets = >::get(); + let mut onchain_inventory = BTreeMap::new(); + for asset in &assets { + // There is no race condition here, as it will be computed for a given block + let total = Self::get_onchain_balance(*asset); + onchain_inventory + .entry(*asset) + .and_modify(|total_balance: &mut Decimal| { + *total_balance = (*total_balance).saturating_add(total) + }) + .or_insert(total); + } + // 5. Compute the sum of new balances on-chain using ingress messages + let current_blk = frame_system::Pallet::::current_block_number().saturated_into(); + if current_blk > last_processed_blk { + for blk in last_processed_blk.saturating_add(1)..=current_blk { + let ingress_msgs = + >::get(blk.saturated_into::()); + for msg in ingress_msgs { + match msg { + polkadex_primitives::ingress::IngressMessages::Deposit(_, asset, amt) => { + onchain_inventory + .entry(asset) + .and_modify(|total_balance| { + *total_balance = (*total_balance).saturating_add(amt) + }) + .or_insert(amt); + }, + _ => {}, } } } - // 7. Compute deviation and return it - let mut deviation = BTreeMap::new(); - for asset in &assets { - let diff = - onchain_inventory.get(asset).cloned().unwrap_or_default().saturating_sub( - offchain_inventory.get(&asset).cloned().unwrap_or_default(), - ); - deviation.insert(*asset, diff); - } - Self::release_offchain_lock(); - return Ok(deviation) - } else { - return Err(DispatchError::Other("Unable to acquire offchain storage lock")) } + // 6. Compute deviation and return it + let mut deviation = BTreeMap::new(); + for asset in &assets { + let diff = onchain_inventory + .get(asset) + .cloned() + .unwrap_or_default() + .saturating_sub(offchain_inventory.get(&asset).cloned().unwrap_or_default()); + deviation.insert(*asset, diff); + } + Ok(deviation) } } diff --git a/pallets/ocex/src/tests.rs b/pallets/ocex/src/tests.rs index 7e1de7800..ce6adfd4e 100644 --- a/pallets/ocex/src/tests.rs +++ b/pallets/ocex/src/tests.rs @@ -2565,9 +2565,7 @@ fn test_whitelist_orderbook_operator_full() { #[test] fn test_old_user_action_enum_payload_with_new_enum_returns_ok() { let payload = r#"{"actions":[{"BlockImport":4842070},{"BlockImport":4842071},{"BlockImport":4842072},{"Withdraw":{"signature":{"Sr25519":"1ce02504db86d6c40826737a0616248570274d6fc880d1294585da3663efb41a8cd7f66db1666edbf0037e193ddf9597ec567e875ccb84b1187bbe6e5d1b5c88"},"payload":{"asset_id":{"asset":"95930534000017180603917534864279132680"},"amount":"0.01","timestamp":1690900017685},"main":"5GLQUnNXayJGG6AZ6ht2MFigMHLKPWZjZqbko2tYQ7GJxi6A","proxy":"5GeYN9KaGkxEzaP2gpefqpCp18a9MEMosPCintz83CGRpKGa"}},{"BlockImport":4842073},{"BlockImport":4842074},{"BlockImport":4842075},{"BlockImport":4842076},{"BlockImport":4842077},{"BlockImport":4842078},{"Withdraw":{"signature":{"Sr25519":"b8a7bb383882379a5cb3796c1fb362a9efca5c224c60e2bb91bfed7a9f94bb620620e32dcecbc7e64011e3d3d073b1290e46b3cb97cf0b96c49ba5b0e9e1548f"},"payload":{"asset_id":{"asset":"123"},"amount":"10","timestamp":1690900085111},"main":"5GLFKUxSXTf8MDDKM1vqEFb5TuV1q642qpQT964mrmjeKz4w","proxy":"5ExtoLVQaef9758mibzLhaxK4GBk7qoysSWo7FKt2nrV26i8"}},{"BlockImport":4842079},{"BlockImport":4842080},{"BlockImport":4842081},{"BlockImport":4842082},{"Withdraw":{"signature":{"Sr25519":"4e589e61b18815abcc3fe50626e54844d1e2fd9bb0575fce8eabb5af1ba4b42fba060ad3067bef341e8d5973d932f30d9113c0abbbd65e96e2dd5cbaf94d4581"},"payload":{"asset_id":{"asset":"456"},"amount":"4","timestamp":1690900140296},"main":"5GLFKUxSXTf8MDDKM1vqEFb5TuV1q642qpQT964mrmjeKz4w","proxy":"5ExtoLVQaef9758mibzLhaxK4GBk7qoysSWo7FKt2nrV26i8"}},{"BlockImport":4842083},{"BlockImport":4842084},{"BlockImport":4842085},{"BlockImport":4842086},{"BlockImport":4842087},{"BlockImport":4842088},{"BlockImport":4842089},{"BlockImport":4842090},{"BlockImport":4842091},{"BlockImport":4842092},{"BlockImport":4842093},{"BlockImport":4842094},{"BlockImport":4842095},{"BlockImport":4842096},{"BlockImport":4842097},{"BlockImport":4842098},{"BlockImport":4842099},{"BlockImport":4842100},{"BlockImport":4842101}],"stid":74132,"snapshot_id":10147,"signature":"901dc6972f94d69f253b9ca5a83410a5bc729e5c30c68cba3e68ea4860ca73e447d06c41d3bad05aca4e031f0fa46b1f64fac70159cec68151fef534e48515de00"}"#; - let payload: Result, serde_json::error::Error> = - serde_json::from_str(payload); - assert!(payload.is_ok()); + let _: UserActionBatch = serde_json::from_str(payload).unwrap(); } #[test] diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 101148aa5..560ed7ade 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -288,8 +288,8 @@ impl Pallet { for action in &batch.actions { match action { UserActions::Trade(trades) => Self::trades(trades, state)?, - UserActions::Withdraw(request, stid) => { - let withdrawal = Self::withdraw(request, state, *stid)?; + UserActions::Withdraw(request) => { + let withdrawal = Self::withdraw(request, state, 0)?; withdrawals.push(withdrawal); }, UserActions::BlockImport(blk) => diff --git a/primitives/orderbook/src/types.rs b/primitives/orderbook/src/types.rs index b53d134c6..1694b937d 100644 --- a/primitives/orderbook/src/types.rs +++ b/primitives/orderbook/src/types.rs @@ -232,7 +232,7 @@ pub enum UserActions { /// Trade operation requested. Trade(Vec), /// Withdraw operation requested. ( payload, stid) - Withdraw(WithdrawalRequest, u64), + Withdraw(WithdrawalRequest), /// Block import requested. BlockImport(u32), /// Reset Flag diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 62f4655ca..7fbee03cd 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1575,7 +1575,13 @@ impl_runtime_apis! { fn get_ob_recover_state() -> Result, DispatchError> { Ok(OCEX::get_ob_recover_state()?.encode()) } fn get_balance(from: AccountId, of: AssetId) -> Result { OCEX::get_balance(from, of) } fn calculate_inventory_deviation() -> Result, - DispatchError> { OCEX::calculate_inventory_deviation() } + DispatchError> { + // 1. Acquire the lock to run off-chain worker + OCEX::acquire_offchain_lock()?; + let result = OCEX::calculate_inventory_deviation(); + OCEX::release_offchain_lock(); + result + } } impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { From a12f3ad65e1117e21f84abc36f568128a5d65b95 Mon Sep 17 00:00:00 2001 From: Gautham Date: Mon, 28 Aug 2023 13:51:29 +0300 Subject: [PATCH 62/91] remove unused deps --- pallets/ocex/src/rpc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/ocex/src/rpc.rs b/pallets/ocex/src/rpc.rs index 3c5f41548..dabaf7876 100644 --- a/pallets/ocex/src/rpc.rs +++ b/pallets/ocex/src/rpc.rs @@ -1,6 +1,5 @@ use crate::{ pallet::{Accounts, AllowlistedToken, IngressMessages}, - snapshot::StateInfo, storage::OffchainState, validator::WORKER_STATUS, Config, Pallet, From 04c2825f65be2696253072b8637664c34155f348 Mon Sep 17 00:00:00 2001 From: gautham Date: Mon, 28 Aug 2023 20:33:36 +0530 Subject: [PATCH 63/91] Fix clippy --- pallets/ocex/src/rpc.rs | 30 +++++++++++++++--------------- pallets/ocex/src/validator.rs | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pallets/ocex/src/rpc.rs b/pallets/ocex/src/rpc.rs index dabaf7876..2d4db1110 100644 --- a/pallets/ocex/src/rpc.rs +++ b/pallets/ocex/src/rpc.rs @@ -22,8 +22,8 @@ impl Pallet { // Check if another worker is already running or not let s_info = StorageValueRef::persistent(&WORKER_STATUS); for _ in 0..3 { - if let Ok(_) = s_info.mutate( - |value: Result, StorageRetrievalError>| -> Result { + if s_info + .mutate(|value: Result, StorageRetrievalError>| -> Result { match value { Ok(Some(true)) => { log::warn!(target:"ocex","Another worker is online, retrying after 1 sec"); @@ -35,8 +35,9 @@ impl Pallet { Err(()) }, } - }, - ) { + }) + .is_ok() + { return Ok(()) } } @@ -107,16 +108,15 @@ impl Pallet { let ingress_msgs = >::get(blk.saturated_into::()); for msg in ingress_msgs { - match msg { - polkadex_primitives::ingress::IngressMessages::Deposit(_, asset, amt) => { - onchain_inventory - .entry(asset) - .and_modify(|total_balance| { - *total_balance = (*total_balance).saturating_add(amt) - }) - .or_insert(amt); - }, - _ => {}, + if let polkadex_primitives::ingress::IngressMessages::Deposit(_, asset, amt) = + msg + { + onchain_inventory + .entry(asset) + .and_modify(|total_balance| { + *total_balance = (*total_balance).saturating_add(amt) + }) + .or_insert(amt); } } } @@ -128,7 +128,7 @@ impl Pallet { .get(asset) .cloned() .unwrap_or_default() - .saturating_sub(offchain_inventory.get(&asset).cloned().unwrap_or_default()); + .saturating_sub(offchain_inventory.get(asset).cloned().unwrap_or_default()); deviation.insert(*asset, diff); } Ok(deviation) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 560ed7ade..191dabd00 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -65,7 +65,7 @@ impl Pallet { } // Check if another worker is already running or not - if let Err(_) = Self::acquire_offchain_lock() { + if Self::acquire_offchain_lock().is_err() { return Ok(false) } // Check the next batch to process From fcbfeea4bc9eea4225158e6fcdffed86660a0276 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 00:07:11 +0530 Subject: [PATCH 64/91] Resolved serhi's comment --- Cargo.toml | 1 + pallets/ocex/rpc/Cargo.toml | 8 ++++---- pallets/ocex/rpc/src/lib.rs | 2 +- pallets/ocex/rpc/src/offchain.rs | 13 +++++++++++++ pallets/ocex/src/checkpoint_handler.rs | 27 -------------------------- pallets/ocex/src/lib.rs | 1 + pallets/ocex/src/validator.rs | 17 ++++++++-------- pallets/thea/src/aggregator.rs | 8 ++++++-- primitives/orderbook/src/lib.rs | 18 +++++++++++++++++ 9 files changed, 52 insertions(+), 43 deletions(-) delete mode 100644 pallets/ocex/src/checkpoint_handler.rs diff --git a/Cargo.toml b/Cargo.toml index 9a9859e8e..13fadf844 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,7 @@ log = { version = "0.4.8", default-features = false } anyhow = "1.0.56" smallvec = "1.6.1" jsonrpsee = "0.16.2" +parking_lot = "0.12.1" blake2-rfc = { version = "0.2.18", default-features = false } static_assertions = "1.1.0" parity-scale-codec = { version = "3.1.5", default-features = false } diff --git a/pallets/ocex/rpc/Cargo.toml b/pallets/ocex/rpc/Cargo.toml index 0c80c8edf..f5fa8140c 100644 --- a/pallets/ocex/rpc/Cargo.toml +++ b/pallets/ocex/rpc/Cargo.toml @@ -16,10 +16,10 @@ orderbook-primitives = { path = "../../../primitives/orderbook" } pallet-ocex-runtime-api = { path = "runtime-api" } serde_json = { workspace = true, default-features = true } polkadex-primitives = { workspace = true } -sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } -sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } -sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.43" } -parking_lot = "0.12.1" +sc-rpc-api = { workspace = true, default-features = true } +sc-rpc = { workspace = true, default-features = true } +sp-offchain = { workspace = true, default-features = true } +parking_lot = { workspace = true } hash-db = { workspace = true } trie-db = { workspace = true } sp-trie = { workspace = true } diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 0e3552e35..bf9a485cd 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -149,7 +149,7 @@ where }; let offchain_worker = OffchainStorageAdapter::new(self.storage.clone()); while offchain_worker.get_worker_status() { - std::thread::sleep(std::time::Duration::from_millis(100)); + std::thread::sleep(std::time::Duration::from_millis(100)); // 1 sec waiting time & break after 3rd attempt } offchain_worker.update_worker_status(true); return if let Ok(Ok(ob_checkpoint_raw)) = api.fetch_checkpoint(at) { diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index 867e04549..4f6c7db46 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -5,15 +5,25 @@ use std::sync::Arc; pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status"; +/// Adapter to Access OCEX Offchain Storage pub struct OffchainStorageAdapter { storage: Arc>, } impl OffchainStorageAdapter { + + /// Create a new `OffchainStorageAdapter` instance. + /// # Parameters + /// * `storage`: Offchain storage + /// # Returns + /// * `OffchainStorageAdapter`: A new `OffchainStorageAdapter` instance. pub fn new(storage: Arc>) -> Self { Self { storage } } + /// Get worker status + /// # Returns + /// * `bool`: Worker status pub fn get_worker_status(&self) -> bool { let prefix = sp_offchain::STORAGE_PREFIX; let bytes: Option = self.storage.read().get(prefix, &WORKER_STATUS).map(Into::into); @@ -29,6 +39,9 @@ impl OffchainStorageAdapter { } } + /// Update worker status + /// # Parameters + /// * `status`: Worker status pub fn update_worker_status(&self, status: bool) { let prefix = sp_offchain::STORAGE_PREFIX; let encoded_value = Encode::encode(&status); diff --git a/pallets/ocex/src/checkpoint_handler.rs b/pallets/ocex/src/checkpoint_handler.rs deleted file mode 100644 index cae8cb59f..000000000 --- a/pallets/ocex/src/checkpoint_handler.rs +++ /dev/null @@ -1,27 +0,0 @@ -use sp_runtime::offchain::storage::StorageValueRef; - -const CHECKPOINT_FLAG: [u8; 30] = *b"offchain-ocex::checkpoint_flag"; - -struct CheckpointHandler; - -impl CheckpointHandler { - fn get_checkpoint_flag() -> bool { - let s_r = StorageValueRef::persistent(&CHECKPOINT_FLAG); - match s_r.get::() { - Ok(Some(x)) => x, - Ok(None) => { - log::trace!(target:"ocex","checkpoint_flag not found"); - false - }, - Err(_) => { - log::error!(target:"ocex","Failed to get checkpoint_flag"); - false - }, - } - } - - fn set_checkpoint_flag(flag: bool) { - let s_w = StorageValueRef::persistent(&CHECKPOINT_FLAG); - s_w.set(&flag); - } -} diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 083884d0a..cdeedd7c5 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -1318,6 +1318,7 @@ pub mod pallet { )) } + /// Fetch checkpoint for recovery pub fn fetch_checkpoint() -> Result { let account_id = >::iter().fold(vec![], |mut ids_accum, (acc, acc_info)| { diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 3125ad8e6..f65d4f6cc 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -180,24 +180,23 @@ impl Pallet { Ok(true) } + /// Returns the offchain state pub fn get_worker_status() -> OrderbookWorkerStatus { let s_info = StorageValueRef::persistent(&WORKER_STATUS); match s_info .get::() - .map_err(|err| { - log::error!(target:"ocex","Error while loading worker status: {:?}",err); - "Unable to load worker status" - }) - .unwrap() { - //TODO: Fix this unwrap - Some(true) => { + Ok(Some(true)) => { // Another worker is online, so exit log::info!(target:"ocex", "Another worker is online, so exit"); return OrderbookWorkerStatus::InProgress }, - None => OrderbookWorkerStatus::NotStarted, - Some(false) => OrderbookWorkerStatus::Idle, + Ok(None) => OrderbookWorkerStatus::NotStarted, + Ok(Some(false)) => OrderbookWorkerStatus::Idle, + Err(err) => { + log::error!(target:"ocex","Error while loading worker status: {:?}",err); + OrderbookWorkerStatus::Error + }, } } diff --git a/pallets/thea/src/aggregator.rs b/pallets/thea/src/aggregator.rs index ac1a2a119..d1e2f76af 100644 --- a/pallets/thea/src/aggregator.rs +++ b/pallets/thea/src/aggregator.rs @@ -21,9 +21,13 @@ impl AggregatorClient { .unwrap_or_default() } - /// Returns the latest incoming nonce for solochain + /// Returns the payload for given nonce for given network and destination + /// # Parameters + /// * `nonce`: Nonce of the outgoing message + /// * `network`: Network of the outgoing message + /// * `destination`: Message destination /// # Returns - /// * `u64`: Latest incoming nonce for solochain + /// * `Option`: Payload for given nonce for given network and destination pub fn get_payload_for_nonce( nonce: u64, network: Network, diff --git a/primitives/orderbook/src/lib.rs b/primitives/orderbook/src/lib.rs index c07b743b2..7314773f4 100644 --- a/primitives/orderbook/src/lib.rs +++ b/primitives/orderbook/src/lib.rs @@ -142,6 +142,15 @@ pub struct ObCheckpointRaw { } impl ObCheckpointRaw { + + /// Create a new `ObCheckpointRaw` instance. + /// # Parameters + /// * `snapshot_id`: The snapshot ID of the order book recovery state. + /// * `balances`: A `BTreeMap` that maps `AccountAsset`s to `Decimal` balances. + /// * `last_processed_block_number`: The last block number that was processed by validator. + /// * `state_change_id`: State change id + /// # Returns + /// * `ObCheckpointRaw`: A new `ObCheckpointRaw` instance. pub fn new( snapshot_id: u64, balances: BTreeMap, @@ -151,6 +160,9 @@ impl ObCheckpointRaw { Self { snapshot_id, balances, last_processed_block_number, state_change_id } } + /// Convert `ObCheckpointRaw` to `ObCheckpoint`. + /// # Returns + /// * `ObCheckpoint`: A new `ObCheckpoint` instance. #[cfg(feature = "std")] pub fn to_checkpoint(&self) -> ObCheckpoint { ObCheckpoint { @@ -162,13 +174,19 @@ impl ObCheckpointRaw { } } +/// Orderbook offchain worker status pub enum OrderbookWorkerStatus { Idle, InProgress, NotStarted, + Error } impl OrderbookWorkerStatus { + + /// Check if the status is idle + /// # Returns + /// * `bool`: True if the status is idle pub fn is_idle(&self) -> bool { match self { OrderbookWorkerStatus::Idle => true, From c19d897b4adfc23efac35cb99d74cb743cb75872 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 01:37:02 +0530 Subject: [PATCH 65/91] Fixed taplo --- runtime/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 3776364b5..84c81b388 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -187,7 +187,7 @@ std = [ "thea-executor/std", "frame-try-runtime?/std", "thea-message-handler?/std", - "orderbook-primitives/std" + "orderbook-primitives/std", ] runtime-benchmarks = [ #theirs From b632d5feb7435a4aa2e4aa56a94afd0f57da905b Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 18:39:35 +0530 Subject: [PATCH 66/91] Refactor RPCs --- node/src/rpc.rs | 8 ++++++-- pallets/ocex/rpc/src/lib.rs | 33 +++++++++++++++++++++++++------- pallets/ocex/rpc/src/offchain.rs | 20 +++++++++++++++++++ runtime/src/lib.rs | 8 +------- 4 files changed, 53 insertions(+), 16 deletions(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 1acebb13d..b965dd910 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -134,7 +134,7 @@ where // use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut io = RpcModule::new(()); - let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa, backend:_ } = + let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa, backend } = deps; let BabeDeps { keystore, babe_worker_handle } = babe; @@ -173,7 +173,11 @@ where io.merge(PolkadexRewardsRpc::new(client.clone()).into_rpc())?; io.merge( PolkadexOcexRpc::new( - client.clone() + client.clone(), + backend + .offchain_storage() + .ok_or_else(|| "Backend doesn't provide an offchain storage")?, + deny_unsafe, ) .into_rpc(), )?; diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index a987c5da1..5fe52146a 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -19,6 +19,8 @@ //! This crate provides an RPC methods for OCEX pallet - balances state and onchain/offchain //! recovery data. +pub mod offchain; + use jsonrpsee::{ core::{async_trait, Error as JsonRpseeError, RpcResult}, proc_macros::rpc, @@ -32,6 +34,9 @@ use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::traits::Block as BlockT; use std::sync::Arc; +use parking_lot::RwLock; +use sc_rpc_api::DenyUnsafe; +use sp_core::offchain::OffchainStorage; const RUNTIME_ERROR: i32 = 1; @@ -62,31 +67,41 @@ pub trait PolkadexOcexRpcApi { /// /// * `Client`: The client API used to interact with the Substrate runtime. /// * `Block`: The block type of the Substrate runtime. -pub struct PolkadexOcexRpc { +pub struct PolkadexOcexRpc { /// An `Arc` reference to the client API for accessing runtime functionality. client: Arc, + /// Offchain storage + storage: Arc>, + _deny_unsafe: DenyUnsafe, + /// A marker for the `Block` type parameter, used to ensure the struct /// is covariant with respect to the block type. _marker: std::marker::PhantomData, } -impl PolkadexOcexRpc { - pub fn new(client: Arc) -> Self { - Self { client, _marker: Default::default() } +impl PolkadexOcexRpc { + pub fn new(client: Arc, storage: T, deny_unsafe: DenyUnsafe) -> Self { + Self { + client, + storage: Arc::new(RwLock::new(storage)), + _deny_unsafe: deny_unsafe, + _marker: Default::default(), + } } } #[async_trait] -impl +impl PolkadexOcexRpcApiServer<::Hash, AccountId, Hash> -for PolkadexOcexRpc +for PolkadexOcexRpc where Block: BlockT, Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, Client::Api: PolkadexOcexRuntimeApi, AccountId: Codec, Hash: Codec, + T: OffchainStorage + 'static { fn get_ob_recover_state( &self, @@ -136,19 +151,23 @@ for PolkadexOcexRpc Some(at) => at, None => self.client.info().best_hash, }; + let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); + offchain_storage.acquire_offchain_lock(3); let runtime_api_result = api.calculate_inventory_deviation(at).map_err(runtime_error_into_rpc_err)?; let json = serde_json::to_string(&runtime_api_result).map_err(runtime_error_into_rpc_err)?; Ok(json) } + fn fetch_checkpoint(&self, at: Option<::Hash>) -> RpcResult { let api = self.client.runtime_api(); let at = match at { Some(at) => at, None => self.client.info().best_hash, }; - + let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); + offchain_storage.acquire_offchain_lock(3); let ob_checkpoint_raw = api.fetch_checkpoint(at).map_err(runtime_error_into_rpc_err)?.map_err(runtime_error_into_rpc_err)?; let ob_checkpoint = ob_checkpoint_raw.to_checkpoint(); diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index 4f6c7db46..38b7e0387 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -39,6 +39,20 @@ impl OffchainStorageAdapter { } } + pub fn acquire_offchain_lock(&self, tries: u8) -> bool { + let prefix = sp_offchain::STORAGE_PREFIX; + let old_value = Encode::encode(&false); + let new_value = Encode::encode(&true); + for _ in 0..tries { + if self.storage.write().compare_and_set(prefix, &WORKER_STATUS, Some(&old_value), &new_value) { + return true; + } + // Wait for 1 sec + std::thread::sleep(std::time::Duration::from_secs(1)); + } + false + } + /// Update worker status /// # Parameters /// * `status`: Worker status @@ -48,3 +62,9 @@ impl OffchainStorageAdapter { self.storage.write().set(prefix, &WORKER_STATUS, &encoded_value); } } + +impl Drop for OffchainStorageAdapter { + fn drop(&mut self) { + self.update_worker_status(false); + } +} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f9b751b89..55f34addd 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1576,17 +1576,11 @@ impl_runtime_apis! { fn get_ob_recover_state() -> Result, DispatchError> { Ok(OCEX::get_ob_recover_state()?.encode()) } fn get_balance(from: AccountId, of: AssetId) -> Result { OCEX::get_balance(from, of) } fn fetch_checkpoint() -> Result { - OCEX::acquire_offchain_lock()?; - let result = OCEX::fetch_checkpoint(); - OCEX::release_offchain_lock(); - result + OCEX::fetch_checkpoint() } fn calculate_inventory_deviation() -> Result, DispatchError> { - // 1. Acquire the lock to run off-chain worker - OCEX::acquire_offchain_lock()?; let result = OCEX::calculate_inventory_deviation(); - OCEX::release_offchain_lock(); result } } From 7b2b37526faa6a51215897e160f38f469a71b423 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 18:40:44 +0530 Subject: [PATCH 67/91] Added comment --- pallets/ocex/rpc/src/offchain.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index 38b7e0387..dd7b1b20c 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -39,6 +39,11 @@ impl OffchainStorageAdapter { } } + /// Acquire offchain lock + /// # Parameters + /// * `tries`: Number of tries to acquire lock + /// # Returns + /// * `bool`: True if lock is acquired else false pub fn acquire_offchain_lock(&self, tries: u8) -> bool { let prefix = sp_offchain::STORAGE_PREFIX; let old_value = Encode::encode(&false); From bbcc1a0018722e52af1cdc1042a7ba3ba3b78a22 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 18:48:04 +0530 Subject: [PATCH 68/91] Error handling --- pallets/ocex/rpc/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 5fe52146a..97064cb0f 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -152,7 +152,9 @@ for PolkadexOcexRpc None => self.client.info().best_hash, }; let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); - offchain_storage.acquire_offchain_lock(3); + if !offchain_storage.acquire_offchain_lock(3) { + return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")); + } let runtime_api_result = api.calculate_inventory_deviation(at).map_err(runtime_error_into_rpc_err)?; let json = @@ -167,7 +169,9 @@ for PolkadexOcexRpc None => self.client.info().best_hash, }; let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); - offchain_storage.acquire_offchain_lock(3); + if !offchain_storage.acquire_offchain_lock(3) { + return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")); + } let ob_checkpoint_raw = api.fetch_checkpoint(at).map_err(runtime_error_into_rpc_err)?.map_err(runtime_error_into_rpc_err)?; let ob_checkpoint = ob_checkpoint_raw.to_checkpoint(); From 00cb3914c82e0e8ef670c1c15e871542c88489fe Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 19:01:16 +0530 Subject: [PATCH 69/91] Updated offchain worker --- pallets/ocex/rpc/src/lib.rs | 6 ++++-- pallets/ocex/rpc/src/offchain.rs | 35 +++++--------------------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 97064cb0f..06cca57c2 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -73,7 +73,7 @@ pub struct PolkadexOcexRpc { /// Offchain storage storage: Arc>, - _deny_unsafe: DenyUnsafe, + deny_unsafe: DenyUnsafe, /// A marker for the `Block` type parameter, used to ensure the struct /// is covariant with respect to the block type. @@ -85,7 +85,7 @@ impl PolkadexOcexRpc { Self { client, storage: Arc::new(RwLock::new(storage)), - _deny_unsafe: deny_unsafe, + deny_unsafe, _marker: Default::default(), } } @@ -146,6 +146,7 @@ for PolkadexOcexRpc &self, at: Option<::Hash>, ) -> RpcResult { + self.deny_unsafe.check_if_safe()?; let api = self.client.runtime_api(); let at = match at { Some(at) => at, @@ -163,6 +164,7 @@ for PolkadexOcexRpc } fn fetch_checkpoint(&self, at: Option<::Hash>) -> RpcResult { + self.deny_unsafe.check_if_safe()?; let api = self.client.runtime_api(); let at = match at { Some(at) => at, diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index dd7b1b20c..d7bfa12ae 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -1,6 +1,6 @@ -use parity_scale_codec::{Decode, Encode}; +use parity_scale_codec::Encode; use parking_lot::RwLock; -use sp_core::{offchain::OffchainStorage, Bytes}; +use sp_core::offchain::OffchainStorage; use std::sync::Arc; pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status"; @@ -21,24 +21,6 @@ impl OffchainStorageAdapter { Self { storage } } - /// Get worker status - /// # Returns - /// * `bool`: Worker status - pub fn get_worker_status(&self) -> bool { - let prefix = sp_offchain::STORAGE_PREFIX; - let bytes: Option = self.storage.read().get(prefix, &WORKER_STATUS).map(Into::into); - match bytes { - Some(encoded_bytes) => { - let encoded_value = encoded_bytes.to_vec(); - match Decode::decode(&mut &encoded_value[..]) { - Ok(worker_status) => worker_status, - Err(_) => false, - } - }, - None => false, - } - } - /// Acquire offchain lock /// # Parameters /// * `tries`: Number of tries to acquire lock @@ -57,19 +39,12 @@ impl OffchainStorageAdapter { } false } - - /// Update worker status - /// # Parameters - /// * `status`: Worker status - pub fn update_worker_status(&self, status: bool) { - let prefix = sp_offchain::STORAGE_PREFIX; - let encoded_value = Encode::encode(&status); - self.storage.write().set(prefix, &WORKER_STATUS, &encoded_value); - } } impl Drop for OffchainStorageAdapter { fn drop(&mut self) { - self.update_worker_status(false); + let prefix = sp_offchain::STORAGE_PREFIX; + let encoded_value = Encode::encode(&false); + self.storage.write().set(prefix, &WORKER_STATUS, &encoded_value); } } From b2502f22d76c280b9dd76d6a63695ad6aabdcc91 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 19:14:38 +0530 Subject: [PATCH 70/91] Fixed formatting --- pallets/ocex/rpc/src/lib.rs | 40 +++++++++++++++++--------------- pallets/ocex/rpc/src/offchain.rs | 10 +++++--- pallets/ocex/src/validator.rs | 6 ++--- primitives/orderbook/src/lib.rs | 4 +--- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 06cca57c2..3b410ab98 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -29,14 +29,14 @@ use jsonrpsee::{ use orderbook_primitives::recovery::{ObCheckpoint, ObRecoveryState}; pub use pallet_ocex_runtime_api::PolkadexOcexRuntimeApi; use parity_scale_codec::{Codec, Decode}; +use parking_lot::RwLock; use polkadex_primitives::AssetId; +use sc_rpc_api::DenyUnsafe; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; +use sp_core::offchain::OffchainStorage; use sp_runtime::traits::Block as BlockT; use std::sync::Arc; -use parking_lot::RwLock; -use sc_rpc_api::DenyUnsafe; -use sp_core::offchain::OffchainStorage; const RUNTIME_ERROR: i32 = 1; @@ -93,15 +93,15 @@ impl PolkadexOcexRpc { #[async_trait] impl -PolkadexOcexRpcApiServer<::Hash, AccountId, Hash> -for PolkadexOcexRpc - where - Block: BlockT, - Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, - Client::Api: PolkadexOcexRuntimeApi, - AccountId: Codec, - Hash: Codec, - T: OffchainStorage + 'static + PolkadexOcexRpcApiServer<::Hash, AccountId, Hash> + for PolkadexOcexRpc +where + Block: BlockT, + Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, + Client::Api: PolkadexOcexRuntimeApi, + AccountId: Codec, + Hash: Codec, + T: OffchainStorage + 'static, { fn get_ob_recover_state( &self, @@ -121,7 +121,7 @@ for PolkadexOcexRpc .map_err(runtime_error_into_rpc_err)? .as_ref(), ) - .map_err(runtime_error_into_rpc_err) + .map_err(runtime_error_into_rpc_err) } fn get_balance( @@ -154,7 +154,7 @@ for PolkadexOcexRpc }; let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); if !offchain_storage.acquire_offchain_lock(3) { - return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")); + return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")) } let runtime_api_result = api.calculate_inventory_deviation(at).map_err(runtime_error_into_rpc_err)?; @@ -170,12 +170,14 @@ for PolkadexOcexRpc Some(at) => at, None => self.client.info().best_hash, }; - let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); + let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); if !offchain_storage.acquire_offchain_lock(3) { - return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")); + return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")) } - let ob_checkpoint_raw = - api.fetch_checkpoint(at).map_err(runtime_error_into_rpc_err)?.map_err(runtime_error_into_rpc_err)?; + let ob_checkpoint_raw = api + .fetch_checkpoint(at) + .map_err(runtime_error_into_rpc_err)? + .map_err(runtime_error_into_rpc_err)?; let ob_checkpoint = ob_checkpoint_raw.to_checkpoint(); Ok(ob_checkpoint) } @@ -185,4 +187,4 @@ for PolkadexOcexRpc fn runtime_error_into_rpc_err(err: impl std::fmt::Debug) -> JsonRpseeError { CallError::Custom(ErrorObject::owned(RUNTIME_ERROR, "Runtime error", Some(format!("{err:?}")))) .into() -} \ No newline at end of file +} diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index d7bfa12ae..1ea1a4506 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -11,7 +11,6 @@ pub struct OffchainStorageAdapter { } impl OffchainStorageAdapter { - /// Create a new `OffchainStorageAdapter` instance. /// # Parameters /// * `storage`: Offchain storage @@ -31,8 +30,13 @@ impl OffchainStorageAdapter { let old_value = Encode::encode(&false); let new_value = Encode::encode(&true); for _ in 0..tries { - if self.storage.write().compare_and_set(prefix, &WORKER_STATUS, Some(&old_value), &new_value) { - return true; + if self.storage.write().compare_and_set( + prefix, + &WORKER_STATUS, + Some(&old_value), + &new_value, + ) { + return true } // Wait for 1 sec std::thread::sleep(std::time::Duration::from_secs(1)); diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 6c5a71082..09be6eb48 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -192,9 +192,7 @@ impl Pallet { /// Returns the offchain state pub fn get_worker_status() -> OrderbookWorkerStatus { let s_info = StorageValueRef::persistent(&WORKER_STATUS); - match s_info - .get::() - { + match s_info.get::() { Ok(Some(true)) => { // Another worker is online, so exit log::info!(target:"ocex", "Another worker is online, so exit"); @@ -334,7 +332,7 @@ impl Pallet { Ok(withdrawals) } - /// Loads the state info from the offchain state + /// Loads the state info from the offchain state pub fn load_state_info(state: &mut OffchainState) -> Result { match state.get(&STATE_INFO.to_vec())? { Some(data) => Ok(StateInfo::decode(&mut &data[..]).unwrap_or_default()), diff --git a/primitives/orderbook/src/lib.rs b/primitives/orderbook/src/lib.rs index 7314773f4..c923d7795 100644 --- a/primitives/orderbook/src/lib.rs +++ b/primitives/orderbook/src/lib.rs @@ -142,7 +142,6 @@ pub struct ObCheckpointRaw { } impl ObCheckpointRaw { - /// Create a new `ObCheckpointRaw` instance. /// # Parameters /// * `snapshot_id`: The snapshot ID of the order book recovery state. @@ -179,11 +178,10 @@ pub enum OrderbookWorkerStatus { Idle, InProgress, NotStarted, - Error + Error, } impl OrderbookWorkerStatus { - /// Check if the status is idle /// # Returns /// * `bool`: True if the status is idle From 4e039da25e3db27a084f2e14978855e560c448ef Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 29 Aug 2023 19:20:20 +0530 Subject: [PATCH 71/91] Fixed warnings --- node/src/rpc.rs | 2 +- pallets/ocex/src/validator.rs | 20 +------------------- primitives/orderbook/src/lib.rs | 20 -------------------- runtime/src/lib.rs | 3 +-- 4 files changed, 3 insertions(+), 42 deletions(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index b965dd910..52a6c58ad 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -176,7 +176,7 @@ where client.clone(), backend .offchain_storage() - .ok_or_else(|| "Backend doesn't provide an offchain storage")?, + .ok_or("Backend doesn't provide an offchain storage")?, deny_unsafe, ) .into_rpc(), diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 09be6eb48..650b8f09a 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -8,7 +8,7 @@ use crate::{ }; use orderbook_primitives::{ types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, - OrderbookWorkerStatus, SnapshotSummary, + SnapshotSummary, }; use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::{ingress::IngressMessages, withdrawal::Withdrawal, AssetId}; @@ -189,24 +189,6 @@ impl Pallet { Ok(true) } - /// Returns the offchain state - pub fn get_worker_status() -> OrderbookWorkerStatus { - let s_info = StorageValueRef::persistent(&WORKER_STATUS); - match s_info.get::() { - Ok(Some(true)) => { - // Another worker is online, so exit - log::info!(target:"ocex", "Another worker is online, so exit"); - return OrderbookWorkerStatus::InProgress - }, - Ok(None) => OrderbookWorkerStatus::NotStarted, - Ok(Some(false)) => OrderbookWorkerStatus::Idle, - Err(err) => { - log::error!(target:"ocex","Error while loading worker status: {:?}",err); - OrderbookWorkerStatus::Error - }, - } - } - /// Checks if another worker is already running or not pub fn check_worker_status() -> Result { let s_info = StorageValueRef::persistent(&WORKER_STATUS); diff --git a/primitives/orderbook/src/lib.rs b/primitives/orderbook/src/lib.rs index c923d7795..f9015922c 100644 --- a/primitives/orderbook/src/lib.rs +++ b/primitives/orderbook/src/lib.rs @@ -172,23 +172,3 @@ impl ObCheckpointRaw { } } } - -/// Orderbook offchain worker status -pub enum OrderbookWorkerStatus { - Idle, - InProgress, - NotStarted, - Error, -} - -impl OrderbookWorkerStatus { - /// Check if the status is idle - /// # Returns - /// * `bool`: True if the status is idle - pub fn is_idle(&self) -> bool { - match self { - OrderbookWorkerStatus::Idle => true, - _ => false, - } - } -} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 55f34addd..3401f0627 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1580,8 +1580,7 @@ impl_runtime_apis! { } fn calculate_inventory_deviation() -> Result, DispatchError> { - let result = OCEX::calculate_inventory_deviation(); - result + OCEX::calculate_inventory_deviation() } } From f40a5f7cdb5a6eae4d5c0a309c18e789fc6a5622 Mon Sep 17 00:00:00 2001 From: zktony Date: Wed, 30 Aug 2023 10:56:14 +0530 Subject: [PATCH 72/91] Fixed sleep --- Cargo.lock | 1 + Cargo.toml | 1 + pallets/ocex/rpc/Cargo.toml | 1 + pallets/ocex/rpc/src/lib.rs | 15 +++++++++------ pallets/ocex/rpc/src/offchain.rs | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57dd35298..c92dd1253 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5470,6 +5470,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-trie", + "tokio", "trie-db", ] diff --git a/Cargo.toml b/Cargo.toml index 13fadf844..e85b72410 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,7 @@ anyhow = "1.0.56" smallvec = "1.6.1" jsonrpsee = "0.16.2" parking_lot = "0.12.1" +tokio = "1.32.0" blake2-rfc = { version = "0.2.18", default-features = false } static_assertions = "1.1.0" parity-scale-codec = { version = "3.1.5", default-features = false } diff --git a/pallets/ocex/rpc/Cargo.toml b/pallets/ocex/rpc/Cargo.toml index f5fa8140c..d8ea9bd6f 100644 --- a/pallets/ocex/rpc/Cargo.toml +++ b/pallets/ocex/rpc/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +tokio = { workspace = true } serde = { workspace = true, default-features = true } parity-scale-codec = { workspace = true, features = ["derive"] } jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] } diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 3b410ab98..84d66213c 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -54,10 +54,10 @@ pub trait PolkadexOcexRpcApi { ) -> RpcResult; #[method(name = "ob_inventoryDeviation")] - fn calculate_inventory_deviation(&self, at: Option) -> RpcResult; + async fn calculate_inventory_deviation(&self, at: Option) -> RpcResult; #[method(name = "ob_fetchCheckpoint")] - fn fetch_checkpoint(&self, at: Option) -> RpcResult; + async fn fetch_checkpoint(&self, at: Option) -> RpcResult; } /// A structure that represents the Polkadex OCEX pallet RPC, which allows querying @@ -142,7 +142,7 @@ where Ok(json) } - fn calculate_inventory_deviation( + async fn calculate_inventory_deviation( &self, at: Option<::Hash>, ) -> RpcResult { @@ -153,7 +153,7 @@ where None => self.client.info().best_hash, }; let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); - if !offchain_storage.acquire_offchain_lock(3) { + if !offchain_storage.acquire_offchain_lock(3).await { return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")) } let runtime_api_result = @@ -163,7 +163,10 @@ where Ok(json) } - fn fetch_checkpoint(&self, at: Option<::Hash>) -> RpcResult { + async fn fetch_checkpoint( + &self, + at: Option<::Hash>, + ) -> RpcResult { self.deny_unsafe.check_if_safe()?; let api = self.client.runtime_api(); let at = match at { @@ -171,7 +174,7 @@ where None => self.client.info().best_hash, }; let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); - if !offchain_storage.acquire_offchain_lock(3) { + if !offchain_storage.acquire_offchain_lock(3).await { return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")) } let ob_checkpoint_raw = api diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index 1ea1a4506..84e5fcae1 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -25,7 +25,7 @@ impl OffchainStorageAdapter { /// * `tries`: Number of tries to acquire lock /// # Returns /// * `bool`: True if lock is acquired else false - pub fn acquire_offchain_lock(&self, tries: u8) -> bool { + pub async fn acquire_offchain_lock(&self, tries: u8) -> bool { let prefix = sp_offchain::STORAGE_PREFIX; let old_value = Encode::encode(&false); let new_value = Encode::encode(&true); @@ -39,7 +39,7 @@ impl OffchainStorageAdapter { return true } // Wait for 1 sec - std::thread::sleep(std::time::Duration::from_secs(1)); + tokio::time::sleep(std::time::Duration::from_secs(1)).await; } false } From 90064e1145a7f754a60cf385af253c9bb7e513dc Mon Sep 17 00:00:00 2001 From: zktony Date: Fri, 1 Sep 2023 12:35:24 +0530 Subject: [PATCH 73/91] Resolved comments --- pallets/ocex/rpc/src/lib.rs | 3 ++- pallets/thea/src/validation.rs | 11 +++++------ primitives/orderbook/src/lib.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 84d66213c..8e1ba361b 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -39,6 +39,7 @@ use sp_runtime::traits::Block as BlockT; use std::sync::Arc; const RUNTIME_ERROR: i32 = 1; +const RETRIES: u8 = 3; #[rpc(client, server)] pub trait PolkadexOcexRpcApi { @@ -174,7 +175,7 @@ where None => self.client.info().best_hash, }; let offchain_storage = offchain::OffchainStorageAdapter::new(self.storage.clone()); - if !offchain_storage.acquire_offchain_lock(3).await { + if !offchain_storage.acquire_offchain_lock(RETRIES).await { return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")) } let ob_checkpoint_raw = api diff --git a/pallets/thea/src/validation.rs b/pallets/thea/src/validation.rs index ae4b663c0..4e08b702d 100644 --- a/pallets/thea/src/validation.rs +++ b/pallets/thea/src/validation.rs @@ -12,7 +12,6 @@ impl Pallet { /// Starts the offchain worker instance that checks for finalized next incoming messages /// for both solochain and parachain, signs it and submits to aggregator pub fn run_thea_validation(_blk: T::BlockNumber) -> Result<(), &'static str> { - //TODO: Find better way to replace u64 if !sp_io::offchain::is_validator() { return Ok(()) } @@ -25,7 +24,7 @@ impl Pallet { // state let next_incoming_nonce = >::get(network).saturating_add(1); let next_outgoing_nonce = - AggregatorClient::::get_latest_incoming_nonce_parachain().saturating_add(1); //TODO: Replace with Parachain Struct object + AggregatorClient::::get_latest_incoming_nonce_parachain().saturating_add(1); log::debug!(target:"thea","Next Incoming nonce: {:?}, Outgoing nonce: {:?} for network: {:?}", next_incoming_nonce,next_outgoing_nonce,network); // b. Check if payload for N is available at source and destination on its finalized @@ -34,23 +33,23 @@ impl Pallet { next_incoming_nonce, network, Destination::Parachain, - ); //TODO: Replace with Parachain Struct object + ); let next_outgoing_message = AggregatorClient::::get_payload_for_nonce( next_outgoing_nonce, network, Destination::Solochain, - ); //TODO: Replace with Parachain Struct object + ); // c. Compute who should sign this and if its us then sign the payload if let Some(message) = next_incoming_message { // d. store the signed payload on-chain for relayers to relay it to destination - Resolver::::compute_signer_and_submit(message, Destination::Solochain)?; //TODO: Replace with + Resolver::::compute_signer_and_submit(message, Destination::Solochain)?; // Resolver Struct // object } else { log::debug!(target:"thea","No incoming message with nonce: {:?} from network: {:?}",next_incoming_nonce,network); } if let Some(message) = next_outgoing_message { - Resolver::::compute_signer_and_submit(message, Destination::Parachain)?; //TODO: Replace with + Resolver::::compute_signer_and_submit(message, Destination::Parachain)?; // Resolver Struct // object } else { diff --git a/primitives/orderbook/src/lib.rs b/primitives/orderbook/src/lib.rs index f9015922c..e955d07e2 100644 --- a/primitives/orderbook/src/lib.rs +++ b/primitives/orderbook/src/lib.rs @@ -163,10 +163,10 @@ impl ObCheckpointRaw { /// # Returns /// * `ObCheckpoint`: A new `ObCheckpoint` instance. #[cfg(feature = "std")] - pub fn to_checkpoint(&self) -> ObCheckpoint { + pub fn to_checkpoint(self) -> ObCheckpoint { ObCheckpoint { snapshot_id: self.snapshot_id, - balances: self.balances.clone(), + balances: self.balances, last_processed_block_number: self.last_processed_block_number, state_change_id: self.state_change_id, } From 9f0df457559f1551d64f01727fa6528f8b8bf766 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 4 Sep 2023 08:50:20 +0530 Subject: [PATCH 74/91] Added docs --- pallets/ocex/src/aggregator.rs | 18 ++++++++++++++++++ pallets/ocex/src/rpc.rs | 18 ++++++++++++++++++ pallets/ocex/src/storage.rs | 18 ++++++++++++++++++ pallets/ocex/src/validator.rs | 18 ++++++++++++++++++ pallets/thea/src/aggregator.rs | 18 ++++++++++++++++++ pallets/thea/src/resolver.rs | 18 ++++++++++++++++++ pallets/thea/src/validation.rs | 28 +++++++++++++++++++++++----- 7 files changed, 131 insertions(+), 5 deletions(-) diff --git a/pallets/ocex/src/aggregator.rs b/pallets/ocex/src/aggregator.rs index 8c3d3aeff..689295f74 100644 --- a/pallets/ocex/src/aggregator.rs +++ b/pallets/ocex/src/aggregator.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use crate::{ validator::{JSONRPCResponse, AGGREGATOR, LAST_PROCESSED_SNAPSHOT}, Config, diff --git a/pallets/ocex/src/rpc.rs b/pallets/ocex/src/rpc.rs index 2d4db1110..9fedf0cca 100644 --- a/pallets/ocex/src/rpc.rs +++ b/pallets/ocex/src/rpc.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use crate::{ pallet::{Accounts, AllowlistedToken, IngressMessages}, storage::OffchainState, diff --git a/pallets/ocex/src/storage.rs b/pallets/ocex/src/storage.rs index 007a539d0..126cbf390 100644 --- a/pallets/ocex/src/storage.rs +++ b/pallets/ocex/src/storage.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use crate::validator::map_trie_error; use hash_db::{AsHashDB, HashDB, Prefix}; use sp_core::{Hasher, H256}; diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 650b8f09a..2c4129bf3 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use crate::{ aggregator::AggregatorClient, pallet::ValidatorSetId, diff --git a/pallets/thea/src/aggregator.rs b/pallets/thea/src/aggregator.rs index d1e2f76af..d68265426 100644 --- a/pallets/thea/src/aggregator.rs +++ b/pallets/thea/src/aggregator.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use crate::{resolver::Resolver, Config}; use parity_scale_codec::{alloc::string::ToString, Decode, Encode}; use scale_info::prelude::string::String; diff --git a/pallets/thea/src/resolver.rs b/pallets/thea/src/resolver.rs index 40b25a5d1..4f3f04f49 100644 --- a/pallets/thea/src/resolver.rs +++ b/pallets/thea/src/resolver.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use crate::{validation::JSONRPCResponse, Authorities, Config, ValidatorSetId}; use parity_scale_codec::{alloc::string::ToString, Encode}; use scale_info::prelude::string::String; diff --git a/pallets/thea/src/validation.rs b/pallets/thea/src/validation.rs index 4e08b702d..744382953 100644 --- a/pallets/thea/src/validation.rs +++ b/pallets/thea/src/validation.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use crate::{ aggregator::AggregatorClient, pallet::{ActiveNetworks, IncomingNonce}, @@ -39,19 +57,19 @@ impl Pallet { network, Destination::Solochain, ); - // c. Compute who should sign this and if its us then sign the payload + // c. Compute who should sign this and if its us then sign the payload if let Some(message) = next_incoming_message { // d. store the signed payload on-chain for relayers to relay it to destination Resolver::::compute_signer_and_submit(message, Destination::Solochain)?; - // Resolver Struct - // object + // Resolver Struct + // object } else { log::debug!(target:"thea","No incoming message with nonce: {:?} from network: {:?}",next_incoming_nonce,network); } if let Some(message) = next_outgoing_message { Resolver::::compute_signer_and_submit(message, Destination::Parachain)?; - // Resolver Struct - // object + // Resolver Struct + // object } else { log::debug!(target:"thea","No outgoing message with nonce: {:?} to network: {:?}",next_outgoing_nonce,network); } From 209891339195c530f74286351477415035452684 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 4 Sep 2023 08:52:29 +0530 Subject: [PATCH 75/91] Added doc --- pallets/ocex/rpc/src/offchain.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index 84e5fcae1..4044cba40 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -1,3 +1,21 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2022-2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + use parity_scale_codec::Encode; use parking_lot::RwLock; use sp_core::offchain::OffchainStorage; From 79853e57800ad56fcf07c9ed96af6be46546c8f3 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 4 Sep 2023 08:54:45 +0530 Subject: [PATCH 76/91] added mod level doc --- pallets/ocex/rpc/src/offchain.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/ocex/rpc/src/offchain.rs b/pallets/ocex/rpc/src/offchain.rs index 4044cba40..625b911a7 100644 --- a/pallets/ocex/rpc/src/offchain.rs +++ b/pallets/ocex/rpc/src/offchain.rs @@ -16,6 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +//! # Offchain Storage Adapter +//! This module provides an adapter to access offchain storage. +//! This adapter is used by `function_handler` to access offchain storage. + use parity_scale_codec::Encode; use parking_lot::RwLock; use sp_core::offchain::OffchainStorage; From 30f8a304f152acbc1ee1d1e3767d7c333dce6741 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 5 Sep 2023 19:34:20 +0530 Subject: [PATCH 77/91] Handle checkpoint --- pallets/ocex/src/aggregator.rs | 28 ++++++++++++-- pallets/ocex/src/storage.rs | 4 ++ pallets/ocex/src/validator.rs | 70 +++++++++++++++++++++++++++------- 3 files changed, 85 insertions(+), 17 deletions(-) diff --git a/pallets/ocex/src/aggregator.rs b/pallets/ocex/src/aggregator.rs index 689295f74..d15335707 100644 --- a/pallets/ocex/src/aggregator.rs +++ b/pallets/ocex/src/aggregator.rs @@ -20,10 +20,7 @@ use crate::{ validator::{JSONRPCResponse, AGGREGATOR, LAST_PROCESSED_SNAPSHOT}, Config, }; -use orderbook_primitives::{ - types::{ApprovedSnapshot, UserActionBatch}, - SnapshotSummary, -}; +use orderbook_primitives::{types::{ApprovedSnapshot, UserActionBatch}, SnapshotSummary, ObCheckpointRaw}; use parity_scale_codec::{alloc::string::ToString, Decode, Encode}; use sp_application_crypto::RuntimeAppPublic; use sp_core::offchain::{Duration, HttpError}; @@ -110,6 +107,29 @@ impl AggregatorClient { } } + pub fn get_checkpoint() -> Option { + let body = serde_json::json!({}).to_string(); + let result = match Self::send_request( + "checkpoint", + &(AGGREGATOR.to_owned() + "/checkpoint"), + &body, + ) { + Ok(encoded_checkpoint) => encoded_checkpoint, + Err(err) => { + log::error!(target:"ocex","Error fetching checkpoint: {:?}",err); + return None + }, + }; + + match ObCheckpointRaw::decode(&mut &result[..]) { + Ok(checkpoint) => Some(checkpoint), + Err(_) => { + log::error!(target:"ocex","Unable to decode checkpoint"); + None + }, + } + } + /// Send request to aggregator /// # Parameters /// * `log_target`: Log target for debug logs diff --git a/pallets/ocex/src/storage.rs b/pallets/ocex/src/storage.rs index 126cbf390..0a46adc26 100644 --- a/pallets/ocex/src/storage.rs +++ b/pallets/ocex/src/storage.rs @@ -69,6 +69,10 @@ impl<'a> OffchainState<'a> { self.cache.insert(key, value); } + pub fn insert_all(&mut self, cache: sp_std::collections::btree_map::BTreeMap, Vec>) { + self.cache = cache; + } + pub fn commit(&mut self) -> Result { for (key, value) in self.cache.iter() { self.trie.insert(key, value).map_err(map_trie_error)?; diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 2c4129bf3..965612f19 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -16,18 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{ - aggregator::AggregatorClient, - pallet::ValidatorSetId, - settlement::{add_balance, process_trade, sub_balance}, - snapshot::StateInfo, - storage::{store_trie_root, OffchainState}, - Config, Pallet, SnapshotNonce, -}; -use orderbook_primitives::{ - types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, - SnapshotSummary, -}; +use crate::{aggregator::AggregatorClient, pallet::ValidatorSetId, settlement::{add_balance, process_trade, sub_balance}, snapshot::StateInfo, storage::{store_trie_root, OffchainState}, Config, Pallet, SnapshotNonce, Snapshots}; +use orderbook_primitives::{types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, SnapshotSummary, ObCheckpointRaw}; use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::{ingress::IngressMessages, withdrawal::Withdrawal, AssetId}; use rust_decimal::Decimal; @@ -47,6 +37,7 @@ pub const LAST_PROCESSED_SNAPSHOT: [u8; 26] = *b"offchain-ocex::snapshot_id"; /// As a future improvment, we can make it decentralized, by having the community run /// such aggregation endpoints pub const AGGREGATOR: &str = "https://ob.aggregator.polkadex.trade"; +pub const CHECKPOINT_BLOCKS: u64 = 1260; impl Pallet { /// Runs the offchain worker computes the next batch of user actions and @@ -92,7 +83,7 @@ impl Pallet { }, }; - let last_processed_nonce = state_info.snapshot_id; + let mut last_processed_nonce = state_info.snapshot_id; // Check if we already processed this snapshot and updated our offchain state. if last_processed_nonce == next_nonce { @@ -104,6 +95,37 @@ impl Pallet { log::info!(target:"ocex","last_processed_nonce: {:?}, next_nonce: {:?}",last_processed_nonce, next_nonce); + if next_nonce.saturating_sub(last_processed_nonce) >= CHECKPOINT_BLOCKS { + let checkpoint = AggregatorClient::::get_checkpoint(); + let (computed_root, checkpoint) = match checkpoint { + None => { + log::error!(target:"ocex","No checkpoint found"); + return Err("No checkpoint found") + }, + Some(checkpoint) => { + match Self::process_checkpoint(&mut state, checkpoint.clone()) { + Ok(_) => { + let computed_root = state.commit()?; + (computed_root, checkpoint) + }, + Err(err) => { + log::error!(target:"ocex","Error processing checkpoint: {:?}",err); + return Err("Sync failed") + }, + } + }, + }; + let snapshot_summary = >::get(checkpoint.snapshot_id).ok_or("Snapshot not found")?; + if snapshot_summary.state_hash != computed_root { + log::error!(target:"ocex","State root mismatch: {:?} != {:?}",snapshot_summary.state_hash, computed_root); + return Err("State root mismatch") + } + store_trie_root(computed_root); + last_processed_nonce = snapshot_summary.snapshot_id; + // Update params from checkpoint + Self::update_state_info(&mut state_info, checkpoint); + } + if next_nonce.saturating_sub(last_processed_nonce) >= 2 { if state_info.last_block == 0 { state_info.last_block = 4768083; // This is hard coded as the starting point @@ -332,6 +354,28 @@ impl Pallet { Ok(withdrawals) } + pub fn process_checkpoint(state: &mut OffchainState, checkpoint: ObCheckpointRaw) -> Result<(), &'static str> { + log::info!(target:"ocex","Processing checkpoint: {:?}",checkpoint.snapshot_id); + for (account_asset, balance) in checkpoint.balances { + let key = account_asset.main.to_raw_vec(); + let mut value = match state.get(&key)? { + None => BTreeMap::new(), + Some(encoded) => BTreeMap::decode(&mut &encoded[..]) + .map_err(|_| "Unable to decode balances for account")?, + }; + value.insert(account_asset.asset, balance); + state.insert(key, value.encode()); + } + Ok(()) + } + + pub fn update_state_info(state_info: &mut StateInfo, checkpoint: ObCheckpointRaw) { + state_info.snapshot_id = checkpoint.snapshot_id; + state_info.stid = checkpoint.state_change_id; + state_info.last_block = checkpoint.last_processed_block_number; + + } + /// Loads the state info from the offchain state pub fn load_state_info(state: &mut OffchainState) -> Result { match state.get(&STATE_INFO.to_vec())? { From 46ed03f1d31c51e6c05e220aa697ada8e1e81129 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 5 Sep 2023 19:46:59 +0530 Subject: [PATCH 78/91] Fixed formatting --- pallets/ocex/src/aggregator.rs | 10 ++++++++-- pallets/ocex/src/storage.rs | 5 ++++- pallets/ocex/src/validator.rs | 34 +++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/pallets/ocex/src/aggregator.rs b/pallets/ocex/src/aggregator.rs index d15335707..768459610 100644 --- a/pallets/ocex/src/aggregator.rs +++ b/pallets/ocex/src/aggregator.rs @@ -20,7 +20,10 @@ use crate::{ validator::{JSONRPCResponse, AGGREGATOR, LAST_PROCESSED_SNAPSHOT}, Config, }; -use orderbook_primitives::{types::{ApprovedSnapshot, UserActionBatch}, SnapshotSummary, ObCheckpointRaw}; +use orderbook_primitives::{ + types::{ApprovedSnapshot, UserActionBatch}, + ObCheckpointRaw, SnapshotSummary, +}; use parity_scale_codec::{alloc::string::ToString, Decode, Encode}; use sp_application_crypto::RuntimeAppPublic; use sp_core::offchain::{Duration, HttpError}; @@ -107,11 +110,14 @@ impl AggregatorClient { } } + /// Load checkpoint from aggregator + /// # Returns + /// * `Option`: Loaded checkpoint or None if error occured pub fn get_checkpoint() -> Option { let body = serde_json::json!({}).to_string(); let result = match Self::send_request( "checkpoint", - &(AGGREGATOR.to_owned() + "/checkpoint"), + &(AGGREGATOR.to_owned() + "/latest_checkpoint"), &body, ) { Ok(encoded_checkpoint) => encoded_checkpoint, diff --git a/pallets/ocex/src/storage.rs b/pallets/ocex/src/storage.rs index 0a46adc26..134d74bbb 100644 --- a/pallets/ocex/src/storage.rs +++ b/pallets/ocex/src/storage.rs @@ -69,7 +69,10 @@ impl<'a> OffchainState<'a> { self.cache.insert(key, value); } - pub fn insert_all(&mut self, cache: sp_std::collections::btree_map::BTreeMap, Vec>) { + pub fn insert_all( + &mut self, + cache: sp_std::collections::btree_map::BTreeMap, Vec>, + ) { self.cache = cache; } diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 965612f19..72445617b 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -16,8 +16,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{aggregator::AggregatorClient, pallet::ValidatorSetId, settlement::{add_balance, process_trade, sub_balance}, snapshot::StateInfo, storage::{store_trie_root, OffchainState}, Config, Pallet, SnapshotNonce, Snapshots}; -use orderbook_primitives::{types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, SnapshotSummary, ObCheckpointRaw}; +use crate::{ + aggregator::AggregatorClient, + pallet::ValidatorSetId, + settlement::{add_balance, process_trade, sub_balance}, + snapshot::StateInfo, + storage::{store_trie_root, OffchainState}, + Config, Pallet, SnapshotNonce, Snapshots, +}; +use orderbook_primitives::{ + types::{ApprovedSnapshot, Trade, UserActionBatch, UserActions, WithdrawalRequest}, + ObCheckpointRaw, SnapshotSummary, +}; use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::{ingress::IngressMessages, withdrawal::Withdrawal, AssetId}; use rust_decimal::Decimal; @@ -68,7 +78,6 @@ impl Pallet { } // Check the next batch to process let next_nonce = >::get().saturating_add(1); - let mut root = crate::storage::load_trie_root(); log::info!(target:"ocex","block: {:?}, state_root {:?}", block_num, root); let mut storage = crate::storage::State; @@ -97,12 +106,12 @@ impl Pallet { if next_nonce.saturating_sub(last_processed_nonce) >= CHECKPOINT_BLOCKS { let checkpoint = AggregatorClient::::get_checkpoint(); - let (computed_root, checkpoint) = match checkpoint { + let (computed_root, checkpoint) = match checkpoint { None => { log::error!(target:"ocex","No checkpoint found"); return Err("No checkpoint found") }, - Some(checkpoint) => { + Some(checkpoint) => match Self::process_checkpoint(&mut state, checkpoint.clone()) { Ok(_) => { let computed_root = state.commit()?; @@ -112,10 +121,10 @@ impl Pallet { log::error!(target:"ocex","Error processing checkpoint: {:?}",err); return Err("Sync failed") }, - } - }, + }, }; - let snapshot_summary = >::get(checkpoint.snapshot_id).ok_or("Snapshot not found")?; + let snapshot_summary = + >::get(checkpoint.snapshot_id).ok_or("Snapshot not found")?; if snapshot_summary.state_hash != computed_root { log::error!(target:"ocex","State root mismatch: {:?} != {:?}",snapshot_summary.state_hash, computed_root); return Err("State root mismatch") @@ -125,7 +134,6 @@ impl Pallet { // Update params from checkpoint Self::update_state_info(&mut state_info, checkpoint); } - if next_nonce.saturating_sub(last_processed_nonce) >= 2 { if state_info.last_block == 0 { state_info.last_block = 4768083; // This is hard coded as the starting point @@ -354,7 +362,11 @@ impl Pallet { Ok(withdrawals) } - pub fn process_checkpoint(state: &mut OffchainState, checkpoint: ObCheckpointRaw) -> Result<(), &'static str> { + /// Processes a checkpoint, updating the offchain state accordingly. + pub fn process_checkpoint( + state: &mut OffchainState, + checkpoint: ObCheckpointRaw, + ) -> Result<(), &'static str> { log::info!(target:"ocex","Processing checkpoint: {:?}",checkpoint.snapshot_id); for (account_asset, balance) in checkpoint.balances { let key = account_asset.main.to_raw_vec(); @@ -369,11 +381,11 @@ impl Pallet { Ok(()) } + /// Updates the state info pub fn update_state_info(state_info: &mut StateInfo, checkpoint: ObCheckpointRaw) { state_info.snapshot_id = checkpoint.snapshot_id; state_info.stid = checkpoint.state_change_id; state_info.last_block = checkpoint.last_processed_block_number; - } /// Loads the state info from the offchain state From 24931d5e22a8fdb18a78fee7470303abd0be1041 Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 5 Sep 2023 20:02:42 +0530 Subject: [PATCH 79/91] Fixed clippy --- primitives/orderbook/src/recovery.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/primitives/orderbook/src/recovery.rs b/primitives/orderbook/src/recovery.rs index 396f2f8e8..022be3afb 100644 --- a/primitives/orderbook/src/recovery.rs +++ b/primitives/orderbook/src/recovery.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::types::AccountAsset; +use crate::{types::AccountAsset, ObCheckpointRaw}; use parity_scale_codec::{Decode, Encode}; use polkadex_primitives::{AccountId, BlockNumber}; use rust_decimal::Decimal; @@ -57,3 +57,15 @@ pub struct ObCheckpoint { /// State change id pub state_change_id: u64, } + +impl ObCheckpoint { + /// Convert to raw checkpoint + pub fn to_raw(&self) -> ObCheckpointRaw { + ObCheckpointRaw { + snapshot_id: self.snapshot_id, + balances: self.balances.clone(), + last_processed_block_number: self.last_processed_block_number, + state_change_id: self.state_change_id, + } + } +} From eb8e77df407d5d5f447ce1949318effca6541a2e Mon Sep 17 00:00:00 2001 From: zktony Date: Wed, 6 Sep 2023 10:28:38 +0530 Subject: [PATCH 80/91] Removed insert_all --- pallets/ocex/src/storage.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pallets/ocex/src/storage.rs b/pallets/ocex/src/storage.rs index 134d74bbb..126cbf390 100644 --- a/pallets/ocex/src/storage.rs +++ b/pallets/ocex/src/storage.rs @@ -69,13 +69,6 @@ impl<'a> OffchainState<'a> { self.cache.insert(key, value); } - pub fn insert_all( - &mut self, - cache: sp_std::collections::btree_map::BTreeMap, Vec>, - ) { - self.cache = cache; - } - pub fn commit(&mut self) -> Result { for (key, value) in self.cache.iter() { self.trie.insert(key, value).map_err(map_trie_error)?; From 75f8a7f0e8d5efecb957283460734f2cae0c37db Mon Sep 17 00:00:00 2001 From: zktony Date: Thu, 7 Sep 2023 11:58:39 +0530 Subject: [PATCH 81/91] Added logs --- pallets/ocex/src/lib.rs | 2 ++ pallets/ocex/src/validator.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pallets/ocex/src/lib.rs b/pallets/ocex/src/lib.rs index 28114945c..f321408e9 100644 --- a/pallets/ocex/src/lib.rs +++ b/pallets/ocex/src/lib.rs @@ -1322,6 +1322,7 @@ pub mod pallet { /// Fetch checkpoint for recovery pub fn fetch_checkpoint() -> Result { + log::debug!(target:"ocex", "fetch_checkpoint called"); let account_id = >::iter().fold(vec![], |mut ids_accum, (acc, acc_info)| { ids_accum.push((acc.clone(), acc_info.proxies)); @@ -1341,6 +1342,7 @@ pub mod pallet { let last_processed_block_number = state_info.last_block; let snapshot_id = state_info.snapshot_id; let state_change_id = state_info.stid; + log::debug!(target:"ocex", "fetch_checkpoint returning"); Ok(ObCheckpointRaw::new( snapshot_id, balances, diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 72445617b..6bbe1bdc7 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -105,6 +105,7 @@ impl Pallet { log::info!(target:"ocex","last_processed_nonce: {:?}, next_nonce: {:?}",last_processed_nonce, next_nonce); if next_nonce.saturating_sub(last_processed_nonce) >= CHECKPOINT_BLOCKS { + log::debug!(target:"ocex","Fetching checkpoint from Aggregator"); let checkpoint = AggregatorClient::::get_checkpoint(); let (computed_root, checkpoint) = match checkpoint { None => { @@ -123,12 +124,14 @@ impl Pallet { }, }, }; + log::debug!(target:"ocex","Checkpoint processed: {:?}",checkpoint.snapshot_id); let snapshot_summary = >::get(checkpoint.snapshot_id).ok_or("Snapshot not found")?; if snapshot_summary.state_hash != computed_root { log::error!(target:"ocex","State root mismatch: {:?} != {:?}",snapshot_summary.state_hash, computed_root); return Err("State root mismatch") } + log::debug!(target:"ocex","State root matched: {:?}",snapshot_summary.state_hash); store_trie_root(computed_root); last_processed_nonce = snapshot_summary.snapshot_id; // Update params from checkpoint @@ -386,6 +389,7 @@ impl Pallet { state_info.snapshot_id = checkpoint.snapshot_id; state_info.stid = checkpoint.state_change_id; state_info.last_block = checkpoint.last_processed_block_number; + log::debug!(target:"ocex","Updated state_info"); } /// Loads the state info from the offchain state From 834227544013e1b73b3a9519351ca22066d3615b Mon Sep 17 00:00:00 2001 From: zktony Date: Thu, 7 Sep 2023 14:25:33 +0530 Subject: [PATCH 82/91] Commented deny upsafe --- pallets/ocex/rpc/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 8e1ba361b..6c747b802 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -168,7 +168,7 @@ where &self, at: Option<::Hash>, ) -> RpcResult { - self.deny_unsafe.check_if_safe()?; + //self.deny_unsafe.check_if_safe()?; let api = self.client.runtime_api(); let at = match at { Some(at) => at, From 828fd1e5036798b278059ce41efd4cee050b19d9 Mon Sep 17 00:00:00 2001 From: zktony Date: Thu, 7 Sep 2023 15:33:46 +0530 Subject: [PATCH 83/91] Updated offchain worker --- pallets/ocex/src/validator.rs | 41 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 72445617b..3350ea93f 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -111,17 +111,19 @@ impl Pallet { log::error!(target:"ocex","No checkpoint found"); return Err("No checkpoint found") }, - Some(checkpoint) => - match Self::process_checkpoint(&mut state, checkpoint.clone()) { - Ok(_) => { - let computed_root = state.commit()?; - (computed_root, checkpoint) - }, - Err(err) => { - log::error!(target:"ocex","Error processing checkpoint: {:?}",err); - return Err("Sync failed") - }, + Some(checkpoint) => match Self::process_checkpoint(&mut state, &checkpoint) { + Ok(_) => { + // Update params from checkpoint + Self::update_state_info(&mut state_info, &checkpoint); + Self::store_state_info(state_info, &mut state); + let computed_root = state.commit()?; //TODO: Reset state, if it is stale + (computed_root, checkpoint) + }, + Err(err) => { + log::error!(target:"ocex","Error processing checkpoint: {:?}",err); + return Err("Sync failed") }, + }, }; let snapshot_summary = >::get(checkpoint.snapshot_id).ok_or("Snapshot not found")?; @@ -131,8 +133,6 @@ impl Pallet { } store_trie_root(computed_root); last_processed_nonce = snapshot_summary.snapshot_id; - // Update params from checkpoint - Self::update_state_info(&mut state_info, checkpoint); } if next_nonce.saturating_sub(last_processed_nonce) >= 2 { if state_info.last_block == 0 { @@ -330,6 +330,15 @@ impl Pallet { Ok(withdrawal) } + // Process bacth + // Commit + // Process B2 + // Commit + + //Fetch checkpoint + //Processing It + //Commting + /// Processes a batch of user actions, updating the offchain state accordingly. fn process_batch( state: &mut OffchainState, @@ -365,24 +374,24 @@ impl Pallet { /// Processes a checkpoint, updating the offchain state accordingly. pub fn process_checkpoint( state: &mut OffchainState, - checkpoint: ObCheckpointRaw, + checkpoint: &ObCheckpointRaw, ) -> Result<(), &'static str> { log::info!(target:"ocex","Processing checkpoint: {:?}",checkpoint.snapshot_id); - for (account_asset, balance) in checkpoint.balances { + for (account_asset, balance) in &checkpoint.balances { let key = account_asset.main.to_raw_vec(); let mut value = match state.get(&key)? { None => BTreeMap::new(), Some(encoded) => BTreeMap::decode(&mut &encoded[..]) .map_err(|_| "Unable to decode balances for account")?, }; - value.insert(account_asset.asset, balance); + value.insert(account_asset.asset, *balance); state.insert(key, value.encode()); } Ok(()) } /// Updates the state info - pub fn update_state_info(state_info: &mut StateInfo, checkpoint: ObCheckpointRaw) { + pub fn update_state_info(state_info: &mut StateInfo, checkpoint: &ObCheckpointRaw) { state_info.snapshot_id = checkpoint.snapshot_id; state_info.stid = checkpoint.state_change_id; state_info.last_block = checkpoint.last_processed_block_number; From e17c1fd46a194ef2e570c83d66d8f42f8bb72012 Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 7 Sep 2023 13:04:32 +0300 Subject: [PATCH 84/91] Increment spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 3401f0627..73822ff28 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 308, + spec_version: 310, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 65f79f69a779a8a948ab19797310999d983e719a Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 7 Sep 2023 13:21:16 +0300 Subject: [PATCH 85/91] Fix TODO --- pallets/ocex/src/validator.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 3350ea93f..f39f231e8 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -106,6 +106,11 @@ impl Pallet { if next_nonce.saturating_sub(last_processed_nonce) >= CHECKPOINT_BLOCKS { let checkpoint = AggregatorClient::::get_checkpoint(); + // We load a new trie when the state is stale. + drop(state); + root = H256::zero(); + storage = crate::storage::State; + state = OffchainState::load(&mut storage, &mut root); let (computed_root, checkpoint) = match checkpoint { None => { log::error!(target:"ocex","No checkpoint found"); @@ -116,7 +121,7 @@ impl Pallet { // Update params from checkpoint Self::update_state_info(&mut state_info, &checkpoint); Self::store_state_info(state_info, &mut state); - let computed_root = state.commit()?; //TODO: Reset state, if it is stale + let computed_root = state.commit()?; (computed_root, checkpoint) }, Err(err) => { From 382115cadf86ba208d1d98c94737effee2d36ffc Mon Sep 17 00:00:00 2001 From: Gautham Date: Thu, 7 Sep 2023 13:58:08 +0300 Subject: [PATCH 86/91] Fix Deviation RPC --- pallets/ocex/rpc/src/lib.rs | 21 ++++++++++++++++----- primitives/orderbook/src/recovery.rs | 15 ++++++++++++++- scripts/check_deviation.sh | 7 +++++++ 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100755 scripts/check_deviation.sh diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 6c747b802..59036b1b2 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -24,9 +24,10 @@ pub mod offchain; use jsonrpsee::{ core::{async_trait, Error as JsonRpseeError, RpcResult}, proc_macros::rpc, + tracing::log, types::error::{CallError, ErrorObject}, }; -use orderbook_primitives::recovery::{ObCheckpoint, ObRecoveryState}; +use orderbook_primitives::recovery::{DeviationMap, ObCheckpoint, ObRecoveryState}; pub use pallet_ocex_runtime_api::PolkadexOcexRuntimeApi; use parity_scale_codec::{Codec, Decode}; use parking_lot::RwLock; @@ -157,10 +158,19 @@ where if !offchain_storage.acquire_offchain_lock(3).await { return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock")) } - let runtime_api_result = - api.calculate_inventory_deviation(at).map_err(runtime_error_into_rpc_err)?; - let json = - serde_json::to_string(&runtime_api_result).map_err(runtime_error_into_rpc_err)?; + log::info!(target:"ocex","calculating the inventory deviation.."); + let deviation = + match api.calculate_inventory_deviation(at).map_err(runtime_error_into_rpc_err)? { + Err(err) => { + log::error!(target:"ocex","Error calling calculate_inventory_deviation: {:?}",err); + return Err(runtime_error_into_rpc_err( + "Error calling calculate_inventory_deviation ", + )) + }, + Ok(deviation_map) => DeviationMap::new(deviation_map), + }; + log::info!(target:"ocex","serializing the deviation map.."); + let json = serde_json::to_string(&deviation).map_err(runtime_error_into_rpc_err)?; Ok(json) } @@ -189,6 +199,7 @@ where /// Converts a runtime trap into an RPC error. fn runtime_error_into_rpc_err(err: impl std::fmt::Debug) -> JsonRpseeError { + log::error!(target:"ocex","runtime rpc error: {:?} ",err); CallError::Custom(ErrorObject::owned(RUNTIME_ERROR, "Runtime error", Some(format!("{err:?}")))) .into() } diff --git a/primitives/orderbook/src/recovery.rs b/primitives/orderbook/src/recovery.rs index 022be3afb..bfb3dbc42 100644 --- a/primitives/orderbook/src/recovery.rs +++ b/primitives/orderbook/src/recovery.rs @@ -18,7 +18,7 @@ use crate::{types::AccountAsset, ObCheckpointRaw}; use parity_scale_codec::{Decode, Encode}; -use polkadex_primitives::{AccountId, BlockNumber}; +use polkadex_primitives::{AccountId, AssetId, BlockNumber}; use rust_decimal::Decimal; use scale_info::TypeInfo; use serde_with::{json::JsonString, serde_as}; @@ -69,3 +69,16 @@ impl ObCheckpoint { } } } + +#[serde_as] +#[derive(Clone, Debug, Encode, Decode, Default, serde::Serialize, serde::Deserialize, TypeInfo)] +pub struct DeviationMap { + #[serde_as(as = "JsonString>")] + map: BTreeMap, +} + +impl DeviationMap { + pub fn new(map: BTreeMap) -> Self { + Self { map } + } +} diff --git a/scripts/check_deviation.sh b/scripts/check_deviation.sh new file mode 100755 index 000000000..408a12fb2 --- /dev/null +++ b/scripts/check_deviation.sh @@ -0,0 +1,7 @@ + +curl -H "Content-Type: application/json" -d '{ + "jsonrpc":"2.0", + "id":1, + "method":"ob_inventoryDeviation", + "params":[] +}' http://localhost:9944 From 6e9cfb6d828ff3747b3aeae92b7f175a722ac871 Mon Sep 17 00:00:00 2001 From: zktony Date: Sun, 10 Sep 2023 13:25:26 +0530 Subject: [PATCH 87/91] Resolved Serhi's comments --- pallets/ocex/rpc/src/lib.rs | 2 +- pallets/ocex/src/validator.rs | 9 --------- primitives/orderbook/src/recovery.rs | 4 ++++ scripts/check_deviation.sh | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pallets/ocex/rpc/src/lib.rs b/pallets/ocex/rpc/src/lib.rs index 59036b1b2..fd5d57706 100644 --- a/pallets/ocex/rpc/src/lib.rs +++ b/pallets/ocex/rpc/src/lib.rs @@ -178,7 +178,7 @@ where &self, at: Option<::Hash>, ) -> RpcResult { - //self.deny_unsafe.check_if_safe()?; + //self.deny_unsafe.check_if_safe()?; //As it is used by the aggregator, we need to allow it let api = self.client.runtime_api(); let at = match at { Some(at) => at, diff --git a/pallets/ocex/src/validator.rs b/pallets/ocex/src/validator.rs index 976d30ec4..447edaadb 100644 --- a/pallets/ocex/src/validator.rs +++ b/pallets/ocex/src/validator.rs @@ -338,15 +338,6 @@ impl Pallet { Ok(withdrawal) } - // Process bacth - // Commit - // Process B2 - // Commit - - //Fetch checkpoint - //Processing It - //Commting - /// Processes a batch of user actions, updating the offchain state accordingly. fn process_batch( state: &mut OffchainState, diff --git a/primitives/orderbook/src/recovery.rs b/primitives/orderbook/src/recovery.rs index bfb3dbc42..2f151f22d 100644 --- a/primitives/orderbook/src/recovery.rs +++ b/primitives/orderbook/src/recovery.rs @@ -70,6 +70,7 @@ impl ObCheckpoint { } } +/// A struct representing the deviation map to detect anomalies in the User balance. #[serde_as] #[derive(Clone, Debug, Encode, Decode, Default, serde::Serialize, serde::Deserialize, TypeInfo)] pub struct DeviationMap { @@ -78,6 +79,9 @@ pub struct DeviationMap { } impl DeviationMap { + /// Create a new `DeviationMap` instance. + /// # Parameters + /// * `map`: A `BTreeMap` that maps `AssetId`s to `Decimal` balances. pub fn new(map: BTreeMap) -> Self { Self { map } } diff --git a/scripts/check_deviation.sh b/scripts/check_deviation.sh index 408a12fb2..c59d7e628 100755 --- a/scripts/check_deviation.sh +++ b/scripts/check_deviation.sh @@ -1,4 +1,4 @@ - +#!/bin/bash curl -H "Content-Type: application/json" -d '{ "jsonrpc":"2.0", "id":1, From ca2961db4ec741648871dfd54e86546420ad65ae Mon Sep 17 00:00:00 2001 From: Serhii Temchenko Date: Sun, 10 Sep 2023 14:47:38 -0700 Subject: [PATCH 88/91] fix(ci): Used different method to install taplo since old fails with errors --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bef597fa..6e2655632 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,9 @@ jobs: default: true components: rustfmt, clippy - name: Install .toml files linter - run: cargo install taplo-cli + run: | + curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-linux-x86_64.gz \ + | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo - name: Checkout to the current branch uses: actions/checkout@v3 - name: Cache Rust Dependencies From bbe2ed9edd3e66d9274cd6de255a600f1513cf72 Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 15 Sep 2023 13:35:42 +0300 Subject: [PATCH 89/91] Add script for temp node --- scripts/start_temp_node.sh | 1 + 1 file changed, 1 insertion(+) create mode 100755 scripts/start_temp_node.sh diff --git a/scripts/start_temp_node.sh b/scripts/start_temp_node.sh new file mode 100755 index 000000000..1ddcae42c --- /dev/null +++ b/scripts/start_temp_node.sh @@ -0,0 +1 @@ +../target/release/polkadex-node --tmp --chain=../extras/customSpecRaw.json --sync=warp \ No newline at end of file From 5182f32f614dccb099ad52ce00b97f286a394a7a Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 20 Oct 2023 21:33:51 +0530 Subject: [PATCH 90/91] Update OB GovernanceOrigin --- runtime/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 73822ff28..896c4da99 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 310, + spec_version: 311, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -1279,7 +1279,7 @@ impl pallet_ocex_lmp::Config for Runtime { type OtherAssets = Assets; type EnclaveOrigin = EnsureSigned; type AuthorityId = pallet_ocex_lmp::sr25519::AuthorityId; - type GovernanceOrigin = EnsureRootOrHalfOrderbookCouncil; + type GovernanceOrigin = EnsureRootOrHalfCouncil; type WeightInfo = pallet_ocex_lmp::weights::WeightInfo; } From 918836b38c48a6215fdcecb333698b987f625633 Mon Sep 17 00:00:00 2001 From: Gautham Date: Fri, 20 Oct 2023 21:37:54 +0530 Subject: [PATCH 91/91] Add check deviation binary --- Cargo.toml | 4 +- scripts/check-off-on-deviation/Cargo.lock | 4365 ++++++++++++++++++++ scripts/check-off-on-deviation/Cargo.toml | 12 + scripts/check-off-on-deviation/src/main.rs | 90 + scripts/get_balance_rpc.sh | 7 + 5 files changed, 4477 insertions(+), 1 deletion(-) create mode 100644 scripts/check-off-on-deviation/Cargo.lock create mode 100644 scripts/check-off-on-deviation/Cargo.toml create mode 100644 scripts/check-off-on-deviation/src/main.rs create mode 100755 scripts/get_balance_rpc.sh diff --git a/Cargo.toml b/Cargo.toml index e85b72410..1e4d14743 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,9 @@ members = [ "misc/load-testing", "misc/crowdloan-verifier", ] - +exclude = [ + "scripts/check-off-on-deviation", +] default-members = [ "client", "node", diff --git a/scripts/check-off-on-deviation/Cargo.lock b/scripts/check-off-on-deviation/Cargo.lock new file mode 100644 index 000000000..b07ec7af5 --- /dev/null +++ b/scripts/check-off-on-deviation/Cargo.lock @@ -0,0 +1,4365 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli 0.27.3", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli 0.28.0", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.10", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom 0.2.10", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "array-bytes" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-trait" +version = "0.1.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line 0.21.0", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object 0.32.1", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +dependencies = [ + "serde", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive", + "hashbrown 0.13.2", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "bounded-collections" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "bytecheck" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-expr" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "check-off-on-deviation" +version = "0.1.0" +dependencies = [ + "anyhow", + "jsonrpsee", + "orderbook-primitives", + "tokio", +] + +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.48.5", +] + +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-entity" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40099d38061b37e505e63f89bab52199037a72b931ad4868d9089ff7268660b0" +dependencies = [ + "serde", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.7", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "curve25519-dalek" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" +dependencies = [ + "byteorder", + "digest 0.8.1", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.37", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +dependencies = [ + "serde", +] + +[[package]] +name = "derive-syn-parse" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[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.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature 2.1.0", + "spki", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature 1.6.4", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "elliptic-curve" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array 0.14.7", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "expander" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "frame-metadata" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" +dependencies = [ + "cfg-if", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "frame-support" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "bitflags 1.3.2", + "environmental", + "frame-metadata", + "frame-support-procedural", + "impl-trait-for-tuples", + "k256", + "log", + "once_cell", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-core-hashing-proc-macro", + "sp-debug-derive", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-weights", + "tt-call", +] + +[[package]] +name = "frame-support-procedural" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "Inflector", + "cfg-expr", + "derive-syn-parse", + "frame-support-procedural-tools", + "itertools", + "proc-macro-warning", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "frame-system" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "cfg-if", + "frame-support", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-version", + "sp-weights", +] + +[[package]] +name = "fs-err" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +dependencies = [ + "gloo-timers", + "send_wrapper", +] + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +dependencies = [ + "fallible-iterator", + "indexmap 1.9.3", + "stable_deref_trait", +] + +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + +[[package]] +name = "gloo-net" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils", + "http", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "gloo-utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 1.9.3", + "slab", + "tokio", + "tokio-util", + "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 = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.7", + "hmac 0.8.1", +] + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.4.9", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +dependencies = [ + "futures-util", + "http", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[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 = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "js-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonrpsee" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ad9b31183a8bcbe843e32ca8554ad2936633548d95a7bb6a8e14c767dea6b05" +dependencies = [ + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-http-client", + "jsonrpsee-proc-macros", + "jsonrpsee-types", + "jsonrpsee-wasm-client", + "jsonrpsee-ws-client", + "tracing", +] + +[[package]] +name = "jsonrpsee-client-transport" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97f2743cad51cc86b0dbfe316309eeb87a9d96a3d7f4dd7a99767c4b5f065335" +dependencies = [ + "futures-channel", + "futures-util", + "gloo-net", + "http", + "jsonrpsee-core", + "pin-project", + "rustls-native-certs", + "soketto", + "thiserror", + "tokio", + "tokio-rustls", + "tokio-util", + "tracing", + "url", + "webpki-roots", +] + +[[package]] +name = "jsonrpsee-core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35dc957af59ce98373bcdde0c1698060ca6c2d2e9ae357b459c7158b6df33330" +dependencies = [ + "anyhow", + "async-lock", + "async-trait", + "beef", + "futures-timer", + "futures-util", + "hyper", + "jsonrpsee-types", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "wasm-bindgen-futures", +] + +[[package]] +name = "jsonrpsee-http-client" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd865d0072764cb937b0110a92b5f53e995f7101cb346beca03d93a2dea79de" +dependencies = [ + "async-trait", + "hyper", + "hyper-rustls", + "jsonrpsee-core", + "jsonrpsee-types", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "tracing", + "url", +] + +[[package]] +name = "jsonrpsee-proc-macros" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cef91b1017a4edb63f65239381c18de39f88d0e0760ab626d806e196f7f51477" +dependencies = [ + "heck", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "jsonrpsee-types" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa9e25aec855b2a7d3ed90fded6c41e8c3fb72b63f071e1be3f0004eba19b625" +dependencies = [ + "anyhow", + "beef", + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "jsonrpsee-wasm-client" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010306151579898dc1000bab239ef7a73a73f04cb8ef267ee28b9a000267e813" +dependencies = [ + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", +] + +[[package]] +name = "jsonrpsee-ws-client" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d88e35e9dfa89248ae3e92f689c1f0a190ce12d377eba7d2d08e5a7f6cc5694a" +dependencies = [ + "http", + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", + "url", +] + +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.7", +] + +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" + +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64 0.13.1", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "linux-raw-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" + +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix 0.38.14", +] + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +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 = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +dependencies = [ + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.48.0", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec 0.7.4", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +dependencies = [ + "crc32fast", + "hashbrown 0.13.2", + "indexmap 1.9.3", + "memchr", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "orderbook-primitives" +version = "1.1.0" +dependencies = [ + "anyhow", + "chrono", + "log", + "parity-scale-codec", + "polkadex-primitives", + "primitive-types", + "rand 0.8.5", + "rust_decimal", + "scale-info", + "serde", + "serde_with", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "parity-scale-codec" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +dependencies = [ + "arrayvec 0.7.4", + "bitvec", + "byte-slice-cast", + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "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_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "polkadex-primitives" +version = "1.1.0" +dependencies = [ + "anyhow", + "frame-support", + "frame-system", + "parity-scale-codec", + "primitive-types", + "rust_decimal", + "scale-info", + "serde", + "sp-application-crypto", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primitive-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +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", +] + +[[package]] +name = "proc-macro-warning" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "proc-macro2" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.10", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "ref-cast" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "regex" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.3.8", + "regex-syntax 0.7.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]] +name = "regex-automata" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.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.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "rend" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rkyv" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +dependencies = [ + "bitvec", + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.30.0" +source = "git+https://github.com/Polkadex-Substrate/rust-decimal.git?branch=master#25f084996a7c941593aa1d2d8711e8218c391563" +dependencies = [ + "arrayvec 0.7.4", + "borsh", + "bytecheck", + "byteorder", + "bytes", + "num-traits", + "parity-scale-codec", + "parity-scale-codec-derive", + "rand 0.8.5", + "rkyv", + "scale-info", + "serde", + "serde_json", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustix" +version = "0.36.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustix" +version = "0.38.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.7", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustls" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.4", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "scale-info" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "schannel" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "schnellru" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" +dependencies = [ + "ahash 0.8.3", + "cfg-if", + "hashbrown 0.13.2", +] + +[[package]] +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.3", + "getrandom 0.1.16", + "merlin", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.2", + "subtle", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array 0.14.7", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +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 = "security-framework" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "serde" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "serde_json" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +dependencies = [ + "base64 0.13.1", + "chrono", + "hex", + "indexmap 1.9.3", + "serde", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "sha-1" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "soketto" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" +dependencies = [ + "base64 0.13.1", + "bytes", + "futures", + "httparse", + "log", + "rand 0.8.5", + "sha-1", +] + +[[package]] +name = "sp-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "scale-info", + "sp-api-proc-macro", + "sp-core", + "sp-metadata-ir", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "sp-version", + "thiserror", +] + +[[package]] +name = "sp-api-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "Inflector", + "blake2", + "expander", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "sp-application-crypto" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-arithmetic" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-core" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes", + "bitflags 1.3.2", + "blake2", + "bounded-collections", + "bs58", + "dyn-clonable", + "ed25519-zebra", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "parity-scale-codec", + "parking_lot", + "paste", + "primitive-types", + "rand 0.8.5", + "regex", + "scale-info", + "schnorrkel", + "secp256k1", + "secrecy", + "serde", + "sp-core-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "zeroize", +] + +[[package]] +name = "sp-core-hashing" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.7", + "sha2 0.10.7", + "sha3", + "sp-std", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing-proc-macro" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro2", + "quote", + "sp-core-hashing", + "syn 2.0.37", +] + +[[package]] +name = "sp-debug-derive" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "sp-externalities" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std", + "sp-storage", +] + +[[package]] +name = "sp-inherents" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-io" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "bytes", + "ed25519", + "ed25519-dalek", + "futures", + "libsecp256k1", + "log", + "parity-scale-codec", + "rustversion", + "secp256k1", + "sp-core", + "sp-externalities", + "sp-keystore", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keystore" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "parity-scale-codec", + "parking_lot", + "sp-core", + "sp-externalities", + "thiserror", +] + +[[package]] +name = "sp-metadata-ir" +version = "0.1.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-metadata", + "parity-scale-codec", + "scale-info", + "sp-std", +] + +[[package]] +name = "sp-panic-handler" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-runtime" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "paste", + "rand 0.8.5", + "scale-info", + "serde", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-weights", +] + +[[package]] +name = "sp-runtime-interface" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "primitive-types", + "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 = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "Inflector", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "sp-staking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-state-machine" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "parking_lot", + "rand 0.8.5", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-std", + "sp-trie", + "thiserror", + "tracing", +] + +[[package]] +name = "sp-std" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" + +[[package]] +name = "sp-storage" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-tracing" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "sp-std", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-trie" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ahash 0.8.3", + "hash-db", + "hashbrown 0.13.2", + "lazy_static", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot", + "scale-info", + "schnellru", + "sp-core", + "sp-std", + "thiserror", + "tracing", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-version" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-core-hashing-proc-macro", + "sp-runtime", + "sp-std", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "sp-wasm-interface" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std", + "wasmi", + "wasmtime", +] + +[[package]] +name = "sp-weights" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ss58-registry" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "substrate-bip39" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +dependencies = [ + "hmac 0.11.0", + "pbkdf2 0.8.0", + "schnorrkel", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "target-lexicon" +version = "0.12.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" + +[[package]] +name = "thiserror" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +dependencies = [ + "deranged", + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", +] + +[[package]] +name = "tiny-bip39" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" +dependencies = [ + "anyhow", + "hmac 0.12.1", + "once_cell", + "pbkdf2 0.11.0", + "rand 0.8.5", + "rustc-hash", + "sha2 0.10.7", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2 0.5.4", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +dependencies = [ + "bytes", + "futures-core", + "futures-io", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.0.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "trie-db" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" +dependencies = [ + "hash-db", + "hashbrown 0.13.2", + "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]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "tt-call" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "digest 0.10.7", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.37", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" + +[[package]] +name = "wasmi" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" +dependencies = [ + "parity-wasm", + "wasmi-validation", + "wasmi_core", +] + +[[package]] +name = "wasmi-validation" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "wasmi_core" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" +dependencies = [ + "downcast-rs", + "libm", + "memory_units", + "num-rational", + "num-traits", +] + +[[package]] +name = "wasmparser" +version = "0.102.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" +dependencies = [ + "indexmap 1.9.3", + "url", +] + +[[package]] +name = "wasmtime" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f907fdead3153cb9bfb7a93bbd5b62629472dc06dee83605358c64c52ed3dda9" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "indexmap 1.9.3", + "libc", + "log", + "object 0.30.4", + "once_cell", + "paste", + "psm", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-environ", + "wasmtime-jit", + "wasmtime-runtime", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b9daa7c14cd4fa3edbf69de994408d5f4b7b0959ac13fa69d465f6597f810d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-environ" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli 0.27.3", + "indexmap 1.9.3", + "log", + "object 0.30.4", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" +dependencies = [ + "addr2line 0.19.0", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli 0.27.3", + "log", + "object 0.30.4", + "rustc-demangle", + "serde", + "target-lexicon", + "wasmtime-environ", + "wasmtime-jit-icache-coherence", + "wasmtime-runtime", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" +dependencies = [ + "once_cell", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aecae978b13f7f67efb23bd827373ace4578f2137ec110bbf6a4a7cde4121bbd" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-runtime" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658cf6f325232b6760e202e5255d823da5e348fdea827eff0a2a22319000b441" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "indexmap 1.9.3", + "libc", + "log", + "mach", + "memfd", + "memoffset", + "paste", + "rand 0.8.5", + "rustix 0.36.15", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-jit-debug", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-types" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + +[[package]] +name = "web-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "winnow" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] diff --git a/scripts/check-off-on-deviation/Cargo.toml b/scripts/check-off-on-deviation/Cargo.toml new file mode 100644 index 000000000..987021abf --- /dev/null +++ b/scripts/check-off-on-deviation/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "check-off-on-deviation" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.75" +jsonrpsee = {version = "0.20.1", features = ["client","macros"]} +orderbook-primitives = { version = "1.1.0", path = "../../primitives/orderbook" } +tokio = { version = "1.27", features = ["rt-multi-thread", "macros", "time"] } diff --git a/scripts/check-off-on-deviation/src/main.rs b/scripts/check-off-on-deviation/src/main.rs new file mode 100644 index 000000000..8b6df143e --- /dev/null +++ b/scripts/check-off-on-deviation/src/main.rs @@ -0,0 +1,90 @@ +// This file is part of Polkadex. +// +// Copyright (c) 2023 Polkadex oü. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program 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. +// +// This program 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 this program. If not, see . + +//! Maintains an `JsonrpseeApiClient` client and calls necessary `JsonrpseeApiClient` requests +//! methods when required by different modules. The client is initialized in main module. + +use std::collections::BTreeMap; +use jsonrpsee::{ + core::client::ClientT, + rpc_params, + ws_client::{WsClient, WsClientBuilder}, +}; +use orderbook_primitives::recovery::ObRecoveryState; + +use std::sync::Arc; + +/// A Jsonrpsee client for blockchain used by block relayer to get required data from chain. +pub struct JsonrpseeApiClient { + pub client: Arc, + pub url: String, +} + +impl JsonrpseeApiClient { + /// A WebSocket client is created using the WsClientBuilder and the resulting client is stored + /// in an Arc (atomic reference counted) pointer to allow for shared ownership across threads. + pub async fn new(blockchain_url: &str) -> anyhow::Result { + let client = WsClientBuilder::default().build(blockchain_url).await?; + Ok(Self { + client: Arc::new(client), + url: blockchain_url.to_string(), + }) + } + + /// Retrieves the current OB recovery state from the engine. + /// Returns the recovery state as an `ObRecoveryState` object if successful. + /// + /// Returns + /// + /// `anyhow::Result`: The state at which engine should be recovered + pub async fn get_recovery_state(&mut self) -> anyhow::Result { + // Start the connection again + self.client = Arc::new(WsClientBuilder::default().build(self.url.as_str()).await?); + + // Retrieve the recovery state from the engine + Ok(self + .client + .request::("ob_getRecoverState", rpc_params![]) + .await?) + } +} + +#[tokio::test] +pub async fn test_parse_recovery() { + let mut client = JsonrpseeApiClient::new("wss://fullnode.polkadex.trade:443") + .await + .unwrap(); + client.get_recovery_state().await.unwrap(); +} + + +#[tokio::main] +async fn main() { + let mut client = JsonrpseeApiClient::new("ws://localhost:9944").await.unwrap(); + + let ob_state = client.get_recovery_state().await.unwrap(); + + let mut assets = BTreeMap::new(); + + for (acc_asset,total) in ob_state.balances{ + assets.entry(acc_asset.asset).and_modify(|amt | { + *amt +=total + }).or_insert(total); + } + println!("Offchain -balance: {:?}",assets); +} \ No newline at end of file diff --git a/scripts/get_balance_rpc.sh b/scripts/get_balance_rpc.sh new file mode 100755 index 000000000..ab3721ddc --- /dev/null +++ b/scripts/get_balance_rpc.sh @@ -0,0 +1,7 @@ +#!/bin/bash +curl -H "Content-Type: application/json" -d '{ + "jsonrpc":"2.0", + "id":1, + "method":"ob_getBalance", + "params":["esqcMH7tgSpFQ8vivW42yZezgEzxD1ye9YXaW7MLDtQb1KNs4",{"asset":"3496813586714279103986568049643838918"}] +}' http://localhost:9944