Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulate-transaction: remove confusing Cost field in response #295

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading