Add storage-subxt crate with static codegen runtime bindings#282
Conversation
Introduce crates/storage-subxt, the first crate in the workspace using static subxt codegen (all other subxt consumers are dynamic OnlineClient). It ships generated bindings for the paseo runtime plus committed SCALE metadata, re-exports codec/scale-info/subxt/subxt-core/subxt-signer, and gates runtime selection behind a `mainnet` feature (mainnet artifacts are placeholders until a real mainnet runtime exists). - Workspace: add member, internal path dep, and subxt-core dependency - justfile: add `subxt-codegen` recipe that downloads metadata and regenerates bindings against a running node; metadata and generated code are written to separate files, and the SPDX header is prepended so regeneration keeps files license-compliant - License: crate is Apache-2.0 like sibling library crates, SPDX headers in all sources; generated bindings excluded from hawkeye enforcement
ilchu
left a comment
There was a problem hiding this comment.
Just one doubt about derives being maybe more than needed, but LGTM still.
| --derive-for-type "pallet_storage_provider::pallet::ProviderInfo=serde::Serialize" \ | ||
| --derive-for-type "pallet_storage_provider::pallet::ProviderInfo=serde::Deserialize" \ | ||
| --derive-for-type "pallet_storage_provider::pallet::ProviderSettings=serde::Serialize" \ | ||
| --derive-for-type "pallet_storage_provider::pallet::ProviderSettings=serde::Deserialize" \ | ||
| --derive-for-type "pallet_storage_provider::pallet::ProviderStats=serde::Serialize" \ | ||
| --derive-for-type "pallet_storage_provider::pallet::ProviderStats=serde::Deserialize" \ | ||
| --derive-for-type "bounded_collections::bounded_vec::BoundedVec=serde::Serialize" \ | ||
| --derive-for-type "bounded_collections::bounded_vec::BoundedVec=serde::Deserialize" \ | ||
| --derive-for-type "sp_runtime::MultiSignature=codec::Encode" \ | ||
| --derive-for-type "sp_runtime::MultiSignature=codec::Decode" \ |
There was a problem hiding this comment.
I understand all these are good-to-haves, but so far they're not really required by any consumers, right? And as long as we can avoid anything hand-enumerative, I'd rather do that.
There was a problem hiding this comment.
I would say yes, we do need. subxt codegen generates the runtime types with only a minimal set of derives.
As my experience in #239, when wiring subxt codegen with rust clients, I faced several errors like the trait X is not implemented for struct....
We could use subxt codegen ...--derive <Derive> to apply to all structs/types . but I prefer
--derive-for-type to scope them to only the types that actually need them.
There was a problem hiding this comment.
I am not fan of duplicating the info (this can go out-of-sync easily), can we just reference just subxt-codegen?
There was a problem hiding this comment.
I am not fan of duplicating the info (this can go out-of-sync easily), can we just reference
just subxt-codegen?
@danielbui12 what about this one?
| ] | ||
| excludes = [ | ||
| "**/*.bin.ts", | ||
| "crates/storage-subxt/**/*.rs", |
There was a problem hiding this comment.
why? shouldn't it be apache?
There was a problem hiding this comment.
it will be append in generate script
Lines 255 to 279 in d83397d
| // Mainnet metadata has not been generated yet. Re-exports paseo bindings so | ||
| // --all-features compiles. Replace with real generated bindings once the | ||
| // mainnet metadata file is available (generate like storage_paseo_runtime.rs). | ||
| pub use crate::storage_paseo_runtime::*; No newline at end of file |
There was a problem hiding this comment.
@danielbui12 I would remove mainnet stuff, no TODOs, ok, we could keep mainnet feature
There was a problem hiding this comment.
remove storage_mainnet_runtime.rs and all its relevant?
There was a problem hiding this comment.
remove storage_mainnet_runtime.rs and all its relevant?
yes, we won't have it for a long time and anyway, these subxt should be generated from the released WASM runtimes, we need some mechanism for comaptibility checking, so we don't need to regenerate and unless not necessary and provider can still work and so on, there is more to it:
#254
#259
I think we could probably merge this, but we will better see with your PR where we want to remove dynamic values to versioned runtime apis...
| @@ -0,0 +1 @@ | |||
| // TODO: resolve mainnet scale No newline at end of file | |||
There was a problem hiding this comment.
@danielbui12 why was this not removed? we discussed to remove all the mainnet stuff..
Regenerates crates/storage-subxt (added on dev in #282 with subxt-codegen 0.44) for subxt 0.50: subxt-core was discontinued at 0.44.3, so the bindings are regenerated with subxt-codegen 0.50.2 against the tracked metadata snapshot (default ::subxt crate path), the crate drops subxt-core and its no_std feature split (subxt 0.50 is std-only), and the justfile codegen recipe loses the --crate ::subxt_core flag.
Brings in the storage-subxt static bindings crate (#282) and converts this branch's new chain access to it as part of the resolution: - chain_events decodes ChallengeCreated / ReplicaAgreementEstablished / ProviderCheckpointSubmitted / BucketCheckpointed through the static event types instead of dynamic name + scale-value field lookups; a shape drift now surfaces as a logged decode failure (backstopped by the safety-net scans) instead of silent None lookups - fetch_challenge point-reads Challenges through the typed static address (unvalidated: bindings are generated from the paseo runtime and the local runtime shares the pallet), replacing the raw-offset decode on this path and picking up the ChunkLocation target shape - pre-existing dynamic call sites (subxt_client scans and tx payloads, chain-state reads, auth membership) are untouched: converting them is a repo-wide follow-up, not part of this branch Also folds the event fan-out tests into the coordinators test binary, reusing its shared helpers (test_state, wait_for, and the committed- chunk fixture now hosted in main.rs) instead of duplicating them in a separate integration target.
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 workspaceIssues