Batching and ordering on the active contracts service

The active contracts service returns a stream of GetActiveContractsResponse each of which containing a list of CreatedEvents. However, afaik neither the process for batching creates into individual GetActiveContractsResponse stream elements is documented nor ordering within a batch or across batches.

Based on experiments, it seems to be the case that events are currently ordered by ledger offset. I couldn’t actually come up with a case where things get batched.

Is that correct? If so, is this a guarantee we make and should document and are there other guarantees? Or should users always treat the ACS endpoint as an unordered set of created events that are batched purely for performance reasons with no guarantees on order or batching process?

1 Like

To the best of my understanding, the fact that you may be sent a batch of create events is up to the ledger implementation. This is a possible throughput optimization that is not implemented on the sandbox.

I think there is a case to ask ledger implementations to guarantee the ordering of returned active contracts, as from the user perspective it could be an advantage in certain use cases to process a very large active contract set as if it was a stream of ordered events.

3 Likes

Are there any ledgers that do implement this optimization at the moment? vmbc maybe?

1 Like