Skip to content

refactor(provider-node): extract chain traits for testability and harden CI#145

Merged
mudigal merged 11 commits into
devfrom
refactor/provider-node-trait-extraction
Jun 10, 2026
Merged

refactor(provider-node): extract chain traits for testability and harden CI#145
mudigal merged 11 commits into
devfrom
refactor/provider-node-trait-extraction

Conversation

@mudigal

@mudigal mudigal commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

#144

Split from #139 (PR 1 of 4).

  • Trait extraction: Extract chain interaction traits from 4 coordinators (agreement, challenge, checkpoint, replica-sync) so each can be tested with mock chain clients. Move Subxt implementations to dedicated _subxt.rs files.
  • Unified error type: Add ProviderError in error.rs, make sign() fallible across API handlers.
  • Testability: Add helpers to fs_index.rs and s3_index.rs for test construction.
  • CI hardening: Combine 3 pallet coverage jobs into one with glob discovery, add validation guards, fix integration test flakiness, fix //Bob nonce issue in S3 CI test.

PR stack

# PR Base Description
1 This PR dev Refactor + CI
2 #146 dev Pallet tests (independent)
3 #147 This PR HTTP integration tests
4 #148 #147 Coordinator + FS tests

Test plan

  • SKIP_WASM_BUILD=1 cargo clippy -p storage-provider-node --all-targets passes
  • CI check workflow passes
  • No test files included — tests come in PRs 3 and 4

…den CI

Extract chain interaction traits from 4 coordinators (agreement, challenge,
checkpoint, replica-sync) so each can be tested with mock chain clients.
Move Subxt implementations to dedicated `_subxt.rs` files.

- Add unified `ProviderError` type in `error.rs`
- Wire `Box<dyn Trait>` in `command.rs` startup
- Make `sign()` fallible across API handlers
- Add testability helpers to `fs_index.rs` and `s3_index.rs`
- CI: combine 3 pallet coverage jobs, glob discovery, validation guards
- CI: fix integration test flakiness
- Fix `//Bob` nonce issue in S3 CI integration test
Comment thread storage-interfaces/s3/client/examples/ci_integration_test.rs
Comment thread provider-node/Cargo.toml Outdated
Comment thread provider-node/src/challenge_responder_subxt.rs Outdated
Comment thread provider-node/src/agreement_coordinator.rs Outdated
Comment thread provider-node/src/agreement_coordinator.rs Outdated
mudigal and others added 4 commits June 9, 2026 13:06
…emove tempfile from PR 1

Replace manual `Pin<Box<dyn Future>>` return types with `#[async_trait]`
across all 4 coordinator chain-client traits and their subxt impls:
- AgreementChainClient
- ChallengeChainClient
- CheckpointChainClient
- ReplicaSyncChainClient

This preserves object safety (still `Box<dyn Trait>`) while making the
code cleaner and easier to implement mock versions in tests.

Also removes `tempfile` dev-dependency (unused in this PR; belongs in PR 3).
…struction

Replace verbose Value::named_composite/unnamed_variant calls with the
scale_value::value! macro across all _subxt.rs files. Also shorten
fully-qualified subxt::dynamic::Value:: paths with a use import.
…paritytech/web3-storage into refactor/provider-node-trait-extraction
@mudigal mudigal enabled auto-merge (squash) June 9, 2026 15:06
mudigal and others added 5 commits June 10, 2026 11:18
Each coordinator trait now has an `impl<T: Trait> Trait for Arc<T>` that
delegates to the inner value, eliminating the need for SharedMock newtype
wrappers in tests.
…paritytech/web3-storage into refactor/provider-node-trait-extraction
The merge from dev incorrectly removed the "Resolve chain-spec script"
step and left a reference to matrix.runtime.chain_spec_script which
doesn't exist in this job (no matrix strategy). Restore the env var
approach that reads from runtimes-matrix.json.
@mudigal mudigal merged commit 05715c0 into dev Jun 10, 2026
35 of 37 checks passed
@mudigal mudigal deleted the refactor/provider-node-trait-extraction branch June 10, 2026 13:02

@franciscoaguirre franciscoaguirre left a comment

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.

What do you think about having the same struct implement all the different chain client traits? Would it reuse connections?

-p pallet-storage-provider \
-p pallet-drive-registry \
-p pallet-s3-registry \
--ignore-filename-regex='(weights\.rs|runtime_api\.rs|mock\.rs|primitives/|benchmarking\.rs|bechmarking\.rs)' \

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.

bechmarking.rs?

-p storage-provider-node \
--ignore-filename-regex='(\.cargo|rustc|_subxt\.rs|command\.rs|cli\.rs|main\.rs)' \
--summary-only 2>&1 \
| grep '^TOTAL' | awk '{print $10}' | tr -d '%')

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 know it's unlikely to cause any issues, but can we add --json and use jq to extract the percentage. That way we need to fiddle less with text and it's easier to read

}

#[async_trait::async_trait]
impl CheckpointChainClient for SubxtCheckpointChainClient {

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.

Feels like all these different traits could be implemented by the same struct to reuse the subxt api and signer. We can still keep the impls in different files

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.

3 participants