Skip to content

feat: migrate storage-client and provider-node to typed subxt bindings via storage-subxt#239

Open
danielbui12 wants to merge 37 commits into
devfrom
subxt_runtime_metadata
Open

feat: migrate storage-client and provider-node to typed subxt bindings via storage-subxt#239
danielbui12 wants to merge 37 commits into
devfrom
subxt_runtime_metadata

Conversation

@danielbui12

@danielbui12 danielbui12 commented Jun 25, 2026

Copy link
Copy Markdown
Member

Changes

  • New crate storage-subxt: generated subxt typed bindings for the runtime, re-exporting subxt and subxt_signer as the single source of truth for those deps across the workspace
  • storage-client
    • Replaced all subxt::dynamic::tx/storage/constant calls with typed runtime::tx() / runtime::storage() / runtime::constants() builders
    • Added runtime_convert.rs: byte-exact conversion layer between domain types (AccountId32, H256, MultiSignature, AgreementTerms, Role, EndAction, proof structs) and generated runtime_types::*
    • Replaced per-file manual scale_value decoders with direct typed-struct field access
    • Migrated event_subscription.rs to typed as_event::<ev::*>() decoding; deleted scale_decode.rs
    • Removed direct subxt/subxt-signer deps from client/Cargo.toml; all imports now flow through storage_subxt::subxt / storage_subxt::subxt_signer
  • provider-node
    • SubxtChainClient rewritten: holds a SubstrateClient (from storage_client) instead of raw OnlineClient + Keypair; all coordinator trait impls use typed storage::* / extrinsics::*
    • ChainMembershipResolver in auth.rs replaced dynamic Buckets query + scale_value decoding with typed storage::bucket_info() + rt::storage_primitives::Role matching
    • Added three new functions to client/src/substrate.rs: extrinsics::update_provider_multiaddr, extrinsics::provider_checkpoint, storage::checkpoint_config

Issue

@danielbui12 danielbui12 self-assigned this Jun 25, 2026
@danielbui12
danielbui12 marked this pull request as ready for review June 25, 2026 10:58
@danielbui12
danielbui12 requested a review from bkontur June 25, 2026 10:59
@bkontur

bkontur commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

@danielbui12 please, make some TODO to check also using storage queries in TS SDK e.g.: 48d7560#diff-9c9ec00799f06105758439222211e7ef2fc782460416fb49c8234c3c1a8305efR174

@danielbui12

Copy link
Copy Markdown
Member Author

@danielbui12 please, make some TODO to check also using storage queries in TS SDK e.g.: 48d7560#diff-9c9ec00799f06105758439222211e7ef2fc782460416fb49c8234c3c1a8305efR174

I created an issue #243

@danielbui12

Copy link
Copy Markdown
Member Author

/cmd fmt

…lenge index, and challenge queries

Bump StorageProviderApi to #[api_version(2)] and extend its read surface so
clients can recover double-map keys and enumerate challenges via the typed
runtime API instead of hand-parsing raw storage-key bytes.

- AgreementResponse gains `bucket_id`; ChallengeResponse gains `index`
  (position within a deadline block's Vec<Challenge>), populated in
  query_agreement_info/query_bucket_agreements/query_provider_agreements and
  query_challenges_at.
- Add bucket_challenges(bucket_id) and provider_challenges(provider) following
  the existing bucket_agreements/provider_agreements pattern; wired into both
  the local and paseo runtime impl blocks.
- Cover the new fields and queries with pallet unit tests.
Add a symmetric challenger_challenges(challenger) -> Vec<ChallengeResponse>
method alongside the existing bucket_challenges/provider_challenges, completing
the key-scoped challenge query surface. This serves list_my_challenges which
filters by the challenger field and has no other clean runtime-API mapping.

Implements query_challenger_challenges in the pallet (identical shape to
query_provider_challenges, filtering on challenge.challenger). Wired into both
the local and paseo runtime impl blocks. Test added: 194 pallet tests pass.
Replace the hand-rolled Providers storage-key byte parsing in
DiscoveryClient with typed StorageProviderApi calls, removing the
account_ss58_from_key helper that decoded the SS58 account out of raw
key bytes at fixed offsets.

- list_providers now calls providers(offset, limit).
- providers_with_capacity now calls providers_with_capacity(bytes_needed,
  offset, limit) (server-side filter also enforces stake sufficiency).
- Return type changes from (String, ProviderInfo) to
  (String, ProviderInfoResponse); integration tests updated to the flat
  response fields.

Includes the regenerated storage-subxt bindings (api_version 2) the
client now compiles against.
Migrate all client and provider-node sites that hand-parsed storage keys
to the versioned StorageProviderApi runtime API:

- discovery.rs: enumerate providers via providers(offset,limit)
- admin.rs: list_bucket_agreements via bucket_agreements; return
  AgreementResponse directly (drop AgreementInfo wrapper)
- provider.rs: provider_agreements / provider_challenges; drop redundant
  ChallengeInfo.deadline (already in ChallengeResponse)
- challenger.rs: challenger_challenges; paginated provider enumeration
- subxt_client.rs: provider_agreements for replica discovery; delete
  extract_bucket_if_provider
- storage-subxt: AgreementResponse::is_primary helper
Comment thread pallet/src/lib.rs Outdated
Comment thread pallet/src/lib.rs Outdated
Comment thread pallet/src/runtime_api.rs
@danielbui12
danielbui12 requested a review from bkontur July 3, 2026 00:53
Comment thread provider-node/src/storage/disk.rs Outdated
use sp_core::H256;
use std::path::Path;
use std::sync::{Arc, Mutex};
use storage_client::provider_node_request_scheme::*;

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.

@danielbui12 ok, ok, I see, this PR tries to move "too much"/"lots of" stuff now. The problem why I created the #178 is that at some point we started using storage-client as a dependency of provider-node, which is not the best thing, it should rather be the other way, the SDK client should use/include some shared deps from provider (e.g. subxt handling or common structs). Let me think, we need extract and clean carefully in the direction of #178

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I revert the provider-node migrations. keep only the subxt bidings-related changes

accepting_extensions: true,
agreements_total: 3,
challenges_failed: 1,
settings: ProviderSettings {

@bkontur bkontur Jul 6, 2026

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.

  • @danielbui12 please, replicate/extract just this wrapping change here on the top of the dev branch and nothing else (+ looks like packages contains some related changes also)?
  • plus you can also move those #[api_version(2)] and pallet changes

@danielbui12 danielbui12 Jul 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@bkontur

  • this changes come along with new subxt bindings, I dont get your point how to split them?
  • "plus you can also move those #[api_version(2)] and pallet changes" not sure I get the new one. could you elaborate more?

Comment thread storage-subxt/Cargo.toml
Comment thread storage-subxt/src/lib.rs
Comment thread provider-node/src/subxt_client.rs
Comment thread provider-node/src/auth.rs
Comment thread storage-subxt/src/lib.rs Outdated
Comment thread client/src/admin.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration: subxt::dynamic → typed storage_subxt bindings Expose interfaces via a separate RuntimeApi

3 participants