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

Mark sync_state_genSyncSpec JSON-RPC as safe #10832

Merged
Merged
Changes from 3 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
12 changes: 5 additions & 7 deletions client/sync-state-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ pub struct SyncStateRpcHandler<Block: BlockT, Backend> {
client: Arc<Backend>,
shared_authority_set: SharedAuthoritySet<Block>,
shared_epoch_changes: SharedEpochChanges<Block>,
deny_unsafe: sc_rpc_api::DenyUnsafe,
}

impl<Block, Backend> SyncStateRpcHandler<Block, Backend>
Expand All @@ -143,17 +142,20 @@ where
Backend: HeaderBackend<Block> + sc_client_api::AuxStore + 'static,
{
/// Create a new handler.
///
/// The `deny_unsafe` parameter is deprecated and unused. It is there only to maintain
/// API backwards compatibility.
pub fn new(
chain_spec: Box<dyn sc_chain_spec::ChainSpec>,
client: Arc<Backend>,
shared_authority_set: SharedAuthoritySet<Block>,
shared_epoch_changes: SharedEpochChanges<Block>,
deny_unsafe: sc_rpc_api::DenyUnsafe,
_deny_unsafe: sc_rpc_api::DenyUnsafe,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this.

) -> Result<Self, Error<Block>> {
if sc_chain_spec::get_extension::<LightSyncStateExtension>(chain_spec.extensions())
.is_some()
{
Ok(Self { chain_spec, client, shared_authority_set, shared_epoch_changes, deny_unsafe })
Ok(Self { chain_spec, client, shared_authority_set, shared_epoch_changes })
} else {
Err(Error::<Block>::LightSyncStateExtensionNotFound)
}
Expand Down Expand Up @@ -185,10 +187,6 @@ where
Backend: HeaderBackend<Block> + sc_client_api::AuxStore + 'static,
{
fn system_gen_sync_spec(&self, raw: bool) -> jsonrpc_core::Result<jsonrpc_core::Value> {
if let Err(err) = self.deny_unsafe.check_if_safe() {
return Err(err.into())
}

let mut chain_spec = self.chain_spec.cloned_box();

let sync_state = self.build_sync_state().map_err(map_error::<Block, Error<Block>>)?;
Expand Down