Skip to content

Commit

Permalink
Merge stellar/horizon-protocol-19 into master (#4340)
Browse files Browse the repository at this point in the history
* all: Add Protocol 19 XDR and update StrKey to support Signed Payloads (#4279)
* services/horizon: Support new account fields for protocol-19. (#4294)
* xdr, keypair: Add helpers to create CAP-40 decorated signatures (#4302)
* services/horizon: Update txsub queue to account for new CAP-21 preconditions (#4301)
* txnbuild: Add support for new CAP-21 preconditions. (#4303)

Adds support for new CAP-21 preconditions with a simple, but breaking API
change:

TransactionParams.Timebounds -> TransactionParams.Preconditions.TimeBounds

You can now pass a lot more preconditions to a Transaction (including
timebounds), and these are managed by the new Preconditions object. All of the
XDR abstractions are hidden away behind this object.

* services/horizon: Support new CAP-21 transaction conditions (#4297)
* txnbuild: Complete rename, avoid using XDR types in `TransactionParams`. (#4307)
* all: Update Protocol 19 XDR to the latest (#4308)
* horizon: Set up protocol 19 integration tests infrastructure (#4312)
* horizon: Test new protocol 19 account fields (#4322)
* horizon: Add integration test for extra signers using tx preconditions (#4305)
* horizon: Add transaction submission test for Protocol 19 (#4327)
* services/horizon: Use `bigint` over `timestamp` to accommodate large years (#4337)

This is necessary because PostgreSQL puts "reasonable" limitations
on how dates can be represented. Because the state verifier test
will generate random int64s for the V3 account extension field
introduced in CAP-21, this will blow up on inserting into the DB
with errors like:

    pq: date/time field value out of range: "120911623444-02-01 21:35:20Z"

because PostgreSQL only allows years up to 5874897
(https://stackoverflow.com/a/36446977).

Technically, since this field is not user-controlled and comes
directly from Stellar Core, we would not see this in practice.

However, it's a more durable fix to stop the extra layer of
"interpretation" of this value and just treat it like it is:
a 64-bit integer that happens to represent a UNIX timestamp.

* services/horizon: Change `min_account_sequence_age` column from `bigint` to string (#4339)
* Add changelog details and prep v10.0.0 SDK release

Co-authored-by: Alfonso Acosta <[email protected]>
Co-authored-by: erika-sdf <[email protected]>
Co-authored-by: Paul Bellamy <[email protected]>
Co-authored-by: Shawn Reuland <[email protected]>
Co-authored-by: shawn <[email protected]>
Co-authored-by: George <[email protected]>
  • Loading branch information
6 people authored Apr 19, 2022
2 parents 8be872a + 911b0e1 commit 9f968df
Show file tree
Hide file tree
Showing 128 changed files with 5,546 additions and 1,225 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/horizon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
go: [1.17, 1.18]
pg: [9.6.5]
ingestion-backend: [db, captive-core, captive-core-remote-storage]
captive-core: [18.5.0-873.rc1.d387c6a71.focal]
protocol-version: [18, 19]
runs-on: ${{ matrix.os }}
services:
postgres:
Expand All @@ -32,7 +32,12 @@ jobs:
ports:
- 5432:5432
env:
HORIZON_INTEGRATION_TESTS: "true"
HORIZON_INTEGRATION_TESTS_ENABLED: true
HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }}
PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 18.4.1-875.95d896a49.focal~v19unsafe
PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:18.4.1-875.95d896a49.focal-v19unsafe
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
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
Expand Down Expand Up @@ -61,8 +66,11 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: Pull latest Stellar Core image
run: docker pull stellar/stellar-core
- name: Pull and set Stellar Core image
shell: bash
run: |
docker pull "$PROTOCOL_${{ matrix.protocol-version }}_CORE_DOCKER_IMG"
echo HORIZON_INTEGRATION_TESTS_DOCKER_IMG="$PROTOCOL_${{ matrix.protocol-version }}_CORE_DOCKER_IMG" >> $GITHUB_ENV
- if: ${{ startsWith(matrix.ingestion-backend, 'captive-core') }}
name: Install and enable Captive Core
Expand All @@ -74,14 +82,14 @@ jobs:
sudo wget -qO - https://apt.stellar.org/SDF.asc | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true sudo apt-key add -
sudo bash -c 'echo "deb https://apt.stellar.org focal unstable" > /etc/apt/sources.list.d/SDF-unstable.list'
sudo apt-get update && sudo apt-get install -y stellar-core=${{ matrix.captive-core }}
sudo apt-get update && sudo apt-get install -y stellar-core="$PROTOCOL_${{ matrix.protocol-version }}_CORE_DEBIAN_PKG_VERSION"
echo "Using stellar core version $(stellar-core version)"
echo 'HORIZON_INTEGRATION_ENABLE_CAPTIVE_CORE=true' >> $GITHUB_ENV
echo 'CAPTIVE_CORE_BIN=/usr/bin/stellar-core' >> $GITHUB_ENV
echo 'HORIZON_INTEGRATION_TESTS_ENABLE_CAPTIVE_CORE=true' >> $GITHUB_ENV
echo 'HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_BIN=/usr/bin/stellar-core' >> $GITHUB_ENV
- if: ${{ matrix.ingestion-backend == 'captive-core-remote-storage' }}
name: Setup Captive Core Remote Storage
run: echo 'HORIZON_INTEGRATION_ENABLE_CAPTIVE_CORE_USE_DB=true' >> $GITHUB_ENV
run: echo 'HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_USE_DB=true' >> $GITHUB_ENV

- run: go test -race -timeout 25m -v ./services/horizon/internal/integration/...

Expand Down
8 changes: 8 additions & 0 deletions clients/horizonclient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ All notable changes to this project will be documented in this
file. This project adheres to [Semantic Versioning](http://semver.org/).


## [v10.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v10.0.0) - 2022-04-18

**This release adds support for Protocol 19:**

* The library is updated to align with breaking changes to `txnbuild`.


## [v9.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v9.0.0) - 2022-01-10

None


## [8.0.0-beta.0](https://github.com/stellar/go/releases/tag/horizonclient-v8.0.0-beta.0) - 2021-10-04

**This release adds support for Protocol 18.**
Expand Down
4 changes: 2 additions & 2 deletions clients/horizonclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,10 @@ func (c *Client) StreamOrderBooks(ctx context.Context, request OrderBookRequest,
// It defaults to localtime when the server time is not available.
// Note that this will generate your timebounds when you init the transaction, not when you build or submit
// the transaction! So give yourself enough time to get the transaction built and signed before submitting.
func (c *Client) FetchTimebounds(seconds int64) (txnbuild.Timebounds, error) {
func (c *Client) FetchTimebounds(seconds int64) (txnbuild.TimeBounds, error) {
serverURL, err := url.Parse(c.HorizonURL)
if err != nil {
return txnbuild.Timebounds{}, errors.Wrap(err, "unable to parse horizon url")
return txnbuild.TimeBounds{}, errors.Wrap(err, "unable to parse horizon url")
}
currentTime := currentServerTime(serverURL.Hostname(), c.clock.Now().UTC().Unix())
if currentTime != 0 {
Expand Down
10 changes: 5 additions & 5 deletions clients/horizonclient/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ func ExampleClient_SubmitFeeBumpTransaction() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewInfiniteTimeout(), // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1154,7 +1154,7 @@ func ExampleClient_SubmitFeeBumpTransactionWithOptions() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewInfiniteTimeout(), // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1211,7 +1211,7 @@ func ExampleClient_SubmitTransaction() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewInfiniteTimeout(), // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1253,7 +1253,7 @@ func ExampleClient_SubmitTransactionWithOptions() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewInfiniteTimeout(), // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1295,7 +1295,7 @@ func ExampleClient_SubmitTransactionWithOptions_skip_memo_required_check() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewInfiniteTimeout(), // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions clients/horizonclient/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestCheckMemoRequired(t *testing.T) {
IncrementSequenceNum: true,
Operations: tc.operations,
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
tt.NoError(err)
Expand Down Expand Up @@ -878,7 +878,7 @@ func TestSubmitTransactionRequest(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -946,7 +946,7 @@ func TestSubmitTransactionRequestMuxedAccounts(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1006,7 +1006,7 @@ func TestSubmitFeeBumpTransaction(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1075,7 +1075,7 @@ func TestSubmitTransactionWithOptionsRequest(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ func TestSubmitTransactionWithOptionsRequest(t *testing.T) {
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Memo: txnbuild.MemoText("HelloWorld"),
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1202,7 +1202,7 @@ func TestSubmitFeeBumpTransactionWithOptions(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1293,7 +1293,7 @@ func TestSubmitFeeBumpTransactionWithOptions(t *testing.T) {
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Memo: txnbuild.MemoText("HelloWorld"),
Timebounds: txnbuild.NewTimebounds(0, 10),
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1483,7 +1483,7 @@ func TestFetchTimebounds(t *testing.T) {
ServerTimeMap["localhost"] = newRecord
st, err = client.FetchTimebounds(100)
assert.NoError(t, err)
assert.IsType(t, st, txnbuild.Timebounds{})
assert.IsType(t, st, txnbuild.TimeBounds{})
assert.Equal(t, st.MinTime, int64(0))
// time should be 200, serverTime + 100seconds
assert.Equal(t, st.MaxTime, int64(200))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ func TestAccountSign_signingAddressAccountAuthenticatedButSigningAddressInvalid(
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -411,8 +411,8 @@ func TestAccountSign_signingAddressAccountAuthenticatedOtherSignerSelected(t *te
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -477,8 +477,8 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxSourceAccountValid(t *t
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -544,8 +544,8 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxAndOpSourceAccountValid
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -610,8 +610,8 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxSourceAccountInvalid(t
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -673,8 +673,8 @@ func TestAccountSign_signingAddressAccountAuthenticatedOpSourceAccountInvalid(t
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -737,8 +737,8 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxAndOpSourceAccountInval
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -806,8 +806,8 @@ func TestAccountSign_signingAddressPhoneNumberOwnerAuthenticated(t *testing.T) {
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -878,8 +878,8 @@ func TestAccountSign_signingAddressPhoneNumberOtherAuthenticated(t *testing.T) {
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -950,8 +950,8 @@ func TestAccountSign_signingAddressEmailOwnerAuthenticated(t *testing.T) {
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1031,8 +1031,8 @@ func TestAccountSign_signingAddressEmailOwnerAuthenticatedOpSourceAccountIsAllow
},
&txnbuild.EndSponsoringFutureReserves{},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1108,8 +1108,8 @@ func TestAccountSign_signingAddressEmailOwnerAuthenticatedOpSourceAccountInvalid
},
&txnbuild.EndSponsoringFutureReserves{},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1175,8 +1175,8 @@ func TestAccountSign_signingAddressEmailOtherAuthenticated(t *testing.T) {
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1281,8 +1281,8 @@ func TestAccountSign_signingAddressRejectsFeeBumpTx(t *testing.T) {
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1351,8 +1351,8 @@ func TestAccountSign_signingAddressValidContentTypeForm(t *testing.T) {
},
},
},
BaseFee: txnbuild.MinBaseFee,
Timebounds: txnbuild.NewTimebounds(0, 1),
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down
8 changes: 5 additions & 3 deletions exp/services/webauth/internal/serve/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,11 @@ func TestToken_jsonInputNoWebAuthDomainSuccess(t *testing.T) {
Value: []byte("ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg"),
},
},
BaseFee: txnbuild.MinBaseFee,
Memo: nil,
Timebounds: txnbuild.NewTimebounds(txMinTimebounds, txMaxTimebounds),
BaseFee: txnbuild.MinBaseFee,
Memo: nil,
Preconditions: txnbuild.Preconditions{
TimeBounds: txnbuild.NewTimebounds(txMinTimebounds, txMaxTimebounds),
},
},
)
require.NoError(t, err)
Expand Down
Loading

0 comments on commit 9f968df

Please sign in to comment.