Bad blocks RPC + reporting (#9433)
* Bad blocks RPC. * Return bad blocks via RPC. * Fix test. * More verbose bad block message. * Expose via CLI. * Remove stray whitespace. * Remove stray newline. * Fix tests.
This commit is contained in:
committed by
Afri Schoedon
parent
915c366056
commit
61bd47ccc1
@@ -477,7 +477,7 @@ usage! {
|
||||
|
||||
ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,private,parity_pubsub,traces,rpc,shh,shh_pubsub", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
|
||||
"--jsonrpc-apis=[APIS]",
|
||||
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
|
||||
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
|
||||
|
||||
ARG arg_jsonrpc_hosts: (String) = "none", or |c: &Config| c.rpc.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")),
|
||||
"--jsonrpc-hosts=[HOSTS]",
|
||||
|
||||
@@ -58,18 +58,10 @@ pub enum Api {
|
||||
Signer,
|
||||
/// Parity - Custom extensions (Safe)
|
||||
Parity,
|
||||
/// Parity PubSub - Generic Publish-Subscriber (Safety depends on other APIs exposed).
|
||||
ParityPubSub,
|
||||
/// Parity Accounts extensions (UNSAFE: Passwords, Side Effects (new account))
|
||||
ParityAccounts,
|
||||
/// Parity - Set methods (UNSAFE: Side Effects affecting node operation)
|
||||
ParitySet,
|
||||
/// Traces (Safe)
|
||||
Traces,
|
||||
/// Rpc (Safe)
|
||||
Rpc,
|
||||
/// SecretStore (UNSAFE: arbitrary hash signing)
|
||||
SecretStore,
|
||||
/// Private transaction manager (Safe)
|
||||
Private,
|
||||
/// Whisper (Safe)
|
||||
@@ -78,6 +70,17 @@ pub enum Api {
|
||||
Whisper,
|
||||
/// Whisper Pub-Sub (Safe but same concerns as above).
|
||||
WhisperPubSub,
|
||||
/// Parity PubSub - Generic Publish-Subscriber (Safety depends on other APIs exposed).
|
||||
ParityPubSub,
|
||||
/// Parity Accounts extensions (UNSAFE: Passwords, Side Effects (new account))
|
||||
ParityAccounts,
|
||||
/// Parity - Set methods (UNSAFE: Side Effects affecting node operation)
|
||||
ParitySet,
|
||||
/// SecretStore (UNSAFE: arbitrary hash signing)
|
||||
SecretStore,
|
||||
/// Geth-compatible (best-effort) debug API (Potentially UNSAFE)
|
||||
/// NOTE We don't aim to support all methods, only the ones that are useful.
|
||||
Debug,
|
||||
}
|
||||
|
||||
impl FromStr for Api {
|
||||
@@ -87,22 +90,23 @@ impl FromStr for Api {
|
||||
use self::Api::*;
|
||||
|
||||
match s {
|
||||
"web3" => Ok(Web3),
|
||||
"net" => Ok(Net),
|
||||
"debug" => Ok(Debug),
|
||||
"eth" => Ok(Eth),
|
||||
"pubsub" => Ok(EthPubSub),
|
||||
"personal" => Ok(Personal),
|
||||
"signer" => Ok(Signer),
|
||||
"net" => Ok(Net),
|
||||
"parity" => Ok(Parity),
|
||||
"parity_pubsub" => Ok(ParityPubSub),
|
||||
"parity_accounts" => Ok(ParityAccounts),
|
||||
"parity_pubsub" => Ok(ParityPubSub),
|
||||
"parity_set" => Ok(ParitySet),
|
||||
"traces" => Ok(Traces),
|
||||
"personal" => Ok(Personal),
|
||||
"private" => Ok(Private),
|
||||
"pubsub" => Ok(EthPubSub),
|
||||
"rpc" => Ok(Rpc),
|
||||
"secretstore" => Ok(SecretStore),
|
||||
"private" => Ok(Private),
|
||||
"shh" => Ok(Whisper),
|
||||
"shh_pubsub" => Ok(WhisperPubSub),
|
||||
"signer" => Ok(Signer),
|
||||
"traces" => Ok(Traces),
|
||||
"web3" => Ok(Web3),
|
||||
api => Err(format!("Unknown api: {}", api))
|
||||
}
|
||||
}
|
||||
@@ -171,20 +175,21 @@ fn to_modules(apis: &HashSet<Api>) -> BTreeMap<String, String> {
|
||||
let mut modules = BTreeMap::new();
|
||||
for api in apis {
|
||||
let (name, version) = match *api {
|
||||
Api::Web3 => ("web3", "1.0"),
|
||||
Api::Net => ("net", "1.0"),
|
||||
Api::Debug => ("debug", "1.0"),
|
||||
Api::Eth => ("eth", "1.0"),
|
||||
Api::EthPubSub => ("pubsub", "1.0"),
|
||||
Api::Personal => ("personal", "1.0"),
|
||||
Api::Signer => ("signer", "1.0"),
|
||||
Api::Net => ("net", "1.0"),
|
||||
Api::Parity => ("parity", "1.0"),
|
||||
Api::ParityAccounts => ("parity_accounts", "1.0"),
|
||||
Api::ParityPubSub => ("parity_pubsub", "1.0"),
|
||||
Api::ParitySet => ("parity_set", "1.0"),
|
||||
Api::Traces => ("traces", "1.0"),
|
||||
Api::Personal => ("personal", "1.0"),
|
||||
Api::Private => ("private", "1.0"),
|
||||
Api::Rpc => ("rpc", "1.0"),
|
||||
Api::SecretStore => ("secretstore", "1.0"),
|
||||
Api::Private => ("private", "1.0"),
|
||||
Api::Signer => ("signer", "1.0"),
|
||||
Api::Traces => ("traces", "1.0"),
|
||||
Api::Web3 => ("web3", "1.0"),
|
||||
Api::Whisper => ("shh", "1.0"),
|
||||
Api::WhisperPubSub => ("shh_pubsub", "1.0"),
|
||||
};
|
||||
@@ -265,6 +270,9 @@ impl FullDependencies {
|
||||
);
|
||||
for api in apis {
|
||||
match *api {
|
||||
Api::Debug => {
|
||||
handler.extend_with(DebugClient::new(self.client.clone()).to_delegate());
|
||||
},
|
||||
Api::Web3 => {
|
||||
handler.extend_with(Web3Client::new().to_delegate());
|
||||
},
|
||||
@@ -481,6 +489,9 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
|
||||
|
||||
for api in apis {
|
||||
match *api {
|
||||
Api::Debug => {
|
||||
warn!(target: "rpc", "Debug API is not available in light client mode.")
|
||||
},
|
||||
Api::Web3 => {
|
||||
handler.extend_with(Web3Client::new().to_delegate());
|
||||
},
|
||||
@@ -647,6 +658,7 @@ impl ApiSet {
|
||||
public_list
|
||||
},
|
||||
ApiSet::SafeContext => {
|
||||
public_list.insert(Api::Debug);
|
||||
public_list.insert(Api::Traces);
|
||||
public_list.insert(Api::ParityPubSub);
|
||||
public_list.insert(Api::ParityAccounts);
|
||||
@@ -656,6 +668,7 @@ impl ApiSet {
|
||||
public_list
|
||||
},
|
||||
ApiSet::All => {
|
||||
public_list.insert(Api::Debug);
|
||||
public_list.insert(Api::Traces);
|
||||
public_list.insert(Api::ParityPubSub);
|
||||
public_list.insert(Api::ParityAccounts);
|
||||
@@ -682,6 +695,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_api_parsing() {
|
||||
assert_eq!(Api::Debug, "debug".parse().unwrap());
|
||||
assert_eq!(Api::Web3, "web3".parse().unwrap());
|
||||
assert_eq!(Api::Net, "net".parse().unwrap());
|
||||
assert_eq!(Api::Eth, "eth".parse().unwrap());
|
||||
@@ -738,7 +752,7 @@ mod test {
|
||||
// semi-safe
|
||||
Api::ParityAccounts,
|
||||
// Unsafe
|
||||
Api::ParitySet, Api::Signer,
|
||||
Api::ParitySet, Api::Signer, Api::Debug
|
||||
].into_iter().collect();
|
||||
assert_eq!(ApiSet::SafeContext.list_apis(), expected);
|
||||
}
|
||||
@@ -751,6 +765,7 @@ mod test {
|
||||
Api::ParitySet, Api::Signer,
|
||||
Api::Personal,
|
||||
Api::Private,
|
||||
Api::Debug,
|
||||
].into_iter().collect()));
|
||||
}
|
||||
|
||||
@@ -760,7 +775,7 @@ mod test {
|
||||
Api::Web3, Api::Net, Api::Eth, Api::EthPubSub, Api::Parity, Api::ParityPubSub, Api::Traces, Api::Rpc, Api::SecretStore, Api::Whisper, Api::WhisperPubSub,
|
||||
Api::ParityAccounts,
|
||||
Api::ParitySet, Api::Signer,
|
||||
Api::Private
|
||||
Api::Private, Api::Debug,
|
||||
].into_iter().collect()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user