Skip to content

feat: add rustchain_epoch, rustchain_hall_of_fame, rustchain_bounties read tools (#1 task 1) - #2

Closed
Vyacheslav-Tomashevskiy wants to merge 3 commits into
Scottcjn:mainfrom
Vyacheslav-Tomashevskiy:feat-more-read-tools
Closed

feat: add rustchain_epoch, rustchain_hall_of_fame, rustchain_bounties read tools (#1 task 1)#2
Vyacheslav-Tomashevskiy wants to merge 3 commits into
Scottcjn:mainfrom
Vyacheslav-Tomashevskiy:feat-more-read-tools

Conversation

@Vyacheslav-Tomashevskiy

Copy link
Copy Markdown
Contributor

Implements Task 1 — "More read tools" from #1: three new read-only, keyless LangChain tools, following the exact pattern of the existing four (client method → framework-free summarize_*BaseTool wrapper), with tests.

New tools

Tool Source surface Answers
rustchain_epoch GET /epoch current epoch/slot, blocks per epoch, enrolled miners, epoch pot, total supply
rustchain_hall_of_fame GET /hall/leaderboard oldest / most-attested machines ranked by rust score (device model, year, badge)
rustchain_bounties open bounty-labelled GitHub issues open RTC bounties, sorted by reward

rustchain_bounties reads the same canonical source the official bounty-concierge aggregator uses — open issues labelled bounty on Scottcjn/rustchain-bounties via the public, unauthenticated GitHub issues API — and parses the RTC reward from each title (reusing concierge's reward regex; a "50-200 RTC" range reports the upper bound, and RTC… wallet addresses are not mistaken for rewards).

Contract honoured

  • Read-only / keyless — no wallet writes, no secrets. New endpoints are the same public surfaces a browser can hit; bounties() uses the unauthenticated GitHub API.
  • Never raises inside an agent loop — wrappers keep the existing try/except → "RustChain query failed (...)" behaviour; summarizers tolerate bare lists / empty / malformed payloads.
  • Each tool returns a compact agent-friendly summary, not a raw JSON blob.

Tests & verification

  • pytest -q green (14 tests; added coverage for all three summarizers, the reward parser incl. ranges + wallet-address rejection, PR filtering, and the bounties client URL/params).
  • Smoke-tested live against rustchain.org and the GitHub API — sample output:
    • RustChain is in epoch 195 (slot 28190, 144 blocks/epoch). 24 miner(s) enrolled, epoch pot 1.5 RTC, total supply 8388608 RTC.
    • #1 PowerPC 7450 (G4) @ 733MHz, 2001 — rust_score 1178.45, 868457 attestations [Oxidized Legend]
    • 100 open RustChain bounties (~… RTC across those with a stated reward). Top: …

README tool table updated and version bumped 0.1.0 → 0.2.0. Scoped to Task 1 only — happy to follow up with the async client (Task 2) or demo (Task 3).

@Vyacheslav-Tomashevskiy

Copy link
Copy Markdown
Contributor Author

Heads-up: this is now supersededrustchain_epoch and rustchain_bounties landed via #3074 (the v0.2.0 merge), so this branch conflicts and largely duplicates them. The only piece here not in main is rustchain_hall_of_fame (oldest / most-attested machines via /hall/leaderboard). Happy to rebase it down to just that one tool if it's wanted; otherwise feel free to close this. I've moved on to the still-open tasks (async client #3, provenance #4).

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

Code Review - RustChain Tools Implementation

Feature Implementation Review

This PR adds multiple RustChain tools: rustchain_epoch, rustchain_hall_of_fame, and more.

Key Changes Reviewed:

  • Multiple tool implementations
  • Good code structure
  • Comprehensive functionality

Recommendation: ✅ Approved

Great contribution!


Reviewed by @jaxint
Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

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

PR Review Summary

Thank you for this contribution to the RustChain ecosystem!

Quick Review

  • ✅ PR title is clear and descriptive
  • ✅ Changes align with project goals
  • ✅ Appreciate the effort in improving the codebase

Wallet for RTC Reward

AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG


Automated review by RustChain bounty hunter

@Scottcjn

Copy link
Copy Markdown
Owner

Thanks for this stack, @Vyacheslav-Tomashevskiy — the LangChain-RustChain direction is genuinely valuable and the provenance tool (#4) is nicely done. Before we can merge #2#3#4, a consolidated review (Codex + Grok pass) surfaced a few blockers that span the stack. Grouping them here since they're interdependent:

Blocking

  1. Broken documented async install path (feat: async client + async tool variants (AsyncRustChainClient) — #1 Task 2 #3): the README says pip install "...[async]" then get_async_rustchain_tools(), but the async extra only pulls httpx. The async tools still import langchain_core + pydantic, so the documented path fails unless the langchain extra is also installed. → Make the async extra include the LangChain deps (or document that both extras are required).
  2. Bounty contract diverges across the stackRustChainClient.bounties / summarize_bounties and the async bounties() return different shapes between feat: add rustchain_epoch, rustchain_hall_of_fame, rustchain_bounties read tools (#1 task 1) #2, feat: async client + async tool variants (AsyncRustChainClient) — #1 Task 2 #3, feat: add rustchain_provenance — RIP-0310 Proof-of-Provenance read tool (#1 Task 5) #4. → Pin one canonical bounty shape and have sync + async + summarizer all conform (the README promises sync/async parity).

Should-fix
3. Reward-parsing regression (#3 async path): it doesn't filter label:bounty and uses an integer-only body regex, so title rewards like [BOUNTY: 50 RTC] and decimal amounts get misreported as see issue. → Match the safer canonical parser (filter label:bounty, parse title + decimals).
4. Tests catch broad Exception and return (#3 tests/test_tools.py) — that silently passes on real failures, not just missing optional deps. → Narrow to ImportError/ModuleNotFoundError so the async surface is actually covered.
5. Minor: confirm the merged __init__.py __all__ still exports AsyncRustChainClient / get_async_rustchain_tools (the #4 snippet omits them).

Once 1–2 are fixed (and ideally 3–4), this is mergeable in order. Re #5-vs-#6 (the "how big is RustChain" demo) — they're duplicates; we'll keep one (#5, the create_react_agent version) once the stack lands. Appreciate the work — happy to re-review as soon as the async packaging + bounty shape are sorted.

Vyacheslav-Tomashevskiy pushed a commit to Vyacheslav-Tomashevskiy/langchain-rustchain that referenced this pull request Jun 21, 2026
…ps, safer parser

Addresses the consolidated Codex+Grok review on Scottcjn#2 (blocks Scottcjn#2 -> Scottcjn#3 -> Scottcjn#4):

1. (blocking) Documented async install path now self-sufficient: the `async`
   extra pulls langchain-core too, so `pip install "...[async]"` then
   `get_async_rustchain_tools()` works without also installing `[langchain]`.
   README updated to match.
2. (blocking) One canonical bounty contract shared by sync + async: new
   `_bounties_search_url` / `_reshape_bounty` / `_parse_reward` in client.py;
   both `RustChainClient.bounties` and `AsyncRustChainClient.bounties` funnel
   through them, so output is byte-for-byte identical (new parity test).
3. (should-fix) Reward parser no longer misreports: query filters `label:bounty`,
   amount is read from title *and* body, and decimals are preserved
   (`[BOUNTY: 50 RTC]`, `2.5 RTC`) instead of falling back to "see issue".
4. (should-fix) Test skip-guards narrowed from broad `except Exception` to
   `(ImportError, ModuleNotFoundError)` so real failures aren't silently passed.
5. Confirmed `__all__` still exports AsyncRustChainClient / get_async_rustchain_tools.

All 25 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Vyacheslav-Tomashevskiy

Vyacheslav-Tomashevskiy commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the consolidated review over in #3 (commit on feat-async-client):

  • the async extra now pulls langchain-core (documented install path is self-sufficient),
  • one canonical bounty contract shared by sync + async via _bounties_search_url / _reshape_bounty / _parse_reward (byte-identical output, parity test added),
  • the reward parser filters label:bounty and reads the amount from title + body with decimals preserved,
  • the langchain-optional test guards are narrowed from broad except Exception to (ImportError, ModuleNotFoundError).

All 25 tests pass. Per-point mapping is in #3. As noted earlier, this branch (#2) is largely superseded by the #3074 v0.2.0 merge — only rustchain_hall_of_fame is unique here; happy to rebase #2 down to just that one tool, or close it, whichever you prefer.

@Vyacheslav-Tomashevskiy

Copy link
Copy Markdown
Contributor Author

Closing this one to keep the merge path clean, @Scottcjn.

After the v0.2.0 merge (#3074), everything #2 added is now either already on main or non-viable:

  • rustchain_epoch, rustchain_miners, rustchain_network_stats, rustchain_node_health, rustchain_payouts, rustchain_bounties — all already on main, so this branch just conflicts/duplicates them (hence the dirty state).
  • rustchain_hall_of_fame — the only unique tool here, but it targets GET /hall/leaderboard, which on the live node returns {"error":"Unauthorized — admin key required"}. There's no public equivalent: facts.json's verify_us lists transactions.json / health / api/miners / epoch / metrics.json but no hall endpoint, and metrics.json doesn't carry the leaderboard either. A read-only LangChain tool that always 401s isn't worth shipping.

So the mergeable stack is just #3#4#5 now (all five consolidated-review blockers are addressed in the #3 commit). If a public /hall/leaderboard (or a hall block in metrics.json) ever lands, I'm happy to reopen a clean, rebased rustchain_hall_of_fame against it. Thanks!

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