feat: migrate storage-client and provider-node to typed subxt bindings via storage-subxt#239
feat: migrate storage-client and provider-node to typed subxt bindings via storage-subxt#239danielbui12 wants to merge 37 commits into
Conversation
|
@danielbui12 please, make some TODO to check also using storage queries in TS SDK e.g.: 48d7560#diff-9c9ec00799f06105758439222211e7ef2fc782460416fb49c8234c3c1a8305efR174 |
I created an issue #243 |
|
/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
| use sp_core::H256; | ||
| use std::path::Path; | ||
| use std::sync::{Arc, Mutex}; | ||
| use storage_client::provider_node_request_scheme::*; |
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
I revert the provider-node migrations. keep only the subxt bidings-related changes
| accepting_extensions: true, | ||
| agreements_total: 3, | ||
| challenges_failed: 1, | ||
| settings: ProviderSettings { |
There was a problem hiding this comment.
- @danielbui12 please, replicate/extract just this wrapping change here on the top of the
devbranch and nothing else (+ looks likepackagescontains some related changes also)? - plus you can also move those
#[api_version(2)]andpalletchanges
There was a problem hiding this comment.
- 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?
Changes
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 workspacesubxt::dynamic::tx/storage/constantcalls with typedruntime::tx()/runtime::storage()/runtime::constants()buildersruntime_convert.rs: byte-exact conversion layer between domain types (AccountId32,H256,MultiSignature,AgreementTerms,Role,EndAction, proof structs) andgenerated runtime_types::*scale_valuedecoders with direct typed-struct field accessevent_subscription.rsto typedas_event::<ev::*>()decoding; deletedscale_decode.rssubxt/subxt-signerdeps fromclient/Cargo.toml; all imports now flow throughstorage_subxt::subxt/storage_subxt::subxt_signerprovider-nodeSubxtChainClientrewritten: holds aSubstrateClient(fromstorage_client) instead of rawOnlineClient+Keypair; all coordinator trait impls use typedstorage::*/extrinsics::*ChainMembershipResolverinauth.rsreplaced dynamic Buckets query + scale_value decoding with typedstorage::bucket_info()+rt::storage_primitives::Rolematchingclient/src/substrate.rs:extrinsics::update_provider_multiaddr,extrinsics::provider_checkpoint,storage::checkpoint_configIssue
RuntimeApi#237