Skip to content

Commit

Permalink
Upgrade to substrate rc4 release (paritytech#131)
Browse files Browse the repository at this point in the history
* Upgrade to substrate rc4 release

* Fix up test-node/service

* Fix up client node config

* Fix up remaining compilation errors

* Fmt

* Remove fixme

* Fix test

* Release v0.10.0
  • Loading branch information
ascjones authored Jun 29, 2020
1 parent 4ee7fb1 commit d3e9e3f
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 89 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 0.10.0 (2020-06-19)

* Upgrade to substrate rc4 release [#131](https://github.com/paritytech/substrate-subxt/pull/131)
* Support unsigned extrinsics. [#130](https://github.com/paritytech/substrate-subxt/pull/130)

# Version 0.9.0 (2020-06-25)

* Events sub [#126](https://github.com/paritytech/substrate-subxt/pull/126)
Expand Down
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "client", "proc-macro", "test-node"]

[package]
name = "substrate-subxt"
version = "0.9.0"
version = "0.10.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand All @@ -30,26 +30,26 @@ serde_json = "1.0.55"
url = "2.1.1"
codec = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive", "full"] }

frame-metadata = { version = "11.0.0-rc3", package = "frame-metadata" }
frame-support = { version = "2.0.0-rc3", package = "frame-support" }
sp-runtime = { version = "2.0.0-rc3", package = "sp-runtime" }
sp-version = { version = "2.0.0-rc3", package = "sp-version" }
pallet-indices = { version = "2.0.0-rc3", package = "pallet-indices" }
frame-metadata = { version = "11.0.0-rc4", package = "frame-metadata" }
frame-support = { version = "2.0.0-rc4", package = "frame-support" }
sp-runtime = { version = "2.0.0-rc4", package = "sp-runtime" }
sp-version = { version = "2.0.0-rc4", package = "sp-version" }
pallet-indices = { version = "2.0.0-rc4", package = "pallet-indices" }
hex = "0.4.2"
sp-rpc = { version = "2.0.0-rc3", package = "sp-rpc" }
sp-core = { version = "2.0.0-rc3", package = "sp-core" }
sc-rpc-api = { version = "0.8.0-rc3", package = "sc-rpc-api" }
sp-transaction-pool = { version = "2.0.0-rc3", package = "sp-transaction-pool" }
sp-rpc = { version = "2.0.0-rc4", package = "sp-rpc" }
sp-core = { version = "2.0.0-rc4", package = "sp-core" }
sc-rpc-api = { version = "0.8.0-rc4", package = "sc-rpc-api" }
sp-transaction-pool = { version = "2.0.0-rc4", package = "sp-transaction-pool" }
substrate-subxt-client = { version = "0.1.0", path = "client", optional = true }
substrate-subxt-proc-macro = { version = "0.9.0", path = "proc-macro" }

[dev-dependencies]
async-std = { version = "=1.5.0", features = ["attributes"] }
env_logger = "0.7.1"
wabt = "0.9.2"
frame-system = { version = "2.0.0-rc3", package = "frame-system" }
pallet-balances = { version = "2.0.0-rc3", package = "pallet-balances" }
sp-keyring = { version = "2.0.0-rc3", package = "sp-keyring" }
frame-system = { version = "2.0.0-rc4", package = "frame-system" }
pallet-balances = { version = "2.0.0-rc4", package = "pallet-balances" }
sp-keyring = { version = "2.0.0-rc4", package = "sp-keyring" }
substrate-subxt-client = { version = "0.1.0", path = "client" }
tempdir = "0.3.7"
test-node = { path = "test-node" }
6 changes: 3 additions & 3 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ futures = { version = "0.3.5", features = ["compat"] }
futures01 = { package = "futures", version = "0.1.29" }
jsonrpsee = "0.1.0"
log = "0.4.8"
sc-network = { version = "0.8.0-rc3", default-features = false }
sc-service = { version = "0.8.0-rc3", default-features = false }
sc-network = { version = "0.8.0-rc4", default-features = false }
sc-service = { version = "0.8.0-rc4", default-features = false }
serde_json = "1.0.55"
sp-keyring = "2.0.0-rc3"
sp-keyring = "2.0.0-rc4"
thiserror = "1.0.20"

[dev-dependencies]
Expand Down
9 changes: 7 additions & 2 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,13 @@ fn start_subxt_client<C: ChainSpec + 'static, S: AbstractService>(
impl_version: config.impl_version,
chain_spec: Box::new(config.chain_spec),
role: config.role.into(),
task_executor: std::sync::Arc::new(move |fut, ty| {
task_executor: (move |fut, ty| {
match ty {
TaskType::Async => task::spawn(fut),
TaskType::Blocking => task::spawn_blocking(|| task::block_on(fut)),
};
}),
})
.into(),
database: config.db,
keystore: KeystoreConfig::InMemory,
max_runtime_instances: 8,
Expand All @@ -231,6 +232,7 @@ fn start_subxt_client<C: ChainSpec + 'static, S: AbstractService>(
pruning: Default::default(),
rpc_cors: Default::default(),
rpc_http: Default::default(),
rpc_ipc: Default::default(),
rpc_ws: Default::default(),
rpc_ws_max_connections: Default::default(),
rpc_methods: Default::default(),
Expand All @@ -240,6 +242,8 @@ fn start_subxt_client<C: ChainSpec + 'static, S: AbstractService>(
tracing_targets: Default::default(),
transaction_pool: Default::default(),
wasm_method: Default::default(),
base_path: Default::default(),
informant_output_format: Default::default(),
};

log::info!("{}", service_config.impl_name);
Expand Down Expand Up @@ -329,6 +333,7 @@ mod tests {
test_node::chain_spec::ChainSpec::from_json_bytes(bytes).unwrap();
let tmp = TempDir::new("subxt-").expect("failed to create tempdir");
let config = SubxtClientConfig {
// base_path:
impl_name: "substrate-subxt-light-client",
impl_version: "0.0.1",
author: "David Craven",
Expand Down
2 changes: 1 addition & 1 deletion proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async-std = { version = "=1.5.0", features = ["attributes"] }
codec = { package = "parity-scale-codec", version = "1.3.0", features = ["derive"] }
env_logger = "0.7.1"
pretty_assertions = "0.6.1"
sp-keyring = "2.0.0-rc3"
sp-keyring = "2.0.0-rc4"
substrate-subxt = { path = ".." }
trybuild = "1.0.30"

Expand Down
3 changes: 2 additions & 1 deletion src/frame/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use serde::de::DeserializeOwned;
use sp_runtime::{
traits::{
AtLeast32Bit,
AtLeast32BitUnsigned,
Bounded,
CheckEqual,
Extrinsic,
Expand Down Expand Up @@ -67,7 +68,7 @@ pub trait System {
+ MaybeSerializeDeserialize
+ Debug
+ MaybeDisplay
+ AtLeast32Bit
+ AtLeast32BitUnsigned
+ Default
+ Bounded
+ Copy
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<T: Runtime> Client<T> {
/// Get a block hash. By default returns the latest block hash
pub async fn block_hash(
&self,
block_number: Option<BlockNumber<T>>,
block_number: Option<BlockNumber>,
) -> Result<Option<T::Hash>, Error> {
let hash = self.rpc.block_hash(block_number).await?;
Ok(hash)
Expand Down Expand Up @@ -578,7 +578,7 @@ mod tests {

// create raw payload with AccoundId and sign it
let raw_payload = client
.create_unsigned(
.create_payload(
balances::TransferCall {
to: &dest,
amount: 10_000,
Expand Down
25 changes: 7 additions & 18 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use jsonrpsee::{
},
Client,
};
use num_traits::bounds::Bounded;
use sc_rpc_api::state::ReadProof;
use serde::Serialize;
use sp_core::{
Expand Down Expand Up @@ -83,23 +82,15 @@ pub type ChainBlock<T> =

/// Wrapper for NumberOrHex to allow custom From impls
#[derive(Serialize)]
#[serde(bound = "<T as System>::BlockNumber: Serialize")]
pub struct BlockNumber<T: System>(NumberOrHex<<T as System>::BlockNumber>);

impl<T> From<NumberOrHex<<T as System>::BlockNumber>> for BlockNumber<T>
where
T: System,
{
fn from(x: NumberOrHex<<T as System>::BlockNumber>) -> Self {
pub struct BlockNumber(NumberOrHex);

impl From<NumberOrHex> for BlockNumber {
fn from(x: NumberOrHex) -> Self {
BlockNumber(x)
}
}

impl<T> From<u32> for BlockNumber<T>
where
T: System,
<T as System>::BlockNumber: From<u32>,
{
impl From<u32> for BlockNumber {
fn from(x: u32) -> Self {
NumberOrHex::Number(x.into()).into()
}
Expand Down Expand Up @@ -160,9 +151,7 @@ impl<T: Runtime> Rpc<T> {

/// Fetch the genesis hash
pub async fn genesis_hash(&self) -> Result<T::Hash, Error> {
let block_zero = Some(ListOrValue::Value(NumberOrHex::Number(
T::BlockNumber::min_value(),
)));
let block_zero = Some(ListOrValue::Value(NumberOrHex::Number(0)));
let params = Params::Array(vec![to_json_value(block_zero)?]);
let list_or_value: ListOrValue<Option<T::Hash>> =
self.client.request("chain_getBlockHash", params).await?;
Expand Down Expand Up @@ -198,7 +187,7 @@ impl<T: Runtime> Rpc<T> {
/// Get a block hash, returns hash of latest block by default
pub async fn block_hash(
&self,
block_number: Option<BlockNumber<T>>,
block_number: Option<BlockNumber>,
) -> Result<Option<T::Hash>, Error> {
let block_number = block_number.map(ListOrValue::Value);
let params = Params::Array(vec![to_json_value(block_number)?]);
Expand Down
40 changes: 20 additions & 20 deletions test-node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "test-node"
version = "2.0.0-rc3"
version = "2.0.0-rc4"
authors = ["Anonymous"]
description = "Substrate Node template"
edition = "2018"
Expand All @@ -18,25 +18,25 @@ log = "0.4.8"
structopt = "0.3.15"
parking_lot = "0.11.0"

sc-cli = { version = "0.8.0-rc3", features = ["wasmtime"] }
sp-core = "2.0.0-rc3"
sc-executor = { version = "0.8.0-rc3", features = ["wasmtime"] }
sc-service = { version = "0.8.0-rc3", features = ["wasmtime"] }
sp-inherents = "2.0.0-rc3"
sc-transaction-pool = "2.0.0-rc3"
sp-transaction-pool = "2.0.0-rc3"
sc-network = "0.8.0-rc3"
sc-consensus-aura = "0.8.0-rc3"
sp-consensus-aura = "0.8.0-rc3"
sp-consensus = "0.8.0-rc3"
sc-consensus = "0.8.0-rc3"
sc-finality-grandpa = "0.8.0-rc3"
sp-finality-grandpa = "2.0.0-rc3"
sc-client-api = "2.0.0-rc3"
sp-runtime = "2.0.0-rc3"
sc-basic-authorship = "0.8.0-rc3"
sc-cli = { version = "0.8.0-rc4", features = ["wasmtime"] }
sp-core = "2.0.0-rc4"
sc-executor = { version = "0.8.0-rc4", features = ["wasmtime"] }
sc-service = { version = "0.8.0-rc4", features = ["wasmtime"] }
sp-inherents = "2.0.0-rc4"
sc-transaction-pool = "2.0.0-rc4"
sp-transaction-pool = "2.0.0-rc4"
sc-network = "0.8.0-rc4"
sc-consensus-aura = "0.8.0-rc4"
sp-consensus-aura = "0.8.0-rc4"
sp-consensus = "0.8.0-rc4"
sc-consensus = "0.8.0-rc4"
sc-finality-grandpa = "0.8.0-rc4"
sp-finality-grandpa = "2.0.0-rc4"
sc-client-api = "2.0.0-rc4"
sp-runtime = "2.0.0-rc4"
sc-basic-authorship = "0.8.0-rc4"

test-node-runtime = { version = "2.0.0-rc3", path = "runtime" }
test-node-runtime = { version = "2.0.0-rc4", path = "runtime" }

[build-dependencies]
substrate-build-script-utils = "2.0.0-rc3"
substrate-build-script-utils = "2.0.0-rc4"
46 changes: 23 additions & 23 deletions test-node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "test-node-runtime"
version = "2.0.0-rc3"
version = "2.0.0-rc4"
authors = ["Anonymous"]
edition = "2018"
license = "Unlicense"
Expand All @@ -13,29 +13,29 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }

aura = { version = "2.0.0-rc3", default-features = false, package = "pallet-aura" }
balances = { version = "2.0.0-rc3", default-features = false, package = "pallet-balances" }
frame-support = { version = "2.0.0-rc3", default-features = false }
grandpa = { version = "2.0.0-rc3", default-features = false, package = "pallet-grandpa" }
randomness-collective-flip = { version = "2.0.0-rc3", default-features = false, package = "pallet-randomness-collective-flip" }
sudo = { version = "2.0.0-rc3", default-features = false, package = "pallet-sudo" }
system = { version = "2.0.0-rc3", default-features = false, package = "frame-system" }
timestamp = { version = "2.0.0-rc3", default-features = false, package = "pallet-timestamp" }
transaction-payment = { version = "2.0.0-rc3", default-features = false, package = "pallet-transaction-payment" }
frame-executive = { version = "2.0.0-rc3", default-features = false }
aura = { version = "2.0.0-rc4", default-features = false, package = "pallet-aura" }
balances = { version = "2.0.0-rc4", default-features = false, package = "pallet-balances" }
frame-support = { version = "2.0.0-rc4", default-features = false }
grandpa = { version = "2.0.0-rc4", default-features = false, package = "pallet-grandpa" }
randomness-collective-flip = { version = "2.0.0-rc4", default-features = false, package = "pallet-randomness-collective-flip" }
sudo = { version = "2.0.0-rc4", default-features = false, package = "pallet-sudo" }
system = { version = "2.0.0-rc4", default-features = false, package = "frame-system" }
timestamp = { version = "2.0.0-rc4", default-features = false, package = "pallet-timestamp" }
transaction-payment = { version = "2.0.0-rc4", default-features = false, package = "pallet-transaction-payment" }
frame-executive = { version = "2.0.0-rc4", default-features = false }
serde = { version = "1.0.114", optional = true, features = ["derive"] }
sp-api = { version = "2.0.0-rc3", default-features = false }
sp-block-builder = { default-features = false, version = "2.0.0-rc3" }
sp-consensus-aura = { version = "0.8.0-rc3", default-features = false }
sp-core = { version = "2.0.0-rc3", default-features = false }
sp-inherents = { default-features = false, version = "2.0.0-rc3" }
sp-io = { version = "2.0.0-rc3", default-features = false }
sp-offchain = { version = "2.0.0-rc3", default-features = false }
sp-runtime = { version = "2.0.0-rc3", default-features = false }
sp-session = { version = "2.0.0-rc3", default-features = false }
sp-std = { version = "2.0.0-rc3", default-features = false }
sp-transaction-pool = { version = "2.0.0-rc3", default-features = false }
sp-version = { version = "2.0.0-rc3", default-features = false }
sp-api = { version = "2.0.0-rc4", default-features = false }
sp-block-builder = { default-features = false, version = "2.0.0-rc4" }
sp-consensus-aura = { version = "0.8.0-rc4", default-features = false }
sp-core = { version = "2.0.0-rc4", default-features = false }
sp-inherents = { default-features = false, version = "2.0.0-rc4" }
sp-io = { version = "2.0.0-rc4", default-features = false }
sp-offchain = { version = "2.0.0-rc4", default-features = false }
sp-runtime = { version = "2.0.0-rc4", default-features = false }
sp-session = { version = "2.0.0-rc4", default-features = false }
sp-std = { version = "2.0.0-rc4", default-features = false }
sp-transaction-pool = { version = "2.0.0-rc4", default-features = false }
sp-version = { version = "2.0.0-rc4", default-features = false }

[build-dependencies]
wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner" }
Expand Down
2 changes: 2 additions & 0 deletions test-node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ parameter_types! {
}

impl system::Trait for Runtime {
/// The basic call filter to use in dispatchable.
type BaseCallFilter = ();
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
Expand Down
13 changes: 7 additions & 6 deletions test-node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()?;
.build_full()?;

if role.is_authority() {
let proposer = sc_basic_authorship::ProposerFactory::new(
Expand Down Expand Up @@ -177,19 +177,20 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr

// the AURA authoring task is considered essential, i.e. if it
// fails we take down the service with it.
service.spawn_essential_task("aura", aura);
service
.spawn_essential_task_handle()
.spawn_blocking("aura", aura);
}

// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore = if role.is_authority() {
Some(service.keystore())
Some(service.keystore() as sp_core::traits::BareCryptoStorePtr)
} else {
None
};

let grandpa_config = sc_finality_grandpa::Config {
// #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
name: Some(name),
Expand Down Expand Up @@ -219,7 +220,7 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr

// the GRANDPA voter task is considered infallible, i.e.
// if it fails we take down the service with it.
service.spawn_essential_task(
service.spawn_essential_task_handle().spawn_blocking(
"grandpa-voter",
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
);
Expand Down Expand Up @@ -299,5 +300,5 @@ pub fn new_light(config: Configuration) -> Result<impl AbstractService, ServiceE
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()
.build_light()
}

0 comments on commit d3e9e3f

Please sign in to comment.