Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[jsonrpsee] http ACL companion #9801

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" }
sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" }

# These dependencies are used for the node template's RPCs
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-unify-acl-builder", features = ["server"] }
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
sc-rpc-api = { version = "0.10.0-dev", path = "../../../client/rpc-api" }
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
# third-party dependencies
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-unify-acl-builder", features = ["server"] }
serde = { version = "1.0.126", features = ["derive"] }
futures = "0.3.16"
hex-literal = "0.3.1"
Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
futures = "0.3.16"
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["client", "macros"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-unify-acl-builder", features = ["client", "macros"] }
tokio = { version = "1.10", features = ["full"] }
node-primitives = { version = "2.0.0", path = "../primitives" }
sp-tracing = { version = "4.0.0-dev", path = "../../../primitives/tracing" }
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-unify-acl-builder", features = ["server"] }
sc-consensus-babe = { version = "0.10.0-dev", path = "../" }
sc-rpc-api = { version = "0.10.0-dev", path = "../../../rpc-api" }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../../primitives/consensus/babe" }
Expand Down
12 changes: 6 additions & 6 deletions client/consensus/babe/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use futures::TryFutureExt;
use jsonrpsee::{
proc_macros::rpc,
types::{async_trait, Error as JsonRpseeError, JsonRpcResult},
types::{async_trait, Error as JsonRpseeError, RpcResult},
};

use sc_consensus_babe::{authorship, Config, Epoch};
Expand All @@ -44,7 +44,7 @@ pub trait BabeApi {
/// Returns data about which slots (primary or secondary) can be claimed in the current epoch
/// with the keys in the keystore.
#[method(name = "epochAuthorship")]
async fn epoch_authorship(&self) -> JsonRpcResult<HashMap<AuthorityId, EpochAuthorship>>;
async fn epoch_authorship(&self) -> RpcResult<HashMap<AuthorityId, EpochAuthorship>>;
}

/// Provides RPC methods for interacting with Babe.
Expand Down Expand Up @@ -88,7 +88,7 @@ where
C::Api: BabeRuntimeApi<B>,
SC: SelectChain<B> + Clone + 'static,
{
async fn epoch_authorship(&self) -> JsonRpcResult<HashMap<AuthorityId, EpochAuthorship>> {
async fn epoch_authorship(&self) -> RpcResult<HashMap<AuthorityId, EpochAuthorship>> {
self.deny_unsafe.check_if_safe()?;
let header = self.select_chain.best_chain().map_err(Error::Consensus).await?;
let epoch_start = self
Expand Down Expand Up @@ -133,13 +133,13 @@ where
match claim {
PreDigest::Primary { .. } => {
claims.entry(key).or_default().primary.push(slot);
},
}
PreDigest::SecondaryPlain { .. } => {
claims.entry(key).or_default().secondary.push(slot);
},
}
PreDigest::SecondaryVRF { .. } => {
claims.entry(key).or_default().secondary_vrf.push(slot.into());
},
}
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/manual-seal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
derive_more = "0.99.2"
futures = "0.3.9"

jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-unify-acl-builder", features = ["server"] }
log = "0.4.8"
codec = { package = "parity-scale-codec", version = "2.0.0" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
10 changes: 5 additions & 5 deletions client/consensus/manual-seal/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use futures::{
};
use jsonrpsee::{
proc_macros::rpc,
types::{async_trait, Error as JsonRpseeError, JsonRpcResult},
types::{async_trait, Error as JsonRpseeError, RpcResult},
};
use sc_consensus::ImportedAux;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -74,15 +74,15 @@ pub trait ManualSealApi<Hash> {
create_empty: bool,
finalize: bool,
parent_hash: Option<Hash>,
) -> JsonRpcResult<CreatedBlock<Hash>>;
) -> RpcResult<CreatedBlock<Hash>>;

/// Instructs the manual-seal authorship task to finalize a block
#[method(name = "finalizeBlock")]
async fn finalize_block(
&self,
hash: Hash,
justification: Option<EncodedJustification>,
) -> JsonRpcResult<bool>;
) -> RpcResult<bool>;
}

/// A struct that implements the [`ManualSealApi`].
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<Hash: Send + 'static> ManualSealApiServer<Hash> for ManualSeal<Hash> {
create_empty: bool,
finalize: bool,
parent_hash: Option<Hash>,
) -> JsonRpcResult<CreatedBlock<Hash>> {
) -> RpcResult<CreatedBlock<Hash>> {
let mut sink = self.import_block_channel.clone();
let (sender, receiver) = oneshot::channel();
// NOTE: this sends a Result over the channel.
Expand All @@ -137,7 +137,7 @@ impl<Hash: Send + 'static> ManualSealApiServer<Hash> for ManualSeal<Hash> {
&self,
hash: Hash,
justification: Option<EncodedJustification>,
) -> JsonRpcResult<bool> {
) -> RpcResult<bool> {
let mut sink = self.import_block_channel.clone();
let (sender, receiver) = oneshot::channel();
let command = EngineCommand::FinalizeBlock { hash, sender: Some(sender), justification };
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain"
sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" }
sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" }
finality-grandpa = { version = "0.14.1", features = ["derive-codec"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["server"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-unify-acl-builder", features = ["server"] }
futures = { version = "0.3.4", features = ["compat"] }
serde = { version = "1.0.105", features = ["derive"] }
serde_json = "1.0.50"
Expand Down
14 changes: 7 additions & 7 deletions client/finality-grandpa/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::sync::Arc;

use jsonrpsee::{
proc_macros::rpc,
types::{async_trait, error::Error as JsonRpseeError, JsonRpcResult},
types::{async_trait, error::Error as JsonRpseeError, RpcResult},
SubscriptionSink,
};

Expand All @@ -48,7 +48,7 @@ pub trait GrandpaApi<Notification, Hash, Number> {
/// Returns the state of the current best round state as well as the
/// ongoing background rounds.
#[method(name = "roundState")]
async fn round_state(&self) -> JsonRpcResult<ReportedRoundStates>;
async fn round_state(&self) -> RpcResult<ReportedRoundStates>;

/// Returns the block most recently finalized by Grandpa, alongside
/// side its justification.
Expand All @@ -57,12 +57,12 @@ pub trait GrandpaApi<Notification, Hash, Number> {
aliases = "grandpa_justifications"
item = Notification
)]
fn subscribe_justifications(&self) -> JsonRpcResult<()>;
fn subscribe_justifications(&self) -> RpcResult<()>;

/// Prove finality for the given block number by returning the Justification for the last block
/// in the set and all the intermediary headers to link them together.
#[method(name = "proveFinality")]
async fn prove_finality(&self, block: Number) -> JsonRpcResult<Option<EncodedFinalityProof>>;
async fn prove_finality(&self, block: Number) -> RpcResult<Option<EncodedFinalityProof>>;
}

/// Provides RPC methods for interacting with GRANDPA.
Expand Down Expand Up @@ -98,12 +98,12 @@ where
Block: BlockT,
ProofProvider: RpcFinalityProofProvider<Block> + Send + Sync + 'static,
{
async fn round_state(&self) -> JsonRpcResult<ReportedRoundStates> {
async fn round_state(&self) -> RpcResult<ReportedRoundStates> {
ReportedRoundStates::from(&self.authority_set, &self.voter_state)
.map_err(|e| JsonRpseeError::to_call_error(e))
}

fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> JsonRpcResult<()> {
fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> RpcResult<()> {
let stream = self.justification_stream.subscribe().map(
|x: sc_finality_grandpa::GrandpaJustification<Block>| {
JustificationNotification::from(x)
Expand Down Expand Up @@ -134,7 +134,7 @@ where
async fn prove_finality(
&self,
block: NumberFor<Block>,
) -> JsonRpcResult<Option<EncodedFinalityProof>> {
) -> RpcResult<Option<EncodedFinalityProof>> {
self.finality_proof_provider
.rpc_prove_finality(block)
.map_err(|finality_err| error::Error::ProveFinalityFailed(finality_err))
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sc-chain-spec = { path = "../chain-spec", version = "4.0.0-dev" }
serde = { version = "1.0.126", features = ["derive"] }
serde_json = "1.0.41"

jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "master", features = ["full"] }
jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", branch = "na-http-server-unify-acl-builder", features = ["full"] }

sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
sp-rpc = { version = "4.0.0-dev", path = "../../primitives/rpc" }
Expand Down
18 changes: 9 additions & 9 deletions client/rpc-api/src/author/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

//! Substrate block-author/full-node API.

use jsonrpsee::{proc_macros::rpc, types::JsonRpcResult};
use jsonrpsee::{proc_macros::rpc, types::RpcResult};
use sc_transaction_pool_api::TransactionStatus;
use sp_core::Bytes;

Expand All @@ -30,40 +30,40 @@ pub mod hash;
pub trait AuthorApi<Hash, BlockHash> {
/// Submit hex-encoded extrinsic for inclusion in block.
#[method(name = "submitExtrinsic")]
async fn submit_extrinsic(&self, extrinsic: Bytes) -> JsonRpcResult<Hash>;
async fn submit_extrinsic(&self, extrinsic: Bytes) -> RpcResult<Hash>;

/// Insert a key into the keystore.
#[method(name = "insertKey")]
fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> JsonRpcResult<()>;
fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> RpcResult<()>;

/// Generate new session keys and returns the corresponding public keys.
#[method(name = "rotateKeys")]
fn rotate_keys(&self) -> JsonRpcResult<Bytes>;
fn rotate_keys(&self) -> RpcResult<Bytes>;

/// Checks if the keystore has private keys for the given session public keys.
///
/// `session_keys` is the SCALE encoded session keys object from the runtime.
///
/// Returns `true` iff all private keys could be found.
#[method(name = "hasSessionKeys")]
fn has_session_keys(&self, session_keys: Bytes) -> JsonRpcResult<bool>;
fn has_session_keys(&self, session_keys: Bytes) -> RpcResult<bool>;

/// Checks if the keystore has private keys for the given public key and key type.
///
/// Returns `true` if a private key could be found.
#[method(name = "hasKey")]
fn has_key(&self, public_key: Bytes, key_type: String) -> JsonRpcResult<bool>;
fn has_key(&self, public_key: Bytes, key_type: String) -> RpcResult<bool>;

/// Returns all pending extrinsics, potentially grouped by sender.
#[method(name = "pendingExtrinsics")]
fn pending_extrinsics(&self) -> JsonRpcResult<Vec<Bytes>>;
fn pending_extrinsics(&self) -> RpcResult<Vec<Bytes>>;

/// Remove given extrinsic from the pool and temporarily ban it to prevent reimporting.
#[method(name = "removeExtrinsic")]
fn remove_extrinsic(
&self,
bytes_or_hash: Vec<hash::ExtrinsicOrHash<Hash>>,
) -> JsonRpcResult<Vec<Hash>>;
) -> RpcResult<Vec<Hash>>;

/// Submit an extrinsic to watch.
///
Expand All @@ -75,5 +75,5 @@ pub trait AuthorApi<Hash, BlockHash> {
unsubscribe_aliases = "author_unwatchExtrinsic",
item = TransactionStatus<Hash, BlockHash>
)]
fn watch_extrinsic(&self, bytes: Bytes) -> JsonRpcResult<()>;
fn watch_extrinsic(&self, bytes: Bytes) -> RpcResult<()>;
}
Loading