Skip to content

Simulation Result Diff Comparator #534

Description

@Kingsman-99

Description

src/simulationDiff.ts exists but does not provide a structured comparison between two separate simulation runs (e.g. a baseline vs a modified transaction). During development and debugging, engineers need to understand exactly how a change to a transaction affects resource consumption, auth entries, and footprint size. A diff comparator should accept two simulation results and return a typed, human-readable difference object.

Technical Context

Extend src/simulationDiff.ts. Accepts two SorobanRpc.SimulateTransactionResponse objects. Compares fields: cost.cpuInsns, cost.memBytes, minResourceFee, footprint.readOnly, footprint.readWrite, and auth entries. Adds SimulationDiff and ResourceDelta to src/types.ts. Integrates with src/profiler.ts to emit diffs on each profiling run.

Acceptance Criteria

  • compareSimulations(baseline, revised): SimulationDiff returns a typed object with cpuDelta, memDelta, feeDelta, footprintAdded[], footprintRemoved[], and authChanged: boolean
  • Positive deltas indicate the revised simulation uses more resources; negative indicates fewer
  • footprintAdded and footprintRemoved list the LedgerKey XDR base64 strings that differ between the two runs
  • formatDiffSummary(diff: SimulationDiff): string produces a human-readable multi-line summary for logging
  • Unit tests assert correct deltas for: identical simulations (all zeros), revised simulation with 2× CPU usage, revised simulation with additional auth entry
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions