Emit Transfer Contract Events for Classic Transfers #1553
Replies: 6 comments 31 replies
-
Define "emit"? I don't think this is even logistically possible from Core's perspective. Since smart contracts operate in their own land of execution and thus emit events into metadata via host functions, how would classic operations replicate this? Are you suggesting they inject Don't get me wrong, this sounds really nice, but I just can't see how it's possible. |
Beta Was this translation helpful? Give feedback.
-
While this seems easy enough to support for simple payments, I wonder what should we do for things like path payments, DEX trades, claimable balances etc. In Soroban world these would contain a number of transfer events, as well as maybe some other events. I don't think that's feasible for classic, as we wouldn't want to have an operation to emit a lot of events (these won't have a fee, unlike in Soroban case). I wonder if a subset of operations that move balances is sufficient to support. Basically, it would be nice to identify the requirements/use cases that we can support with certain 'classic' events. |
Beta Was this translation helpful? Give feedback.
-
Just wanted to big ➕ this! There have been a handful of conversations lately (internal + external) that have assumed or implied that we will be rebuilding or recreating the unified data models that we built out in Horizon, but now in RPC. Repeating this behavior would only recreate a lot of the issues we saw with Horizon, and allow RPC to become the defacto backend/monolith for any and all applications that want on-chain data. So yes, I'd wholeheartedly agree that the right layer to solve this at feels like the source-of-truth of the events data (ie. Core).
I think this is the right bit to start with as there's generally a lot of interest around a unified understanding of "what is a payment" or "what moves value" (lots of interest/talk around an open-source payment indexer, for example). |
Beta Was this translation helpful? Give feedback.
-
I'm a big fan of this proposal. I want to point out that there are two layers in this unification effort -- the source of the data and the format of the data. Providing a stream for all stellar asset transactions at the protocol level via events, as opposed to at the application level (like Horizon's /payments endpoint), makes sources of this data interchangeable. Clients can use RPC, a txmeta lake (produced by galaxie), captive core, or some other source of txmeta. However, I think it is equally important that we unify the format of the data provided. We could add events for all stellar asset transfers, providing a unified the stream for this data, but if the format of these events vary, clients will inevitably support a subset of these formats. We have this same problem right now with Horizon's Unfortunately I think we've already introduced multiple data formats in cases where a single format could have sufficed. For example, So lets take path payments for example. I would advocate that the event(s) emitted as a result of a path payment operation use the I'd like to see events in this format emitted for the following classic operations:
Now there are some classic operations where using the same format may not be the best path because there is not an obvious
In these cases, we may need to use a different format. The good news is that most applications won't need to care about these events because they don't use claimable balances or native AMMs. Finally, I think we should also consider emitting events for transaction fees. These are a kind XLM transfer, and anyone using events to update balances won't be able to maintain an accurate XLM balance without this event. |
Beta Was this translation helpful? Give feedback.
-
I've written up a document taking the list that @JakeUrban posted at #1553 (comment) and documenting what I think each of the events would need to be emitted to align the events with the events that the Stellar Asset Contract already emits today. https://docs.google.com/document/d/1511nhYdUiaGAJ-CT7TzVeAdBaTm4HLBgEFndfjno4jc Please leave comments about specifics directly on the document ☝🏻, or more general broad comments here 👇🏻. cc @JakeUrban appreciate your 👀 again. cc @sisuresh @dmkozh @anupsdf @MonsieurNicolas Cross-posted to Discord: https://discord.com/channels/897514728459468821/1285736582426394760/1300244089102532718 |
Beta Was this translation helpful? Give feedback.
-
@jopmiddelkamp I'd be curious on your take from Beans' perspective. Or if you'd continue using a third-party indexer, maybe you can ask your indexer to take a look at this? @earrietadev what is xBull's solution for indexing value transfers? Would this be helpful? I know from Freighter and Vibrant's perspective, this would be quite helpful because it would make our implementation much simpler. Today Vibrant listens for classic payments and path payments using RPC's Its a similar situation for Freighter. |
Beta Was this translation helpful? Give feedback.
-
What
I propose we unify transfer events on the network in smart contract events, by exploring emitting transfer contract events, like those defined by SEP-41, CAP-46-6, and those potentially defined by #1534, for classic transfers (payments, path payments, etc).
Why
To create a singe unified data stream of all movements of assets / tokens on Stellar.
Today there is no single way to consume transfer events on the network. Transfers are divided by the classic vs smart contract divide, and then also on a separate dimension by stellar assets and custom tokens.
The RPC is the way developers are intended to stream and ingest live events occurring on Stellar. The RPC exposes smart contract events. However any application using the RPC and wanting to ingest transfers must implement complex logic merging the results of streaming smart contract events and transactions containing payments, path payments, offers, so on.
The shortest paths to a payments implementation today is to go back to Horizon's /effects endpoints, or Horizon's /payments endpoint, however the migration path we're wanting to create is in the opposite direction from Horizon to the RPC. There should be a way for developers to ingest all transfers from RPC, otherwise the path for migrating from Horizon to RPC is not realistic.
We could explore ways to add payment information to RPC, such as a similar Horizon-like /effects endpoint or /payments endpoint, however I think that is solving the problem at the wrong layer and repeating mistakes of the past. We've made that mistake before with Horizon, by solving all indexing problems at the Horizon layer which encouraged folks to build on Horizon rather than innovate on new and or better data sources.
RPC's API is designed to provide a raw view into the network and live / current network data. It exposes raw transaction XDR, and raw events. RPC doesn't contain "business logic" or even "indexer logic" for understanding network data. This is critical because if you build on RPC, you're building on the same data that's also available from Galexie, other CDP tooling, or raw meta. You have access to the same data, so applications can select between them without being disadvantaged, and without artificial / convenience forcing functions causing folks to interact with one when another would be more appropriate.
What's critical is that network data be a good foundation to build on. In many ways it is, but for understanding transfers between accounts it is unfortunately not. Soroban transfers have resolved this problem for transfers originating on Soroban through Soroban events, and if classic adopted the same events network data would tell a great coherent story about transfers.
If we solve the problem at the network layer, then events on Stellar can support a unified view into the movement of value on the network.
How
All transfers / payments on Stellar classic are the result of interactions with Stellar Assets. All Stellar Assets have a reserved contract address and a reserved installation of the built-in Stellar Asset Contract. For example, on mainnet (pubnet) the
native
asset has contract addressCAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA
. Stellar classic operations can emit Soroban events using the asset's reserved contract address, even if the reserved contract address hasn't been deployed to yet for that contract. All classic transfers of value are mappable to Soroban events, because the Soroban Stellar Asset Contract was modelled on the Stellar asset classic behaviours.A proposed mapping exists at: https://docs.google.com/document/d/1511nhYdUiaGAJ-CT7TzVeAdBaTm4HLBgEFndfjno4jc
And is being discussed here: #1553 (comment)
Links
Discussion on Discord: https://discord.com/channels/897514728459468821/1285736582426394760
Beta Was this translation helpful? Give feedback.
All reactions