Skip to content

[codex] Fix wallet network info fallback#7496

Open
q36zhd46w17o wants to merge 2 commits into
Scottcjn:mainfrom
q36zhd46w17o:codex/rust-wallet-network-info-fallback
Open

[codex] Fix wallet network info fallback#7496
q36zhd46w17o wants to merge 2 commits into
Scottcjn:mainfrom
q36zhd46w17o:codex/rust-wallet-network-info-fallback

Conversation

@q36zhd46w17o

Copy link
Copy Markdown
Contributor

Summary

  • keep /network/info as the primary Rust wallet network metadata endpoint
  • fall back to currently deployed JSON routes when that endpoint returns HTML 404 or other non-success responses
  • add regression tests for the primary endpoint, /api/stats + /epoch, and the deployed /health + /epoch fallback path

Why

https://rustchain.org/network/info currently returns nginx HTML 404, so the Rust wallet client cannot parse the network metadata expected by rtc-wallet network. A previous server/proxy PR for this issue was closed; this PR uses a different client-side strategy that works against the public routes deployed today.

Validation

  • curl -sk -D - https://rustchain.org/network/info | head -80 observed HTTP/2 404 with text/html on 2026-06-17 UTC
  • cargo fmt --manifest-path rustchain-wallet/Cargo.toml --check
  • cargo test --manifest-path rustchain-wallet/Cargo.toml client::tests::test_get_network_info -- --nocapture
  • cargo test --manifest-path rustchain-wallet/Cargo.toml
  • cargo run --release --manifest-path rustchain-wallet/Cargo.toml -- network --rpc https://rustchain.org

Release command output included:

Network Information:
  Chain ID:      rustchain-mainnet-v2
  Network:       mainnet
  Block Height:  28356
  Peers:         28
  Min Fee:       1000 RTC
  Version:       2.2.1-rip200

Note: debug cargo run is blocked before command execution by a pre-existing clap debug assertion in the send subcommand (-f is assigned to both from and fee), so the live command validation used the release binary.

Bounty

Fixes #7094.
RTC payout address: RTCde409a83a31e54f946144390eaeb9964a444d2e6

This is a small bug-fix contribution under the RustChain RTC bounty/contributor payment rules (Micro / merged PR category).

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines labels Jun 17, 2026
@q36zhd46w17o

Copy link
Copy Markdown
Contributor Author

CI boundary note for this PR:

The Rust wallet-focused checks are passing so far:

  • Rustfmt
  • Clippy
  • Test (ubuntu-latest)
  • Test (macos-latest)
  • Test (windows-latest)
  • Documentation
  • Security Audit
  • Build (ubuntu-latest)
  • Build (macos-latest)

The top-level Python test job is red on an existing unrelated OTC bridge test outside this PR's files:

tests/test_otc_bridge_htlc_preimage.py::test_buy_order_defers_htlc_secret_to_matching_seller
assert False is True

This PR only changes rustchain-wallet/src/client.rs and the local wallet crate validation passed (cargo test --manifest-path rustchain-wallet/Cargo.toml). Windows build was still in progress when I posted this note.

@jaxint jaxint 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.

Review

@jaxint jaxint 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.

Reviewed and approved.

Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

@jaxint jaxint 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.

Reviewed and approved.

Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

@jaxint jaxint 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.

Great work on this PR! The implementation looks solid. Thanks for contributing to RustChain.

@jaxint jaxint 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.

Outstanding contribution! The code quality is excellent. Keep up the great work!

@BossChaos BossChaos 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.

Code Review — Clean, well-documented PR with appropriate test coverage. Aligns with BCOS-L1 standards.

✅ Bounty claim: Code Review Bounty #73 | Wallet: RTC6d1f27d28961279f1034d9561c2403697eb55602

@jaxint

jaxint commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Technical Review - Wallet Network Info Fallback Fix

Thank you for this robustness improvement.

Analysis

Problem: Wallet network info fallback not working correctly, leading to:

  • Missing network information in wallet displays
  • Incorrect network detection
  • User confusion about wallet configuration

Fix: Implements proper fallback mechanism for wallet network info:

  • Primary source checked first
  • Fallback to alternative sources
  • Graceful degradation when all sources fail

Implementation Quality

✓ BCOS-L1 label (blockchain consensus layer)
✓ size/M (medium effort)
✓ Test coverage included

Fallback Strategy

Recommended fallback chain:

Primary Source → Secondary Source → Default/Cache → Error

Recommendations

  1. Logging: Add structured logging for fallback triggers
  2. Metrics: Track fallback success rates
  3. Documentation: Document fallback order in API docs

Bounty Claim: Technical review with fallback strategy analysis.

Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

@jaxint jaxint 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.

PR Review Summary

PR #7496: [codex] Fix wallet network info fallback

Changes Overview

  • Files changed: ~N/A
  • Lines: +196 -3

Code Quality Assessment

✅ Code appears well-structured
✅ Changes align with stated purpose
✅ No obvious security issues detected

Suggestions

  • Consider adding/updating tests if applicable
  • Ensure documentation is updated for user-facing changes

Review submitted by @jaxint via RustChain bounty program
Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

@jaxint jaxint 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.

PR Review

Overall Assessment: ✅ Approved

This PR implements [codex] Fix wallet network info fallback.

Key observations:

  • Changes are focused and well-scoped
  • Code follows project conventions
  • Implementation addresses the stated issue

Recommendation: Merge pending CI checks.


Reviewed by @jaxint for RustChain bounty #71 (PR review bounty program).

@jaxint jaxint 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.

Thanks for this PR! The changes look good. Please ensure all tests pass before merging.

@jaxint jaxint 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.

Nice work! The code quality is good and the approach is sound.

@jaxint jaxint 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.

PR Review

Overall Assessment: ✅ Approved

This PR implements changes for [codex] Fix wallet network info fallback.

Key observations:

  • Changes are focused and well-scoped
  • Code follows project conventions
  • Implementation addresses the stated issue

Recommendation: Merge pending CI checks.


Reviewed by @jaxint for RustChain bounty #71 (PR review bounty program).

@jaxint jaxint 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.

PR Review

Overall Assessment: ✅ Approved

This PR implements [codex] Fix wallet network info fallback by @q36zhd46w17o.

Key observations:

  • Changes are focused and well-scoped
  • Code follows project conventions
  • Implementation addresses the stated goal

Recommendation: Merge pending CI checks.


Reviewed by @jaxint for RustChain bounty #71 (PR review bounty program).

@jaxint jaxint 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.

Nice work on this PR! The implementation looks solid. ✅

@jaxint jaxint 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.

PR Review

Overall Assessment: ✅ Approved

This PR implements [codex] Fix wallet network info fallback.

Key observations:

  • Changes are focused and well-scoped
  • Code follows project conventions
  • Implementation addresses the stated issue

Recommendation: Merge pending CI checks.


Reviewed by @jaxint for RustChain bounty #71 (PR review bounty program).

@jaxint jaxint 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.

PR Review

Overall Assessment: ✅ Approved

This PR implements [codex] Fix wallet network info fallback.

Key observations:

  • Changes are focused and well-scoped
  • Code follows project conventions
  • Implementation addresses the stated issue

Recommendation: Merge pending CI checks.


Reviewed by @jaxint for RustChain bounty #71 (PR review bounty program).

@jaxint

jaxint commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Good PR! The implementation addresses the issue effectively. Clean diff! 🔧

@daviediao-code

Copy link
Copy Markdown

Practical fix for wallet network info fallback.

Review:

  • Network info fallback improves reliability in degraded states
  • Clean implementation without breaking existing flows

Approved ✅

@jaxint jaxint 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.

PR Review

Overall Assessment: Approved

This PR implements: [codex] Fix wallet network info fallback

Key observations:

  • Changes are focused and well-scoped
  • Code follows project conventions
  • Implementation addresses the stated issue

Recommendation: Merge pending CI checks.


Reviewed by @jaxint for RustChain bounty #71 (PR review bounty program).
Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

@jaxint

jaxint commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Comment:

Excellent work! The refactoring makes the code more maintainable.

Automated review submitted for bounty #71

@jaxint

jaxint commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for addressing this issue. Code looks good!

@jaxint jaxint 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.

Thanks for this PR! The changes look well-structured and follow the project conventions.

Key observations:

  • The implementation aligns with the codebase architecture
  • Error handling appears comprehensive
  • Documentation is clear and concise

Suggestions for consideration:

  • Consider adding unit tests for edge cases
  • Verify backward compatibility with existing integrations
  • Check for any potential performance implications

Overall, this is a solid contribution. Ready for maintainer review.

@jaxint

jaxint commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

PR Review

Thank you for this contribution! I've reviewed the changes and here's my assessment:

Code Quality

  • ✅ Code structure is clean and follows project conventions
  • ✅ Error handling appears comprehensive
  • ✅ Changes align with the project's architecture

Testing

  • ✅ Existing tests should cover the affected areas
  • Consider adding unit tests for edge cases if applicable

Documentation

  • Consider updating related documentation if this affects user-facing behavior

Overall: This looks good to merge. Nice work! 🎉


Reviewed as part of RustChain bounty program (#71)

@jaxint jaxint 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.

Thanks for this PR! The changes look good. The implementation follows the project conventions and the code is well-structured.

A few suggestions:

  • Consider adding tests for the new functionality
  • Update documentation if applicable
  • Ensure CI passes before merge

Overall, this is a solid contribution. Keep up the great work!

@FakerHideInBush FakerHideInBush 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.

Head SHA: 668e8d7

The three-tier fallback is a good approach for nodes with partial endpoint availability, and the get_json<T> helper cleans up the repetition nicely. Three correctness issues before merge:

1. min_fee hardcoded to 1000 in both fallback paths

min_fee: 1000,   // in get_network_info_from_stats
min_fee: 1000,   // in get_network_info_from_health_epoch

The primary /network/info endpoint returns the real minimum fee. Both fallback paths substitute a hardcoded constant instead. If the chain governance changes min_fee (e.g., to 500 or 2000), callers using the fallback path will silently compute incorrect fees — which could cause transaction rejections or overpayment. Since /network/info is the only known source for min_fee, either the fallback should explicitly document this limitation (// min_fee unknown via this path; callers should treat this as a lower bound) or the NetworkInfo struct should expose an Option<u64> for min_fee so callers can detect when the value is unavailable.

2. /epoch is called twice when /api/stats succeeds but /epoch fails

get_network_info_from_stats makes two sequential requests: /api/stats then /epoch. If /api/stats succeeds and /epoch fails, get_network_info_from_stats returns Err, and the outer fallback immediately calls get_network_info_from_health_epoch, which also calls /epoch. Result: 4 HTTP round trips total (/network/info, /api/stats, /epoch, /health, /epoch) all fail, and the caller sees the combined error message without knowing that /api/stats was actually healthy.

This scenario is not covered by the test suite — all three tests have /api/stats and /epoch either both succeed or the entire /api/stats leg fails immediately. A test where /api/stats returns 200 but /epoch returns 503 would expose the double-call and confirm the error message correctly attributes the root cause.

3. peer_count silently conflates total_miners and enrolled_miners

peer_count: stats.total_miners.unwrap_or(epoch.enrolled_miners),

total_miners from /api/stats is the count of all registered miners on the network. enrolled_miners from /epoch is the count of miners enrolled in the current epoch — a subset, often far smaller. Using enrolled_miners as a fallback for peer_count reports a different metric without any indication to the caller. If total_miners is absent from the stats response, callers expecting peer_count to mean "total registered peers" will silently receive the epoch-enrollment count instead. At minimum, document this substitution with a comment; ideally, expose both values separately in NetworkInfo.

@jaxint jaxint 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.

Well done! The performance improvements are noticeable.

@jaxint jaxint 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.

Reviewed for bounty #71. LGTM - the changes look good and follow proper conventions.

@jaxint jaxint 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.

PR Review

Overall Assessment: ✅ Approved

This PR implements [codex] Fix wallet network info fallback.

Key observations:

  • Changes are focused and well-scoped
  • Code follows project conventions
  • Implementation addresses the stated issue

Recommendation: Merge pending CI checks.


Reviewed by @jaxint for RustChain bounty #71 (PR review bounty program).

@jaxint jaxint 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.

Code Review

Thank you for this contribution.

General Assessment:

  • Code changes are clear and well-structured
  • Implementation follows project conventions
  • Testing appears adequate

Suggestions:

  • Consider adding inline comments for complex logic
  • Verify edge case handling
  • Update documentation if needed

Overall, this looks good to merge. Great work! 🚀

@jaxint jaxint 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.

Looks good to me! Ready for merge.

@jaxint jaxint 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.

Review Summary

This PR looks good! Changes are well-structured and follow project conventions.

Key Observations:

  • Code changes align with stated objectives
  • No obvious security or performance concerns
  • Implementation follows best practices

Recommendation: Ready for merge after addressing any CI feedback.

Thank you for this contribution!

@Scottcjn

Copy link
Copy Markdown
Owner

Security review flagged a few should-fix items on the wallet network-info fallback (the review hit a partial timeout, so worth a careful re-read). Please double-check the fallback path doesn't mask a real error or return stale/incorrect network state, and add a test for the fallback branch. Re-ping me when ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust wallet network command hits HTML 404 from /network/info

6 participants