Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a262766
no-std tests and porting of subxt-metadata
tadeohepperle Jan 26, 2024
8aa4bec
Merge branch 'master' into tadeohepperle/subxt-metadata-no-std
tadeohepperle Jan 26, 2024
55cfb23
update pipeline
tadeohepperle Jan 26, 2024
1b4e371
fix generate custom metadata test
tadeohepperle Jan 26, 2024
d679e95
fix cargo run command
tadeohepperle Jan 26, 2024
7954815
adjust pipeline
tadeohepperle Jan 29, 2024
fbee16d
Merge branch 'master' into tadeohepperle/subxt-metadata-no-std
tadeohepperle Jan 29, 2024
a3ec38f
init of subxt-core crate
tadeohepperle Jan 29, 2024
4512ad7
subxt-core compiles to no std again
tadeohepperle Jan 30, 2024
2e66b48
subxt compiles with new dependency features
tadeohepperle Feb 1, 2024
7b2cfdc
subxt: use utils from core
tadeohepperle Feb 1, 2024
aed00e5
start porting dynamic value stuff
tadeohepperle Feb 1, 2024
97aad71
add storage address and custom error type to core crate
tadeohepperle Feb 1, 2024
7aa6989
remove prelude from subxt-metadata
tadeohepperle Feb 1, 2024
addc4c8
Merge branch 'master' into tadeohepperle/subxt-metadata-no-std
tadeohepperle Feb 1, 2024
87200b4
revert autoformatting of Cargo.toml
tadeohepperle Feb 1, 2024
57743c3
remove alloc::format! again, still causes linker errors
tadeohepperle Feb 2, 2024
408f81e
Merge branch 'master' into tadeohepperle/subxt-metadata-no-std
tadeohepperle Feb 2, 2024
6236c49
Merge branch 'tadeohepperle/subxt-metadata-no-std' into tadeohepperle…
tadeohepperle Feb 2, 2024
e427529
remove prelude from core, use alloc directly
tadeohepperle Feb 2, 2024
e855aac
constants and storage entries
tadeohepperle Feb 2, 2024
930f2c4
custom values and runtime apis
tadeohepperle Feb 2, 2024
14b21ab
port subxt-signer to no-std (such a pain)
tadeohepperle Feb 2, 2024
4e2d3fd
core integration into subxt, except for examples
tadeohepperle Feb 2, 2024
fce85c4
start fixing examples and cleaning up interface
tadeohepperle Feb 2, 2024
e5ee971
discover linker errors for subxt-signer critical section of once_cell
tadeohepperle Feb 2, 2024
bc6cd9b
fmt for whole workspace
tadeohepperle Feb 2, 2024
f41f090
add no-std-build for thumbv7em-none-eabi target
tadeohepperle Feb 5, 2024
32f69dd
Merge branch 'tadeohepperle/subxt-metadata-no-std' into tadeohepperle…
tadeohepperle Feb 5, 2024
2b38a0f
try compiling with different methods, no success
tadeohepperle Feb 7, 2024
ce17d82
remove std feature flag
tadeohepperle Feb 14, 2024
5d6e0d5
Merge branch 'master' into tadeohepperle/subxt-metadata-no-std
tadeohepperle Feb 14, 2024
cb0d35d
Merge branch 'master' into tadeohepperle/subxt-metadata-no-std
tadeohepperle Feb 14, 2024
64987fe
adjust subxt signer static once locks
tadeohepperle Feb 14, 2024
d447f7c
remove libc and add small readme with test instructions
tadeohepperle Feb 14, 2024
a0a79c4
Merge branch 'tadeohepperle/subxt-metadata-no-std' into tadeohepperle…
tadeohepperle Feb 14, 2024
cc33870
remove unicode normalization and std references
tadeohepperle Feb 14, 2024
b86b1ea
subxt signer linker errors but core compiles
tadeohepperle Feb 14, 2024
1fe8ec3
[Fix] Auto-generated PR: delete polkadot binaries from working direct…
tadeohepperle Feb 14, 2024
db00212
Add missing codegen mod in integration tests (#1418)
tadeohepperle Feb 14, 2024
fda9a5f
Subxt Metadata: `#[no_std]` compatibility (#1401)
tadeohepperle Feb 15, 2024
ac3c7d7
fix examples with core crate
tadeohepperle Feb 15, 2024
e527687
formatting
tadeohepperle Feb 15, 2024
eeca8f8
Merge branch 'master' into tadeohepperle/subxt-core-2
tadeohepperle Feb 15, 2024
6147ac9
fix unused deps
tadeohepperle Feb 15, 2024
fbf2cc9
fix doc tests and docs
tadeohepperle Feb 16, 2024
aae7636
fmt
tadeohepperle Feb 16, 2024
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
37 changes: 33 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 21 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"cli",
"codegen",
"core",
"lightclient",
"testing/substrate-runner",
"testing/test-runtime",
Expand Down Expand Up @@ -56,6 +57,7 @@ assert_matches = "1.5.0"
base58 = { version = "0.2.0" }
bitvec = { version = "1", default-features = false }
blake2 = { version = "0.10.6", default-features = false }
cfg-if = "1.0.0"
clap = { version = "4.5.0", features = ["derive", "cargo"] }
criterion = "0.4"
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false }
Expand All @@ -64,29 +66,29 @@ console_error_panic_hook = "0.1.7"
darling = "0.20.5"
derivative = "2.2.0"
derive_more = "0.99.17"
either = "1.10.0"
either = { version = "1.9.0", default-features = false }
frame-metadata = { version = "16.0.0", default-features = false }
futures = { version = "0.3.30", default-features = false, features = ["std"] }
getrandom = { version = "0.2", default-features = false }
hashbrown = "0.14.3"
hex = "0.4.3"
hex = { version = "0.4.3", default-features = false }
heck = "0.4.1"
impl-serde = { version = "0.4.0" }
impl-serde = { version = "0.4.0", default-features = false }
indoc = "2"
jsonrpsee = { version = "0.22" }
pretty_assertions = "1.4.0"
primitive-types = { version = "0.12.2", default-features = false, features = ["codec", "scale-info", "serde"] }
primitive-types = { version = "0.12.2", default-features = false }
proc-macro-error = "1.0.4"
proc-macro2 = "1.0.78"
quote = "1.0.35"
regex = "1.10.3"
regex = { version = "1.10.3", default-features = false }
scale-info = { version = "2.10.0", default-features = false }
scale-value = "0.13.0"
scale-bits = "0.4.0"
scale-decode = "0.10.0"
scale-encode = "0.5.0"
serde = { version = "1.0.196" }
serde_json = { version = "1.0.113" }
scale-value = { version = "0.13.0", default-features = false }
scale-bits = { version = "0.4.0", default-features = false }
scale-decode = { version = "0.10.0", default-features = false }
scale-encode = { version = "0.5.0", default-features = false }
serde = { version = "1.0.196", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.113", default-features = false }
syn = { version = "2.0.15", features = ["full", "extra-traits"] }
thiserror = "1.0.57"
tokio = { version = "1.36", default-features = false }
Expand Down Expand Up @@ -129,21 +131,22 @@ sp-keyring = "31.0.0"
# Subxt workspace crates:
subxt = { version = "0.34.0", path = "subxt", default-features = false }
subxt-macro = { version = "0.34.0", path = "macro" }
subxt-metadata = { version = "0.34.0", path = "metadata" }
subxt-core = { version = "0.34.0", path = "core", default-features = false }
subxt-metadata = { version = "0.34.0", path = "metadata", default-features = false }
subxt-codegen = { version = "0.34.0", path = "codegen" }
subxt-signer = { version = "0.34.0", path = "signer" }
subxt-signer = { version = "0.34.0", path = "signer", default-features = false }
subxt-lightclient = { version = "0.34.0", path = "lightclient", default-features = false }
test-runtime = { path = "testing/test-runtime" }
substrate-runner = { path = "testing/substrate-runner" }

# subxt-signer deps that I expect aren't useful anywhere else:
bip39 = "2.0.0"
hmac = "0.12.1"
bip39 = { version = "2.0.0", default-features = false }
hmac = { version = "0.12.1", default-features = false }
pbkdf2 = { version = "0.12.2", default-features = false }
schnorrkel = "0.11.4"
secp256k1 = "0.28.2"
schnorrkel = { version = "0.11.4", default-features = false }
secp256k1 = { version = "0.28.2", default-features = false }
secrecy = "0.8.0"
sha2 = "0.10.8"
sha2 = { version = "0.10.8", default-features = false }
zeroize = { version = "1", default-features = false }

[profile.dev.package.smoldot-light]
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/explore/pallets/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn mocked_offline_client(metadata: Metadata) -> OfflineClient<SubstrateConfig> {
H256::from_str("91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3")
.expect("Valid hash; qed");

let runtime_version = subxt::backend::RuntimeVersion {
let runtime_version = subxt::RuntimeVersion {
spec_version: 9370,
transaction_version: 20,
};
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/explore/runtime_apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use subxt_metadata::RuntimeApiMetadata;

/// Runs for a specified runtime API trait.
/// Cases to consider:
/// ```norun
/// ```txt
/// method is:
/// None => Show pallet docs + available methods
/// Some (invalid) => Show Error + available methods
Expand Down
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ syn = { workspace = true }
scale-info = { workspace = true }
subxt-metadata = { workspace = true }
jsonrpsee = { workspace = true, features = ["async-client", "client-ws-transport-native-tls", "http-client"], optional = true }
hex = { workspace = true }
hex = { workspace = true, features = ["std"] }
tokio = { workspace = true, features = ["rt-multi-thread"], optional = true }
thiserror = { workspace = true }
scale-typegen = { workspace = true }
Expand Down
65 changes: 65 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[package]
name = "subxt-core"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
publish = true

license.workspace = true
readme = "README.md"
repository.workspace = true
documentation.workspace = true
homepage.workspace = true
description = "Sign extrinsics to be submitted by Subxt"
keywords = ["parity", "subxt", "extrinsic", "no-std"]

[features]
default = ["std"]
std = ["scale-info/std", "scale-value/std", "scale-bits/std", "scale-decode/std", "scale-encode/std", "frame-metadata/std", "subxt-metadata/std"]
substrate-compat = ["sp-core", "sp-runtime"]

[dependencies]

codec = { package = "parity-scale-codec", workspace = true, default-features = false, features = ["derive"] }
scale-info = { workspace = true, default-features = false, features = ["bit-vec"] }
scale-value = { workspace = true, default-features = false }
scale-bits = { workspace = true, default-features = false }
scale-decode = { workspace = true, default-features = false, features = ["derive", "primitive-types"] }
scale-encode = { workspace = true, default-features = false, features = ["derive", "primitive-types", "bits"] }
frame-metadata = { workspace = true, default-features = false }
subxt-metadata = { workspace = true, default-features = false }
derivative = { workspace = true, features = ["use_core"] }
derive_more = { workspace = true }
hex = { workspace = true, default-features = false, features = ["alloc"] }
serde = { workspace = true, default-features = false, features = ["derive"] }
serde_json = { workspace = true, default-features = false, features = ["raw_value", "alloc"] }

# 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-core-hashing = { workspace = true }

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

[dev-dependencies]
bitvec = { workspace = true }
codec = { workspace = true, features = ["derive", "bit-vec"] }
sp-core = { workspace = true }
sp-keyring = { workspace = true }
sp-runtime = { workspace = true }


[package.metadata.docs.rs]
defalt-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
defalt-features = true
3 changes: 3 additions & 0 deletions core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Subxt-Core

This library provides core functionality using in `subxt` and `subxt-signer`. It should be no-std compatible.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think for now we should add a warning here and in the lib docs that this is not stable may still change significantly between releases, so better to rely on subxt where possible: there's a lot to look at and think about with this new crate, but at the same time it'd be good to feel like we can release it now and iterate on it without worrying too much about breaking things :)

60 changes: 60 additions & 0 deletions core/src/client/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use derivative::Derivative;

use crate::{config::Config, metadata::Metadata};

/// the base for a client should be:
/// - runtime version
/// - genesis hash
/// - metadata

#[derive(Derivative)]
#[derivative(Debug(bound = ""), Clone(bound = ""))]
pub struct ClientBase<C: Config> {
pub genesis_hash: C::Hash,
pub runtime_version: RuntimeVersion,
pub metadata: Metadata,
marker: core::marker::PhantomData<C>,
}

impl<C: Config> ClientBase<C> {
pub fn new(genesis_hash: C::Hash, runtime_version: RuntimeVersion, metadata: Metadata) -> Self {
Self {
genesis_hash,
runtime_version,
metadata,
marker: core::marker::PhantomData,
}
}

pub fn metadata(&self) -> Metadata {
self.metadata.clone()
}

pub fn runtime_version(&self) -> RuntimeVersion {
self.runtime_version
}

pub fn genesis_hash(&self) -> C::Hash {
self.genesis_hash
}
}

/// Runtime version information needed to submit transactions.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RuntimeVersion {
/// Version of the runtime specification. A full-node will not attempt to use its native
/// runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`,
/// `spec_version` and `authoring_version` are the same between Wasm and native.
pub spec_version: u32,

/// All existing dispatches are fully compatible when this number doesn't change. If this
/// number changes, then `spec_version` must change, also.
///
/// This number must change when an existing dispatchable (module ID, dispatch ID) is changed,
/// either through an alteration in its user-level semantics, a parameter
/// added/removed/changed, a dispatchable being removed, a module being removed, or a
/// dispatchable/module changing its index.
///
/// It need *not* change when a new module is added or when a dispatchable is added.
pub transaction_version: u32,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,12 @@
//! [`crate::config::DefaultExtrinsicParams`] provides a general-purpose
//! implementation of this that will work in many cases.

use crate::{client::OfflineClientT, Config};
use core::fmt::Debug;
use crate::client::ClientBase;

/// An error that can be emitted when trying to construct an instance of [`ExtrinsicParams`],
/// encode data from the instance, or match on signed extensions.
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum ExtrinsicParamsError {
/// Cannot find a type id in the metadata. The context provides some additional
/// information about the source of the error (eg the signed extension name).
#[error("Cannot find type id '{type_id} in the metadata (context: {context})")]
MissingTypeId {
/// Type ID.
type_id: u32,
/// Some arbitrary context to help narrow the source of the error.
context: &'static str,
},
/// A signed extension in use on some chain was not provided.
#[error("The chain expects a signed extension with the name {0}, but we did not provide one")]
UnknownSignedExtension(String),
/// Some custom error.
#[error("Error constructing extrinsic parameters: {0}")]
Custom(CustomExtrinsicParamsError),
}

/// A custom error.
pub type CustomExtrinsicParamsError = Box<dyn std::error::Error + Send + Sync + 'static>;
use super::Config;
use crate::ExtrinsicParamsError;

impl From<std::convert::Infallible> for ExtrinsicParamsError {
fn from(value: std::convert::Infallible) -> Self {
match value {}
}
}
impl From<CustomExtrinsicParamsError> for ExtrinsicParamsError {
fn from(value: CustomExtrinsicParamsError) -> Self {
ExtrinsicParamsError::Custom(value)
}
}
use alloc::vec::Vec;

/// This trait allows you to configure the "signed extra" and
/// "additional" parameters that are a part of the transaction payload
Expand All @@ -56,9 +24,9 @@ pub trait ExtrinsicParams<T: Config>: ExtrinsicParamsEncoder + Sized + 'static {
type OtherParams;

/// Construct a new instance of our [`ExtrinsicParams`].
fn new<Client: OfflineClientT<T>>(
fn new(
nonce: u64,
client: Client,
client: ClientBase<T>,
other_params: Self::OtherParams,
) -> Result<Self, ExtrinsicParamsError>;
}
Expand Down
Loading