Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exp: Add the Zenith (Light Horizon) prototype #4352

Merged
merged 146 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 145 commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
c2f03ff
exp/lighthorizon: Init
bartekn Feb 4, 2022
41f13ef
More op adapters
bartekn Feb 5, 2022
39dafba
refactoring, more ops
bartekn Feb 7, 2022
79d1cbb
More ops
bartekn Feb 7, 2022
9984e2b
Use operations.TypeNames
bartekn Feb 7, 2022
5cbe604
Merge branch 'master' into lighthorizon
bartekn Feb 7, 2022
11ad8de
all ops
bartekn Feb 8, 2022
542e5c3
Merge branch 'lighthorizon' of github.com:bartekn/go into lighthorizon
bartekn Feb 8, 2022
7d34235
rename files
bartekn Feb 8, 2022
b5bf85f
Imitate horizon responses
bartekn Feb 8, 2022
8eaed23
fixes
bartekn Feb 8, 2022
e12667f
indexer
bartekn Feb 18, 2022
d3a4bf3
s3 upload
bartekn Feb 21, 2022
b728976
Upload/download to save memory
bartekn Feb 21, 2022
570f9bc
Use a rwmutex for thread safety on indexes
Feb 22, 2022
f7bebe3
Extract s3 operations to S3IndexStore
Feb 22, 2022
f8b5108
Implement NextActive, and use index to skip checkpoints
Feb 22, 2022
3127509
Fix deadlock and constant-ize constant
Feb 22, 2022
b34326d
Add remaining countdown to indexer
Feb 23, 2022
27f71d1
use sync/errgroup for simpler error handling
Feb 23, 2022
2078ca2
Clear indexes in Flush to save memory
Feb 23, 2022
ead329d
Add FileIndexStore
Feb 23, 2022
0d30385
fixup! use sync/errgroup for simpler error handling
Feb 23, 2022
719297a
FileIndexStore add top-level dirs to organize slightly
Feb 23, 2022
8735d72
Add some root dirs to the file index store
Feb 23, 2022
8cc1cad
fixup! Add some root dirs to the file index store
Feb 23, 2022
0e5f896
Try gzipping local index files
Feb 24, 2022
246293e
gzipped index file per account for s3 as well
Mar 1, 2022
ee487b0
First pass at adding an s3 cache for checkpoints
Mar 1, 2022
d29da53
Add warning that there's no cache expiry
Mar 1, 2022
f2c68a5
Ignore malformed indexes so that we can rebuild them
Mar 1, 2022
f34cd1e
Fix bug in gzip writer
Mar 1, 2022
0eb4003
prefix s3 paths with 3-char
Mar 1, 2022
197914f
add an lru cache for s3 fs caching
Mar 2, 2022
ec37f06
Merge method
Mar 8, 2022
84dd02b
Batch index generation
Mar 8, 2022
94dd4a5
First pass at a lighthorizon dockerfile
Mar 9, 2022
565620e
Add blank prefix so lighthorizon and single build
Mar 9, 2022
bb60607
Add accounts file
Mar 9, 2022
d684687
Merge branch 'lighthorizon' of github.com:bartekn/go into lighthorizon
Mar 9, 2022
3e2a8f5
Adding a trie index for transactions
Mar 10, 2022
fc48df0
lighthorizon /transactions?id=<txhash>
Mar 10, 2022
e3acbad
Change TrieIndex to a radix tree. Saves ~20% size on-disk
Mar 11, 2022
b68b19f
Reduce and bugfixes
bartekn Mar 13, 2022
4587f7c
Merge branch 'lighthorizon' of github.com:bartekn/go into lighthorizon
bartekn Mar 13, 2022
fe907fd
Add a one-byte bitmask header for trie index nodes (saves a few bytes…
Mar 14, 2022
13312e8
Add subpath to tx indexes to keep index folders clean
Mar 14, 2022
3c3518a
Add transaction index building to batch/map
Mar 14, 2022
d6852a8
Add TrieIndex.Merge method
Mar 14, 2022
4379223
add -modules flag to single so you can limit which indexes get built
Mar 14, 2022
c4d5379
Add txn-by-hash merging into batch reduce
Mar 15, 2022
3358d4b
Add ledgerexporter service which stores txmeta in GCS
tamirms Feb 2, 2022
d182a32
Add historyarchive.ArchiveGCSBackend
Apr 18, 2022
41e44a0
Add historyarchive.ArchiveBackend.Close()
Apr 18, 2022
f37348f
ledgerexporter service supports multiple write targets
Apr 18, 2022
ac10f81
lighthorizon reading from ledgerexporter txmeta archive
Apr 25, 2022
38652e2
lighthorizon serving ops from txmeta
Apr 25, 2022
ebf37a7
index/cmd/single read from txmeta files
Apr 26, 2022
48e51e9
exp/lighthorizon: Add initial support for XDR serialization (#4369)
Shaptic May 5, 2022
e3397e5
exp/lighthorizon: Improve trie tests to avoid raw comparisons/outputs…
Shaptic May 12, 2022
ac4417a
exp/lighthorizon: Add XDR marshalling for the `TrieNode` structure. (…
Shaptic May 12, 2022
4eeba9d
lighthorizon: Sync with upstream master branch (#4404)
Shaptic May 24, 2022
64b0b67
Explain map and reduce commands
bartekn May 26, 2022
056eb0c
exp/lighthorizon: Refactor single-process index builder. (#4410)
Shaptic May 31, 2022
f6f9055
exp/services/ledgerexporter: Extend tool to support lower ledger boun…
Shaptic May 31, 2022
7015de6
exp/lighthorizon: Refactor and repair the reduce job (#4424)
Shaptic Jun 6, 2022
3aa5029
exp/lighthorizon: Unify map-reduce and single-process index builders …
Shaptic Jun 6, 2022
6b47337
exp/lighthorizon: Thread-safe support for reading account list via Fi…
Shaptic Jun 9, 2022
33cbd42
exp/lighthorizon: Restructure index package into sensible sub-package…
Shaptic Jun 10, 2022
e03abae
exp/lighthorizon: Merge on-disk index with in-memory one on load. (#4…
Shaptic Jun 21, 2022
e0e8bf1
exp/lighthorizon: Allow indexer to continually update as new txmeta a…
Shaptic Jun 23, 2022
00ae4ed
exp/lighthorizon: enforce the limit from request on the response size…
sreuland Jun 30, 2022
b3a5466
Dockerize ledgerexport to run in AWS Batch
2opremio Jun 30, 2022
740bc0b
exp/lighthorizon: Add test for batch index building map job (#4440)
Shaptic Jun 30, 2022
eeea565
Refactor bound preparation and add --continue flag
2opremio Jul 1, 2022
811c551
Address review feedback and rework env variable names
2opremio Jul 1, 2022
9aff46a
Run gofmt -w (I don't know why those files were changed)
2opremio Jul 1, 2022
9212a03
Add proper logging to indicate what range is being exported
2opremio Jul 1, 2022
61fe924
Add clarification about end ledger
2opremio Jul 1, 2022
969f21b
Fix boolean argument passing
2opremio Jul 3, 2022
b0095ec
Merge remote-tracking branch 'origin/lighthorizon' into dockerize-led…
2opremio Jul 4, 2022
168ba93
Address review feedback
2opremio Jul 6, 2022
b877e6d
Address feedback
2opremio Jul 7, 2022
58fe6c2
Use sqlite for captive core
2opremio Jul 7, 2022
17e0db9
Merge pull request #4443 from 2opremio/dockerize-ledgerexporter
2opremio Jul 11, 2022
2f0fa9c
exp/lighthorizon: Add basic scaffolding for metrics. (#4456)
Shaptic Jul 11, 2022
17f5d36
lighthorizon: Prepend version to ledger files (#4450)
2opremio Jul 13, 2022
6e864fc
exp/lighthorizon/index: More testing for batch indexing and off-by-on…
Shaptic Jul 14, 2022
291e99e
Minor ledgerexporter infrastructure improvements (#4461)
2opremio Jul 19, 2022
66228cb
Forgot to add login step to ledgerexporter workflow
2opremio Jul 19, 2022
033de79
exp/lighthorizon: Set a default number of workers. (#4465)
Shaptic Jul 20, 2022
8c9eec3
exp/lighthorizon: Fix the single-process index builder data race. (#4…
Shaptic Jul 21, 2022
bceaf07
/exp/lighthorizon: new endpoints for tx and ops paged listing by acco…
sreuland Jul 22, 2022
9b93a36
exp/lighthorizon: Add an on-disk cache for frequently accessed ledger…
Shaptic Jul 26, 2022
90f32cc
exp/lighthorizon/index: Drop building indices for successful transact…
Shaptic Jul 27, 2022
738befe
Add metrics middleware to collect request duration metrics (#4486)
tamirms Jul 28, 2022
6a9373e
exp/lighthorizon: Isolate cursor advancement code to its own interfac…
Shaptic Jul 28, 2022
3808eaf
exp/lighthorizon/index: Parse network passphrase from the env. (#4491)
Shaptic Jul 29, 2022
1ac18f3
Refactor access to meta archive (#4488)
bartekn Aug 1, 2022
a12b11f
exp/lighthorizon: Add response age prometheus metrics (#4492)
tamirms Aug 2, 2022
a047725
exp/lighthorizon/index: Allow accounts to be indexed by ledger. (#4495)
Shaptic Aug 2, 2022
2e50ba8
services/horizon/docker/ledgerexporter: deploy ledgerexporter image a…
sreuland Aug 3, 2022
7d26a32
Make indexing s3 bucket configurable (#4507)
2opremio Aug 4, 2022
67b94b5
exp/lighthorizon: Add duration metrics for on-the-fly ingestion eleme…
Shaptic Aug 5, 2022
1c2072b
exp/lighthorizon: Add JSON content type to responses. (#4509)
Shaptic Aug 5, 2022
c18e31f
exp/lighthorizon: *Correctly* set `Content-Type`, plus JSONify errors…
Shaptic Aug 5, 2022
4a82936
exp/lighthorizon/services: Move service-specific stuff to its own fil…
Shaptic Aug 8, 2022
828fc46
exp/lighthorizon, xdr: Rename `CheckpointIndex` to better reflect its…
Shaptic Aug 8, 2022
aeb23a3
exp/lighthorizon: Add a suite of tools to manage the on-disk ledger c…
Shaptic Aug 10, 2022
22b0e46
Merge branch 'master' into lighthorizon
Shaptic Aug 10, 2022
a47f74c
Run 'go mod tidy' after merge
Shaptic Aug 10, 2022
34c98a3
exp/lighthorizon: add horizon web docker/k8s deployment (#4519)
sreuland Aug 10, 2022
d98b01b
Merge branch 'lighthorizon' into lighthorizon_mergeUpstream
sreuland Aug 10, 2022
b395544
It seems like the merge caused some deleted files to stay in:
Shaptic Aug 10, 2022
817e19f
Merge branch 'master' into lighthorizon_mergeUpstream
Shaptic Aug 10, 2022
b8c287d
One more that didn't get removed :thinking:
Shaptic Aug 10, 2022
ca471e9
all: Merge 'master' into lighthorizon branch. (#4529)
Shaptic Aug 10, 2022
9f9216c
Merge branch 'master' into lighthorizon_mergeUpstreamAgain
Shaptic Aug 11, 2022
5ffdd3b
all: Merge `master` into the 'lighthorizon' branch again. (#4536)
Shaptic Aug 11, 2022
c3ec897
all: Incorporate generics into Light Horizon code. (#4537)
Shaptic Aug 12, 2022
7a30aef
bump go version to 18 on lighthorizon docker images, they need it now…
sreuland Aug 15, 2022
adadbcc
exp/lighthorizon/actions: use standard Problem model on API error res…
sreuland Aug 17, 2022
4838973
exp/lighthorizon/build/index-batch: carry over map/reduce updates to …
sreuland Aug 17, 2022
01b3b4a
exp/lighthorizon: Properly transform transactions into JSON. (#4531)
Shaptic Aug 19, 2022
f8fcb05
exp/lighthorizon: Add a set of tools to aide in index inspection. (#4…
Shaptic Aug 30, 2022
a8f9750
exp/lighthorizon/cmd: index batch fix s3 sub paths in reduce (#4552)
sreuland Aug 31, 2022
56a0321
exp/lighthorzon: Add a generic, thread-safe `SafeSet`. (#4572)
Shaptic Sep 2, 2022
3c53909
support/storage: Make the on-disk cache thread-safe. (#4575)
Shaptic Sep 7, 2022
7a5cc31
exp/lighthorizon: Incorporate tool subcommands into the webserver. (#…
Shaptic Sep 12, 2022
c9c58d2
exp/lighthorizon/index/cmd: Fix index single watch, slow down the ret…
sreuland Sep 13, 2022
f6dad54
exp/lighthorizon: Refactor archive interface and support parallel led…
Shaptic Sep 15, 2022
02dab00
exp/lighthorizon: Minor error-handling and deployment improvements. (…
Shaptic Sep 20, 2022
a088915
exp/lighthorizon/index: Add ability to disable bits in index. (#4601)
Shaptic Sep 27, 2022
dc430d4
exp/lighthorizon: Add parameters to preload ledger cache. (#4615)
Shaptic Oct 11, 2022
d3cf7fd
Rename file to fix typo
Shaptic May 19, 2023
922c969
Merge branch 'master' into lighthorizon
Shaptic Jan 5, 2024
10054c5
Re-run gofmt after generating
Shaptic Jan 5, 2024
1ce75a7
Update generated XDR file
Shaptic Jan 5, 2024
3bfd4b3
Fix things after the merge
Shaptic Jan 5, 2024
5691d2f
Remove unused creation method
Shaptic Jan 5, 2024
4724299
Fixup bad merge in the captive core config
Shaptic Jan 5, 2024
29cea5f
Upgrade gRPC to conform to later Go versions
Shaptic Jan 5, 2024
52cc470
Attempting to get Go version nonsense resolved
Shaptic Jan 5, 2024
6567031
Only do exporter jobs and fixup Dockerfile versions
Shaptic Jan 6, 2024
3e36559
Merge branch 'master' into lighthorizon
Shaptic Jan 9, 2024
7f9e886
Update Dockerfile to Ubuntu 22.04 Jammy
Shaptic Jan 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 47 additions & 0 deletions .github/workflows/horizon.yml
Original file line number Diff line number Diff line change
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ xdr/Stellar-contract-meta.x \
xdr/Stellar-contract-spec.x \
xdr/Stellar-contract.x \
xdr/Stellar-internal.x \
xdr/Stellar-contract-config-setting.x
xdr/Stellar-contract-config-setting.x \
xdr/Stellar-lighthorizon.x

XDRGEN_COMMIT=e2cac557162d99b12ae73b846cf3d5bfe16636de
XDR_COMMIT=bb54e505f814386a3f45172e0b7e95b7badbe969
Expand Down
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
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
Loading