Skip to content

feat(cli): add contract diagnostic tool for direct on-chain inspection#765

Draft
vfusco wants to merge 1 commit intofix/advancer-snapshot-syncfrom
feature/contract-helper-tool
Draft

feat(cli): add contract diagnostic tool for direct on-chain inspection#765
vfusco wants to merge 1 commit intofix/advancer-snapshot-syncfrom
feature/contract-helper-tool

Conversation

@vfusco
Copy link
Collaborator

@vfusco vfusco commented Mar 20, 2026

Read-only CLI tool that queries Ethereum contracts directly via eth_call
and eth_getLogs — no database required.

Nine subcommands: summary, app, consensus, inputbox, tournament, epoch,
output, commitment, match. Auto-discovers contract tree from application
address, detects consensus type via ERC-165, uses FindTransitions for
efficient event discovery, and supports --tree for recursive tournament
traversal.

@vfusco vfusco added this to the 2.0.0 milestone Mar 20, 2026
@vfusco vfusco requested review from Copilot and mpolitzer March 20, 2026 14:02
@vfusco vfusco self-assigned this Mar 20, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an experimental, read-only contract diagnostics subtree to cartesi-rollups-cli that inspects Cartesi Rollups contracts directly via RPC (eth_call / eth_getLogs), plus supporting utilities and bindings.

Changes:

  • Introduces cartesi-rollups-cli contract ... with subcommands for application/consensus/inputbox/tournament/epoch/summary/output/commitment/match inspection.
  • Adds JSON-RPC error extraction + revert-selector matching utilities and reuses them in PRT tournament handling.
  • Extends generated contract bindings to include IAuthority and IQuorum.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/ethutil/rpcerror.go Adds JSON-RPC error info extraction and selector-matching helpers.
pkg/contracts/iquorum/iquorum.go New generated Go binding for IQuorum.
pkg/contracts/iauthority/iauthority.go New generated Go binding for IAuthority.
pkg/contracts/generate/main.go Updates binding generator to include IAuthority and IQuorum.
internal/prt/util.go Re-exports JSON-RPC error helpers from pkg/ethutil for backward compatibility.
internal/prt/itournament_adapter.go Uses shared JSON-RPC error helpers and selector matching for “no winner” revert detection.
cmd/cartesi-rollups-cli/root/root.go Registers new contract command under the CLI root.
cmd/cartesi-rollups-cli/root/contract/contract.go Implements contract parent command, shared RPC client setup, consensus detection, and common helpers.
cmd/cartesi-rollups-cli/root/contract/types.go Defines JSON output types for all contract subcommands.
cmd/cartesi-rollups-cli/root/contract/app.go Implements contract app (IApplication inspection + JSON/text output).
cmd/cartesi-rollups-cli/root/contract/consensus.go Implements contract consensus (auto-detect Authority/Quorum/DaveConsensus).
cmd/cartesi-rollups-cli/root/contract/inputbox.go Implements contract inputbox (discover + query InputBox).
cmd/cartesi-rollups-cli/root/contract/tournament.go Implements contract tournament (tournament state, events, and optional tree traversal).
cmd/cartesi-rollups-cli/root/contract/epoch.go Implements contract epoch (event-based epoch/claim history across consensus types).
cmd/cartesi-rollups-cli/root/contract/summary.go Implements contract summary (parallel snapshot across app/consensus/inputbox/tournament).
cmd/cartesi-rollups-cli/root/contract/output.go Implements contract output (output execution checks).
cmd/cartesi-rollups-cli/root/contract/commitment.go Implements contract commitment (commitment state lookup in current tournament).
cmd/cartesi-rollups-cli/root/contract/match.go Implements contract match (match state + commitment discovery via events).
cmd/cartesi-rollups-cli/root/contract/selectors.go Defines selector constants and sentinel errors used by the tool.
cmd/cartesi-rollups-cli/root/contract/format.go Adds formatting + text-output helper primitives.
cmd/cartesi-rollups-cli/root/contract/contract_test.go Unit tests for shared helpers (safeUint64/parseBlockFlag/validateHash/consensusType).
cmd/cartesi-rollups-cli/root/contract/format_test.go Unit tests for formatting and printer output.
cmd/cartesi-rollups-cli/root/contract/epoch_test.go Unit tests for epoch history helpers (block range + merge).
cmd/cartesi-rollups-cli/root/contract/tournament_test.go Unit tests for tournament event formatting and commitment registry resolution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vfusco vfusco force-pushed the feature/contract-helper-tool branch 2 times, most recently from e167f61 to 66f4738 Compare March 20, 2026 14:41
Read-only CLI tool that queries Ethereum contracts directly via eth_call
and eth_getLogs — no database required.

Nine subcommands: summary, app, consensus, inputbox, tournament, epoch,
output, commitment, match. Auto-discovers contract tree from application
address, detects consensus type via ERC-165, uses FindTransitions for
efficient event discovery, and supports --tree for recursive tournament
traversal.
@vfusco vfusco force-pushed the feature/contract-helper-tool branch from 66f4738 to 8e20357 Compare March 20, 2026 14:52
@vfusco vfusco changed the base branch from next/2.0 to fix/advancer-snapshot-sync March 20, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants