From 36504f49b81ea0bdc58cad8e9009a6736add8af7 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Tue, 3 May 2022 16:21:04 -0400 Subject: [PATCH 01/24] feat: add ledger sync protocol Signed-off-by: Brandon H. Gomes --- pallets/manta-pay/src/lib.rs | 192 +++++++++++++++++++++++---------- pallets/manta-pay/src/types.rs | 13 +-- 2 files changed, 142 insertions(+), 63 deletions(-) diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index 788e88df6..e9c16212c 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -71,7 +71,7 @@ use manta_crypto::{ constraint::ProofSystem, merkle_tree::{self, forest::Configuration as _}, }; -use manta_pay::config; +use manta_pay::{config, signer::Checkpoint}; use manta_primitives::{ assets::{AssetConfig, FungibleLedger as _, FungibleLedgerError}, types::{AssetId, Balance}, @@ -132,40 +132,29 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet {} - /// Shards of the merkle tree of UTXOs + /// UTXOs and Encrypted Notes Grouped by Shard #[pallet::storage] pub(super) type Shards = StorageDoubleMap<_, Identity, u8, Identity, u64, ([u8; 32], EncryptedNote), ValueQuery>; - /// Shard merkle trees + /// Shard Merkle Tree Paths #[pallet::storage] pub(super) type ShardTrees = StorageMap<_, Identity, u8, UtxoMerkleTreePath, ValueQuery>; - /// Outputs of Utxo accumulator + /// Outputs of Utxo Accumulator #[pallet::storage] pub(super) type UtxoAccumulatorOutputs = StorageMap<_, Identity, [u8; 32], (), ValueQuery>; - /// Utxo set of MantaPay protocol + /// UTXO Set #[pallet::storage] pub(super) type UtxoSet = StorageMap<_, Identity, [u8; 32], (), ValueQuery>; - /// Void number set + /// Void Number Set #[pallet::storage] pub(super) type VoidNumberSet = StorageMap<_, Identity, [u8; 32], (), ValueQuery>; - /// Void number set insertion order - /// Each element of the key is an `u64` insertion order number of void number. - #[pallet::storage] - pub(super) type VoidNumberSetInsertionOrder = - StorageMap<_, Identity, u64, [u8; 32], ValueQuery>; - - /// The size of Void Number Set - /// FIXME: this should be removed. - #[pallet::storage] - pub(super) type VoidNumberSetSize = StorageValue<_, u64, ValueQuery>; - #[pallet::call] impl Pallet { /// Transforms some public assets into private ones using `post`, withdrawing the public @@ -174,15 +163,7 @@ pub mod pallet { #[transactional] pub fn to_private(origin: OriginFor, post: TransferPost) -> DispatchResultWithPostInfo { let origin = ensure_signed(origin)?; - let mut ledger = Self::ledger(); - Self::deposit_event( - config::TransferPost::try_from(post) - .map_err(|_| Error::::InvalidSerializedForm)? - .post(vec![origin], vec![], &(), &mut ledger) - .map_err(Error::::from)? - .convert(None), - ); - Ok(().into()) + Self::post_transaction(None, vec![origin], vec![], post) } /// Transforms some private assets into public ones using `post`, depositing the public @@ -191,15 +172,7 @@ pub mod pallet { #[transactional] pub fn to_public(origin: OriginFor, post: TransferPost) -> DispatchResultWithPostInfo { let origin = ensure_signed(origin)?; - let mut ledger = Self::ledger(); - Self::deposit_event( - config::TransferPost::try_from(post) - .map_err(|_| Error::::InvalidSerializedForm)? - .post(vec![], vec![origin], &(), &mut ledger) - .map_err(Error::::from)? - .convert(None), - ); - Ok(().into()) + Self::post_transaction(None, vec![], vec![origin], post) } /// Transfers private assets encoded in `post`. @@ -215,15 +188,7 @@ pub mod pallet { post: TransferPost, ) -> DispatchResultWithPostInfo { let origin = ensure_signed(origin)?; - let mut ledger = Self::ledger(); - Self::deposit_event( - config::TransferPost::try_from(post) - .map_err(|_| Error::::InvalidSerializedForm)? - .post(vec![], vec![], &(), &mut ledger) - .map_err(Error::::from)? - .convert(Some(origin)), - ); - Ok(().into()) + Self::post_transaction(Some(origin), vec![], vec![], post) } /// Transfers public `asset` from `origin` to the `sink` account. @@ -480,19 +445,140 @@ pub mod pallet { where T: Config, { - /// Returns the ledger implementation for this pallet. + /// Maximum Number of Updates per Shard + const PULL_MAX_PER_SHARD_UPDATE_SIZE: usize = 128; + + /// Maximum Size of Sender Data Update + const PULL_MAX_SENDER_UPDATE_SIZE: usize = 1024; + + /// Pulls receiver data from the ledger starting at the `receiver_index`. + #[inline] + fn pull_receivers( + receiver_index: &mut [usize; 256], + ) -> Result<(bool, ReceiverChunk), scale_codec::Error> { + let mut more_receivers = false; + let mut receivers = Vec::new(); + for (i, index) in receiver_index.iter_mut().enumerate() { + more_receivers |= Self::pull_receivers_for_shard(i as u8, index, &mut receivers)?; + } + Ok((more_receivers, receivers)) + } + + /// Pulls receiver data from the shard at `shard_index` starting at the `receiver_index`, + /// pushing the results back to `receivers`. #[inline] - fn ledger() -> Ledger { - Ledger(PhantomData) + fn pull_receivers_for_shard( + shard_index: u8, + receiver_index: &mut usize, + receivers: &mut ReceiverChunk, + ) -> Result { + let mut iter = if *receiver_index == 0 { + Shards::::iter_prefix(shard_index) + } else { + let raw_key = Shards::::hashed_key_for(shard_index, *receiver_index as u64 - 1); + Shards::::iter_prefix_from(shard_index, raw_key) + }; + for _ in 0..Self::PULL_MAX_PER_SHARD_UPDATE_SIZE { + match iter.next() { + Some((_, (utxo, encrypted_note))) => { + *receiver_index += 1; + receivers.push((decode(utxo)?, encrypted_note.try_into()?)); + } + _ => return Ok(false), + } + } + Ok(iter.next().is_some()) + } + + /// Pulls sender data from the ledger starting at the `sender_index`. + #[inline] + fn pull_senders( + sender_index: &mut usize, + ) -> Result<(bool, SenderChunk), scale_codec::Error> { + let mut senders = Vec::new(); + let mut iter = VoidNumberSet::::iter().skip(*sender_index); + for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { + match iter.next() { + Some((sender, _)) => { + *sender_index += 1; + senders.push(decode(sender)?); + } + _ => return Ok((false, senders)), + } + } + Ok((iter.next().is_some(), senders)) } - /// The account ID of AssetManager + /// Returns the update required to be synchronized with the ledger starting from + /// `checkpoint`. + #[inline] + pub fn pull(mut checkpoint: Checkpoint) -> Result { + let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index)?; + let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index)?; + Ok(PullResponse { + should_continue: more_receivers || more_senders, + checkpoint, + receivers, + senders, + }) + } + + /// Returns the account ID of this pallet. + #[inline] pub fn account_id() -> T::AccountId { T::PalletId::get().into_account() } + + /// Posts the transaction encoded in `post` to the ledger, using `sources` and `sinks` as + /// the public deposit and public withdraw accounts respectively. + #[inline] + fn post_transaction( + origin: Option, + sources: Vec, + sinks: Vec, + post: TransferPost, + ) -> DispatchResultWithPostInfo { + Self::deposit_event( + config::TransferPost::try_from(post) + .map_err(|_| Error::::InvalidSerializedForm)? + .post(sources, sinks, &(), &mut Ledger(PhantomData)) + .map_err(Error::::from)? + .convert(origin), + ); + Ok(().into()) + } } } +/// Receiver Chunk Data +pub type ReceiverChunk = Vec<(config::Utxo, config::EncryptedNote)>; + +/// Sender Chunk Data +pub type SenderChunk = Vec; + +/// Pull Response +#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)] +pub struct PullResponse { + /// Pull Continuation Flag + /// + /// The `should_continue` flag is set to `true` if the client should request more data from the + /// ledger to finish the pull. + pub should_continue: bool, + + /// Ledger Checkpoint + /// + /// If the `should_continue` flag is set to `true` then `checkpoint` is the next + /// [`Checkpoint`](Connection::Checkpoint) to request data from the ledger. Otherwise, it + /// represents the current ledger state. + pub checkpoint: Checkpoint, + + /// Ledger Receiver Chunk + pub receivers: ReceiverChunk, + + /// Ledger Sender Chunk + pub senders: SenderChunk, +} + /// Preprocessed Event enum PreprocessedEvent where @@ -600,16 +686,8 @@ where I: IntoIterator, { let _ = super_key; - let index = VoidNumberSetSize::::get(); - let mut i = 0; for (_, void_number) in iter { - let void_number = encode(&void_number.0); - VoidNumberSet::::insert(void_number, ()); - VoidNumberSetInsertionOrder::::insert(index + i, void_number); - i += 1; - } - if i != 0 { - VoidNumberSetSize::::set(index + i); + VoidNumberSet::::insert(encode(&void_number.0), ()); } } } diff --git a/pallets/manta-pay/src/types.rs b/pallets/manta-pay/src/types.rs index 4f9976c97..479d7f352 100644 --- a/pallets/manta-pay/src/types.rs +++ b/pallets/manta-pay/src/types.rs @@ -18,6 +18,7 @@ use super::*; use manta_util::into_array_unchecked; +use scale_codec::Error; /// Encodes the SCALE encodable `value` into a byte array with the given length `N`. #[inline] @@ -31,11 +32,11 @@ where /// Decodes the `bytes` array of the given length `N` into the SCALE decodable type `T` returning a /// blanket error if decoding fails. #[inline] -pub(crate) fn decode(bytes: [u8; N]) -> Result +pub(crate) fn decode(bytes: [u8; N]) -> Result where T: Decode, { - T::decode(&mut bytes.as_slice()).map_err(|_| ()) + T::decode(&mut bytes.as_slice()) } /// Asset @@ -101,7 +102,7 @@ impl From for EncryptedNote { } impl TryFrom for config::EncryptedNote { - type Error = (); + type Error = Error; #[inline] fn try_from(encrypted_note: EncryptedNote) -> Result { @@ -133,7 +134,7 @@ impl From for SenderPost { } impl TryFrom for config::SenderPost { - type Error = (); + type Error = Error; #[inline] fn try_from(post: SenderPost) -> Result { @@ -165,7 +166,7 @@ impl From for ReceiverPost { } impl TryFrom for config::ReceiverPost { - type Error = (); + type Error = Error; #[inline] fn try_from(post: ReceiverPost) -> Result { @@ -213,7 +214,7 @@ impl From for TransferPost { } impl TryFrom for config::TransferPost { - type Error = (); + type Error = Error; #[inline] fn try_from(post: TransferPost) -> Result { From 296b2cc7901851049617b4b11435be7155fe741c Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Wed, 4 May 2022 19:04:39 -0400 Subject: [PATCH 02/24] wip: add RPC interfaces for ledger pull Signed-off-by: Brandon H. Gomes --- Cargo.lock | 417 +++++++++++++++++++++------------ node/src/main.rs | 3 + node/src/rpc.rs | 26 +- pallets/manta-pay/Cargo.toml | 31 ++- pallets/manta-pay/src/lib.rs | 124 +--------- pallets/manta-pay/src/rpc.rs | 210 +++++++++++++++++ pallets/manta-pay/src/types.rs | 50 +++- runtime/dolphin/src/lib.rs | 8 + 8 files changed, 566 insertions(+), 303 deletions(-) create mode 100644 pallets/manta-pay/src/rpc.rs diff --git a/Cargo.lock b/Cargo.lock index 7e7c6e1ce..d303f37ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" [[package]] name = "approx" @@ -434,9 +434,9 @@ dependencies = [ [[package]] name = "async-process" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" +checksum = "cf2c06e30a24e8c78a3987d07f0930edf76ef35e027e7bdb063fccafdad1f60c" dependencies = [ "async-io", "blocking", @@ -472,7 +472,7 @@ dependencies = [ "memchr", "num_cpus", "once_cell", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "pin-utils", "slab", "wasm-bindgen-futures", @@ -519,7 +519,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", ] [[package]] @@ -532,7 +532,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", ] [[package]] @@ -584,24 +584,24 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" dependencies = [ "addr2line", "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide 0.4.4", - "object", + "miniz_oxide", + "object 0.28.3", "rustc-demangle", ] [[package]] name = "base-x" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" +checksum = "dc19a4937b4fbd3fe3379793130e42060d10627a360f2127802b10b87e7baf74" [[package]] name = "base58" @@ -1251,7 +1251,7 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", - "semver 1.0.7", + "semver 1.0.9", "serde", "serde_json", ] @@ -1388,7 +1388,7 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", @@ -2210,6 +2210,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "data-encoding" version = "2.3.2" @@ -2527,9 +2562,9 @@ dependencies = [ [[package]] name = "enumn" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e58b112d5099aa0857c5d05f0eacab86406dd8c0f85fe5d320a13256d29ecf4" +checksum = "052bc8773a98bd051ff37db74a8a25f00e6bfa2cbd03373390c72e9f7afbf344" dependencies = [ "proc-macro2", "quote", @@ -2702,7 +2737,7 @@ dependencies = [ "crc32fast", "libc", "libz-sys", - "miniz_oxide 0.5.1", + "miniz_oxide", ] [[package]] @@ -3064,7 +3099,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "waker-fn", ] @@ -3122,7 +3157,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "pin-utils", "slab", ] @@ -3287,9 +3322,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758" +checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" dependencies = [ "ahash", ] @@ -3380,9 +3415,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" +checksum = "ff8670570af52249509a86f5e3e18a08c60b177071826898fde8997cf5f6bfbb" dependencies = [ "bytes 1.1.0", "fnv", @@ -3397,14 +3432,14 @@ checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" dependencies = [ "bytes 1.1.0", "http", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", ] [[package]] name = "httparse" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6330e8a36bd8c859f3fa6d9382911fbb7147ec39807f63b923933a247240b9ba" +checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" [[package]] name = "httpdate" @@ -3434,7 +3469,7 @@ dependencies = [ "httparse", "httpdate", "itoa 1.0.1", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "socket2 0.4.4", "tokio", "tower-service", @@ -3472,6 +3507,12 @@ dependencies = [ "tokio-native-tls", ] +[[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.1.5" @@ -3651,9 +3692,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] name = "itertools" @@ -4083,9 +4124,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.123" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb691a747a7ab48abc15c5b42066eaafde10dc427e3b6ee2a1cf43db04c763bd" +checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" [[package]] name = "libloading" @@ -4648,9 +4689,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859" +checksum = "92e7e15d7610cce1d9752e137625f14e61a28cd45929b6e12e47b50fe154ee2e" dependencies = [ "cc", "pkg-config", @@ -4709,9 +4750,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", "value-bag", @@ -4846,19 +4887,30 @@ dependencies = [ [[package]] name = "manta-accounting" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#0795efe8b779dab5e0e681c30a42a81545e3b509" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" dependencies = [ "derivative", "derive_more", "futures 0.3.21", "indexmap", - "manta-crypto", - "manta-util", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", "parking_lot 0.12.0", "rand 0.8.5", "statrs", ] +[[package]] +name = "manta-accounting" +version = "0.4.0" +source = "git+https://github.com/manta-network/manta-rs.git#ec4470b3f25a7d2e6b8289e0c6f9b3c19be30571" +dependencies = [ + "derivative", + "derive_more", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", +] + [[package]] name = "manta-collator-selection" version = "3.1.5" @@ -4889,17 +4941,27 @@ dependencies = [ [[package]] name = "manta-crypto" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#0795efe8b779dab5e0e681c30a42a81545e3b509" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" +dependencies = [ + "derivative", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "rand_core 0.6.3", +] + +[[package]] +name = "manta-crypto" +version = "0.4.0" +source = "git+https://github.com/manta-network/manta-rs.git#ec4470b3f25a7d2e6b8289e0c6f9b3c19be30571" dependencies = [ "derivative", - "manta-util", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", "rand_core 0.6.3", ] [[package]] name = "manta-pay" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#0795efe8b779dab5e0e681c30a42a81545e3b509" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" dependencies = [ "aes-gcm", "ark-bls12-381", @@ -4914,9 +4976,9 @@ dependencies = [ "ark-std", "blake2 0.10.4", "derivative", - "manta-accounting", - "manta-crypto", - "manta-util", + "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", "parity-scale-codec", "rand_chacha 0.3.1", "scale-info", @@ -4930,7 +4992,7 @@ dependencies = [ "frame-support", "frame-system", "log", - "manta-accounting", + "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", "parity-scale-codec", "scale-info", "smallvec", @@ -5010,7 +5072,7 @@ dependencies = [ [[package]] name = "manta-sdk" version = "0.5.0" -source = "git+https://github.com/manta-network/sdk.git#fef5dc1868f6dea4911c8bb03cb6b29399810063" +source = "git+https://github.com/manta-network/sdk.git#48859513e49f8bd7f78586cc5265225363c260b3" dependencies = [ "anyhow", "attohttpc", @@ -5022,7 +5084,16 @@ dependencies = [ [[package]] name = "manta-util" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#0795efe8b779dab5e0e681c30a42a81545e3b509" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" +dependencies = [ + "serde", + "serde_with", +] + +[[package]] +name = "manta-util" +version = "0.4.0" +source = "git+https://github.com/manta-network/manta-rs.git#ec4470b3f25a7d2e6b8289e0c6f9b3c19be30571" [[package]] name = "maplit" @@ -5062,9 +5133,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" @@ -5166,16 +5237,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - [[package]] name = "miniz_oxide" version = "0.5.1" @@ -5472,9 +5533,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790" dependencies = [ "num-traits", ] @@ -5491,9 +5552,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -5524,9 +5585,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", "libm", @@ -5553,6 +5614,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.10.0" @@ -5602,18 +5672,30 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.38" +version = "0.10.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" +checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" dependencies = [ "bitflags", "cfg-if 1.0.0", "foreign-types", "libc", "once_cell", + "openssl-macros", "openssl-sys", ] +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "openssl-probe" version = "0.1.5" @@ -5622,9 +5704,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.72" +version = "0.9.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" +checksum = "9d5fd19fb3e0a8191c1e34935718976a3e70c112ab9a24af6d7cadccd9d90bc0" dependencies = [ "autocfg", "cc", @@ -6173,19 +6255,24 @@ dependencies = [ "frame-support", "frame-system", "indoc", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", "lazy_static", - "manta-accounting", - "manta-crypto", + "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", "manta-pay", "manta-primitives", "manta-sdk", - "manta-util", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", "pallet-asset-manager", "pallet-assets", "pallet-balances", "parity-scale-codec", "rand 0.8.5", "scale-info", + "sp-api", + "sp-blockchain", "sp-core", "sp-io", "sp-runtime", @@ -6697,9 +6784,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e7f385d61562f5834282b90aa50b41f38a35cf64d5209b8b05487b50553dbe" +checksum = "6e73cd0b0a78045276b19eaae8eaaa20e44a1da9a0217ff934a810d9492ae701" dependencies = [ "blake2-rfc", "crc32fast", @@ -6856,7 +6943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ "lock_api 0.4.7", - "parking_lot_core 0.9.2", + "parking_lot_core 0.9.3", ] [[package]] @@ -6889,9 +6976,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if 1.0.0", "libc", @@ -7043,9 +7130,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -8513,9 +8600,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" dependencies = [ "autocfg", "crossbeam-deque", @@ -8525,14 +8612,13 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", "num_cpus", ] @@ -8577,18 +8663,18 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" +checksum = "685d58625b6c2b83e4cc88a27c4bf65adb7b6b16dbdc413e515c9405b47432ab" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" +checksum = "a043824e29c94169374ac5183ac0ed43f5724dc4556b19568007486bd840fa1f" dependencies = [ "proc-macro2", "quote", @@ -8693,7 +8779,7 @@ dependencies = [ "mime", "native-tls", "percent-encoding 2.1.0", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "serde", "serde_json", "serde_urlencoded", @@ -8887,7 +8973,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.7", + "semver 1.0.9", ] [[package]] @@ -10040,9 +10126,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" +checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" dependencies = [ "serde", ] @@ -10064,9 +10150,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] @@ -10083,9 +10169,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", @@ -10094,9 +10180,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" dependencies = [ "itoa 1.0.1", "ryu", @@ -10115,6 +10201,29 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b827f2113224f3f19a665136f006709194bdfdcb1fdc1e4b2b5cbac8e0cced54" +dependencies = [ + "rustversion", + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sha-1" version = "0.8.2" @@ -11105,6 +11214,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "structopt" version = "0.3.26" @@ -11252,9 +11367,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" +checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52" dependencies = [ "proc-macro2", "quote", @@ -11319,18 +11434,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", @@ -11419,9 +11534,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] @@ -11434,9 +11549,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.17.0" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" +checksum = "dce653fb475565de9f6fb0614b28bca8df2c430c0cf84bcd9c843f15de5414cc" dependencies = [ "bytes 1.1.0", "libc", @@ -11444,7 +11559,7 @@ dependencies = [ "mio 0.8.2", "num_cpus", "once_cell", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "signal-hook-registry", "socket2 0.4.4", "tokio-macros", @@ -11490,7 +11605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3" dependencies = [ "futures-core", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "tokio", ] @@ -11505,7 +11620,7 @@ dependencies = [ "futures-io", "futures-sink", "log", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "tokio", ] @@ -11518,16 +11633,16 @@ dependencies = [ "bytes 1.1.0", "futures-core", "futures-sink", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "tokio", "tracing", ] [[package]] name = "toml" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ "serde", ] @@ -11540,21 +11655,21 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80b9fa4360528139bc96100c160b7ae879f5567f49f1782b0b02035b0358ebf3" +checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" dependencies = [ "cfg-if 1.0.0", - "pin-project-lite 0.2.8", + "pin-project-lite 0.2.9", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" +checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" dependencies = [ "proc-macro2", "quote", @@ -11563,9 +11678,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dfce9f3241b150f36e8e54bb561a742d5daa1a47b5dd9a5ce369fd4a4db2210" +checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" dependencies = [ "lazy_static", "valuable", @@ -11583,9 +11698,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" dependencies = [ "lazy_static", "log", @@ -11632,7 +11747,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" dependencies = [ "hash-db", - "hashbrown 0.12.0", + "hashbrown 0.12.1", "log", "rustc-hex", "smallvec", @@ -11729,9 +11844,9 @@ checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" [[package]] name = "twox-hash" -version = "1.6.2" +version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee73e6e4924fe940354b8d4d98cad5231175d615cd855b758adc658c0aac6a0" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if 1.0.0", "rand 0.8.5", @@ -11773,9 +11888,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-normalization" @@ -11800,9 +11915,9 @@ checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" [[package]] name = "unindent" @@ -11887,9 +12002,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.0.0-alpha.8" +version = "1.0.0-alpha.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79923f7731dc61ebfba3633098bf3ac533bbd35ccd8c57e7088d9a5eebe0263f" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" dependencies = [ "ctor", "version_check", @@ -12110,7 +12225,7 @@ dependencies = [ "lazy_static", "libc", "log", - "object", + "object 0.27.1", "paste", "psm", "rayon", @@ -12162,7 +12277,7 @@ dependencies = [ "gimli", "log", "more-asserts", - "object", + "object 0.27.1", "target-lexicon", "thiserror", "wasmparser", @@ -12181,7 +12296,7 @@ dependencies = [ "indexmap", "log", "more-asserts", - "object", + "object 0.27.1", "serde", "target-lexicon", "thiserror", @@ -12200,7 +12315,7 @@ dependencies = [ "bincode", "cfg-if 1.0.0", "gimli", - "object", + "object 0.27.1", "region", "rustix", "serde", @@ -12452,9 +12567,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ "windows_aarch64_msvc", "windows_i686_gnu", @@ -12465,33 +12580,33 @@ dependencies = [ [[package]] name = "windows_aarch64_msvc" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_i686_gnu" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_msvc" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_x86_64_gnu" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_msvc" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "winreg" @@ -12633,9 +12748,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" dependencies = [ "zeroize_derive", ] diff --git a/node/src/main.rs b/node/src/main.rs index 4ebfa95b9..8485e00b2 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -15,8 +15,11 @@ // along with Manta. If not, see . //! Manta/Calamari Parachain CLI + #![warn(missing_docs)] +extern crate alloc; + mod chain_specs; mod cli; mod command; diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 084da1357..1fff1ff1c 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -16,16 +16,17 @@ //! Parachain-specific RPCs implementation. -use std::sync::Arc; - +use alloc::sync::Arc; +use frame_rpc_system::{FullSystem, SystemApi}; +use manta_primitives::types::{AccountId, Balance, Block, Index as Nonce}; +use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use sc_client_api::AuxStore; -pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use manta_primitives::types::{AccountId, Balance, Block, Index as Nonce}; +pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; /// A type representing all RPC extensions. pub type RpcExtension = jsonrpc_core::IoHandler; @@ -55,24 +56,15 @@ where C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, { - use frame_rpc_system::{FullSystem, SystemApi}; - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; - - let mut io = jsonrpc_core::IoHandler::default(); let FullDeps { client, pool, deny_unsafe, } = deps; - io.extend_with(SystemApi::to_delegate(FullSystem::new( - client.clone(), - pool, - deny_unsafe, - ))); - io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new( - client, - ))); - + let mut io = jsonrpc_core::IoHandler::default(); + io.extend_with(FullSystem::new(client.clone(), pool, deny_unsafe).to_delegate()); + io.extend_with(TransactionPayment::new(client).to_delegate()); + io.extend_with(manta_pay::Pull::new(client).to_delegate()); io } diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index e1e089d01..b2b3856c3 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -62,31 +62,38 @@ tempfile = { version = "3.3.0", optional = true } frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false, optional = true } frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } -sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } scale-codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "1.0.0", default-features = false, features = ["derive"] } +sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } +sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } +sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } + +# JSON-RPC +jsonrpc-core = "18.0.0" +jsonrpc-core-client = "18.0.0" +jsonrpc-derive = "18.0.0" # manta dependencies -manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } -manta-crypto = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } -manta-pay = { git = "https://github.com/manta-network/manta-rs.git", default-features = false, features = ["groth16", "scale"] } +manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false } +manta-crypto = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false } +manta-pay = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false, features = ["groth16", "scale", "serde"] } manta-sdk = { git = "https://github.com/manta-network/sdk.git", default-features = false } -manta-util = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } +manta-util = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false, features = ["serde"] } manta-primitives = { path = "../../primitives", default-features = false} [dev-dependencies] bencher = "0.1.5" criterion = "0.3.4" lazy_static = "1.4.0" -manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", features = ["test"] } +manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", features = ["test"] } +manta-sdk = { git = "https://github.com/manta-network/sdk.git", features = ["download"] } +pallet-asset-manager = { path = "../asset-manager"} +pallet-assets = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } +pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } +rand = "0.8.4" sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16"} sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16"} -pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } -pallet-assets = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } -pallet-asset-manager = { path = "../asset-manager"} -manta-sdk = { git = "https://github.com/manta-network/sdk.git", features = ["download"] } tempfile = "3.3.0" -rand = "0.8.4" xcm = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.16" } diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index e9c16212c..e82032ed3 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -71,7 +71,7 @@ use manta_crypto::{ constraint::ProofSystem, merkle_tree::{self, forest::Configuration as _}, }; -use manta_pay::{config, signer::Checkpoint}; +use manta_pay::config; use manta_primitives::{ assets::{AssetConfig, FungibleLedger as _, FungibleLedgerError}, types::{AssetId, Balance}, @@ -90,12 +90,13 @@ mod mock; #[cfg(test)] mod test; -#[cfg(feature = "runtime-benchmarks")] -pub mod benchmark; - +pub mod rpc; pub mod types; pub mod weights; +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmark; + /// MantaPay Pallet #[frame_support::pallet] pub mod pallet { @@ -135,7 +136,7 @@ pub mod pallet { /// UTXOs and Encrypted Notes Grouped by Shard #[pallet::storage] pub(super) type Shards = - StorageDoubleMap<_, Identity, u8, Identity, u64, ([u8; 32], EncryptedNote), ValueQuery>; + StorageDoubleMap<_, Identity, u8, Identity, u64, (Utxo, EncryptedNote), ValueQuery>; /// Shard Merkle Tree Paths #[pallet::storage] @@ -145,15 +146,15 @@ pub mod pallet { /// Outputs of Utxo Accumulator #[pallet::storage] pub(super) type UtxoAccumulatorOutputs = - StorageMap<_, Identity, [u8; 32], (), ValueQuery>; + StorageMap<_, Identity, UtxoAccumulatorOutput, (), ValueQuery>; /// UTXO Set #[pallet::storage] - pub(super) type UtxoSet = StorageMap<_, Identity, [u8; 32], (), ValueQuery>; + pub(super) type UtxoSet = StorageMap<_, Identity, Utxo, (), ValueQuery>; /// Void Number Set #[pallet::storage] - pub(super) type VoidNumberSet = StorageMap<_, Identity, [u8; 32], (), ValueQuery>; + pub(super) type VoidNumberSet = StorageMap<_, Identity, VoidNumber, (), ValueQuery>; #[pallet::call] impl Pallet { @@ -445,84 +446,6 @@ pub mod pallet { where T: Config, { - /// Maximum Number of Updates per Shard - const PULL_MAX_PER_SHARD_UPDATE_SIZE: usize = 128; - - /// Maximum Size of Sender Data Update - const PULL_MAX_SENDER_UPDATE_SIZE: usize = 1024; - - /// Pulls receiver data from the ledger starting at the `receiver_index`. - #[inline] - fn pull_receivers( - receiver_index: &mut [usize; 256], - ) -> Result<(bool, ReceiverChunk), scale_codec::Error> { - let mut more_receivers = false; - let mut receivers = Vec::new(); - for (i, index) in receiver_index.iter_mut().enumerate() { - more_receivers |= Self::pull_receivers_for_shard(i as u8, index, &mut receivers)?; - } - Ok((more_receivers, receivers)) - } - - /// Pulls receiver data from the shard at `shard_index` starting at the `receiver_index`, - /// pushing the results back to `receivers`. - #[inline] - fn pull_receivers_for_shard( - shard_index: u8, - receiver_index: &mut usize, - receivers: &mut ReceiverChunk, - ) -> Result { - let mut iter = if *receiver_index == 0 { - Shards::::iter_prefix(shard_index) - } else { - let raw_key = Shards::::hashed_key_for(shard_index, *receiver_index as u64 - 1); - Shards::::iter_prefix_from(shard_index, raw_key) - }; - for _ in 0..Self::PULL_MAX_PER_SHARD_UPDATE_SIZE { - match iter.next() { - Some((_, (utxo, encrypted_note))) => { - *receiver_index += 1; - receivers.push((decode(utxo)?, encrypted_note.try_into()?)); - } - _ => return Ok(false), - } - } - Ok(iter.next().is_some()) - } - - /// Pulls sender data from the ledger starting at the `sender_index`. - #[inline] - fn pull_senders( - sender_index: &mut usize, - ) -> Result<(bool, SenderChunk), scale_codec::Error> { - let mut senders = Vec::new(); - let mut iter = VoidNumberSet::::iter().skip(*sender_index); - for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { - match iter.next() { - Some((sender, _)) => { - *sender_index += 1; - senders.push(decode(sender)?); - } - _ => return Ok((false, senders)), - } - } - Ok((iter.next().is_some(), senders)) - } - - /// Returns the update required to be synchronized with the ledger starting from - /// `checkpoint`. - #[inline] - pub fn pull(mut checkpoint: Checkpoint) -> Result { - let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index)?; - let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index)?; - Ok(PullResponse { - should_continue: more_receivers || more_senders, - checkpoint, - receivers, - senders, - }) - } - /// Returns the account ID of this pallet. #[inline] pub fn account_id() -> T::AccountId { @@ -550,35 +473,6 @@ pub mod pallet { } } -/// Receiver Chunk Data -pub type ReceiverChunk = Vec<(config::Utxo, config::EncryptedNote)>; - -/// Sender Chunk Data -pub type SenderChunk = Vec; - -/// Pull Response -#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)] -pub struct PullResponse { - /// Pull Continuation Flag - /// - /// The `should_continue` flag is set to `true` if the client should request more data from the - /// ledger to finish the pull. - pub should_continue: bool, - - /// Ledger Checkpoint - /// - /// If the `should_continue` flag is set to `true` then `checkpoint` is the next - /// [`Checkpoint`](Connection::Checkpoint) to request data from the ledger. Otherwise, it - /// represents the current ledger state. - pub checkpoint: Checkpoint, - - /// Ledger Receiver Chunk - pub receivers: ReceiverChunk, - - /// Ledger Sender Chunk - pub senders: SenderChunk, -} - /// Preprocessed Event enum PreprocessedEvent where diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs new file mode 100644 index 000000000..9910de562 --- /dev/null +++ b/pallets/manta-pay/src/rpc.rs @@ -0,0 +1,210 @@ +// Copyright 2019-2022 Manta Network. +// This file is part of pallet-manta-pay. +// +// pallet-manta-pay 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. +// +// pallet-manta-pay 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 pallet-manta-pay. If not, see . + +//! MantaPay RPC Interfaces + +use crate::{ + types::{decode, EncryptedNote, Utxo, VoidNumber}, + Config, Pallet, Shards, VoidNumberSet, +}; +use alloc::sync::Arc; +use core::marker::PhantomData; +use jsonrpc_core::{Error as RpcError, ErrorCode}; +use jsonrpc_derive::rpc; +use manta_accounting::wallet::ledger; +use manta_pay::{ + config, + signer::{Checkpoint, RawCheckpoint}, +}; +use manta_util::serde::{Deserialize, Serialize}; +use scale_codec::{Decode, Encode, Error as CodecError}; +use scale_info::TypeInfo; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_runtime::{generic::BlockId, traits::Block}; + +/// Pull API +#[rpc(server)] +pub trait PullApi { + /// Returns the update required to be synchronized with the ledger starting from + /// `checkpoint`. + #[rpc(name = "manta_pay_pull")] + fn pull(&self, checkpoint: Checkpoint) -> jsonrpc_core::Result; +} + +/// Receiver Chunk Data Type +pub type ReceiverChunk = Vec<(config::Utxo, config::EncryptedNote)>; + +/// Sender Chunk Data Type +pub type SenderChunk = Vec; + +/// Ledger Source Pull Response +#[derive( + Clone, Debug, Decode, Default, Deserialize, Encode, Eq, Hash, PartialEq, Serialize, TypeInfo, +)] +#[serde(crate = "manta_util::serde", deny_unknown_fields)] +pub struct PullResponse { + /// Pull Continuation Flag + /// + /// The `should_continue` flag is set to `true` if the client should request more data from the + /// ledger to finish the pull. + pub should_continue: bool, + + /// Ledger Checkpoint + /// + /// If the `should_continue` flag is set to `true` then `checkpoint` is the next [`Checkpoint`] + /// to request data from the ledger. Otherwise, it represents the current ledger state. + pub checkpoint: Checkpoint, + + /// Ledger Receiver Chunk + pub receivers: ReceiverChunk, + + /// Ledger Sender Chunk + pub senders: SenderChunk, +} + +impl Pallet +where + T: Config, +{ + /// Maximum Number of Updates per Shard + const PULL_MAX_PER_SHARD_UPDATE_SIZE: usize = 128; + + /// Maximum Size of Sender Data Update + const PULL_MAX_SENDER_UPDATE_SIZE: usize = 1024; + + /// Pulls receiver data from the ledger starting at the `receiver_index`. + #[inline] + fn pull_receivers( + receiver_index: &mut [usize; 256], + ) -> Result<(bool, ReceiverChunk), CodecError> { + let mut more_receivers = false; + let mut receivers = Vec::new(); + for (i, index) in receiver_index.iter_mut().enumerate() { + more_receivers |= Self::pull_receivers_for_shard(i as u8, index, &mut receivers)?; + } + Ok((more_receivers, receivers)) + } + + /// Pulls receiver data from the shard at `shard_index` starting at the `receiver_index`, + /// pushing the results back to `receivers`. + #[inline] + fn pull_receivers_for_shard( + shard_index: u8, + receiver_index: &mut usize, + receivers: &mut ReceiverChunk, + ) -> Result { + let mut iter = if *receiver_index == 0 { + Shards::::iter_prefix(shard_index) + } else { + let raw_key = Shards::::hashed_key_for(shard_index, *receiver_index as u64 - 1); + Shards::::iter_prefix_from(shard_index, raw_key) + }; + for _ in 0..Self::PULL_MAX_PER_SHARD_UPDATE_SIZE { + match iter.next() { + Some((_, (utxo, encrypted_note))) => { + *receiver_index += 1; + receivers.push((decode(utxo)?, encrypted_note)); + } + _ => return Ok(false), + } + } + Ok(iter.next().is_some()) + } + + /// Pulls sender data from the ledger starting at the `sender_index`. + #[inline] + fn pull_senders(sender_index: &mut usize) -> Result<(bool, SenderChunk), CodecError> { + let mut senders = Vec::new(); + let mut iter = VoidNumberSet::::iter().skip(*sender_index); + for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { + match iter.next() { + Some((sender, _)) => { + *sender_index += 1; + senders.push(decode(sender)?); + } + _ => return Ok((false, senders)), + } + } + Ok((iter.next().is_some(), senders)) + } + + /// Returns the update required to be synchronized with the ledger starting from + /// `checkpoint`. + #[inline] + pub fn pull(mut checkpoint: Checkpoint) -> Result { + let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index)?; + let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index)?; + Ok(PullResponse { + should_continue: more_receivers || more_senders, + checkpoint, + receivers, + senders, + }) + } +} + +sp_api::decl_runtime_apis! { + pub trait MantaPayPullRuntimeApi { + fn pull(checkpoint: RawCheckpoint) -> Result; + } +} + +/// Pull RPC API Implementation +pub struct Pull { + /// Client + client: Arc, + + /// Type Parameter Marker + __: PhantomData, +} + +impl Pull { + /// Builds a new [`Pull`] RPC API implementation. + #[inline] + pub fn new(client: Arc) -> Self { + Self { + client, + __: PhantomData, + } + } +} + +impl PullApi for Pull +where + B: Block, + C: 'static + ProvideRuntimeApi + HeaderBackend, + C::Api: MantaPayPullRuntimeApi, +{ + #[inline] + fn pull(&self, checkpoint: Checkpoint) -> jsonrpc_core::Result { + let api = self.client.runtime_api(); + let at = BlockId::hash(self.client.info().best_hash); + match api.pull(&at, checkpoint.into()) { + Ok(Ok(response)) => Ok(response), + Ok(Err(err)) => Err(RpcError { + code: ErrorCode::ServerError(1), + message: "Unable to compute state diff for pull".into(), + data: Some(err.to_string().into()), + }), + Err(err) => Err(RpcError { + code: ErrorCode::ServerError(2), + message: "Error during runtime API".into(), + data: Some(err.to_string().into()), + }), + } + } +} diff --git a/pallets/manta-pay/src/types.rs b/pallets/manta-pay/src/types.rs index 479d7f352..74baec569 100644 --- a/pallets/manta-pay/src/types.rs +++ b/pallets/manta-pay/src/types.rs @@ -17,7 +17,10 @@ //! Type Definitions for Manta Pay use super::*; -use manta_util::into_array_unchecked; +use manta_util::{ + into_array_unchecked, + serde::{Deserialize, Serialize}, +}; use scale_codec::Error; /// Encodes the SCALE encodable `value` into a byte array with the given length `N`. @@ -39,6 +42,24 @@ where T::decode(&mut bytes.as_slice()) } +/// Group Type +pub type Group = [u8; 32]; + +/// UTXO Type +pub type Utxo = [u8; 32]; + +/// Void Number Type +pub type VoidNumber = [u8; 32]; + +/// UTXO Accumulator Output Type +pub type UtxoAccumulatorOutput = [u8; 32]; + +/// Ciphertext Type +pub type Ciphertext = [u8; 68]; + +/// Transfer Proof Type +pub type Proof = [u8; 192]; + /// Asset #[derive( Clone, @@ -72,13 +93,26 @@ impl Asset { } /// Encrypted Note -#[derive(Clone, Debug, Decode, Encode, Eq, Hash, MaxEncodedLen, PartialEq, TypeInfo)] +#[derive( + Clone, + Debug, + Decode, + Deserialize, + Encode, + Eq, + Hash, + MaxEncodedLen, + PartialEq, + Serialize, + TypeInfo, +)] +#[serde(crate = "manta_util::serde", deny_unknown_fields)] pub struct EncryptedNote { /// Ephemeral Public Key - pub ephemeral_public_key: [u8; 32], + pub ephemeral_public_key: Group, /// Ciphertext - pub ciphertext: [u8; 68], + pub ciphertext: Ciphertext, } impl Default for EncryptedNote { @@ -117,10 +151,10 @@ impl TryFrom for config::EncryptedNote { #[derive(Clone, Debug, Decode, Encode, Eq, Hash, MaxEncodedLen, PartialEq, TypeInfo)] pub struct SenderPost { /// UTXO Accumulator Output - pub utxo_accumulator_output: [u8; 32], + pub utxo_accumulator_output: UtxoAccumulatorOutput, /// Void Number - pub void_number: [u8; 32], + pub void_number: VoidNumber, } impl From for SenderPost { @@ -149,7 +183,7 @@ impl TryFrom for config::SenderPost { #[derive(Clone, Debug, Decode, Encode, Eq, Hash, MaxEncodedLen, PartialEq, TypeInfo)] pub struct ReceiverPost { /// Unspent Transaction Output - pub utxo: [u8; 32], + pub utxo: Utxo, /// Encrypted Note pub encrypted_note: EncryptedNote, @@ -196,7 +230,7 @@ pub struct TransferPost { pub sinks: Vec, /// Validity Proof - pub validity_proof: [u8; 192], + pub validity_proof: Proof, } impl From for TransferPost { diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index 0b051daae..15eccbab5 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -1276,6 +1276,14 @@ impl_runtime_apis! { } } + /* TODO: + impl pallet_manta_pay::rpc::MantaPayPullRuntimeApi for Runtime { + fn pull(checkpoint: Checkpoint) -> Result { + todo!() + } + } + */ + #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade() -> (Weight, Weight) { From 792f66e18b2315bd3d26803c47f6f8aa4584d506 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Wed, 4 May 2022 23:59:33 -0400 Subject: [PATCH 03/24] wip: add rpc to node Signed-off-by: Brandon H. Gomes --- Cargo.lock | 8 ++-- pallets/manta-pay/Cargo.toml | 2 +- pallets/manta-pay/src/rpc.rs | 74 ++++++++++++++-------------------- pallets/manta-pay/src/types.rs | 1 + runtime/dolphin/src/lib.rs | 17 ++++---- 5 files changed, 45 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d303f37ba..681a67747 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4887,7 +4887,7 @@ dependencies = [ [[package]] name = "manta-accounting" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" dependencies = [ "derivative", "derive_more", @@ -4941,7 +4941,7 @@ dependencies = [ [[package]] name = "manta-crypto" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" dependencies = [ "derivative", "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", @@ -4961,7 +4961,7 @@ dependencies = [ [[package]] name = "manta-pay" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" dependencies = [ "aes-gcm", "ark-bls12-381", @@ -5084,7 +5084,7 @@ dependencies = [ [[package]] name = "manta-util" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#15f69a6622d85cf2c941fafe2604435a19e51eea" +source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" dependencies = [ "serde", "serde_with", diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index b2b3856c3..5dfdfe08e 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -79,7 +79,7 @@ manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", bran manta-crypto = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false } manta-pay = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false, features = ["groth16", "scale", "serde"] } manta-sdk = { git = "https://github.com/manta-network/sdk.git", default-features = false } -manta-util = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false, features = ["serde"] } +manta-util = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false, features = ["serde", "serde_with"] } manta-primitives = { path = "../../primitives", default-features = false} [dev-dependencies] diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs index 9910de562..17fe610b9 100644 --- a/pallets/manta-pay/src/rpc.rs +++ b/pallets/manta-pay/src/rpc.rs @@ -17,20 +17,16 @@ //! MantaPay RPC Interfaces use crate::{ - types::{decode, EncryptedNote, Utxo, VoidNumber}, + types::{EncryptedNote, Utxo, VoidNumber}, Config, Pallet, Shards, VoidNumberSet, }; use alloc::sync::Arc; use core::marker::PhantomData; -use jsonrpc_core::{Error as RpcError, ErrorCode}; +use jsonrpc_core::{Error, ErrorCode, Result}; use jsonrpc_derive::rpc; -use manta_accounting::wallet::ledger; -use manta_pay::{ - config, - signer::{Checkpoint, RawCheckpoint}, -}; +use manta_pay::signer::{Checkpoint, RawCheckpoint}; use manta_util::serde::{Deserialize, Serialize}; -use scale_codec::{Decode, Encode, Error as CodecError}; +use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; @@ -42,14 +38,14 @@ pub trait PullApi { /// Returns the update required to be synchronized with the ledger starting from /// `checkpoint`. #[rpc(name = "manta_pay_pull")] - fn pull(&self, checkpoint: Checkpoint) -> jsonrpc_core::Result; + fn pull(&self, checkpoint: Checkpoint) -> Result; } /// Receiver Chunk Data Type -pub type ReceiverChunk = Vec<(config::Utxo, config::EncryptedNote)>; +pub type ReceiverChunk = Vec<(Utxo, EncryptedNote)>; /// Sender Chunk Data Type -pub type SenderChunk = Vec; +pub type SenderChunk = Vec; /// Ledger Source Pull Response #[derive( @@ -88,15 +84,13 @@ where /// Pulls receiver data from the ledger starting at the `receiver_index`. #[inline] - fn pull_receivers( - receiver_index: &mut [usize; 256], - ) -> Result<(bool, ReceiverChunk), CodecError> { + fn pull_receivers(receiver_index: &mut [usize; 256]) -> (bool, ReceiverChunk) { let mut more_receivers = false; let mut receivers = Vec::new(); for (i, index) in receiver_index.iter_mut().enumerate() { - more_receivers |= Self::pull_receivers_for_shard(i as u8, index, &mut receivers)?; + more_receivers |= Self::pull_receivers_for_shard(i as u8, index, &mut receivers); } - Ok((more_receivers, receivers)) + (more_receivers, receivers) } /// Pulls receiver data from the shard at `shard_index` starting at the `receiver_index`, @@ -106,7 +100,7 @@ where shard_index: u8, receiver_index: &mut usize, receivers: &mut ReceiverChunk, - ) -> Result { + ) -> bool { let mut iter = if *receiver_index == 0 { Shards::::iter_prefix(shard_index) } else { @@ -117,49 +111,49 @@ where match iter.next() { Some((_, (utxo, encrypted_note))) => { *receiver_index += 1; - receivers.push((decode(utxo)?, encrypted_note)); + receivers.push((utxo, encrypted_note)); } - _ => return Ok(false), + _ => return false, } } - Ok(iter.next().is_some()) + iter.next().is_some() } /// Pulls sender data from the ledger starting at the `sender_index`. #[inline] - fn pull_senders(sender_index: &mut usize) -> Result<(bool, SenderChunk), CodecError> { + fn pull_senders(sender_index: &mut usize) -> (bool, SenderChunk) { let mut senders = Vec::new(); let mut iter = VoidNumberSet::::iter().skip(*sender_index); for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { match iter.next() { Some((sender, _)) => { *sender_index += 1; - senders.push(decode(sender)?); + senders.push(sender); } - _ => return Ok((false, senders)), + _ => return (false, senders), } } - Ok((iter.next().is_some(), senders)) + (iter.next().is_some(), senders) } /// Returns the update required to be synchronized with the ledger starting from /// `checkpoint`. #[inline] - pub fn pull(mut checkpoint: Checkpoint) -> Result { - let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index)?; - let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index)?; - Ok(PullResponse { + pub fn pull(mut checkpoint: Checkpoint) -> PullResponse { + let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index); + let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index); + PullResponse { should_continue: more_receivers || more_senders, checkpoint, receivers, senders, - }) + } } } sp_api::decl_runtime_apis! { pub trait MantaPayPullRuntimeApi { - fn pull(checkpoint: RawCheckpoint) -> Result; + fn pull(checkpoint: RawCheckpoint) -> PullResponse; } } @@ -190,21 +184,13 @@ where C::Api: MantaPayPullRuntimeApi, { #[inline] - fn pull(&self, checkpoint: Checkpoint) -> jsonrpc_core::Result { + fn pull(&self, checkpoint: Checkpoint) -> Result { let api = self.client.runtime_api(); let at = BlockId::hash(self.client.info().best_hash); - match api.pull(&at, checkpoint.into()) { - Ok(Ok(response)) => Ok(response), - Ok(Err(err)) => Err(RpcError { - code: ErrorCode::ServerError(1), - message: "Unable to compute state diff for pull".into(), - data: Some(err.to_string().into()), - }), - Err(err) => Err(RpcError { - code: ErrorCode::ServerError(2), - message: "Error during runtime API".into(), - data: Some(err.to_string().into()), - }), - } + api.pull(&at, checkpoint.into()).map_err(|err| Error { + code: ErrorCode::ServerError(1), + message: "Unable to compute state diff for pull".into(), + data: Some(err.to_string().into()), + }) } } diff --git a/pallets/manta-pay/src/types.rs b/pallets/manta-pay/src/types.rs index 74baec569..ec4132c2e 100644 --- a/pallets/manta-pay/src/types.rs +++ b/pallets/manta-pay/src/types.rs @@ -112,6 +112,7 @@ pub struct EncryptedNote { pub ephemeral_public_key: Group, /// Ciphertext + #[serde(with = "manta_util::serde_with::As::<[manta_util::serde_with::Same; 68]>")] pub ciphertext: Ciphertext, } diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index 15eccbab5..7e7279efc 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -26,19 +26,22 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use sp_core::{ + crypto::KeyTypeId, + u32_trait::{_1, _2, _3, _4, _5}, + OpaqueMetadata, +}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Perbill, Permill, }; - -use sp_core::u32_trait::{_1, _2, _3, _4, _5}; use sp_std::{cmp::Ordering, prelude::*}; +use sp_version::RuntimeVersion; + #[cfg(feature = "std")] use sp_version::NativeVersion; -use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, match_type, @@ -1276,13 +1279,11 @@ impl_runtime_apis! { } } - /* TODO: impl pallet_manta_pay::rpc::MantaPayPullRuntimeApi for Runtime { - fn pull(checkpoint: Checkpoint) -> Result { - todo!() + fn pull(checkpoint: Checkpoint) -> PullResponse { + MantaPay::pull(checkpoint) } } - */ #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { From b11e24b83675c7536f2fd14ba17ec482a065bc0f Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Thu, 5 May 2022 14:52:52 -0400 Subject: [PATCH 04/24] wip: add rpc feature gating Signed-off-by: Brandon H. Gomes --- node/src/rpc.rs | 9 +++++---- pallets/manta-pay/Cargo.toml | 22 ++++++++++++++++------ pallets/manta-pay/src/lib.rs | 4 +++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 1fff1ff1c..d3f5f9039 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -51,9 +51,10 @@ where + Send + Sync + 'static, - C::Api: frame_rpc_system::AccountNonceApi, - C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - C::Api: BlockBuilder, + C::Api: BlockBuilder + + frame_rpc_system::AccountNonceApi + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + manta_pay::rpc::MantaPayPullRuntimeApi, P: TransactionPool + Sync + Send + 'static, { let FullDeps { @@ -65,6 +66,6 @@ where let mut io = jsonrpc_core::IoHandler::default(); io.extend_with(FullSystem::new(client.clone(), pool, deny_unsafe).to_delegate()); io.extend_with(TransactionPayment::new(client).to_delegate()); - io.extend_with(manta_pay::Pull::new(client).to_delegate()); + io.extend_with(manta_pay::rpc::Pull::new(client).to_delegate()); io } diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index 5dfdfe08e..ddd604138 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -23,6 +23,16 @@ required-features = ["precompute-coins"] # Default Features default = ["std"] +# RPC Interface +rpc = [ + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "sp-api", + "sp-blockchain", + "sp-runtime", +] + # Runtime Benchmarks runtime-benchmarks = [ "frame-benchmarking", @@ -64,15 +74,15 @@ frame-support = { git = "https://github.com/paritytech/substrate.git", branch = frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } scale-codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "1.0.0", default-features = false, features = ["derive"] } -sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } -sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } +sp-api = { git = 'https://github.com/paritytech/substrate.git', optional = true, branch = "polkadot-v0.9.16", default-features = false } +sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', optional = true, branch = "polkadot-v0.9.16", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.16", default-features = false } sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } # JSON-RPC -jsonrpc-core = "18.0.0" -jsonrpc-core-client = "18.0.0" -jsonrpc-derive = "18.0.0" +jsonrpc-core = { version = "18.0.0", optional = true, default-features = false } +jsonrpc-core-client = { version = "18.0.0", optional = true, default-features = false } +jsonrpc-derive = { version = "18.0.0", optional = true, default-features = false } # manta dependencies manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false } diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index e82032ed3..18502fc88 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -90,10 +90,12 @@ mod mock; #[cfg(test)] mod test; -pub mod rpc; pub mod types; pub mod weights; +#[cfg(feature = "rpc")] +pub mod rpc; + #[cfg(feature = "runtime-benchmarks")] pub mod benchmark; From a262e1f81cd30e827e9cf27c2bed2f7df8f90fbb Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Thu, 5 May 2022 15:23:30 -0400 Subject: [PATCH 05/24] fix: replace back sp-runtime dependency Signed-off-by: Brandon H. Gomes --- pallets/manta-pay/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index ddd604138..62b35f577 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -30,7 +30,6 @@ rpc = [ "jsonrpc-derive", "sp-api", "sp-blockchain", - "sp-runtime", ] # Runtime Benchmarks @@ -76,7 +75,7 @@ scale-codec = { package = "parity-scale-codec", version = "2.3.1", default-featu scale-info = { version = "1.0.0", default-features = false, features = ["derive"] } sp-api = { git = 'https://github.com/paritytech/substrate.git', optional = true, branch = "polkadot-v0.9.16", default-features = false } sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', optional = true, branch = "polkadot-v0.9.16", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.16", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } # JSON-RPC From 408f11fdcb5a8ff92dcb6343fb463e91a9f99854 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Thu, 5 May 2022 18:11:17 -0400 Subject: [PATCH 06/24] wip: split up runtime-api and rpc-api Signed-off-by: Brandon H. Gomes --- Cargo.lock | 55 ++++---------- node/Cargo.toml | 3 +- node/src/rpc.rs | 1 - pallets/manta-pay/Cargo.toml | 36 ++++++--- pallets/manta-pay/src/lib.rs | 119 ++++++++++++++++++++++++++++- pallets/manta-pay/src/rpc.rs | 126 +------------------------------ pallets/manta-pay/src/runtime.rs | 26 +++++++ pallets/manta-pay/src/types.rs | 31 ++++---- runtime/dolphin/Cargo.toml | 3 +- runtime/dolphin/src/lib.rs | 4 +- 10 files changed, 202 insertions(+), 202 deletions(-) create mode 100644 pallets/manta-pay/src/runtime.rs diff --git a/Cargo.lock b/Cargo.lock index 681a67747..4d104e15a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4840,6 +4840,7 @@ dependencies = [ "log", "manta-primitives", "manta-runtime", + "pallet-manta-pay", "pallet-transaction-payment-rpc", "parity-scale-codec", "polkadot-cli", @@ -4887,30 +4888,19 @@ dependencies = [ [[package]] name = "manta-accounting" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" +source = "git+https://github.com/manta-network/manta-rs.git#c1e46ad8155494d4c978f959f1e394690406443a" dependencies = [ "derivative", "derive_more", "futures 0.3.21", "indexmap", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-crypto", + "manta-util", "parking_lot 0.12.0", "rand 0.8.5", "statrs", ] -[[package]] -name = "manta-accounting" -version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#ec4470b3f25a7d2e6b8289e0c6f9b3c19be30571" -dependencies = [ - "derivative", - "derive_more", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", -] - [[package]] name = "manta-collator-selection" version = "3.1.5" @@ -4941,27 +4931,17 @@ dependencies = [ [[package]] name = "manta-crypto" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" +source = "git+https://github.com/manta-network/manta-rs.git#c1e46ad8155494d4c978f959f1e394690406443a" dependencies = [ "derivative", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", - "rand_core 0.6.3", -] - -[[package]] -name = "manta-crypto" -version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#ec4470b3f25a7d2e6b8289e0c6f9b3c19be30571" -dependencies = [ - "derivative", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-util", "rand_core 0.6.3", ] [[package]] name = "manta-pay" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" +source = "git+https://github.com/manta-network/manta-rs.git#c1e46ad8155494d4c978f959f1e394690406443a" dependencies = [ "aes-gcm", "ark-bls12-381", @@ -4976,9 +4956,9 @@ dependencies = [ "ark-std", "blake2 0.10.4", "derivative", - "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-accounting", + "manta-crypto", + "manta-util", "parity-scale-codec", "rand_chacha 0.3.1", "scale-info", @@ -4992,7 +4972,7 @@ dependencies = [ "frame-support", "frame-system", "log", - "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-accounting", "parity-scale-codec", "scale-info", "smallvec", @@ -5084,17 +5064,12 @@ dependencies = [ [[package]] name = "manta-util" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api#475b0a4ec7fa5030ccfdd4e63c704088665ccd43" +source = "git+https://github.com/manta-network/manta-rs.git#c1e46ad8155494d4c978f959f1e394690406443a" dependencies = [ "serde", "serde_with", ] -[[package]] -name = "manta-util" -version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#ec4470b3f25a7d2e6b8289e0c6f9b3c19be30571" - [[package]] name = "maplit" version = "1.0.2" @@ -6259,12 +6234,12 @@ dependencies = [ "jsonrpc-core-client", "jsonrpc-derive", "lazy_static", - "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-accounting", + "manta-crypto", "manta-pay", "manta-primitives", "manta-sdk", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?branch=feat/flexible-ledger-api)", + "manta-util", "pallet-asset-manager", "pallet-assets", "pallet-balances", diff --git a/node/Cargo.toml b/node/Cargo.toml index 98156da94..76c4d83f6 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -88,9 +88,10 @@ xcm = { git = "https://github.com/paritytech/polkadot.git", branch = "release-v0 # Self dependencies calamari-runtime = { path = '../runtime/calamari' } -manta-runtime = { path = '../runtime/manta' } dolphin-runtime = { path = '../runtime/dolphin' } manta-primitives = { path = '../primitives' } +manta-runtime = { path = '../runtime/manta' } +pallet-manta-pay = { path = '../pallets/manta-pay', features = ["rpc"] } [build-dependencies] substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index d3f5f9039..cd758ba70 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -62,7 +62,6 @@ where pool, deny_unsafe, } = deps; - let mut io = jsonrpc_core::IoHandler::default(); io.extend_with(FullSystem::new(client.clone(), pool, deny_unsafe).to_delegate()); io.extend_with(TransactionPayment::new(client).to_delegate()); diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index 62b35f577..48ff4aec0 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -28,6 +28,11 @@ rpc = [ "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", + "serde", +] + +# Runtime API +runtime = [ "sp-api", "sp-blockchain", ] @@ -40,6 +45,13 @@ runtime-benchmarks = [ "manta-primitives/runtime-benchmarks", ] +# Serde Serialization +serde = [ + "manta-pay/serde", + "manta-util/serde", + "manta-util/serde_with", +] + # Standard Library std = [ "frame-benchmarking/std", @@ -63,18 +75,18 @@ precompute-coins = [ [dependencies] # utils anyhow = { version = "1.0.55", optional = true } -indoc = { version = "1.0.3", default-features = false, optional = true} -rand = { version = "0.8.4", default-features = false, optional = true } +indoc = { version = "1.0.3", optional = true, default-features = false } +rand = { version = "0.8.4", optional = true, default-features = false } tempfile = { version = "3.3.0", optional = true } # substrate dependencies -frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false, optional = true } +frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", optional = true, default-features = false } frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } scale-codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "1.0.0", default-features = false, features = ["derive"] } -sp-api = { git = 'https://github.com/paritytech/substrate.git', optional = true, branch = "polkadot-v0.9.16", default-features = false } -sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', optional = true, branch = "polkadot-v0.9.16", default-features = false } +sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", optional = true, default-features = false } +sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", optional = true, default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16", default-features = false } sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16", default-features = false } @@ -84,25 +96,25 @@ jsonrpc-core-client = { version = "18.0.0", optional = true, default-features = jsonrpc-derive = { version = "18.0.0", optional = true, default-features = false } # manta dependencies -manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false } -manta-crypto = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false } -manta-pay = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false, features = ["groth16", "scale", "serde"] } +manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } +manta-crypto = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } +manta-pay = { git = "https://github.com/manta-network/manta-rs.git", default-features = false, features = ["groth16", "scale"] } manta-sdk = { git = "https://github.com/manta-network/sdk.git", default-features = false } -manta-util = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", default-features = false, features = ["serde", "serde_with"] } -manta-primitives = { path = "../../primitives", default-features = false} +manta-util = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } +manta-primitives = { path = "../../primitives", default-features = false } [dev-dependencies] bencher = "0.1.5" criterion = "0.3.4" lazy_static = "1.4.0" -manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", branch = "feat/flexible-ledger-api", features = ["test"] } +manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", features = ["test"] } manta-sdk = { git = "https://github.com/manta-network/sdk.git", features = ["download"] } pallet-asset-manager = { path = "../asset-manager"} pallet-assets = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } rand = "0.8.4" sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16"} -sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16"} +sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.16" } tempfile = "3.3.0" xcm = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.16" } diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index 18502fc88..bda76addc 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -71,7 +71,7 @@ use manta_crypto::{ constraint::ProofSystem, merkle_tree::{self, forest::Configuration as _}, }; -use manta_pay::config; +use manta_pay::{config, signer::Checkpoint}; use manta_primitives::{ assets::{AssetConfig, FungibleLedger as _, FungibleLedgerError}, types::{AssetId, Balance}, @@ -81,6 +81,9 @@ use scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use types::*; +#[cfg(feature = "serde")] +use manta_util::serde::{Deserialize, Serialize}; + pub use pallet::*; pub use weights::WeightInfo; @@ -93,11 +96,14 @@ mod test; pub mod types; pub mod weights; +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmark; + #[cfg(feature = "rpc")] pub mod rpc; -#[cfg(feature = "runtime-benchmarks")] -pub mod benchmark; +#[cfg(feature = "runtime")] +pub mod runtime; /// MantaPay Pallet #[frame_support::pallet] @@ -448,6 +454,80 @@ pub mod pallet { where T: Config, { + /// Maximum Number of Updates per Shard + const PULL_MAX_PER_SHARD_UPDATE_SIZE: usize = 128; + + /// Maximum Size of Sender Data Update + const PULL_MAX_SENDER_UPDATE_SIZE: usize = 1024; + + /// Pulls receiver data from the ledger starting at the `receiver_index`. + #[inline] + fn pull_receivers(receiver_index: &mut [usize; 256]) -> (bool, ReceiverChunk) { + let mut more_receivers = false; + let mut receivers = Vec::new(); + for (i, index) in receiver_index.iter_mut().enumerate() { + more_receivers |= Self::pull_receivers_for_shard(i as u8, index, &mut receivers); + } + (more_receivers, receivers) + } + + /// Pulls receiver data from the shard at `shard_index` starting at the `receiver_index`, + /// pushing the results back to `receivers`. + #[inline] + fn pull_receivers_for_shard( + shard_index: u8, + receiver_index: &mut usize, + receivers: &mut ReceiverChunk, + ) -> bool { + let mut iter = if *receiver_index == 0 { + Shards::::iter_prefix(shard_index) + } else { + let raw_key = Shards::::hashed_key_for(shard_index, *receiver_index as u64 - 1); + Shards::::iter_prefix_from(shard_index, raw_key) + }; + for _ in 0..Self::PULL_MAX_PER_SHARD_UPDATE_SIZE { + match iter.next() { + Some((_, (utxo, encrypted_note))) => { + *receiver_index += 1; + receivers.push((utxo, encrypted_note)); + } + _ => return false, + } + } + iter.next().is_some() + } + + /// Pulls sender data from the ledger starting at the `sender_index`. + #[inline] + fn pull_senders(sender_index: &mut usize) -> (bool, SenderChunk) { + let mut senders = Vec::new(); + let mut iter = VoidNumberSet::::iter().skip(*sender_index); + for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { + match iter.next() { + Some((sender, _)) => { + *sender_index += 1; + senders.push(sender); + } + _ => return (false, senders), + } + } + (iter.next().is_some(), senders) + } + + /// Returns the update required to be synchronized with the ledger starting from + /// `checkpoint`. + #[inline] + pub fn pull(mut checkpoint: Checkpoint) -> PullResponse { + let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index); + let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index); + PullResponse { + should_continue: more_receivers || more_senders, + checkpoint, + receivers, + senders, + } + } + /// Returns the account ID of this pallet. #[inline] pub fn account_id() -> T::AccountId { @@ -475,6 +555,39 @@ pub mod pallet { } } +/// Receiver Chunk Data Type +pub type ReceiverChunk = Vec<(Utxo, EncryptedNote)>; + +/// Sender Chunk Data Type +pub type SenderChunk = Vec; + +/// Ledger Source Pull Response +#[cfg_attr( + feature = "serde", + derive(Deserialize, Serialize), + serde(crate = "manta_util::serde", deny_unknown_fields) +)] +#[derive(Clone, Debug, Decode, Default, Encode, Eq, Hash, PartialEq, TypeInfo)] +pub struct PullResponse { + /// Pull Continuation Flag + /// + /// The `should_continue` flag is set to `true` if the client should request more data from the + /// ledger to finish the pull. + pub should_continue: bool, + + /// Ledger Checkpoint + /// + /// If the `should_continue` flag is set to `true` then `checkpoint` is the next [`Checkpoint`] + /// to request data from the ledger. Otherwise, it represents the current ledger state. + pub checkpoint: Checkpoint, + + /// Ledger Receiver Chunk + pub receivers: ReceiverChunk, + + /// Ledger Sender Chunk + pub senders: SenderChunk, +} + /// Preprocessed Event enum PreprocessedEvent where diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs index 17fe610b9..b44111569 100644 --- a/pallets/manta-pay/src/rpc.rs +++ b/pallets/manta-pay/src/rpc.rs @@ -16,18 +16,12 @@ //! MantaPay RPC Interfaces -use crate::{ - types::{EncryptedNote, Utxo, VoidNumber}, - Config, Pallet, Shards, VoidNumberSet, -}; +use crate::{runtime::MantaPayPullRuntimeApi, PullResponse}; use alloc::sync::Arc; use core::marker::PhantomData; use jsonrpc_core::{Error, ErrorCode, Result}; use jsonrpc_derive::rpc; -use manta_pay::signer::{Checkpoint, RawCheckpoint}; -use manta_util::serde::{Deserialize, Serialize}; -use scale_codec::{Decode, Encode}; -use scale_info::TypeInfo; +use manta_pay::signer::Checkpoint; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Block}; @@ -41,122 +35,6 @@ pub trait PullApi { fn pull(&self, checkpoint: Checkpoint) -> Result; } -/// Receiver Chunk Data Type -pub type ReceiverChunk = Vec<(Utxo, EncryptedNote)>; - -/// Sender Chunk Data Type -pub type SenderChunk = Vec; - -/// Ledger Source Pull Response -#[derive( - Clone, Debug, Decode, Default, Deserialize, Encode, Eq, Hash, PartialEq, Serialize, TypeInfo, -)] -#[serde(crate = "manta_util::serde", deny_unknown_fields)] -pub struct PullResponse { - /// Pull Continuation Flag - /// - /// The `should_continue` flag is set to `true` if the client should request more data from the - /// ledger to finish the pull. - pub should_continue: bool, - - /// Ledger Checkpoint - /// - /// If the `should_continue` flag is set to `true` then `checkpoint` is the next [`Checkpoint`] - /// to request data from the ledger. Otherwise, it represents the current ledger state. - pub checkpoint: Checkpoint, - - /// Ledger Receiver Chunk - pub receivers: ReceiverChunk, - - /// Ledger Sender Chunk - pub senders: SenderChunk, -} - -impl Pallet -where - T: Config, -{ - /// Maximum Number of Updates per Shard - const PULL_MAX_PER_SHARD_UPDATE_SIZE: usize = 128; - - /// Maximum Size of Sender Data Update - const PULL_MAX_SENDER_UPDATE_SIZE: usize = 1024; - - /// Pulls receiver data from the ledger starting at the `receiver_index`. - #[inline] - fn pull_receivers(receiver_index: &mut [usize; 256]) -> (bool, ReceiverChunk) { - let mut more_receivers = false; - let mut receivers = Vec::new(); - for (i, index) in receiver_index.iter_mut().enumerate() { - more_receivers |= Self::pull_receivers_for_shard(i as u8, index, &mut receivers); - } - (more_receivers, receivers) - } - - /// Pulls receiver data from the shard at `shard_index` starting at the `receiver_index`, - /// pushing the results back to `receivers`. - #[inline] - fn pull_receivers_for_shard( - shard_index: u8, - receiver_index: &mut usize, - receivers: &mut ReceiverChunk, - ) -> bool { - let mut iter = if *receiver_index == 0 { - Shards::::iter_prefix(shard_index) - } else { - let raw_key = Shards::::hashed_key_for(shard_index, *receiver_index as u64 - 1); - Shards::::iter_prefix_from(shard_index, raw_key) - }; - for _ in 0..Self::PULL_MAX_PER_SHARD_UPDATE_SIZE { - match iter.next() { - Some((_, (utxo, encrypted_note))) => { - *receiver_index += 1; - receivers.push((utxo, encrypted_note)); - } - _ => return false, - } - } - iter.next().is_some() - } - - /// Pulls sender data from the ledger starting at the `sender_index`. - #[inline] - fn pull_senders(sender_index: &mut usize) -> (bool, SenderChunk) { - let mut senders = Vec::new(); - let mut iter = VoidNumberSet::::iter().skip(*sender_index); - for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { - match iter.next() { - Some((sender, _)) => { - *sender_index += 1; - senders.push(sender); - } - _ => return (false, senders), - } - } - (iter.next().is_some(), senders) - } - - /// Returns the update required to be synchronized with the ledger starting from - /// `checkpoint`. - #[inline] - pub fn pull(mut checkpoint: Checkpoint) -> PullResponse { - let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index); - let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index); - PullResponse { - should_continue: more_receivers || more_senders, - checkpoint, - receivers, - senders, - } - } -} - -sp_api::decl_runtime_apis! { - pub trait MantaPayPullRuntimeApi { - fn pull(checkpoint: RawCheckpoint) -> PullResponse; - } -} - /// Pull RPC API Implementation pub struct Pull { /// Client diff --git a/pallets/manta-pay/src/runtime.rs b/pallets/manta-pay/src/runtime.rs new file mode 100644 index 000000000..0e34d65b7 --- /dev/null +++ b/pallets/manta-pay/src/runtime.rs @@ -0,0 +1,26 @@ +// Copyright 2019-2022 Manta Network. +// This file is part of pallet-manta-pay. +// +// pallet-manta-pay 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. +// +// pallet-manta-pay 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 pallet-manta-pay. If not, see . + +//! MantaPay Runtime APIs + +use crate::PullResponse; +use manta_pay::signer::RawCheckpoint; + +sp_api::decl_runtime_apis! { + pub trait MantaPayPullRuntimeApi { + fn pull(checkpoint: RawCheckpoint) -> PullResponse; + } +} diff --git a/pallets/manta-pay/src/types.rs b/pallets/manta-pay/src/types.rs index ec4132c2e..e53c7f2e7 100644 --- a/pallets/manta-pay/src/types.rs +++ b/pallets/manta-pay/src/types.rs @@ -17,12 +17,12 @@ //! Type Definitions for Manta Pay use super::*; -use manta_util::{ - into_array_unchecked, - serde::{Deserialize, Serialize}, -}; +use manta_util::into_array_unchecked; use scale_codec::Error; +#[cfg(feature = "rpc")] +use manta_util::serde::{Deserialize, Serialize}; + /// Encodes the SCALE encodable `value` into a byte array with the given length `N`. #[inline] pub(crate) fn encode(value: T) -> [u8; N] @@ -93,26 +93,21 @@ impl Asset { } /// Encrypted Note -#[derive( - Clone, - Debug, - Decode, - Deserialize, - Encode, - Eq, - Hash, - MaxEncodedLen, - PartialEq, - Serialize, - TypeInfo, +#[cfg_attr( + feature = "rpc", + derive(Deserialize, Serialize), + serde(crate = "manta_util::serde", deny_unknown_fields) )] -#[serde(crate = "manta_util::serde", deny_unknown_fields)] +#[derive(Clone, Debug, Decode, Encode, Eq, Hash, MaxEncodedLen, PartialEq, TypeInfo)] pub struct EncryptedNote { /// Ephemeral Public Key pub ephemeral_public_key: Group, /// Ciphertext - #[serde(with = "manta_util::serde_with::As::<[manta_util::serde_with::Same; 68]>")] + #[cfg_attr( + feature = "rpc", + serde(with = "manta_util::serde_with::As::<[manta_util::serde_with::Same; 68]>") + )] pub ciphertext: Ciphertext, } diff --git a/runtime/dolphin/Cargo.toml b/runtime/dolphin/Cargo.toml index 2544ee983..3635d4e4b 100644 --- a/runtime/dolphin/Cargo.toml +++ b/runtime/dolphin/Cargo.toml @@ -85,7 +85,7 @@ manta-primitives = { path = '../../primitives', default-features = false } manta-collator-selection = { path = '../../pallets/collator-selection', default-features = false } pallet-tx-pause = { path = '../../pallets/tx-pause', default-features = false } pallet-asset-manager = { path = '../../pallets/asset-manager', default-features = false } -pallet-manta-pay = { path='../../pallets/manta-pay', default-features = false } +pallet-manta-pay = { path='../../pallets/manta-pay', default-features = false, features = ["rpc"] } # Third party (vendored) dependencies orml-xtokens = { git = "https://github.com/manta-network/open-runtime-module-library.git", default-features = false, rev="4a66b29"} @@ -190,5 +190,6 @@ std = [ 'pallet-treasury/std', 'pallet-assets/std', 'pallet-manta-pay/std', + 'pallet-manta-pay/rpc', 'pallet-asset-manager/std', ] diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index 7e7279efc..91247ee42 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -1279,8 +1279,8 @@ impl_runtime_apis! { } } - impl pallet_manta_pay::rpc::MantaPayPullRuntimeApi for Runtime { - fn pull(checkpoint: Checkpoint) -> PullResponse { + impl pallet_manta_pay::rpc::MantaPayPullRuntimeApi for Runtime { + fn pull(checkpoint: pallet_manta_pay::rpc::Checkpoint) -> pallet_manta_pay::rpc::PullResponse { MantaPay::pull(checkpoint) } } From 4deeb91f497f335ede70a168d78483b5c33aa3b4 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Thu, 5 May 2022 22:02:55 -0400 Subject: [PATCH 07/24] fix: use correct feature flags for runtime-api Signed-off-by: Brandon H. Gomes --- pallets/manta-pay/Cargo.toml | 7 +++---- pallets/manta-pay/src/lib.rs | 3 ++- primitives/src/assets.rs | 4 ++-- runtime/dolphin/Cargo.toml | 2 +- runtime/dolphin/src/lib.rs | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index 48ff4aec0..afa65c0aa 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -29,14 +29,13 @@ rpc = [ "jsonrpc-core-client", "jsonrpc-derive", "serde", -] - -# Runtime API -runtime = [ "sp-api", "sp-blockchain", ] +# Runtime API +runtime = ["sp-api"] + # Runtime Benchmarks runtime-benchmarks = [ "frame-benchmarking", diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index e680601c0..fbe7db1e6 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -71,7 +71,7 @@ use manta_crypto::{ constraint::ProofSystem, merkle_tree::{self, forest::Configuration as _}, }; -use manta_pay::{config, signer::Checkpoint}; +use manta_pay::config; use manta_primitives::{ assets::{AssetConfig, FungibleLedger as _, FungibleLedgerError}, types::{AssetId, Balance}, @@ -84,6 +84,7 @@ use types::*; #[cfg(feature = "serde")] use manta_util::serde::{Deserialize, Serialize}; +pub use manta_pay::signer::{Checkpoint, RawCheckpoint}; pub use pallet::*; pub use weights::WeightInfo; diff --git a/primitives/src/assets.rs b/primitives/src/assets.rs index 54db53f48..4f764343a 100644 --- a/primitives/src/assets.rs +++ b/primitives/src/assets.rs @@ -439,7 +439,7 @@ where >::deposit_creating(beneficiary, amount); } else { >::mint_into(asset_id, beneficiary, amount) - .map_err(|e| FungibleLedgerError::InvalidMint(e))?; + .map_err(FungibleLedgerError::InvalidMint)?; } Ok(()) } @@ -469,6 +469,6 @@ where ) .map(|_| ()) } - .map_err(|e| FungibleLedgerError::InvalidTransfer(e)) + .map_err(FungibleLedgerError::InvalidTransfer) } } diff --git a/runtime/dolphin/Cargo.toml b/runtime/dolphin/Cargo.toml index 9ccdbcf21..75df6d74e 100644 --- a/runtime/dolphin/Cargo.toml +++ b/runtime/dolphin/Cargo.toml @@ -85,7 +85,7 @@ manta-primitives = { path = '../../primitives', default-features = false } manta-collator-selection = { path = '../../pallets/collator-selection', default-features = false } pallet-tx-pause = { path = '../../pallets/tx-pause', default-features = false } pallet-asset-manager = { path = '../../pallets/asset-manager', default-features = false } -pallet-manta-pay = { path='../../pallets/manta-pay', default-features = false, features = ["rpc"] } +pallet-manta-pay = { path='../../pallets/manta-pay', default-features = false, features = ["runtime"] } runtime-common = { path = '../common', default-features = false } # Third party (vendored) dependencies diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index acc9ec3bc..23f4b4ee0 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -843,9 +843,9 @@ impl_runtime_apis! { } } - impl pallet_manta_pay::rpc::MantaPayPullRuntimeApi for Runtime { - fn pull(checkpoint: pallet_manta_pay::rpc::Checkpoint) -> pallet_manta_pay::rpc::PullResponse { - MantaPay::pull(checkpoint) + impl pallet_manta_pay::runtime::MantaPayPullRuntimeApi for Runtime { + fn pull(checkpoint: pallet_manta_pay::RawCheckpoint) -> pallet_manta_pay::PullResponse { + MantaPay::pull(checkpoint.into()) } } From 169a6ade8616079c0cb81b8f21bf23200ebf35b9 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Thu, 5 May 2022 22:23:23 -0400 Subject: [PATCH 08/24] fix: use correct library name for manta-pay Signed-off-by: Brandon H. Gomes --- node/Cargo.toml | 2 +- node/src/rpc.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/node/Cargo.toml b/node/Cargo.toml index 76c4d83f6..22cf385d5 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -91,7 +91,7 @@ calamari-runtime = { path = '../runtime/calamari' } dolphin-runtime = { path = '../runtime/dolphin' } manta-primitives = { path = '../primitives' } manta-runtime = { path = '../runtime/manta' } -pallet-manta-pay = { path = '../pallets/manta-pay', features = ["rpc"] } +pallet-manta-pay = { path = '../pallets/manta-pay', features = ["rpc", "runtime"] } [build-dependencies] substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.16" } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index cd758ba70..4f140a18c 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -54,7 +54,7 @@ where C::Api: BlockBuilder + frame_rpc_system::AccountNonceApi + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + manta_pay::rpc::MantaPayPullRuntimeApi, + + pallet_manta_pay::runtime::MantaPayPullRuntimeApi, P: TransactionPool + Sync + Send + 'static, { let FullDeps { @@ -65,6 +65,6 @@ where let mut io = jsonrpc_core::IoHandler::default(); io.extend_with(FullSystem::new(client.clone(), pool, deny_unsafe).to_delegate()); io.extend_with(TransactionPayment::new(client).to_delegate()); - io.extend_with(manta_pay::rpc::Pull::new(client).to_delegate()); + io.extend_with(pallet_manta_pay::rpc::Pull::new(client).to_delegate()); io } From 530c4695a88ddb85fa4dbcfe767f87aadb63361a Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Thu, 5 May 2022 23:54:57 -0400 Subject: [PATCH 09/24] fix: import RPC-API trait Signed-off-by: Brandon H. Gomes --- node/src/rpc.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 4f140a18c..9591f86f1 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -19,6 +19,7 @@ use alloc::sync::Arc; use frame_rpc_system::{FullSystem, SystemApi}; use manta_primitives::types::{AccountId, Balance, Block, Index as Nonce}; +use pallet_manta_pay::rpc::PullApi; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use sc_client_api::AuxStore; use sc_transaction_pool_api::TransactionPool; From dc8c9e567b1a4e323cd99d5e07d90ad36249cf45 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Fri, 6 May 2022 23:15:13 -0400 Subject: [PATCH 10/24] feat: build RPC Builder abstraction for custom RPCs Signed-off-by: Brandon H. Gomes --- node/src/chain_specs/calamari.rs | 3 +- node/src/chain_specs/dolphin.rs | 5 +- node/src/chain_specs/manta.rs | 6 +- node/src/chain_specs/mod.rs | 20 +- node/src/command.rs | 6 +- node/src/rpc.rs | 71 ----- node/src/rpc/common.rs | 54 ++++ node/src/rpc/dolphin.rs | 58 ++++ node/src/rpc/mod.rs | 56 ++++ node/src/service.rs | 267 +++++++----------- pallets/asset-manager/src/benchmarking.rs | 25 +- .../collator-selection/src/benchmarking.rs | 8 +- pallets/collator-selection/src/lib.rs | 12 +- pallets/collator-selection/src/migrations.rs | 7 +- pallets/manta-pay/src/rpc.rs | 4 +- pallets/manta-pay/src/runtime.rs | 2 +- pallets/tx-pause/src/benchmarking.rs | 13 +- pallets/vesting/src/benchmarking.rs | 28 +- runtime/calamari/src/lib.rs | 3 +- runtime/dolphin/src/lib.rs | 2 +- runtime/manta/src/lib.rs | 6 +- 21 files changed, 328 insertions(+), 328 deletions(-) delete mode 100644 node/src/rpc.rs create mode 100644 node/src/rpc/common.rs create mode 100644 node/src/rpc/dolphin.rs create mode 100644 node/src/rpc/mod.rs diff --git a/node/src/chain_specs/calamari.rs b/node/src/chain_specs/calamari.rs index ddd4d2cfa..a30de88e6 100644 --- a/node/src/chain_specs/calamari.rs +++ b/node/src/chain_specs/calamari.rs @@ -16,8 +16,7 @@ use super::*; use crate::command::CALAMARI_PARACHAIN_ID; - -use calamari_runtime::{CouncilConfig, DemocracyConfig, GenesisConfig, TechnicalCommitteeConfig}; +use calamari_runtime::{CouncilConfig, DemocracyConfig, TechnicalCommitteeConfig}; use manta_primitives::helpers::{get_account_id_from_seed, get_collator_keys_from_seed}; /// Specialized `ChainSpec` for the normal parachain runtime. diff --git a/node/src/chain_specs/dolphin.rs b/node/src/chain_specs/dolphin.rs index b18bfc28e..0f2b7a486 100644 --- a/node/src/chain_specs/dolphin.rs +++ b/node/src/chain_specs/dolphin.rs @@ -16,10 +16,7 @@ use super::*; use crate::command::DOLPHIN_PARACHAIN_ID; - -use dolphin_runtime::{ - AssetManagerConfig, CouncilConfig, DemocracyConfig, GenesisConfig, TechnicalCommitteeConfig, -}; +use dolphin_runtime::{CouncilConfig, DemocracyConfig, TechnicalCommitteeConfig}; use manta_primitives::helpers::{get_account_id_from_seed, get_collator_keys_from_seed}; /// Specialized `ChainSpec` for the normal parachain runtime. diff --git a/node/src/chain_specs/manta.rs b/node/src/chain_specs/manta.rs index 0274d2180..dbb45c9ca 100644 --- a/node/src/chain_specs/manta.rs +++ b/node/src/chain_specs/manta.rs @@ -16,8 +16,6 @@ use super::*; use crate::command::MANTA_PARACHAIN_ID; - -pub type MantaChainSpec = sc_service::GenericChainSpec; use manta_primitives::helpers::{get_account_id_from_seed, get_collator_keys_from_seed}; const MANTA_PROTOCOL_ID: &str = "manta"; // for p2p network configuration @@ -29,6 +27,8 @@ const POLKADOT_RELAYCHAIN_MAIN_NET: &str = "polkadot"; /// The default XCM version to set in genesis config. const SAFE_XCM_VERSION: u32 = 2; +pub type MantaChainSpec = sc_service::GenericChainSpec; + /// Generate the manta session keys from individual elements. /// /// The input must be a tuple of individual keys (a single arg for now since we have just one key). @@ -48,7 +48,6 @@ pub fn manta_properties() -> Properties { // manta chain spec pub fn manta_development_config() -> MantaChainSpec { let properties = manta_properties(); - MantaChainSpec::from_genesis( // Name "Manta Parachain Development", @@ -85,7 +84,6 @@ pub fn manta_development_config() -> MantaChainSpec { pub fn manta_local_config() -> MantaChainSpec { let properties = manta_properties(); - MantaChainSpec::from_genesis( // Name "Manta Parachain Local", diff --git a/node/src/chain_specs/mod.rs b/node/src/chain_specs/mod.rs index 9f2333966..82c823853 100644 --- a/node/src/chain_specs/mod.rs +++ b/node/src/chain_specs/mod.rs @@ -14,29 +14,25 @@ // You should have received a copy of the GNU General Public License // along with Manta. If not, see . -#![allow(unused_imports)] #![allow(dead_code)] -use cumulus_primitives_core::ParaId; -use hex_literal::hex; + use manta_primitives::{ constants, - types::{AccountId, AuraId, Balance, Signature}, + types::{AccountId, AuraId, Balance}, }; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::{ChainType, Properties}; use serde::{Deserialize, Serialize}; -use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_core::sr25519; pub mod calamari; -pub use self::calamari::*; -pub use calamari_runtime::currency::KMA; -pub mod manta; -pub use self::manta::*; -pub use manta_runtime::currency::MANTA; pub mod dolphin; -pub use self::dolphin::*; +pub mod manta; + +pub use self::{calamari::*, dolphin::*, manta::*}; +pub use calamari_runtime::currency::KMA; pub use dolphin_runtime::currency::DOL; +pub use manta_runtime::currency::MANTA; const CALAMARI_ENDOWMENT: Balance = 1_000_000_000 * KMA; // 10 endowment so that total supply is 10B diff --git a/node/src/command.rs b/node/src/command.rs index 3299d9e7e..624b5ed24 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -19,12 +19,10 @@ use crate::{ cli::{Cli, RelayChainCli, Subcommand}, service::{new_partial, CalamariRuntimeExecutor, DolphinRuntimeExecutor, MantaRuntimeExecutor}, }; - use codec::Encode; use cumulus_client_service::genesis::generate_genesis_block; use cumulus_primitives_core::ParaId; use log::info; - use manta_primitives::types::{AuraId, Header}; use polkadot_parachain::primitives::AccountIdConversion; use sc_cli::{ @@ -199,9 +197,9 @@ impl SubstrateCli for RelayChainCli { } } +#[allow(clippy::borrowed_box)] fn extract_genesis_wasm(chain_spec: &Box) -> Result> { let mut storage = chain_spec.build_storage()?; - storage .top .remove(sp_core::storage::well_known_keys::CODE) @@ -394,7 +392,7 @@ pub fn run() -> Result<()> { runner.run_node_until_exit(|config| async move { let para_id = crate::chain_specs::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain extension in chain-spec.")?; + .ok_or("Could not find parachain extension in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, diff --git a/node/src/rpc.rs b/node/src/rpc.rs deleted file mode 100644 index 9591f86f1..000000000 --- a/node/src/rpc.rs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2020-2022 Manta Network. -// This file is part of Manta. -// -// Manta 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. -// -// Manta 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 Manta. If not, see . - -//! Parachain-specific RPCs implementation. - -use alloc::sync::Arc; -use frame_rpc_system::{FullSystem, SystemApi}; -use manta_primitives::types::{AccountId, Balance, Block, Index as Nonce}; -use pallet_manta_pay::rpc::PullApi; -use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; -use sc_client_api::AuxStore; -use sc_transaction_pool_api::TransactionPool; -use sp_api::ProvideRuntimeApi; -use sp_block_builder::BlockBuilder; -use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; - -pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; - -/// A type representing all RPC extensions. -pub type RpcExtension = jsonrpc_core::IoHandler; - -/// Full client dependencies -pub struct FullDeps { - /// The client instance to use. - pub client: Arc, - /// Transaction pool instance. - pub pool: Arc

, - /// Whether to deny unsafe calls - pub deny_unsafe: DenyUnsafe, -} - -/// Instantiate all RPC extensions. -pub fn create_full(deps: FullDeps) -> RpcExtension -where - C: ProvideRuntimeApi - + HeaderBackend - + AuxStore - + HeaderMetadata - + Send - + Sync - + 'static, - C::Api: BlockBuilder - + frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + pallet_manta_pay::runtime::MantaPayPullRuntimeApi, - P: TransactionPool + Sync + Send + 'static, -{ - let FullDeps { - client, - pool, - deny_unsafe, - } = deps; - let mut io = jsonrpc_core::IoHandler::default(); - io.extend_with(FullSystem::new(client.clone(), pool, deny_unsafe).to_delegate()); - io.extend_with(TransactionPayment::new(client).to_delegate()); - io.extend_with(pallet_manta_pay::rpc::Pull::new(client).to_delegate()); - io -} diff --git a/node/src/rpc/common.rs b/node/src/rpc/common.rs new file mode 100644 index 000000000..ff27c5e05 --- /dev/null +++ b/node/src/rpc/common.rs @@ -0,0 +1,54 @@ +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. +// +// Manta 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 Manta. If not, see . + +//! Common RPC Extensions + +use crate::rpc::{Builder, RpcExtension}; +use frame_rpc_system::{AccountNonceApi, FullSystem, SystemApi}; +use manta_primitives::types::{AccountId, Balance, Block, Index as Nonce}; +use pallet_transaction_payment_rpc::{ + TransactionPayment, TransactionPaymentApi, TransactionPaymentRuntimeApi, +}; +use sc_client_api::HeaderBackend; +use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; +use sc_service::{Error, RpcExtensionBuilder}; +use sc_transaction_pool_api::TransactionPool; +use sp_api::ProvideRuntimeApi; +use sp_block_builder::BlockBuilder; + +/// Common RPC Extension Marker +pub struct Common; + +impl RpcExtensionBuilder for Builder +where + C: 'static + ProvideRuntimeApi + HeaderBackend, + C::Api: BlockBuilder + + AccountNonceApi + + TransactionPaymentRuntimeApi, + P: 'static + TransactionPool, +{ + type Output = RpcExtension; + + #[inline] + fn build(&self, deny: DenyUnsafe, _: SubscriptionTaskExecutor) -> Result { + let mut io = RpcExtension::default(); + io.extend_with( + FullSystem::new(self.client.clone(), self.transaction_pool.clone(), deny).to_delegate(), + ); + io.extend_with(TransactionPayment::new(self.client.clone()).to_delegate()); + Ok(io) + } +} diff --git a/node/src/rpc/dolphin.rs b/node/src/rpc/dolphin.rs new file mode 100644 index 000000000..1f5e4e478 --- /dev/null +++ b/node/src/rpc/dolphin.rs @@ -0,0 +1,58 @@ +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. +// +// Manta 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 Manta. If not, see . + +//! Dolphin RPC Extensions + +use crate::rpc::{common::Common, Builder, RpcExtension}; +use frame_rpc_system::AccountNonceApi; +use manta_primitives::types::{AccountId, Balance, Block, Index as Nonce}; +use pallet_manta_pay::{ + rpc::{Pull, PullApi}, + runtime::PullRuntimeApi, +}; +use pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi; +use sc_client_api::HeaderBackend; +use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; +use sc_service::{Error, RpcExtensionBuilder}; +use sc_transaction_pool_api::TransactionPool; +use sp_api::ProvideRuntimeApi; +use sp_block_builder::BlockBuilder; + +/// Dolphin RPC Extension Marker +pub struct Dolphin; + +impl RpcExtensionBuilder for Builder +where + C: 'static + ProvideRuntimeApi + HeaderBackend, + C::Api: BlockBuilder + + AccountNonceApi + + PullRuntimeApi + + TransactionPaymentRuntimeApi, + P: 'static + TransactionPool, +{ + type Output = RpcExtension; + + #[inline] + fn build( + &self, + deny: DenyUnsafe, + subscription_executor: SubscriptionTaskExecutor, + ) -> Result { + let mut io = self.using::().build(deny, subscription_executor)?; + io.extend_with(Pull::new(self.client.clone()).to_delegate()); + Ok(io) + } +} diff --git a/node/src/rpc/mod.rs b/node/src/rpc/mod.rs new file mode 100644 index 000000000..45751878b --- /dev/null +++ b/node/src/rpc/mod.rs @@ -0,0 +1,56 @@ +// Copyright 2020-2022 Manta Network. +// This file is part of Manta. +// +// Manta 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. +// +// Manta 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 Manta. If not, see . + +//! Parachain-specific RPCs implementation. + +use alloc::sync::Arc; +use core::marker::PhantomData; + +pub mod common; +pub mod dolphin; + +/// RPC Extension Type +pub type RpcExtension = jsonrpc_core::IoHandler; + +/// RPC Extension Builder +pub struct Builder { + /// Client + client: Arc, + + /// Transaction Poool + transaction_pool: Arc

, + + /// Runtime Marker + __: PhantomData, +} + +impl Builder { + /// Builds a new RPC Extension [`Builder`] from `client` and `transaction_pool`. + #[inline] + pub fn new(client: Arc, transaction_pool: Arc

) -> Self { + Self { + client, + transaction_pool, + __: PhantomData, + } + } + + /// Converts `self` into a [`Builder`] with the `T` marker. + #[inline] + pub fn using(&self) -> Builder { + Builder::new(self.client.clone(), self.transaction_pool.clone()) + } +} diff --git a/node/src/service.rs b/node/src/service.rs index 3332a2de1..5aa75822b 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -14,12 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Manta. If not, see . +use crate::rpc; use codec::Codec; use core::marker::PhantomData; use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; use cumulus_client_consensus_common::{ ParachainBlockImport, ParachainCandidate, ParachainConsensus, }; +use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; use cumulus_client_network::BlockAnnounceValidator; use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, @@ -30,13 +32,8 @@ use cumulus_primitives_core::{ }; use cumulus_relay_chain_interface::RelayChainInterface; use cumulus_relay_chain_local::build_relay_chain_interface; -use polkadot_service::NativeExecutionDispatch; - -use crate::rpc; -pub use manta_primitives::types::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; - -use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; use futures::lock::Mutex; +use polkadot_service::NativeExecutionDispatch; use sc_client_api::ExecutorProvider; use sc_consensus::{ import_queue::{BasicQueue, Verifier as VerifierT}, @@ -44,22 +41,28 @@ use sc_consensus::{ }; use sc_executor::NativeElseWasmExecutor; use sc_network::NetworkService; -use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager}; +use sc_service::{Configuration, Error, Role, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; -use sp_api::{ApiExt, ConstructRuntimeApi}; +use sp_api::{ApiExt, ConstructRuntimeApi, Metadata, ProvideRuntimeApi}; +use sp_block_builder::BlockBuilder; use sp_consensus::{CacheKeyId, SlotData}; use sp_consensus_aura::AuraApi; use sp_core::crypto::Pair; use sp_keystore::SyncCryptoStorePtr; +use sp_offchain::OffchainWorkerApi; use sp_runtime::{ app_crypto::AppKey, generic::BlockId, traits::{BlakeTwo256, Header as HeaderT}, }; +use sp_session::SessionKeys; +use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use std::sync::Arc; use substrate_prometheus_endpoint::Registry; -// Native Manta Parachain executor instance. +pub use manta_primitives::types::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; + +/// Native Manta Parachain executor instance. pub struct MantaRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for MantaRuntimeExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; @@ -73,7 +76,7 @@ impl sc_executor::NativeExecutionDispatch for MantaRuntimeExecutor { } } -// Native Calamari Parachain executor instance. +/// Native Calamari Parachain executor instance. pub struct CalamariRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for CalamariRuntimeExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; @@ -87,7 +90,7 @@ impl sc_executor::NativeExecutionDispatch for CalamariRuntimeExecutor { } } -// Native Dolphin Parachain executor instance. +/// Native Dolphin Parachain executor instance. pub struct DolphinRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for DolphinRuntimeExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; @@ -101,6 +104,28 @@ impl sc_executor::NativeExecutionDispatch for DolphinRuntimeExecutor { } } +/// Full Client Implementation Type +pub type Client = TFullClient>; + +/// Default Import Queue Type +pub type ImportQueue = sc_consensus::DefaultImportQueue>; + +/// Full Transaction Pool Type +pub type TransactionPool = sc_transaction_pool::FullPool>; + +/// Components Needed for Chain Ops Subcommands +pub type PartialComponents = sc_service::PartialComponents< + Client, + TFullBackend, + (), + ImportQueue, + TransactionPool, + (Option, Option), +>; + +/// State Backend Type +pub type StateBackend = sc_client_api::StateBackendFor, Block>; + /// Starts a `ServiceBuilder` for a full service. /// /// Use this macro if you don't actually need the full service, but just the builder in order to @@ -108,50 +133,23 @@ impl sc_executor::NativeExecutionDispatch for DolphinRuntimeExecutor { pub fn new_partial( config: &Configuration, build_import_queue: BIQ, -) -> Result< - PartialComponents< - TFullClient>, - TFullBackend, - (), - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - (Option, Option), - >, - sc_service::Error, -> +) -> Result, Error> where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: TaggedTransactionQueue + + Metadata + + SessionKeys + + ApiExt + + OffchainWorkerApi + + BlockBuilder, + StateBackend: sp_api::StateBackend, Executor: NativeExecutionDispatch + 'static, BIQ: FnOnce( - Arc>>, + Arc>, &Configuration, Option, &TaskManager, - ) -> Result< - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_service::Error, - >, + ) -> Result, Error>, { let telemetry = config .telemetry_endpoints @@ -163,14 +161,12 @@ where Ok((worker, telemetry)) }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( config.wasm_method, config.default_heap_pages, config.max_runtime_instances, config.runtime_cache_size, ); - let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( config, @@ -178,16 +174,13 @@ where executor, )?; let client = Arc::new(client); - let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle()); - let telemetry = telemetry.map(|(worker, telemetry)| { task_manager .spawn_handle() .spawn("telemetry", None, worker.run()); telemetry }); - let transaction_pool = sc_transaction_pool::BasicPool::new_full( config.transaction_pool.clone(), config.role.is_authority().into(), @@ -195,15 +188,13 @@ where task_manager.spawn_essential_handle(), client.clone(), ); - let import_queue = build_import_queue( client.clone(), config, telemetry.as_ref().map(|telemetry| telemetry.handle()), &task_manager, )?; - - let params = PartialComponents { + Ok(PartialComponents { backend, client, import_queue, @@ -212,9 +203,7 @@ where transaction_pool, select_chain: (), other: (telemetry, telemetry_worker_handle), - }; - - Ok(params) + }) } /// Start a node with the given parachain `Configuration` and relay chain `Configuration`. @@ -225,64 +214,47 @@ async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, id: ParaId, - _rpc_ext_builder: RB, + rpc_extensions_builder: RB, build_import_queue: BIQ, build_consensus: BIC, -) -> sc_service::error::Result<( - TaskManager, - Arc>>, -)> +) -> Result<(TaskManager, Arc>), Error> where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: TaggedTransactionQueue + + Metadata + + SessionKeys + + ApiExt + + OffchainWorkerApi + + BlockBuilder + cumulus_primitives_core::CollectCollationInfo + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + frame_rpc_system::AccountNonceApi, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, + StateBackend: sp_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, RB: Fn( - Arc>, - ) -> Result, sc_service::Error> - + Send - + 'static, + Arc>, + Arc>, + ) -> Box< + (dyn sc_service::RpcExtensionBuilder + Send + 'static), + >, BIQ: FnOnce( - Arc>>, + Arc>, &Configuration, Option, &TaskManager, - ) -> Result< - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_service::Error, - > + 'static, + ) -> Result, Error> + + 'static, BIC: FnOnce( - Arc>>, + Arc>, Option<&Registry>, Option, &TaskManager, Arc, - Arc< - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - >, + Arc>, Arc>, SyncCryptoStorePtr, bool, - ) -> Result>, sc_service::Error>, + ) -> Result>, Error>, { if matches!(parachain_config.role, Role::Light) { return Err("Light client not supported!".into()); @@ -323,23 +295,8 @@ where warp_sync: None, })?; - let rpc_extensions_builder = { - let client = client.clone(); - let transaction_pool = transaction_pool.clone(); - - Box::new(move |deny_unsafe, _| { - let deps = rpc::FullDeps { - client: client.clone(), - pool: transaction_pool.clone(), - deny_unsafe, - }; - - Ok(rpc::create_full(deps)) - }) - }; - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - rpc_extensions_builder, + rpc_extensions_builder: rpc_extensions_builder(client.clone(), transaction_pool.clone()), client: client.clone(), transaction_pool: transaction_pool.clone(), task_manager: &mut task_manager, @@ -369,10 +326,8 @@ where params.keystore_container.sync_keystore(), force_authoring, )?; - let spawner = task_manager.spawn_handle(); - - let params = StartCollatorParams { + start_collator(StartCollatorParams { para_id: id, block_status: client.clone(), announce_block, @@ -384,11 +339,10 @@ where import_queue, collator_key, relay_chain_slot_duration, - }; - - start_collator(params).await?; + }) + .await?; } else { - let params = StartFullNodeParams { + start_full_node(StartFullNodeParams { client: client.clone(), announce_block, task_manager: &mut task_manager, @@ -396,13 +350,10 @@ where relay_chain_interface, relay_chain_slot_duration, import_queue, - }; - - start_full_node(params)?; + })?; } start_network.start_network(); - Ok((task_manager, client)) } @@ -447,7 +398,7 @@ impl Clone for WaitForAuraConsensus { #[async_trait::async_trait] impl ParachainConsensus for WaitForAuraConsensus where - Client: sp_api::ProvideRuntimeApi + Send + Sync, + Client: ProvideRuntimeApi + Send + Sync, Client::Api: AuraApi, AuraId: Send + Codec + Sync, { @@ -490,7 +441,7 @@ struct Verifier { #[async_trait::async_trait] impl VerifierT for Verifier where - Client: sp_api::ProvideRuntimeApi + Send + Sync, + Client: ProvideRuntimeApi + Send + Sync, Client::Api: AuraApi, AuraId: Send + Sync + Codec, { @@ -521,32 +472,21 @@ where /// Build the import queue for the calamari/manta runtime. pub fn parachain_build_import_queue( - client: Arc>>, + client: Arc>, config: &Configuration, telemetry_handle: Option, task_manager: &TaskManager, -) -> Result< - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_service::Error, -> +) -> Result, Error> where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: TaggedTransactionQueue + + Metadata + + SessionKeys + + ApiExt + + OffchainWorkerApi + + BlockBuilder + sp_consensus_aura::AuraApi::Pair as Pair>::Public>, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, + StateBackend: sp_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, <::Pair as Pair>::Signature: TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, @@ -555,7 +495,6 @@ where let aura_verifier = move || { let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap(); - Box::new(cumulus_client_consensus_aura::build_verifier::< ::Pair, _, @@ -583,7 +522,7 @@ where let relay_chain_verifier = Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) - })) as Box<_>; + })); let verifier = Verifier { client: client.clone(), @@ -609,28 +548,20 @@ pub async fn start_parachain_node( parachain_config: Configuration, polkadot_config: Configuration, id: ParaId, -) -> sc_service::error::Result<( - TaskManager, - Arc>>, -)> +) -> Result<(TaskManager, Arc>), Error> where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: TaggedTransactionQueue + + Metadata + + SessionKeys + + ApiExt + + OffchainWorkerApi + + BlockBuilder + cumulus_primitives_core::CollectCollationInfo + sp_consensus_aura::AuraApi::Pair as Pair>::Public> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + frame_rpc_system::AccountNonceApi, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, + StateBackend: sp_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, <::Pair as Pair>::Signature: TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, @@ -639,7 +570,7 @@ where parachain_config, polkadot_config, id, - |_| Ok(Default::default()), + |client, transaction_pool| Box::new(rpc::Builder::new(client, transaction_pool)), parachain_build_import_queue::<_, _, AuraId>, |client, prometheus_registry, diff --git a/pallets/asset-manager/src/benchmarking.rs b/pallets/asset-manager/src/benchmarking.rs index dac3ae3e4..47dfaf197 100644 --- a/pallets/asset-manager/src/benchmarking.rs +++ b/pallets/asset-manager/src/benchmarking.rs @@ -34,11 +34,11 @@ fn assert_last_event(generic_event: ::Event) { benchmarks! { where_clause { where >::AssetLocation: From } + register_asset { let location = >::AssetLocation::default(); let metadata = >::AssetRegistrarMetadata::default(); - - }: _(RawOrigin::Root, location.clone(), metadata.clone()) + }: _(RawOrigin::Root, location.clone(), metadata) verify { assert_eq!(Pallet::::asset_id_location(>::StartNonNativeAssetId::get()), Some(location)); } @@ -47,21 +47,17 @@ benchmarks! { let start = >::StartNonNativeAssetId::get(); let end = start + 1000; for i in start..end { - let location: MultiLocation = MultiLocation::new(0, X1(Parachain(i))); let location = >::AssetLocation::from(location.clone()); let metadata = >::AssetRegistrarMetadata::default(); - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; Pallet::::set_units_per_second(RawOrigin::Root.into(), i, 0)?; } - // does not really matter what we register, as long as it is different than the previous let location = >::AssetLocation::default(); let metadata = >::AssetRegistrarMetadata::default(); let amount = 10; - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; - + Pallet::::register_asset(RawOrigin::Root.into(), location, metadata)?; }: _(RawOrigin::Root, end, amount) verify { assert_eq!(Pallet::::get_units_per_second(end), Some(amount)); @@ -71,18 +67,15 @@ benchmarks! { let start = >::StartNonNativeAssetId::get(); let end = start + 1000; for i in start..end { - let location: MultiLocation = MultiLocation::new(0, X1(Parachain(i))); let location = >::AssetLocation::from(location.clone()); let metadata = >::AssetRegistrarMetadata::default(); - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; } - // does not really matter what we register, as long as it is different than the previous let location = >::AssetLocation::default(); let metadata = >::AssetRegistrarMetadata::default(); - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; + Pallet::::register_asset(RawOrigin::Root.into(), location, metadata)?; let new_location = >::AssetLocation::from(MultiLocation::new(0, X1(Parachain(end)))); }: _(RawOrigin::Root, end, new_location.clone()) verify { @@ -93,18 +86,15 @@ benchmarks! { let start = >::StartNonNativeAssetId::get(); let end = start + 1000; for i in start..end { - let location: MultiLocation = MultiLocation::new(0, X1(Parachain(i))); let location = >::AssetLocation::from(location.clone()); let metadata = >::AssetRegistrarMetadata::default(); - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; } - // does not really matter what we register, as long as it is different than the previous let location = >::AssetLocation::default(); let metadata = >::AssetRegistrarMetadata::default(); - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; + Pallet::::register_asset(RawOrigin::Root.into(), location, metadata.clone())?; }: _(RawOrigin::Root, end, metadata.clone()) verify { assert_last_event::(Event::AssetMetadataUpdated { asset_id: end, metadata }.into()); @@ -114,19 +104,16 @@ benchmarks! { let start = >::StartNonNativeAssetId::get(); let end = start + 1000; for i in start..end { - let location = >::AssetLocation::from(MultiLocation::new(0, X1(Parachain(i)))); let metadata = >::AssetRegistrarMetadata::default(); - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; } - let beneficiary: T::AccountId = whitelisted_caller(); let amount = 100; // does not really matter what we register, as long as it is different than the previous let location = >::AssetLocation::default(); let metadata = >::AssetRegistrarMetadata::default(); - Pallet::::register_asset(RawOrigin::Root.into(), location.clone(), metadata.clone())?; + Pallet::::register_asset(RawOrigin::Root.into(), location, metadata)?; }: _(RawOrigin::Root, end, beneficiary.clone(), amount) verify { assert_last_event::(Event::AssetMinted { asset_id: end, beneficiary, amount }.into()); diff --git a/pallets/collator-selection/src/benchmarking.rs b/pallets/collator-selection/src/benchmarking.rs index d2e858eac..d4d8972a2 100644 --- a/pallets/collator-selection/src/benchmarking.rs +++ b/pallets/collator-selection/src/benchmarking.rs @@ -130,7 +130,7 @@ benchmarks! { let origin = T::UpdateOrigin::successful_origin(); }: { assert_ok!( - >::set_desired_candidates(origin, max.clone()) + >::set_desired_candidates(origin, max) ); } verify { @@ -142,7 +142,7 @@ benchmarks! { let origin = T::UpdateOrigin::successful_origin(); }: { assert_ok!( - >::set_candidacy_bond(origin, bond.clone()) + >::set_candidacy_bond(origin, bond) ); } verify { @@ -186,7 +186,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let bond: BalanceOf = T::Currency::minimum_balance() * 2u32.into(); - T::Currency::make_free_balance_be(&caller, bond.clone()); + T::Currency::make_free_balance_be(&caller, bond); >::set_keys( RawOrigin::Signed(caller.clone()).into(), @@ -249,7 +249,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let bond: BalanceOf = T::Currency::minimum_balance() * 2u32.into(); - T::Currency::make_free_balance_be(&caller, bond.clone()); + T::Currency::make_free_balance_be(&caller, bond); >::set_keys( RawOrigin::Signed(caller.clone()).into(), diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 83afccc17..7085a1bfc 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -192,7 +192,7 @@ pub mod pallet { pub(super) type BlockCount = u32; #[pallet::type_value] pub(super) fn StartingBlockCount() -> BlockCount { - 0u32.into() + 0u32 } #[pallet::storage] pub(super) type BlocksPerCollatorThisSession = @@ -613,15 +613,13 @@ pub mod pallet { kick_candidates.iter().for_each(|(acc_id,my_blocks_this_session)| { if *my_blocks_this_session < evict_below_blocks { // If our validator is not also a candidate we're invulnerable or already kicked - if let Some(_) = candidates.iter().find(|&x|{x.who == *acc_id}) - { - Self::try_remove_candidate(&acc_id) - .and_then(|_| { + if candidates.iter().any(|x| x.who == *acc_id) { + Self::try_remove_candidate(acc_id) + .map(|_| { removed_account_ids.push(acc_id.clone()); log::info!("Removed collator of account {:?} as it only produced {} blocks this session which is below acceptable threshold of {}", &acc_id, my_blocks_this_session,evict_below_blocks); - Ok(()) }) - .unwrap_or_else(|why| -> () { + .unwrap_or_else(|why| { log::warn!("Failed to remove candidate due to underperformance {:?}", why); debug_assert!(false, "failed to remove candidate {:?}", why); }); diff --git a/pallets/collator-selection/src/migrations.rs b/pallets/collator-selection/src/migrations.rs index f6fa7cb2e..3f4460c67 100644 --- a/pallets/collator-selection/src/migrations.rs +++ b/pallets/collator-selection/src/migrations.rs @@ -23,7 +23,8 @@ use frame_support::{ traits::{Get, PalletInfoAccess, StorageVersion}, Twox64Concat, }; -/// This migrates the pallet from the standard version by parity to our modified storage + +/// This migrates the pallet from the standard version by parity to our modified storage. impl Pallet { pub fn migrate_v0_to_v1() -> frame_support::weights::Weight { use frame_support::migration::{ @@ -68,7 +69,7 @@ impl Pallet { pub fn pre_migrate_v0_to_v1() -> Result<(), &'static str> { use frame_support::migration::{have_storage_value, storage_key_iter}; let chainver = Self::on_chain_storage_version(); - if !(chainver < 1) { + if chainver >= 1 { return Err("Migration to V1 does not apply"); } if !have_storage_value(Self::name().as_bytes(), b"KickThreshold", &[]) { @@ -87,7 +88,7 @@ impl Pallet { pub fn post_migrate_v0_to_v1() -> Result<(), &'static str> { use frame_support::migration::{have_storage_value, storage_key_iter}; - if !(Self::on_chain_storage_version() == 1) { + if Self::on_chain_storage_version() != 1 { return Err("storage version not upgraded"); } if have_storage_value(Self::name().as_bytes(), b"KickThreshold", &[]) { diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs index b44111569..98cb6d631 100644 --- a/pallets/manta-pay/src/rpc.rs +++ b/pallets/manta-pay/src/rpc.rs @@ -16,7 +16,7 @@ //! MantaPay RPC Interfaces -use crate::{runtime::MantaPayPullRuntimeApi, PullResponse}; +use crate::{runtime::PullRuntimeApi, PullResponse}; use alloc::sync::Arc; use core::marker::PhantomData; use jsonrpc_core::{Error, ErrorCode, Result}; @@ -59,7 +59,7 @@ impl PullApi for Pull where B: Block, C: 'static + ProvideRuntimeApi + HeaderBackend, - C::Api: MantaPayPullRuntimeApi, + C::Api: PullRuntimeApi, { #[inline] fn pull(&self, checkpoint: Checkpoint) -> Result { diff --git a/pallets/manta-pay/src/runtime.rs b/pallets/manta-pay/src/runtime.rs index 0e34d65b7..c7b9f06e4 100644 --- a/pallets/manta-pay/src/runtime.rs +++ b/pallets/manta-pay/src/runtime.rs @@ -20,7 +20,7 @@ use crate::PullResponse; use manta_pay::signer::RawCheckpoint; sp_api::decl_runtime_apis! { - pub trait MantaPayPullRuntimeApi { + pub trait PullRuntimeApi { fn pull(checkpoint: RawCheckpoint) -> PullResponse; } } diff --git a/pallets/tx-pause/src/benchmarking.rs b/pallets/tx-pause/src/benchmarking.rs index 8c4a9ef07..cc4b68eeb 100644 --- a/pallets/tx-pause/src/benchmarking.rs +++ b/pallets/tx-pause/src/benchmarking.rs @@ -22,12 +22,10 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; - +use crate::Pallet as TransactionPause; use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; use frame_system::{EventRecord, RawOrigin}; -use crate::Pallet as TransactionPause; - pub fn assert_last_event(generic_event: ::Event) { let events = frame_system::Pallet::::events(); let system_event: ::Event = generic_event.into(); @@ -36,7 +34,6 @@ pub fn assert_last_event(generic_event: ::Event) { } benchmarks! { - // Benchmark `pause_transaction` extrinsic: pause_transaction { let pallet_name = b"Balances".to_vec(); @@ -44,7 +41,7 @@ benchmarks! { }: pause_transaction(RawOrigin::Root, pallet_name.clone(), function_name.clone()) verify { assert_last_event::( - Event::TransactionPaused(pallet_name.clone(), function_name.clone()).into() + Event::TransactionPaused(pallet_name.clone(), function_name).into() ); } @@ -53,13 +50,11 @@ benchmarks! { let origin: T::Origin = T::Origin::from(RawOrigin::Root); let pallet_name = b"Balances".to_vec(); let function_name = b"transfer".to_vec(); - - TransactionPause::::pause_transaction(origin.clone(), pallet_name.clone(), function_name.clone())?; - + TransactionPause::::pause_transaction(origin, pallet_name.clone(), function_name.clone())?; }: unpause_transaction(RawOrigin::Root, pallet_name.clone(), function_name.clone()) verify { assert_last_event::( - Event::TransactionUnpaused(pallet_name.clone(), function_name.clone()).into() + Event::TransactionUnpaused(pallet_name, function_name).into() ); } } diff --git a/pallets/vesting/src/benchmarking.rs b/pallets/vesting/src/benchmarking.rs index 4e49bd2e0..e62202c48 100644 --- a/pallets/vesting/src/benchmarking.rs +++ b/pallets/vesting/src/benchmarking.rs @@ -19,8 +19,6 @@ extern crate alloc; use super::*; -#[allow(unused_imports)] -use crate::Pallet as CalamariVesting; use core::{ops::Div, time::Duration}; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::assert_ok; @@ -49,12 +47,10 @@ fn init_setup< .saturated_into::() + 1; pallet_timestamp::Pallet::::set_timestamp(now); - let existential_deposit = >::ExistentialDeposit::get(); let amount = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); let source_caller = T::Lookup::unlookup(caller.clone()); - let _ = pallet_balances::Pallet::::make_free_balance_be(&caller, amount); - + let _ = pallet_balances::Pallet::::make_free_balance_be(caller, amount); assert_ok!(pallet_balances::Pallet::::set_balance( RawOrigin::Root.into(), source_caller, @@ -92,13 +88,20 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let recipient: T::AccountId = account("receiver", 0, SEED); let source_recipient = T::Lookup::unlookup(recipient.clone()); - init_setup::(&caller); let existential_deposit = >::ExistentialDeposit::get(); - let unvested = existential_deposit.saturating_mul(ED_MULTIPLIER.div(10u32).into()).saturated_into::().try_into().ok().unwrap(); - assert_ok!(crate::Pallet::::vested_transfer(RawOrigin::Signed(caller.clone()).into(), source_recipient, unvested)); + let unvested = existential_deposit + .saturating_mul(ED_MULTIPLIER.div(10u32).into()) + .saturated_into::() + .try_into() + .ok() + .unwrap(); + assert_ok!( + crate::Pallet::::vested_transfer( + RawOrigin::Signed(caller).into(), source_recipient, unvested + ) + ); assert!(crate::Pallet::::vesting_balance(&recipient).is_some()); - let now = Duration::from_secs(1660694400) .as_millis() .saturated_into::() @@ -113,7 +116,12 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); init_setup::(&caller); let existential_deposit = >::ExistentialDeposit::get(); - let unvested = existential_deposit.saturating_mul(ED_MULTIPLIER.div(10u32).into()).saturated_into::().try_into().ok().unwrap(); + let unvested = existential_deposit + .saturating_mul(ED_MULTIPLIER.div(10u32).into()) + .saturated_into::() + .try_into() + .ok() + .unwrap(); let recipient: T::AccountId = account("receiver", 0, SEED); let source_recipient = T::Lookup::unlookup(recipient.clone()); }: _(RawOrigin::Signed(caller.clone()), source_recipient, unvested) diff --git a/runtime/calamari/src/lib.rs b/runtime/calamari/src/lib.rs index a808d2f13..a829413b6 100644 --- a/runtime/calamari/src/lib.rs +++ b/runtime/calamari/src/lib.rs @@ -899,8 +899,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_asset_manager, AssetManager); let storage_info = AllPalletsReversedWithSystemFirst::storage_info(); - - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index 23f4b4ee0..d2aec5dc1 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -843,7 +843,7 @@ impl_runtime_apis! { } } - impl pallet_manta_pay::runtime::MantaPayPullRuntimeApi for Runtime { + impl pallet_manta_pay::runtime::PullRuntimeApi for Runtime { fn pull(checkpoint: pallet_manta_pay::RawCheckpoint) -> pallet_manta_pay::PullResponse { MantaPay::pull(checkpoint.into()) } diff --git a/runtime/manta/src/lib.rs b/runtime/manta/src/lib.rs index 3fc19f2f1..b10e7255a 100644 --- a/runtime/manta/src/lib.rs +++ b/runtime/manta/src/lib.rs @@ -795,12 +795,10 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_session, SessionBench::); list_benchmark!(list, extra, pallet_utility, Utility); list_benchmark!(list, extra, pallet_multisig, Multisig); - list_benchmark!(list, extra, pallet_tx_pause, TransactionPause); let storage_info = AllPalletsReversedWithSystemFirst::storage_info(); - - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -856,7 +854,6 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { let relay_chain_slot = relay_state_proof .read_slot() .expect("Could not read the relay chain slot from the proof"); - let inherent_data = cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( relay_chain_slot, @@ -864,7 +861,6 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { ) .create_inherent_data() .expect("Could not create the timestamp inherent data"); - inherent_data.check_extrinsics(block) } } From a82894c85eb77f790b1d897422144a606201aff1 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Fri, 6 May 2022 23:23:52 -0400 Subject: [PATCH 11/24] feat: add custom Dolphin RPC Signed-off-by: Brandon H. Gomes --- node/src/command.rs | 16 +++++++++++++--- node/src/rpc/mod.rs | 7 +++++-- node/src/service.rs | 11 +++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index 624b5ed24..b0751b63b 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -17,6 +17,7 @@ use crate::{ chain_specs, cli::{Cli, RelayChainCli, Subcommand}, + rpc::{self, Builder}, service::{new_partial, CalamariRuntimeExecutor, DolphinRuntimeExecutor, MantaRuntimeExecutor}, }; use codec::Encode; @@ -436,7 +437,10 @@ pub fn run() -> Result<()> { manta_runtime::RuntimeApi, MantaRuntimeExecutor, AuraId, - >(config, polkadot_config, id) + _, + >(config, polkadot_config, id, |c, p| { + Box::new(Builder::new(c, p)) + }) .await .map(|r| r.0) .map_err(Into::into) @@ -445,7 +449,10 @@ pub fn run() -> Result<()> { calamari_runtime::RuntimeApi, CalamariRuntimeExecutor, AuraId, - >(config, polkadot_config, id) + _, + >(config, polkadot_config, id, |c, p| { + Box::new(Builder::new(c, p)) + }) .await .map(|r| r.0) .map_err(Into::into) @@ -454,7 +461,10 @@ pub fn run() -> Result<()> { dolphin_runtime::RuntimeApi, DolphinRuntimeExecutor, AuraId, - >(config, polkadot_config, id) + _, + >(config, polkadot_config, id, |c, p| { + Box::new(Builder::<_, _, rpc::Dolphin>::new(c, p)) + }) .await .map(|r| r.0) .map_err(Into::into) diff --git a/node/src/rpc/mod.rs b/node/src/rpc/mod.rs index 45751878b..b4aac119d 100644 --- a/node/src/rpc/mod.rs +++ b/node/src/rpc/mod.rs @@ -19,8 +19,11 @@ use alloc::sync::Arc; use core::marker::PhantomData; -pub mod common; -pub mod dolphin; +mod common; +mod dolphin; + +pub use common::Common; +pub use dolphin::Dolphin; /// RPC Extension Type pub type RpcExtension = jsonrpc_core::IoHandler; diff --git a/node/src/service.rs b/node/src/service.rs index 5aa75822b..ca7ceb99d 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -544,10 +544,11 @@ where } /// Start a calamari/manta parachain node. -pub async fn start_parachain_node( +pub async fn start_parachain_node( parachain_config: Configuration, polkadot_config: Configuration, id: ParaId, + rpc: RPC, ) -> Result<(TaskManager, Arc>), Error> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, @@ -565,12 +566,18 @@ where Executor: sc_executor::NativeExecutionDispatch + 'static, <::Pair as Pair>::Signature: TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, + RPC: Fn( + Arc>, + Arc>, + ) -> Box< + (dyn sc_service::RpcExtensionBuilder + Send + 'static), + >, { start_node_impl::( parachain_config, polkadot_config, id, - |client, transaction_pool| Box::new(rpc::Builder::new(client, transaction_pool)), + rpc, parachain_build_import_queue::<_, _, AuraId>, |client, prometheus_registry, From 13d65817c26702904b66cec75399ca8542557cc8 Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Sat, 7 May 2022 00:13:42 -0400 Subject: [PATCH 12/24] fix: use insertion-ordered void number StorageMap Signed-off-by: Brandon H. Gomes --- pallets/manta-pay/src/lib.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index fbe7db1e6..3532453c6 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -165,6 +165,16 @@ pub mod pallet { #[pallet::storage] pub(super) type VoidNumberSet = StorageMap<_, Identity, VoidNumber, (), ValueQuery>; + /// Void Number Ordered by Insertion + #[pallet::storage] + pub(super) type InsertionOrderedVoidNumbers = + StorageMap<_, Identity, u64, VoidNumber, ValueQuery>; + + /// The size of Void Number Set + /// FIXME: this should be removed. + #[pallet::storage] + pub(super) type VoidNumberSetSize = StorageValue<_, u64, ValueQuery>; + #[pallet::call] impl Pallet { /// Transforms some public assets into private ones using `post`, withdrawing the public @@ -502,10 +512,10 @@ pub mod pallet { #[inline] fn pull_senders(sender_index: &mut usize) -> (bool, SenderChunk) { let mut senders = Vec::new(); - let mut iter = VoidNumberSet::::iter().skip(*sender_index); + let mut iter = InsertionOrderedVoidNumbers::::iter().skip(*sender_index); for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { match iter.next() { - Some((sender, _)) => { + Some((_, sender)) => { *sender_index += 1; senders.push(sender); } @@ -696,8 +706,16 @@ where I: IntoIterator, { let _ = super_key; + let index = VoidNumberSetSize::::get(); + let mut i = 0; for (_, void_number) in iter { - VoidNumberSet::::insert(encode(&void_number.0), ()); + let void_number = encode(&void_number.0); + VoidNumberSet::::insert(void_number, ()); + InsertionOrderedVoidNumbers::::insert(index + i, void_number); + i += 1; + } + if i != 0 { + VoidNumberSetSize::::set(index + i); } } } From 9f217c0673a6ce6ff1c912200216384b23af9aaa Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Sat, 7 May 2022 09:27:17 -0400 Subject: [PATCH 13/24] fix: use Pallet import Signed-off-by: Brandon H. Gomes --- pallets/vesting/src/benchmarking.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/vesting/src/benchmarking.rs b/pallets/vesting/src/benchmarking.rs index e62202c48..90d941750 100644 --- a/pallets/vesting/src/benchmarking.rs +++ b/pallets/vesting/src/benchmarking.rs @@ -19,6 +19,7 @@ extern crate alloc; use super::*; +use crate::Pallet; use core::{ops::Div, time::Duration}; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::assert_ok; @@ -132,7 +133,7 @@ benchmarks! { } impl_benchmark_test_suite!( - CalamariVesting, + Pallet, crate::mock::ExtBuilder::default() .existential_deposit(1) .build(), From 3b8e2e0d510bd313d4a44d05936e7f13209b605c Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Sat, 7 May 2022 10:13:03 -0400 Subject: [PATCH 14/24] chore: add CHANGELOG entry Signed-off-by: Brandon H. Gomes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3a27a050..a84d052b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Breaking changes ### Features +- [\#529](https://github.com/Manta-Network/Manta/pull/529) Add RPC for MantaPay to synchronize with latest ledger state ### Improvements From d16332f9ea43955f3640f3de499946db322058ae Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Sat, 7 May 2022 10:39:22 -0400 Subject: [PATCH 15/24] chore: set default-run to the node binary Signed-off-by: Brandon H. Gomes --- Cargo.toml | 1 - node/Cargo.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 68d8da57d..41e0d28fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,3 @@ - [workspace] resolver = "2" members = [ diff --git a/node/Cargo.toml b/node/Cargo.toml index 22cf385d5..f974e9eb1 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -9,6 +9,7 @@ license = 'GPL-3.0' name = 'manta' repository = 'https://github.com/Manta-Network/Manta/' version = '3.1.5' +default-run = "manta" [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] From 04bedc4298f1ef4a12520b861cb8fc8b111c5a85 Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Wed, 25 May 2022 23:01:46 -0400 Subject: [PATCH 16/24] manual rpc test works (#566) * manual rpc test works Signed-off-by: Shumo Chu * clean up Signed-off-by: Shumo Chu --- pallets/manta-pay/src/rpc.rs | 2 +- tests/README.md | 7 + tests/index.ts | 42 ++ tests/package.json | 19 + tests/tsconfig.json | 10 + tests/yarn.lock | 786 +++++++++++++++++++++++++++++++++++ 6 files changed, 865 insertions(+), 1 deletion(-) create mode 100644 tests/README.md create mode 100644 tests/index.ts create mode 100644 tests/package.json create mode 100644 tests/tsconfig.json create mode 100644 tests/yarn.lock diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs index 98cb6d631..ea07f6bee 100644 --- a/pallets/manta-pay/src/rpc.rs +++ b/pallets/manta-pay/src/rpc.rs @@ -31,7 +31,7 @@ use sp_runtime::{generic::BlockId, traits::Block}; pub trait PullApi { /// Returns the update required to be synchronized with the ledger starting from /// `checkpoint`. - #[rpc(name = "manta_pay_pull")] + #[rpc(name = "mantaPay_pull")] fn pull(&self, checkpoint: Checkpoint) -> Result; } diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 000000000..0e8332225 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,7 @@ +Functional Tests for Manta +========================== + +Get data from `mantaPay_pull` rpc methods: +```bash +yarn ts-node index.ts +``` \ No newline at end of file diff --git a/tests/index.ts b/tests/index.ts new file mode 100644 index 000000000..ea0210fe8 --- /dev/null +++ b/tests/index.ts @@ -0,0 +1,42 @@ +import { ApiPromise, WsProvider } from '@polkadot/api'; + +// Construct +const wsProvider = new WsProvider('ws://127.0.0.1:9800'); +async function main(){ + const api = await ApiPromise.create({ + provider: wsProvider, + types: { + Checkpoint: { + receiver_index: '[u64; 256]', + sender_index: 'u64' + }, + EncryptedNote: { + ephemeral_public_key: '[u8; 32]', + ciphertext: '[u8; 68]' + }, + PullResponse: { + should_continue: 'bool', + checkpoint: 'Checkpoint', + receivers: 'Vec<([u8; 32], EncryptedNote)>', + senders: 'Vec<[u8; 32]>', + } + }, + rpc: { + mantapay: { + pull: { + description: 'pull from mantaPay', + params: [ + { + name: 'checkpoint', + type: 'Checkpoint' + } + ], + type: 'PullResponse' + } + } + }}); + const junk = await (api.rpc as any).mantapay.pull({receiver_index: new Array(256).fill(0), sender_index: 0}); + console.log(junk); +} + +main().catch(console.error).finally(() => process.exit()); diff --git a/tests/package.json b/tests/package.json new file mode 100644 index 000000000..0fd871f83 --- /dev/null +++ b/tests/package.json @@ -0,0 +1,19 @@ +{ + "name": "manta-tests", + "version": "1.0.0", + "description": "Functional Tests for Manta", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@polkadot/api": "^7.10.1", + "@polkadot/types": "^7.10.1", + "@types/yargs": "^17.0.0", + "ts-node": "^10.8.0", + "typescript": "4.6.4" + } +} diff --git a/tests/tsconfig.json b/tests/tsconfig.json new file mode 100644 index 000000000..7c11c3f12 --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/tests/yarn.lock b/tests/yarn.lock new file mode 100644 index 000000000..ecabcf5fe --- /dev/null +++ b/tests/yarn.lock @@ -0,0 +1,786 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/runtime@^7.17.8": + version "7.18.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.0.tgz#6d77142a19cb6088f0af662af1ada37a604d34ae" + integrity sha512-YMQvx/6nKEaucl0MY56mwIG483xk8SDNdlUwb2Ts6FUpr7fm85DxEmsY18LXBNhcTz6tO6JwZV8w1W06v8UKeg== + dependencies: + regenerator-runtime "^0.13.4" + +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + +"@jridgewell/resolve-uri@^3.0.3": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz#30cd49820a962aff48c8fffc5cd760151fca61fe" + integrity sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.13" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz#b6461fb0c2964356c469e115f504c95ad97ab88c" + integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@noble/hashes@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.0.0.tgz#d5e38bfbdaba174805a4e649f13be9a9ed3351ae" + integrity sha512-DZVbtY62kc3kkBtMHqwCOfXrT/hnoORy5BJ4+HU1IR59X0KWAOqsfzQPcUl/lQLlG7qXbe/fZ3r/emxtAl+sqg== + +"@noble/secp256k1@1.5.5": + version "1.5.5" + resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.5.5.tgz#315ab5745509d1a8c8e90d0bdf59823ccf9bcfc3" + integrity sha512-sZ1W6gQzYnu45wPrWx8D3kwI2/U29VYTx9OjbDAd7jwRItJ0cSTMPRL/C8AWZFn9kWFLQGqEXVEE86w4Z8LpIQ== + +"@polkadot/api-augment@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-augment/-/api-augment-7.15.1.tgz#120b766feeaa96996f1c6717a5261c2e0845c1e0" + integrity sha512-7csQLS6zuYuGq7W1EkTBz1ZmxyRvx/Qpz7E7zPSwxmY8Whb7Yn2effU9XF0eCcRpyfSW8LodF8wMmLxGYs1OaQ== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/api-base" "7.15.1" + "@polkadot/rpc-augment" "7.15.1" + "@polkadot/types" "7.15.1" + "@polkadot/types-augment" "7.15.1" + "@polkadot/types-codec" "7.15.1" + "@polkadot/util" "^8.7.1" + +"@polkadot/api-base@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-base/-/api-base-7.15.1.tgz#7567595be68431cc4085c48b18ba66933ff7b4d9" + integrity sha512-UlhLdljJPDwGpm5FxOjvJNFTxXMRFaMuVNx6EklbuetbBEJ/Amihhtj0EJRodxQwtZ4ZtPKYKt+g+Dn7OJJh4g== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/rpc-core" "7.15.1" + "@polkadot/types" "7.15.1" + "@polkadot/util" "^8.7.1" + rxjs "^7.5.5" + +"@polkadot/api-derive@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-7.15.1.tgz#450542bb7d848013225d6c8480648340e5ee6a61" + integrity sha512-CsOQppksQBaa34L1fWRzmfQQpoEBwfH0yTTQxgj3h7rFYGVPxEKGeFjo1+IgI2vXXvOO73Z8E4H/MnbxvKrs1Q== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/api" "7.15.1" + "@polkadot/api-augment" "7.15.1" + "@polkadot/api-base" "7.15.1" + "@polkadot/rpc-core" "7.15.1" + "@polkadot/types" "7.15.1" + "@polkadot/types-codec" "7.15.1" + "@polkadot/util" "^8.7.1" + "@polkadot/util-crypto" "^8.7.1" + rxjs "^7.5.5" + +"@polkadot/api@7.15.1", "@polkadot/api@^7.10.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-7.15.1.tgz#24eaeaa8ffbc6f30ff3d9846a816a18a688ceb8b" + integrity sha512-z0z6+k8+R9ixRMWzfsYrNDnqSV5zHKmyhTCL0I7+1I081V18MJTCFUKubrh0t1gD0/FCt3U9Ibvr4IbtukYLrQ== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/api-augment" "7.15.1" + "@polkadot/api-base" "7.15.1" + "@polkadot/api-derive" "7.15.1" + "@polkadot/keyring" "^8.7.1" + "@polkadot/rpc-augment" "7.15.1" + "@polkadot/rpc-core" "7.15.1" + "@polkadot/rpc-provider" "7.15.1" + "@polkadot/types" "7.15.1" + "@polkadot/types-augment" "7.15.1" + "@polkadot/types-codec" "7.15.1" + "@polkadot/types-create" "7.15.1" + "@polkadot/types-known" "7.15.1" + "@polkadot/util" "^8.7.1" + "@polkadot/util-crypto" "^8.7.1" + eventemitter3 "^4.0.7" + rxjs "^7.5.5" + +"@polkadot/keyring@^8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-8.7.1.tgz#07cf6d6ee351dcf70fbf965b1d6d96c5025ae1b8" + integrity sha512-t6ZgQVC+nQT7XwbWtEhkDpiAzxKVJw8Xd/gWdww6xIrawHu7jo3SGB4QNdPgkf8TvDHYAAJiupzVQYAlOIq3GA== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/util" "8.7.1" + "@polkadot/util-crypto" "8.7.1" + +"@polkadot/networks@8.7.1", "@polkadot/networks@^8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/networks/-/networks-8.7.1.tgz#26c2ec6158c985bb77c510d98a3ab1c7e049f89c" + integrity sha512-8xAmhDW0ry5EKcEjp6VTuwoTm0DdDo/zHsmx88P6sVL87gupuFsL+B6TrsYLl8GcaqxujwrOlKB+CKTUg7qFKg== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/util" "8.7.1" + "@substrate/ss58-registry" "^1.17.0" + +"@polkadot/rpc-augment@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-augment/-/rpc-augment-7.15.1.tgz#391a42a9c3e553335a2a544598a717b47654ad6e" + integrity sha512-sK0+mphN7nGz/eNPsshVi0qd0+N0Pqxuebwc1YkUGP0f9EkDxzSGp6UjGcSwWVaAtk9WZZ1MpK1Jwb/2GrKV7Q== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/rpc-core" "7.15.1" + "@polkadot/types" "7.15.1" + "@polkadot/types-codec" "7.15.1" + "@polkadot/util" "^8.7.1" + +"@polkadot/rpc-core@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-7.15.1.tgz#47855cf05bd2f8dbf87d9f1f77343114e61c664a" + integrity sha512-4Sb0e0PWmarCOizzxQAE1NQSr5z0n+hdkrq3+aPohGu9Rh4PodG+OWeIBy7Ov/3GgdhNQyBLG+RiVtliXecM3g== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/rpc-augment" "7.15.1" + "@polkadot/rpc-provider" "7.15.1" + "@polkadot/types" "7.15.1" + "@polkadot/util" "^8.7.1" + rxjs "^7.5.5" + +"@polkadot/rpc-provider@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-7.15.1.tgz#a213de907a6f4f480c3c819aa95e4e60d4247f84" + integrity sha512-n0RWfSaD/r90JXeJkKry1aGZwJeBUUiMpXUQ9Uvp6DYBbYEDs0fKtWLpdT3PdFrMbe5y3kwQmNLxwe6iF4+mzg== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/keyring" "^8.7.1" + "@polkadot/types" "7.15.1" + "@polkadot/types-support" "7.15.1" + "@polkadot/util" "^8.7.1" + "@polkadot/util-crypto" "^8.7.1" + "@polkadot/x-fetch" "^8.7.1" + "@polkadot/x-global" "^8.7.1" + "@polkadot/x-ws" "^8.7.1" + "@substrate/connect" "0.7.0-alpha.0" + eventemitter3 "^4.0.7" + mock-socket "^9.1.2" + nock "^13.2.4" + +"@polkadot/types-augment@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-augment/-/types-augment-7.15.1.tgz#437047f961b8d29e5ffd4fd59cd35f0e6374750b" + integrity sha512-aqm7xT/66TCna0I2utpIekoquKo0K5pnkA/7WDzZ6gyD8he2h0IXfe8xWjVmuyhjxrT/C/7X1aUF2Z0xlOCwzQ== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/types" "7.15.1" + "@polkadot/types-codec" "7.15.1" + "@polkadot/util" "^8.7.1" + +"@polkadot/types-codec@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-codec/-/types-codec-7.15.1.tgz#c0155867efd3ae35e15fea6a8aab49c2c63988fa" + integrity sha512-nI11dT7FGaeDd/fKPD8iJRFGhosOJoyjhZ0gLFFDlKCaD3AcGBRTTY8HFJpP/5QXXhZzfZsD93fVKrosnegU0Q== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/util" "^8.7.1" + +"@polkadot/types-create@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-create/-/types-create-7.15.1.tgz#ec4cafa314a82a25a109f0f52207e9169fc9b003" + integrity sha512-+HiaHn7XOwP0kv/rVdORlVkNuMoxuvt+jd67A/CeEreJiXqRLu+S61Mdk7wi6719PTaOal1hTDFfyGrtUd8FSQ== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/types-codec" "7.15.1" + "@polkadot/util" "^8.7.1" + +"@polkadot/types-known@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-7.15.1.tgz#71dbf0835a48cdc97d0f50b0000298687e29818d" + integrity sha512-LMcNP0CxT84DqAKV62/qDeeIVIJCR5yzE9b+9AsYhyfhE4apwxjrThqZA7K0CF56bOdQJSexAerYB/jwk2IijA== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/networks" "^8.7.1" + "@polkadot/types" "7.15.1" + "@polkadot/types-codec" "7.15.1" + "@polkadot/types-create" "7.15.1" + "@polkadot/util" "^8.7.1" + +"@polkadot/types-support@7.15.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-support/-/types-support-7.15.1.tgz#9c274759647dd89d46ea9cf74d593bcedcd85527" + integrity sha512-FIK251ffVo+NaUXLlaJeB5OvT7idDd3uxaoBM6IwsS87rzt2CcWMyCbu0uX89AHZUhSviVx7xaBxfkGEqMePWA== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/util" "^8.7.1" + +"@polkadot/types@7.15.1", "@polkadot/types@^7.10.1": + version "7.15.1" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-7.15.1.tgz#fb78886f4437fbc472e01019846fb1f229d2a177" + integrity sha512-KawZVS+eLR1D6O7c/P5cSUwr6biM9Qd2KwKtJIO8l1Mrxp7r+y2tQnXSSXVAd6XPdb3wVMhnIID+NW3W99TAnQ== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/keyring" "^8.7.1" + "@polkadot/types-augment" "7.15.1" + "@polkadot/types-codec" "7.15.1" + "@polkadot/types-create" "7.15.1" + "@polkadot/util" "^8.7.1" + "@polkadot/util-crypto" "^8.7.1" + rxjs "^7.5.5" + +"@polkadot/util-crypto@8.7.1", "@polkadot/util-crypto@^8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-8.7.1.tgz#f9fcca2895b5f160ce1c2faa0aa3054cc7aa4655" + integrity sha512-TaSuJ2aNrB5sYK7YXszkEv24nYJKRFqjF2OrggoMg6uYxUAECvTkldFnhtgeizMweRMxJIBu6bMHlSIutbWgjw== + dependencies: + "@babel/runtime" "^7.17.8" + "@noble/hashes" "1.0.0" + "@noble/secp256k1" "1.5.5" + "@polkadot/networks" "8.7.1" + "@polkadot/util" "8.7.1" + "@polkadot/wasm-crypto" "^5.1.1" + "@polkadot/x-bigint" "8.7.1" + "@polkadot/x-randomvalues" "8.7.1" + "@scure/base" "1.0.0" + ed2curve "^0.3.0" + tweetnacl "^1.0.3" + +"@polkadot/util@8.7.1", "@polkadot/util@^8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-8.7.1.tgz#27fe93bf7b8345276f10cfe9c0380510cd4584f6" + integrity sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/x-bigint" "8.7.1" + "@polkadot/x-global" "8.7.1" + "@polkadot/x-textdecoder" "8.7.1" + "@polkadot/x-textencoder" "8.7.1" + "@types/bn.js" "^5.1.0" + bn.js "^5.2.0" + ip-regex "^4.3.0" + +"@polkadot/wasm-crypto-asmjs@^5.1.1": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-asmjs/-/wasm-crypto-asmjs-5.1.1.tgz#6648e9c6f627501f61aef570e110022f2be1eff2" + integrity sha512-1WBwc2G3pZMKW1T01uXzKE30Sg22MXmF3RbbZiWWk3H2d/Er4jZQRpjumxO5YGWan+xOb7HQQdwnrUnrPgbDhg== + dependencies: + "@babel/runtime" "^7.17.8" + +"@polkadot/wasm-crypto-wasm@^5.1.1": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-wasm/-/wasm-crypto-wasm-5.1.1.tgz#dc371755a05fe93f87a2754a2bcf1ff42e4bb541" + integrity sha512-F9PZ30J2S8vUNl2oY7Myow5Xsx5z5uNVpnNlJwlmY8IXBvyucvyQ4HSdhJsrbs4W1BfFc0mHghxgp0FbBCnf/Q== + dependencies: + "@babel/runtime" "^7.17.8" + +"@polkadot/wasm-crypto@^5.1.1": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-5.1.1.tgz#d1f8a0da631028ba904c374c1e8496ab3ba4636b" + integrity sha512-JCcAVfH8DhYuEyd4oX1ouByxhou0TvpErKn8kHjtzt7+tRoFi0nzWlmK4z49vszsV3JJgXxV81i10C0BYlwTcQ== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/wasm-crypto-asmjs" "^5.1.1" + "@polkadot/wasm-crypto-wasm" "^5.1.1" + +"@polkadot/x-bigint@8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/x-bigint/-/x-bigint-8.7.1.tgz#a496225def32e98c430c76b91c1579f48acf501a" + integrity sha512-ClkhgdB/KqcAKk3zA6Qw8wBL6Wz67pYTPkrAtImpvoPJmR+l4RARauv+MH34JXMUNlNb3aUwqN6lq2Z1zN+mJg== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/x-global" "8.7.1" + +"@polkadot/x-fetch@^8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/x-fetch/-/x-fetch-8.7.1.tgz#dc866e7aa87c39b2e64c87f734b8fbaf1b9190e1" + integrity sha512-ygNparcalYFGbspXtdtZOHvNXZBkNgmNO+um9C0JYq74K5OY9/be93uyfJKJ8JcRJtOqBfVDsJpbiRkuJ1PRfg== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/x-global" "8.7.1" + "@types/node-fetch" "^2.6.1" + node-fetch "^2.6.7" + +"@polkadot/x-global@8.7.1", "@polkadot/x-global@^8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/x-global/-/x-global-8.7.1.tgz#b972044125a4fe059f4aef7c15a4e22d18179095" + integrity sha512-WOgUor16IihgNVdiTVGAWksYLUAlqjmODmIK1cuWrLOZtV1VBomWcb3obkO9sh5P6iWziAvCB/i+L0vnTN9ZCA== + dependencies: + "@babel/runtime" "^7.17.8" + +"@polkadot/x-randomvalues@8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/x-randomvalues/-/x-randomvalues-8.7.1.tgz#b7cc358c2a6d20f7e7798d45d1d5c7ac8c9ab4f2" + integrity sha512-njt17MlfN6yNyNEti7fL12lr5qM6A1aSGkWKVuqzc7XwSBesifJuW4km5u6r2gwhXjH2eHDv9SoQ7WXu8vrrkg== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/x-global" "8.7.1" + +"@polkadot/x-textdecoder@8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz#b706ef98d5a033d02c633009fb8dab4a4f9d7d55" + integrity sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/x-global" "8.7.1" + +"@polkadot/x-textencoder@8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz#7820e30081e8e0a607c1c27b9e3486d82d1a723e" + integrity sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/x-global" "8.7.1" + +"@polkadot/x-ws@^8.7.1": + version "8.7.1" + resolved "https://registry.yarnpkg.com/@polkadot/x-ws/-/x-ws-8.7.1.tgz#501c63c575e04bba68bdc32448e2c9b692f0411e" + integrity sha512-Mt0tcNzGXyKnN3DQ06alkv+JLtTfXWu6zSypFrrKHSQe3u79xMQ1nSicmpT3gWLhIa8YF+8CYJXMrqaXgCnDhw== + dependencies: + "@babel/runtime" "^7.17.8" + "@polkadot/x-global" "8.7.1" + "@types/websocket" "^1.0.5" + websocket "^1.0.34" + +"@scure/base@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.0.0.tgz#109fb595021de285f05a7db6806f2f48296fcee7" + integrity sha512-gIVaYhUsy+9s58m/ETjSJVKHhKTBMmcRb9cEV5/5dwvfDlfORjKrFsDeDHWRrm6RjcPvCLZFwGJjAjLj1gg4HA== + +"@substrate/connect-extension-protocol@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@substrate/connect-extension-protocol/-/connect-extension-protocol-1.0.0.tgz#d452beda84b3ebfcf0e88592a4695e729a91e858" + integrity sha512-nFVuKdp71hMd/MGlllAOh+a2hAqt8m6J2G0aSsS/RcALZexxF9jodbFc62ni8RDtJboeOfXAHhenYOANvJKPIg== + +"@substrate/connect@0.7.0-alpha.0": + version "0.7.0-alpha.0" + resolved "https://registry.yarnpkg.com/@substrate/connect/-/connect-0.7.0-alpha.0.tgz#df605f4e808b58d146ad0272a79b2c4b870459a5" + integrity sha512-fvO7w++M8R95R/pGJFW9+cWOt8OYnnTfgswxtlPqSgzqX4tta8xcNQ51crC72FcL5agwSGkA1gc2/+eyTj7O8A== + dependencies: + "@substrate/connect-extension-protocol" "^1.0.0" + "@substrate/smoldot-light" "0.6.8" + eventemitter3 "^4.0.7" + +"@substrate/smoldot-light@0.6.8": + version "0.6.8" + resolved "https://registry.yarnpkg.com/@substrate/smoldot-light/-/smoldot-light-0.6.8.tgz#e626e25cd2386824f1164e7d7dda7258580c36e4" + integrity sha512-9lVwbG6wrtss0sd6013BJGe4WN4taujsGG49pwyt1Lj36USeL2Sb164TTUxmZF/g2NQEqDPwPROBdekQ2gFmgg== + dependencies: + buffer "^6.0.1" + pako "^2.0.4" + websocket "^1.0.32" + +"@substrate/ss58-registry@^1.17.0": + version "1.18.0" + resolved "https://registry.yarnpkg.com/@substrate/ss58-registry/-/ss58-registry-1.18.0.tgz#0744480e880ae8e557327557a2a7fc95577292ec" + integrity sha512-nAA1qsorxgdDnx5ie/FL90nM2riTNn72wIq8jtWsR8trsk1uTIHJgQQjEgviFCtMg4Ws9bEjo8DkWBgVGdPFmw== + +"@tsconfig/node10@^1.0.7": + version "1.0.8" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9" + integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg== + +"@tsconfig/node12@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c" + integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw== + +"@tsconfig/node14@^1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" + integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== + +"@tsconfig/node16@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" + integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== + +"@types/bn.js@^5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.0.tgz#32c5d271503a12653c62cf4d2b45e6eab8cebc68" + integrity sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA== + dependencies: + "@types/node" "*" + +"@types/node-fetch@^2.6.1": + version "2.6.1" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.1.tgz#8f127c50481db65886800ef496f20bbf15518975" + integrity sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + +"@types/node@*": + version "17.0.35" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.35.tgz#635b7586086d51fb40de0a2ec9d1014a5283ba4a" + integrity sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg== + +"@types/websocket@^1.0.5": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@types/websocket/-/websocket-1.0.5.tgz#3fb80ed8e07f88e51961211cd3682a3a4a81569c" + integrity sha512-NbsqiNX9CnEfC1Z0Vf4mE1SgAJ07JnRYcNex7AJ9zAVzmiGHmjKFEk7O4TJIsgv2B1sLEb6owKFZrACwdYngsQ== + dependencies: + "@types/node" "*" + +"@types/yargs-parser@*": + version "21.0.0" + resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b" + integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA== + +"@types/yargs@^17.0.0": + version "17.0.10" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.10.tgz#591522fce85d8739bca7b8bb90d048e4478d186a" + integrity sha512-gmEaFwpj/7f/ROdtIlci1R1VYU1J4j95m8T+Tj3iBgiBFKg1foE/PSl93bBd5T9LDXNPo8UlNN6W0qwD8O5OaA== + dependencies: + "@types/yargs-parser" "*" + +acorn-walk@^8.1.1: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + +acorn@^8.4.1: + version "8.7.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" + integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +bn.js@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" + integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== + +buffer@^6.0.1: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +bufferutil@^4.0.1: + version "4.0.6" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.6.tgz#ebd6c67c7922a0e902f053e5d8be5ec850e48433" + integrity sha512-jduaYOYtnio4aIAyc6UbvPCVcgq7nYpVnucyxr6eCYg/Woad9Hf/oxxBRDnGGjPfjUm6j5O/uBWhIu4iLebFaw== + dependencies: + node-gyp-build "^4.3.0" + +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + +d@1, d@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a" + integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== + dependencies: + es5-ext "^0.10.50" + type "^1.0.1" + +debug@^2.2.0: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@^4.1.0: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +ed2curve@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/ed2curve/-/ed2curve-0.3.0.tgz#322b575152a45305429d546b071823a93129a05d" + integrity sha512-8w2fmmq3hv9rCrcI7g9hms2pMunQr1JINfcjwR9tAyZqhtyaMN991lF/ZfHfr5tzZQ8c7y7aBgZbjfbd0fjFwQ== + dependencies: + tweetnacl "1.x.x" + +es5-ext@^0.10.35, es5-ext@^0.10.50: + version "0.10.61" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.61.tgz#311de37949ef86b6b0dcea894d1ffedb909d3269" + integrity sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA== + dependencies: + es6-iterator "^2.0.3" + es6-symbol "^3.1.3" + next-tick "^1.1.0" + +es6-iterator@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + integrity sha1-p96IkUGgWpSwhUQDstCg+/qY87c= + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-symbol@^3.1.1, es6-symbol@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.3.tgz#bad5d3c1bcdac28269f4cb331e431c78ac705d18" + integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== + dependencies: + d "^1.0.1" + ext "^1.1.2" + +eventemitter3@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +ext@^1.1.2: + version "1.6.0" + resolved "https://registry.yarnpkg.com/ext/-/ext-1.6.0.tgz#3871d50641e874cc172e2b53f919842d19db4c52" + integrity sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg== + dependencies: + type "^2.5.0" + +form-data@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +ip-regex@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5" + integrity sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q== + +is-typedarray@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= + +json-stringify-safe@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= + +lodash.set@^4.3.2: + version "4.3.2" + resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" + integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mock-socket@^9.1.2: + version "9.1.3" + resolved "https://registry.yarnpkg.com/mock-socket/-/mock-socket-9.1.3.tgz#bcb106c6b345001fa7619466fcf2f8f5a156b10f" + integrity sha512-uz8lx8c5wuJYJ21f5UtovqpV0+KJuVwE7cVOLNhrl2QW/CvmstOLRfjXnLSbfFHZtJtiaSGQu0oCJA8SmRcK6A== + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +next-tick@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" + integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== + +nock@^13.2.4: + version "13.2.4" + resolved "https://registry.yarnpkg.com/nock/-/nock-13.2.4.tgz#43a309d93143ee5cdcca91358614e7bde56d20e1" + integrity sha512-8GPznwxcPNCH/h8B+XZcKjYPXnUV5clOKCjAqyjsiqA++MpNx9E9+t8YPp0MbThO+KauRo7aZJ1WuIZmOrT2Ug== + dependencies: + debug "^4.1.0" + json-stringify-safe "^5.0.1" + lodash.set "^4.3.2" + propagate "^2.0.0" + +node-fetch@^2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== + dependencies: + whatwg-url "^5.0.0" + +node-gyp-build@^4.3.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.4.0.tgz#42e99687ce87ddeaf3a10b99dc06abc11021f3f4" + integrity sha512-amJnQCcgtRVw9SvoebO3BKGESClrfXGCUTX9hSn1OuGQTQBOZmVd0Z0OlecpuRksKvbsUqALE8jls/ErClAPuQ== + +pako@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.0.4.tgz#6cebc4bbb0b6c73b0d5b8d7e8476e2b2fbea576d" + integrity sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg== + +propagate@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45" + integrity sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag== + +regenerator-runtime@^0.13.4: + version "0.13.9" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" + integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== + +rxjs@^7.5.5: + version "7.5.5" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.5.tgz#2ebad89af0f560f460ad5cc4213219e1f7dd4e9f" + integrity sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw== + dependencies: + tslib "^2.1.0" + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= + +ts-node@^10.8.0: + version "10.8.0" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.0.tgz#3ceb5ac3e67ae8025c1950626aafbdecb55d82ce" + integrity sha512-/fNd5Qh+zTt8Vt1KbYZjRHCE9sI5i7nqfD/dzBBRDeVXZXS6kToW6R7tTU6Nd4XavFs0mAVCg29Q//ML7WsZYA== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + +tslib@^2.1.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" + integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== + +tweetnacl@1.x.x, tweetnacl@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" + integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== + +type@^1.0.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" + integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== + +type@^2.5.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/type/-/type-2.6.0.tgz#3ca6099af5981d36ca86b78442973694278a219f" + integrity sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ== + +typedarray-to-buffer@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" + integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== + dependencies: + is-typedarray "^1.0.0" + +typescript@4.6.4: + version "4.6.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" + integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== + +utf-8-validate@^5.0.2: + version "5.0.9" + resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.9.tgz#ba16a822fbeedff1a58918f2a6a6b36387493ea3" + integrity sha512-Yek7dAy0v3Kl0orwMlvi7TPtiCNrdfHNd7Gcc/pLq4BLXqfAmd0J7OWMizUQnTTJsyjKn02mU7anqwfmUP4J8Q== + dependencies: + node-gyp-build "^4.3.0" + +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= + +websocket@^1.0.32, websocket@^1.0.34: + version "1.0.34" + resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.34.tgz#2bdc2602c08bf2c82253b730655c0ef7dcab3111" + integrity sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ== + dependencies: + bufferutil "^4.0.1" + debug "^2.2.0" + es5-ext "^0.10.50" + typedarray-to-buffer "^3.1.5" + utf-8-validate "^5.0.2" + yaeti "^0.0.6" + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +yaeti@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/yaeti/-/yaeti-0.0.6.tgz#f26f484d72684cf42bedfb76970aa1608fbf9577" + integrity sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc= + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== From 59d1bc483574e67cedeeb28c7fb9c4805ea50669 Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Mon, 6 Jun 2022 21:32:28 -0400 Subject: [PATCH 17/24] fix compilation Signed-off-by: Shumo Chu --- node/src/command.rs | 15 ++++++++++++--- node/src/lib.rs | 25 ------------------------- node/src/main.rs | 13 ++++++++++++- node/src/service.rs | 28 +++++++++++----------------- pallets/manta-pay/src/types.rs | 8 ++++++-- 5 files changed, 41 insertions(+), 48 deletions(-) delete mode 100644 node/src/lib.rs diff --git a/node/src/command.rs b/node/src/command.rs index 2543a4443..f37f3aab9 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -436,7 +436,10 @@ pub fn run_with(cli: Cli) -> Result<()> { manta_runtime::RuntimeApi, MantaRuntimeExecutor, AuraId, - >(config, polkadot_config, collator_options, id) + _, + >(config, polkadot_config, collator_options, id, |c, p| { + Box::new(Builder::new(c, p)) + }) .await .map(|r| r.0) .map_err(Into::into) @@ -445,7 +448,10 @@ pub fn run_with(cli: Cli) -> Result<()> { calamari_runtime::RuntimeApi, CalamariRuntimeExecutor, AuraId, - >(config, polkadot_config, collator_options, id) + _, + >(config, polkadot_config, collator_options, id, |c, p| { + Box::new(Builder::new(c, p)) + }) .await .map(|r| r.0) .map_err(Into::into) @@ -454,7 +460,10 @@ pub fn run_with(cli: Cli) -> Result<()> { dolphin_runtime::RuntimeApi, DolphinRuntimeExecutor, AuraId, - >(config, polkadot_config, collator_options, id) + _, + >(config, polkadot_config, collator_options, id, |c, p| { + Box::new(Builder::<_, _, rpc::Dolphin>::new(c, p)) + }) .await .map(|r| r.0) .map_err(Into::into) diff --git a/node/src/lib.rs b/node/src/lib.rs deleted file mode 100644 index c3de5a567..000000000 --- a/node/src/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2020-2022 Manta Network. -// This file is part of Manta. -// -// Manta 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. -// -// Manta 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 Manta. If not, see . - -//! Manta/Calamari Parachain CLI - -#![allow(missing_docs)] - -pub mod chain_specs; -pub mod cli; -pub mod command; -pub mod rpc; -pub mod service; diff --git a/node/src/main.rs b/node/src/main.rs index 555fdcca3..ee4203706 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -16,6 +16,17 @@ //! Manta/Calamari Parachain CLI +#![warn(missing_docs)] + +extern crate alloc; + +mod chain_specs; +mod cli; +mod command; +mod rpc; +mod service; + + fn main() -> sc_cli::Result<()> { - manta::command::run() + command::run() } diff --git a/node/src/service.rs b/node/src/service.rs index 7965e0901..c5e0354c0 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -36,12 +36,9 @@ use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayC use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface; use polkadot_service::{CollatorPair, NativeExecutionDispatch}; -use crate::rpc; pub use manta_primitives::types::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; -use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; use futures::lock::Mutex; -use polkadot_service::NativeExecutionDispatch; use sc_client_api::ExecutorProvider; use sc_consensus::{ import_queue::{BasicQueue, Verifier as VerifierT}, @@ -67,7 +64,6 @@ use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use std::sync::Arc; use substrate_prometheus_endpoint::Registry; -pub use manta_primitives::types::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; /// Native Manta Parachain executor instance. pub struct MantaRuntimeExecutor; @@ -144,11 +140,11 @@ pub fn new_partial( where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: TaggedTransactionQueue - + Metadata + + sp_api::Metadata + SessionKeys + ApiExt + OffchainWorkerApi - + BlockBuilder, + + sp_block_builder::BlockBuilder, StateBackend: sp_api::StateBackend, Executor: NativeExecutionDispatch + 'static, BIQ: FnOnce( @@ -253,11 +249,11 @@ async fn start_node_impl( where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: TaggedTransactionQueue - + Metadata + + sp_api::Metadata + SessionKeys + ApiExt + OffchainWorkerApi - + BlockBuilder + + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + frame_rpc_system::AccountNonceApi, @@ -389,9 +385,7 @@ where relay_chain_slot_duration, import_queue, collator_options, - }; - - start_full_node(params)?; + })?; } start_network.start_network(); @@ -439,7 +433,7 @@ impl Clone for WaitForAuraConsensus { #[async_trait::async_trait] impl ParachainConsensus for WaitForAuraConsensus where - Client: ProvideRuntimeApi + Send + Sync, + Client: sp_api::ProvideRuntimeApi + Send + Sync, Client::Api: AuraApi, AuraId: Send + Codec + Sync, { @@ -482,7 +476,7 @@ struct Verifier { #[async_trait::async_trait] impl VerifierT for Verifier where - Client: ProvideRuntimeApi + Send + Sync, + Client: sp_api::ProvideRuntimeApi + Send + Sync, Client::Api: AuraApi, AuraId: Send + Sync + Codec, { @@ -521,11 +515,11 @@ pub fn parachain_build_import_queue( where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: TaggedTransactionQueue - + Metadata + + sp_api::Metadata + SessionKeys + ApiExt + OffchainWorkerApi - + BlockBuilder + + sp_block_builder::BlockBuilder + sp_consensus_aura::AuraApi::Pair as Pair>::Public>, StateBackend: sp_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, @@ -595,11 +589,11 @@ pub async fn start_parachain_node( where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: TaggedTransactionQueue - + Metadata + + sp_api::Metadata + SessionKeys + ApiExt + OffchainWorkerApi - + BlockBuilder + + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo + sp_consensus_aura::AuraApi::Pair as Pair>::Public> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi diff --git a/pallets/manta-pay/src/types.rs b/pallets/manta-pay/src/types.rs index 80e8c567d..03c165e12 100644 --- a/pallets/manta-pay/src/types.rs +++ b/pallets/manta-pay/src/types.rs @@ -108,10 +108,14 @@ impl Asset { #[derive(Clone, Debug, Decode, Encode, Eq, Hash, MaxEncodedLen, PartialEq, TypeInfo)] pub struct EncryptedNote { /// Ephemeral Public Key - pub ephemeral_public_key: [u8; EPHEMERAL_PUBLIC_KEY_LENGTH], + pub ephemeral_public_key: Group, /// Ciphertext - pub ciphertext: [u8; CIPHER_TEXT_LENGTH], + #[cfg_attr( + feature = "rpc", + serde(with = "manta_util::serde_with::As::<[manta_util::serde_with::Same; CIPHER_TEXT_LENGTH]>") + )] + pub ciphertext: Ciphertext, } impl Default for EncryptedNote { From 6bd5669686682401cc7def9bdcc4776d1d6d0190 Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Mon, 6 Jun 2022 21:40:04 -0400 Subject: [PATCH 18/24] refactor type names Signed-off-by: Shumo Chu --- pallets/manta-pay/src/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/manta-pay/src/types.rs b/pallets/manta-pay/src/types.rs index 03c165e12..c3c84bd7e 100644 --- a/pallets/manta-pay/src/types.rs +++ b/pallets/manta-pay/src/types.rs @@ -154,10 +154,10 @@ impl TryFrom for config::EncryptedNote { #[derive(Clone, Debug, Decode, Encode, Eq, Hash, MaxEncodedLen, PartialEq, TypeInfo)] pub struct SenderPost { /// UTXO Accumulator Output - pub utxo_accumulator_output: [u8; UTXO_ACCUMULATOR_OUTPUT_LENGTH], + pub utxo_accumulator_output: UtxoAccumulatorOutput, /// Void Number - pub void_number: [u8; VOID_NUMBER_LENGTH], + pub void_number: VoidNumber, } impl From for SenderPost { @@ -186,7 +186,7 @@ impl TryFrom for config::SenderPost { #[derive(Clone, Debug, Decode, Encode, Eq, Hash, MaxEncodedLen, PartialEq, TypeInfo)] pub struct ReceiverPost { /// Unspent Transaction Output - pub utxo: [u8; UTXO_LENGTH], + pub utxo: Utxo, /// Encrypted Note pub encrypted_note: EncryptedNote, From 83ca5606fdb0a01ba27843d877d1721af10f6d5a Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Mon, 6 Jun 2022 22:20:08 -0400 Subject: [PATCH 19/24] update manta-rs and sdk Signed-off-by: Shumo Chu --- Cargo.lock | 6 +++--- node/src/main.rs | 1 - node/src/service.rs | 1 - pallets/manta-pay/src/types.rs | 4 +++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1d22fcc7..8c3cceab9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -551,9 +551,9 @@ checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" [[package]] name = "attohttpc" -version = "0.18.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69e13a99a7e6e070bb114f7ff381e58c7ccc188630121fc4c2fe4bcf24cd072" +checksum = "262c3f7f5d61249d8c00e5546e2685cd15ebeeb1bc0f3cc5449350a1cb07319e" dependencies = [ "flate2", "http", @@ -5449,7 +5449,7 @@ dependencies = [ [[package]] name = "manta-sdk" version = "0.5.0" -source = "git+https://github.com/manta-network/sdk.git#fef5dc1868f6dea4911c8bb03cb6b29399810063" +source = "git+https://github.com/manta-network/sdk.git#4695cffb2cbb65f9a2efc24d54c11c801785b006" dependencies = [ "anyhow", "attohttpc", diff --git a/node/src/main.rs b/node/src/main.rs index ee4203706..8485e00b2 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -26,7 +26,6 @@ mod command; mod rpc; mod service; - fn main() -> sc_cli::Result<()> { command::run() } diff --git a/node/src/service.rs b/node/src/service.rs index c5e0354c0..08d8c43f2 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -64,7 +64,6 @@ use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use std::sync::Arc; use substrate_prometheus_endpoint::Registry; - /// Native Manta Parachain executor instance. pub struct MantaRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for MantaRuntimeExecutor { diff --git a/pallets/manta-pay/src/types.rs b/pallets/manta-pay/src/types.rs index c3c84bd7e..f62f5bc36 100644 --- a/pallets/manta-pay/src/types.rs +++ b/pallets/manta-pay/src/types.rs @@ -113,7 +113,9 @@ pub struct EncryptedNote { /// Ciphertext #[cfg_attr( feature = "rpc", - serde(with = "manta_util::serde_with::As::<[manta_util::serde_with::Same; CIPHER_TEXT_LENGTH]>") + serde( + with = "manta_util::serde_with::As::<[manta_util::serde_with::Same; CIPHER_TEXT_LENGTH]>" + ) )] pub ciphertext: Ciphertext, } From 983ff7919504e1ba589b494343a0107f6adc8f87 Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Tue, 7 Jun 2022 15:05:34 -0400 Subject: [PATCH 20/24] fix tests using patched manta-rs Signed-off-by: Shumo Chu --- Cargo.lock | 54 ++++++++++++++++++++++++++---------- pallets/manta-pay/Cargo.toml | 1 + primitives/Cargo.toml | 2 +- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c3cceab9..18d4507dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5284,14 +5284,25 @@ dependencies = [ [[package]] name = "manta-accounting" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#e779189021bfe91fbc7060c1ae97e2855734535c" +source = "git+https://github.com/manta-network/manta-rs.git?rev=d21b0af#d21b0afa6954f5f39e559ea2339f5a31f940008a" +dependencies = [ + "derivative", + "derive_more", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", +] + +[[package]] +name = "manta-accounting" +version = "0.4.0" +source = "git+https://github.com/manta-network/manta-rs.git#ebf935276c4bb172d23d6748e0b9d11a48d409b7" dependencies = [ "derivative", "derive_more", "futures 0.3.21", "indexmap", - "manta-crypto", - "manta-util", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", "parking_lot 0.12.0", "statrs", ] @@ -5326,10 +5337,20 @@ dependencies = [ [[package]] name = "manta-crypto" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#e779189021bfe91fbc7060c1ae97e2855734535c" +source = "git+https://github.com/manta-network/manta-rs.git?rev=d21b0af#d21b0afa6954f5f39e559ea2339f5a31f940008a" +dependencies = [ + "derivative", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", + "rand_core 0.6.3", +] + +[[package]] +name = "manta-crypto" +version = "0.4.0" +source = "git+https://github.com/manta-network/manta-rs.git#ebf935276c4bb172d23d6748e0b9d11a48d409b7" dependencies = [ "derivative", - "manta-util", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", "rand 0.8.5", "rand_core 0.6.3", ] @@ -5337,7 +5358,7 @@ dependencies = [ [[package]] name = "manta-pay" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#e779189021bfe91fbc7060c1ae97e2855734535c" +source = "git+https://github.com/manta-network/manta-rs.git#ebf935276c4bb172d23d6748e0b9d11a48d409b7" dependencies = [ "aes-gcm", "ark-bls12-381", @@ -5352,9 +5373,9 @@ dependencies = [ "ark-std", "blake2 0.10.4", "derivative", - "manta-accounting", - "manta-crypto", - "manta-util", + "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", "parity-scale-codec", "rand_chacha 0.3.1", "scale-info", @@ -5368,7 +5389,7 @@ dependencies = [ "frame-support", "frame-system", "log", - "manta-accounting", + "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", "parity-scale-codec", "scale-info", "smallvec", @@ -5461,7 +5482,12 @@ dependencies = [ [[package]] name = "manta-util" version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git#e779189021bfe91fbc7060c1ae97e2855734535c" +source = "git+https://github.com/manta-network/manta-rs.git?rev=d21b0af#d21b0afa6954f5f39e559ea2339f5a31f940008a" + +[[package]] +name = "manta-util" +version = "0.4.0" +source = "git+https://github.com/manta-network/manta-rs.git#ebf935276c4bb172d23d6748e0b9d11a48d409b7" dependencies = [ "serde", "serde_with", @@ -6629,12 +6655,12 @@ dependencies = [ "jsonrpc-core-client", "jsonrpc-derive", "lazy_static", - "manta-accounting", - "manta-crypto", + "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", "manta-pay", "manta-primitives", "manta-sdk", - "manta-util", + "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", "pallet-asset-manager", "pallet-assets", "pallet-balances", diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index 4d6174483..f59aeaf00 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -118,3 +118,4 @@ manta-sdk = { git = "https://github.com/manta-network/sdk.git", features = ["dow rand = "0.8.4" tempfile = "3.3.0" xcm = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.18" } +manta-util = { git = "https://github.com/manta-network/manta-rs.git", features = ["std"]} diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 0a3e1b055..28c0d3bc6 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -17,7 +17,7 @@ smallvec = "1.8.0" log = "0.4.16" # manta-rs dependencies -manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } +manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", rev="d21b0af", default-features = false } # Substrate primitives frame-support = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.18" } From 4ce08cc1040444abc1131807f31a47a522bac908 Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Tue, 7 Jun 2022 23:27:20 -0400 Subject: [PATCH 21/24] update mannual test Signed-off-by: Shumo Chu --- tests/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/index.ts b/tests/index.ts index ea0210fe8..cad5c6f8f 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -22,7 +22,7 @@ async function main(){ } }, rpc: { - mantapay: { + mantaPay: { pull: { description: 'pull from mantaPay', params: [ @@ -35,8 +35,8 @@ async function main(){ } } }}); - const junk = await (api.rpc as any).mantapay.pull({receiver_index: new Array(256).fill(0), sender_index: 0}); - console.log(junk); + const payload = await (api.rpc as any).mantaPay.pull({receiver_index: new Array(256).fill(0), sender_index: 0}); + console.log(payload); } main().catch(console.error).finally(() => process.exit()); From 31fc4f21802ded1b9abd25a2bc32f3a7f907e1c9 Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Wed, 8 Jun 2022 12:44:00 -0400 Subject: [PATCH 22/24] address review comments Signed-off-by: Shumo Chu --- Cargo.lock | 46 ++++++--------------------- node/src/chain_specs/dolphin.rs | 4 +-- pallets/asset-manager/src/lib.rs | 2 +- pallets/collator-selection/src/lib.rs | 3 +- pallets/manta-pay/Cargo.toml | 1 - pallets/manta-pay/src/lib.rs | 16 ++++++---- primitives/Cargo.toml | 2 +- runtime/dolphin/src/lib.rs | 2 +- 8 files changed, 27 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7429dc363..28ac6830e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5282,17 +5282,6 @@ dependencies = [ "xcm", ] -[[package]] -name = "manta-accounting" -version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?rev=d21b0af#d21b0afa6954f5f39e559ea2339f5a31f940008a" -dependencies = [ - "derivative", - "derive_more", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", -] - [[package]] name = "manta-accounting" version = "0.4.0" @@ -5302,8 +5291,8 @@ dependencies = [ "derive_more", "futures 0.3.21", "indexmap", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-crypto", + "manta-util", "parking_lot 0.12.0", "statrs", ] @@ -5335,23 +5324,13 @@ dependencies = [ "sp-tracing", ] -[[package]] -name = "manta-crypto" -version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?rev=d21b0af#d21b0afa6954f5f39e559ea2339f5a31f940008a" -dependencies = [ - "derivative", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", - "rand_core 0.6.3", -] - [[package]] name = "manta-crypto" version = "0.4.0" source = "git+https://github.com/manta-network/manta-rs.git#ebf935276c4bb172d23d6748e0b9d11a48d409b7" dependencies = [ "derivative", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-util", "rand 0.8.5", "rand_core 0.6.3", ] @@ -5374,9 +5353,9 @@ dependencies = [ "ark-std", "blake2 0.10.4", "derivative", - "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-accounting", + "manta-crypto", + "manta-util", "parity-scale-codec", "rand_chacha 0.3.1", "scale-info", @@ -5390,7 +5369,7 @@ dependencies = [ "frame-support", "frame-system", "log", - "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git?rev=d21b0af)", + "manta-accounting", "parity-scale-codec", "scale-info", "smallvec", @@ -5480,11 +5459,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "manta-util" -version = "0.4.0" -source = "git+https://github.com/manta-network/manta-rs.git?rev=d21b0af#d21b0afa6954f5f39e559ea2339f5a31f940008a" - [[package]] name = "manta-util" version = "0.4.0" @@ -6656,12 +6630,12 @@ dependencies = [ "jsonrpc-core-client", "jsonrpc-derive", "lazy_static", - "manta-accounting 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", - "manta-crypto 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-accounting", + "manta-crypto", "manta-pay", "manta-primitives", "manta-sdk", - "manta-util 0.4.0 (git+https://github.com/manta-network/manta-rs.git)", + "manta-util", "pallet-asset-manager", "pallet-assets", "pallet-balances", diff --git a/node/src/chain_specs/dolphin.rs b/node/src/chain_specs/dolphin.rs index 0f2b7a486..69542f159 100644 --- a/node/src/chain_specs/dolphin.rs +++ b/node/src/chain_specs/dolphin.rs @@ -16,12 +16,12 @@ use super::*; use crate::command::DOLPHIN_PARACHAIN_ID; -use dolphin_runtime::{CouncilConfig, DemocracyConfig, TechnicalCommitteeConfig}; +use dolphin_runtime::{CouncilConfig, DemocracyConfig, GenesisConfig, TechnicalCommitteeConfig}; use manta_primitives::helpers::{get_account_id_from_seed, get_collator_keys_from_seed}; /// Specialized `ChainSpec` for the normal parachain runtime. pub type DolphinChainSpec = - sc_service::GenericChainSpec; + sc_service::GenericChainSpec; const DOLPHIN_PROTOCOL_ID: &str = "dolphin"; // for p2p network configuration const KUSAMA_RELAYCHAIN_LOCAL_NET: &str = "kusama-local"; diff --git a/pallets/asset-manager/src/lib.rs b/pallets/asset-manager/src/lib.rs index 94940ff7f..328c36a64 100644 --- a/pallets/asset-manager/src/lib.rs +++ b/pallets/asset-manager/src/lib.rs @@ -564,7 +564,7 @@ pub mod pallet { Self::get_para_id_from_multilocation(location.into().as_ref()) { if para_id != 2084 { - Self::increase_count_of_associated_assets(para_id); + let _ = Self::increase_count_of_associated_assets(para_id); reads += 1; // There's one read in method increase_count_of_associated_assets. writes += 1; // There's one write in method increase_count_of_associated_assets. } diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 06b822cce..3a0e99a3c 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -616,9 +616,10 @@ pub mod pallet { // If our validator is not also a candidate we're invulnerable or already kicked if candidates.iter().any(|x| x.who == *acc_id) { Self::try_remove_candidate(acc_id) - .map(|_| { + .and_then(|_| { removed_account_ids.push(acc_id.clone()); log::info!("Removed collator of account {:?} as it only produced {} blocks this session which is below acceptable threshold of {}", &acc_id, my_blocks_this_session,evict_below_blocks); + Ok(()) }) .unwrap_or_else(|why| { log::warn!("Failed to remove candidate due to underperformance {:?}", why); diff --git a/pallets/manta-pay/Cargo.toml b/pallets/manta-pay/Cargo.toml index f59aeaf00..5980d5300 100644 --- a/pallets/manta-pay/Cargo.toml +++ b/pallets/manta-pay/Cargo.toml @@ -87,7 +87,6 @@ sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkad scale-codec = { package = "parity-scale-codec", version = '3.0.0', default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } -# TODO: investigate whether these two are needed sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.18", optional = true, default-features = false } sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.18", optional = true, default-features = false } diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index 3532453c6..d9df1c3f2 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -167,7 +167,7 @@ pub mod pallet { /// Void Number Ordered by Insertion #[pallet::storage] - pub(super) type InsertionOrderedVoidNumbers = + pub(super) type VoidNumberSetInsertionOrder = StorageMap<_, Identity, u64, VoidNumber, ValueQuery>; /// The size of Void Number Set @@ -512,7 +512,7 @@ pub mod pallet { #[inline] fn pull_senders(sender_index: &mut usize) -> (bool, SenderChunk) { let mut senders = Vec::new(); - let mut iter = InsertionOrderedVoidNumbers::::iter().skip(*sender_index); + let mut iter = VoidNumberSetInsertionOrder::::iter().skip(*sender_index); for _ in 0..Self::PULL_MAX_SENDER_UPDATE_SIZE { match iter.next() { Some((_, sender)) => { @@ -525,10 +525,14 @@ pub mod pallet { (iter.next().is_some(), senders) } - /// Returns the update required to be synchronized with the ledger starting from - /// `checkpoint`. + /// Returns the diff of ledger state of mantaPay since `checkpoint`. + /// `PullResponse` contains: + /// * `should_continue`: a boolean flag to indicate if there is more to pull + /// * `checkpoint`: updated checkpoint + /// * `receivers`: receivers diff + /// * `senders`: senders diff #[inline] - pub fn pull(mut checkpoint: Checkpoint) -> PullResponse { + pub fn pull_ledger_diff(mut checkpoint: Checkpoint) -> PullResponse { let (more_receivers, receivers) = Self::pull_receivers(&mut checkpoint.receiver_index); let (more_senders, senders) = Self::pull_senders(&mut checkpoint.sender_index); PullResponse { @@ -711,7 +715,7 @@ where for (_, void_number) in iter { let void_number = encode(&void_number.0); VoidNumberSet::::insert(void_number, ()); - InsertionOrderedVoidNumbers::::insert(index + i, void_number); + VoidNumberSetInsertionOrder::::insert(index + i, void_number); i += 1; } if i != 0 { diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 28c0d3bc6..0a3e1b055 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -17,7 +17,7 @@ smallvec = "1.8.0" log = "0.4.16" # manta-rs dependencies -manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", rev="d21b0af", default-features = false } +manta-accounting = { git = "https://github.com/manta-network/manta-rs.git", default-features = false } # Substrate primitives frame-support = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.18" } diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index 74b51f459..8d68dc950 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -871,7 +871,7 @@ impl_runtime_apis! { impl pallet_manta_pay::runtime::PullRuntimeApi for Runtime { fn pull(checkpoint: pallet_manta_pay::RawCheckpoint) -> pallet_manta_pay::PullResponse { - MantaPay::pull(checkpoint.into()) + MantaPay::pull_ledger_diff(checkpoint.into()) } } From 480aabc59da6be0c672f1b1d2681f97780a744ff Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Wed, 8 Jun 2022 14:40:54 -0400 Subject: [PATCH 23/24] remove comment Signed-off-by: Shumo Chu --- pallets/manta-pay/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/manta-pay/src/lib.rs b/pallets/manta-pay/src/lib.rs index d9df1c3f2..d457b8369 100644 --- a/pallets/manta-pay/src/lib.rs +++ b/pallets/manta-pay/src/lib.rs @@ -171,7 +171,6 @@ pub mod pallet { StorageMap<_, Identity, u64, VoidNumber, ValueQuery>; /// The size of Void Number Set - /// FIXME: this should be removed. #[pallet::storage] pub(super) type VoidNumberSetSize = StorageValue<_, u64, ValueQuery>; From afa765b99bc49fd647770e346e2201109e807ff7 Mon Sep 17 00:00:00 2001 From: Shumo Chu Date: Wed, 8 Jun 2022 15:44:55 -0400 Subject: [PATCH 24/24] pull -> pull_ledger_diff Signed-off-by: Shumo Chu --- node/src/rpc/dolphin.rs | 4 ++-- pallets/manta-pay/src/rpc.rs | 12 ++++++------ pallets/manta-pay/src/runtime.rs | 4 ++-- runtime/dolphin/src/lib.rs | 4 ++-- tests/index.ts | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/node/src/rpc/dolphin.rs b/node/src/rpc/dolphin.rs index 1f5e4e478..49813a030 100644 --- a/node/src/rpc/dolphin.rs +++ b/node/src/rpc/dolphin.rs @@ -21,7 +21,7 @@ use frame_rpc_system::AccountNonceApi; use manta_primitives::types::{AccountId, Balance, Block, Index as Nonce}; use pallet_manta_pay::{ rpc::{Pull, PullApi}, - runtime::PullRuntimeApi, + runtime::PullLedgerDiffApi, }; use pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi; use sc_client_api::HeaderBackend; @@ -39,7 +39,7 @@ where C: 'static + ProvideRuntimeApi + HeaderBackend, C::Api: BlockBuilder + AccountNonceApi - + PullRuntimeApi + + PullLedgerDiffApi + TransactionPaymentRuntimeApi, P: 'static + TransactionPool, { diff --git a/pallets/manta-pay/src/rpc.rs b/pallets/manta-pay/src/rpc.rs index ea07f6bee..4691f4539 100644 --- a/pallets/manta-pay/src/rpc.rs +++ b/pallets/manta-pay/src/rpc.rs @@ -16,7 +16,7 @@ //! MantaPay RPC Interfaces -use crate::{runtime::PullRuntimeApi, PullResponse}; +use crate::{runtime::PullLedgerDiffApi, PullResponse}; use alloc::sync::Arc; use core::marker::PhantomData; use jsonrpc_core::{Error, ErrorCode, Result}; @@ -31,8 +31,8 @@ use sp_runtime::{generic::BlockId, traits::Block}; pub trait PullApi { /// Returns the update required to be synchronized with the ledger starting from /// `checkpoint`. - #[rpc(name = "mantaPay_pull")] - fn pull(&self, checkpoint: Checkpoint) -> Result; + #[rpc(name = "mantaPay_pull_ledger_diff")] + fn pull_ledger_diff(&self, checkpoint: Checkpoint) -> Result; } /// Pull RPC API Implementation @@ -59,13 +59,13 @@ impl PullApi for Pull where B: Block, C: 'static + ProvideRuntimeApi + HeaderBackend, - C::Api: PullRuntimeApi, + C::Api: PullLedgerDiffApi, { #[inline] - fn pull(&self, checkpoint: Checkpoint) -> Result { + fn pull_ledger_diff(&self, checkpoint: Checkpoint) -> Result { let api = self.client.runtime_api(); let at = BlockId::hash(self.client.info().best_hash); - api.pull(&at, checkpoint.into()).map_err(|err| Error { + api.pull_ledger_diff(&at, checkpoint.into()).map_err(|err| Error { code: ErrorCode::ServerError(1), message: "Unable to compute state diff for pull".into(), data: Some(err.to_string().into()), diff --git a/pallets/manta-pay/src/runtime.rs b/pallets/manta-pay/src/runtime.rs index c7b9f06e4..2414cd51e 100644 --- a/pallets/manta-pay/src/runtime.rs +++ b/pallets/manta-pay/src/runtime.rs @@ -20,7 +20,7 @@ use crate::PullResponse; use manta_pay::signer::RawCheckpoint; sp_api::decl_runtime_apis! { - pub trait PullRuntimeApi { - fn pull(checkpoint: RawCheckpoint) -> PullResponse; + pub trait PullLedgerDiffApi { + fn pull_ledger_diff(checkpoint: RawCheckpoint) -> PullResponse; } } diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs index 8d68dc950..2c1e0b64a 100644 --- a/runtime/dolphin/src/lib.rs +++ b/runtime/dolphin/src/lib.rs @@ -869,8 +869,8 @@ impl_runtime_apis! { } } - impl pallet_manta_pay::runtime::PullRuntimeApi for Runtime { - fn pull(checkpoint: pallet_manta_pay::RawCheckpoint) -> pallet_manta_pay::PullResponse { + impl pallet_manta_pay::runtime::PullLedgerDiffApi for Runtime { + fn pull_ledger_diff(checkpoint: pallet_manta_pay::RawCheckpoint) -> pallet_manta_pay::PullResponse { MantaPay::pull_ledger_diff(checkpoint.into()) } } diff --git a/tests/index.ts b/tests/index.ts index cad5c6f8f..4d374176e 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -23,7 +23,7 @@ async function main(){ }, rpc: { mantaPay: { - pull: { + pull_ledger_diff: { description: 'pull from mantaPay', params: [ { @@ -35,7 +35,7 @@ async function main(){ } } }}); - const payload = await (api.rpc as any).mantaPay.pull({receiver_index: new Array(256).fill(0), sender_index: 0}); + const payload = await (api.rpc as any).mantaPay.pull_ledger_diff({receiver_index: new Array(256).fill(0), sender_index: 0}); console.log(payload); }