Skip to content

feat: expose platform bootstrap metadata in masternode responses - #14

Merged
PastaPastaPasta merged 1 commit into
masterfrom
feat/masternode-platform-metadata
Sep 9, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
feat/masternode-platform-metadata

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 8, 2026

Copy link
Copy Markdown
Member

The /masternodes response drops the Platform node ID and P2P port already present in Core's deterministic masternode list. Consumers such as Dashmate's release tooling therefore cannot construct Tenderdash seeds from the quorum server.

Preserve platformNodeID, platformP2PPort, and separately registered addresses alongside the existing fields. Add lastUpdated (Unix seconds) to successful masternode responses, publishing it atomically with the cached list. Reads and failed refreshes retain the original timestamp. The existing data array, legacy responses, and cache-only request handling remain compatible; configured host overrides also apply to the additional endpoints.

Validation: cargo build --locked, cargo test --locked (8 passing), and cargo clippy --locked --all-targets passed. Existing compiler/Clippy warnings remain. Tests cover DML field preservation, legacy entries, ban filtering, HTTP response compatibility, host overrides, and timestamp preservation after a failed refresh.

Supports the quorum-server source planned for dashpay/platform#4539. This change has not been deployed.

This pull request was created by Codex.

Summary by CodeRabbit

  • New Features

    • The /masternodes endpoint now includes an optional lastUpdated timestamp showing when cached data was last successfully refreshed.
    • Masternode responses can include platform identity, platform P2P port, and categorized service addresses when provided.
    • Host overrides are applied consistently to primary and alternate addresses.
    • Missing platform details remain omitted rather than being inferred.
  • Documentation

    • Added endpoint documentation, response examples, freshness guidance, and compatibility notes for existing clients.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: ab98689c-46ff-422e-bd34-67e6a30d4e9b

📥 Commits

Reviewing files that changed from the base of the PR and between ea71a8b and 63e1ec8.

📒 Files selected for processing (4)
  • README.md
  • src/api.rs
  • src/masternode.rs
  • src/masternode_cache.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds optional masternode platform address fields and an atomic cache snapshot with refresh metadata. The /masternodes endpoint returns lastUpdated, applies host overrides, and documents the response contract.

Changes

Masternode metadata and cache freshness

Layer / File(s) Summary
Masternode data shape and conversion
src/masternode.rs
Masternode types preserve optional address categories, platform identity, and platform ports. Conversion tests cover legacy fields and banned status.
Atomic snapshot cache
src/masternode_cache.rs
The cache stores masternodes with a Unix refresh timestamp in one snapshot. Tests cover successful refreshes, failed refreshes, host overrides, and empty-cache behavior.
API response and endpoint documentation
src/api.rs, README.md
The endpoint returns optional lastUpdated, applies host overrides to primary and nested addresses, and documents platform endpoint fields and cache semantics.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 63e1e

The masternodes response adds optional bootstrap metadata and cache freshness while retaining existing response compatibility. No concrete current-head merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant get_masternodes
  participant MasternodeCache
  Client->>get_masternodes: request /masternodes
  get_masternodes->>MasternodeCache: get_snapshot()
  MasternodeCache-->>get_masternodes: cached list and last_updated
  get_masternodes->>get_masternodes: apply host overrides
  get_masternodes-->>Client: data and optional lastUpdated
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 3 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: exposing platform bootstrap metadata in masternode responses.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 47.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/masternode-platform-metadata

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution failed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Sep 9, 2026

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit 63e1ec8) · triage: normal · Phase 2 only (queue backlog)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 2 only (queue backlog)

Verified the supplied Phase-2 evidence against head 63e1ec8 and confirmed one non-blocking test-coverage suggestion; no blocking defects were identified. The successful refresh publication path is not exercised by the tests, although the implementation publishes metadata and freshness together and preserves the snapshot after failed refreshes. Independent locked, offline build, all 8 tests, and Clippy passed with warnings; formatting validation failed.

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

Review provenance

  • Triage: normal by gpt-6-astra (effort low) — The change is contained to API metadata serialization, endpoint host overrides, and atomic in-memory cache timestamps, with compatibility and refresh-failure risks but no changes to consensus, cryptography, persistent storage, or network connection behavior.
  • Phase 1 reviewers: not run (skipped for throughput: 42 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-reviewer

🟡 1 suggestion(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/masternode_cache.rs`:
- [SUGGESTION] src/masternode_cache.rs:275-283: Exercise successful snapshot publication through refresh()
  Both populated-cache tests seed cache.data directly with a fabricated MasternodeSnapshot. The only test call to refresh() uses an invalid RPC URL and exits before successful publication, so the tests would still pass if update_cache_internal() stopped publishing snapshots or published an incorrect timestamp. Add a successful-refresh test using a local JSON-RPC fixture with POSE_BANNED entries to avoid outbound gRPC probes. Assert that refresh() replaces an older snapshot with the returned metadata and a timestamp bounded by the refresh call, then make a subsequent refresh fail and verify that the successfully published list and timestamp remain unchanged. This covers the production state transition behind the new lastUpdated contract rather than only serialization and reads of manually seeded data.

Comment thread src/masternode_cache.rs
Comment on lines +275 to +283
async fn should_serve_fields_and_original_refresh_time_without_rpc() {
let mut config = Config::default();
// Even an accidentally attempted RPC cannot reach the network.
config.rpc.url = "not a URL".into();
let cache = Arc::new(MasternodeCache::new(config.clone()));
*cache.data.write().unwrap() = Some(snapshot());
let first = response(config.clone(), cache.clone(), "/masternodes").await;
assert_eq!(first["success"], true);
assert_eq!(first["lastUpdated"], 1234567890);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Exercise successful snapshot publication through refresh()

Both populated-cache tests seed cache.data directly with a fabricated MasternodeSnapshot. The only test call to refresh() uses an invalid RPC URL and exits before successful publication, so the tests would still pass if update_cache_internal() stopped publishing snapshots or published an incorrect timestamp. Add a successful-refresh test using a local JSON-RPC fixture with POSE_BANNED entries to avoid outbound gRPC probes. Assert that refresh() replaces an older snapshot with the returned metadata and a timestamp bounded by the refresh call, then make a subsequent refresh fail and verify that the successfully published list and timestamp remain unchanged. This covers the production state transition behind the new lastUpdated contract rather than only serialization and reads of manually seeded data.

source: ['claude']

@ktechmidas ktechmidas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PastaPastaPasta
PastaPastaPasta merged commit 241b288 into master Sep 9, 2026
1 check passed
@PastaPastaPasta
PastaPastaPasta deleted the feat/masternode-platform-metadata branch September 9, 2026 01:33
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