Ledger Entry Change Events #1692
Replies: 6 comments 17 replies
-
Alternatively, we can propose CAPs that define events for subsets of ledger entry changes, similar to CAP-67. For example, we can propose a CAP that emits events for changes specific to However, I would advocate for emitting events for all possible ledger entries changes, potentially with the exception of changes to ledger entries that we plan to deprecate or remove from the protocol. |
Beta Was this translation helpful? Give feedback.
-
Would the goal be to emit 1️⃣ a generic ledger-entry-changed event that then contained a diff of the fields that changed for that entry? Or 2️⃣ are you meaning emitting domain specific events for all the conceptual reasons that ledger entries change, such as events for the creation or claiming of claimable balances? I'm 👍🏻 for adding more events to capture happenings on Stellar outside contracts. But I think we need to be specific. If we aren't specific the risk is not just about potentially emitting unnecessary events, but that we'll structure new events in ways that don't align well with their practical uses. If the goal is to emit 2️⃣, could you share a list of events alongside their topics and data? Something like this doc we did for classic asset events. Fyi there's a super discussion that is tracking all proposals for new events, and once this proposal becomes more clear we should add it to the list: |
Beta Was this translation helpful? Give feedback.
-
This is an important caveat: there is no 1:1 mapping between the contract data entries and the events emitted. Meta is still necessary to track granular changes (e.g. for block explorers). Events are needed to highlight the relevant changes.
This is not an entirely correct statement: it's sufficient to only look at the meta in order to get all the ledger entry changes. As I've pointed above, the mapping between the events and entry changes is not 1:1 in a general case. So tracking the events and tracking the ledger entry changes achieves somewhat different goals.
I think we need to specify what exactly needs to be tracked. Unified events made sense because they fit into SEP-41 data model for the most part. But in general events are an abstraction layer over the data storage, so designing them should correspond to the intended use cases and not the the internal data layout. We could of course just emit ledger entry diffs in the event format, but that wouldn't achieve the same goals as token events did. |
Beta Was this translation helpful? Give feedback.
-
I'm not particularly opinionated on this as long as we accomplish the following:
My loosely held preference is for 2️⃣, because consuming a generic ledger-entry-changed event doesn't improve the developer experience compared to consuming the ledger-entry-change XDR structs. Clients have to parse the change struct, determine the type, then iterate over the attributes they care about to determine what has changed. In my experience, developers parse the operations themselves or the If we emit domain-specific events, clients are told what the "type" is through the topic, and the data is limited to what has changed, not the full set of attributes for the entry struct. I can make an attempt at defining the events, but I suspect there will be a lot of debate on these definitions so I'd like to first make sure we're in agreement of the goals / design philosophy before proceeding. Another reason to be in favor of 2️⃣ is something @anupsdf and @MonsieurNicolas have mentioned: as TPS increases, the size of txmeta will become unsustainable. Emitting a comprehensive set of events could serve as a replacement for
Agreed, no need to emit events for contract data changes since events are already emitted by the contract to describe the relevant changes to clients.
Also agreed. Lets use "adding a signer to an account" as an example. I think this should result in something like:
|
Beta Was this translation helpful? Give feedback.
-
Ok, @leighmcculloch @dmkozh PTAL. I'm not attached to this approach but this was what made the most sense to me on the first pass. I'm sure there are several aspects of this that need correction / adjustment! Rationale
EventsAccount Created
Account Deleted (merged)
Account UpdatedExample: Set Options to Add Signer and Updated Medium Threshold
Trustline Created
Trustline UpdatedExample: SetTrustlineFlags to Deauthorize Trustline
Offer Entry Created
Offer Entry UpdatedExample: Update Offer Price and Amount
Offer Entry Deleted (pulled or crossed)
Claimable Balance Created
Liquidity Pool Created
Liquidity Pool UpdatedExample: Update Pool Reserves and Shares After Trade
Data Entry Created
Data Entry UpdatedExample: Update Data Value
Data Entry Deleted
|
Beta Was this translation helpful? Give feedback.
-
This has been suggested in the above thread ^^ but it's getting long so pulling this conversation out into another thread. I too, think we should tackle this in a very specific, use-case driven way, rather than a generic/sweeping implementation that will likely mirror what we have today (a la, horizon /effects). IMO, this means we should have separate, targeted SEPs (+ corresponding CAPs) that define the structures of these events. For example, the first couple event structures defined above are around account create/update/delete. We currently don't have any existing SEPs defined relating to contract accounts, so perhaps it is best to start there. What events would be generally useful for accounts to emit and downstreams to process, regardless of whether they are contract accounts or classic accounts? Those events should probably be codified in a SEP, and then we'd have a corresponding CAP which effectively implements the SEP for classic/built-in accounts, similar to the relationship between SEP-41 and CAP-67. I would imagine we would continue to follow this pattern. The community agrees on a SEP for a specific use-case, and then "classic" is kind of like the protocol built-in contract that we then update to implement the standard. Another are could be that defi discussion referenced above. We had actually internally taken a pass at defining part of that data model (see here - cc @karthikiyer56 ) at one point. So I guess I'm saying, maybe it's best to break up this discussion into multiple, smaller, targeted use-case based SEPs/discussions. |
Beta Was this translation helpful? Give feedback.
-
CAP-67 or "Unified Asset Events" was proposed to address this problem:
This problem was worth solving because most applications on Stellar needed to track asset movements executed using classic operations.
I'd like to propose a protocol change that tackles the generalized problem, which is:
Tracking changes to ledger entries is complex because you need to consume both Soroban events and
LedgerEntryChange
XDR structs for classic operationsThis problem is worth solving for similar reasons to why we introduced CAP-67: many applications on Stellar need to track more than just asset movements.
CAP-67 defined events to be emitted when changes were made to
AccountEntry.balance
andTrustlineEntry.balance
attributes. I am proposing that Stellar emit events for any change to any ledger entry, excluding changes to ledger entries for which we already emit events (ex.ContractDataEntry
).The objective of this proposal is to ensure all applications can track any change to the ledger solely through events.
Beta Was this translation helpful? Give feedback.
All reactions