Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: use polkadot-sdk umbrella crate #1786

Merged
merged 20 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
8,498 changes: 6,989 additions & 1,509 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ which = "6.0.3"
strip-ansi-escapes = "0.2.0"
proptest = "1.5.0"
hex-literal = "0.4.1"
sc-executor = "0.40.1"
sc-executor-common = "0.35.0"

# Light client support:
smoldot = { version = "0.18.0", default-features = false }
Expand All @@ -138,13 +136,7 @@ instant = { version = "0.1.13", default-features = false }
tokio-util = "0.7.12"

# Substrate crates:
sp-core = { version = "34.0.0", default-features = false }
sp-crypto-hashing = { version = "0.1.0", default-features = false }
sp-runtime = "39.0.1"
sp-keyring = "39.0.0"
sp-maybe-compressed-blob = "11.0.0"
sp-state-machine = "0.43.0"
sp-io = "38.0.0"
polkadot-sdk = { version = "0.5", default-features = false }
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved

# Subxt workspace crates:
subxt = { version = "0.37.0", path = "subxt", default-features = false }
Expand Down
12 changes: 3 additions & 9 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std = [
"impl-serde/std",
"primitive-types/std",
]
substrate-compat = ["sp-core", "sp-runtime"]
substrate-compat = ["polkadot-sdk/sp-core", "polkadot-sdk/sp-runtime", "polkadot-sdk/std"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

So sp-core wasn't std before and sp-runtime was I think.. I guess std is needed here for it to work?

Copy link
Member Author

@niklasad1 niklasad1 Sep 30, 2024

Choose a reason for hiding this comment

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

sp-runtime was already std, https://github.com/paritytech/subxt/blob/master/Cargo.toml#L143

That's why it's required to be std but yeah it could brings in more dependencies because sp-core/std wasn't enabled before...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder how many more deps it ends up bringing in; maybe worth checking?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should only affect --feature --substrate-compat and not the std or no-std which I'm okay with...

Sure, lemme check

Copy link
Member Author

@niklasad1 niklasad1 Sep 30, 2024

Choose a reason for hiding this comment

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

cargo check -p subxt-core --features substrate-compat

this branch brings 351 deps vs 350 on master, I think it's fine :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah that's all good then!


[dependencies]
codec = { package = "parity-scale-codec", workspace = true, default-features = false, features = ["derive"] }
Expand All @@ -49,19 +49,16 @@ serde = { workspace = true, default-features = false, features = ["derive"] }
serde_json = { workspace = true, default-features = false, features = ["raw_value", "alloc"] }
hashbrown = { workspace = true }


# For ss58 encoding AccountId32 to serialize them properly:
base58 = { workspace = true }
blake2 = { workspace = true }

# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
impl-serde = { workspace = true, default-features = false }
primitive-types = { workspace = true, default-features = false, features = ["codec", "serde_no_std", "scale-info"] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] }

# Included if the "substrate-compat" feature is enabled.
sp-core = { workspace = true, optional = true }
sp-runtime = { workspace = true, optional = true }
tracing = { workspace = true, default-features = false }

# AccountId20
Expand All @@ -73,12 +70,9 @@ bitvec = { workspace = true }
codec = { workspace = true, features = ["derive", "bit-vec"] }
subxt-macro = { workspace = true }
subxt-signer = { workspace = true, features = ["sr25519", "subxt"] }
sp-core = { workspace = true }
sp-keyring = { workspace = true }
sp-runtime = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing", "sp-core", "sp-keyring"] }
hex = { workspace = true }


[package.metadata.docs.rs]
defalt-features = true
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
1 change: 1 addition & 0 deletions core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ cfg_substrate_compat! {
/// implement subxt's Hasher and Header traits for some substrate structs
mod substrate_impls {
use super::*;
use polkadot_sdk::sp_runtime;

impl<T: sp_runtime::traits::Header> Header for T
where
Expand Down
1 change: 1 addition & 0 deletions core/src/config/substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder, Hashe
use alloc::format;
use alloc::vec::Vec;
use codec::{Decode, Encode};
use polkadot_sdk::sp_crypto_hashing;
use serde::{Deserialize, Serialize};

pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub mod ext {
pub use scale_value;

cfg_substrate_compat! {
pub use sp_runtime;
pub use sp_core;
pub use polkadot_sdk::sp_runtime;
pub use polkadot_sdk::sp_core;
}
}
1 change: 1 addition & 0 deletions core/src/storage/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::error::{Error, MetadataError};
use crate::metadata::Metadata;
use alloc::borrow::ToOwned;
use alloc::vec::Vec;
use polkadot_sdk::sp_crypto_hashing;
use subxt_metadata::{PalletMetadata, StorageEntryMetadata, StorageHasher};

/// Return the root of a given [`Address`]: hash the pallet name and entry name
Expand Down
2 changes: 1 addition & 1 deletion core/src/tx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ use alloc::borrow::{Cow, ToOwned};
use alloc::vec::Vec;
use codec::{Compact, Encode};
use payload::Payload;
use polkadot_sdk::sp_crypto_hashing::blake2_256;
use signer::Signer as SignerT;
use sp_crypto_hashing::blake2_256;

// Expose these here since we expect them in some calls below.
pub use crate::client::{ClientState, RuntimeVersion};
Expand Down
4 changes: 2 additions & 2 deletions core/src/tx/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ cfg_substrate_compat! {
mod pair_signer {
use super::Signer;
use crate::Config;
use sp_core::Pair as PairT;
use sp_runtime::{
use polkadot_sdk::sp_core::Pair as PairT;
use polkadot_sdk::sp_runtime::{
traits::{IdentifyAccount, Verify},
AccountId32 as SpAccountId32, MultiSignature as SpMultiSignature,
};
Expand Down
5 changes: 3 additions & 2 deletions core/src/utils/account_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl core::str::FromStr for AccountId32 {
#[cfg(feature = "substrate-compat")]
mod substrate_impls {
use super::*;
use polkadot_sdk::{sp_core, sp_runtime};

impl From<sp_runtime::AccountId32> for AccountId32 {
fn from(value: sp_runtime::AccountId32) -> Self {
Expand All @@ -199,8 +200,8 @@ mod substrate_impls {
mod test {
use super::*;

use sp_core::crypto::Ss58Codec;
use sp_keyring::AccountKeyring;
use polkadot_sdk::sp_core::{self, crypto::Ss58Codec};
use polkadot_sdk::sp_keyring::AccountKeyring;

#[test]
fn ss58_is_compatible_with_substrate_impl() {
Expand Down
1 change: 1 addition & 0 deletions core/src/utils/multi_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl<AccountId, AccountIndex> From<AccountId> for MultiAddress<AccountId, Accoun
#[cfg(feature = "substrate-compat")]
mod substrate_impls {
use super::{super::AccountId32, *};
use polkadot_sdk::sp_runtime;

impl<N> From<sp_runtime::AccountId32> for MultiAddress<AccountId32, N> {
fn from(value: sp_runtime::AccountId32) -> Self {
Expand Down
1 change: 1 addition & 0 deletions core/src/utils/multi_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub enum MultiSignature {
#[cfg(feature = "substrate-compat")]
mod substrate_impls {
use super::*;
use polkadot_sdk::{sp_core, sp_runtime};

impl From<sp_runtime::MultiSignature> for MultiSignature {
fn from(value: sp_runtime::MultiSignature) -> Self {
Expand Down
8 changes: 2 additions & 6 deletions macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description = "Generate types and helpers for interacting with Substrate runtime

[features]
web = ["subxt-codegen/web"]
runtime-path = ["sp-io", "sc-executor-common", "sp-state-machine", "sp-maybe-compressed-blob", "sc-executor"]
runtime-path = ["polkadot-sdk"]

[lib]
proc-macro = true
Expand All @@ -28,11 +28,7 @@ syn = { workspace = true }
quote = { workspace = true }
subxt-codegen = { workspace = true, features = ["fetch-metadata"] }
scale-typegen = { workspace = true }
sc-executor = { workspace = true, optional = true }
sp-maybe-compressed-blob = { workspace = true, optional = true }
sp-state-machine = { workspace = true, optional = true }
sp-io = { workspace = true, optional = true }
sc-executor-common = { workspace = true, optional = true }
polkadot-sdk = { workspace = true, optional = true, features = ["sp-io", "sc-executor-common", "sp-state-machine", "sp-maybe-compressed-blob", "sc-executor"] }

[lints]
workspace = true
10 changes: 7 additions & 3 deletions macro/src/wasm_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
use std::{borrow::Cow, path::Path};

use codec::Decode;
use sc_executor::{WasmExecutionMethod, WasmExecutor};
use sc_executor_common::runtime_blob::RuntimeBlob;
use sp_maybe_compressed_blob::CODE_BLOB_BOMB_LIMIT;
use polkadot_sdk::{
sc_executor::{self, WasmExecutionMethod, WasmExecutor},
sc_executor_common::runtime_blob::RuntimeBlob,
sp_io,
sp_maybe_compressed_blob::{self, CODE_BLOB_BOMB_LIMIT},
sp_state_machine,
};
use subxt_codegen::{fetch_metadata::fetch_metadata_from_file_blocking, CodegenError, Metadata};

/// Result type shorthand
Expand Down
2 changes: 1 addition & 1 deletion metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ std = ["scale-info/std", "frame-metadata/std"]
scale-info = { workspace = true, default-features = false }
frame-metadata = { workspace = true, default-features = false, features = ["current", "decode"] }
codec = { package = "parity-scale-codec", workspace = true, default-features = false, features = ["derive"] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, default-features = false, features = ["sp-crypto-hashing"] }
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
hashbrown = { workspace = true }

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions metadata/src/utils/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
use alloc::vec::Vec;
use hashbrown::HashMap;
use outer_enum_hashes::OuterEnumHashes;
use polkadot_sdk::sp_crypto_hashing;
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};

pub mod outer_enum_hashes;
Expand Down
6 changes: 2 additions & 4 deletions signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ keywords = ["parity", "subxt", "extrinsic", "signer"]
default = ["sr25519", "ecdsa", "subxt", "std"]
std = [
"regex/std",
"sp-crypto-hashing/std",
"pbkdf2/std",
"sha2/std",
"hmac/std",
Expand Down Expand Up @@ -60,7 +59,7 @@ cfg-if = { workspace = true }
codec = { package = "parity-scale-codec", workspace = true, features = [
"derive",
] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] }
pbkdf2 = { workspace = true }
sha2 = { workspace = true }
hmac = { workspace = true }
Expand All @@ -85,10 +84,9 @@ crypto_secretbox = { workspace = true, optional = true, features = ["alloc", "sa
getrandom = { workspace = true, optional = true }

[dev-dependencies]
sp-keyring = { workspace = true }
proptest = { workspace = true }
hex-literal = { workspace = true }
sp-core = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-core", "sp-keyring"] }

[package.metadata.cargo-machete]
ignored = ["getrandom"]
Expand Down
1 change: 1 addition & 0 deletions signer/src/crypto/derive_junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// see LICENSE for license details.

use codec::{Decode, Encode};
use polkadot_sdk::sp_crypto_hashing;

// This code is taken from sp_core::crypto::DeriveJunction. The logic should be identical,
// though the API is tweaked a touch.
Expand Down
4 changes: 2 additions & 2 deletions signer/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

//! An ecdsa keypair implementation.
use codec::Encode;
use polkadot_sdk::sp_crypto_hashing;

use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri};
use core::{fmt::Display, str::FromStr};
Expand Down Expand Up @@ -359,8 +360,7 @@ mod test {

use super::*;

use sp_core::crypto::Pair as _;
use sp_core::ecdsa::Pair as SpPair;
use polkadot_sdk::sp_core::{self, crypto::Pair as _, ecdsa::Pair as SpPair};

#[test]
fn check_from_phrase_matches() {
Expand Down
4 changes: 2 additions & 2 deletions signer/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ mod test {

use super::*;

use sp_core::crypto::Pair as _;
use sp_core::sr25519::Pair as SpPair;
use polkadot_sdk::sp_core::{self, crypto::Pair as _, sr25519::Pair as SpPair};
use polkadot_sdk::sp_keyring;

#[test]
fn check_from_phrase_matches() {
Expand Down
6 changes: 2 additions & 4 deletions subxt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ instant = { workspace = true }
# Provides some deserialization, types like U256/H256 and hashing impls like twox/blake256:
impl-serde = { workspace = true }
primitive-types = { workspace = true, features = ["codec", "scale-info", "serde"] }
sp-crypto-hashing = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing", "std"] }

# Included if the "jsonrpsee" feature is enabled.
jsonrpsee = { workspace = true, optional = true, features = ["jsonrpsee-types"] }
Expand Down Expand Up @@ -127,9 +127,7 @@ bitvec = { workspace = true }
codec = { workspace = true, features = ["derive", "bit-vec"] }
scale-info = { workspace = true, features = ["bit-vec"] }
tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread", "sync"] }
sp-core = { workspace = true }
sp-keyring = { workspace = true }
sp-runtime = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-core", "sp-keyring", "sp-runtime", "sp-crypto-hashing"] }
assert_matches = { workspace = true }
subxt-signer = { path = "../signer", features = ["unstable-eth"] }
# Tracing subscriber is useful for light-client examples to ensure that
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ mod test {
pub use crate::backend::rpc::{RawRpcFuture, RawRpcSubscription};
pub use crate::{backend::StorageResponse, error::RpcError};
pub use futures::StreamExt;
pub use polkadot_sdk::sp_core::{self, H256};
pub use rpc::RpcClientT;
pub use serde::Serialize;
pub use serde_json::value::RawValue;
pub use sp_core::H256;
pub use std::collections::{HashMap, VecDeque};
pub use subxt_core::{config::DefaultExtrinsicParams, Config};
pub use tokio::sync::{mpsc, Mutex};
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/backend/unstable/follow_stream_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ mod test_utils {
#[cfg(test)]
mod test {
use futures::TryStreamExt;
use sp_core::H256;
use polkadot_sdk::sp_core::H256;

use super::super::follow_stream::test_utils::{
ev_best_block, ev_finalized, ev_initialized, ev_new_block,
Expand Down
3 changes: 2 additions & 1 deletion subxt/src/book/usage/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@
//! # {
//! use subxt::config::PolkadotConfig;
//! use std::str::FromStr;
//! use polkadot_sdk::{sp_core, sp_keyring};
//!
//! //// 1. Use a `subxt_signer` impl:
//! use subxt_signer::{ SecretUri, sr25519 };
//! use subxt_signer::{SecretUri, sr25519};
//!
//! // Get hold of a `Signer` for a test account:
//! let alice = sr25519::dev::alice();
Expand Down
1 change: 1 addition & 0 deletions subxt/src/events/events_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::backend::{Backend, BackendExt, BlockRef};
use crate::{client::OnlineClientT, error::Error, events::Events, Config};
use derive_where::derive_where;
use polkadot_sdk::sp_crypto_hashing;
use std::future::Future;

/// A client for working with events.
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub mod ext {
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// substitute_type(
/// path = "sp_runtime::multiaddress::MultiAddress<A, B>",
/// with = "::subxt::utils::Static<::sp_runtime::MultiAddress<A, B>>"
/// with = "::subxt::utils::Static<polkadot_sdk::sp_runtime::MultiAddress<A, B>>"
/// )
/// )]
/// mod polkadot {}
Expand Down
1 change: 1 addition & 0 deletions subxt/src/storage/storage_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
use codec::Decode;
use derive_where::derive_where;
use futures::StreamExt;
use polkadot_sdk::sp_crypto_hashing;
use std::{future::Future, marker::PhantomData};
use subxt_core::storage::address::{Address, StorageHashers, StorageKey};
use subxt_core::utils::Yes;
Expand Down
4 changes: 2 additions & 2 deletions subxt/src/tx/tx_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ mod test {

#[test]
fn transaction_validity_decoding_is_ok() {
use sp_runtime::transaction_validity as sp;
use sp_runtime::transaction_validity::TransactionValidity as T;
use polkadot_sdk::sp_runtime::transaction_validity as sp;
use polkadot_sdk::sp_runtime::transaction_validity::TransactionValidity as T;

let pairs = vec![
(
Expand Down
2 changes: 1 addition & 1 deletion testing/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ hex = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
scale-info = { workspace = true, features = ["bit-vec"] }
sp-core = { workspace = true }
polkadot-sdk = { workspace = true, features = ["sp-core"] }
syn = { workspace = true }
subxt = { workspace = true, features = ["unstable-metadata", "native", "jsonrpsee", "substrate-compat", "unstable-reconnecting-rpc-client"] }
subxt-signer = { workspace = true, features = ["default"] }
Expand Down
1 change: 1 addition & 0 deletions testing/integration-tests/src/full_client/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// see LICENSE for license details.

use crate::{node_runtime, subxt_test, test_context, utils::wait_for_blocks};
use polkadot_sdk::sp_core;

#[cfg(fullclient)]
use subxt::utils::AccountId32;
Expand Down
Loading
Loading