Skip to content

[Feature] Replay mainnet transactions by hash list #505

@ExoMonk

Description

@ExoMonk

Summary

Add the ability to replay transactions from mainnet (or any network) given a list of transaction signatures/hashes. This would allow developers to:

  • Reproduce and debug production transactions locally
  • Test protocol behavior against real historical transactions
  • Analyze transaction execution in a controlled environment

Use Cases

  • Debugging failed transactions - Replay a failed mainnet tx to understand what went wrong
  • Protocol testing - Replay a sequence of swaps/liquidations to test protocol behavior
  • MEV research - Analyze transaction execution and state changes
  • Audit workflows - Reproduce specific transaction scenarios from production

Proposed Interface

# Replay a single transaction
surfpool replay <TX_HASH> -u https://api.mainnet-beta.solana.com
# Replay multiple transactions from a file
surfpool replay --from-file tx_hashes.txt -u mainnet
# Replay with profiling output
surfpool replay <TX_HASH> -u mainnet --profile --output results.json

Or as a cheatcode RPC method:

{
  "method": "surfnet_replayTransaction",
  "params": {
    "signature": "5K2...",
    "profile": true
  }
}

Workflow:

  1. Fetch transaction via getTransaction (with maxSupportedTransactionVersion)
  2. Extract slot number and all account keys (including ALT lookups)
  3. Fetch account states at that slot using getMultipleAccounts
  4. Clone any missing programs
  5. Set time to transaction's block time via surfnet_timeTravel
  6. Execute via surfnet_profileTransaction or sendTransaction
  7. Return execution results (logs, CUs, state changes)

Related

-> Existing surfnet_profileTransaction cheatcode provides the execution infrastructure
-> surfnet_setAccount can be used to set up pre-execution state
-> Consider integration with scenarios for replaying transaction sequences

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions