Conversation
There was a problem hiding this comment.
Pull request overview
Extends transaction simulation to preview state changes for custom SEP-41 tokens without persistence.
Changes:
- Runs registered protocol processors during simulation.
- Exposes staged SEP-41 state changes.
- Wires models and SEP-41 registration into serving.
- Adds service and GraphQL test coverage.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Review |
|---|---|
internal/services/transaction_simulation.go |
Requires same-ledger contract classification and explicit processor resets before processing. |
internal/services/transaction_simulation_test.go |
Updates constructor calls. |
internal/services/transaction_simulation_sep41_test.go |
Adds end-to-end SEP-41 simulation tests. |
internal/services/sep41/processor.go |
Exposes staged changes; nit: restore the Reset documentation placement. |
internal/services/protocol_processor.go |
Extends the processor interface. |
internal/services/protocol_migrate_test.go |
Updates the test processor. |
internal/services/processor_registry_test.go |
Updates registry stubs. |
internal/services/mocks.go |
Extends the processor mock. |
internal/services/ingest_test.go |
Updates the ingestion test processor. |
internal/serve/serve.go |
Registers SEP-41 and injects models. |
internal/serve/graphql/utils_test.go |
Covers the simulation failure code. |
internal/serve/graphql/resolvers/simulation_test.go |
Tests simulated-state conversion. |
internal/serve/graphql/resolvers/queries_resolvers_test.go |
Tests simulation error mapping. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot resolve the merge conflicts in this pull request |
adead45 to
5531231
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (1)
internal/services/transaction_simulation.go:62
- This comment says
modelsis used only forprotocol_contracts, but this path also queriesProtocolWasmsto classify same-transaction bindings (line 453). Mentioning both lookups avoids misleading callers that provide partial model aggregates.
// NewTransactionSimulationService builds the simulation service. models is used
// only for the read-only protocol_contracts lookup that routes contract events
// to the registered protocol processors (SEP-41); a nil models skips protocol
// processing, so previews then cover native/SAC tokens only.
5531231 to
b266840
Compare
b266840 to
b68e1bf
Compare
| // a contract bound to an already-classified wasm emits rows even without a | ||
| // committed protocol_contracts entry. Classification for the buffered wasm | ||
| // hashes comes from committed protocol_wasms. | ||
| var classification map[types.HashBytea]string |
There was a problem hiding this comment.
Why are we doing classification when generating the simulated state changes? Shouldn't that happen only in live ingestion?
There was a problem hiding this comment.
Because ingestion will classify this contract when the transaction lands, the preview must classify it too, or it would miss rows history will show. It's in-memory and read-only, nothing is persisted.
What
Extends
simulateStateChangesto cover custom SEP-41 tokens by mirroring what live ingestion does after the indexer pass, with persistence removed:ProtocolProcessor.StagedStateChanges()(new interface method): reads the processor's computed state changes without persisting them to the DB.sep41so the processor registers itself at startup, and the simulation service getsModelsso it can do the classification lookup.Why
Previously the simulation only ran the main indexer, skips non-SAC token events deliberately because
sep41.Processorowns them.Known limitations
N/A
Issue that this PR addresses
#618
PR Structure
allif the changes are broad or impact many packages.Thoroughness
Release