Skip to content

Commit

Permalink
Karthik/5438/deprecate horizon fields for protocol 22 (#5478)
Browse files Browse the repository at this point in the history
* Update .gitignore to ignore bucket-cache/ at any level

* clean up all occurences of Amount and NumAccounts (#5438)

* Cleanup validAfter and validBefore

* Remove unused fn

* Update fixture

* SQL to drop columns for protocol 22 release

* Remove amount and num_accounts from ExpAssetStats table and test fixtures

* Remoce extra space in sql migration file. Generate bindata.go with gogenerate.sh

* Update code to show only authorized accounts and balances in ticker service

* Fix tests in ticker

* Updated CHANGELOG.md to include breaking changes
  • Loading branch information
karthikiyer56 authored Oct 2, 2024
1 parent 6904ece commit a3d1f08
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/services/horizon/captive-core
/services/horizon/horizon
/services/horizon/stellar-horizon
/bucket-cache
**bucket-cache/
.vscode
.idea
debug
Expand Down
2 changes: 0 additions & 2 deletions clients/horizonclient/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,6 @@ func TestAssetsRequest(t *testing.T) {
assert.Equal(t, record.Asset.Code, "ABC")
assert.Equal(t, record.Asset.Issuer, "GCLWGQPMKXQSPF776IU33AH4PZNOOWNAWGGKVTBQMIC5IMKUNP3E6NVU")
assert.Equal(t, record.PT, "1")
assert.Equal(t, record.NumAccounts, int32(3))
assert.Equal(t, record.Amount, "105.0000000")
assert.Equal(t, record.Flags.AuthRevocable, false)
assert.Equal(t, record.Flags.AuthRequired, true)
assert.Equal(t, record.Flags.AuthImmutable, false)
Expand Down
67 changes: 30 additions & 37 deletions protocols/horizon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,12 @@ type AssetStat struct {
} `json:"_links"`

base.Asset
PT string `json:"paging_token"`
ContractID string `json:"contract_id,omitempty"`
// Action needed in release: horizon-v3.0.0: deprecated field
NumAccounts int32 `json:"num_accounts"`
NumClaimableBalances int32 `json:"num_claimable_balances"`
NumLiquidityPools int32 `json:"num_liquidity_pools"`
NumContracts int32 `json:"num_contracts"`
NumArchivedContracts int32 `json:"num_archived_contracts"`
// Action needed in release: horizon-v3.0.0: deprecated field
Amount string `json:"amount"`
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 int32 `json:"num_archived_contracts"`
Accounts AssetStatAccounts `json:"accounts"`
ClaimableBalancesAmount string `json:"claimable_balances_amount"`
LiquidityPoolsAmount string `json:"liquidity_pools_amount"`
Expand Down Expand Up @@ -509,33 +505,30 @@ type Transaction struct {
// When TransactionSuccess is removed from the SDKs we can remove this HAL link
Transaction hal.Link `json:"transaction"`
} `json:"_links"`
ID string `json:"id"`
PT string `json:"paging_token"`
Successful bool `json:"successful"`
Hash string `json:"hash"`
Ledger int32 `json:"ledger"`
LedgerCloseTime time.Time `json:"created_at"`
Account string `json:"source_account"`
AccountMuxed string `json:"account_muxed,omitempty"`
AccountMuxedID uint64 `json:"account_muxed_id,omitempty,string"`
AccountSequence int64 `json:"source_account_sequence,string"`
FeeAccount string `json:"fee_account"`
FeeAccountMuxed string `json:"fee_account_muxed,omitempty"`
FeeAccountMuxedID uint64 `json:"fee_account_muxed_id,omitempty,string"`
FeeCharged int64 `json:"fee_charged,string"`
MaxFee int64 `json:"max_fee,string"`
OperationCount int32 `json:"operation_count"`
EnvelopeXdr string `json:"envelope_xdr"`
ResultXdr string `json:"result_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"`
Memo string `json:"memo,omitempty"`
Signatures []string `json:"signatures"`
// Action needed in release: horizon-v3.0.0: remove valid_(after|before)
ValidAfter string `json:"valid_after,omitempty"`
ValidBefore string `json:"valid_before,omitempty"`
ID string `json:"id"`
PT string `json:"paging_token"`
Successful bool `json:"successful"`
Hash string `json:"hash"`
Ledger int32 `json:"ledger"`
LedgerCloseTime time.Time `json:"created_at"`
Account string `json:"source_account"`
AccountMuxed string `json:"account_muxed,omitempty"`
AccountMuxedID uint64 `json:"account_muxed_id,omitempty,string"`
AccountSequence int64 `json:"source_account_sequence,string"`
FeeAccount string `json:"fee_account"`
FeeAccountMuxed string `json:"fee_account_muxed,omitempty"`
FeeAccountMuxedID uint64 `json:"fee_account_muxed_id,omitempty,string"`
FeeCharged int64 `json:"fee_charged,string"`
MaxFee int64 `json:"max_fee,string"`
OperationCount int32 `json:"operation_count"`
EnvelopeXdr string `json:"envelope_xdr"`
ResultXdr string `json:"result_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"`
Memo string `json:"memo,omitempty"`
Signatures []string `json:"signatures"`
Preconditions *TransactionPreconditions `json:"preconditions,omitempty"`
FeeBumpTransaction *FeeBumpTransaction `json:"fee_bump_transaction,omitempty"`
InnerTransaction *InnerTransaction `json:"inner_transaction,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions services/horizon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).

## Pending

### Breaking Changes

- Removed `num_accounts` and `amount` fields from Asset stats related endpoints, and `valid_before` and `valid_after` fields from transaction related endpoints. Issue - [5438](https://github.com/stellar/go/issues/5438), PR - [5478](https://github.com/stellar/go/pull/5478)
- These fields have already been functionally deprecated as of release v2.1.0. As a part of this release, these fields are omitted from API Response
- Additionally, the `num_accounts` and `amount` columns have been dropped from `exp_asset_stats` table in Postgres.

### Added

- Reingest from pre-computed tx meta on remote cloud storage. ([4911](https://github.com/stellar/go/issues/4911)), ([5374](https://github.com/stellar/go/pull/5374))
Expand Down
20 changes: 0 additions & 20 deletions services/horizon/internal/actions/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "10",
LiquidityPools: "20",
},
Amount: "1",
NumAccounts: 2,
}
usdAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand All @@ -157,8 +155,6 @@ func TestAssetStats(t *testing.T) {
},
ClaimableBalancesAmount: "0.0000010",
LiquidityPoolsAmount: "0.0000020",
Amount: "0.0000001",
NumAccounts: usdAssetStat.NumAccounts,
ContractsAmount: "0.0000000",
ArchivedContractsAmount: "0.0000000",
Asset: base.Asset{
Expand Down Expand Up @@ -187,8 +183,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "23",
NumAccounts: 1,
}
etherAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand All @@ -206,8 +200,6 @@ func TestAssetStats(t *testing.T) {
LiquidityPoolsAmount: "0.0000000",
ContractsAmount: "0.0000000",
ArchivedContractsAmount: "0.0000000",
Amount: "0.0000023",
NumAccounts: etherAssetStat.NumAccounts,
Asset: base.Asset{
Type: "credit_alphanum4",
Code: etherAssetStat.AssetCode,
Expand All @@ -234,8 +226,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "1",
NumAccounts: 2,
}
otherUSDAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand All @@ -251,10 +241,8 @@ func TestAssetStats(t *testing.T) {
},
ClaimableBalancesAmount: "0.0000000",
LiquidityPoolsAmount: "0.0000000",
Amount: "0.0000001",
ContractsAmount: "0.0000000",
ArchivedContractsAmount: "0.0000000",
NumAccounts: otherUSDAssetStat.NumAccounts,
Asset: base.Asset{
Type: "credit_alphanum4",
Code: otherUSDAssetStat.AssetCode,
Expand Down Expand Up @@ -283,8 +271,6 @@ func TestAssetStats(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "111",
NumAccounts: 3,
}
eurAssetStatResponse := horizon.AssetStat{
Accounts: horizon.AssetStatAccounts{
Expand All @@ -300,10 +286,8 @@ func TestAssetStats(t *testing.T) {
},
ClaimableBalancesAmount: "0.0000000",
LiquidityPoolsAmount: "0.0000000",
Amount: "0.0000111",
ContractsAmount: "0.0000000",
ArchivedContractsAmount: "0.0000000",
NumAccounts: eurAssetStat.NumAccounts,
Asset: base.Asset{
Type: "credit_alphanum4",
Code: eurAssetStat.AssetCode,
Expand Down Expand Up @@ -453,8 +437,6 @@ func TestAssetStatsIssuerDoesNotExist(t *testing.T) {
Unauthorized: "3",
ClaimableBalances: "0",
},
Amount: "1",
NumAccounts: 2,
}
numChanged, err := q.InsertAssetStat(tt.Ctx, usdAssetStat)
tt.Assert.NoError(err)
Expand All @@ -478,10 +460,8 @@ func TestAssetStatsIssuerDoesNotExist(t *testing.T) {
},
ClaimableBalancesAmount: "0.0000000",
LiquidityPoolsAmount: "0.0000000",
Amount: "0.0000001",
ContractsAmount: "0.0000000",
ArchivedContractsAmount: "0.0000000",
NumAccounts: usdAssetStat.NumAccounts,
Asset: base.Asset{
Type: "credit_alphanum4",
Code: usdAssetStat.AssetCode,
Expand Down
2 changes: 0 additions & 2 deletions services/horizon/internal/db2/history/asset_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ func assetStatToMap(assetStat ExpAssetStat) map[string]interface{} {
"asset_issuer": assetStat.AssetIssuer,
"accounts": assetStat.Accounts,
"balances": assetStat.Balances,
"amount": assetStat.Amount,
"num_accounts": assetStat.NumAccounts,
"contract_id": assetStat.ContractID,
}
}
Expand Down
46 changes: 0 additions & 46 deletions services/horizon/internal/db2/history/asset_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ func TestAssetStatContracts(t *testing.T) {
LiquidityPools: "0",
Unauthorized: "0",
},
Amount: "0",
NumAccounts: 0,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12,
Expand All @@ -59,8 +57,6 @@ func TestAssetStatContracts(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "23",
NumAccounts: 1,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4,
Expand All @@ -78,8 +74,6 @@ func TestAssetStatContracts(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
},
}
var contractID [32]byte
Expand Down Expand Up @@ -219,8 +213,6 @@ func TestInsertAssetStats(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12,
Expand All @@ -238,8 +230,6 @@ func TestInsertAssetStats(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "23",
NumAccounts: 1,
},
}
tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, assetStats))
Expand Down Expand Up @@ -276,8 +266,6 @@ func TestInsertAssetStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
},
{
AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12,
Expand All @@ -295,8 +283,6 @@ func TestInsertAssetStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "23",
NumAccounts: 1,
},
}

Expand Down Expand Up @@ -333,8 +319,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat)
Expand All @@ -344,18 +328,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) {
numChanged, err = q.InsertAssetStat(tt.Ctx, assetStat)
tt.Assert.Error(err)
tt.Assert.Equal(numChanged, int64(0))

assetStat.NumAccounts = 4
assetStat.Amount = "3"
numChanged, err = q.InsertAssetStat(tt.Ctx, assetStat)
tt.Assert.Error(err)
tt.Assert.Equal(numChanged, int64(0))

assetStat.NumAccounts = 2
assetStat.Amount = "1"
got, err := q.GetAssetStat(tt.Ctx, assetStat.AssetType, assetStat.AssetCode, assetStat.AssetIssuer)
tt.Assert.NoError(err)
tt.Assert.Equal(got, assetStat)
}

func TestUpdateAssetStatDoesNotExistsError(t *testing.T) {
Expand All @@ -380,8 +352,6 @@ func TestUpdateAssetStatDoesNotExistsError(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.UpdateAssetStat(tt.Ctx, assetStat)
Expand Down Expand Up @@ -415,8 +385,6 @@ func TestUpdateStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat)
Expand All @@ -427,8 +395,6 @@ func TestUpdateStat(t *testing.T) {
tt.Assert.NoError(err)
tt.Assert.Equal(got, assetStat)

assetStat.NumAccounts = 50
assetStat.Amount = "23"
assetStat.SetContractID([32]byte{23})

numChanged, err = q.UpdateAssetStat(tt.Ctx, assetStat)
Expand Down Expand Up @@ -462,8 +428,6 @@ func TestGetAssetStatDoesNotExist(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

_, err := q.GetAssetStat(tt.Ctx, assetStat.AssetType, assetStat.AssetCode, assetStat.AssetIssuer)
Expand Down Expand Up @@ -493,8 +457,6 @@ func TestRemoveAssetStat(t *testing.T) {
ClaimableBalances: "4",
LiquidityPools: "5",
},
Amount: "1",
NumAccounts: 2,
}

numChanged, err := q.RemoveAssetStat(tt.Ctx,
Expand Down Expand Up @@ -628,8 +590,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "1",
NumAccounts: 2,
},
Contracts: zero,
}
Expand All @@ -650,8 +610,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "23",
NumAccounts: 1,
},
Contracts: zero,
}
Expand All @@ -672,8 +630,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "0",
LiquidityPools: "0",
},
Amount: "1",
NumAccounts: 2,
},
Contracts: zero,
}
Expand All @@ -694,8 +650,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) {
ClaimableBalances: "1",
LiquidityPools: "2",
},
Amount: "111",
NumAccounts: 3,
},
Contracts: ContractStat{
ActiveBalance: "120",
Expand Down
Loading

0 comments on commit a3d1f08

Please sign in to comment.