Skip to content

Commit

Permalink
Merge branch 'master' into v2.28.2-backmerge. Steps:
Browse files Browse the repository at this point in the history
    git switch master
    git pull upstream master   # sync to stellar/go
    git checkout horizon-v2.28.2
    git switch -C v2.28.2-backmerge
    git merge -S master
    # <resolve all conflicts>
    git commit -S
    git push origin v2.28.2-backmerge
  • Loading branch information
Shaptic committed Feb 13, 2024
2 parents f232a9b + 73de95c commit f8cc68d
Show file tree
Hide file tree
Showing 489 changed files with 13,378 additions and 468 deletions.
53 changes: 50 additions & 3 deletions .github/workflows/horizon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
env:
HORIZON_INTEGRATION_TESTS_ENABLED: true
HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }}
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 20.1.0-1656.114b833e7.focal
PROTOCOL_20_CORE_DOCKER_IMG: stellar/unsafe-stellar-core:20.1.0-1656.114b833e7.focal
PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.2.0@sha256:2b1237a6ca43ea5768031d9ab442e4895d0ce5437b38cbfee4c8ab9237f231ae
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 20.2.0-1716.rc3.34d82fc00.focal
PROTOCOL_20_CORE_DOCKER_IMG: stellar/unsafe-stellar-core:20.2.0-1716.rc3.34d82fc00.focal
PROTOCOL_20_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:20.3.0-rc1-52
PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.14.0-1500.5664eff4e.focal
PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.14.0-1500.5664eff4e.focal
PGHOST: localhost
Expand Down Expand Up @@ -158,3 +158,50 @@ jobs:
- if: github.ref == 'refs/heads/master'
name: Push to DockerHub
run: docker push stellar/horizon-verify-range:latest

ledger-exporter:
name: Test and push the Ledger Exporter images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# For pull requests, build and test the PR head not a merge of the PR with the destination.
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Build and test Ledger Exporter images
# Any range should do for basic testing, this range was chosen pretty early in history so that it only takes a few mins to run
run: |
chmod 755 ./exp/lighthorizon/build/build.sh
mkdir $PWD/ledgerexport
# mkdir $PWD/index
./exp/lighthorizon/build/build.sh ledgerexporter stellar latest false
docker run -e ARCHIVE_TARGET=file:///ledgerexport\
-e START=5\
-e END=150\
-e NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015"\
-e CAPTIVE_CORE_CONFIG="/captive-core-pubnet.cfg"\
-e HISTORY_ARCHIVE_URLS="https://history.stellar.org/prd/core-live/core_live_001"\
-v $PWD/ledgerexport:/ledgerexport\
stellar/lighthorizon-ledgerexporter
# # run map job
# docker run -e NETWORK_PASSPHRASE='pubnet' -e JOB_INDEX_ENV=AWS_BATCH_JOB_ARRAY_INDEX -e AWS_BATCH_JOB_ARRAY_INDEX=0 -e BATCH_SIZE=64 -e FIRST_CHECKPOINT=64 \
# -e WORKER_COUNT=1 -e RUN_MODE=map -v $PWD/ledgerexport:/ledgermeta -e TXMETA_SOURCE=file:///ledgermeta -v $PWD/index:/index -e INDEX_TARGET=file:///index stellar/lighthorizon-index-batch
# # run reduce job
# docker run -e NETWORK_PASSPHRASE='pubnet' -e JOB_INDEX_ENV=AWS_BATCH_JOB_ARRAY_INDEX -e AWS_BATCH_JOB_ARRAY_INDEX=0 -e MAP_JOB_COUNT=1 -e REDUCE_JOB_COUNT=1 \
# -e WORKER_COUNT=1 -e RUN_MODE=reduce -v $PWD/index:/index -e INDEX_SOURCE_ROOT=file:///index -e INDEX_TARGET=file:///index stellar/lighthorizon-index-batch
# Push images
- if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/lighthorizon'
name: Login to DockerHub
uses: docker/login-action@bb984efc561711aaa26e433c32c3521176eae55b
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/lighthorizon'
name: Push to DockerHub
run: |
chmod 755 ./exp/lighthorizon/build/build.sh
./exp/lighthorizon/build/build.sh ledgerexporter stellar latest true
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Docker build targets use an optional "TAG" environment
# variable can be set to use custom tag name. For example:
# TAG=my-registry.example.com/keystore:dev make keystore
XDRS = xdr/Stellar-SCP.x \
DOWNLOADABLE_XDRS = xdr/Stellar-SCP.x \
xdr/Stellar-ledger-entries.x \
xdr/Stellar-ledger.x \
xdr/Stellar-overlay.x \
Expand All @@ -14,8 +14,12 @@ xdr/Stellar-contract.x \
xdr/Stellar-internal.x \
xdr/Stellar-contract-config-setting.x

XDRS = $(DOWNLOADABLE_XDRS) xdr/Stellar-lighthorizon.x



XDRGEN_COMMIT=e2cac557162d99b12ae73b846cf3d5bfe16636de
XDR_COMMIT=bb54e505f814386a3f45172e0b7e95b7badbe969
XDR_COMMIT=b96148cd4acc372cc9af17b909ffe4b12c43ecb6

.PHONY: xdr xdr-clean xdr-update

Expand All @@ -40,15 +44,15 @@ recoverysigner:
regulated-assets-approval-server:
$(MAKE) -C services/regulated-assets-approval-server/ docker-build

gxdr/xdr_generated.go: $(XDRS)
gxdr/xdr_generated.go: $(DOWNLOADABLE_XDRS)
go run github.com/xdrpp/goxdr/cmd/goxdr -p gxdr -enum-comments -o $@ $(XDRS)
gofmt -s -w $@

xdr/%.x:
printf "%s" ${XDR_COMMIT} > xdr/xdr_commit_generated.txt
curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr/$(XDR_COMMIT)/$(@F)

xdr/xdr_generated.go: $(XDRS)
xdr/xdr_generated.go: $(DOWNLOADABLE_XDRS)
docker run -it --rm -v $$PWD:/wd -w /wd ruby /bin/bash -c '\
gem install specific_install -v 0.3.8 && \
gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_COMMIT) && \
Expand All @@ -64,6 +68,6 @@ xdr/xdr_generated.go: $(XDRS)
xdr: gxdr/xdr_generated.go xdr/xdr_generated.go

xdr-clean:
rm xdr/*.x || true
rm $(DOWNLOADABLE_XDRS) || true

xdr-update: xdr-clean xdr
7 changes: 7 additions & 0 deletions clients/horizonclient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
* The library is updated to align with breaking changes to `txnbuild`.


## [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
Expand Down
23 changes: 22 additions & 1 deletion clients/stellarcore/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"net/http"
"testing"

"github.com/stretchr/testify/assert"

proto "github.com/stellar/go/protocols/stellarcore"
"github.com/stellar/go/support/http/httptest"
"github.com/stretchr/testify/assert"
)

func TestSubmitTransaction(t *testing.T) {
Expand All @@ -27,6 +28,26 @@ func TestSubmitTransaction(t *testing.T) {
}
}

func TestSubmitTransactionError(t *testing.T) {
hmock := httptest.NewClient()
c := &Client{HTTP: hmock, URL: "http://localhost:11626"}

// happy path - new transaction
hmock.On("GET", "http://localhost:11626/tx?blob=foo").
ReturnString(
200,
`{"diagnostic_events":"AAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAAEJcwAAAAUAAAAAAAG6fA==","error":"AAAAAAABCdf////vAAAAAA==","status":"ERROR"}`,
)

resp, err := c.SubmitTransaction(context.Background(), "foo")

if assert.NoError(t, err) {
assert.Equal(t, "ERROR", resp.Status)
assert.Equal(t, resp.Error, "AAAAAAABCdf////vAAAAAA==")
assert.Equal(t, "AAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAAEJcwAAAAUAAAAAAAG6fA==", resp.DiagnosticEvents)
}
}

func TestManualClose(t *testing.T) {
hmock := httptest.NewClient()
c := &Client{HTTP: hmock, URL: "http://localhost:11626"}
Expand Down
142 changes: 142 additions & 0 deletions exp/lighthorizon/actions/accounts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package actions

import (
"errors"
"net/http"
"os"
"strconv"

"github.com/stellar/go/support/log"
"github.com/stellar/go/xdr"

"github.com/stellar/go/exp/lighthorizon/adapters"
"github.com/stellar/go/exp/lighthorizon/services"
hProtocol "github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/protocols/horizon/operations"
"github.com/stellar/go/support/render/hal"
supportProblem "github.com/stellar/go/support/render/problem"
"github.com/stellar/go/toid"
)

const (
urlAccountId = "account_id"
)

func accountRequestParams(w http.ResponseWriter, r *http.Request) (string, pagination, error) {
var accountId string
var accountErr bool

if accountId, accountErr = getURLParam(r, urlAccountId); !accountErr {
return "", pagination{}, errors.New("unable to find account_id in url path")
}

paginate, err := paging(r)
if err != nil {
return "", pagination{}, err
}

if paginate.Cursor < 1 {
paginate.Cursor = toid.New(1, 1, 1).ToInt64()
}

if paginate.Limit == 0 {
paginate.Limit = 10
}

return accountId, paginate, nil
}

func NewTXByAccountHandler(lightHorizon services.LightHorizon) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var accountId string
var paginate pagination
var err error

if accountId, paginate, err = accountRequestParams(w, r); err != nil {
errorMsg := supportProblem.MakeInvalidFieldProblem("account_id", err)
sendErrorResponse(r.Context(), w, *errorMsg)
return
}

page := hal.Page{
Cursor: strconv.FormatInt(paginate.Cursor, 10),
Order: string(paginate.Order),
Limit: uint64(paginate.Limit),
}
page.Init()
page.FullURL = r.URL

txns, err := lightHorizon.Transactions.GetTransactionsByAccount(ctx, paginate.Cursor, paginate.Limit, accountId)
if err != nil {
log.Error(err)
if os.IsNotExist(err) {
sendErrorResponse(r.Context(), w, supportProblem.NotFound)
} else if err != nil {
sendErrorResponse(r.Context(), w, supportProblem.ServerError)
}
return
}

encoder := xdr.NewEncodingBuffer()
for _, txn := range txns {
var response hProtocol.Transaction
response, err = adapters.PopulateTransaction(r.URL, &txn, encoder)
if err != nil {
log.Error(err)
sendErrorResponse(r.Context(), w, supportProblem.ServerError)
return
}

page.Add(response)
}

page.PopulateLinks()
sendPageResponse(r.Context(), w, page)
}
}

func NewOpsByAccountHandler(lightHorizon services.LightHorizon) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var accountId string
var paginate pagination
var err error

if accountId, paginate, err = accountRequestParams(w, r); err != nil {
errorMsg := supportProblem.MakeInvalidFieldProblem("account_id", err)
sendErrorResponse(r.Context(), w, *errorMsg)
return
}

page := hal.Page{
Cursor: strconv.FormatInt(paginate.Cursor, 10),
Order: string(paginate.Order),
Limit: uint64(paginate.Limit),
}
page.Init()
page.FullURL = r.URL

ops, err := lightHorizon.Operations.GetOperationsByAccount(ctx, paginate.Cursor, paginate.Limit, accountId)
if err != nil {
log.Error(err)
sendErrorResponse(r.Context(), w, supportProblem.ServerError)
return
}

for _, op := range ops {
var response operations.Operation
response, err = adapters.PopulateOperation(r, &op)
if err != nil {
log.Error(err)
sendErrorResponse(r.Context(), w, supportProblem.ServerError)
return
}

page.Add(response)
}

page.PopulateLinks()
sendPageResponse(r.Context(), w, page)
}
}
Loading

0 comments on commit f8cc68d

Please sign in to comment.