Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4c0abc5
A clean new attempt
kianenigma Feb 3, 2021
7f9b5b8
Checkpoint to move remote.
kianenigma Feb 10, 2021
4883812
A lot of dependency wiring to make it feature gated.
kianenigma Feb 10, 2021
be549b4
bad macro, bad macro.
kianenigma Feb 10, 2021
8e97733
Master.into()
kianenigma Feb 11, 2021
7edef9e
refactor(remote ext): use jsonrpsee
niklasad1 Feb 11, 2021
99e7818
refactor(remote ext): use jsonrpsee
niklasad1 Feb 11, 2021
89f4c2a
Merge branch 'na-remote-ext-jsonrpsee-show-kian' of github.com:parity…
niklasad1 Feb 11, 2021
fd9c2b1
Merge remote-tracking branch 'origin/kiz-finally-finally-finally-fina…
niklasad1 Feb 11, 2021
d84dad4
Undo the DB mess.
kianenigma Feb 11, 2021
bd7f87c
fix(remote ext): use max limit `u32::MAX`
niklasad1 Feb 11, 2021
d9c7951
resolve TODOs
niklasad1 Feb 11, 2021
9d0717a
jsonrpsee switch to `hyper` as backend
niklasad1 Feb 11, 2021
c95c215
Merge remote-tracking branch 'origin/kiz-finally-finally-finally-fina…
niklasad1 Feb 11, 2021
8b7c7c3
Update utils/frame/try-runtime/remote-externalities/src/lib.rs
niklasad1 Feb 11, 2021
2f1206a
update jsonrpsee
niklasad1 Feb 15, 2021
79c7dee
Merge branch 'na-remote-ext-jsonrpsee-show-kian' of github.com:parity…
niklasad1 Feb 15, 2021
c893bd7
Merge remote-tracking branch 'origin/master' into na-remote-ext-jsonr…
niklasad1 Mar 4, 2021
df8d9fe
remove boiler-plate
niklasad1 Mar 4, 2021
a9a4a19
suppress warnings to CI happy
niklasad1 Mar 4, 2021
a0e8bae
Merge remote-tracking branch 'origin/master' into na-remote-ext-jsonr…
niklasad1 Mar 5, 2021
cc248a0
Unbreak his build
kianenigma Mar 5, 2021
c8796c7
Use option
kianenigma Mar 5, 2021
01688f2
fix nit; make it work again
niklasad1 Mar 5, 2021
eced71c
fix err message.
kianenigma Mar 6, 2021
195fee3
Merge branch 'master' of github.com:paritytech/substrate into na-remo…
kianenigma Mar 6, 2021
4e696c4
Update utils/frame/remote-externalities/Cargo.toml
niklasad1 Mar 6, 2021
8c6c859
Fix uri stuff
kianenigma Mar 6, 2021
12ca19a
ccccrbvlhchdlejdhiiuefuiurbntlrjlviuilcnhl
kianenigma Mar 6, 2021
7f08f50
remove needless clone
niklasad1 Mar 6, 2021
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
Prev Previous commit
Next Next commit
Fix uri stuff
  • Loading branch information
kianenigma committed Mar 6, 2021
commit 8c6c859d5708794e13e8ec240a9d55eb87749929
47 changes: 22 additions & 25 deletions utils/frame/remote-externalities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
use std::{
fs,
path::{Path, PathBuf},
sync::Arc,
};
use log::*;
use sp_core::{hashing::twox_128};
Expand Down Expand Up @@ -160,10 +159,6 @@ pub struct OfflineConfig {
pub struct OnlineConfig {
/// The HTTP uri to use.
pub uri: String,
/// JSONRPC HTTP Client.
//
// NOTE: Arc is used here because `HttpClient` doesn't implement `Clone`.
pub rpc: Arc<HttpClient>,
/// The block number at which to connect. Will be latest finalized head if not provided.
pub at: Option<Hash>,
/// An optional cache file to WRITE to, not for reading. Not cached if set to `None`.
Expand All @@ -174,18 +169,15 @@ pub struct OnlineConfig {

impl Default for OnlineConfig {
fn default() -> Self {
Self {
uri: TARGET.to_owned(),
rpc: Arc::new(
HttpClient::new(
TARGET,
HttpConfig { max_request_body_size: u32::MAX }
).expect("valid HTTP url; qed")
),
at: None,
cache: None,
modules: Default::default(),
}
Self { uri: TARGET.to_owned(), at: None, cache: None, modules: Default::default() }
}
}

impl OnlineConfig {
/// Return a new http rpc client.
fn rpc(&self) -> HttpClient {
HttpClient::new(self.uri.clone(), HttpConfig { max_request_body_size: u32::MAX })
.expect("valid HTTP url; qed")
}
}

Expand Down Expand Up @@ -248,9 +240,10 @@ impl Builder {
impl Builder {
async fn rpc_get_head(&self) -> Result<Hash, &'static str> {
trace!(target: LOG_TARGET, "rpc: finalized_head");
RpcApi::finalized_head(&*self.as_online().rpc)
.await
.map_err(|_| "rpc finalized_head failed.")
RpcApi::finalized_head(&self.as_online().rpc()).await.map_err(|e| {
error!("Error = {:?}", e);
"rpc finalized_head failed."
})
}

/// Relay the request to `state_getPairs` rpc endpoint.
Expand All @@ -262,9 +255,10 @@ impl Builder {
at: Hash,
) -> Result<Vec<KeyPair>, &'static str> {
trace!(target: LOG_TARGET, "rpc: storage_pairs: {:?} / {:?}", prefix, at);
RpcApi::storage_pairs(&*self.as_online().rpc, prefix, Some(at))
.await
.map_err(|_| "rpc finalized_head failed")
RpcApi::storage_pairs(&self.as_online().rpc(), prefix, Some(at)).await.map_err(|e| {
error!("Error = {:?}", e);
"rpc storage_pairs failed"
})
}
}

Expand Down Expand Up @@ -318,8 +312,11 @@ impl Builder {
}

async fn init_remote_client(&mut self) -> Result<(), &'static str> {
let at = self.rpc_get_head().await?;
self.as_online_mut().at = Some(at);
info!(target: LOG_TARGET, "initializing remote client to {:?}", self.as_online().uri);
if self.as_online().at.is_none() {
let at = self.rpc_get_head().await?;
self.as_online_mut().at = Some(at);
}
Ok(())
}

Expand Down