-
Notifications
You must be signed in to change notification settings - Fork 505
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
ingest: Add support for ledger entry change type "restore" for Protocol 23 #5587
ingest: Add support for ledger entry change type "restore" for Protocol 23 #5587
Conversation
7433a31
to
e443da6
Compare
e239fcf
to
586392c
Compare
d064abc
to
25c51fa
Compare
25c51fa
to
a954a67
Compare
Co-authored-by: tamirms <tamirms@gmail.com>
Co-authored-by: tamirms <tamirms@gmail.com>
@urvisavla the PR looks good, I think the only remaining task is to add a check to ensure that the Change Compactor instance is only used to compact changes from a single ledger |
@tamirms
However, I'm having trouble reliably getting the ledger sequence number from a What's the most reliable way to determine the current ledger sequence number for a Change without storing it in the Also, it seems the new Change struct fields added in #5536 are not designed to be used with the Change Compactor which wasn't immediately obvious to me and caused some confusion. |
@urvisavla you can get it from change.Ledger or, if that's not present you can check change.Transaction.Ledger, or you can fix #5578 and then it should always be present in change.Ledger
The fields are not preserved after the compaction process but the changes fed into the change reader should still have valid fields |
These fields must be preserved during compaction if we are to compare the ledger sequence number of incoming changes with existing ones in the cache. However, there are alternative solutions, such as storing the ledger sequence in the ChangeCompactor object. I have created #5607 to evaluate potential solutions and implement it separately to unblock this PR. |
yes, that's what I had in mind
👍 |
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
CHANGELOG.md
within the component folder structure. For example, if I changed horizon, then I updated (services/horizon/CHANGELOG.md. I add a new line item describing the change and reference to this PR. If I don't update a CHANGELOG, I acknowledge this PR's change may not be mentioned in future release notes.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.
What
This PR adds support for a new ledger entry change type called
restore
in the ingest library, introduced in Protocol 23. Additionally, the meta forupdate
andremove
changes will now change if an entry was restored in the same transaction. For example, if an entry is restored and removed within the same transaction, the meta will be [restored, removed] and if restored and updated in the same transaction, the meta will be [restored, updated]. This differs from pre-Protocol 32, where updated and removed entries always appear as [state, updated] and [state, removed].Main Changes
Previously, the Change struct in the ingest library didn't store the change type explicitly but inferred it from the Pre and Post values. However, with the introduction of restore, distinguishing change types purely based on Pre and Post is no longer possible.
restore
change type in change compactorThe compaction process in the ingest library combines multiple changes within the same ledger for a single change to reduce the number of DB operations. With the introduction of the
restore
change type, the compaction logic is updated to:Change Compactor
configEmitArchivedEntryRemovalChange
has been added to control the handling REMOVED change for archived entries. By default, REMOVED changes are not emitted for entries that are created and removed within the same ledger. However, if an entry is restored and then removed in the same ledger, it is unclear whether a REMOVED change should be emitted, as this depends on the downstream system's strategy for storing archived entries. This setting allows REMOVED changes to be emitted for such entries which may be necessary for systems that store them. Systems that do not store archived entries (e.g. those running periodic garbage collection of archived entries) can set this to false to suppress the REMOVED change.Why
#5421
Known limitations
restore
change type required for integration tests is currently unavailable so this change is only unit-tested.