From b7858456e00a8b880a0b590d1be0372a29507f67 Mon Sep 17 00:00:00 2001 From: nol4lej Date: Wed, 5 Aug 2026 20:04:37 -0400 Subject: [PATCH] fix(rpc): retire the legacy shieldedPool_* server --- Cargo.lock | 17 ----- Cargo.toml | 1 - frame/shielded-pool/rpc/Cargo.toml | 18 ----- frame/shielded-pool/rpc/src/lib.rs | 107 ----------------------------- template/node/Cargo.toml | 1 - template/node/src/rpc/mod.rs | 3 - 6 files changed, 147 deletions(-) delete mode 100644 frame/shielded-pool/rpc/Cargo.toml delete mode 100644 frame/shielded-pool/rpc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 68f0973c..0ead1397 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7270,7 +7270,6 @@ dependencies = [ "orbinum-zk-core", "pallet-relayer-rpc", "pallet-relayer-runtime-api", - "pallet-shielded-pool-rpc", "pallet-shielded-pool-runtime-api", "pallet-transaction-payment", "pallet-transaction-payment-rpc", @@ -8125,22 +8124,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-shielded-pool-rpc" -version = "0.1.0" -dependencies = [ - "hex", - "jsonrpsee", - "pallet-shielded-pool", - "pallet-shielded-pool-runtime-api", - "parity-scale-codec", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-runtime", -] - [[package]] name = "pallet-shielded-pool-runtime-api" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 1688fb8e..af2b2739 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -248,7 +248,6 @@ pallet-relayer = { path = "frame/relayer", default-features = false } pallet-relayer-rpc = { path = "frame/relayer/rpc" } pallet-relayer-runtime-api = { path = "frame/relayer/runtime-api", default-features = false } pallet-shielded-pool = { path = "frame/shielded-pool", default-features = false } -pallet-shielded-pool-rpc = { path = "frame/shielded-pool/rpc" } pallet-shielded-pool-runtime-api = { path = "frame/shielded-pool/runtime-api", default-features = false } pallet-validator-set = { path = "frame/validator-set", default-features = false } pallet-zk-verifier = { path = "frame/zk-verifier", default-features = false } diff --git a/frame/shielded-pool/rpc/Cargo.toml b/frame/shielded-pool/rpc/Cargo.toml deleted file mode 100644 index 4fdd4af5..00000000 --- a/frame/shielded-pool/rpc/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "pallet-shielded-pool-rpc" -version = "0.1.0" -authors = ["Orbinum Team"] -edition = "2024" -license = "GPL-3.0-or-later" - -[dependencies] -hex = "0.4" -jsonrpsee = { version = "0.24.9", features = ["server", "macros", "client"] } -pallet-shielded-pool = { path = ".." } -pallet-shielded-pool-runtime-api = { path = "../runtime-api" } -parity-scale-codec = { version = "3.6", features = ["derive"] } -serde = { version = "1.0", features = ["derive"] } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2512" } -sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2512" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2512" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2512" } diff --git a/frame/shielded-pool/rpc/src/lib.rs b/frame/shielded-pool/rpc/src/lib.rs deleted file mode 100644 index 528f5774..00000000 --- a/frame/shielded-pool/rpc/src/lib.rs +++ /dev/null @@ -1,107 +0,0 @@ -use jsonrpsee::{core::RpcResult, proc_macros::rpc, types::ErrorObjectOwned}; -use pallet_shielded_pool_runtime_api::ShieldedPoolRuntimeApi; -use serde::{Deserialize, Serialize}; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::HeaderBackend; -use sp_runtime::traits::Block as BlockT; -use std::sync::Arc; - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct MerkleTreeInfo { - pub root: String, - pub tree_size: u32, - pub depth: u32, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct MerkleProof { - pub root: String, - pub leaf_index: u32, - pub siblings: Vec, -} - -#[rpc(client, server)] -pub trait ShieldedPoolApi { - #[method(name = "shieldedPool_getMerkleTreeInfo")] - fn get_merkle_tree_info(&self) -> RpcResult; - - #[method(name = "shieldedPool_getMerkleProof")] - fn get_merkle_proof(&self, commitment: String) -> RpcResult; -} - -pub struct ShieldedPool { - client: Arc, // We keep client generic, but implement for specific bounds - _marker: std::marker::PhantomData, -} - -impl ShieldedPool { - pub fn new(client: Arc) -> Self { - Self { - client, - _marker: Default::default(), - } - } -} - -impl ShieldedPoolApiServer for ShieldedPool -where - C: ProvideRuntimeApi + HeaderBackend + 'static, - C::Api: ShieldedPoolRuntimeApi, - B: BlockT, -{ - fn get_merkle_tree_info(&self) -> RpcResult { - let api = self.client.runtime_api(); - let best_block = self.client.info().best_hash; - - // Call runtime API - let (root, tree_size, depth) = api - .get_merkle_tree_info(best_block) - .map_err(|e| ErrorObjectOwned::owned(1, format!("Runtime error: {e}"), None::<()>))?; - - Ok(MerkleTreeInfo { - root: format!("0x{}", hex::encode(root)), - tree_size, - depth, - }) - } - - fn get_merkle_proof(&self, commitment_hex: String) -> RpcResult { - let commitment_bytes = hex::decode(commitment_hex.trim_start_matches("0x")) - .map_err(|e| ErrorObjectOwned::owned(1, format!("Invalid hex: {e}"), None::<()>))?; - - let mut commitment = [0u8; 32]; - if commitment_bytes.len() != 32 { - return Err(ErrorObjectOwned::owned( - 1, - "Commitment must be 32 bytes", - None::<()>, - )); - } - commitment.copy_from_slice(&commitment_bytes); - - let api = self.client.runtime_api(); - let best_block = self.client.info().best_hash; - - let (leaf_index, proof) = api - .get_merkle_proof_for_commitment(best_block, commitment) - .map_err(|e| ErrorObjectOwned::owned(1, format!("Runtime error: {e}"), None::<()>))? - .ok_or_else(|| { - ErrorObjectOwned::owned(1, "Commitment not found in tree", None::<()>) - })?; - - let root_hash = api - .get_merkle_tree_info(best_block) - .map(|(root, _, _)| root) - .unwrap_or([0u8; 32]); - - Ok(MerkleProof { - root: format!("0x{}", hex::encode(root_hash)), - leaf_index, - siblings: proof - .siblings - .iter() - .map(|h| format!("0x{}", hex::encode(h))) - .collect(), - }) - } -} diff --git a/template/node/Cargo.toml b/template/node/Cargo.toml index 32b49273..356874b9 100644 --- a/template/node/Cargo.toml +++ b/template/node/Cargo.toml @@ -58,7 +58,6 @@ sp-transaction-pool = { workspace = true, features = ["default"] } frame-system-rpc-runtime-api = { workspace = true } pallet-relayer-rpc = { workspace = true } pallet-relayer-runtime-api = { workspace = true } -pallet-shielded-pool-rpc = { workspace = true } pallet-shielded-pool-runtime-api = { workspace = true } pallet-transaction-payment-rpc = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } diff --git a/template/node/src/rpc/mod.rs b/template/node/src/rpc/mod.rs index 9e184020..ce00c4e6 100644 --- a/template/node/src/rpc/mod.rs +++ b/template/node/src/rpc/mod.rs @@ -86,7 +86,6 @@ where CT: fp_rpc::ConvertTransaction<::Extrinsic> + Send + Sync + 'static, { use pallet_relayer_rpc::{Relayer, RelayerApiServer}; - use pallet_shielded_pool_rpc::{ShieldedPool, ShieldedPoolApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use pallet_zk_verifier_rpc::{ZkVerifier, ZkVerifierApiServer}; use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer}; @@ -106,12 +105,10 @@ where io.merge(System::new(client.clone(), pool.clone()).into_rpc())?; io.merge(TransactionPayment::new(client.clone()).into_rpc())?; - io.merge(ShieldedPool::new(client.clone()).into_rpc())?; io.merge(ZkVerifier::new(client.clone()).into_rpc())?; io.merge(Relayer::new(client.clone()).into_rpc())?; io.merge(RelayerAuthor::new(keystore).into_rpc())?; - // Orbinum Privacy + Chain RPC io.merge(PrivacyRpc::new(client.clone()).into_rpc())?; io.merge(ChainRpc::new(client.clone()).into_rpc())?;