-
Notifications
You must be signed in to change notification settings - Fork 523
exp/ingest: Process ledger upgrade meta #1862
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/ingest: Process ledger upgrade meta #1862
Conversation
@@ -30,8 +32,7 @@ func NewDBLedgerReader(sequence uint32, backend ledgerbackend.LedgerBackend) (*D | |||
backend: backend, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to initialize reader. upgradeChanges
to []Change{}
. Otherwise it will not be possible to distinguish an empty list from nil in GetLedgerUpgradeChangesFromContext()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting! I started wondering how is it possible that it works right now. It seems that the nil
slice returned by interface{}
return values is returned as empty slice (not nil): https://play.golang.org/p/1PHT_WH7URR. I think the answer is here.
Close() error | ||
} | ||
|
||
type UpgradeChangesContainer interface { | ||
GetUpgradeChanges() []Change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this separate from the LedgerReader
interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to add GetUpgradeChanges() []Change
to LedgerReader
because users shouldn't get all upgrade changes, instead they should stream them. This is because upgrade changes can be even 1 GB according to stellar-core devs (but so far the largest were just a few MBs). It's hard to implement streaming now because all upgrade changes are in a single field in a DB. I guess the new stellar-core ledger protocol should solve it.
I created a new interface because a reader in LedgerPipeline
can be one of: io.DBLedgerReader
, readerWrapperLedger
or reporterLedgerReader
. Instead of checking the types separately, they all implement this interface.
@tamirms I realized that there are several things I needed to fix:
Can you check 74478d5 and 👍 if it's OK? |
@bartekn the commit looks good |
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
Summary
This commits adds support for getting ledger upgrade changes from
exp/ingest/io.LedgerReader
and updates ledger processors in Horizon to process ledger upgrade meta.Requirement for #1848.
Close #1470.
Goal and scope
As described in Integration doc in stellar-core the ledger meta changes need to be processed in the following order:
This commit adds missing ledger upgrade processing by adding a new method on
LedgerReader
that streamsio.Change
objects connected to a given ledger upgrades. Because processing ledger upgrade meta is essential to update the state correctly,LedgerReader.Close()
will return an error in case some ledger upgrades have not been read.Summary of changes
ReadUpgradeChange
toio.LedgerReader
.Known limitations & issues
LedgerEntryChanges
connected to ledger upgrade can be of arbitrary size. Currently all ledger upgrade changes are read fully into memory because they are stored in a single field in stellar-core DB (streaming them would require an awkward code that callssubstr
on an upgrade DB row). This should be solved when stellar-core ledger protocol is finished.LedgerReader
API is designed to support streaming upgrade changes.What shouldn't be reviewed