go icon indicating copy to clipboard operation
go copied to clipboard

services/soroban-rpc: simulateTransaction

Open tsachiherman opened this issue 2 years ago • 0 comments

Depends on https://github.com/stellar/stellar-core/issues/3484, which is merged now.

This API should follow the soroban-rpc API Docs on Confluence, so that devs can swap out API server they are using soroban-rpc/cli serve/horizon seamlessly.

simulateTransaction

Submit a trial contract invocation to get back return values, expected ledger footprint, and expected costs.

TODO: Should/can we offer to auto-calculate the footprint as part of sendTransaction to save round-trips? Solana does this, but it might conflict with our signature scheme?

Parameters:

  • <xdr.Transaction> - The transaction to be simulated

Returns:

  • <object>
    • cost: <object> - Information about the fees expected, instructions used, etc.
      • cpuInsns: <string> - Stringified-number of the total cpu instructions consumed by this transaction
      • memBytes: <string> - Stringified-number of the total memory bytes allocated by this transaction
    • footprint: <object>
      • readOnly: <xdr.LedgerKey[]> - Array of ledger keys expected to be read by this transaction
      • readWrite: <xdr.LedgerKey[]> - Array of ledger keys expected to be written by this transaction.
    • results: <object[]>
      • xdr: <xdr.ScVal> - (optional) Only present on success. xdr-encoded return value of the contract call
    • latestLedger: <number> - The current latest ledger observed by the node when this response was generated.

Possible Errors:

  • TODO: Figure out failure modes.
  • Call panicked/rejected/trapped (whatever we’re calling it)

tsachiherman avatar Sep 19 '22 14:09 tsachiherman