Skip to content

refactor: extract challenge responder into provider-challenge (2) - #334

Open
danielbui12 wants to merge 1 commit into
provider_challenge_refactoringfrom
wire_provider_challenge_with_storage_subxt
Open

refactor: extract challenge responder into provider-challenge (2)#334
danielbui12 wants to merge 1 commit into
provider_challenge_refactoringfrom
wire_provider_challenge_with_storage_subxt

Conversation

@danielbui12

@danielbui12 danielbui12 commented Aug 4, 2026

Copy link
Copy Markdown
Member

Changes

Wire provider-challenge path to storage-subxt static bindings

- Read challenges through the StorageProviderApi::provider_challenges runtime
  API, which filters to this provider on-chain, replacing the dynamic
  Challenges map iteration and its hand-computed 62-byte key offsets
- Build respond_to_challenge as a static payload instead of scale_value trees,
  dropping the u128 widening casts the dynamic encoder relied on
- Return the response transaction's finalized block hash instead of a zero
  placeholder; None when success is inferred from a duplicate rejection, where
  the block is genuinely unknown
- Make submit_and_finalize, try_submit and submit_once generic over subxt's
  Payload trait so static and dynamic payloads share one retry path
- Validate every static address, removing the unvalidated() escapes so a
  runtime that has drifted from the tracked metadata fails at the call site
- Delete the fixed-offset Challenge SCALE decoder, its stale layout docs and
  the byte-level integration test that pinned them
- The deleted decoder documented a flat Challenge, but the pallet nests
  leaf_index and chunk_index under target: ChunkLocation; the offsets only
  still worked because SCALE structs are transparent
@danielbui12 danielbui12 self-assigned this Aug 4, 2026
let storage_address = storage_subxt::api::storage()
.storage_provider()
.challenges()
.unvalidated();

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.

IMO, it is better to make it thrown any errors at compile step, avoid unexpected bug since we maintain every crates

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.

1 participant