Fix input tx reference#789
Open
vfusco wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces the previous “transaction reference” concept on inputs with an explicit L1 transaction hash + log index identity, enabling correct handling of multiple InputAdded logs emitted by a single transaction, and adds filtering by transaction hash via JSON-RPC and CLI.
Changes:
- Model/repository/schema update:
Input.TransactionReference→Input.TransactionHash+Input.LogIndex, with a uniqueness constraint on(application, transaction_hash, log_index). - Add new repository + API support to list/filter inputs by
transaction_hash(JSON-RPC + CLI). - Add integration + unit test coverage for “multiple inputs in the same transaction” and for the new JSON fields.
Reviewed changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/validator/validator_test.go | Updates tests to use TransactionHash instead of TransactionReference. |
| test/integration/testdata/Spambox.sol | Adds helper contract source to generate multiple inputs from one tx. |
| test/integration/testdata/spambox_bytecode.hex | Adds precompiled bytecode for Spambox deployment in tests. |
| test/integration/testdata/spambox_abi.json | Adds ABI used to deploy/call Spambox in tests. |
| test/integration/same_block_inputs_test.go | Adds an integration test that reproduces multi-InputAdded-in-one-tx behavior and validates tx-hash filtering. |
| test/integration/foreclose_replay_test.go | Updates replay comparisons to assert TransactionHash + LogIndex. |
| internal/repository/repotest/input_test_cases.go | Adds repo-level test coverage for same-transaction inputs and tx-hash filtering. |
| internal/repository/repotest/builders.go | Updates input builder defaults and adds helpers for TransactionHash and LogIndex. |
| internal/repository/repository.go | Extends InputFilter with TransactionHash; removes GetInputByTxReference; introduces ErrInputLogIdentityConflict. |
| internal/repository/postgres/schema/migrations/000001_create_initial_schema.up.sql | Updates the input table schema to store transaction_hash and log_index and enforce uniqueness. |
| internal/repository/postgres/input.go | Updates queries/scans to include TransactionHash and LogIndex; removes tx-reference lookup method. |
| internal/repository/postgres/epoch.go | Stores TransactionHash + LogIndex; wraps unique-constraint conflicts as ErrInputLogIdentityConflict. |
| internal/repository/postgres/db/rollupsdb/public/table/input.go | Updates generated table columns to match schema (transaction_hash, log_index). |
| internal/repository/postgres/application.go | Updates snapshot query scanning to include TransactionHash and LogIndex. |
| internal/model/models.go | Updates Input struct fields and JSON marshal/unmarshal to include log_index. |
| internal/model/models_json_test.go | Adds roundtrip + validation tests for transaction_hash and log_index JSON handling. |
| internal/jsonrpc/jsonrpc.go | Adds request param parsing and repository filter wiring for transaction_hash. |
| internal/jsonrpc/jsonrpc-discover.json | Updates OpenRPC docs: adds transaction_hash filter and replaces transaction_reference with transaction_hash + log_index. |
| internal/jsonrpc/jsonrpc_test.go | Adds JSON-RPC tests for filtering by transaction_hash and validates response fields. |
| internal/jsonrpc/api/params.go | Adds transaction_hash to ListInputsParams. |
| internal/evmreader/input.go | Populates TransactionHash and LogIndex from L1 logs; escalates log-identity conflicts to CORRUPTED. |
| internal/evmreader/input_test.go | Updates expectations to assert TransactionHash and LogIndex. |
| internal/evmreader/fixtures_test.go | Ensures fixture logs include types.Log.Index so LogIndex can be tested. |
| internal/evmreader/edge_cases_test.go | Adds tests ensuring log index is preserved across same-tx inputs and conflict handling marks app corrupted. |
| internal/config/config.go | Tightens hash parsing to require exactly 32 bytes (avoids silent pad/truncate). |
| cmd/cartesi-rollups-cli/root/read/service/repository.go | Adds transaction-hash filtering to repository-backed CLI read flow. |
| cmd/cartesi-rollups-cli/root/read/service/jsonrpc.go | Validates transaction_hash before forwarding JSON-RPC requests. |
| cmd/cartesi-rollups-cli/root/read/inputs/inputs.go | Adds --transaction-hash flag and wiring to the read inputs CLI command. |
Files not reviewed (1)
- internal/repository/postgres/db/rollupsdb/public/table/input.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9d32530 to
7d231d0
Compare
d133218 to
deb34e0
Compare
renatomaia
approved these changes
Jul 10, 2026
mpolitzer
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.