From 48f95bba31a1a338054985dd71389732976afeed Mon Sep 17 00:00:00 2001 From: Tamir Sen Date: Fri, 1 May 2020 08:13:28 +0200 Subject: [PATCH 1/2] Drop participant id columns The id columns in the history_transaction_participants and history_operation_participants table are never used. These columns are auto incremented every time rows are inserted into their respective tables. There is a possibility that the column values will overflow and in that case horizon ingestion will be blocked. --- .../horizon/internal/db2/schema/bindata.go | 23 +++++++++++++++++++ .../migrations/35_drop_participant_id.sql | 15 ++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 services/horizon/internal/db2/schema/migrations/35_drop_participant_id.sql diff --git a/services/horizon/internal/db2/schema/bindata.go b/services/horizon/internal/db2/schema/bindata.go index 419465f911..fce6af4ed2 100644 --- a/services/horizon/internal/db2/schema/bindata.go +++ b/services/horizon/internal/db2/schema/bindata.go @@ -27,6 +27,7 @@ // migrations/32_drop_exp_history_tables.sql (3.826kB) // migrations/33_remove_unused.sql (860B) // migrations/34_fee_bump_transactions.sql (863B) +// migrations/35_drop_participant_id.sql (306B) // migrations/3_use_sequence_in_history_accounts.sql (447B) // migrations/4_add_protocol_version.sql (188B) // migrations/5_create_trades_table.sql (1.1kB) @@ -643,6 +644,26 @@ func migrations34_fee_bump_transactionsSql() (*asset, error) { return a, nil } +var _migrations35_drop_participant_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\xce\x31\x0e\xc2\x30\x0c\x46\xe1\x3d\xa7\xf8\x77\xd4\x13\x30\x05\xd2\x2d\x50\x54\xb5\x73\x65\x95\xa8\x78\xc0\x89\x1c\x4b\x88\xdb\x33\xc2\x90\x01\x38\xc0\x7b\xfa\xba\x0e\xbb\x3b\x6f\x4a\x96\x30\x17\xe7\x7c\x9c\xfa\x11\x93\x3f\xc4\x1e\x37\xae\x96\xf5\xb9\xe4\x92\x94\x8c\xb3\x2c\x85\xd4\x78\xe5\x42\x62\xd5\x01\x40\x18\x87\x0b\x8e\x43\x9c\x4f\x67\xf0\x75\xdf\xee\x4d\x49\x2a\xad\x5f\x1e\x3e\x45\x21\x3f\xe4\x67\x93\x0f\xe1\x3d\x04\x8b\xa5\x2d\xe9\x3f\xb4\xf6\xe8\x15\x00\x00\xff\xff\xfa\x9c\x4a\x38\x32\x01\x00\x00") + +func migrations35_drop_participant_idSqlBytes() ([]byte, error) { + return bindataRead( + _migrations35_drop_participant_idSql, + "migrations/35_drop_participant_id.sql", + ) +} + +func migrations35_drop_participant_idSql() (*asset, error) { + bytes, err := migrations35_drop_participant_idSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "migrations/35_drop_participant_id.sql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xff, 0x7, 0x95, 0xf6, 0xca, 0xd3, 0x76, 0xfd, 0x68, 0x9b, 0xc5, 0x95, 0xb7, 0x43, 0x56, 0x2c, 0xbe, 0x33, 0x3d, 0xee, 0x33, 0xb7, 0xec, 0xf8, 0x18, 0xd6, 0x8a, 0xf3, 0x31, 0x37, 0x8f, 0x62}} + return a, nil +} + var _migrations3_use_sequence_in_history_accountsSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x91\x4d\x6b\xb3\x40\x14\x85\xf7\xf3\x2b\xce\x2e\xca\xfb\x66\x91\x6d\x5c\x4d\xc6\x1b\x22\x8c\x63\x3b\x5e\xdb\x64\x25\xa2\x43\x3a\x90\x6a\xeb\xd8\xaf\x7f\x5f\x48\xd3\x0f\x08\x6d\xa1\xcb\x73\x78\xe0\x39\xdc\x3b\x9f\xe3\xdf\xad\xdf\x8f\xcd\xe4\x50\xdd\x09\x65\x49\x32\xa1\xa4\xcb\x8a\x8c\x22\xdc\xf8\x30\x0d\xe3\x4b\xdd\xb4\xed\xf0\xd0\x4f\xa1\xf6\x5d\x1d\xdc\xbd\x00\x80\x92\xa5\x65\x5c\x67\xbc\xc1\xe2\x58\x64\x46\x59\xca\xc9\x30\x56\xbb\x53\x65\x0a\xe4\x99\xb9\x92\xba\xa2\x8f\x2c\xb7\x9f\x59\x49\xb5\x21\x2c\x12\x51\x92\x26\xc5\x08\x6e\x7a\x6c\x0e\xd1\xec\x1b\xef\xec\x3f\xa2\x13\x99\xcb\x6d\xe4\xbb\x18\x6b\x5b\xe4\x67\x33\xe3\x38\x11\x52\x33\x59\xb0\x5c\x69\x42\x61\xf4\xee\x0c\xc2\x1b\xa1\x0a\x5d\xe5\x06\xbe\x43\x49\x8c\x94\xd6\xb2\xd2\x8c\xde\x3d\xff\xbc\x64\xb9\x1c\xdd\xbe\x3d\x34\x21\xc4\x89\x10\x5f\xcf\x98\x0e\x4f\xfd\x1f\xec\xa9\x2d\x2e\xde\xf5\x89\x38\xa6\xdf\xde\x90\x88\xd7\x00\x00\x00\xff\xff\x55\xe2\xdd\x2c\xbf\x01\x00\x00") func migrations3_use_sequence_in_history_accountsSqlBytes() ([]byte, error) { @@ -921,6 +942,7 @@ var _bindata = map[string]func() (*asset, error){ "migrations/32_drop_exp_history_tables.sql": migrations32_drop_exp_history_tablesSql, "migrations/33_remove_unused.sql": migrations33_remove_unusedSql, "migrations/34_fee_bump_transactions.sql": migrations34_fee_bump_transactionsSql, + "migrations/35_drop_participant_id.sql": migrations35_drop_participant_idSql, "migrations/3_use_sequence_in_history_accounts.sql": migrations3_use_sequence_in_history_accountsSql, "migrations/4_add_protocol_version.sql": migrations4_add_protocol_versionSql, "migrations/5_create_trades_table.sql": migrations5_create_trades_tableSql, @@ -1000,6 +1022,7 @@ var _bintree = &bintree{nil, 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{}}, "3_use_sequence_in_history_accounts.sql": &bintree{migrations3_use_sequence_in_history_accountsSql, map[string]*bintree{}}, "4_add_protocol_version.sql": &bintree{migrations4_add_protocol_versionSql, map[string]*bintree{}}, "5_create_trades_table.sql": &bintree{migrations5_create_trades_tableSql, map[string]*bintree{}}, diff --git a/services/horizon/internal/db2/schema/migrations/35_drop_participant_id.sql b/services/horizon/internal/db2/schema/migrations/35_drop_participant_id.sql new file mode 100644 index 0000000000..e6f440b54b --- /dev/null +++ b/services/horizon/internal/db2/schema/migrations/35_drop_participant_id.sql @@ -0,0 +1,15 @@ +-- +migrate Up + +ALTER TABLE history_operation_participants + DROP COLUMN id; + +ALTER TABLE history_transaction_participants + DROP COLUMN id; + +-- +migrate Down + +ALTER TABLE history_operation_participants + ADD COLUMN id integer; + +ALTER TABLE history_transaction_participants + ADD COLUMN id integer; \ No newline at end of file From 90c2af2806b335189010cd155ffd3ae6c64873ea Mon Sep 17 00:00:00 2001 From: Tamir Sen Date: Fri, 1 May 2020 08:21:53 +0200 Subject: [PATCH 2/2] Update CHANGELOG --- services/horizon/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index 0e232c3a3c..7f26250e7a 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## v1.2.1 + +* Remove `id` columns from `history_operation_participants` and `history_transaction_participants` to prevent possible integer overflow [#2532](https://github.com/stellar/go/pull/2532). + ## v1.2.0 ### Scheduled Breaking Changes