Skip to content

Comments

Add support to CLI to read PRT data#737

Open
renatomaia wants to merge 6 commits intonext/2.0from
features/cli-read-prt-data
Open

Add support to CLI to read PRT data#737
renatomaia wants to merge 6 commits intonext/2.0from
features/cli-read-prt-data

Conversation

@renatomaia
Copy link

closes #722

@renatomaia renatomaia self-assigned this Feb 19, 2026
@renatomaia renatomaia force-pushed the features/cli-read-prt-data branch from efdc751 to 305b9fd Compare February 19, 2026 19:42
@vfusco vfusco requested a review from Copilot February 20, 2026 15:20
@vfusco vfusco added this to Node Unit Feb 20, 2026
@vfusco vfusco added this to the 2.0.0 milestone Feb 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

This PR adds CLI support for reading PRT (Permissionless Referee Tournament) dispute entities (tournaments, commitments, matches, match_advances) to align with the JSON-RPC API. It also refactors existing read commands for consistency and improves the repository/JSON-RPC layers by changing filter field types from strings to proper address types.

Changes:

  • Added four new CLI read commands for PRT dispute entities (tournaments, commitments, matches, match_advances)
  • Refactored existing read commands (epochs, inputs, outputs, reports) for consistency in structure and error handling
  • Changed CommitmentFilter.TournamentAddress and MatchFilter.TournamentAddress from *string to *common.Address in the repository layer
  • Renamed GetProcessedInputs to GetProcessedInputCount in the repository interface
  • Exported parseIndex as ParseIndex in JSON-RPC for broader use
  • Fixed JSON field naming: IDHashIdHash to match OpenRPC spec (snake_case id_hash)

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 31 comments.

Show a summary per file
File Description
internal/repository/repository.go Changed filter field types to use *common.Address instead of *string; renamed method to GetProcessedInputCount
internal/repository/postgres/match.go Updated to use common.Address type directly from filter, removing intermediate conversion
internal/repository/postgres/commitment.go Updated to use common.Address type directly from filter, removing intermediate conversion
internal/repository/postgres/application.go Renamed GetProcessedInputs to GetProcessedInputCount
internal/jsonrpc/types.go Fixed JSON field names from IDHash to IdHash to match OpenRPC spec
internal/jsonrpc/jsonrpc.go Exported parseIndex as ParseIndex; updated filter handling to parse addresses before assigning to filters; updated all references to use new field names
cmd/cartesi-rollups-cli/root/read/tournaments/tournaments.go New CLI command for reading tournaments
cmd/cartesi-rollups-cli/root/read/commitments/commitments.go New CLI command for reading commitments
cmd/cartesi-rollups-cli/root/read/matches/matches.go New CLI command for reading matches
cmd/cartesi-rollups-cli/root/read/match_advances/match_advances.go New CLI command for reading match advances
cmd/cartesi-rollups-cli/root/read/read.go Wired new commands into the CLI
cmd/cartesi-rollups-cli/root/read/epochs/epochs.go Refactored for consistency with new command structure
cmd/cartesi-rollups-cli/root/read/inputs/inputs.go Refactored for consistency with new command structure
cmd/cartesi-rollups-cli/root/read/outputs/outputs.go Refactored for consistency with new command structure
cmd/cartesi-rollups-cli/root/read/reports/reports.go Refactored for consistency with new command structure

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

if err != nil {
cobra.CheckErr(fmt.Errorf("invalid epoch index value: %w", err))
}

Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The tournament address argument (args[2]) and ID hash argument (args[3]) should be validated before being passed to the repository. The JSON-RPC handler validates the tournament address using config.ToAddressFromString and validates the ID hash using config.ToHashFromString. Add similar validation here.

Suggested change
// Validate tournament address and id hash arguments
if _, err := config.ToAddressFromString(args[2]); err != nil {
cobra.CheckErr(fmt.Errorf("invalid tournament address value: %w", err))
}
if _, err := config.ToHashFromString(args[3]); err != nil {
cobra.CheckErr(fmt.Errorf("invalid id hash value: %w", err))
}

Copilot uses AI. Check for mistakes.
if err != nil {
cobra.CheckErr(fmt.Errorf("invalid application value: %w", err))
}

Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The tournament address argument (args[1]) should be validated before being passed to the repository. The JSON-RPC handler validates this using config.ToAddressFromString. Add validation similar to line 131 where the flag value is validated.

Suggested change
if _, err := config.ToAddressFromString(args[1]); err != nil {
cobra.CheckErr(fmt.Errorf("invalid tournament address value: %w", err))
}

Copilot uses AI. Check for mistakes.
@renatomaia renatomaia force-pushed the features/cli-read-prt-data branch from e84cea7 to 1b7160a Compare February 20, 2026 19:01
@renatomaia renatomaia force-pushed the features/cli-read-prt-data branch 2 times, most recently from d93c155 to ac88e77 Compare February 20, 2026 22:35
@renatomaia renatomaia force-pushed the features/cli-read-prt-data branch from ac88e77 to 90c3e94 Compare February 21, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants