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

services/horizon/ingest: express parsing routines for Offers as public, reusable functions #5414

Open
sreuland opened this issue Aug 6, 2024 · 1 comment

Comments

@sreuland
Copy link
Contributor

sreuland commented Aug 6, 2024

What problem does your feature solve?

New application development that needs to run ingestion pipeline will tend to implement(repeat) many similar parsing routines to generate derived 'Offer' models that Horizon ingestion does internally.

Horizon has many routines that are package private, internal to ingestion which parse and derive 'Offer' from stellar tx meta, so, they can't be re-used externally as-is.

What would you like to see?

Follows same design proposal for reusable transformer function for a common model

A few of these private ingestion parsing routines in Horizon exposed as pure(no side effects) functions and package public so they can be re-used by external apps to derive the same 'Offer' data models quickly in their ingestion pipelines.

The presence of public functions for parsing 'Offer' model can further encourage external adoption of proposed streaming ingestion pipeline of which operators within a stream invoke these functions directly to include offers data in their stream processing.

Create new pure function and model for 'Offer' in the shared ingest package. Horizon internal ingestion should not be changed or refactored, later this may be revisited.

  • ingest.HasOffer(op xdr.Operation) bool

  • for all operations that qualified as offer in HasOffer(), pull up the 'details' parsing routines of these operations from transactionOperationWrapper.Details() and fold into -> ingest.DeriveOffer(tx xdr.Transaction, op xdr.Operation) []OfferEvent:

    • managebuy
    • managesell
    • createsell
  • Offer data is modeled as a derived event representing the life cycle events of an offer, this is initial estimate of event schema, during effort, can change these:

  type OfferPartiallyFilledEvent struct {    
        Price:                         "8.0000000"
        Amount:                    "89.9342000"
        PriceAssetRatioD:    "1"
        PriceAssetRatioN:    "8"
        BuyingAsset:            "native"
        SellingAsset:             "XCZ:GC2BTZPHJEVOGPW6MJUVUPANWLRGK3JMD26ZMP64ZRMYXBRSW5CIKEW5"
        Timestamp:               "1723153694"
   }
type OfferCreatedEvent struct {    
        Price:                         "8.0000000"
        Amount:                    "89.9342000"
        PriceAssetRatioD:    "1"
        PriceAssetRatioN:    "8"
        BuyingAsset:            "native"
        SellingAsset:             "XCZ:GC2BTZPHJEVOGPW6MJUVUPANWLRGK3JMD26ZMP64ZRMYXBRSW5CIKEW5"
        Timestamp:               "1723153694"
   }
type OfferClosedEvent struct {    
        BuyingAsset:            "native"
        SellingAsset:             "XCZ:GC2BTZPHJEVOGPW6MJUVUPANWLRGK3JMD26ZMP64ZRMYXBRSW5CIKEW5"
        Timestamp:               "1723153694"
   }

  • Unit test coverage on new functions added to ingest package

Visualization of where this transform function fits in the larger CDP design for data pipeline:

Image

What alternatives are there?

we don't publicize the routines, external apps use horizon code as reference, and will clone from this to their codebase as they choose to re-implement.

@sreuland sreuland changed the title services/horizon/ingest: express offers parsing routines as public, reusable functions services/horizon/ingest: express parsing routines for Offers as public, reusable functions Aug 8, 2024
@tamirms tamirms added this to the platform sprint 51 milestone Sep 17, 2024
@karthikiyer56
Copy link
Contributor

Is there a notion of OfferCancelled at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

4 participants