Skip to content

Boostrap app structure - #2

Closed
lucasbalieiro wants to merge 5 commits into
stratum-mining:mainfrom
lucasbalieiro:boostrap-app-structure
Closed

Boostrap app structure#2
lucasbalieiro wants to merge 5 commits into
stratum-mining:mainfrom
lucasbalieiro:boostrap-app-structure

Conversation

@lucasbalieiro

@lucasbalieiro lucasbalieiro commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

closes #1

this PR bootstraps the app and establishes the initial structure that future compliance scenarios will follow.

I know this is a larger-than-usual PR because it lays down the initial infrastructure. At this stage, I'm mainly looking for feedback on the overall architecture and project structure, so there's no need to spend too much time reviewing implementation details.

The goal is to establish a framework that makes adding new scenarios straightforward, without requiring changes to the execution framework. The SetupConnection scenario included in this PR serves as the reference implementation for future scenarios.

Currently, the application can connect to SV2 endpoints (Pools and Job Declarator Servers), execute protocol compliance scenarios, and report pass/fail results. Scenarios can be run against a single endpoint or against multiple deployments defined in a TOML configuration file.

What's included

  • A library plus a CLI (src/bin/sv2_compliance.rs) for running compliance scenarios against individual endpoints or batches of deployments.

  • A generic scenario framework (src/scenario.rs) built around AppType and Scenario.

  • The first compliance scenario (src/setup_connection/), organized as the template for future scenarios.

  • TOML-based batch execution (src/config.rs and src/runner.rs).

  • GitHub Actions CI running:

    • cargo test --all-targets
    • cargo clippy --all-targets -- -D warnings
    • cargo fmt --all -- --check (nightly)

Adding new scenarios

Adding a new scenario should only require:

  1. Creating src/<scenario>/ with a run(endpoint, app_type) entrypoint.
  2. Registering it in src/bin/sv2_compliance.rs with Scenario::new(...).

Once registered, it automatically works with both single-endpoint and TOML-based batch execution, and can be filtered with --scenario.

Introduces the core framework and the first scenario for testing SV2
endpoints:

- scenario.rs: AppType (pool, job-declarator-server, template-provider),
  TestResult, and Scenario abstraction
- setup_connection: happy-path and error-case SetupConnection handshakes,
  with AppType-derived protocols and flags (e.g. DECLARE_TX_DATA for JDS)
- sv2-compliance CLI: test a single endpoint via --endpoint/--app-type,
  with optional --scenario filter and -v logging
- integration tests against a local pool and JDS
Adds the ability to run scenarios against multiple endpoints from a
single config file:

- config.rs: Config/Site model with optional pool_address and
  jds_address, parsed from a TOML file
- runner.rs: builds targets from the config and runs scenarios against
  each, printing a per-site summary
- CLI: --config conflicts with --endpoint and drives batch mode
- targets.example.toml: sample config with pool and JDS sites
- integration tests covering config parsing and batch runs
The repository rustfmt.toml uses unstable options (imports_granularity,
imports_layout, etc.), so formatting is applied with nightly rustfmt to
match the intended style.
- test: installs capnp + libcapnp-dev, caches cargo and the unpacked
  Bitcoin Core under template-provider/, runs cargo test --all-targets
- fmt: rustfmt --check on nightly to honor the unstable options in
  rustfmt.toml
- clippy: -D warnings over all targets
Comment thread .github/workflows/ci.yaml
@lucasbalieiro
lucasbalieiro marked this pull request as ready for review August 4, 2026 03:12
@plebhash

plebhash commented Aug 4, 2026

Copy link
Copy Markdown
Member

I'm still exploring things at a very superficial level... just manually trying to run and see what happens

I launched a local SRI Pool and ran:

cargo run -- --endpoint 0.0.0.0:3333 --app-type pool
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.22s
     Running `target/debug/sv2-compliance --endpoint '0.0.0.0:3333' --app-type pool`
Running 1 scenario(s) against 1 target(s)

  ── 0.0.0.0:3333 ──
     testing Pool endpoint at 0.0.0.0:3333
    ── SetupConnection ──
       Happy-path and error-case SetupConnection handshakes
      ✓ SetupConnection (MiningProtocol) (version=2)
      ✓ SetupConnection (TemplateDistributionProtocol) expects rejection
      ✓ SetupConnection (JobDeclarationProtocol) expects rejection


✓ 3/3 tests passed across 1 target(s)

all good


but then I killed SRI Pool and tried to run again:

cargo run -- --endpoint 0.0.0.0:3333 --app-type pool
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.27s
     Running `target/debug/sv2-compliance --endpoint '0.0.0.0:3333' --app-type pool`
Running 1 scenario(s) against 1 target(s)

  ── 0.0.0.0:3333 ──
     testing Pool endpoint at 0.0.0.0:3333
    ── SetupConnection ──
       Happy-path and error-case SetupConnection handshakes

thread 'main' panicked at /home/plebhash/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/integration_tests_sv2-0.4.0/lib/sniffer.rs:190:17:
timeout while waiting for message SetupConnection to go upstream
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
^C^C^C^C^C

a few observations:

  • it took a really long time for the panic (probably ~60s which IIRC is default timeout for integration_tests_sv2::Sniffer)
  • process is frozen, I cannot kill it with Ctrl+C

@plebhash

plebhash commented Aug 6, 2026

Copy link
Copy Markdown
Member

@lucasbalieiro I spent a few hours for the past few days trying to create a mental model of where this is going

overall it seems to be in an interesting direction

I had a few things I was going to point out on the code diff, but then I decided to ask Kimi K3 (IMHO the best frontier-model available today) to address #1 and see how much it would differ from the direction we're going here

for many pre-requisites, it ended up taking an approach that's very similar to what we have here... which is a solid indicator that there's not too much ambiguity in the design space, and we were already going in the right direction here

but for some other things, it took a different approach... I took time to review those divergences and I feel they're worth consideration (especially encapsulation)

so I'm creating #3 as an alternative to this so we can compare trade-offs

@lucasbalieiro

Copy link
Copy Markdown
Collaborator Author

closing this in favor #3

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.

bootstrap interoparability_tests_sv2 crate

3 participants