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

Implement function which merges two LedgerCloseMeta objects #5479

Open
tamirms opened this issue Sep 30, 2024 · 1 comment
Open

Implement function which merges two LedgerCloseMeta objects #5479

tamirms opened this issue Sep 30, 2024 · 1 comment
Assignees

Comments

@tamirms
Copy link
Contributor

tamirms commented Sep 30, 2024

We want a function which takes two LedgerCloseMeta xdr objects and returns a LedgerCloseMeta object which includes all the transactions and meta from the two source LedgerCloseMeta xdr objects. The purpose of this function is to create ledgers with arbitrarily an large number of transactions. Instead of generating fake transactions and meta we can combine existing ledgers to create large ledgers.

@tamirms
Copy link
Contributor Author

tamirms commented Oct 3, 2024

I prototyped the merge function here . However, I ran into a problem related to the specific order in which ledger entry changes are applied.

Changes within a ledger should be applied in the following order:

  1. fee changes of all transactions
  2. transaction meta changes of all transactions
  3. upgrade changes

So if we have two ledgers the order of application for those two ledgers will be:

  1. fee changes of all transactions from ledger 1
  2. transaction meta changes of all transactions from ledger 1
  3. upgrade changes from ledger 1
  4. fee changes of all transactions from ledger 2
  5. transaction meta changes of all transactions from ledger 2
  6. upgrade changes from ledger 2

However, if we try to merge ledgers 1 and 2 into a single ledger we can no longer maintain the ordering above and instead we will obtain the following order:

  1. fee changes of all transactions from ledger 1
  2. fee changes of all transactions from ledger 2
  3. transaction meta changes of all transactions from ledger 1
  4. transaction meta changes of all transactions from ledger 2
  5. upgrade changes from ledger 1
  6. upgrade changes from ledger 2

Given the importance of having the correct application order, I think we cannot proceed with combining several ledger objects into one. Instead, I think we'll need to refactor ingestion to support ingesting multiple ledgers within a single DB transaction as an approximation of having one large ledger which is the union of a bunch of smaller ledgers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant