Skip to content

Commit

Permalink
xdr, services/horizon: Merge Horizon v2.17.0rc1 back into master (#4356
Browse files Browse the repository at this point in the history
…).
  • Loading branch information
Shaptic authored Apr 29, 2022
2 parents 229fb05 + 453586e commit d40d8fc
Show file tree
Hide file tree
Showing 21 changed files with 422 additions and 246 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/horizon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
env:
HORIZON_INTEGRATION_TESTS_ENABLED: true
HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }}
PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.0.0-891.rc1.9d0704eb4.focal
PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.0.0-891.rc1.9d0704eb4.focal
PROTOCOL_18_CORE_DEBIAN_PKG_VERSION: 18.5.0-873.rc1.d387c6a71.focal
PROTOCOL_18_CORE_DOCKER_IMG: stellar/stellar-core:18.5.0-873.rc1.d387c6a71.focal
PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.0.0-907.9d0704eb4.focal
PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.0.0-907.9d0704eb4.focal
PROTOCOL_18_CORE_DEBIAN_PKG_VERSION: 19.0.0-907.9d0704eb4.focal
PROTOCOL_18_CORE_DOCKER_IMG: stellar/stellar-core:19.0.0-907.9d0704eb4.focal
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
Expand Down
23 changes: 15 additions & 8 deletions gxdr/xdr_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions services/horizon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## V2.17.0 Release Candidate

**Upgrading to this version from <= v2.8.3 will trigger a state rebuild. During this process (which will take at least 10 minutes), Horizon will not ingest new ledgers.**

**Support for Protocol 19** ([4340](https://github.com/stellar/go/pull/4340)):

- Account records can now contain two new, optional fields:

```json
```txt
"sequence_ledger": 0, // uint32 ledger number
"sequence_time": "0" // uint64 unix time in seconds, as a string
```
Expand All @@ -18,7 +22,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).

- Transaction records can now contain the following optional object:

```json
```txt
"preconditions": {
"timebounds": {
"min_time": "0", // uint64 unix time in seconds, as a string
Expand All @@ -43,7 +47,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
### DB Schema Migration

The migration makes the following schema changes:

- adds new, optional columns to the `history_transactions` table related to the new preconditions
- adds new, optional columns to the `accounts` table related to the new account extension
- amends the `signer` column of the `accounts_signers` table to allow signers of arbitrary length
Expand Down
17 changes: 9 additions & 8 deletions services/horizon/internal/actions/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/guregu/null"
"github.com/guregu/null/zero"

"github.com/stretchr/testify/assert"

Expand All @@ -32,8 +33,8 @@ var (
AccountID: accountOne,
Balance: 20000,
SequenceNumber: 223456789,
SequenceLedger: 2345,
SequenceTime: 1647265533,
SequenceLedger: zero.IntFrom(0),
SequenceTime: zero.IntFrom(0),
NumSubEntries: 10,
Flags: 1,
HomeDomain: "stellar.org",
Expand All @@ -50,8 +51,8 @@ var (
AccountID: accountTwo,
Balance: 50000,
SequenceNumber: 648736,
SequenceLedger: 3456,
SequenceTime: 1647365533,
SequenceLedger: zero.IntFrom(3456),
SequenceTime: zero.IntFrom(1647365533),
NumSubEntries: 10,
Flags: 2,
HomeDomain: "meridian.stellar.org",
Expand All @@ -68,8 +69,8 @@ var (
AccountID: signer,
Balance: 50000,
SequenceNumber: 648736,
SequenceLedger: 4567,
SequenceTime: 1647465533,
SequenceLedger: zero.IntFrom(4567),
SequenceTime: zero.IntFrom(1647465533),
NumSubEntries: 10,
Flags: 2,
MasterWeight: 5,
Expand Down Expand Up @@ -176,8 +177,8 @@ func TestAccountInfo(t *testing.T) {
AccountID: accountID,
Balance: 9999999900,
SequenceNumber: 8589934593,
SequenceLedger: 4567,
SequenceTime: 1647465533,
SequenceLedger: zero.IntFrom(4567),
SequenceTime: zero.IntFrom(1647465533),
NumSubEntries: 1,
InflationDestination: "",
HomeDomain: "",
Expand Down
4 changes: 4 additions & 0 deletions services/horizon/internal/codes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func String(code interface{}) (string, error) {
return "tx_internal_error", nil
case xdr.TransactionResultCodeTxBadSponsorship:
return "tx_bad_sponsorship", nil
case xdr.TransactionResultCodeTxBadMinSeqAgeOrGap:
return "tx_bad_minseq_age_or_gap", nil
case xdr.TransactionResultCodeTxMalformed:
return "tx_malformed", nil
}
case xdr.OperationResultCode:
switch code {
Expand Down
24 changes: 13 additions & 11 deletions services/horizon/internal/db2/history/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/guregu/null"
"github.com/guregu/null/zero"
"github.com/stellar/go/services/horizon/internal/db2"
"github.com/stellar/go/services/horizon/internal/test"
"github.com/stellar/go/xdr"
Expand All @@ -19,8 +20,8 @@ var (
AccountID: "GAOQJGUAB7NI7K7I62ORBXMN3J4SSWQUQ7FOEPSDJ322W2HMCNWPHXFB",
Balance: 20000,
SequenceNumber: 223456789,
SequenceLedger: 2345,
SequenceTime: 1647265533,
SequenceLedger: zero.IntFrom(0),
SequenceTime: zero.IntFrom(0),
NumSubEntries: 10,
InflationDestination: inflationDest,
Flags: 1,
Expand All @@ -38,8 +39,8 @@ var (
AccountID: "GCT2NQM5KJJEF55NPMY444C6M6CA7T33HRNCMA6ZFBIIXKNCRO6J25K7",
Balance: 50000,
SequenceNumber: 648736,
SequenceLedger: 3456,
SequenceTime: 1647365533,
SequenceLedger: zero.IntFrom(3456),
SequenceTime: zero.IntFrom(1647365533),
NumSubEntries: 10,
InflationDestination: inflationDest,
Flags: 2,
Expand All @@ -60,8 +61,8 @@ var (
AccountID: "GDPGOMFSP4IF7A4P7UBKA4UC4QTRLEHGBD6IMDIS3W3KBDNBFAQ7FXDY",
Balance: 50000,
SequenceNumber: 648736,
SequenceLedger: 4567,
SequenceTime: 1647465533,
SequenceLedger: zero.IntFrom(4567),
SequenceTime: zero.IntFrom(1647465533),
NumSubEntries: 10,
InflationDestination: inflationDest,
Flags: 2,
Expand Down Expand Up @@ -93,8 +94,8 @@ func TestInsertAccount(t *testing.T) {
assert.Equal(t, "GAOQJGUAB7NI7K7I62ORBXMN3J4SSWQUQ7FOEPSDJ322W2HMCNWPHXFB", accounts[0].AccountID)
assert.Equal(t, int64(20000), accounts[0].Balance)
assert.Equal(t, int64(223456789), accounts[0].SequenceNumber)
assert.Equal(t, uint32(2345), accounts[0].SequenceLedger)
assert.Equal(t, uint64(1647265533), accounts[0].SequenceTime)
assert.Equal(t, zero.IntFrom(0), accounts[0].SequenceLedger)
assert.Equal(t, zero.IntFrom(0), accounts[0].SequenceTime)
assert.Equal(t, uint32(10), accounts[0].NumSubEntries)
assert.Equal(t, "GBUH7T6U36DAVEKECMKN5YEBQYZVRBPNSZAAKBCO6P5HBMDFSQMQL4Z4", accounts[0].InflationDestination)
assert.Equal(t, uint32(1), accounts[0].Flags)
Expand Down Expand Up @@ -129,8 +130,8 @@ func TestUpsertAccount(t *testing.T) {
AccountID: "GAOQJGUAB7NI7K7I62ORBXMN3J4SSWQUQ7FOEPSDJ322W2HMCNWPHXFB",
Balance: 32847893,
SequenceNumber: 223456789,
SequenceTime: 223456789223456789,
SequenceLedger: 2345,
SequenceTime: zero.IntFrom(223456789223456789),
SequenceLedger: zero.IntFrom(2345),
NumSubEntries: 10,
InflationDestination: inflationDest,
Flags: 1,
Expand Down Expand Up @@ -458,7 +459,8 @@ func TestGetAccountByID(t *testing.T) {
assert.Equal(t, "GAOQJGUAB7NI7K7I62ORBXMN3J4SSWQUQ7FOEPSDJ322W2HMCNWPHXFB", resultAccount.AccountID)
assert.Equal(t, int64(20000), resultAccount.Balance)
assert.Equal(t, int64(223456789), resultAccount.SequenceNumber)
assert.Equal(t, uint32(2345), resultAccount.SequenceLedger)
assert.Equal(t, zero.IntFrom(0), resultAccount.SequenceLedger)
assert.Equal(t, zero.IntFrom(0), resultAccount.SequenceTime)
assert.Equal(t, uint32(10), resultAccount.NumSubEntries)
assert.Equal(t, "GBUH7T6U36DAVEKECMKN5YEBQYZVRBPNSZAAKBCO6P5HBMDFSQMQL4Z4", resultAccount.InflationDestination)
assert.Equal(t, uint32(1), resultAccount.Flags)
Expand Down
5 changes: 3 additions & 2 deletions services/horizon/internal/db2/history/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

sq "github.com/Masterminds/squirrel"
"github.com/guregu/null"
"github.com/guregu/null/zero"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"

Expand Down Expand Up @@ -221,8 +222,8 @@ type AccountEntry struct {
BuyingLiabilities int64 `db:"buying_liabilities"`
SellingLiabilities int64 `db:"selling_liabilities"`
SequenceNumber int64 `db:"sequence_number"`
SequenceLedger uint32 `db:"sequence_ledger"`
SequenceTime uint64 `db:"sequence_time"`
SequenceLedger zero.Int `db:"sequence_ledger"`
SequenceTime zero.Int `db:"sequence_time"`
NumSubEntries uint32 `db:"num_subentries"`
InflationDestination string `db:"inflation_destination"`
HomeDomain string `db:"home_domain"`
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/ingest/processor_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/guregu/null"
"github.com/guregu/null/zero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

Expand All @@ -30,7 +31,7 @@ func TestProcessorRunnerRunHistoryArchiveIngestionGenesis(t *testing.T) {
AccountID: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
Balance: int64(1000000000000000000),
SequenceNumber: 0,
SequenceTime: 0,
SequenceTime: zero.IntFrom(0),
MasterWeight: 1,
},
}).Return(nil).Once()
Expand Down Expand Up @@ -96,7 +97,6 @@ func TestProcessorRunnerRunHistoryArchiveIngestionHistoryArchive(t *testing.T) {
AccountID: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
Balance: int64(1000000000000000000),
SequenceNumber: 0,
SequenceTime: 0,
MasterWeight: 1,
},
}).Return(nil).Once()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package processors
import (
"context"

"github.com/guregu/null/zero"
"github.com/stellar/go/ingest"
"github.com/stellar/go/services/horizon/internal/db2/history"
"github.com/stellar/go/support/errors"
Expand Down Expand Up @@ -117,8 +118,8 @@ func (p *AccountsProcessor) ledgerEntryToRow(entry xdr.LedgerEntry) history.Acco
BuyingLiabilities: int64(liabilities.Buying),
SellingLiabilities: int64(liabilities.Selling),
SequenceNumber: int64(account.SeqNum),
SequenceLedger: uint32(account.SeqLedger()),
SequenceTime: uint64(account.SeqTime()),
SequenceLedger: zero.IntFrom(int64(account.SeqLedger())),
SequenceTime: zero.IntFrom(int64(account.SeqTime())),
NumSubEntries: uint32(account.NumSubEntries),
InflationDestination: inflationDestination,
Flags: uint32(account.Flags),
Expand Down
Loading

0 comments on commit d40d8fc

Please sign in to comment.