From 3274d0f71fbc702a1c59218a7083d60f4237e0b5 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 20 Apr 2023 13:13:33 +0200 Subject: [PATCH 01/20] all: enforce simplified Golang code (#4852) --- Makefile | 4 +- exp/orderbook/graph_benchmark_test.go | 2 +- exp/orderbook/graph_test.go | 2 +- exp/services/market-tracker/calc_test.go | 26 ++-- exp/services/market-tracker/orders_test.go | 2 +- .../db/dbmigrate/dbmigrate_generated.go | 18 +-- gofmt.sh | 2 +- gogenerate.sh | 2 +- .../db2/history/account_signers_test.go | 4 +- .../internal/db2/history/participants_test.go | 8 +- .../horizon/internal/db2/schema/bindata.go | 130 +++++++++--------- .../internal/test/scenarios/bindata.go | 44 +++--- services/keystore/api.go | 4 +- .../db/dbmigrate/dbmigrate_generated.go | 8 +- .../ticker/internal/gql/static/bindata.go | 4 +- .../ticker/internal/tickerdb/helpers_test.go | 24 ++-- .../internal/tickerdb/migrations/bindata.go | 24 ++-- .../internal/tickerdb/queries_market.go | 20 +-- .../internal/tickerdb/queries_market_test.go | 26 ++-- .../internal/tickerdb/queries_trade_test.go | 18 +-- .../tickerdb/tickerdbtest/tickerdbtest.go | 12 +- 21 files changed, 192 insertions(+), 192 deletions(-) diff --git a/Makefile b/Makefile index ccb01770f5..8d028a527f 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ regulated-assets-approval-server: gxdr/xdr_generated.go: $(XDRS) go run github.com/xdrpp/goxdr/cmd/goxdr -p gxdr -enum-comments -o $@ $(XDRS) - go fmt $@ + gofmt -s -w $@ xdr/%.x: curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-core/master/src/protocol-curr/$@ @@ -46,7 +46,7 @@ xdr/xdr_generated.go: $(XDRS) --namespace xdr \ --output xdr/ \ $(XDRS)' - go fmt $@ + gofmt -s -w $@ xdr: gxdr/xdr_generated.go xdr/xdr_generated.go diff --git a/exp/orderbook/graph_benchmark_test.go b/exp/orderbook/graph_benchmark_test.go index 8588a2f36a..8ad04fd401 100644 --- a/exp/orderbook/graph_benchmark_test.go +++ b/exp/orderbook/graph_benchmark_test.go @@ -268,7 +268,7 @@ func BenchmarkLiquidityPoolExpectations(b *testing.B) { func createRandomAmounts(quantity int) []xdr.Int64 { amounts := make([]xdr.Int64, quantity) - for i, _ := range amounts { + for i := range amounts { amounts[i] = xdr.Int64(1 + rand.Int63n(math.MaxInt64-100)) } return amounts diff --git a/exp/orderbook/graph_test.go b/exp/orderbook/graph_test.go index a839628f8b..6793db49b5 100644 --- a/exp/orderbook/graph_test.go +++ b/exp/orderbook/graph_test.go @@ -166,7 +166,7 @@ func assertGraphEquals(t *testing.T, a, b *OrderBookGraph) { assert.Equalf(t, len(a.liquidityPools), len(b.liquidityPools), "expected same # of liquidity pools but got %v %v", a, b) - for assetString, _ := range a.assetStringToID { + for assetString := range a.assetStringToID { asset := a.assetStringToID[assetString] otherAsset, ok := b.assetStringToID[assetString] if !ok { diff --git a/exp/services/market-tracker/calc_test.go b/exp/services/market-tracker/calc_test.go index 590336af9f..d71d0626f4 100644 --- a/exp/services/market-tracker/calc_test.go +++ b/exp/services/market-tracker/calc_test.go @@ -82,7 +82,7 @@ func TestCalcSpread(t *testing.T) { func TestCalcSpreadPctAtDepth(t *testing.T) { bids := []usdOrder{ - usdOrder{ + { xlmAmount: 100.0, usdAmount: 10.0, usdPrice: 10.0, @@ -134,17 +134,17 @@ func TestCalcBestOrderAtDepth(t *testing.T) { func TestCalcSlippageAtDepth(t *testing.T) { bids := []usdOrder{ - usdOrder{ + { xlmAmount: 1., usdAmount: 30., usdPrice: 30., }, - usdOrder{ + { xlmAmount: 1., usdAmount: 25., usdPrice: 25., }, - usdOrder{ + { xlmAmount: 1., usdAmount: 50., usdPrice: 20., @@ -152,17 +152,17 @@ func TestCalcSlippageAtDepth(t *testing.T) { } asks := []usdOrder{ - usdOrder{ + { xlmAmount: 5., usdAmount: 100., usdPrice: 20., }, - usdOrder{ + { xlmAmount: 4., usdAmount: 100., usdPrice: 25., }, - usdOrder{ + { xlmAmount: 4., usdAmount: 120., usdPrice: 30., @@ -209,17 +209,17 @@ func TestCalcAvgPriceAtDepth(t *testing.T) { func TestCalcFairValuePct(t *testing.T) { bids := []usdOrder{ - usdOrder{ + { xlmAmount: 1., usdAmount: 30., usdPrice: 30., }, - usdOrder{ + { xlmAmount: 1., usdAmount: 25., usdPrice: 25., }, - usdOrder{ + { xlmAmount: 1., usdAmount: 50., usdPrice: 20., @@ -227,17 +227,17 @@ func TestCalcFairValuePct(t *testing.T) { } asks := []usdOrder{ - usdOrder{ + { xlmAmount: 5., usdAmount: 100., usdPrice: 20., }, - usdOrder{ + { xlmAmount: 4., usdAmount: 100., usdPrice: 25., }, - usdOrder{ + { xlmAmount: 4., usdAmount: 120., usdPrice: 30., diff --git a/exp/services/market-tracker/orders_test.go b/exp/services/market-tracker/orders_test.go index 22a13774df..00c363d6b3 100644 --- a/exp/services/market-tracker/orders_test.go +++ b/exp/services/market-tracker/orders_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" ) -var badAmtOrders = []hProtocol.PriceLevel{hProtocol.PriceLevel{ +var badAmtOrders = []hProtocol.PriceLevel{{ PriceR: hProtocol.Price{ N: 4, D: 2, diff --git a/exp/services/recoverysigner/internal/db/dbmigrate/dbmigrate_generated.go b/exp/services/recoverysigner/internal/db/dbmigrate/dbmigrate_generated.go index 0b5322861f..d3af13813e 100644 --- a/exp/services/recoverysigner/internal/db/dbmigrate/dbmigrate_generated.go +++ b/exp/services/recoverysigner/internal/db/dbmigrate/dbmigrate_generated.go @@ -380,15 +380,15 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "migrations": &bintree{nil, map[string]*bintree{ - "20200309000000-initial-1.sql": &bintree{migrations20200309000000Initial1Sql, map[string]*bintree{}}, - "20200309000001-initial-2.sql": &bintree{migrations20200309000001Initial2Sql, map[string]*bintree{}}, - "20200311000000-create-accounts.sql": &bintree{migrations20200311000000CreateAccountsSql, map[string]*bintree{}}, - "20200311000001-create-identities.sql": &bintree{migrations20200311000001CreateIdentitiesSql, map[string]*bintree{}}, - "20200311000002-create-auth-methods.sql": &bintree{migrations20200311000002CreateAuthMethodsSql, map[string]*bintree{}}, - "20200320000000-create-accounts-audit.sql": &bintree{migrations20200320000000CreateAccountsAuditSql, map[string]*bintree{}}, - "20200320000001-create-identities-audit.sql": &bintree{migrations20200320000001CreateIdentitiesAuditSql, map[string]*bintree{}}, - "20200320000002-create-auth-methods-audit.sql": &bintree{migrations20200320000002CreateAuthMethodsAuditSql, map[string]*bintree{}}, + "migrations": {nil, map[string]*bintree{ + "20200309000000-initial-1.sql": {migrations20200309000000Initial1Sql, map[string]*bintree{}}, + "20200309000001-initial-2.sql": {migrations20200309000001Initial2Sql, map[string]*bintree{}}, + "20200311000000-create-accounts.sql": {migrations20200311000000CreateAccountsSql, map[string]*bintree{}}, + "20200311000001-create-identities.sql": {migrations20200311000001CreateIdentitiesSql, map[string]*bintree{}}, + "20200311000002-create-auth-methods.sql": {migrations20200311000002CreateAuthMethodsSql, map[string]*bintree{}}, + "20200320000000-create-accounts-audit.sql": {migrations20200320000000CreateAccountsAuditSql, map[string]*bintree{}}, + "20200320000001-create-identities-audit.sql": {migrations20200320000001CreateIdentitiesAuditSql, map[string]*bintree{}}, + "20200320000002-create-auth-methods-audit.sql": {migrations20200320000002CreateAuthMethodsAuditSql, map[string]*bintree{}}, }}, }} diff --git a/gofmt.sh b/gofmt.sh index f51f2c931c..98b1791261 100755 --- a/gofmt.sh +++ b/gofmt.sh @@ -2,7 +2,7 @@ set -e printf "Running gofmt checks...\n" -OUTPUT=$(gofmt -d .) +OUTPUT=$(gofmt -d -s .) if [[ $OUTPUT ]]; then printf "gofmt found unformatted files:\n\n" diff --git a/gogenerate.sh b/gogenerate.sh index 307b87eecb..cb89037136 100755 --- a/gogenerate.sh +++ b/gogenerate.sh @@ -2,7 +2,7 @@ set -e printf "Running go generate...\n" -go generate ./... && go fmt ./... +go generate ./... && gofmt -s -w -d . printf "Checking for no diff...\n" git diff --exit-code || (echo "Files changed after running go generate. Run go generate ./... locally and update generated files." && exit 1) diff --git a/services/horizon/internal/db2/history/account_signers_test.go b/services/horizon/internal/db2/history/account_signers_test.go index 6e753515ae..158df82409 100644 --- a/services/horizon/internal/db2/history/account_signers_test.go +++ b/services/horizon/internal/db2/history/account_signers_test.go @@ -95,12 +95,12 @@ func TestMultipleAccountsForSigner(t *testing.T) { tt.Assert.Equal(int64(1), rowsAffected) expected := []AccountSigner{ - AccountSigner{ + { Account: account, Signer: signer, Weight: weight, }, - AccountSigner{ + { Account: anotherAccount, Signer: signer, Weight: anotherWeight, diff --git a/services/horizon/internal/db2/history/participants_test.go b/services/horizon/internal/db2/history/participants_test.go index ee37f2b833..4aaf70b151 100644 --- a/services/horizon/internal/db2/history/participants_test.go +++ b/services/horizon/internal/db2/history/participants_test.go @@ -48,10 +48,10 @@ func TestTransactionParticipantsBatch(t *testing.T) { participants := getTransactionParticipants(tt, q) tt.Assert.Equal( []transactionParticipant{ - transactionParticipant{TransactionID: 1, AccountID: 100}, - transactionParticipant{TransactionID: 1, AccountID: 101}, - transactionParticipant{TransactionID: 1, AccountID: 102}, - transactionParticipant{TransactionID: 2, AccountID: 100}, + {TransactionID: 1, AccountID: 100}, + {TransactionID: 1, AccountID: 101}, + {TransactionID: 1, AccountID: 102}, + {TransactionID: 2, AccountID: 100}, }, participants, ) diff --git a/services/horizon/internal/db2/schema/bindata.go b/services/horizon/internal/db2/schema/bindata.go index 1c68c940cc..a0d18c7b76 100644 --- a/services/horizon/internal/db2/schema/bindata.go +++ b/services/horizon/internal/db2/schema/bindata.go @@ -1612,71 +1612,71 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "migrations": &bintree{nil, map[string]*bintree{ - "10_add_trades_price.sql": &bintree{migrations10_add_trades_priceSql, map[string]*bintree{}}, - "11_add_trades_account_index.sql": &bintree{migrations11_add_trades_account_indexSql, map[string]*bintree{}}, - "12_asset_stats_amount_string.sql": &bintree{migrations12_asset_stats_amount_stringSql, map[string]*bintree{}}, - "13_trade_offer_ids.sql": &bintree{migrations13_trade_offer_idsSql, map[string]*bintree{}}, - "14_fix_asset_toml_field.sql": &bintree{migrations14_fix_asset_toml_fieldSql, map[string]*bintree{}}, - "15_ledger_failed_txs.sql": &bintree{migrations15_ledger_failed_txsSql, map[string]*bintree{}}, - "16_ingest_failed_transactions.sql": &bintree{migrations16_ingest_failed_transactionsSql, map[string]*bintree{}}, - "17_transaction_fee_paid.sql": &bintree{migrations17_transaction_fee_paidSql, map[string]*bintree{}}, - "18_account_for_signers.sql": &bintree{migrations18_account_for_signersSql, map[string]*bintree{}}, - "19_offers.sql": &bintree{migrations19_offersSql, map[string]*bintree{}}, - "1_initial_schema.sql": &bintree{migrations1_initial_schemaSql, map[string]*bintree{}}, - "20_account_for_signer_index.sql": &bintree{migrations20_account_for_signer_indexSql, map[string]*bintree{}}, - "21_trades_remove_zero_amount_constraints.sql": &bintree{migrations21_trades_remove_zero_amount_constraintsSql, map[string]*bintree{}}, - "22_trust_lines.sql": &bintree{migrations22_trust_linesSql, map[string]*bintree{}}, - "23_exp_asset_stats.sql": &bintree{migrations23_exp_asset_statsSql, map[string]*bintree{}}, - "24_accounts.sql": &bintree{migrations24_accountsSql, map[string]*bintree{}}, - "25_expingest_rename_columns.sql": &bintree{migrations25_expingest_rename_columnsSql, map[string]*bintree{}}, - "26_exp_history_ledgers.sql": &bintree{migrations26_exp_history_ledgersSql, map[string]*bintree{}}, - "27_exp_history_transactions.sql": &bintree{migrations27_exp_history_transactionsSql, map[string]*bintree{}}, - "28_exp_history_operations.sql": &bintree{migrations28_exp_history_operationsSql, map[string]*bintree{}}, - "29_exp_history_assets.sql": &bintree{migrations29_exp_history_assetsSql, map[string]*bintree{}}, - "2_index_participants_by_toid.sql": &bintree{migrations2_index_participants_by_toidSql, map[string]*bintree{}}, - "30_exp_history_trades.sql": &bintree{migrations30_exp_history_tradesSql, map[string]*bintree{}}, - "31_exp_history_effects.sql": &bintree{migrations31_exp_history_effectsSql, map[string]*bintree{}}, - "32_drop_exp_history_tables.sql": &bintree{migrations32_drop_exp_history_tablesSql, map[string]*bintree{}}, - "33_remove_unused.sql": &bintree{migrations33_remove_unusedSql, map[string]*bintree{}}, - "34_fee_bump_transactions.sql": &bintree{migrations34_fee_bump_transactionsSql, map[string]*bintree{}}, - "35_drop_participant_id.sql": &bintree{migrations35_drop_participant_idSql, map[string]*bintree{}}, - "36_deleted_offers.sql": &bintree{migrations36_deleted_offersSql, map[string]*bintree{}}, - "37_add_tx_set_operation_count_to_ledgers.sql": &bintree{migrations37_add_tx_set_operation_count_to_ledgersSql, map[string]*bintree{}}, - "38_add_constraints.sql": &bintree{migrations38_add_constraintsSql, map[string]*bintree{}}, - "39_claimable_balances.sql": &bintree{migrations39_claimable_balancesSql, map[string]*bintree{}}, - "39_history_trades_indices.sql": &bintree{migrations39_history_trades_indicesSql, map[string]*bintree{}}, - "3_use_sequence_in_history_accounts.sql": &bintree{migrations3_use_sequence_in_history_accountsSql, map[string]*bintree{}}, - "40_fix_inner_tx_max_fee_constraint.sql": &bintree{migrations40_fix_inner_tx_max_fee_constraintSql, map[string]*bintree{}}, - "41_add_sponsor_to_state_tables.sql": &bintree{migrations41_add_sponsor_to_state_tablesSql, map[string]*bintree{}}, - "42_add_num_sponsored_and_num_sponsoring_to_accounts.sql": &bintree{migrations42_add_num_sponsored_and_num_sponsoring_to_accountsSql, map[string]*bintree{}}, - "43_add_claimable_balances_flags.sql": &bintree{migrations43_add_claimable_balances_flagsSql, map[string]*bintree{}}, - "44_asset_stat_accounts_and_balances.sql": &bintree{migrations44_asset_stat_accounts_and_balancesSql, map[string]*bintree{}}, - "45_add_claimable_balances_history.sql": &bintree{migrations45_add_claimable_balances_historySql, map[string]*bintree{}}, - "46_add_muxed_accounts.sql": &bintree{migrations46_add_muxed_accountsSql, map[string]*bintree{}}, - "47_precompute_trade_aggregations.sql": &bintree{migrations47_precompute_trade_aggregationsSql, map[string]*bintree{}}, - "48_rebuild_trade_aggregations.sql": &bintree{migrations48_rebuild_trade_aggregationsSql, map[string]*bintree{}}, - "49_add_brin_index_trade_aggregations.sql": &bintree{migrations49_add_brin_index_trade_aggregationsSql, map[string]*bintree{}}, - "4_add_protocol_version.sql": &bintree{migrations4_add_protocol_versionSql, map[string]*bintree{}}, - "50_liquidity_pools.sql": &bintree{migrations50_liquidity_poolsSql, map[string]*bintree{}}, - "51_remove_ht_unused_indexes.sql": &bintree{migrations51_remove_ht_unused_indexesSql, map[string]*bintree{}}, - "52_add_trade_type_index.sql": &bintree{migrations52_add_trade_type_indexSql, map[string]*bintree{}}, - "53_add_trades_rounding_slippage.sql": &bintree{migrations53_add_trades_rounding_slippageSql, map[string]*bintree{}}, - "54_tx_preconditions_and_account_fields.sql": &bintree{migrations54_tx_preconditions_and_account_fieldsSql, map[string]*bintree{}}, - "55_filter_rules.sql": &bintree{migrations55_filter_rulesSql, map[string]*bintree{}}, - "56_txsub_read_only.sql": &bintree{migrations56_txsub_read_onlySql, map[string]*bintree{}}, - "57_trade_aggregation_autovac.sql": &bintree{migrations57_trade_aggregation_autovacSql, map[string]*bintree{}}, - "58_add_index_by_id_optimization.sql": &bintree{migrations58_add_index_by_id_optimizationSql, map[string]*bintree{}}, - "59_remove_foreign_key_constraints.sql": &bintree{migrations59_remove_foreign_key_constraintsSql, map[string]*bintree{}}, - "5_create_trades_table.sql": &bintree{migrations5_create_trades_tableSql, map[string]*bintree{}}, - "60_add_asset_id_indexes.sql": &bintree{migrations60_add_asset_id_indexesSql, map[string]*bintree{}}, - "61_trust_lines_by_account_type_code_issuer.sql": &bintree{migrations61_trust_lines_by_account_type_code_issuerSql, map[string]*bintree{}}, - "62_claimable_balance_claimants.sql": &bintree{migrations62_claimable_balance_claimantsSql, map[string]*bintree{}}, - "6_create_assets_table.sql": &bintree{migrations6_create_assets_tableSql, map[string]*bintree{}}, - "7_modify_trades_table.sql": &bintree{migrations7_modify_trades_tableSql, map[string]*bintree{}}, - "8_add_aggregators.sql": &bintree{migrations8_add_aggregatorsSql, map[string]*bintree{}}, - "8_create_asset_stats_table.sql": &bintree{migrations8_create_asset_stats_tableSql, map[string]*bintree{}}, - "9_add_header_xdr.sql": &bintree{migrations9_add_header_xdrSql, map[string]*bintree{}}, + "migrations": {nil, map[string]*bintree{ + "10_add_trades_price.sql": {migrations10_add_trades_priceSql, map[string]*bintree{}}, + "11_add_trades_account_index.sql": {migrations11_add_trades_account_indexSql, map[string]*bintree{}}, + "12_asset_stats_amount_string.sql": {migrations12_asset_stats_amount_stringSql, map[string]*bintree{}}, + "13_trade_offer_ids.sql": {migrations13_trade_offer_idsSql, map[string]*bintree{}}, + "14_fix_asset_toml_field.sql": {migrations14_fix_asset_toml_fieldSql, map[string]*bintree{}}, + "15_ledger_failed_txs.sql": {migrations15_ledger_failed_txsSql, map[string]*bintree{}}, + "16_ingest_failed_transactions.sql": {migrations16_ingest_failed_transactionsSql, map[string]*bintree{}}, + "17_transaction_fee_paid.sql": {migrations17_transaction_fee_paidSql, map[string]*bintree{}}, + "18_account_for_signers.sql": {migrations18_account_for_signersSql, map[string]*bintree{}}, + "19_offers.sql": {migrations19_offersSql, map[string]*bintree{}}, + "1_initial_schema.sql": {migrations1_initial_schemaSql, map[string]*bintree{}}, + "20_account_for_signer_index.sql": {migrations20_account_for_signer_indexSql, map[string]*bintree{}}, + "21_trades_remove_zero_amount_constraints.sql": {migrations21_trades_remove_zero_amount_constraintsSql, map[string]*bintree{}}, + "22_trust_lines.sql": {migrations22_trust_linesSql, map[string]*bintree{}}, + "23_exp_asset_stats.sql": {migrations23_exp_asset_statsSql, map[string]*bintree{}}, + "24_accounts.sql": {migrations24_accountsSql, map[string]*bintree{}}, + "25_expingest_rename_columns.sql": {migrations25_expingest_rename_columnsSql, map[string]*bintree{}}, + "26_exp_history_ledgers.sql": {migrations26_exp_history_ledgersSql, map[string]*bintree{}}, + "27_exp_history_transactions.sql": {migrations27_exp_history_transactionsSql, map[string]*bintree{}}, + "28_exp_history_operations.sql": {migrations28_exp_history_operationsSql, map[string]*bintree{}}, + "29_exp_history_assets.sql": {migrations29_exp_history_assetsSql, map[string]*bintree{}}, + "2_index_participants_by_toid.sql": {migrations2_index_participants_by_toidSql, map[string]*bintree{}}, + "30_exp_history_trades.sql": {migrations30_exp_history_tradesSql, map[string]*bintree{}}, + "31_exp_history_effects.sql": {migrations31_exp_history_effectsSql, map[string]*bintree{}}, + "32_drop_exp_history_tables.sql": {migrations32_drop_exp_history_tablesSql, map[string]*bintree{}}, + "33_remove_unused.sql": {migrations33_remove_unusedSql, map[string]*bintree{}}, + "34_fee_bump_transactions.sql": {migrations34_fee_bump_transactionsSql, map[string]*bintree{}}, + "35_drop_participant_id.sql": {migrations35_drop_participant_idSql, map[string]*bintree{}}, + "36_deleted_offers.sql": {migrations36_deleted_offersSql, map[string]*bintree{}}, + "37_add_tx_set_operation_count_to_ledgers.sql": {migrations37_add_tx_set_operation_count_to_ledgersSql, map[string]*bintree{}}, + "38_add_constraints.sql": {migrations38_add_constraintsSql, map[string]*bintree{}}, + "39_claimable_balances.sql": {migrations39_claimable_balancesSql, map[string]*bintree{}}, + "39_history_trades_indices.sql": {migrations39_history_trades_indicesSql, map[string]*bintree{}}, + "3_use_sequence_in_history_accounts.sql": {migrations3_use_sequence_in_history_accountsSql, map[string]*bintree{}}, + "40_fix_inner_tx_max_fee_constraint.sql": {migrations40_fix_inner_tx_max_fee_constraintSql, map[string]*bintree{}}, + "41_add_sponsor_to_state_tables.sql": {migrations41_add_sponsor_to_state_tablesSql, map[string]*bintree{}}, + "42_add_num_sponsored_and_num_sponsoring_to_accounts.sql": {migrations42_add_num_sponsored_and_num_sponsoring_to_accountsSql, map[string]*bintree{}}, + "43_add_claimable_balances_flags.sql": {migrations43_add_claimable_balances_flagsSql, map[string]*bintree{}}, + "44_asset_stat_accounts_and_balances.sql": {migrations44_asset_stat_accounts_and_balancesSql, map[string]*bintree{}}, + "45_add_claimable_balances_history.sql": {migrations45_add_claimable_balances_historySql, map[string]*bintree{}}, + "46_add_muxed_accounts.sql": {migrations46_add_muxed_accountsSql, map[string]*bintree{}}, + "47_precompute_trade_aggregations.sql": {migrations47_precompute_trade_aggregationsSql, map[string]*bintree{}}, + "48_rebuild_trade_aggregations.sql": {migrations48_rebuild_trade_aggregationsSql, map[string]*bintree{}}, + "49_add_brin_index_trade_aggregations.sql": {migrations49_add_brin_index_trade_aggregationsSql, map[string]*bintree{}}, + "4_add_protocol_version.sql": {migrations4_add_protocol_versionSql, map[string]*bintree{}}, + "50_liquidity_pools.sql": {migrations50_liquidity_poolsSql, map[string]*bintree{}}, + "51_remove_ht_unused_indexes.sql": {migrations51_remove_ht_unused_indexesSql, map[string]*bintree{}}, + "52_add_trade_type_index.sql": {migrations52_add_trade_type_indexSql, map[string]*bintree{}}, + "53_add_trades_rounding_slippage.sql": {migrations53_add_trades_rounding_slippageSql, map[string]*bintree{}}, + "54_tx_preconditions_and_account_fields.sql": {migrations54_tx_preconditions_and_account_fieldsSql, map[string]*bintree{}}, + "55_filter_rules.sql": {migrations55_filter_rulesSql, map[string]*bintree{}}, + "56_txsub_read_only.sql": {migrations56_txsub_read_onlySql, map[string]*bintree{}}, + "57_trade_aggregation_autovac.sql": {migrations57_trade_aggregation_autovacSql, map[string]*bintree{}}, + "58_add_index_by_id_optimization.sql": {migrations58_add_index_by_id_optimizationSql, map[string]*bintree{}}, + "59_remove_foreign_key_constraints.sql": {migrations59_remove_foreign_key_constraintsSql, map[string]*bintree{}}, + "5_create_trades_table.sql": {migrations5_create_trades_tableSql, map[string]*bintree{}}, + "60_add_asset_id_indexes.sql": {migrations60_add_asset_id_indexesSql, map[string]*bintree{}}, + "61_trust_lines_by_account_type_code_issuer.sql": {migrations61_trust_lines_by_account_type_code_issuerSql, map[string]*bintree{}}, + "62_claimable_balance_claimants.sql": {migrations62_claimable_balance_claimantsSql, 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{}}, + "8_create_asset_stats_table.sql": {migrations8_create_asset_stats_tableSql, map[string]*bintree{}}, + "9_add_header_xdr.sql": {migrations9_add_header_xdrSql, map[string]*bintree{}}, }}, }} diff --git a/services/horizon/internal/test/scenarios/bindata.go b/services/horizon/internal/test/scenarios/bindata.go index ad319285e8..5ed13e86cb 100644 --- a/services/horizon/internal/test/scenarios/bindata.go +++ b/services/horizon/internal/test/scenarios/bindata.go @@ -688,28 +688,28 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "account_merge-core.sql": &bintree{account_mergeCoreSql, map[string]*bintree{}}, - "account_merge-horizon.sql": &bintree{account_mergeHorizonSql, map[string]*bintree{}}, - "base-core.sql": &bintree{baseCoreSql, map[string]*bintree{}}, - "base-horizon.sql": &bintree{baseHorizonSql, map[string]*bintree{}}, - "failed_transactions-core.sql": &bintree{failed_transactionsCoreSql, map[string]*bintree{}}, - "failed_transactions-horizon.sql": &bintree{failed_transactionsHorizonSql, map[string]*bintree{}}, - "ingest_asset_stats-core.sql": &bintree{ingest_asset_statsCoreSql, map[string]*bintree{}}, - "ingest_asset_stats-horizon.sql": &bintree{ingest_asset_statsHorizonSql, map[string]*bintree{}}, - "kahuna-core.sql": &bintree{kahunaCoreSql, map[string]*bintree{}}, - "kahuna-horizon.sql": &bintree{kahunaHorizonSql, map[string]*bintree{}}, - "offer_ids-core.sql": &bintree{offer_idsCoreSql, map[string]*bintree{}}, - "offer_ids-horizon.sql": &bintree{offer_idsHorizonSql, map[string]*bintree{}}, - "operation_fee_stats_1-core.sql": &bintree{operation_fee_stats_1CoreSql, map[string]*bintree{}}, - "operation_fee_stats_1-horizon.sql": &bintree{operation_fee_stats_1HorizonSql, map[string]*bintree{}}, - "operation_fee_stats_2-core.sql": &bintree{operation_fee_stats_2CoreSql, map[string]*bintree{}}, - "operation_fee_stats_2-horizon.sql": &bintree{operation_fee_stats_2HorizonSql, map[string]*bintree{}}, - "operation_fee_stats_3-core.sql": &bintree{operation_fee_stats_3CoreSql, map[string]*bintree{}}, - "operation_fee_stats_3-horizon.sql": &bintree{operation_fee_stats_3HorizonSql, map[string]*bintree{}}, - "pathed_payment-core.sql": &bintree{pathed_paymentCoreSql, map[string]*bintree{}}, - "pathed_payment-horizon.sql": &bintree{pathed_paymentHorizonSql, map[string]*bintree{}}, - "paths_strict_send-core.sql": &bintree{paths_strict_sendCoreSql, map[string]*bintree{}}, - "paths_strict_send-horizon.sql": &bintree{paths_strict_sendHorizonSql, map[string]*bintree{}}, + "account_merge-core.sql": {account_mergeCoreSql, map[string]*bintree{}}, + "account_merge-horizon.sql": {account_mergeHorizonSql, map[string]*bintree{}}, + "base-core.sql": {baseCoreSql, map[string]*bintree{}}, + "base-horizon.sql": {baseHorizonSql, map[string]*bintree{}}, + "failed_transactions-core.sql": {failed_transactionsCoreSql, map[string]*bintree{}}, + "failed_transactions-horizon.sql": {failed_transactionsHorizonSql, map[string]*bintree{}}, + "ingest_asset_stats-core.sql": {ingest_asset_statsCoreSql, map[string]*bintree{}}, + "ingest_asset_stats-horizon.sql": {ingest_asset_statsHorizonSql, map[string]*bintree{}}, + "kahuna-core.sql": {kahunaCoreSql, map[string]*bintree{}}, + "kahuna-horizon.sql": {kahunaHorizonSql, map[string]*bintree{}}, + "offer_ids-core.sql": {offer_idsCoreSql, map[string]*bintree{}}, + "offer_ids-horizon.sql": {offer_idsHorizonSql, map[string]*bintree{}}, + "operation_fee_stats_1-core.sql": {operation_fee_stats_1CoreSql, map[string]*bintree{}}, + "operation_fee_stats_1-horizon.sql": {operation_fee_stats_1HorizonSql, map[string]*bintree{}}, + "operation_fee_stats_2-core.sql": {operation_fee_stats_2CoreSql, map[string]*bintree{}}, + "operation_fee_stats_2-horizon.sql": {operation_fee_stats_2HorizonSql, map[string]*bintree{}}, + "operation_fee_stats_3-core.sql": {operation_fee_stats_3CoreSql, map[string]*bintree{}}, + "operation_fee_stats_3-horizon.sql": {operation_fee_stats_3HorizonSql, map[string]*bintree{}}, + "pathed_payment-core.sql": {pathed_paymentCoreSql, map[string]*bintree{}}, + "pathed_payment-horizon.sql": {pathed_paymentHorizonSql, map[string]*bintree{}}, + "paths_strict_send-core.sql": {paths_strict_sendCoreSql, map[string]*bintree{}}, + "paths_strict_send-horizon.sql": {paths_strict_sendHorizonSql, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory. diff --git a/services/keystore/api.go b/services/keystore/api.go index f4915f6334..bdce9513cc 100644 --- a/services/keystore/api.go +++ b/services/keystore/api.go @@ -65,8 +65,8 @@ type authResponse struct { } var forwardHeaders = map[string]struct{}{ - "authorization": struct{}{}, - "cookie": struct{}{}, + "authorization": {}, + "cookie": {}, } func authHandler(next http.Handler, authenticator *Authenticator) http.Handler { diff --git a/services/regulated-assets-approval-server/internal/db/dbmigrate/dbmigrate_generated.go b/services/regulated-assets-approval-server/internal/db/dbmigrate/dbmigrate_generated.go index 39efd3c0a8..4b82c3ddd0 100644 --- a/services/regulated-assets-approval-server/internal/db/dbmigrate/dbmigrate_generated.go +++ b/services/regulated-assets-approval-server/internal/db/dbmigrate/dbmigrate_generated.go @@ -270,10 +270,10 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "migrations": &bintree{nil, map[string]*bintree{ - "2021-05-05.0.initial.sql": &bintree{migrations202105050InitialSql, map[string]*bintree{}}, - "2021-05-18.0.accounts-kyc-status.sql": &bintree{migrations202105180AccountsKycStatusSql, map[string]*bintree{}}, - "2021-06-08.0.pending-kyc-status.sql": &bintree{migrations202106080PendingKycStatusSql, map[string]*bintree{}}, + "migrations": {nil, map[string]*bintree{ + "2021-05-05.0.initial.sql": {migrations202105050InitialSql, map[string]*bintree{}}, + "2021-05-18.0.accounts-kyc-status.sql": {migrations202105180AccountsKycStatusSql, map[string]*bintree{}}, + "2021-06-08.0.pending-kyc-status.sql": {migrations202106080PendingKycStatusSql, map[string]*bintree{}}, }}, }} diff --git a/services/ticker/internal/gql/static/bindata.go b/services/ticker/internal/gql/static/bindata.go index 298e85a5d3..31c22760ed 100644 --- a/services/ticker/internal/gql/static/bindata.go +++ b/services/ticker/internal/gql/static/bindata.go @@ -248,8 +248,8 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "graphiql.html": &bintree{graphiqlHtml, map[string]*bintree{}}, - "schema.gql": &bintree{schemaGql, map[string]*bintree{}}, + "graphiql.html": {graphiqlHtml, map[string]*bintree{}}, + "schema.gql": {schemaGql, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory. diff --git a/services/ticker/internal/tickerdb/helpers_test.go b/services/ticker/internal/tickerdb/helpers_test.go index 6c09306636..71f025aa20 100644 --- a/services/ticker/internal/tickerdb/helpers_test.go +++ b/services/ticker/internal/tickerdb/helpers_test.go @@ -70,20 +70,20 @@ func TestGenerateWhereClause(t *testing.T) { *baseAssetIssuer = "baseAssetIssuer" where1, args1 := generateWhereClause([]optionalVar{ - optionalVar{"t1.base_asset_code", nil}, - optionalVar{"t1.base_asset_issuer", nil}, - optionalVar{"t1.counter_asset_code", nil}, - optionalVar{"t1.counter_asset_issuer", nil}, + {"t1.base_asset_code", nil}, + {"t1.base_asset_issuer", nil}, + {"t1.counter_asset_code", nil}, + {"t1.counter_asset_issuer", nil}, }) assert.Equal(t, "", where1) assert.Equal(t, 0, len(args1)) where2, args2 := generateWhereClause([]optionalVar{ - optionalVar{"t1.base_asset_code", baseAssetCode}, - optionalVar{"t1.base_asset_issuer", nil}, - optionalVar{"t1.counter_asset_code", nil}, - optionalVar{"t1.counter_asset_issuer", nil}, + {"t1.base_asset_code", baseAssetCode}, + {"t1.base_asset_issuer", nil}, + {"t1.counter_asset_code", nil}, + {"t1.counter_asset_issuer", nil}, }) assert.Equal(t, "WHERE t1.base_asset_code = ?", where2) @@ -91,10 +91,10 @@ func TestGenerateWhereClause(t *testing.T) { assert.Equal(t, *baseAssetCode, args2[0]) where3, args3 := generateWhereClause([]optionalVar{ - optionalVar{"t1.base_asset_code", baseAssetCode}, - optionalVar{"t1.base_asset_issuer", baseAssetIssuer}, - optionalVar{"t1.counter_asset_code", nil}, - optionalVar{"t1.counter_asset_issuer", nil}, + {"t1.base_asset_code", baseAssetCode}, + {"t1.base_asset_issuer", baseAssetIssuer}, + {"t1.counter_asset_code", nil}, + {"t1.counter_asset_issuer", nil}, }) assert.Equal(t, "WHERE t1.base_asset_code = ? AND t1.base_asset_issuer = ?", where3) diff --git a/services/ticker/internal/tickerdb/migrations/bindata.go b/services/ticker/internal/tickerdb/migrations/bindata.go index c91398d945..c335b6ff5a 100644 --- a/services/ticker/internal/tickerdb/migrations/bindata.go +++ b/services/ticker/internal/tickerdb/migrations/bindata.go @@ -446,18 +446,18 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "migrations": &bintree{nil, map[string]*bintree{ - "20190404184050-initial.sql": &bintree{migrations20190404184050InitialSql, map[string]*bintree{}}, - "20190405112544-increase_asset_code_size.sql": &bintree{migrations20190405112544Increase_asset_code_sizeSql, map[string]*bintree{}}, - "20190408115724-add_new_asset_fields.sql": &bintree{migrations20190408115724Add_new_asset_fieldsSql, map[string]*bintree{}}, - "20190408155841-add_issuers_table.sql": &bintree{migrations20190408155841Add_issuers_tableSql, map[string]*bintree{}}, - "20190409152216-add_trades_table.sql": &bintree{migrations20190409152216Add_trades_tableSql, map[string]*bintree{}}, - "20190409172610-rename_assets_desc_description.sql": &bintree{migrations20190409172610Rename_assets_desc_descriptionSql, map[string]*bintree{}}, - "20190410094830-add_assets_issuer_account_field.sql": &bintree{migrations20190410094830Add_assets_issuer_account_fieldSql, map[string]*bintree{}}, - "20190411165735-data_seed_and_indices.sql": &bintree{migrations20190411165735Data_seed_and_indicesSql, map[string]*bintree{}}, - "20190425110313-add_orderbook_stats.sql": &bintree{migrations20190425110313Add_orderbook_statsSql, map[string]*bintree{}}, - "20190426092321-add_aggregated_orderbook_view.sql": &bintree{migrations20190426092321Add_aggregated_orderbook_viewSql, map[string]*bintree{}}, - "20220909100700-trades_pk_to_bigint.sql": &bintree{migrations20220909100700Trades_pk_to_bigintSql, map[string]*bintree{}}, + "migrations": {nil, map[string]*bintree{ + "20190404184050-initial.sql": {migrations20190404184050InitialSql, map[string]*bintree{}}, + "20190405112544-increase_asset_code_size.sql": {migrations20190405112544Increase_asset_code_sizeSql, map[string]*bintree{}}, + "20190408115724-add_new_asset_fields.sql": {migrations20190408115724Add_new_asset_fieldsSql, map[string]*bintree{}}, + "20190408155841-add_issuers_table.sql": {migrations20190408155841Add_issuers_tableSql, map[string]*bintree{}}, + "20190409152216-add_trades_table.sql": {migrations20190409152216Add_trades_tableSql, map[string]*bintree{}}, + "20190409172610-rename_assets_desc_description.sql": {migrations20190409172610Rename_assets_desc_descriptionSql, map[string]*bintree{}}, + "20190410094830-add_assets_issuer_account_field.sql": {migrations20190410094830Add_assets_issuer_account_fieldSql, map[string]*bintree{}}, + "20190411165735-data_seed_and_indices.sql": {migrations20190411165735Data_seed_and_indicesSql, map[string]*bintree{}}, + "20190425110313-add_orderbook_stats.sql": {migrations20190425110313Add_orderbook_statsSql, map[string]*bintree{}}, + "20190426092321-add_aggregated_orderbook_view.sql": {migrations20190426092321Add_aggregated_orderbook_viewSql, map[string]*bintree{}}, + "20220909100700-trades_pk_to_bigint.sql": {migrations20220909100700Trades_pk_to_bigintSql, map[string]*bintree{}}, }}, }} diff --git a/services/ticker/internal/tickerdb/queries_market.go b/services/ticker/internal/tickerdb/queries_market.go index 8984fcb3eb..d0121cdeac 100644 --- a/services/ticker/internal/tickerdb/queries_market.go +++ b/services/ticker/internal/tickerdb/queries_market.go @@ -23,8 +23,8 @@ func (s *TickerSession) RetrievePartialAggMarkets(ctx context.Context, sqlTrue := new(string) *sqlTrue = "TRUE" optVars := []optionalVar{ - optionalVar{"bAsset.is_valid", sqlTrue}, - optionalVar{"cAsset.is_valid", sqlTrue}, + {"bAsset.is_valid", sqlTrue}, + {"cAsset.is_valid", sqlTrue}, } // parse base and asset codes and add them as SQL parameters @@ -34,8 +34,8 @@ func (s *TickerSession) RetrievePartialAggMarkets(ctx context.Context, return } optVars = append(optVars, []optionalVar{ - optionalVar{"bAsset.code", &bCode}, - optionalVar{"cAsset.code", &cCode}, + {"bAsset.code", &bCode}, + {"cAsset.code", &cCode}, }...) } @@ -70,12 +70,12 @@ func (s *TickerSession) RetrievePartialMarkets(ctx context.Context, *sqlTrue = "TRUE" where, args := generateWhereClause([]optionalVar{ - optionalVar{"bAsset.is_valid", sqlTrue}, - optionalVar{"cAsset.is_valid", sqlTrue}, - optionalVar{"bAsset.code", baseAssetCode}, - optionalVar{"bAsset.issuer_account", baseAssetIssuer}, - optionalVar{"cAsset.code", counterAssetCode}, - optionalVar{"cAsset.issuer_account", counterAssetIssuer}, + {"bAsset.is_valid", sqlTrue}, + {"cAsset.is_valid", sqlTrue}, + {"bAsset.code", baseAssetCode}, + {"bAsset.issuer_account", baseAssetIssuer}, + {"cAsset.code", counterAssetCode}, + {"cAsset.issuer_account", counterAssetIssuer}, }) where += fmt.Sprintf( " AND t.ledger_close_time > now() - interval '%d hours'", diff --git a/services/ticker/internal/tickerdb/queries_market_test.go b/services/ticker/internal/tickerdb/queries_market_test.go index f6be900390..727a659dd7 100644 --- a/services/ticker/internal/tickerdb/queries_market_test.go +++ b/services/ticker/internal/tickerdb/queries_market_test.go @@ -106,7 +106,7 @@ func TestRetrieveMarketData(t *testing.T) { // Now let's create the trades: trades := []Trade{ - Trade{ // XLM_BTC trade + { // XLM_BTC trade HorizonID: "hrzid1", BaseAssetID: xlmAsset.ID, BaseAmount: 100.0, @@ -115,7 +115,7 @@ func TestRetrieveMarketData(t *testing.T) { Price: 0.1, LedgerCloseTime: now, }, - Trade{ // XLM_ETH trade + { // XLM_ETH trade HorizonID: "hrzid3", BaseAssetID: xlmAsset.ID, BaseAmount: 24.0, @@ -124,7 +124,7 @@ func TestRetrieveMarketData(t *testing.T) { Price: 0.92, LedgerCloseTime: oneHourAgo, }, - Trade{ // XLM_ETH trade + { // XLM_ETH trade HorizonID: "hrzid2", BaseAssetID: xlmAsset.ID, BaseAmount: 50.0, @@ -133,7 +133,7 @@ func TestRetrieveMarketData(t *testing.T) { Price: 1.0, LedgerCloseTime: now, }, - Trade{ // XLM_BTC trade + { // XLM_BTC trade HorizonID: "hrzid4", BaseAssetID: xlmAsset.ID, BaseAmount: 50.0, @@ -142,7 +142,7 @@ func TestRetrieveMarketData(t *testing.T) { Price: 0.12, LedgerCloseTime: threeDaysAgo, }, - Trade{ // XLM_ETH trade + { // XLM_ETH trade HorizonID: "hrzid5", BaseAssetID: xlmAsset.ID, BaseAmount: 24.0, @@ -416,7 +416,7 @@ func TestRetrievePartialMarkets(t *testing.T) { // Now let's create the trades: trades := []Trade{ - Trade{ // BTC_ETH trade (ETH is from issuer 1) + { // BTC_ETH trade (ETH is from issuer 1) HorizonID: "hrzid1", BaseAssetID: btcAsset.ID, BaseAmount: 100.0, @@ -425,7 +425,7 @@ func TestRetrievePartialMarkets(t *testing.T) { Price: 0.1, LedgerCloseTime: tenMinutesAgo, }, - Trade{ // BTC_ETH trade (ETH is from issuer 2) + { // BTC_ETH trade (ETH is from issuer 2) HorizonID: "hrzid3", BaseAssetID: btcAsset.ID, BaseAmount: 24.0, @@ -434,7 +434,7 @@ func TestRetrievePartialMarkets(t *testing.T) { Price: 0.92, LedgerCloseTime: now, }, - Trade{ // BTC_ETH trade (ETH is from issuer 1) + { // BTC_ETH trade (ETH is from issuer 1) HorizonID: "hrzid2", BaseAssetID: btcAsset.ID, BaseAmount: 50.0, @@ -443,7 +443,7 @@ func TestRetrievePartialMarkets(t *testing.T) { Price: 1.0, LedgerCloseTime: oneHourAgo, }, - Trade{ // BTC_ETH trade (ETH is from issuer 1) + { // BTC_ETH trade (ETH is from issuer 1) HorizonID: "hrzid4", BaseAssetID: btcAsset.ID, BaseAmount: 50.0, @@ -688,7 +688,7 @@ func Test24hStatsFallback(t *testing.T) { // Now let's create the trades: trades := []Trade{ - Trade{ + { HorizonID: "hrzid1", BaseAssetID: xlmAsset.ID, BaseAmount: 1.0, @@ -697,7 +697,7 @@ func Test24hStatsFallback(t *testing.T) { Price: 0.5, // close price & lowest price LedgerCloseTime: twoDaysAgo, }, - Trade{ // BTC_ETH trade (ETH is from issuer 2) + { // BTC_ETH trade (ETH is from issuer 2) HorizonID: "hrzid2", BaseAssetID: xlmAsset.ID, BaseAmount: 1.0, @@ -795,7 +795,7 @@ func TestPreferAnchorAssetCode(t *testing.T) { // Now let's create the trades: trades := []Trade{ - Trade{ + { HorizonID: "hrzid1", BaseAssetID: xlmAsset.ID, BaseAmount: 1.0, @@ -804,7 +804,7 @@ func TestPreferAnchorAssetCode(t *testing.T) { Price: 0.5, // close price & lowest price LedgerCloseTime: twoDaysAgo, }, - Trade{ // BTC_ETH trade (ETH is from issuer 2) + { // BTC_ETH trade (ETH is from issuer 2) HorizonID: "hrzid2", BaseAssetID: xlmAsset.ID, BaseAmount: 1.0, diff --git a/services/ticker/internal/tickerdb/queries_trade_test.go b/services/ticker/internal/tickerdb/queries_trade_test.go index 3793eaa7a4..c24717261b 100644 --- a/services/ticker/internal/tickerdb/queries_trade_test.go +++ b/services/ticker/internal/tickerdb/queries_trade_test.go @@ -80,13 +80,13 @@ func TestBulkInsertTrades(t *testing.T) { // Now let's create the trades: trades := []Trade{ - Trade{ + { HorizonID: "hrzid1", BaseAssetID: asset1.ID, CounterAssetID: asset2.ID, LedgerCloseTime: time.Now(), }, - Trade{ + { HorizonID: "hrzid2", BaseAssetID: asset2.ID, CounterAssetID: asset1.ID, @@ -193,19 +193,19 @@ func TestGetLastTrade(t *testing.T) { // Now let's create the trades: trades := []Trade{ - Trade{ + { HorizonID: "hrzid2", BaseAssetID: asset2.ID, CounterAssetID: asset1.ID, LedgerCloseTime: oneYearBefore, }, - Trade{ + { HorizonID: "hrzid1", BaseAssetID: asset1.ID, CounterAssetID: asset2.ID, LedgerCloseTime: now, }, - Trade{ + { HorizonID: "hrzid2", BaseAssetID: asset2.ID, CounterAssetID: asset1.ID, @@ -296,25 +296,25 @@ func TestDeleteOldTrades(t *testing.T) { // Now let's create the trades: trades := []Trade{ - Trade{ + { HorizonID: "hrzid1", BaseAssetID: asset1.ID, CounterAssetID: asset2.ID, LedgerCloseTime: now, }, - Trade{ + { HorizonID: "hrzid2", BaseAssetID: asset2.ID, CounterAssetID: asset1.ID, LedgerCloseTime: oneDayAgo, }, - Trade{ + { HorizonID: "hrzid3", BaseAssetID: asset2.ID, CounterAssetID: asset1.ID, LedgerCloseTime: oneMonthAgo, }, - Trade{ + { HorizonID: "hrzid4", BaseAssetID: asset2.ID, CounterAssetID: asset1.ID, diff --git a/services/ticker/internal/tickerdb/tickerdbtest/tickerdbtest.go b/services/ticker/internal/tickerdb/tickerdbtest/tickerdbtest.go index 61de9037fc..0160b409f8 100644 --- a/services/ticker/internal/tickerdb/tickerdbtest/tickerdbtest.go +++ b/services/ticker/internal/tickerdb/tickerdbtest/tickerdbtest.go @@ -128,7 +128,7 @@ func SetupTickerTestSession(t *testing.T, migrationsDir string) (session tickerd // Now let's create the trades: trades := []tickerdb.Trade{ - tickerdb.Trade{ // BTC_ETH trade (ETH is from issuer 1) + { // BTC_ETH trade (ETH is from issuer 1) HorizonID: "hrzid1", BaseAssetID: btcAsset.ID, BaseAmount: 100.0, @@ -137,7 +137,7 @@ func SetupTickerTestSession(t *testing.T, migrationsDir string) (session tickerd Price: 0.1, LedgerCloseTime: tenMinutesAgo, }, - tickerdb.Trade{ // BTC_ETH trade (ETH is from issuer 2) + { // BTC_ETH trade (ETH is from issuer 2) HorizonID: "hrzid3", BaseAssetID: btcAsset.ID, BaseAmount: 24.0, @@ -146,7 +146,7 @@ func SetupTickerTestSession(t *testing.T, migrationsDir string) (session tickerd Price: 0.92, LedgerCloseTime: now, }, - tickerdb.Trade{ // BTC_ETH trade (ETH is from issuer 1) + { // BTC_ETH trade (ETH is from issuer 1) HorizonID: "hrzid2", BaseAssetID: btcAsset.ID, BaseAmount: 50.0, @@ -155,7 +155,7 @@ func SetupTickerTestSession(t *testing.T, migrationsDir string) (session tickerd Price: 1.0, LedgerCloseTime: oneHourAgo, }, - tickerdb.Trade{ // BTC_ETH trade (ETH is from issuer 1) + { // BTC_ETH trade (ETH is from issuer 1) HorizonID: "hrzid4", BaseAssetID: btcAsset.ID, BaseAmount: 50.0, @@ -303,7 +303,7 @@ func SetupTickerTestSession(t *testing.T, migrationsDir string) (session tickerd // Add XLM/BTC trades. trades = []tickerdb.Trade{ - tickerdb.Trade{ + { HorizonID: "hrzid5", BaseAssetID: xlmAsset.ID, BaseAmount: 10.0, @@ -312,7 +312,7 @@ func SetupTickerTestSession(t *testing.T, migrationsDir string) (session tickerd Price: 0.5, // close price & lowest price LedgerCloseTime: tenMinutesAgo, }, - tickerdb.Trade{ + { HorizonID: "hrzid6", BaseAssetID: xlmAsset.ID, BaseAmount: 10.0, From d795eeefe6f17a96d5d917c7906bf612f871d697 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Thu, 27 Apr 2023 18:58:13 +0100 Subject: [PATCH 02/20] Update completed sprint on issue/pr closed (#4857) --- ...pdate-completed-sprint-on-issue-closed.yml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/update-completed-sprint-on-issue-closed.yml diff --git a/.github/workflows/update-completed-sprint-on-issue-closed.yml b/.github/workflows/update-completed-sprint-on-issue-closed.yml new file mode 100644 index 0000000000..8ca1cf26e7 --- /dev/null +++ b/.github/workflows/update-completed-sprint-on-issue-closed.yml @@ -0,0 +1,25 @@ +name: Update CompletedSprint on Issue Closed + +on: + issues: + types: [closed] + pull_request: + types: [closed] + +jobs: + update-completed-sprint: + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.GH_PROJECT_MANAGEMENT_APP_ID }} + private_key: ${{ secrets.GH_PROJECT_MANAGEMENT_APP_PEM }} + - name: Update CompletedSprint on Issue Closed + id: update_completedsprint_on_issue_closed + uses: stellar/actions/update-completed-sprint-on-issue-closed@main + with: + project_name: "Platform Scrum" + field_name: "CompletedSprint" + project_token: ${{ steps.generate_token.outputs.token }} From 35250fe74d30fc47bb07a5d5abcf6223ffb48186 Mon Sep 17 00:00:00 2001 From: Mehmet <119539688+mbsdf@users.noreply.github.com> Date: Tue, 2 May 2023 13:17:21 -0700 Subject: [PATCH 03/20] Bump core image to latest stable release v19.10.0 --- .github/workflows/horizon.yml | 6 +++--- exp/tools/dump-ledger-state/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index 1c2d84a0a0..2854530681 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -34,8 +34,8 @@ jobs: env: HORIZON_INTEGRATION_TESTS_ENABLED: true HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} - PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.9.0-1254.064a2787a.focal - PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.9.0-1254.064a2787a.focal + PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.10.0-1275.bff2c2b37.focal + PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.10.0-1275.bff2c2b37.focal PGHOST: localhost PGPORT: 5432 PGUSER: postgres @@ -108,7 +108,7 @@ jobs: name: Test (and push) verify-range image runs-on: ubuntu-20.04 env: - STELLAR_CORE_VERSION: 19.9.0-1254.064a2787a.focal + STELLAR_CORE_VERSION: 19.10.0-1275.bff2c2b37.focal CAPTIVE_CORE_STORAGE_PATH: /tmp steps: - uses: actions/checkout@v3 diff --git a/exp/tools/dump-ledger-state/Dockerfile b/exp/tools/dump-ledger-state/Dockerfile index 47d51a2813..b4405a5ff8 100644 --- a/exp/tools/dump-ledger-state/Dockerfile +++ b/exp/tools/dump-ledger-state/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:20.04 -ENV STELLAR_CORE_VERSION=19.9.0-1254.064a2787a.focal +ENV STELLAR_CORE_VERSION=19.10.0-1275.bff2c2b37.focal ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl wget gnupg apt-utils From c05dcf64f0ff82f90055f7079b114e58660d966f Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Fri, 19 May 2023 17:18:44 +0100 Subject: [PATCH 04/20] Add a simple test for asset case sorting in ascii (#4876) --- xdr/asset_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xdr/asset_test.go b/xdr/asset_test.go index e1d99d9454..12ecee0875 100644 --- a/xdr/asset_test.go +++ b/xdr/asset_test.go @@ -473,6 +473,16 @@ func TestAssetLessThan(t *testing.T) { assert.False(t, assetIssuerB.LessThan(assetIssuerA)) assert.False(t, assetIssuerB.LessThan(assetIssuerB)) }) + + t.Run("test if codes with upper-case letters are sorted before lower-case letters", func(t *testing.T) { + // All upper-case letters should come before any lower-case ones + assetA, err := NewCreditAsset("B", "GA7NLOF4EHWMJF6DBXXV2H6AYI7IHYWNFZR6R52BYBLY7TE5Q74AIDRA") + require.NoError(t, err) + assetB, err := NewCreditAsset("a", "GA7NLOF4EHWMJF6DBXXV2H6AYI7IHYWNFZR6R52BYBLY7TE5Q74AIDRA") + require.NoError(t, err) + + assert.True(t, assetA.LessThan(assetB)) + }) } func BenchmarkAssetString(b *testing.B) { From 148bf798f4ee1c6df984d766161bbacd9dd7c914 Mon Sep 17 00:00:00 2001 From: urvisavla Date: Fri, 19 May 2023 13:22:26 -0700 Subject: [PATCH 05/20] services/horizon: Suppress Core timeout error (#4860) Suppress Core timeout error when ingestion state machine is in build state. --- services/horizon/internal/app.go | 8 +++ services/horizon/internal/ingest/fsm.go | 52 +++++++++++++++++++ services/horizon/internal/ingest/main.go | 9 ++++ services/horizon/internal/ingest/main_test.go | 5 ++ 4 files changed, 74 insertions(+) diff --git a/services/horizon/internal/app.go b/services/horizon/internal/app.go index 6b9376b759..119e875787 100644 --- a/services/horizon/internal/app.go +++ b/services/horizon/internal/app.go @@ -218,6 +218,14 @@ func (a *App) Paths() paths.Finder { func (a *App) UpdateCoreLedgerState(ctx context.Context) { var next ledger.CoreStatus + // #4446 If the ingestion state machine is in the build state, the query can time out + // because the captive-core buffer may be full. In this case, skip the check. + if a.config.CaptiveCoreToml != nil && + a.config.StellarCoreURL == fmt.Sprintf("http://localhost:%d", a.config.CaptiveCoreToml.HTTPPort) && + a.ingester != nil && a.ingester.GetCurrentState() == ingest.Build { + return + } + logErr := func(err error, msg string) { log.WithStack(err).WithField("err", err.Error()).Error(msg) } diff --git a/services/horizon/internal/ingest/fsm.go b/services/horizon/internal/ingest/fsm.go index a8c5f64d2b..38e3fe9ed7 100644 --- a/services/horizon/internal/ingest/fsm.go +++ b/services/horizon/internal/ingest/fsm.go @@ -30,9 +30,25 @@ func (e ErrReingestRangeConflict) Error() string { return fmt.Sprintf("reingest range overlaps with horizon ingestion, supplied range shouldn't contain ledger %d", e.maximumLedgerSequence) } +type State int + +const ( + None State = iota + Start + Stop + Build + Resume + WaitForCheckpoint + StressTest + VerifyRange + HistoryRange + ReingestHistoryRange +) + type stateMachineNode interface { run(*system) (transition, error) String() string + GetState() State } type transition struct { @@ -105,6 +121,10 @@ func (stopState) String() string { return "stop" } +func (stopState) GetState() State { + return Stop +} + func (stopState) run(s *system) (transition, error) { return stop(), errors.New("Cannot run terminal state") } @@ -117,6 +137,10 @@ func (startState) String() string { return "start" } +func (startState) GetState() State { + return Start +} + func (state startState) run(s *system) (transition, error) { if err := s.historyQ.Begin(); err != nil { return start(), errors.Wrap(err, "Error starting a transaction") @@ -234,6 +258,10 @@ func (b buildState) String() string { return fmt.Sprintf("buildFromCheckpoint(checkpointLedger=%d, skipChecks=%t)", b.checkpointLedger, b.skipChecks) } +func (buildState) GetState() State { + return Build +} + func (b buildState) run(s *system) (transition, error) { var nextFailState = start() if b.stop { @@ -377,6 +405,10 @@ func (r resumeState) String() string { return fmt.Sprintf("resume(latestSuccessfullyProcessedLedger=%d)", r.latestSuccessfullyProcessedLedger) } +func (resumeState) GetState() State { + return Resume +} + func (r resumeState) run(s *system) (transition, error) { if r.latestSuccessfullyProcessedLedger == 0 { return start(), errors.New("unexpected latestSuccessfullyProcessedLedger value") @@ -566,6 +598,10 @@ func (h historyRangeState) String() string { ) } +func (historyRangeState) GetState() State { + return HistoryRange +} + // historyRangeState is used when catching up history data func (h historyRangeState) run(s *system) (transition, error) { if h.fromLedger == 0 || h.toLedger == 0 || @@ -679,6 +715,10 @@ func (h reingestHistoryRangeState) String() string { ) } +func (reingestHistoryRangeState) GetState() State { + return ReingestHistoryRange +} + func (h reingestHistoryRangeState) ingestRange(s *system, fromLedger, toLedger uint32) error { if s.historyQ.GetTx() == nil { return errors.New("expected transaction to be present") @@ -833,6 +873,10 @@ func (waitForCheckpointState) String() string { return "waitForCheckpoint" } +func (waitForCheckpointState) GetState() State { + return WaitForCheckpoint +} + func (waitForCheckpointState) run(*system) (transition, error) { log.Info("Waiting for the next checkpoint...") time.Sleep(10 * time.Second) @@ -854,6 +898,10 @@ func (v verifyRangeState) String() string { ) } +func (verifyRangeState) GetState() State { + return VerifyRange +} + func (v verifyRangeState) run(s *system) (transition, error) { if v.fromLedger == 0 || v.toLedger == 0 || v.fromLedger > v.toLedger { @@ -985,6 +1033,10 @@ func (stressTestState) String() string { return "stressTest" } +func (stressTestState) GetState() State { + return StressTest +} + func (stressTestState) run(s *system) (transition, error) { if err := s.historyQ.Begin(); err != nil { err = errors.Wrap(err, "Error starting a transaction") diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index 735bfc6d34..ab4184202f 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -196,6 +196,7 @@ type System interface { ReingestRange(ledgerRanges []history.LedgerRange, force bool) error BuildGenesisState() error Shutdown() + GetCurrentState() State } type system struct { @@ -228,6 +229,8 @@ type system struct { runStateVerificationOnLedger func(uint32) bool reapOffsets map[string]int64 + + currentState State } func NewSystem(config Config) (System, error) { @@ -292,6 +295,7 @@ func NewSystem(config Config) (System, error) { cancel: cancel, config: config, ctx: ctx, + currentState: None, disableStateVerification: config.DisableStateVerification, historyAdapter: historyAdapter, historyQ: historyQ, @@ -479,6 +483,10 @@ func (s *system) initMetrics() { ) } +func (s *system) GetCurrentState() State { + return s.currentState +} + func (s *system) Metrics() Metrics { return s.metrics } @@ -644,6 +652,7 @@ func (s *system) runStateMachine(cur stateMachineNode) error { panic("unexpected transaction") } + s.currentState = cur.GetState() next, err := cur.run(s) if err != nil { logger := log.WithFields(logpkg.F{ diff --git a/services/horizon/internal/ingest/main_test.go b/services/horizon/internal/ingest/main_test.go index a9d9bb37e5..65c9f47e25 100644 --- a/services/horizon/internal/ingest/main_test.go +++ b/services/horizon/internal/ingest/main_test.go @@ -556,6 +556,11 @@ func (m *mockSystem) BuildGenesisState() error { return args.Error(0) } +func (m *mockSystem) GetCurrentState() State { + args := m.Called() + return args.Get(0).(State) +} + func (m *mockSystem) Shutdown() { m.Called() } From 928281e4b7a4103435dbbb8317363eb6d57f3bff Mon Sep 17 00:00:00 2001 From: stellarsaur <126507441+stellarsaur@users.noreply.github.com> Date: Mon, 22 May 2023 11:43:00 -0700 Subject: [PATCH 06/20] Update CHANGELOG.md for latest release (#4828) --- clients/horizonclient/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clients/horizonclient/CHANGELOG.md b/clients/horizonclient/CHANGELOG.md index ee5cacce2a..aecb94bb9e 100644 --- a/clients/horizonclient/CHANGELOG.md +++ b/clients/horizonclient/CHANGELOG.md @@ -5,6 +5,8 @@ file. This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +## [v11.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v11.0.0) - 2023-03-29 + * Type of `AccountSequence` field in `protocols/horizon.Account` was changed to `int64`. ## [v10.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v10.0.0) - 2022-04-18 From 7a7b1401fcbc6660f4e17b4f447a711a8e2e1b29 Mon Sep 17 00:00:00 2001 From: Mehmet <119539688+mbsdf@users.noreply.github.com> Date: Wed, 31 May 2023 11:02:05 -0700 Subject: [PATCH 07/20] Bump core image to latest release v19.11.0 (#4885) --- .github/workflows/horizon.yml | 6 +++--- exp/tools/dump-ledger-state/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index 2854530681..68fa123de3 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -34,8 +34,8 @@ jobs: env: HORIZON_INTEGRATION_TESTS_ENABLED: true HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} - PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.10.0-1275.bff2c2b37.focal - PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.10.0-1275.bff2c2b37.focal + PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.11.0-1323.7fb6d5e88.focal + PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.11.0-1323.7fb6d5e88.focal PGHOST: localhost PGPORT: 5432 PGUSER: postgres @@ -108,7 +108,7 @@ jobs: name: Test (and push) verify-range image runs-on: ubuntu-20.04 env: - STELLAR_CORE_VERSION: 19.10.0-1275.bff2c2b37.focal + STELLAR_CORE_VERSION: 19.11.0-1323.7fb6d5e88.focal CAPTIVE_CORE_STORAGE_PATH: /tmp steps: - uses: actions/checkout@v3 diff --git a/exp/tools/dump-ledger-state/Dockerfile b/exp/tools/dump-ledger-state/Dockerfile index b4405a5ff8..5b53ae2309 100644 --- a/exp/tools/dump-ledger-state/Dockerfile +++ b/exp/tools/dump-ledger-state/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:20.04 -ENV STELLAR_CORE_VERSION=19.10.0-1275.bff2c2b37.focal +ENV STELLAR_CORE_VERSION=19.11.0-1323.7fb6d5e88.focal ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl wget gnupg apt-utils From b0609969e2b083246cbdbe1915e9c7f29ca3dc20 Mon Sep 17 00:00:00 2001 From: urvisavla Date: Mon, 5 Jun 2023 09:55:42 -0700 Subject: [PATCH 08/20] services/horizon: Protect 'currentState' variable using Mutex to prevent race condition. (#4889) --- services/horizon/internal/ingest/main.go | 8 +++- services/horizon/internal/ingest/main_test.go | 41 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index ab4184202f..dc6dc8dd46 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -230,7 +230,8 @@ type system struct { reapOffsets map[string]int64 - currentState State + currentStateMutex sync.Mutex + currentState State } func NewSystem(config Config) (System, error) { @@ -484,6 +485,8 @@ func (s *system) initMetrics() { } func (s *system) GetCurrentState() State { + s.currentStateMutex.Lock() + defer s.currentStateMutex.Unlock() return s.currentState } @@ -652,7 +655,10 @@ func (s *system) runStateMachine(cur stateMachineNode) error { panic("unexpected transaction") } + s.currentStateMutex.Lock() s.currentState = cur.GetState() + s.currentStateMutex.Unlock() + next, err := cur.run(s) if err != nil { logger := log.WithFields(logpkg.F{ diff --git a/services/horizon/internal/ingest/main_test.go b/services/horizon/internal/ingest/main_test.go index 65c9f47e25..9dd902287c 100644 --- a/services/horizon/internal/ingest/main_test.go +++ b/services/horizon/internal/ingest/main_test.go @@ -5,6 +5,7 @@ import ( "context" "database/sql" "testing" + "time" "github.com/jmoiron/sqlx" "github.com/prometheus/client_golang/prometheus" @@ -242,6 +243,46 @@ func TestMaybeVerifyInternalDBErrCancelOrContextCanceled(t *testing.T) { historyQ.AssertExpectations(t) } +func TestCurrentStateRaceCondition(t *testing.T) { + historyQ := &mockDBQ{} + s := &system{ + historyQ: historyQ, + ctx: context.Background(), + } + + historyQ.On("GetTx").Return(nil) + historyQ.On("Begin").Return(nil) + historyQ.On("Rollback").Return(nil) + historyQ.On("GetLastLedgerIngest", s.ctx).Return(uint32(1), nil) + historyQ.On("GetIngestVersion", s.ctx).Return(CurrentVersion, nil) + + timer := time.NewTimer(2000 * time.Millisecond) + getCh := make(chan bool, 1) + doneCh := make(chan bool, 1) + go func() { + var state = buildState{checkpointLedger: 8, + skipChecks: true, + stop: true} + for range getCh { + _ = s.runStateMachine(state) + } + close(doneCh) + }() + +loop: + for { + s.GetCurrentState() + select { + case <-timer.C: + break loop + default: + } + getCh <- true + } + close(getCh) + <-doneCh +} + type mockDBQ struct { mock.Mock From da99d595db9a8bb9f1843d27717b053ea7150eeb Mon Sep 17 00:00:00 2001 From: urvisavla Date: Tue, 6 Jun 2023 15:24:45 -0700 Subject: [PATCH 09/20] services/horizon: Update default for --captive-core-use-db to true (#4877) * 4856: Update default for --captive-core-use-db to true * Update CHANGELOG.md --- services/horizon/CHANGELOG.md | 5 +++++ services/horizon/internal/flags.go | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index d49fc4f489..43b13be3dc 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -5,6 +5,11 @@ file. This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +### Changes +### Breaking Changes +- Modify the default value of `--captive-core-use-db` to true ([4856](https://github.com/stellar/go/issues/4856)) + - This updates the default behavior of captive core to start in on-disk mode. + - To continue using the previous in-memory mode, explicitly set the `--captive-core-use-db` flag to false ## 2.24.1 diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index e13ff923e6..c2e6cbff4c 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -177,7 +177,7 @@ func Flags() (*Config, support.ConfigOptions) { &support.ConfigOption{ Name: CaptiveCoreConfigUseDB, OptType: types.Bool, - FlagDefault: false, + FlagDefault: true, Required: false, Usage: `when enabled, Horizon ingestion will instruct the captive core invocation to use an external db url for ledger states rather than in memory(RAM).\n @@ -736,9 +736,6 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption if config.StellarCoreDatabaseURL != "" { return fmt.Errorf("Invalid config: --%s passed but --ingest not set. ", StellarCoreDBURLFlagName) } - if config.CaptiveCoreConfigUseDB { - return fmt.Errorf("Invalid config: --%s has been set, but --ingest not set. ", CaptiveCoreConfigUseDB) - } } // Configure log file From 060fd7a5b26cd3196c0561dd94dd2a5443944b19 Mon Sep 17 00:00:00 2001 From: urvisavla Date: Thu, 15 Jun 2023 10:11:42 -0700 Subject: [PATCH 10/20] services/horizon: Improve error handling for when stellar-core crashes (#4893) --- ingest/ledgerbackend/captive_core_backend.go | 21 ++++----- .../captive_core_backend_test.go | 45 ++++++++++++++----- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/ingest/ledgerbackend/captive_core_backend.go b/ingest/ledgerbackend/captive_core_backend.go index deb618cf20..238d91a069 100644 --- a/ingest/ledgerbackend/captive_core_backend.go +++ b/ingest/ledgerbackend/captive_core_backend.go @@ -563,25 +563,26 @@ func (c *CaptiveStellarCore) handleMetaPipeResult(sequence uint32, result metaRe } func (c *CaptiveStellarCore) checkMetaPipeResult(result metaResult, ok bool) error { - // There are 3 types of errors we check for: + // There are 4 error scenarios we check for: // 1. User initiated shutdown by canceling the parent context or calling Close(). - // 2. The stellar core process exited unexpectedly. + // 2. The stellar core process exited unexpectedly with an error message. // 3. Some error was encountered while consuming the ledgers emitted by captive core (e.g. parsing invalid xdr) + // 4. The stellar core process exited unexpectedly without an error message if err := c.stellarCoreRunner.context().Err(); err != nil { // Case 1 - User initiated shutdown by canceling the parent context or calling Close() return err } if !ok || result.err != nil { - if result.err != nil { + exited, err := c.stellarCoreRunner.getProcessExitError() + if exited && err != nil { + // Case 2 - The stellar core process exited unexpectedly with an error message + return errors.Wrap(err, "stellar core exited unexpectedly") + } else if result.err != nil { // Case 3 - Some error was encountered while consuming the ledger stream emitted by captive core. return result.err - } else if exited, err := c.stellarCoreRunner.getProcessExitError(); exited { - // Case 2 - The stellar core process exited unexpectedly - if err == nil { - return errors.Errorf("stellar core exited unexpectedly") - } else { - return errors.Wrap(err, "stellar core exited unexpectedly") - } + } else if exited { + // case 4 - The stellar core process exited unexpectedly without an error message + return errors.Errorf("stellar core exited unexpectedly") } else if !ok { // This case should never happen because the ledger buffer channel can only be closed // if and only if the process exits or the context is canceled. diff --git a/ingest/ledgerbackend/captive_core_backend_test.go b/ingest/ledgerbackend/captive_core_backend_test.go index 7de69db927..25bad26d5f 100644 --- a/ingest/ledgerbackend/captive_core_backend_test.go +++ b/ingest/ledgerbackend/captive_core_backend_test.go @@ -899,6 +899,7 @@ func TestCaptiveGetLedger_ErrReadingMetaResult(t *testing.T) { mockRunner.On("close").Return(nil).Run(func(args mock.Arguments) { cancel() }).Once() + mockRunner.On("getProcessExitError").Return(false, nil) // even if the request to fetch the latest checkpoint succeeds, we should fail at creating the subprocess mockArchive := &historyarchive.MockArchive{} @@ -1084,17 +1085,19 @@ func TestGetLedgerBoundsCheck(t *testing.T) { mockRunner.AssertExpectations(t) } -func TestCaptiveGetLedgerTerminatedUnexpectedly(t *testing.T) { +type GetLedgerTerminatedTestCase struct { + name string + ctx context.Context + ledgers []metaResult + processExited bool + processExitedError error + expectedError string +} + +func CaptiveGetLedgerTerminatedUnexpectedlyTestCases() []GetLedgerTerminatedTestCase { ledger64 := buildLedgerCloseMeta(testLedgerHeader{sequence: uint32(64)}) - for _, testCase := range []struct { - name string - ctx context.Context - ledgers []metaResult - processExited bool - processExitedError error - expectedError string - }{ + return []GetLedgerTerminatedTestCase{ { "stellar core exited unexpectedly without error", context.Background(), @@ -1135,7 +1138,29 @@ func TestCaptiveGetLedgerTerminatedUnexpectedly(t *testing.T) { nil, "meta pipe closed unexpectedly", }, - } { + { + "Parser error while reading from the pipe resulting in stellar-core exit", + context.Background(), + []metaResult{{LedgerCloseMeta: &ledger64}, + {LedgerCloseMeta: nil, err: errors.New("Parser error")}}, + true, + nil, + "Parser error", + }, + { + "stellar core exited unexpectedly with an error resulting in meta pipe closed", + context.Background(), + []metaResult{{LedgerCloseMeta: &ledger64}, + {LedgerCloseMeta: &ledger64, err: errors.New("EOF while decoding")}}, + true, + fmt.Errorf("signal kill"), + "stellar core exited unexpectedly: signal kill", + }, + } +} + +func TestCaptiveGetLedgerTerminatedUnexpectedly(t *testing.T) { + for _, testCase := range CaptiveGetLedgerTerminatedUnexpectedlyTestCases() { t.Run(testCase.name, func(t *testing.T) { metaChan := make(chan metaResult, 100) From 1c1800a2ffc631aaebf7222f3a5e1648aa08b8e0 Mon Sep 17 00:00:00 2001 From: Molly Karcher Date: Thu, 15 Jun 2023 20:19:40 -0400 Subject: [PATCH 11/20] Parse LIMIT_TX_QUEUE_SOURCE_ACCOUNT in core config --- ingest/ledgerbackend/toml.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ingest/ledgerbackend/toml.go b/ingest/ledgerbackend/toml.go index 892363c98b..188c6a56da 100644 --- a/ingest/ledgerbackend/toml.go +++ b/ingest/ledgerbackend/toml.go @@ -88,6 +88,7 @@ type captiveCoreTomlValues struct { UseBucketListDB bool `toml:"EXPERIMENTAL_BUCKETLIST_DB,omitempty"` BucketListDBPageSizeExp *uint `toml:"EXPERIMENTAL_BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT,omitempty"` BucketListDBCutoff *uint `toml:"EXPERIMENTAL_BUCKETLIST_DB_INDEX_CUTOFF,omitempty"` + LimitTxQueueSourceAccount bool `toml:"LIMIT_TX_QUEUE_SOURCE_ACCOUNT,omitempty"` } // QuorumSetIsConfigured returns true if there is a quorum set defined in the configuration. From d2d01d39759f2f315f4af59e4b95700a4def44eb Mon Sep 17 00:00:00 2001 From: Shawn Reuland Date: Tue, 20 Jun 2023 11:58:30 -0700 Subject: [PATCH 12/20] updated changelog for 2.26.0 release notes --- services/horizon/CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index 43b13be3dc..bd535472b8 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -5,12 +5,33 @@ file. This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased + + +## 2.26.0 ### Changes +- Improve error handling for when stellar-core crashes ([4893](https://github.com/stellar/go/pull/4893)) +- Suppress Core timeout error in log output such as `error ticking app: context deadline exceeded` when ingestion state machine is in build state. ([4860](https://github.com/stellar/go/pull/4860)) + + ### Breaking Changes - Modify the default value of `--captive-core-use-db` to true ([4856](https://github.com/stellar/go/issues/4856)) - This updates the default behavior of captive core to start in on-disk mode. - To continue using the previous in-memory mode, explicitly set the `--captive-core-use-db` flag to false +## 2.25.0 + +### Changes + +- Running Horizon with remote captive core is now deprecated ([4826](https://github.com/stellar/go/pull/4826)). +- Add two new configuration variables to control the behavior of state verification ([4821](https://github.com/stellar/go/pull/4821)): + - `--ingest-state-verification-frequency` which specifies the frequency in checkpoints for how often state verification is run + - `--ingest-state-verification-timeout` which specifies a timeout on how long state verification can run + +### Fixes + +* Fix crash in horizon ingestion when running horizon with a remote captive core ([4824](https://github.com/stellar/go/pull/4824)). + + ## 2.24.1 ### Changes From 38dac4eaf3b9ddc4cff6f386e55534190b705ace Mon Sep 17 00:00:00 2001 From: Molly Karcher Date: Fri, 16 Jun 2023 14:38:30 -0400 Subject: [PATCH 13/20] Pinning and updates golang and ubuntu images --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/go.yml | 14 +++++++------- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/horizon-master.yml | 2 +- .github/workflows/horizon-release.yml | 4 ++-- .github/workflows/horizon.yml | 6 +++--- exp/services/recoverysigner/docker/Dockerfile | 4 ++-- exp/services/webauth/docker/Dockerfile | 4 ++-- services/friendbot/docker/Dockerfile | 4 ++-- services/horizon/docker/Dockerfile.dev | 4 ++-- services/horizon/docker/verify-range/Dockerfile | 4 +--- services/horizon/docker/verify-range/start | 4 ++-- .../internal/scripts/check_release_hash/Dockerfile | 2 +- 13 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f0033bba61..9fbf83bbd7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -15,7 +15,7 @@ on: jobs: analyze: name: Analyze - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 795ff54318..84db2f5848 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,7 +9,7 @@ jobs: complete: if: always() needs: [check, build, test] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') run: exit 1 @@ -17,8 +17,8 @@ jobs: check: strategy: matrix: - os: [ubuntu-20.04] - go: [1.20.1] + os: [ubuntu-22.04] + go: ["1.20"] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -37,8 +37,8 @@ jobs: build: strategy: matrix: - os: [ubuntu-20.04] - go: [1.19.6, 1.20.1] + os: [ubuntu-22.04] + go: ["1.19", "1.20"] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -55,8 +55,8 @@ jobs: test: strategy: matrix: - os: [ubuntu-20.04] - go: [1.19.6, 1.20.1] + os: [ubuntu-22.04] + go: ["1.19", "1.20"] pg: [9.6.5, 10] runs-on: ${{ matrix.os }} services: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 4f48b972a2..fbf7423bdb 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -12,7 +12,7 @@ permissions: jobs: golangci: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # version v3.0.2 diff --git a/.github/workflows/horizon-master.yml b/.github/workflows/horizon-master.yml index 556c481b20..e2487a0d64 100644 --- a/.github/workflows/horizon-master.yml +++ b/.github/workflows/horizon-master.yml @@ -8,7 +8,7 @@ jobs: push-state-diff-image: name: Push stellar/ledger-state-diff:{sha,latest} to DockerHub - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/horizon-release.yml b/.github/workflows/horizon-release.yml index aacdcea849..f8dda0ceac 100644 --- a/.github/workflows/horizon-release.yml +++ b/.github/workflows/horizon-release.yml @@ -7,7 +7,7 @@ on: jobs: publish-artifacts: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 name: Upload artifacts to GitHub release steps: - name: Run deprecation tests @@ -22,7 +22,7 @@ jobs: - uses: ./.github/actions/setup-go with: - go-version: 1.20.1 + go-version: "1.20" - name: Check dependencies run: ./gomod.sh diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index 68fa123de3..6f02ce4bd3 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -11,8 +11,8 @@ jobs: name: Integration tests strategy: matrix: - os: [ubuntu-20.04] - go: [1.19.6, 1.20.1] + os: [ubuntu-20.04, ubuntu-22.04] + go: ["1.19", "1.20"] pg: [9.6.5] ingestion-backend: [db, captive-core, captive-core-remote-storage] protocol-version: [19] @@ -106,7 +106,7 @@ jobs: verify-range: name: Test (and push) verify-range image - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 env: STELLAR_CORE_VERSION: 19.11.0-1323.7fb6d5e88.focal CAPTIVE_CORE_STORAGE_PATH: /tmp diff --git a/exp/services/recoverysigner/docker/Dockerfile b/exp/services/recoverysigner/docker/Dockerfile index fed1d7c190..8cd9a72ae6 100644 --- a/exp/services/recoverysigner/docker/Dockerfile +++ b/exp/services/recoverysigner/docker/Dockerfile @@ -1,11 +1,11 @@ -FROM golang:1.19 as build +FROM golang:1.20-bullseye as build ADD . /src/recoverysigner WORKDIR /src/recoverysigner RUN go build -o /bin/recoverysigner ./exp/services/recoverysigner -FROM ubuntu:20.04 +FROM ubuntu:22.04 RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates COPY --from=build /bin/recoverysigner /app/ diff --git a/exp/services/webauth/docker/Dockerfile b/exp/services/webauth/docker/Dockerfile index 4acd1ebf2b..c6bc287d5b 100644 --- a/exp/services/webauth/docker/Dockerfile +++ b/exp/services/webauth/docker/Dockerfile @@ -1,11 +1,11 @@ -FROM golang:1.19 as build +FROM golang:1.20-bullseye as build ADD . /src/webauth WORKDIR /src/webauth RUN go build -o /bin/webauth ./exp/services/webauth -FROM ubuntu:20.04 +FROM ubuntu:22.04 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates COPY --from=build /bin/webauth /app/ diff --git a/services/friendbot/docker/Dockerfile b/services/friendbot/docker/Dockerfile index 24c0ca3120..dc1c74b93f 100644 --- a/services/friendbot/docker/Dockerfile +++ b/services/friendbot/docker/Dockerfile @@ -1,10 +1,10 @@ -FROM golang:1.19.1 as build +FROM golang:1.20-bullseye as build ADD . /src/friendbot WORKDIR /src/friendbot RUN go build -o /bin/friendbot ./services/friendbot -FROM ubuntu:20.04 +FROM ubuntu:22.04 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates COPY --from=build /bin/friendbot /app/ diff --git a/services/horizon/docker/Dockerfile.dev b/services/horizon/docker/Dockerfile.dev index ab0b9cd301..1d1be8d688 100644 --- a/services/horizon/docker/Dockerfile.dev +++ b/services/horizon/docker/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM golang:1.20 AS builder +FROM golang:1.20-bullseye AS builder ARG VERSION="devel" WORKDIR /go/src/github.com/stellar/go @@ -8,7 +8,7 @@ COPY . ./ ENV GOFLAGS="-ldflags=-X=github.com/stellar/go/support/app.version=${VERSION}-(built-from-source)" RUN go install github.com/stellar/go/services/horizon -FROM ubuntu:20.04 +FROM ubuntu:22.04 ARG STELLAR_CORE_VERSION ENV STELLAR_CORE_VERSION=${STELLAR_CORE_VERSION:-*} ENV STELLAR_CORE_BINARY_PATH /usr/bin/stellar-core diff --git a/services/horizon/docker/verify-range/Dockerfile b/services/horizon/docker/verify-range/Dockerfile index 499f86881e..56f8c84796 100644 --- a/services/horizon/docker/verify-range/Dockerfile +++ b/services/horizon/docker/verify-range/Dockerfile @@ -1,6 +1,4 @@ -FROM ubuntu:20.04 - -MAINTAINER Bartek Nowotarski +FROM ubuntu:22.04 ARG STELLAR_CORE_VERSION ENV STELLAR_CORE_VERSION=${STELLAR_CORE_VERSION:-*} diff --git a/services/horizon/docker/verify-range/start b/services/horizon/docker/verify-range/start index 3402670ac2..7d29ab886b 100644 --- a/services/horizon/docker/verify-range/start +++ b/services/horizon/docker/verify-range/start @@ -8,8 +8,8 @@ fi rm -rf "$PGDATA"/* sudo chown -R postgres "$PGDATA" sudo chmod -R 775 "$PGDATA" -sudo -u postgres --preserve-env=PGDATA /usr/lib/postgresql/12/bin/initdb -sudo -u postgres --preserve-env=PGDATA /usr/lib/postgresql/12/bin/pg_ctl start +sudo -u postgres --preserve-env=PGDATA /usr/lib/postgresql/14/bin/initdb +sudo -u postgres --preserve-env=PGDATA /usr/lib/postgresql/14/bin/pg_ctl start sudo -u postgres createdb horizon sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" diff --git a/services/horizon/internal/scripts/check_release_hash/Dockerfile b/services/horizon/internal/scripts/check_release_hash/Dockerfile index a323a4eb6d..b0b1666a41 100644 --- a/services/horizon/internal/scripts/check_release_hash/Dockerfile +++ b/services/horizon/internal/scripts/check_release_hash/Dockerfile @@ -1,5 +1,5 @@ # Change to Go version used in CI or rebuild with --build-arg. -ARG GO_IMAGE=golang:1.19.1 +ARG GO_IMAGE=golang:1.20-bullseye FROM $GO_IMAGE WORKDIR /go/src/github.com/stellar/go From 9e32d8cd82aa7d986e5f06c0f10c92dbb42cc77e Mon Sep 17 00:00:00 2001 From: urvisavla Date: Thu, 22 Jun 2023 10:25:06 -0700 Subject: [PATCH 14/20] services/horizon: Fix ledger endpoint url in HAL (#4928) --- services/horizon/internal/resourceadapter/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/horizon/internal/resourceadapter/root.go b/services/horizon/internal/resourceadapter/root.go index eb2656605d..91a72616ea 100644 --- a/services/horizon/internal/resourceadapter/root.go +++ b/services/horizon/internal/resourceadapter/root.go @@ -46,7 +46,7 @@ func PopulateRoot( dest.Links.AccountTransactions = lb.PagedLink("/accounts/{account_id}/transactions") dest.Links.Assets = lb.Link("/assets{?asset_code,asset_issuer,cursor,limit,order}") dest.Links.Effects = lb.Link("/effects{?cursor,limit,order}") - dest.Links.Ledger = lb.Link("/ledger/{sequence}") + dest.Links.Ledger = lb.Link("/ledgers/{sequence}") dest.Links.Ledgers = lb.Link("/ledgers{?cursor,limit,order}") dest.Links.FeeStats = lb.Link("/fee_stats") dest.Links.Operation = lb.Link("/operations/{id}") From 7aafb6d398ab56e5ca53715cd521f0a2eb151c56 Mon Sep 17 00:00:00 2001 From: urvisavla Date: Mon, 26 Jun 2023 22:18:02 -0700 Subject: [PATCH 15/20] Goreplay middleware (#4932) * tools/goreplay-middleware: Add goreplay middleware * Fix linter errors --------- Co-authored-by: Bartek Nowotarski --- go.mod | 4 +- go.sum | 51 ++++++- support/log/main.go | 5 + tools/goreplay-middleware/CHANGELOG.md | 0 tools/goreplay-middleware/README.md | 1 + tools/goreplay-middleware/main.go | 157 ++++++++++++++++++++++ tools/goreplay-middleware/main_test.go | 49 +++++++ tools/goreplay-middleware/request.go | 99 ++++++++++++++ tools/goreplay-middleware/request_test.go | 86 ++++++++++++ 9 files changed, 445 insertions(+), 7 deletions(-) create mode 100644 tools/goreplay-middleware/CHANGELOG.md create mode 100644 tools/goreplay-middleware/README.md create mode 100644 tools/goreplay-middleware/main.go create mode 100644 tools/goreplay-middleware/main_test.go create mode 100644 tools/goreplay-middleware/request.go create mode 100644 tools/goreplay-middleware/request_test.go diff --git a/go.mod b/go.mod index 4f729a0678..2fc3d7c3ed 100644 --- a/go.mod +++ b/go.mod @@ -59,6 +59,7 @@ require ( cloud.google.com/go/storage v1.10.0 // indirect github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f // indirect github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect + github.com/buger/goreplay v1.3.2 github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/structs v1.0.0 // indirect github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955 // indirect @@ -76,7 +77,7 @@ require ( github.com/jstemmer/go-junit-report v0.9.1 // indirect github.com/klauspost/compress v1.15.0 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect - github.com/kr/pretty v0.1.0 // indirect + github.com/kr/pretty v0.2.0 // indirect github.com/kr/text v0.1.0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect @@ -91,7 +92,6 @@ require ( github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 // indirect github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521 // indirect github.com/sergi/go-diff v0.0.0-20161205080420-83532ca1c1ca // indirect - github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94 // indirect github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431 // indirect github.com/stretchr/objx v0.3.0 // indirect diff --git a/go.sum b/go.sum index c714b5fe83..9da09c79e5 100644 --- a/go.sum +++ b/go.sum @@ -52,6 +52,8 @@ github.com/Masterminds/squirrel v1.5.0 h1:JukIZisrUXadA9pl3rMkjhiamxiB0cXiu+HGp/ github.com/Masterminds/squirrel v1.5.0/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= +github.com/Shopify/sarama v1.26.4/go.mod h1:NbSGBSSndYaIhRcBtY9V0U7AyH+x71bG668AuWys/yU= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/adjust/goautoneg v0.0.0-20150426214442-d788f35a0315 h1:zje9aPr1kQ5nKwjO5MC0S/jehRtNrjfYuLfFRWZH6kY= github.com/adjust/goautoneg v0.0.0-20150426214442-d788f35a0315/go.mod h1:4U522XvlkqOY2AVBUM7ISHODDb6tdB+KAXfGaBDsWts= github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f h1:zvClvFQwU++UpIUBGC8YmDlfhUrweEy1R1Fj1gu5iIM= @@ -60,12 +62,18 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/araddon/gou v0.0.0-20190110011759-c797efecbb61/go.mod h1:ikc1XA58M+Rx7SEbf0bLJCfBkwayZ8T5jBo5FXK8Uz8= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/aws/aws-sdk-go v1.33.2/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.39.5 h1:yoJEE1NJxbpZ3CtPxvOSFJ9ByxiXmBTKk8J+XU5ldtg= github.com/aws/aws-sdk-go v1.39.5/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/bitly/go-hostpool v0.1.0/go.mod h1:4gOCgp6+NZnVqlKyZ/iBZFTAJKembaVENUpMkpg42fw= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/buger/goreplay v1.3.2 h1:MFAStZZCsHMPeN5xJ11rhUtV4ZctFRgzSHTfWSWOJsg= +github.com/buger/goreplay v1.3.2/go.mod h1:EyAKHxJR6K6phd0NaoPETSDbJRB/ogIw3Y15UlSbVBM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -77,6 +85,9 @@ github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnht github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -88,6 +99,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955 h1:gmtGRvSexPU4B1T/yYo0sLOKzER1YT+b4kPxPpm0Ty4= @@ -103,8 +116,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobuffalo/packr v1.12.1 h1:+5u3rqgdhswdYXhrX6DHaO7BM4P8oxrbvgZm9H1cRI4= github.com/gobuffalo/packr v1.12.1/go.mod h1:H2dZhQFqHeZwr/5A/uGQkBp7xYuMGuzXFeKhYdcz5No= @@ -142,6 +156,7 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -161,6 +176,7 @@ github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5 h1:oERTZ1buOUYlpmKaqlO5fYmz8cZ1rYu5DieJzF4ZVmU= github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/gopacket v1.1.20-0.20210429153827-3eaba0894325/go.mod h1:riddUzxTSBpJXk3qBHtYr4qOhFhT6k/1c0E3qkQjQpA= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -195,6 +211,7 @@ github.com/graph-gophers/graphql-go v1.3.0 h1:Eb9x/q6MFpCLz7jBCiP/WTxjSDrYLR1QY4 github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/guregu/null v2.1.3-0.20151024101046-79c5bd36b615+incompatible h1:SZmF1M6CdAm4MmTPYYTG+x9EC8D3FOxUq9S4D37irQg= github.com/guregu/null v2.1.3-0.20151024101046-79c5bd36b615+incompatible/go.mod h1:ePGpQaN9cw0tj45IR5E5ehMvsFlLlQZAkkOXZurJ3NM= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -212,6 +229,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jarcoal/httpmock v0.0.0-20161210151336-4442edb3db31 h1:Aw95BEvxJ3K6o9GGv5ppCd1P8hkeIeEJ30FO+OhOJpM= github.com/jarcoal/httpmock v0.0.0-20161210151336-4442edb3db31/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= +github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= +github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -225,13 +244,16 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.9.8/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -246,6 +268,7 @@ github.com/magiconair/properties v1.5.4 h1:5Y3GEEL4cWijFkb6jtcVs3lX2EWA1ZKq64qu9 github.com/magiconair/properties v1.5.4/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739 h1:ykXz+pRRTibcSjG1yRhpdSHInF8yZY/mfn+Rz2Nd1rE= github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739/go.mod h1:zUx1mhth20V3VKgL5jbd1BSQcW4Fy6Qs4PZvQwRFwzM= +github.com/mattbaird/elastigo v0.0.0-20170123220020-2fe47fd29e4b/go.mod h1:5MWrJXKRQyhQdUCF+vu6U5c4nQpg70vW3eHaU0/AYbU= github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= @@ -270,6 +293,8 @@ github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsq github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.9.0 h1:NOd0BRdOKpPf0SxkL3HxSQOG7rNh+4kl6PHcBPFs7Q0= github.com/pelletier/go-toml v1.9.0/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pierrec/lz4 v2.4.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -288,6 +313,8 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 h1:/K3IL0Z1quvmJ7X0A1AwNEK7CRkVK3YwfOU/QAL4WGg= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00 h1:8DPul/X0IT/1TNMIxoKLwdemEOBBHDC/K4EB16Cw5WE= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= @@ -306,8 +333,8 @@ github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94 h1:JmfC365KywYwHB946TTiQWEb8kqPY+pybPLoGE9GgVk= github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= github.com/spf13/cobra v0.0.0-20160830174925-9c28e4bbd74e h1:YdP6GKJS0Ls++kXc85WCCX2ArKToqixBwpBrWP/5J/k= @@ -340,6 +367,11 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= +github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= +github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xdrpp/goxdr v0.1.1 h1:E1B2c6E8eYhOVyd7yEpOyopzTPirUeF6mVOfXfGyJyc= github.com/xdrpp/goxdr v0.1.1/go.mod h1:dXo1scL/l6s7iME1gxHWo2XCppbHEKZS7m/KyYWkNzA= github.com/xeipuuv/gojsonpointer v0.0.0-20151027082146-e0fe6f683076 h1:KM4T3G70MiR+JtqplcYkNVoNz7pDwYaBxWBXQK804So= @@ -376,6 +408,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -498,6 +531,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -507,6 +541,7 @@ golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -731,8 +766,9 @@ google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/l google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -740,6 +776,11 @@ gopkg.in/gavv/httpexpect.v1 v1.0.0-20170111145843-40724cf1e4a0 h1:r5ptJ1tBxVAeqw gopkg.in/gavv/httpexpect.v1 v1.0.0-20170111145843-40724cf1e4a0/go.mod h1:WtiW9ZA1LdaWqtQRo1VbIL/v4XZ8NDta+O/kSpGgVek= gopkg.in/gorp.v1 v1.7.1 h1:GBB9KrWRATQZh95HJyVGUZrWwOPswitEYEyqlK8JbAA= gopkg.in/gorp.v1 v1.7.1/go.mod h1:Wo3h+DBQZIxATwftsglhdD/62zRFPhGhTiu5jUJmCaw= +gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= +gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q= +gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= +gopkg.in/jcmturner/gokrb5.v7 v7.5.0/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= +gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= gopkg.in/square/go-jose.v2 v2.4.1 h1:H0TmLt7/KmzlrDOpa1F+zr0Tk90PbJYBfsVUmRLrf9Y= gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= diff --git a/support/log/main.go b/support/log/main.go index b27472246c..ce5f80cc04 100644 --- a/support/log/main.go +++ b/support/log/main.go @@ -2,6 +2,7 @@ package log import ( "context" + "io" "os" "github.com/segmentio/go-loggly" @@ -80,6 +81,10 @@ func SetLevel(level logrus.Level) { DefaultLogger.SetLevel(level) } +func SetOut(out io.Writer) { + DefaultLogger.entry.Logger.Out = out +} + func WithField(key string, value interface{}) *Entry { result := DefaultLogger.WithField(key, value) return result diff --git a/tools/goreplay-middleware/CHANGELOG.md b/tools/goreplay-middleware/CHANGELOG.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/goreplay-middleware/README.md b/tools/goreplay-middleware/README.md new file mode 100644 index 0000000000..87ebde01f4 --- /dev/null +++ b/tools/goreplay-middleware/README.md @@ -0,0 +1 @@ +# goreplay-middleware \ No newline at end of file diff --git a/tools/goreplay-middleware/main.go b/tools/goreplay-middleware/main.go new file mode 100644 index 0000000000..89e1e23a73 --- /dev/null +++ b/tools/goreplay-middleware/main.go @@ -0,0 +1,157 @@ +// The code below is a goreplay middleware used for regression testing current +// vs next Horizon version. The middleware system of goreplay is rather simple: +// it streams one of 3 message types to stdin: request (HTTP headers), +// original response and replayed response. On request we can modify the request +// and send it to stdout but we don't use this feature here: we send request +// to mirroring target as is. Finally, everything printed to stderr is the +// middleware log, this is where we put the information about the request if the +// diff is found. +// +// More information and diagrams about the middlewares can be found here: +// https://github.com/buger/goreplay/wiki/Middleware +package main + +import ( + "bufio" + "bytes" + "encoding/hex" + "fmt" + "io" + "os" + "time" + + "github.com/buger/goreplay/proto" + "github.com/stellar/go/support/log" +) + +// maxPerSecond defines how many requests should be checked at max per second +const maxPerSecond = 100 + +const ( + requestType byte = '1' + originalResponseType byte = '2' + replayedResponseType byte = '3' +) + +var lastCheck = time.Now() +var reqsCheckedPerSeq = 0 +var pendingRequestsAdded, ignoredCount, diffsCount, okCount int64 +var pendingRequests = make(map[string]*Request) + +func main() { + processAll(os.Stdin, os.Stderr, os.Stdout) +} + +func processAll(stdin io.Reader, stderr, stdout io.Writer) { + log.SetOut(stderr) + log.SetLevel(log.InfoLevel) + + bufSize := 20 * 1024 * 1024 // 20MB + scanner := bufio.NewScanner(stdin) + buf := make([]byte, bufSize) + scanner.Buffer(buf, bufSize) + var maxPendingRequests = 2000 + + for scanner.Scan() { + encoded := scanner.Bytes() + buf := make([]byte, len(encoded)/2) + _, err := hex.Decode(buf, encoded) + if err != nil { + os.Stderr.WriteString(fmt.Sprintf("hex.Decode error: %v", err)) + continue + } + + if err := scanner.Err(); err != nil { + os.Stderr.WriteString(fmt.Sprintf("scanner.Err(): %v\n", err)) + } + + process(stderr, stdout, buf) + + if len(pendingRequests) > maxPendingRequests { + // Around 3-4% of responses is lost (not sure why) so pendingRequests can grow + // indefinitely. Let's just truncate it when it becomes too big. + // There is one gotcha here. Goreplay will still send requests + // (`1` type payloads) even if traffic is rate limited. So if rate + // limit is applied even more requests can be lost. So we should + // use rate limiting implemented here when using middleware rather than + // Goreplay's rate limit. + pendingRequests = make(map[string]*Request) + } + } +} + +func process(stderr, stdout io.Writer, buf []byte) { + // First byte indicate payload type: + payloadType := buf[0] + headerSize := bytes.IndexByte(buf, '\n') + 1 + header := buf[:headerSize-1] + + // Header contains space separated values of: request type, request id, and request start time (or round-trip time for responses) + meta := bytes.Split(header, []byte(" ")) + // For each request you should receive 3 payloads (request, response, replayed response) with same request id + reqID := string(meta[1]) + payload := buf[headerSize:] + + switch payloadType { + case requestType: + if time.Since(lastCheck) > time.Second { + reqsCheckedPerSeq = 0 + lastCheck = time.Now() + + // Print stats every second + _, _ = os.Stderr.WriteString(fmt.Sprintf( + "middleware stats: pendingRequests=%d requestsAdded=%d ok=%d diffs=%d ignored=%d\n", + len(pendingRequests), + pendingRequestsAdded, + okCount, + diffsCount, + ignoredCount, + )) + } + + if reqsCheckedPerSeq < maxPerSecond { + pendingRequests[reqID] = &Request{ + Headers: payload, + } + pendingRequestsAdded++ + reqsCheckedPerSeq++ + } + + // Emitting data back, without modification + _, err := io.WriteString(stdout, hex.EncodeToString(buf)+"\n") + if err != nil { + _, _ = io.WriteString(stderr, fmt.Sprintf("stdout.WriteString error: %v", err)) + } + case originalResponseType: + if req, ok := pendingRequests[reqID]; ok { + // Original response can arrive after mirrored so this should be improved + // instead of ignoring this case. + req.OriginalResponse = payload + } + case replayedResponseType: + if req, ok := pendingRequests[reqID]; ok { + req.MirroredResponse = payload + + if req.IsIgnored() { + ignoredCount++ + } else { + if !req.ResponseEquals() { + // TODO in the future publish the results to S3 for easier processing + log.WithFields(log.F{ + "expected": req.OriginalBody(), + "actual": req.MirroredBody(), + "headers": string(req.Headers), + "path": string(proto.Path(req.Headers)), + }).Info("Mismatch found") + diffsCount++ + } else { + okCount++ + } + } + + delete(pendingRequests, reqID) + } + default: + _, _ = io.WriteString(stderr, "Unknown message type\n") + } +} diff --git a/tools/goreplay-middleware/main_test.go b/tools/goreplay-middleware/main_test.go new file mode 100644 index 0000000000..42cbcafd13 --- /dev/null +++ b/tools/goreplay-middleware/main_test.go @@ -0,0 +1,49 @@ +package main + +import ( + "bytes" + "encoding/hex" + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestProcess(t *testing.T) { + // For 1 type, it returns the same msg to stdout + payload := "1 ID\nGET /ledgers HTTP/1.1\r\nHost: horizon.stellar.org\r\n\r\n" + stdin := strings.NewReader(hex.EncodeToString([]byte(payload))) + + stdout := bytes.Buffer{} + stderr := bytes.Buffer{} + processAll(stdin, &stderr, &stdout) + + decodedOut, err := hex.DecodeString(strings.TrimRight(stdout.String(), "\n")) + assert.NoError(t, err) + assert.Equal(t, payload, string(decodedOut)) + assert.Equal(t, "", stderr.String()) + + // For 2 type, save the original response + payload = "2 ID\nHeader: true\r\n\r\nBody" + stdin = strings.NewReader(hex.EncodeToString([]byte(payload))) + + stdout = bytes.Buffer{} + stderr = bytes.Buffer{} + processAll(stdin, &stderr, &stdout) + + assert.Len(t, pendingRequests, 1) + assert.Equal(t, "", stdout.String()) + assert.Equal(t, "", stderr.String()) + + // For 2 type, save the original response + payload = "3 ID\nHeader: true\r\n\r\nBody" + stdin = strings.NewReader(hex.EncodeToString([]byte(payload))) + + stdout = bytes.Buffer{} + stderr = bytes.Buffer{} + processAll(stdin, &stderr, &stdout) + + assert.Len(t, pendingRequests, 0) + assert.Equal(t, "", stdout.String()) + assert.Equal(t, "", stderr.String()) +} diff --git a/tools/goreplay-middleware/request.go b/tools/goreplay-middleware/request.go new file mode 100644 index 0000000000..165971f725 --- /dev/null +++ b/tools/goreplay-middleware/request.go @@ -0,0 +1,99 @@ +package main + +import ( + "bytes" + "regexp" + "strings" + + "github.com/buger/goreplay/proto" +) + +var horizonURLs = regexp.MustCompile(`https:\/\/.*?(stellar\.org|127.0.0.1:8000)`) +var findResultMetaXDR = regexp.MustCompile(`"result_meta_xdr":[ ]?"([^"]*)",`) + +// removeRegexps contains a list of regular expressions that, when matched, +// will be changed to an empty string. This is done to exclude known +// differences in responses between two Horizon version. +// +// Let's say that next Horizon version adds a new bool field: +// `is_authorized` on account balances list. You want to remove this +// field so it's not reported for each `/accounts/{id}` response. +var removeRegexps = []*regexp.Regexp{} + +type replace struct { + regexp *regexp.Regexp + repl string +} + +// replaceRegexps works like removeRegexps but replaces data +var replaceRegexps = []replace{} + +type Request struct { + Headers []byte + OriginalResponse []byte + MirroredResponse []byte +} + +func (r *Request) OriginalBody() string { + return string(proto.Body(r.OriginalResponse)) +} + +func (r *Request) MirroredBody() string { + return string(proto.Body(r.MirroredResponse)) +} + +func (r *Request) IsIgnored() bool { + if len(r.OriginalResponse) == 0 { + return true + } + + originalLatestLedgerHeader := proto.Header(r.OriginalResponse, []byte("Latest-Ledger")) + mirroredLatestLedgerHeader := proto.Header(r.MirroredResponse, []byte("Latest-Ledger")) + + if !bytes.Equal(originalLatestLedgerHeader, mirroredLatestLedgerHeader) { + return true + } + + // Responses below are not supported but support can be added with some effort + originalTransferEncodingHeader := proto.Header(r.OriginalResponse, []byte("Transfer-Encoding")) + mirroredTransferEncodingHeader := proto.Header(r.MirroredResponse, []byte("Transfer-Encoding")) + if len(originalTransferEncodingHeader) > 0 || + len(mirroredTransferEncodingHeader) > 0 { + return true + } + + acceptEncodingHeader := proto.Header(r.Headers, []byte("Accept-Encoding")) + if strings.Contains(string(acceptEncodingHeader), "gzip") { + return true + } + + acceptHeader := proto.Header(r.Headers, []byte("Accept")) + return strings.Contains(string(acceptHeader), "event-stream") +} + +func (r *Request) ResponseEquals() bool { + originalBody := proto.Body(r.OriginalResponse) + mirroredBody := proto.Body(r.MirroredResponse) + + return normalizeResponseBody(originalBody) == normalizeResponseBody(mirroredBody) +} + +// normalizeResponseBody normalizes body to allow byte-byte comparison like removing +// URLs from _links or tx meta. May require updating on new releases. +func normalizeResponseBody(body []byte) string { + normalizedBody := string(body) + // `result_meta_xdr` can differ between core instances (confirmed this with core team) + normalizedBody = findResultMetaXDR.ReplaceAllString(normalizedBody, "") + // Remove Horizon URL from the _links + normalizedBody = horizonURLs.ReplaceAllString(normalizedBody, "") + + for _, reg := range removeRegexps { + normalizedBody = reg.ReplaceAllString(normalizedBody, "") + } + + for _, reg := range replaceRegexps { + normalizedBody = reg.regexp.ReplaceAllString(normalizedBody, reg.repl) + } + + return normalizedBody +} diff --git a/tools/goreplay-middleware/request_test.go b/tools/goreplay-middleware/request_test.go new file mode 100644 index 0000000000..3ba2072096 --- /dev/null +++ b/tools/goreplay-middleware/request_test.go @@ -0,0 +1,86 @@ +package main + +import ( + "testing" +) + +func TestNormalizeResponseBody(t *testing.T) { + //nolint:all + resp := `{ + "_links": { + "self": { + "href": "https://horizon-testnet.stellar.org/transactions?cursor=\u0026limit=1\u0026order=desc" + }, + "next": { + "href": "https://horizon-testnet.stellar.org/transactions?cursor=2892102128111616\u0026limit=1\u0026order=desc" + }, + "prev": { + "href": "https://horizon-testnet.stellar.org/transactions?cursor=2892102128111616\u0026limit=1\u0026order=asc" + } + }, + "_embedded": { + "records": [ + { + "_links": { + "self": { + "href": "https://horizon-testnet.stellar.org/transactions/cfc6395b98ed0c5ad63bd808e6b5ec994c3ccc67814945d3c652659b5077da18" + }, + "account": { + "href": "https://horizon-testnet.stellar.org/accounts/GBW7BTQDKVMB62NXB3Z55NZCENRBD4O4OE7YBKBOG4K4DM4QK76L2DJD" + }, + "ledger": { + "href": "https://horizon-testnet.stellar.org/ledgers/673370" + }, + "operations": { + "href": "https://horizon-testnet.stellar.org/transactions/cfc6395b98ed0c5ad63bd808e6b5ec994c3ccc67814945d3c652659b5077da18/operations{?cursor,limit,order}", + "templated": true + }, + "effects": { + "href": "https://horizon-testnet.stellar.org/transactions/cfc6395b98ed0c5ad63bd808e6b5ec994c3ccc67814945d3c652659b5077da18/effects{?cursor,limit,order}", + "templated": true + }, + "precedes": { + "href": "https://horizon-testnet.stellar.org/transactions?order=asc\u0026cursor=2892102128111616" + }, + "succeeds": { + "href": "https://horizon-testnet.stellar.org/transactions?order=desc\u0026cursor=2892102128111616" + }, + "transaction": { + "href": "https://horizon-testnet.stellar.org/transactions/cfc6395b98ed0c5ad63bd808e6b5ec994c3ccc67814945d3c652659b5077da18" + } + }, + "id": "cfc6395b98ed0c5ad63bd808e6b5ec994c3ccc67814945d3c652659b5077da18", + "paging_token": "2892102128111616", + "successful": true, + "hash": "cfc6395b98ed0c5ad63bd808e6b5ec994c3ccc67814945d3c652659b5077da18", + "ledger": 673370, + "created_at": "2022-08-02T12:34:28Z", + "source_account": "GBW7BTQDKVMB62NXB3Z55NZCENRBD4O4OE7YBKBOG4K4DM4QK76L2DJD", + "source_account_sequence": "2892097833140225", + "fee_account": "GBW7BTQDKVMB62NXB3Z55NZCENRBD4O4OE7YBKBOG4K4DM4QK76L2DJD", + "fee_charged": "10000000", + "max_fee": "10000000", + "operation_count": 1, + "envelope_xdr": "AAAAAgAAAABt8M4DVVgfabcO8963IiNiEfHccT+AqC43FcGzkFf8vQCYloAACkZZAAAAAQAAAAEAAAAAAAAAAAAAAABi6RnwAAAAAAAAAAEAAAAAAAAACAAAAABKBB+2UBMP/abwcm/M1TXO+/JQWhPwkalgqizKmXyRIQAAAAAAAAABkFf8vQAAAEDmHHsYzqrzruPqKTFS0mcBPkpVkiF4ykNCJdAf/meM9NDYk+Eg/LD2B2epHdQZDC8TvecyiMQACjrb+Bdb+2YD", + "result_xdr": "AAAAAACYloAAAAAAAAAAAQAAAAAAAAAIAAAAAAAAABdH3lGAAAAAAA==", + "result_meta_xdr": "AAAAAgAAAAIAAAADAApGWgAAAAAAAAAAbfDOA1VYH2m3DvPetyIjYhHx3HE/gKguNxXBs5BX/L0AAAAXR95RgAAKRlkAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAABAApGWgAAAAAAAAAAbfDOA1VYH2m3DvPetyIjYhHx3HE/gKguNxXBs5BX/L0AAAAXR95RgAAKRlkAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAACkZaAAAAAGLpGdQAAAAAAAAAAQAAAAQAAAADAApGWgAAAAAAAAAAbfDOA1VYH2m3DvPetyIjYhHx3HE/gKguNxXBs5BX/L0AAAAXR95RgAAKRlkAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAACkZaAAAAAGLpGdQAAAAAAAAAAgAAAAAAAAAAbfDOA1VYH2m3DvPetyIjYhHx3HE/gKguNxXBs5BX/L0AAAADAApGTwAAAAAAAAAASgQftlATD/2m8HJvzNU1zvvyUFoT8JGpYKosypl8kSEMj1jFrrjxTQAAAM4AAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAhlAAAAAGKzGdkAAAAAAAAAAQAKRloAAAAAAAAAAEoEH7ZQEw/9pvByb8zVNc778lBaE/CRqWCqLMqZfJEhDI9Y3PaXQs0AAADOAAAAAQAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAMAAAAAAAAIZQAAAABisxnZAAAAAAAAAAA=", + "fee_meta_xdr": "AAAAAgAAAAMACkZZAAAAAAAAAABt8M4DVVgfabcO8963IiNiEfHccT+AqC43FcGzkFf8vQAAABdIdugAAApGWQAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEACkZaAAAAAAAAAABt8M4DVVgfabcO8963IiNiEfHccT+AqC43FcGzkFf8vQAAABdH3lGAAApGWQAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==", + "memo_type": "none", + "signatures": [ + "5hx7GM6q867j6ikxUtJnAT5KVZIheMpDQiXQH/5njPTQ2JPhIPyw9gdnqR3UGQwvE73nMojEAAo62/gXW/tmAw==" + ], + "valid_after": "1970-01-01T00:00:00Z", + "valid_before": "2022-08-02T12:34:56Z", + "preconditions": { + "timebounds": { + "min_time": "0", + "max_time": "1659443696" + } + } + } + ] + } + }` + normalizedResp := normalizeResponseBody([]byte(resp)) + t.Log(normalizedResp) +} From ff665ecc56d2078304ba8e0b7efafaefad4b2810 Mon Sep 17 00:00:00 2001 From: Bartek Nowotarski Date: Wed, 28 Jun 2023 01:25:11 +0200 Subject: [PATCH 16/20] all: Fix improper use of errors.Wrap (#4926) * all: Fix improper use of errors.Wrap `errors.Wrap` method returns nil if the first argument passed is also nil. If `errors.Wrap` is copied from a condition like `if err != nil` to another one which also returns `errors.Wrap` but does not overwrite `err` before the returned value will always be `nil`. * Update services/horizon/internal/db2/history/claimable_balances.go Co-authored-by: George --------- Co-authored-by: George Co-authored-by: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> --- services/horizon/internal/db2/history/claimable_balances.go | 2 +- services/horizon/internal/db2/history/orderbook.go | 4 ++-- services/horizon/internal/db2/history/verify_lock.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/horizon/internal/db2/history/claimable_balances.go b/services/horizon/internal/db2/history/claimable_balances.go index 3fe4029dc3..ece94c390b 100644 --- a/services/horizon/internal/db2/history/claimable_balances.go +++ b/services/horizon/internal/db2/history/claimable_balances.go @@ -47,7 +47,7 @@ func (cbq ClaimableBalancesQuery) Cursor() (int64, string, error) { } r = parts[1] if l < 0 { - return l, r, errors.Wrap(err, "Invalid cursor - first value should be higher than 0") + return l, r, errors.New("invalid cursor - first value should be higher than 0") } } diff --git a/services/horizon/internal/db2/history/orderbook.go b/services/horizon/internal/db2/history/orderbook.go index 3de321a4ac..ab3237795f 100644 --- a/services/horizon/internal/db2/history/orderbook.go +++ b/services/horizon/internal/db2/history/orderbook.go @@ -117,7 +117,7 @@ func (q *Q) GetOrderBookSummary(ctx context.Context, sellingAsset, buyingAsset x // we don't expect there to be any inconsistency between levels and offers because // this function should only be invoked in a repeatable read transaction if len(levels) != len(offers) { - return result, errors.Wrap(err, "price levels length does not match summaries length") + return result, errors.New("price levels length does not match summaries length") } for i, level := range levels { sum := offers[i] @@ -151,7 +151,7 @@ func (q *Q) GetOrderBookSummary(ctx context.Context, sellingAsset, buyingAsset x } else if sum.Type == "bid" { result.Bids = append(result.Bids, entry) } else { - return result, errors.Wrap(err, "invalid offer type") + return result, errors.New("invalid offer type") } } diff --git a/services/horizon/internal/db2/history/verify_lock.go b/services/horizon/internal/db2/history/verify_lock.go index 6b7d5910e8..f56045e9b1 100644 --- a/services/horizon/internal/db2/history/verify_lock.go +++ b/services/horizon/internal/db2/history/verify_lock.go @@ -32,7 +32,7 @@ func (q *Q) TryStateVerificationLock(ctx context.Context) (bool, error) { return false, errors.Wrap(err, "error acquiring advisory lock for state verification") } if len(acquired) != 1 { - return false, errors.Wrap(err, "invalid response from advisory lock") + return false, errors.New("invalid response from advisory lock") } return acquired[0], nil } From 2ec1834fed2cf610881e08efc9aee311d8b60073 Mon Sep 17 00:00:00 2001 From: shawn Date: Thu, 29 Jun 2023 11:01:00 -0700 Subject: [PATCH 17/20] fix apt repo reference to focal now (#4929) --- .../horizon/internal/scripts/check_release_hash/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/horizon/internal/scripts/check_release_hash/Dockerfile b/services/horizon/internal/scripts/check_release_hash/Dockerfile index b0b1666a41..6a054aab34 100644 --- a/services/horizon/internal/scripts/check_release_hash/Dockerfile +++ b/services/horizon/internal/scripts/check_release_hash/Dockerfile @@ -8,8 +8,8 @@ ENV DEBIAN_FRONTEND=noninteractive # ca-certificates are required to make tls connections RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl wget gnupg apt-utils git zip unzip apt-transport-https ca-certificates RUN wget -qO - https://apt.stellar.org/SDF.asc | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true apt-key add - -RUN echo "deb https://apt.stellar.org xenial stable" >/etc/apt/sources.list.d/SDF.list -RUN echo "deb https://apt.stellar.org xenial testing" >/etc/apt/sources.list.d/SDF-testing.list +RUN echo "deb https://apt.stellar.org focal stable" >/etc/apt/sources.list.d/SDF.list +RUN echo "deb https://apt.stellar.org focal testing" >/etc/apt/sources.list.d/SDF-testing.list RUN git clone https://github.com/stellar/go.git /go/src/github.com/stellar/go # Fetch dependencies and prebuild binaries. Not necessary but will make check faster. From d639314b724a6088cef4dfeb52fd68fcea7840c3 Mon Sep 17 00:00:00 2001 From: Shawn Reuland Date: Thu, 29 Jun 2023 13:13:49 -0700 Subject: [PATCH 18/20] fixed go fmt on bindata --- .../horizon/internal/db2/schema/bindata.go | 146 +++++++++--------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/services/horizon/internal/db2/schema/bindata.go b/services/horizon/internal/db2/schema/bindata.go index 57d0fa3faf..46546303d1 100644 --- a/services/horizon/internal/db2/schema/bindata.go +++ b/services/horizon/internal/db2/schema/bindata.go @@ -1617,11 +1617,13 @@ var _bindata = map[string]func() (*asset, error){ // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: -// data/ -// foo.txt -// img/ -// a.png -// b.png +// +// data/ +// foo.txt +// img/ +// a.png +// b.png +// // then AssetDir("data") would return []string{"foo.txt", "img"}, // AssetDir("data/img") would return []string{"a.png", "b.png"}, // AssetDir("foo.txt") and AssetDir("notexist") would return an error, and @@ -1654,73 +1656,73 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "migrations": &bintree{nil, map[string]*bintree{ - "10_add_trades_price.sql": &bintree{migrations10_add_trades_priceSql, map[string]*bintree{}}, - "11_add_trades_account_index.sql": &bintree{migrations11_add_trades_account_indexSql, map[string]*bintree{}}, - "12_asset_stats_amount_string.sql": &bintree{migrations12_asset_stats_amount_stringSql, map[string]*bintree{}}, - "13_trade_offer_ids.sql": &bintree{migrations13_trade_offer_idsSql, map[string]*bintree{}}, - "14_fix_asset_toml_field.sql": &bintree{migrations14_fix_asset_toml_fieldSql, map[string]*bintree{}}, - "15_ledger_failed_txs.sql": &bintree{migrations15_ledger_failed_txsSql, map[string]*bintree{}}, - "16_ingest_failed_transactions.sql": &bintree{migrations16_ingest_failed_transactionsSql, map[string]*bintree{}}, - "17_transaction_fee_paid.sql": &bintree{migrations17_transaction_fee_paidSql, map[string]*bintree{}}, - "18_account_for_signers.sql": &bintree{migrations18_account_for_signersSql, map[string]*bintree{}}, - "19_offers.sql": &bintree{migrations19_offersSql, map[string]*bintree{}}, - "1_initial_schema.sql": &bintree{migrations1_initial_schemaSql, map[string]*bintree{}}, - "20_account_for_signer_index.sql": &bintree{migrations20_account_for_signer_indexSql, map[string]*bintree{}}, - "21_trades_remove_zero_amount_constraints.sql": &bintree{migrations21_trades_remove_zero_amount_constraintsSql, map[string]*bintree{}}, - "22_trust_lines.sql": &bintree{migrations22_trust_linesSql, map[string]*bintree{}}, - "23_exp_asset_stats.sql": &bintree{migrations23_exp_asset_statsSql, map[string]*bintree{}}, - "24_accounts.sql": &bintree{migrations24_accountsSql, map[string]*bintree{}}, - "25_expingest_rename_columns.sql": &bintree{migrations25_expingest_rename_columnsSql, map[string]*bintree{}}, - "26_exp_history_ledgers.sql": &bintree{migrations26_exp_history_ledgersSql, map[string]*bintree{}}, - "27_exp_history_transactions.sql": &bintree{migrations27_exp_history_transactionsSql, map[string]*bintree{}}, - "28_exp_history_operations.sql": &bintree{migrations28_exp_history_operationsSql, map[string]*bintree{}}, - "29_exp_history_assets.sql": &bintree{migrations29_exp_history_assetsSql, map[string]*bintree{}}, - "2_index_participants_by_toid.sql": &bintree{migrations2_index_participants_by_toidSql, map[string]*bintree{}}, - "30_exp_history_trades.sql": &bintree{migrations30_exp_history_tradesSql, map[string]*bintree{}}, - "31_exp_history_effects.sql": &bintree{migrations31_exp_history_effectsSql, map[string]*bintree{}}, - "32_drop_exp_history_tables.sql": &bintree{migrations32_drop_exp_history_tablesSql, map[string]*bintree{}}, - "33_remove_unused.sql": &bintree{migrations33_remove_unusedSql, map[string]*bintree{}}, - "34_fee_bump_transactions.sql": &bintree{migrations34_fee_bump_transactionsSql, map[string]*bintree{}}, - "35_drop_participant_id.sql": &bintree{migrations35_drop_participant_idSql, map[string]*bintree{}}, - "36_deleted_offers.sql": &bintree{migrations36_deleted_offersSql, map[string]*bintree{}}, - "37_add_tx_set_operation_count_to_ledgers.sql": &bintree{migrations37_add_tx_set_operation_count_to_ledgersSql, map[string]*bintree{}}, - "38_add_constraints.sql": &bintree{migrations38_add_constraintsSql, map[string]*bintree{}}, - "39_claimable_balances.sql": &bintree{migrations39_claimable_balancesSql, map[string]*bintree{}}, - "39_history_trades_indices.sql": &bintree{migrations39_history_trades_indicesSql, map[string]*bintree{}}, - "3_use_sequence_in_history_accounts.sql": &bintree{migrations3_use_sequence_in_history_accountsSql, map[string]*bintree{}}, - "40_fix_inner_tx_max_fee_constraint.sql": &bintree{migrations40_fix_inner_tx_max_fee_constraintSql, map[string]*bintree{}}, - "41_add_sponsor_to_state_tables.sql": &bintree{migrations41_add_sponsor_to_state_tablesSql, map[string]*bintree{}}, - "42_add_num_sponsored_and_num_sponsoring_to_accounts.sql": &bintree{migrations42_add_num_sponsored_and_num_sponsoring_to_accountsSql, map[string]*bintree{}}, - "43_add_claimable_balances_flags.sql": &bintree{migrations43_add_claimable_balances_flagsSql, map[string]*bintree{}}, - "44_asset_stat_accounts_and_balances.sql": &bintree{migrations44_asset_stat_accounts_and_balancesSql, map[string]*bintree{}}, - "45_add_claimable_balances_history.sql": &bintree{migrations45_add_claimable_balances_historySql, map[string]*bintree{}}, - "46_add_muxed_accounts.sql": &bintree{migrations46_add_muxed_accountsSql, map[string]*bintree{}}, - "47_precompute_trade_aggregations.sql": &bintree{migrations47_precompute_trade_aggregationsSql, map[string]*bintree{}}, - "48_rebuild_trade_aggregations.sql": &bintree{migrations48_rebuild_trade_aggregationsSql, map[string]*bintree{}}, - "49_add_brin_index_trade_aggregations.sql": &bintree{migrations49_add_brin_index_trade_aggregationsSql, map[string]*bintree{}}, - "4_add_protocol_version.sql": &bintree{migrations4_add_protocol_versionSql, map[string]*bintree{}}, - "50_liquidity_pools.sql": &bintree{migrations50_liquidity_poolsSql, map[string]*bintree{}}, - "51_remove_ht_unused_indexes.sql": &bintree{migrations51_remove_ht_unused_indexesSql, map[string]*bintree{}}, - "52_add_trade_type_index.sql": &bintree{migrations52_add_trade_type_indexSql, map[string]*bintree{}}, - "53_add_trades_rounding_slippage.sql": &bintree{migrations53_add_trades_rounding_slippageSql, map[string]*bintree{}}, - "54_tx_preconditions_and_account_fields.sql": &bintree{migrations54_tx_preconditions_and_account_fieldsSql, map[string]*bintree{}}, - "55_filter_rules.sql": &bintree{migrations55_filter_rulesSql, map[string]*bintree{}}, - "56_txsub_read_only.sql": &bintree{migrations56_txsub_read_onlySql, map[string]*bintree{}}, - "57_trade_aggregation_autovac.sql": &bintree{migrations57_trade_aggregation_autovacSql, map[string]*bintree{}}, - "58_add_index_by_id_optimization.sql": &bintree{migrations58_add_index_by_id_optimizationSql, map[string]*bintree{}}, - "59_remove_foreign_key_constraints.sql": &bintree{migrations59_remove_foreign_key_constraintsSql, map[string]*bintree{}}, - "5_create_trades_table.sql": &bintree{migrations5_create_trades_tableSql, map[string]*bintree{}}, - "60_add_asset_id_indexes.sql": &bintree{migrations60_add_asset_id_indexesSql, map[string]*bintree{}}, - "61_trust_lines_by_account_type_code_issuer.sql": &bintree{migrations61_trust_lines_by_account_type_code_issuerSql, map[string]*bintree{}}, - "62_claimable_balance_claimants.sql": &bintree{migrations62_claimable_balance_claimantsSql, map[string]*bintree{}}, - "63_add_contract_id_to_asset_stats.sql": &bintree{migrations63_add_contract_id_to_asset_statsSql, map[string]*bintree{}}, - "64_add_payment_flag_history_ops.sql": &bintree{migrations64_add_payment_flag_history_opsSql, map[string]*bintree{}}, - "6_create_assets_table.sql": &bintree{migrations6_create_assets_tableSql, map[string]*bintree{}}, - "7_modify_trades_table.sql": &bintree{migrations7_modify_trades_tableSql, map[string]*bintree{}}, - "8_add_aggregators.sql": &bintree{migrations8_add_aggregatorsSql, map[string]*bintree{}}, - "8_create_asset_stats_table.sql": &bintree{migrations8_create_asset_stats_tableSql, map[string]*bintree{}}, - "9_add_header_xdr.sql": &bintree{migrations9_add_header_xdrSql, map[string]*bintree{}}, + "migrations": {nil, map[string]*bintree{ + "10_add_trades_price.sql": {migrations10_add_trades_priceSql, map[string]*bintree{}}, + "11_add_trades_account_index.sql": {migrations11_add_trades_account_indexSql, map[string]*bintree{}}, + "12_asset_stats_amount_string.sql": {migrations12_asset_stats_amount_stringSql, map[string]*bintree{}}, + "13_trade_offer_ids.sql": {migrations13_trade_offer_idsSql, map[string]*bintree{}}, + "14_fix_asset_toml_field.sql": {migrations14_fix_asset_toml_fieldSql, map[string]*bintree{}}, + "15_ledger_failed_txs.sql": {migrations15_ledger_failed_txsSql, map[string]*bintree{}}, + "16_ingest_failed_transactions.sql": {migrations16_ingest_failed_transactionsSql, map[string]*bintree{}}, + "17_transaction_fee_paid.sql": {migrations17_transaction_fee_paidSql, map[string]*bintree{}}, + "18_account_for_signers.sql": {migrations18_account_for_signersSql, map[string]*bintree{}}, + "19_offers.sql": {migrations19_offersSql, map[string]*bintree{}}, + "1_initial_schema.sql": {migrations1_initial_schemaSql, map[string]*bintree{}}, + "20_account_for_signer_index.sql": {migrations20_account_for_signer_indexSql, map[string]*bintree{}}, + "21_trades_remove_zero_amount_constraints.sql": {migrations21_trades_remove_zero_amount_constraintsSql, map[string]*bintree{}}, + "22_trust_lines.sql": {migrations22_trust_linesSql, map[string]*bintree{}}, + "23_exp_asset_stats.sql": {migrations23_exp_asset_statsSql, map[string]*bintree{}}, + "24_accounts.sql": {migrations24_accountsSql, map[string]*bintree{}}, + "25_expingest_rename_columns.sql": {migrations25_expingest_rename_columnsSql, map[string]*bintree{}}, + "26_exp_history_ledgers.sql": {migrations26_exp_history_ledgersSql, map[string]*bintree{}}, + "27_exp_history_transactions.sql": {migrations27_exp_history_transactionsSql, map[string]*bintree{}}, + "28_exp_history_operations.sql": {migrations28_exp_history_operationsSql, map[string]*bintree{}}, + "29_exp_history_assets.sql": {migrations29_exp_history_assetsSql, map[string]*bintree{}}, + "2_index_participants_by_toid.sql": {migrations2_index_participants_by_toidSql, map[string]*bintree{}}, + "30_exp_history_trades.sql": {migrations30_exp_history_tradesSql, map[string]*bintree{}}, + "31_exp_history_effects.sql": {migrations31_exp_history_effectsSql, map[string]*bintree{}}, + "32_drop_exp_history_tables.sql": {migrations32_drop_exp_history_tablesSql, map[string]*bintree{}}, + "33_remove_unused.sql": {migrations33_remove_unusedSql, map[string]*bintree{}}, + "34_fee_bump_transactions.sql": {migrations34_fee_bump_transactionsSql, map[string]*bintree{}}, + "35_drop_participant_id.sql": {migrations35_drop_participant_idSql, map[string]*bintree{}}, + "36_deleted_offers.sql": {migrations36_deleted_offersSql, map[string]*bintree{}}, + "37_add_tx_set_operation_count_to_ledgers.sql": {migrations37_add_tx_set_operation_count_to_ledgersSql, map[string]*bintree{}}, + "38_add_constraints.sql": {migrations38_add_constraintsSql, map[string]*bintree{}}, + "39_claimable_balances.sql": {migrations39_claimable_balancesSql, map[string]*bintree{}}, + "39_history_trades_indices.sql": {migrations39_history_trades_indicesSql, map[string]*bintree{}}, + "3_use_sequence_in_history_accounts.sql": {migrations3_use_sequence_in_history_accountsSql, map[string]*bintree{}}, + "40_fix_inner_tx_max_fee_constraint.sql": {migrations40_fix_inner_tx_max_fee_constraintSql, map[string]*bintree{}}, + "41_add_sponsor_to_state_tables.sql": {migrations41_add_sponsor_to_state_tablesSql, map[string]*bintree{}}, + "42_add_num_sponsored_and_num_sponsoring_to_accounts.sql": {migrations42_add_num_sponsored_and_num_sponsoring_to_accountsSql, map[string]*bintree{}}, + "43_add_claimable_balances_flags.sql": {migrations43_add_claimable_balances_flagsSql, map[string]*bintree{}}, + "44_asset_stat_accounts_and_balances.sql": {migrations44_asset_stat_accounts_and_balancesSql, map[string]*bintree{}}, + "45_add_claimable_balances_history.sql": {migrations45_add_claimable_balances_historySql, map[string]*bintree{}}, + "46_add_muxed_accounts.sql": {migrations46_add_muxed_accountsSql, map[string]*bintree{}}, + "47_precompute_trade_aggregations.sql": {migrations47_precompute_trade_aggregationsSql, map[string]*bintree{}}, + "48_rebuild_trade_aggregations.sql": {migrations48_rebuild_trade_aggregationsSql, map[string]*bintree{}}, + "49_add_brin_index_trade_aggregations.sql": {migrations49_add_brin_index_trade_aggregationsSql, map[string]*bintree{}}, + "4_add_protocol_version.sql": {migrations4_add_protocol_versionSql, map[string]*bintree{}}, + "50_liquidity_pools.sql": {migrations50_liquidity_poolsSql, map[string]*bintree{}}, + "51_remove_ht_unused_indexes.sql": {migrations51_remove_ht_unused_indexesSql, map[string]*bintree{}}, + "52_add_trade_type_index.sql": {migrations52_add_trade_type_indexSql, map[string]*bintree{}}, + "53_add_trades_rounding_slippage.sql": {migrations53_add_trades_rounding_slippageSql, map[string]*bintree{}}, + "54_tx_preconditions_and_account_fields.sql": {migrations54_tx_preconditions_and_account_fieldsSql, map[string]*bintree{}}, + "55_filter_rules.sql": {migrations55_filter_rulesSql, map[string]*bintree{}}, + "56_txsub_read_only.sql": {migrations56_txsub_read_onlySql, map[string]*bintree{}}, + "57_trade_aggregation_autovac.sql": {migrations57_trade_aggregation_autovacSql, map[string]*bintree{}}, + "58_add_index_by_id_optimization.sql": {migrations58_add_index_by_id_optimizationSql, map[string]*bintree{}}, + "59_remove_foreign_key_constraints.sql": {migrations59_remove_foreign_key_constraintsSql, map[string]*bintree{}}, + "5_create_trades_table.sql": {migrations5_create_trades_tableSql, map[string]*bintree{}}, + "60_add_asset_id_indexes.sql": {migrations60_add_asset_id_indexesSql, map[string]*bintree{}}, + "61_trust_lines_by_account_type_code_issuer.sql": {migrations61_trust_lines_by_account_type_code_issuerSql, map[string]*bintree{}}, + "62_claimable_balance_claimants.sql": {migrations62_claimable_balance_claimantsSql, map[string]*bintree{}}, + "63_add_contract_id_to_asset_stats.sql": {migrations63_add_contract_id_to_asset_statsSql, map[string]*bintree{}}, + "64_add_payment_flag_history_ops.sql": {migrations64_add_payment_flag_history_opsSql, 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{}}, + "8_create_asset_stats_table.sql": {migrations8_create_asset_stats_tableSql, map[string]*bintree{}}, + "9_add_header_xdr.sql": {migrations9_add_header_xdrSql, map[string]*bintree{}}, }}, }} From 7f4c0d96f5aaac6dc157ccbb574a13a85a5f3292 Mon Sep 17 00:00:00 2001 From: Shawn Reuland Date: Thu, 29 Jun 2023 14:52:34 -0700 Subject: [PATCH 19/20] fixed merge conflict snippet --- services/horizon/internal/ingest/main.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index 41acf0a4dd..dbc586e8ff 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -412,12 +412,6 @@ func (s *system) GetCurrentState() State { return s.currentState } -func (s *system) GetCurrentState() State { - s.currentStateMutex.Lock() - defer s.currentStateMutex.Unlock() - return s.currentState -} - func (s *system) Metrics() Metrics { return s.metrics } From 47bea06d9464495e9187c25b0b0795a9fcdad524 Mon Sep 17 00:00:00 2001 From: Shawn Reuland Date: Fri, 30 Jun 2023 09:29:46 -0700 Subject: [PATCH 20/20] fixed manual merge commit omition --- services/horizon/internal/ingest/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/horizon/internal/ingest/main_test.go b/services/horizon/internal/ingest/main_test.go index 6694fd0a33..fb5ad15948 100644 --- a/services/horizon/internal/ingest/main_test.go +++ b/services/horizon/internal/ingest/main_test.go @@ -251,7 +251,7 @@ func TestCurrentStateRaceCondition(t *testing.T) { } historyQ.On("GetTx").Return(nil) - historyQ.On("Begin").Return(nil) + historyQ.On("Begin", s.ctx).Return(nil) historyQ.On("Rollback").Return(nil) historyQ.On("GetLastLedgerIngest", s.ctx).Return(uint32(1), nil) historyQ.On("GetIngestVersion", s.ctx).Return(CurrentVersion, nil)