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

State table verification #169

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Conversation

lucaszanotelli
Copy link
Contributor

@lucaszanotelli lucaszanotelli commented Nov 21, 2022

Overview

This implements Horizon's verify package to stellar-etl command export_ledger_entry_changes. It only verifies entries from checkpoint ledgers (every 64 ledgers, every ~5 minutes).

Changes

  • Add Raw* fields types AccountOutput, OfferOutput, PoolOutput, ClaimableBalanceOutput and TrustlineOutput
  • Add LedgerIsCheckpoint() function to utils package
  • Add TransformedOutput type to internal/transform/schema.go to assist the Horizon's verify package implementation
  • Refactor internal/utils/verify.go to work with stellar-etl
  • Update unit tests to add new fields

Closes GH#279
Closes GH#280
Closes GH#281

@lucaszanotelli lucaszanotelli requested a review from a team as a code owner November 21, 2022 17:41
@lucaszanotelli lucaszanotelli requested a review from a team November 21, 2022 17:41
Copy link
Contributor

@sydneynotthecity sydneynotthecity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions regarding the newly added elements in the Output structs, otherwise looks good!

}
}
}

for checkpointLedgers := range verifyOutputs {
_, err := verify.VerifyState(ctx, verifyOutputs[checkpointLedgers], archive, checkpointLedgers, verifyBatchSize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know where the verifyBatchSize comes from? Do we know that 50000 is big enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyBatchSize value came from here. About the second question, I don't know the answer. Maybe @bartekn could you help us with that?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value can be changed. It's basically as big as possible but small enough to not cause OOM crash.

internal/transform/account.go Show resolved Hide resolved
internal/transform/claimable_balance.go Show resolved Hide resolved
internal/utils/verify/main.go Outdated Show resolved Hide resolved
return false, errors.Wrap(err, "addLiquidityPoolsToStateVerifier failed")
}

return true, nil
Copy link

@bartekn bartekn Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be Verify() call after Write()'ing all ledger entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartekn calling Verify() against StateVerifier.currentEntries makes sense when these entries come from the Captive Core? I'm struggling to implement this method as it is because the logic I used in this file is different than the original one.

If implementing this is really necessary, could you shed some light on how to?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method needs one argument which is the total number of ledger entries in the user's storage (in our case: BigQuery). This is necessary because due to a bug users can have extra entries. If the provided number is equal to the total number streamed state is correct, if not it means you have extra entries. Obviously you can fool this by passing the number of entries you got from state verifier but it's better to count all entries in the storage.

Copy link
Contributor

@sydneynotthecity sydneynotthecity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and ready for release

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

Successfully merging this pull request may close these issues.

None yet

3 participants