diff --git a/.gitignore b/.gitignore index c505323c66..8b40766e30 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ /services/horizon/captive-core /services/horizon/horizon /services/horizon/stellar-horizon -/bucket-cache +**bucket-cache/ .vscode .idea debug diff --git a/clients/horizonclient/main_test.go b/clients/horizonclient/main_test.go index f7b4ba0788..b11b807bee 100644 --- a/clients/horizonclient/main_test.go +++ b/clients/horizonclient/main_test.go @@ -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) diff --git a/protocols/horizon/main.go b/protocols/horizon/main.go index df4aee78cf..b25c03eb63 100644 --- a/protocols/horizon/main.go +++ b/protocols/horizon/main.go @@ -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"` @@ -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"` diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index cd5d8af57b..a444771ca6 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -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)) diff --git a/services/horizon/internal/actions/asset_test.go b/services/horizon/internal/actions/asset_test.go index 0e4995d93c..6547a6b853 100644 --- a/services/horizon/internal/actions/asset_test.go +++ b/services/horizon/internal/actions/asset_test.go @@ -139,8 +139,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "10", LiquidityPools: "20", }, - Amount: "1", - NumAccounts: 2, } usdAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -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{ @@ -187,8 +183,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "23", - NumAccounts: 1, } etherAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -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, @@ -234,8 +226,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 2, } otherUSDAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -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, @@ -283,8 +271,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "111", - NumAccounts: 3, } eurAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -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, @@ -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) @@ -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, diff --git a/services/horizon/internal/db2/history/asset_stats.go b/services/horizon/internal/db2/history/asset_stats.go index 622619680b..12e910d533 100644 --- a/services/horizon/internal/db2/history/asset_stats.go +++ b/services/horizon/internal/db2/history/asset_stats.go @@ -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, } } diff --git a/services/horizon/internal/db2/history/asset_stats_test.go b/services/horizon/internal/db2/history/asset_stats_test.go index a8352e4d97..520b480fd6 100644 --- a/services/horizon/internal/db2/history/asset_stats_test.go +++ b/services/horizon/internal/db2/history/asset_stats_test.go @@ -40,8 +40,6 @@ func TestAssetStatContracts(t *testing.T) { LiquidityPools: "0", Unauthorized: "0", }, - Amount: "0", - NumAccounts: 0, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, @@ -59,8 +57,6 @@ func TestAssetStatContracts(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "23", - NumAccounts: 1, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -78,8 +74,6 @@ func TestAssetStatContracts(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, }, } var contractID [32]byte @@ -219,8 +213,6 @@ func TestInsertAssetStats(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, @@ -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)) @@ -276,8 +266,6 @@ func TestInsertAssetStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, @@ -295,8 +283,6 @@ func TestInsertAssetStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "23", - NumAccounts: 1, }, } @@ -333,8 +319,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat) @@ -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) { @@ -380,8 +352,6 @@ func TestUpdateAssetStatDoesNotExistsError(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.UpdateAssetStat(tt.Ctx, assetStat) @@ -415,8 +385,6 @@ func TestUpdateStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat) @@ -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) @@ -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) @@ -493,8 +457,6 @@ func TestRemoveAssetStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.RemoveAssetStat(tt.Ctx, @@ -628,8 +590,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 2, }, Contracts: zero, } @@ -650,8 +610,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "23", - NumAccounts: 1, }, Contracts: zero, } @@ -672,8 +630,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 2, }, Contracts: zero, } @@ -694,8 +650,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "1", LiquidityPools: "2", }, - Amount: "111", - NumAccounts: 3, }, Contracts: ContractStat{ ActiveBalance: "120", diff --git a/services/horizon/internal/db2/history/main.go b/services/horizon/internal/db2/history/main.go index e9d8ffb185..f49d1129c5 100644 --- a/services/horizon/internal/db2/history/main.go +++ b/services/horizon/internal/db2/history/main.go @@ -427,8 +427,6 @@ type ExpAssetStat struct { AssetIssuer string `db:"asset_issuer"` Accounts ExpAssetStatAccounts `db:"accounts"` Balances ExpAssetStatBalances `db:"balances"` - Amount string `db:"amount"` - NumAccounts int32 `db:"num_accounts"` ContractID *[]byte `db:"contract_id"` // make sure to update Equals() when adding new fields to ExpAssetStat } @@ -481,9 +479,7 @@ func (e *ExpAssetStat) Equals(o ExpAssetStat) bool { e.AssetCode == o.AssetCode && e.AssetIssuer == o.AssetIssuer && e.Accounts == o.Accounts && - e.Balances == o.Balances && - e.Amount == o.Amount && - e.NumAccounts == o.NumAccounts + e.Balances == o.Balances } func (e *ExpAssetStat) GetContractID() ([32]byte, bool) { diff --git a/services/horizon/internal/db2/schema/bindata.go b/services/horizon/internal/db2/schema/bindata.go index 3c68f6b2fd..5dd80aec97 100644 --- a/services/horizon/internal/db2/schema/bindata.go +++ b/services/horizon/internal/db2/schema/bindata.go @@ -64,6 +64,7 @@ // migrations/65_drop_payment_index.sql (260B) // migrations/66_contract_asset_stats.sql (583B) // migrations/67_remove_unused_indexes.sql (2.897kB) +// migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql (471B) // migrations/6_create_assets_table.sql (366B) // migrations/7_modify_trades_table.sql (2.303kB) // migrations/8_add_aggregators.sql (907B) @@ -1417,6 +1418,26 @@ func migrations67_remove_unused_indexesSql() (*asset, error) { return a, nil } +var _migrations68_remove_deprecated_fields_from_exp_asset_statsSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\xd0\x4d\x4b\xc4\x30\x18\x04\xe0\x7b\x7e\xc5\xdc\xaa\x48\xa1\xf7\xa2\x10\x9b\xa8\xc5\x98\x4a\x7c\x23\xde\x42\xa8\x45\x0a\xf6\x03\x93\xaa\x3f\x5f\xdc\x0f\xe8\xb2\x4b\x77\x61\xaf\x81\x79\x66\xf2\xa6\x29\xae\xba\xf6\xe3\xcb\xc7\x06\x76\x64\x8c\x2b\x92\x06\xc4\x6f\x95\x44\xf3\x3b\x3a\x1f\x42\x13\x5d\x88\x3e\x06\x08\x53\x3d\xa3\xa8\xf4\x0b\x19\x5e\x6a\xc2\xb7\xff\x6c\xdf\x5d\x3f\x75\xce\xd7\xf5\x30\xf5\x31\xe4\x8b\x00\x03\xb0\x45\x94\x7d\xd2\x38\x23\xea\xbb\xff\x54\xce\xd8\xfc\x03\x62\xf8\xe9\x8f\x2a\x5c\x88\x43\xfd\x28\x35\xc9\x7b\x69\xa0\x2b\x82\xb6\x4a\x41\xc8\x3b\x6e\x15\x21\x3b\x61\xda\x0c\x5d\x2f\x03\xc9\x37\xda\xb7\x92\x64\x19\xdb\x40\x0b\x27\x46\xf1\x20\x8b\x47\x5c\xec\xbc\xdd\x5c\x23\xbb\x5c\xb5\xbd\x72\x55\x8a\x9c\xfd\x05\x00\x00\xff\xff\x7f\x2b\x3e\x4a\xd7\x01\x00\x00") + +func migrations68_remove_deprecated_fields_from_exp_asset_statsSqlBytes() ([]byte, error) { + return bindataRead( + _migrations68_remove_deprecated_fields_from_exp_asset_statsSql, + "migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql", + ) +} + +func migrations68_remove_deprecated_fields_from_exp_asset_statsSql() (*asset, error) { + bytes, err := migrations68_remove_deprecated_fields_from_exp_asset_statsSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8, 0x9f, 0xc8, 0xbb, 0xb3, 0x73, 0xf7, 0x7a, 0x22, 0x14, 0x5f, 0x5a, 0x8a, 0x35, 0x6, 0xf1, 0x92, 0x45, 0xd, 0xe5, 0x75, 0x9, 0x7f, 0xab, 0xec, 0xa8, 0x35, 0xdc, 0xcf, 0x7b, 0x96, 0xde}} + return a, nil +} + var _migrations6_create_assets_tableSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x90\x3d\x4f\xc3\x30\x18\x84\x77\xff\x8a\x1b\x1d\x91\x0e\x20\xe8\x92\xc9\x34\x16\x58\x18\xa7\xb8\x31\xa2\x53\xe5\x26\x16\x78\x80\x54\xb6\x11\xca\xbf\x47\xaa\x28\xf9\x50\xe6\x7b\xf4\xbc\xef\xdd\x6a\x85\xab\x4f\xff\x1e\x6c\x72\x30\x27\xb2\xd1\x9c\xd5\x1c\x35\xbb\x97\x1c\x1f\x3e\xa6\x2e\xf4\x07\x1b\xa3\x4b\x11\x94\x00\x80\x6f\xb1\xe3\x5a\x30\x89\xad\x16\xcf\x4c\xef\xf1\xc4\xf7\xc8\xcf\xd9\x19\x3c\xa4\xfe\xe4\xf0\xca\xf4\xe6\x91\x69\xba\xbe\xcd\xa0\xaa\x1a\xca\x48\x39\x86\x9a\xae\x1d\xa0\xeb\x9b\x65\xc8\xc7\xf8\xed\xc2\x3f\x76\xb7\x9e\x63\x46\x89\x17\xc3\xe9\xa0\xcc\x47\x3f\xe4\x13\x4b\x46\xb2\x82\x5c\xfa\x09\x55\xf2\xb7\xbf\xf8\xd8\x5f\xee\x54\x6a\x5e\xd9\xec\x84\x7a\xc0\x31\x05\xe7\x40\x27\xb6\x82\x90\xf1\x74\x65\xf7\xf3\x45\x4a\x5d\x6d\x97\xa7\x6b\x6c\x6c\x6c\xeb\x8a\xdf\x00\x00\x00\xff\xff\xfb\x53\x3e\x81\x6e\x01\x00\x00") func migrations6_create_assets_tableSqlBytes() ([]byte, error) { @@ -1672,6 +1693,7 @@ var _bindata = map[string]func() (*asset, error){ "migrations/65_drop_payment_index.sql": migrations65_drop_payment_indexSql, "migrations/66_contract_asset_stats.sql": migrations66_contract_asset_statsSql, "migrations/67_remove_unused_indexes.sql": migrations67_remove_unused_indexesSql, + "migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql": migrations68_remove_deprecated_fields_from_exp_asset_statsSql, "migrations/6_create_assets_table.sql": migrations6_create_assets_tableSql, "migrations/7_modify_trades_table.sql": migrations7_modify_trades_tableSql, "migrations/8_add_aggregators.sql": migrations8_add_aggregatorsSql, @@ -1787,6 +1809,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "65_drop_payment_index.sql": {migrations65_drop_payment_indexSql, map[string]*bintree{}}, "66_contract_asset_stats.sql": {migrations66_contract_asset_statsSql, map[string]*bintree{}}, "67_remove_unused_indexes.sql": {migrations67_remove_unused_indexesSql, map[string]*bintree{}}, + "68_remove_deprecated_fields_from_exp_asset_stats.sql": {migrations68_remove_deprecated_fields_from_exp_asset_statsSql, map[string]*bintree{}}, "6_create_assets_table.sql": {migrations6_create_assets_tableSql, map[string]*bintree{}}, "7_modify_trades_table.sql": {migrations7_modify_trades_tableSql, map[string]*bintree{}}, "8_add_aggregators.sql": {migrations8_add_aggregatorsSql, map[string]*bintree{}}, diff --git a/services/horizon/internal/db2/schema/migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql b/services/horizon/internal/db2/schema/migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql new file mode 100644 index 0000000000..691a070274 --- /dev/null +++ b/services/horizon/internal/db2/schema/migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql @@ -0,0 +1,18 @@ +-- +migrate Up + +ALTER TABLE exp_asset_stats DROP CONSTRAINT valid_num_accounts; + +ALTER TABLE exp_asset_stats + DROP COLUMN num_accounts; + +ALTER TABLE exp_asset_stats + DROP COLUMN amount; + +-- +migrate Down +ALTER TABLE exp_asset_stats + ADD COLUMN num_accounts INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE exp_asset_stats + ADD COLUMN amount TEXT NOT NULL DEFAULT ''; + +ALTER TABLE exp_asset_stats ADD CONSTRAINT valid_num_accounts CHECK (num_accounts >= 0) NOT VALID; diff --git a/services/horizon/internal/ingest/processors/asset_stats_processor.go b/services/horizon/internal/ingest/processors/asset_stats_processor.go index 6ae83c3a3c..7e76b509c2 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_processor.go +++ b/services/horizon/internal/ingest/processors/asset_stats_processor.go @@ -305,8 +305,6 @@ func IncludeContractIDsInAssetStats( AssetIssuer: assetIssuer, Accounts: history.ExpAssetStatAccounts{}, Balances: newAssetStatBalance().ConvertToHistoryObject(), - Amount: "0", - NumAccounts: 0, } row.SetContractID(contractID) assetStatsDeltas = append(assetStatsDeltas, row) @@ -456,8 +454,6 @@ func (p *AssetStatsProcessor) updateAssetStats( AssetIssuer: delta.AssetIssuer, Accounts: statAccounts, Balances: statBalances.ConvertToHistoryObject(), - Amount: statBalances.Authorized.String(), - NumAccounts: statAccounts.Authorized, ContractID: delta.ContractID, }) if err != nil { @@ -549,8 +545,6 @@ func (p *AssetStatsProcessor) updateContractID( AssetIssuer: assetIssuer, Accounts: history.ExpAssetStatAccounts{}, Balances: newAssetStatBalance().ConvertToHistoryObject(), - Amount: "0", - NumAccounts: 0, } row.SetContractID(contractID) diff --git a/services/horizon/internal/ingest/processors/asset_stats_processor_test.go b/services/horizon/internal/ingest/processors/asset_stats_processor_test.go index e8080773e8..ea267f6d3e 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_processor_test.go +++ b/services/horizon/internal/ingest/processors/asset_stats_processor_test.go @@ -74,8 +74,6 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, }, }).Return(nil).Once() } @@ -141,8 +139,6 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLineWithClawback() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, }, }).Return(nil).Once() } @@ -179,8 +175,6 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLineUnauthorized() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, }).Return(nil).Once() } @@ -320,8 +314,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalance() { ClaimableBalances: "24", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -343,8 +335,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalance() { ClaimableBalances: "46", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -487,8 +477,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -510,8 +498,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -599,8 +585,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -625,8 +609,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } usdAssetStat.SetContractID(usdID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -932,8 +914,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -974,8 +954,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } usdAssetStat.SetContractID(usdID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -1097,8 +1075,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalanceAndTrustl ClaimableBalances: "12", LiquidityPools: "100", }, - Amount: "9", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -1148,8 +1124,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() eurAssetStat := history.ExpAssetStat{ @@ -1164,8 +1138,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -1309,8 +1281,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() eurAssetStat := history.ExpAssetStat{ @@ -1327,8 +1297,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -1406,8 +1374,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDError() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(usdID) s.mockQ.On("GetAssetStat", s.ctx, @@ -1485,8 +1451,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndContractIDErr ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(usdID) s.mockQ.On("GetAssetStat", s.ctx, @@ -1588,8 +1552,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } s.mockQ.On("GetAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1654,8 +1616,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1669,8 +1629,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "110", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -1805,8 +1763,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1822,8 +1778,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -1844,8 +1798,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1861,8 +1813,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -1883,8 +1833,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1900,8 +1848,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -1978,8 +1924,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { ClaimableBalances: "12", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2006,8 +1950,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { ClaimableBalances: "21", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2021,8 +1963,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -2094,8 +2034,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, }, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2121,8 +2059,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2173,8 +2109,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). @@ -2260,8 +2194,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStat", s.ctx, @@ -2282,8 +2214,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "110", - NumAccounts: 1, } s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { return eurAssetStat.Equals(assetStat) @@ -2332,8 +2262,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDFromZeroRow() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). @@ -2432,8 +2360,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndBalanceZeroR ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). @@ -2524,8 +2450,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndRow() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStat", s.ctx, @@ -2621,8 +2545,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestProcessUpgradeChange() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). diff --git a/services/horizon/internal/ingest/processors/asset_stats_set.go b/services/horizon/internal/ingest/processors/asset_stats_set.go index bc27c2a4ef..9b79e49d82 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_set.go +++ b/services/horizon/internal/ingest/processors/asset_stats_set.go @@ -109,8 +109,6 @@ func (value assetStatValue) ConvertToHistoryObject() history.ExpAssetStat { AssetIssuer: value.assetIssuer, Accounts: value.accounts, Balances: balances, - Amount: balances.Authorized, - NumAccounts: value.accounts.Authorized, } } diff --git a/services/horizon/internal/ingest/processors/asset_stats_set_test.go b/services/horizon/internal/ingest/processors/asset_stats_set_test.go index f9989fdc9e..330a2132ec 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_set_test.go +++ b/services/horizon/internal/ingest/processors/asset_stats_set_test.go @@ -109,8 +109,6 @@ func TestAddAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 1, } assert.NoError( @@ -150,9 +148,7 @@ func TestAddAssetStats(t *testing.T) { ) eurAssetStat.Balances.Authorized = "25" - eurAssetStat.Amount = "25" eurAssetStat.Accounts.Authorized++ - eurAssetStat.NumAccounts++ assertAllEquals(t, set, []history.ExpAssetStat{eurAssetStat}) usd := "USD" @@ -214,8 +210,6 @@ func TestAddAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "3", - NumAccounts: 1, }, eurAssetStat, { @@ -232,8 +226,6 @@ func TestAddAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }, } assertAllEquals(t, set, expected) @@ -270,8 +262,6 @@ func TestOverflowAssetStatSet(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "9223372036854775807", - NumAccounts: 1, } if all[0] != eurAssetStat { t.Fatalf("expected asset stat to be %v but got %v", eurAssetStat, all[0]) @@ -305,8 +295,6 @@ func TestOverflowAssetStatSet(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "18446744073709551614", - NumAccounts: 2, } if all[0] != eurAssetStat { t.Fatalf("expected asset stat to be %v but got %v", eurAssetStat, all[0]) diff --git a/services/horizon/internal/ingest/verify_range_state_test.go b/services/horizon/internal/ingest/verify_range_state_test.go index a1df30d854..f330ba362a 100644 --- a/services/horizon/internal/ingest/verify_range_state_test.go +++ b/services/horizon/internal/ingest/verify_range_state_test.go @@ -568,7 +568,6 @@ func (s *VerifyRangeStateTestSuite) TestSuccessWithVerify() { LiquidityPools: "450", Unauthorized: "0", }, - Amount: "0", }, }, }, nil).Once() @@ -651,8 +650,6 @@ func (s *VerifyRangeStateTestSuite) TestVerifyFailsWhenAssetStatsMismatch() { AuthorizedToMaintainLiabilities: "0", Unauthorized: "123", }, - Amount: "0", - NumAccounts: 0, }, } diff --git a/services/horizon/internal/integration/liquidity_pool_test.go b/services/horizon/internal/integration/liquidity_pool_test.go index 9106003179..bb7e39a7c6 100644 --- a/services/horizon/internal/integration/liquidity_pool_test.go +++ b/services/horizon/internal/integration/liquidity_pool_test.go @@ -156,8 +156,6 @@ func TestLiquidityPoolHappyPath(t *testing.T) { tt.Equal("credit_alphanum4", stat.Asset.Type) tt.Equal("USD", stat.Asset.Code) tt.Equal(master.Address(), stat.Asset.Issuer) - tt.Equal(int32(2), stat.NumAccounts) - tt.Equal("225.0000000", stat.Amount) tt.Equal(int32(1), stat.NumLiquidityPools) tt.Equal("775.0000000", stat.LiquidityPoolsAmount) diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index 7eb91a201c..6356ba9ac5 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -260,9 +260,7 @@ func TestExpirationAndRestoration(t *testing.T) { LiquidityPools: "0", Unauthorized: "0", }, - Amount: "0", - NumAccounts: 0, - ContractID: nil, + ContractID: nil, } syntheticAssetStat.SetContractID(storeContractID) _, err := itest.HorizonIngest().HistoryQ().InsertAssetStat( @@ -1104,9 +1102,7 @@ func assertAssetStats(itest *integration.Test, expected assetStats) { asset := assets.Embedded.Records[0] assert.Equal(itest.CurrentTest(), expected.code, asset.Code) assert.Equal(itest.CurrentTest(), expected.issuer, asset.Issuer) - assert.Equal(itest.CurrentTest(), expected.numAccounts, asset.NumAccounts) assert.Equal(itest.CurrentTest(), expected.numAccounts, asset.Accounts.Authorized) - assert.Equal(itest.CurrentTest(), expected.balanceAccounts, amount.MustParse(asset.Amount)) assert.Equal(itest.CurrentTest(), expected.numContracts, asset.NumContracts) assert.Equal(itest.CurrentTest(), expected.numArchivedContracts, asset.NumArchivedContracts) assert.Equal(itest.CurrentTest(), expected.balanceContracts.String(), parseBalance(itest, asset.ContractsAmount).String()) diff --git a/services/horizon/internal/integration/transaction_preconditions_test.go b/services/horizon/internal/integration/transaction_preconditions_test.go index e3aff9e0da..4bf7a6acb8 100644 --- a/services/horizon/internal/integration/transaction_preconditions_test.go +++ b/services/horizon/internal/integration/transaction_preconditions_test.go @@ -49,20 +49,11 @@ func TestTransactionPreconditionsTimeBounds(t *testing.T) { txHistory, err := itest.Client().TransactionDetail(tx.Hash) assert.NoError(t, err) - // Check that the deprecated string datetime fields match the new UNIX - // timestamp fields. - deprecatedHistoryMinTime, err := time.Parse(time.RFC3339, txHistory.ValidAfter) - assert.NoError(t, err) - deprecatedHistoryMaxTime, err := time.Parse(time.RFC3339, txHistory.ValidBefore) - assert.NoError(t, err) - historyMinTime, err := strconv.ParseInt(txHistory.Preconditions.TimeBounds.MinTime, 10, 64) assert.NoError(t, err) historyMaxTime, err := strconv.ParseInt(txHistory.Preconditions.TimeBounds.MaxTime, 10, 64) assert.NoError(t, err) - assert.Equal(t, historyMinTime, deprecatedHistoryMinTime.UTC().Unix()) - assert.Equal(t, historyMaxTime, deprecatedHistoryMaxTime.UTC().Unix()) assert.Equal(t, historyMinTime, txParams.Preconditions.TimeBounds.MinTime) assert.Equal(t, historyMaxTime, txParams.Preconditions.TimeBounds.MaxTime) } diff --git a/services/horizon/internal/resourceadapter/asset_stat.go b/services/horizon/internal/resourceadapter/asset_stat.go index 994cce99a0..8cc2c12740 100644 --- a/services/horizon/internal/resourceadapter/asset_stat.go +++ b/services/horizon/internal/resourceadapter/asset_stat.go @@ -39,7 +39,6 @@ func PopulateAssetStat( res.NumLiquidityPools = row.Accounts.LiquidityPools res.NumContracts = row.Contracts.ActiveHolders res.NumArchivedContracts = row.Contracts.ArchivedHolders - res.NumAccounts = row.NumAccounts err = populateAssetStatBalances(res, row) if err != nil { return err @@ -63,7 +62,6 @@ func PopulateAssetStat( } func populateAssetStatBalances(res *protocol.AssetStat, row history.AssetAndContractStat) (err error) { - res.Amount, err = amount.IntStringToAmount(row.Balances.Authorized) if err != nil { return errors.Wrap(err, "Invalid amount in PopulateAssetStat") } diff --git a/services/horizon/internal/resourceadapter/asset_stat_test.go b/services/horizon/internal/resourceadapter/asset_stat_test.go index d3b14d62e6..cd3209414d 100644 --- a/services/horizon/internal/resourceadapter/asset_stat_test.go +++ b/services/horizon/internal/resourceadapter/asset_stat_test.go @@ -31,8 +31,6 @@ func TestPopulateExpAssetStat(t *testing.T) { ClaimableBalances: "1200000000000000000", LiquidityPools: "7700000000000000000", }, - Amount: "100000000000000000000", // 10T - NumAccounts: 429, }, Contracts: history.ContractStat{ ActiveBalance: "900000000000000000", @@ -67,8 +65,6 @@ func TestPopulateExpAssetStat(t *testing.T) { assert.Equal(t, "770000000000.0000000", res.LiquidityPoolsAmount) assert.Equal(t, "90000000000.0000000", res.ContractsAmount) assert.Equal(t, "70000000000.0000000", res.ArchivedContractsAmount) - assert.Equal(t, "10000000000000.0000000", res.Amount) - assert.Equal(t, int32(429), res.NumAccounts) assert.Equal(t, horizon.AccountFlags{}, res.Flags) assert.Equal(t, "https://xim.com/.well-known/stellar.toml", res.Links.Toml.Href) assert.Equal(t, "", res.ContractID) @@ -90,8 +86,6 @@ func TestPopulateExpAssetStat(t *testing.T) { assert.Equal(t, "credit_alphanum4", res.Type) assert.Equal(t, "XIM", res.Code) assert.Equal(t, "GBZ35ZJRIKJGYH5PBKLKOZ5L6EXCNTO7BKIL7DAVVDFQ2ODJEEHHJXIM", res.Issuer) - assert.Equal(t, "10000000000000.0000000", res.Amount) - assert.Equal(t, int32(429), res.NumAccounts) assert.Equal( t, horizon.AccountFlags{ diff --git a/services/horizon/internal/resourceadapter/transaction.go b/services/horizon/internal/resourceadapter/transaction.go index f458830c2d..4120c5f564 100644 --- a/services/horizon/internal/resourceadapter/transaction.go +++ b/services/horizon/internal/resourceadapter/transaction.go @@ -4,10 +4,8 @@ import ( "context" "encoding/base64" "fmt" - "strconv" - "time" - "github.com/guregu/null" + "strconv" horizonContext "github.com/stellar/go/services/horizon/internal/context" "github.com/stellar/go/xdr" @@ -66,10 +64,6 @@ func PopulateTransaction( dest.Preconditions = &protocol.TransactionPreconditions{} if !row.TimeBounds.Null { - // Action needed in release: horizon-v3.0.0: remove ValidBefore and ValidAfter - dest.ValidBefore = timeString(row.TimeBounds.Upper) - dest.ValidAfter = timeString(row.TimeBounds.Lower) - dest.Preconditions.TimeBounds = &protocol.TransactionPreconditionsTimebounds{ MaxTime: timestampString(row.TimeBounds.Upper), MinTime: timestampString(row.TimeBounds.Lower), @@ -157,14 +151,6 @@ func memoBytes(envelopeXDR string) (string, error) { return base64.StdEncoding.EncodeToString([]byte(memo)), nil } -func timeString(in null.Int) string { - if !in.Valid { - return "" - } - - return time.Unix(in.Int64, 0).UTC().Format(time.RFC3339) -} - func timestampString(in null.Int) string { if !in.Valid { return "" diff --git a/services/horizon/internal/resourceadapter/transaction_test.go b/services/horizon/internal/resourceadapter/transaction_test.go index 694fc885fb..8ce0fe0271 100644 --- a/services/horizon/internal/resourceadapter/transaction_test.go +++ b/services/horizon/internal/resourceadapter/transaction_test.go @@ -223,8 +223,6 @@ func TestPopulateTransaction_Preconditions(t *testing.T) { assert.NoError(t, PopulateTransaction(ctx, row.TransactionHash, &dest, row, false)) assert.NotEmpty(t, dest.ResultMetaXdr) p := dest.Preconditions - assert.Equal(t, validAfter.Format(time.RFC3339), dest.ValidAfter) - assert.Equal(t, validBefore.Format(time.RFC3339), dest.ValidBefore) assert.Equal(t, fmt.Sprint(validAfter.Unix()), p.TimeBounds.MinTime) assert.Equal(t, fmt.Sprint(validBefore.Unix()), p.TimeBounds.MaxTime) assert.Equal(t, minLedger, p.LedgerBounds.MinLedger) diff --git a/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go b/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go index f26afdae11..a24afb9318 100644 --- a/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go +++ b/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go @@ -45,6 +45,9 @@ func TestSetup_accountAlreadyConfigured(t *testing.T) { HomeDomain: "domain.test.com", Sequence: 10, }, nil) + + dummyAsset := horizon.AssetStat{} + dummyAsset.Asset.Code = "FOO" horizonMock. On("Assets", horizonclient.AssetRequest{ ForAssetCode: opts.AssetCode, @@ -53,9 +56,7 @@ func TestSetup_accountAlreadyConfigured(t *testing.T) { }). Return(horizon.AssetsPage{ Embedded: struct{ Records []horizon.AssetStat }{ - Records: []horizon.AssetStat{ - {Amount: "0.0000001"}, - }, + Records: []horizon.AssetStat{dummyAsset}, }, }, nil) diff --git a/services/ticker/internal/scraper/asset_scraper.go b/services/ticker/internal/scraper/asset_scraper.go index ca7899a25d..0bbc82452a 100644 --- a/services/ticker/internal/scraper/asset_scraper.go +++ b/services/ticker/internal/scraper/asset_scraper.go @@ -23,15 +23,16 @@ import ( // shouldDiscardAsset maps the criteria for discarding an asset from the asset index func shouldDiscardAsset(asset hProtocol.AssetStat, shouldValidateTOML bool) bool { - if asset.Amount == "" { + + if asset.Balances.Authorized == "" { return true } - f, _ := strconv.ParseFloat(asset.Amount, 64) + f, _ := strconv.ParseFloat(asset.Balances.Authorized, 64) if f == 0.0 { return true } // [StellarX Ticker]: assets need at least some adoption to show up - if asset.NumAccounts < 10 { + if asset.Accounts.Authorized < 10 { return true } if asset.Code == "REMOVE" { @@ -39,7 +40,7 @@ func shouldDiscardAsset(asset hProtocol.AssetStat, shouldValidateTOML bool) bool } // [StellarX Ticker]: assets with at least 100 accounts get a pass, // even with toml issues - if asset.NumAccounts >= 100 { + if asset.Accounts.Authorized >= 100 { return false } @@ -150,7 +151,7 @@ func makeFinalAsset( issuer TOMLIssuer, errors []error, ) (t FinalAsset, err error) { - amount, err := strconv.ParseFloat(asset.Amount, 64) + amount, err := strconv.ParseFloat(asset.Balances.Authorized, 64) if err != nil { return } @@ -159,7 +160,7 @@ func makeFinalAsset( Type: asset.Type, Code: asset.Code, Issuer: asset.Issuer, - NumAccounts: asset.NumAccounts, + NumAccounts: asset.Accounts.Authorized, AuthRequired: asset.Flags.AuthRequired, AuthRevocable: asset.Flags.AuthRevocable, Amount: amount, diff --git a/services/ticker/internal/scraper/asset_scraper_test.go b/services/ticker/internal/scraper/asset_scraper_test.go index 39f3e0a2ee..411fa9e528 100644 --- a/services/ticker/internal/scraper/asset_scraper_test.go +++ b/services/ticker/internal/scraper/asset_scraper_test.go @@ -15,63 +15,52 @@ import ( ) func TestShouldDiscardAsset(t *testing.T) { - testAsset := hProtocol.AssetStat{ - Amount: "", - } - + testAsset := hProtocol.AssetStat{} assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "0.0", - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "0", - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "0" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 8, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 0 assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 12, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 12 testAsset.Code = "REMOVE" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 100, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 100 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "" assert.Equal(t, shouldDiscardAsset(testAsset, true), false) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 40, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 40 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "http://www.stellar.org/.well-known/stellar.toml" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 40, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 40 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 40, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 40 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "https://www.stellar.org/.well-known/stellar.toml" assert.Equal(t, shouldDiscardAsset(testAsset, true), false) @@ -154,11 +143,10 @@ func TestProcessAsset_notCached(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, `SIGNING_KEY="not cached signing key"`) })) - asset := hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 100, - } + asset := hProtocol.AssetStat{} asset.Code = "SOMETHINGVALID" + asset.Accounts.Authorized = 1 + asset.Balances.Authorized = "123.4" asset.Links.Toml.Href = server.URL tomlCache := &TOMLCache{} finalAsset, err := processAsset(logger, asset, tomlCache, true) @@ -172,11 +160,10 @@ func TestProcessAsset_notCached(t *testing.T) { func TestProcessAsset_cached(t *testing.T) { logger := log.DefaultLogger - asset := hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 100, - } + asset := hProtocol.AssetStat{} asset.Code = "SOMETHINGVALID" + asset.Accounts.Authorized = 1 + asset.Balances.Authorized = "123.4" asset.Links.Toml.Href = "url" tomlCache := &TOMLCache{} tomlCache.Set("url", TOMLIssuer{SigningKey: "signing key"})