From 364ca19e9381aae045a6cc0d17f2a790649e3460 Mon Sep 17 00:00:00 2001 From: tamirms Date: Fri, 25 Oct 2024 09:51:34 +0100 Subject: [PATCH] protocols/horizon: Reinstate errorResultXdr with deprecation warning (#5496) --- protocols/horizon/main.go | 18 +++++++++++++----- services/horizon/CHANGELOG.md | 10 +++++++++- .../actions/submit_transaction_async.go | 2 ++ .../actions/submit_transaction_async_test.go | 7 ++++--- .../httpx/static/txsub_async_oapi.yaml | 4 ++++ .../internal/integration/txsub_async_test.go | 7 ++++--- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/protocols/horizon/main.go b/protocols/horizon/main.go index b25c03eb63..3fa6ef1ab1 100644 --- a/protocols/horizon/main.go +++ b/protocols/horizon/main.go @@ -175,16 +175,20 @@ type AssetStat struct { } `json:"_links"` base.Asset - PT string `json:"paging_token"` - ContractID string `json:"contract_id,omitempty"` - NumClaimableBalances int32 `json:"num_claimable_balances"` - NumLiquidityPools int32 `json:"num_liquidity_pools"` - NumContracts int32 `json:"num_contracts"` + PT string `json:"paging_token"` + ContractID string `json:"contract_id,omitempty"` + NumClaimableBalances int32 `json:"num_claimable_balances"` + NumLiquidityPools int32 `json:"num_liquidity_pools"` + NumContracts int32 `json:"num_contracts"` + // NumArchivedContracts is deprecated and will be removed in the v23 release + // Action needed in release: horizon-v23.0.0: remove field NumArchivedContracts int32 `json:"num_archived_contracts"` Accounts AssetStatAccounts `json:"accounts"` ClaimableBalancesAmount string `json:"claimable_balances_amount"` LiquidityPoolsAmount string `json:"liquidity_pools_amount"` ContractsAmount string `json:"contracts_amount"` + // ArchivedContractsAmount is deprecated and will be removed in the v23 release + // Action needed in release: horizon-v23.0.0: remove field ArchivedContractsAmount string `json:"archived_contracts_amount"` Balances AssetStatBalances `json:"balances"` Flags AccountFlags `json:"flags"` @@ -576,6 +580,10 @@ type AsyncTransactionSubmissionResponse struct { // ErrorResultXDR is a TransactionResult xdr string which contains details on why // the transaction could not be accepted by stellar-core. ErrorResultXDR string `json:"error_result_xdr,omitempty"` + // DeprecatedErrorResultXDR is a deprecated field equivalent to ErrorResultXDR + // which will be removed in the v23 release. Use ErrorResultXDR instead of + // DeprecatedErrorResultXDR + DeprecatedErrorResultXDR string `json:"errorResultXdr,omitempty"` // TxStatus represents the status of the transaction submission returned by stellar-core. // It can be one of: proto.TXStatusPending, proto.TXStatusDuplicate, // proto.TXStatusTryAgainLater, or proto.TXStatusError. diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index 49125a18ab..4b48c6c46d 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -3,7 +3,15 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## 22.0.0-rc +## 22.0.0-rc2 + + +### Deprecations + +- The `errorResultXdr` field from the response of the async transaction submission endpoint has been temporarily reinstated. However it will be removed in the v23 release. ([5496](https://github.com/stellar/go/pull/5496)) +- The `num_archived_contracts` and `archived_contracts_amount` fields from the `/assets` response have been deprecated and will be removed in the v23 Horizon release. ([5496](https://github.com/stellar/go/pull/5496)) + +## 22.0.0-rc1 **This release adds support for Protocol 22** diff --git a/services/horizon/internal/actions/submit_transaction_async.go b/services/horizon/internal/actions/submit_transaction_async.go index 0cce31b5f6..d0a78c5218 100644 --- a/services/horizon/internal/actions/submit_transaction_async.go +++ b/services/horizon/internal/actions/submit_transaction_async.go @@ -115,6 +115,8 @@ func (handler AsyncSubmitTransactionHandler) GetResource(_ HeaderWriter, r *http if resp.Status == proto.TXStatusError { response.ErrorResultXDR = resp.Error + // Action needed in release: horizon-v23.0.0: remove deprecated field + response.DeprecatedErrorResultXDR = resp.Error } return response, nil diff --git a/services/horizon/internal/actions/submit_transaction_async_test.go b/services/horizon/internal/actions/submit_transaction_async_test.go index 258012bc3c..a72cbe8347 100644 --- a/services/horizon/internal/actions/submit_transaction_async_test.go +++ b/services/horizon/internal/actions/submit_transaction_async_test.go @@ -164,9 +164,10 @@ func TestAsyncSubmitTransactionHandler_TransactionStatusResponse(t *testing.T) { DiagnosticEvents: "test-diagnostic-events", }, expectedResponse: horizon.AsyncTransactionSubmissionResponse{ - ErrorResultXDR: "test-error", - TxStatus: proto.TXStatusError, - Hash: TxHash, + ErrorResultXDR: "test-error", + DeprecatedErrorResultXDR: "test-error", + TxStatus: proto.TXStatusError, + Hash: TxHash, }, }, { diff --git a/services/horizon/internal/httpx/static/txsub_async_oapi.yaml b/services/horizon/internal/httpx/static/txsub_async_oapi.yaml index 0e9a23e676..10502b4387 100644 --- a/services/horizon/internal/httpx/static/txsub_async_oapi.yaml +++ b/services/horizon/internal/httpx/static/txsub_async_oapi.yaml @@ -140,6 +140,10 @@ components: type: string nullable: true description: TransactionResult XDR string which is present only if the submission status from core is an ERROR. + errorResultXdr: + type: string + nullable: true + description: This field is deprecated, use error_result_xdr instead. tx_status: type: string enum: ["ERROR", "PENDING", "DUPLICATE", "TRY_AGAIN_LATER"] diff --git a/services/horizon/internal/integration/txsub_async_test.go b/services/horizon/internal/integration/txsub_async_test.go index 4d9ff8e906..8310be1dba 100644 --- a/services/horizon/internal/integration/txsub_async_test.go +++ b/services/horizon/internal/integration/txsub_async_test.go @@ -87,9 +87,10 @@ func TestAsyncTxSub_SubmissionError(t *testing.T) { txResp, err := itest.AsyncSubmitTransaction(master, txParams) assert.NoError(t, err) assert.Equal(t, txResp, horizon.AsyncTransactionSubmissionResponse{ - ErrorResultXDR: "AAAAAAAAAGT////7AAAAAA==", - TxStatus: "ERROR", - Hash: "0684df00f20efd5876f1b8d17bc6d3a68d8b85c06bb41e448815ecaa6307a251", + ErrorResultXDR: "AAAAAAAAAGT////7AAAAAA==", + DeprecatedErrorResultXDR: "AAAAAAAAAGT////7AAAAAA==", + TxStatus: "ERROR", + Hash: "0684df00f20efd5876f1b8d17bc6d3a68d8b85c06bb41e448815ecaa6307a251", }) }