Skip to content

Commit

Permalink
simulate-transaction: remove confusing Cost field in response (#295)
Browse files Browse the repository at this point in the history
* simulate-transaction: remove confusing Cost field in response

* Appease linter
  • Loading branch information
2opremio authored Sep 20, 2024
1 parent accd794 commit b817750
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ func TestSimulateTransactionSucceeds(t *testing.T) {
contractHashBytes := xdr.ScBytes(contractHash[:])
expectedXdr := xdr.ScVal{Type: xdr.ScValTypeScvBytes, Bytes: &contractHashBytes}
require.Greater(t, result.LatestLedger, uint32(0))
require.Greater(t, result.Cost.CPUInstructions, uint64(0))
require.Greater(t, result.Cost.MemoryBytes, uint64(0))

expectedTransactionData := xdr.SorobanTransactionData{
Resources: xdr.SorobanResources{
Expand Down
21 changes: 5 additions & 16 deletions cmd/soroban-rpc/internal/methods/simulate_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ type SimulateTransactionRequest struct {
Format string `json:"xdrFormat,omitempty"`
}

type SimulateTransactionCost struct {
CPUInstructions uint64 `json:"cpuInsns,string"`
MemoryBytes uint64 `json:"memBytes,string"`
}

// SimulateHostFunctionResult contains the simulation result of each HostFunction
// within the single InvokeHostFunctionOp allowed in a Transaction
// SimulateHostFunctionResult contains the simulation result of each HostFunction within the single
// InvokeHostFunctionOp allowed in a Transaction
type SimulateHostFunctionResult struct {
AuthXDR *[]string `json:"auth,omitempty"`
AuthJSON []json.RawMessage `json:"authJson,omitempty"`
Expand Down Expand Up @@ -217,8 +212,6 @@ type SimulateTransactionResponse struct {
MinResourceFee int64 `json:"minResourceFee,string,omitempty"`
// an array of the individual host function call results
Results []SimulateHostFunctionResult `json:"results,omitempty"`
// the effective cpu and memory cost of the invoked transaction execution.
Cost SimulateTransactionCost `json:"cost,omitempty"`
// If present, it indicates that a prior RestoreFootprint is required
RestorePreamble *RestorePreamble `json:"restorePreamble,omitempty"`
// If present, it indicates how the state (ledger entries) will change as a result of the transaction execution.
Expand Down Expand Up @@ -392,13 +385,9 @@ func NewSimulateTransactionHandler(logger *log.Entry, ledgerEntryReader db.Ledge
}

simResp := SimulateTransactionResponse{
Error: result.Error,
Results: results,
MinResourceFee: result.MinFee,
Cost: SimulateTransactionCost{
CPUInstructions: result.CPUInstructions,
MemoryBytes: result.MemoryBytes,
},
Error: result.Error,
Results: results,
MinResourceFee: result.MinFee,
LatestLedger: latestLedger,
RestorePreamble: restorePreamble,
StateChanges: stateChanges,
Expand Down

0 comments on commit b817750

Please sign in to comment.