Skip to content

Commit

Permalink
services/horizon: return null txmeta in api model when SKIP_TXMETA en…
Browse files Browse the repository at this point in the history
…abled (#5228)
  • Loading branch information
sreuland committed Mar 11, 2024
1 parent cabbe84 commit 3fd44ca
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 52 deletions.
35 changes: 33 additions & 2 deletions clients/horizonclient/main_test.go
Expand Up @@ -3,6 +3,7 @@ package horizonclient
import (
"fmt"
"net/http"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -905,6 +906,25 @@ func TestSubmitTransactionRequest(t *testing.T) {
_, err = client.SubmitTransaction(tx)
assert.NoError(t, err)

// verify submit parses correctly when result_meta_xdr absent when skip_meta=true
hmock.On(
"POST",
"https://localhost/transactions",
).Return(func(request *http.Request) (*http.Response, error) {
val := request.FormValue("tx")
assert.Equal(t, val, txXdr)
return httpmock.NewStringResponse(http.StatusOK, strings.Replace(txDetailResponse, "<result_meta_xdr>", "", 1)), nil
})

hmock.On(
"GET",
"https://localhost/accounts/GACTJ4ZFCDZMD2UFR4R7MZOWYBCF6HBP65YKCUT37MUQFPJLDLJ3N5D2/data/config.memo_required",
).ReturnString(404, notFoundResponse)

theTx, err := client.SubmitTransaction(tx)
assert.NoError(t, err)
assert.Empty(t, theTx.ResultMetaXdr)

// memo required - does not submit transaction
hmock.On(
"GET",
Expand Down Expand Up @@ -1388,7 +1408,7 @@ func TestTransactionsRequest(t *testing.T) {
hmock.On(
"GET",
"https://localhost/transactions/5131aed266a639a6eb4802a92fba310454e711ded830ed899745b9e777d7110c",
).ReturnString(200, txDetailResponse)
).ReturnString(200, strings.Replace(txDetailResponse, "<result_meta_xdr>", "result_meta_xdr: AAAAAQAAAAIAAAADAAavdgAAAAAAAAAAtoYrQZHbnPLAFsF4YB88J5VSg0/piQNHm0SL9l0HW1EAAAAXSHbnnAAGr3UAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAABAAavdgAAAAAAAAAAtoYrQZHbnPLAFsF4YB88J5VSg0/piQNHm0SL9l0HW1EAAAAXSHbnnAAGr3UAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAABAAAABAAAAAMABq9zAAAAAAAAAADMSEvcRKXsaUNna++Hy7gWm/CfqTjEA7xoGypfrFGUHAAAAAUQ/z+cAABeBgAASuQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEABq92AAAAAAAAAADMSEvcRKXsaUNna++Hy7gWm/CfqTjEA7xoGypfrFGUHAAAAAcXjracAABeBgAASuQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAMABq92AAAAAAAAAAC2hitBkduc8sAWwXhgHzwnlVKDT+mJA0ebRIv2XQdbUQAAABdIduecAAavdQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEABq92AAAAAAAAAAC2hitBkduc8sAWwXhgHzwnlVKDT+mJA0ebRIv2XQdbUQAAABVB53CcAAavdQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==", 1))

record, err := client.TransactionDetail(txHash)
if assert.NoError(t, err) {
Expand All @@ -1397,6 +1417,17 @@ func TestTransactionsRequest(t *testing.T) {
assert.Equal(t, record.Hash, "5131aed266a639a6eb4802a92fba310454e711ded830ed899745b9e777d7110c")
assert.Equal(t, record.Memo, "2A1V6J5703G47XHY")
}

// transaction detail when skip meta enabled and result_meta_xdr is absent
hmock.On(
"GET",
"https://localhost/transactions/5131aed266a639a6eb4802a92fba310454e711ded830ed899745b9e777d7110c",
).ReturnString(200, strings.Replace(txDetailResponse, "<result_meta_xdr>", "", 1))

record, err = client.TransactionDetail(txHash)
if assert.NoError(t, err) {
assert.Empty(t, record.ResultMetaXdr)
}
}

func TestOrderBookRequest(t *testing.T) {
Expand Down Expand Up @@ -2492,7 +2523,7 @@ var txDetailResponse = `{
"operation_count": 1,
"envelope_xdr": "AAAAALaGK0GR25zywBbBeGAfPCeVUoNP6YkDR5tEi/ZdB1tRAAAAZAAGr3UAAAABAAAAAAAAAAEAAAAQMkExVjZKNTcwM0c0N1hIWQAAAAEAAAABAAAAALaGK0GR25zywBbBeGAfPCeVUoNP6YkDR5tEi/ZdB1tRAAAAAQAAAADMSEvcRKXsaUNna++Hy7gWm/CfqTjEA7xoGypfrFGUHAAAAAAAAAACBo93AAAAAAAAAAABXQdbUQAAAECQ5m6ZHsv8/Gd/aRJ2EMLurJMxFynT7KbD51T7gD91Gqp/fzsRHilSGoVSw5ztmtJb2LP7o3bQbiZynQiJPl8C",
"result_xdr": "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAA=",
"result_meta_xdr": "AAAAAQAAAAIAAAADAAavdgAAAAAAAAAAtoYrQZHbnPLAFsF4YB88J5VSg0/piQNHm0SL9l0HW1EAAAAXSHbnnAAGr3UAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAABAAavdgAAAAAAAAAAtoYrQZHbnPLAFsF4YB88J5VSg0/piQNHm0SL9l0HW1EAAAAXSHbnnAAGr3UAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAABAAAABAAAAAMABq9zAAAAAAAAAADMSEvcRKXsaUNna++Hy7gWm/CfqTjEA7xoGypfrFGUHAAAAAUQ/z+cAABeBgAASuQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEABq92AAAAAAAAAADMSEvcRKXsaUNna++Hy7gWm/CfqTjEA7xoGypfrFGUHAAAAAcXjracAABeBgAASuQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAMABq92AAAAAAAAAAC2hitBkduc8sAWwXhgHzwnlVKDT+mJA0ebRIv2XQdbUQAAABdIduecAAavdQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEABq92AAAAAAAAAAC2hitBkduc8sAWwXhgHzwnlVKDT+mJA0ebRIv2XQdbUQAAABVB53CcAAavdQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==",
"result_meta_xdr": "<result_meta_xdr>",
"fee_meta_xdr": "AAAAAgAAAAMABq91AAAAAAAAAAC2hitBkduc8sAWwXhgHzwnlVKDT+mJA0ebRIv2XQdbUQAAABdIdugAAAavdQAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEABq92AAAAAAAAAAC2hitBkduc8sAWwXhgHzwnlVKDT+mJA0ebRIv2XQdbUQAAABdIduecAAavdQAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==",
"memo_type": "text",
"signatures": [
Expand Down
2 changes: 2 additions & 0 deletions protocols/horizon/README.md
Expand Up @@ -17,6 +17,8 @@ For each new version we will only track changes from the previous version.

#### Changes

* In ["Transaction"](https://developers.stellar.org/api/horizon/resources/transactions/object),
`result_meta_xdr` field is [now nullable](https://github.com/stellar/go/pull/5228), and will be `null` when Horizon has `SKIP_TXMETA=true` set, otherwise if Horizon is configured with `SKIP_TXMETA=false` which is default, then `result_meta_xdr` will be the same value of base64 encoded xdr.
* Operations responses may include a `transaction` field which represents the transaction that created the operation.

### 0.15.0
Expand Down
2 changes: 1 addition & 1 deletion protocols/horizon/main.go
Expand Up @@ -518,7 +518,7 @@ type Transaction struct {
OperationCount int32 `json:"operation_count"`
EnvelopeXdr string `json:"envelope_xdr"`
ResultXdr string `json:"result_xdr"`
ResultMetaXdr string `json:"result_meta_xdr"`
ResultMetaXdr string `json:"result_meta_xdr,omitempty"`
FeeMetaXdr string `json:"fee_meta_xdr"`
MemoType string `json:"memo_type"`
MemoBytes string `json:"memo_bytes,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions services/horizon/CHANGELOG.md
Expand Up @@ -11,6 +11,8 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- History archive access is more effective when you pass list of URLs to Horizon: they will now be accessed in a round-robin fashion, use alternative archives on errors, and intelligently back off ([5224](https://github.com/stellar/go/pull/5224))

### Breaking Changes
- The Horizon API Transaction resource field in json `result_meta_xdr` is now optional and Horizon API will not emit the field when Horizon has been configured with `SKIP_TXMETA=true`, effectively null, otherwise if Horizon is configured with `SKIP_TXMETA=false` which is default, then the API Transaction field `result_meta_xdr` will remain present and populated with base64 encoded xdr [5228](https://github.com/stellar/go/pull/5228).

## 2.28.3

Expand Down
8 changes: 6 additions & 2 deletions services/horizon/internal/actions/operation.go
Expand Up @@ -65,6 +65,7 @@ func (qp OperationsQuery) Validate() error {
type GetOperationsHandler struct {
LedgerState *ledger.State
OnlyPayments bool
SkipTxMeta bool
}

// GetResourcePage returns a page of operations.
Expand Down Expand Up @@ -126,12 +127,13 @@ func (handler GetOperationsHandler) GetResourcePage(w HeaderWriter, r *http.Requ
return nil, err
}

return buildOperationsPage(ctx, historyQ, ops, txs, qp.IncludeTransactions())
return buildOperationsPage(ctx, historyQ, ops, txs, qp.IncludeTransactions(), handler.SkipTxMeta)
}

// GetOperationByIDHandler is the action handler for all end-points returning a list of operations.
type GetOperationByIDHandler struct {
LedgerState *ledger.State
SkipTxMeta bool
}

// OperationQuery query struct for operation/id end-point
Expand Down Expand Up @@ -182,10 +184,11 @@ func (handler GetOperationByIDHandler) GetResource(w HeaderWriter, r *http.Reque
op.TransactionHash,
tx,
ledger,
handler.SkipTxMeta,
)
}

func buildOperationsPage(ctx context.Context, historyQ *history.Q, operations []history.Operation, transactions []history.Transaction, includeTransactions bool) ([]hal.Pageable, error) {
func buildOperationsPage(ctx context.Context, historyQ *history.Q, operations []history.Operation, transactions []history.Transaction, includeTransactions bool, skipTxMeta bool) ([]hal.Pageable, error) {
ledgerCache := history.LedgerCache{}
for _, record := range operations {
ledgerCache.Queue(record.LedgerSequence())
Expand Down Expand Up @@ -216,6 +219,7 @@ func buildOperationsPage(ctx context.Context, historyQ *history.Q, operations []
operationRecord.TransactionHash,
transactionRecord,
ledger,
skipTxMeta,
)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions services/horizon/internal/actions/submit_transaction.go
Expand Up @@ -27,6 +27,7 @@ type SubmitTransactionHandler struct {
NetworkPassphrase string
DisableTxSub bool
CoreStateGetter
SkipTxMeta bool
}

type envelopeInfo struct {
Expand Down Expand Up @@ -84,6 +85,7 @@ func (handler SubmitTransactionHandler) response(r *http.Request, info envelopeI
info.hash,
&resource,
result.Transaction,
handler.SkipTxMeta,
)
return resource, err
}
Expand Down
6 changes: 4 additions & 2 deletions services/horizon/internal/actions/transaction.go
Expand Up @@ -23,6 +23,7 @@ type TransactionQuery struct {

// GetTransactionByHashHandler is the action handler for the end-point returning a transaction.
type GetTransactionByHashHandler struct {
SkipTxMeta bool
}

// GetResource returns a transaction page.
Expand All @@ -49,7 +50,7 @@ func (handler GetTransactionByHashHandler) GetResource(w HeaderWriter, r *http.R
return resource, errors.Wrap(err, "loading transaction record")
}

if err = resourceadapter.PopulateTransaction(ctx, qp.TransactionHash, &resource, record); err != nil {
if err = resourceadapter.PopulateTransaction(ctx, qp.TransactionHash, &resource, record, handler.SkipTxMeta); err != nil {
return resource, errors.Wrap(err, "could not populate transaction")
}
return resource, nil
Expand Down Expand Up @@ -90,6 +91,7 @@ func (qp TransactionsQuery) Validate() error {
// GetTransactionsHandler is the action handler for all end-points returning a list of transactions.
type GetTransactionsHandler struct {
LedgerState *ledger.State
SkipTxMeta bool
}

// GetResourcePage returns a page of transactions.
Expand Down Expand Up @@ -126,7 +128,7 @@ func (handler GetTransactionsHandler) GetResourcePage(w HeaderWriter, r *http.Re

for _, record := range records {
var res horizon.Transaction
err = resourceadapter.PopulateTransaction(ctx, record.TransactionHash, &res, record)
err = resourceadapter.PopulateTransaction(ctx, record.TransactionHash, &res, record, handler.SkipTxMeta)
if err != nil {
return nil, errors.Wrap(err, "could not populate transaction")
}
Expand Down
1 change: 1 addition & 0 deletions services/horizon/internal/app.go
Expand Up @@ -552,6 +552,7 @@ func (a *App) init() error {
},
cache: newHealthCache(healthCacheTTL),
},
SkipTxMeta: a.config.SkipTxmeta,
}

if a.primaryHistoryQ != nil {
Expand Down
20 changes: 14 additions & 6 deletions services/horizon/internal/httpx/router.go
Expand Up @@ -50,6 +50,7 @@ type RouterConfig struct {
HealthCheck http.Handler
EnableIngestionFiltering bool
DisableTxSub bool
SkipTxMeta bool
}

type Router struct {
Expand Down Expand Up @@ -191,8 +192,9 @@ func (r *Router) addRoutes(config *RouterConfig, rateLimiter *throttled.HTTPRate
r.With(historyMiddleware).Method(http.MethodGet, "/operations", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
OnlyPayments: false,
SkipTxMeta: config.SkipTxMeta,
}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState, SkipTxMeta: config.SkipTxMeta}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/effects", streamableHistoryPageHandler(ledgerState, actions.GetEffectsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/trades", streamableHistoryPageHandler(ledgerState, actions.GetTradesHandler{LedgerState: ledgerState, CoreStateGetter: config.CoreGetter}, streamHandler))
})
Expand Down Expand Up @@ -241,29 +243,32 @@ func (r *Router) addRoutes(config *RouterConfig, rateLimiter *throttled.HTTPRate
r.With(historyMiddleware).Method(http.MethodGet, "/accounts/{account_id:\\w+}/operations", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
OnlyPayments: false,
SkipTxMeta: config.SkipTxMeta,
}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/accounts/{account_id:\\w+}/payments", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
OnlyPayments: true,
}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/accounts/{account_id:\\w+}/trades", streamableHistoryPageHandler(ledgerState, actions.GetTradesHandler{LedgerState: ledgerState, CoreStateGetter: config.CoreGetter}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/accounts/{account_id:\\w+}/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/accounts/{account_id:\\w+}/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState, SkipTxMeta: config.SkipTxMeta}, streamHandler))
})
// ledger actions
r.Route("/ledgers", func(r chi.Router) {
r.With(historyMiddleware).Method(http.MethodGet, "/", streamableHistoryPageHandler(ledgerState, actions.GetLedgersHandler{LedgerState: ledgerState}, streamHandler))
r.Route("/{ledger_id}", func(r chi.Router) {
r.With(historyMiddleware).Method(http.MethodGet, "/", ObjectActionHandler{actions.GetLedgerByIDHandler{LedgerState: ledgerState}})
r.With(historyMiddleware).Method(http.MethodGet, "/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState, SkipTxMeta: config.SkipTxMeta}, streamHandler))
r.Group(func(r chi.Router) {
r.With(historyMiddleware).Method(http.MethodGet, "/effects", streamableHistoryPageHandler(ledgerState, actions.GetEffectsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/operations", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
OnlyPayments: false,
SkipTxMeta: config.SkipTxMeta,
}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/payments", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
OnlyPayments: true,
SkipTxMeta: config.SkipTxMeta,
}, streamHandler))
})
})
Expand All @@ -275,18 +280,19 @@ func (r *Router) addRoutes(config *RouterConfig, rateLimiter *throttled.HTTPRate
LedgerState: ledgerState,
OnlyPayments: false,
}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/claimable_balances/{claimable_balance_id:\\w+}/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/claimable_balances/{claimable_balance_id:\\w+}/transactions", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState, SkipTxMeta: config.SkipTxMeta}, streamHandler))
})

// transaction history actions
r.Route("/transactions", func(r chi.Router) {
r.With(historyMiddleware).Method(http.MethodGet, "/", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/", streamableHistoryPageHandler(ledgerState, actions.GetTransactionsHandler{LedgerState: ledgerState, SkipTxMeta: config.SkipTxMeta}, streamHandler))
r.Route("/{tx_id}", func(r chi.Router) {
r.With(historyMiddleware).Method(http.MethodGet, "/", ObjectActionHandler{actions.GetTransactionByHashHandler{}})
r.With(historyMiddleware).Method(http.MethodGet, "/effects", streamableHistoryPageHandler(ledgerState, actions.GetEffectsHandler{LedgerState: ledgerState}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/operations", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
OnlyPayments: false,
SkipTxMeta: config.SkipTxMeta,
}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/payments", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
Expand All @@ -300,8 +306,9 @@ func (r *Router) addRoutes(config *RouterConfig, rateLimiter *throttled.HTTPRate
r.With(historyMiddleware).Method(http.MethodGet, "/", streamableHistoryPageHandler(ledgerState, actions.GetOperationsHandler{
LedgerState: ledgerState,
OnlyPayments: false,
SkipTxMeta: config.SkipTxMeta,
}, streamHandler))
r.With(historyMiddleware).Method(http.MethodGet, "/{id}", ObjectActionHandler{actions.GetOperationByIDHandler{LedgerState: ledgerState}})
r.With(historyMiddleware).Method(http.MethodGet, "/{id}", ObjectActionHandler{actions.GetOperationByIDHandler{LedgerState: ledgerState, SkipTxMeta: config.SkipTxMeta}})
r.With(historyMiddleware).Method(http.MethodGet, "/{op_id}/effects", streamableHistoryPageHandler(ledgerState, actions.GetEffectsHandler{LedgerState: ledgerState}, streamHandler))
})

Expand Down Expand Up @@ -329,6 +336,7 @@ func (r *Router) addRoutes(config *RouterConfig, rateLimiter *throttled.HTTPRate
NetworkPassphrase: config.NetworkPassphrase,
DisableTxSub: config.DisableTxSub,
CoreStateGetter: config.CoreGetter,
SkipTxMeta: config.SkipTxMeta,
}})

// Network state related endpoints
Expand Down
17 changes: 2 additions & 15 deletions services/horizon/internal/integration/transaction_test.go
Expand Up @@ -63,13 +63,7 @@ func TestP19MetaDisabledTransaction(t *testing.T) {

clientTx := itest.MustSubmitOperations(&masterAccount, itest.Master(), op)

var txMetaResult xdr.TransactionMeta
err = xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &txMetaResult)
require.NoError(t, err)

assert.Equal(t, len(txMetaResult.MustV2().Operations), 0)
assert.Equal(t, len(txMetaResult.MustV2().TxChangesAfter), 0)
assert.Equal(t, len(txMetaResult.MustV2().TxChangesBefore), 0)
assert.Empty(t, clientTx.ResultMetaXdr)
}

func TestP20MetaTransaction(t *testing.T) {
Expand Down Expand Up @@ -123,12 +117,5 @@ func TestP20MetaDisabledTransaction(t *testing.T) {
preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp)
clientTx := itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp)

var txMetaResult xdr.TransactionMeta
err = xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &txMetaResult)
require.NoError(t, err)

assert.Equal(t, len(txMetaResult.MustV3().Operations), 0)
assert.Nil(t, txMetaResult.MustV3().SorobanMeta)
assert.Equal(t, len(txMetaResult.MustV3().TxChangesAfter), 0)
assert.Equal(t, len(txMetaResult.MustV3().TxChangesBefore), 0)
assert.Empty(t, clientTx.ResultMetaXdr)
}
7 changes: 4 additions & 3 deletions services/horizon/internal/resourceadapter/operations.go
Expand Up @@ -20,10 +20,11 @@ func NewOperation(
transactionHash string,
transactionRow *history.Transaction,
ledger history.Ledger,
skipTxMeta bool,
) (result hal.Pageable, err error) {

base := operations.Base{}
err = PopulateBaseOperation(ctx, &base, operationRow, transactionHash, transactionRow, ledger)
err = PopulateBaseOperation(ctx, &base, operationRow, transactionHash, transactionRow, ledger, skipTxMeta)
if err != nil {
return
}
Expand Down Expand Up @@ -166,7 +167,7 @@ func NewOperation(
}

// Populate fills out this resource using `row` as the source.
func PopulateBaseOperation(ctx context.Context, dest *operations.Base, operationRow history.Operation, transactionHash string, transactionRow *history.Transaction, ledger history.Ledger) error {
func PopulateBaseOperation(ctx context.Context, dest *operations.Base, operationRow history.Operation, transactionHash string, transactionRow *history.Transaction, ledger history.Ledger, skipTxMeta bool) error {
dest.ID = fmt.Sprintf("%d", operationRow.ID)
dest.PT = operationRow.PagingToken()
dest.TransactionSuccessful = operationRow.TransactionSuccessful
Expand All @@ -190,7 +191,7 @@ func PopulateBaseOperation(ctx context.Context, dest *operations.Base, operation

if transactionRow != nil {
dest.Transaction = new(horizon.Transaction)
return PopulateTransaction(ctx, transactionHash, dest.Transaction, *transactionRow)
return PopulateTransaction(ctx, transactionHash, dest.Transaction, *transactionRow, skipTxMeta)
}
return nil
}
Expand Down

0 comments on commit 3fd44ca

Please sign in to comment.