Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package daml
    Definition Classes
    com
  • package ledger
    Definition Classes
    daml
  • package participant
    Definition Classes
    ledger
  • package state
    Definition Classes
    participant
  • package v2

    Interfaces to read from and write to an (abstract) participant state.

    Interfaces to read from and write to an (abstract) participant state.

    A Daml ledger participant is code that allows to actively participate in the evolution of a shared Daml ledger. Each such participant maintains a particular view onto the state of the Daml ledger. We call this view the participant state.

    Actual implementations of a Daml ledger participant will likely maintain more state than what is exposed through the interfaces in this package, which is why we talk about an abstract participant state. It abstracts over the different implementations of Daml ledger participants.

    The interfaces are optimized for easy implementation. The v2.WriteService interface contains the methods for changing the participant state (and potentially the state of the Daml ledger), which all ledger participants must support. These methods are for example exposed via the Daml Ledger API. Actual ledger participant implementations likely support more implementation-specific methods. They are however not exposed via the Daml Ledger API. The v2.ReadService interface contains the one method v2.ReadService.stateUpdates to read the state of a ledger participant. It represents the participant state as a stream of v2.Updates to an initial participant state. The typical consumer of this method is a class that subscribes to this stream of v2.Updates and reconstructs (a view of) the actual participant state. See the comments on v2.Update and v2.ReadService.stateUpdates for details about the kind of updates and the guarantees given to consumers of the stream of v2.Updates.

    We do expect the interfaces provided in com.daml.ledger.participant.state to evolve, which is why we provide them all in the com.daml.ledger.participant.state.v2 package. Where possible we will evolve them in a backwards compatible fashion, so that a simple recompile suffices to upgrade to a new version. Where that is not possible, we plan to introduce new version of this API in a separate package and maintain it side-by-side with the existing version if possible. There can therefore potentially be multiple versions of participant state APIs at the same time. We plan to deprecate and drop old versions on separate and appropriate timelines.

    Definition Classes
    state
  • ChangeId
  • CompletionInfo
  • DivulgedContract
  • PruningResult
  • ReadService
  • SubmissionResult
  • SubmitterInfo
  • TransactionMeta
  • Update
  • WriteConfigService
  • WritePackagesService
  • WriteParticipantPruningService
  • WritePartyService
  • WriteService

trait ReadService extends ReportsHealth

An interface for reading the state of a ledger participant. Please note that this interface is unstable and may significantly change.

The state of a ledger participant is communicated as a stream of state Updates. That stream is accessible via ReadService!.stateUpdates. Commonly that stream is processed by a single consumer that keeps track of the current state and creates indexes to satisfy read requests against that state.

See com.daml.ledger.participant.state.v2 for further architectural information. See Update for a description of the state updates communicated by ReadService!.stateUpdates.

Linear Supertypes
ReportsHealth, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ReadService
  2. ReportsHealth
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def currentHealth(): HealthStatus
    Definition Classes
    ReportsHealth
  2. abstract def ledgerInitialConditions(): Source[LedgerInitialConditions, NotUsed]

    Retrieve the static initial conditions of the ledger, containing the ledger identifier, the ledger config and the initial ledger record time.

    Retrieve the static initial conditions of the ledger, containing the ledger identifier, the ledger config and the initial ledger record time.

    Returns a single element Source since the implementation may need to first establish connectivity to the underlying ledger. The implementer may assume that this method is called only once, or very rarely. Source is being used instead of Future as this is in line with stateUpdates, and is easy to implement from both Java and Scala.

  3. abstract def stateUpdates(beginAfter: Option[Offset])(implicit loggingContext: LoggingContext): Source[(Offset, Update), NotUsed]

    Get the stream of state Updates starting from the beginning or right after the given Offset

    Get the stream of state Updates starting from the beginning or right after the given Offset

    This is where the meat of the implementation effort lies. Please take your time to read carefully through the properties required from correct implementations. These properties fall into two categories:

    1. properties about the sequence of Update) tuples in a stream read from the beginning, and 2. properties relating the streams obtained from separate calls to ReadService.stateUpdates.

    The first class of properties are invariants of a single stream:

    - *strictly increasing Offsets*: for any two consecutive tuples (o1, u1) and (o2, u2), o1 is strictly smaller than o2.

    - *initialize before transaction acceptance*: before any Update.TransactionAccepted, there is a Update.ConfigurationChanged update and Update.PublicPackageUpload updates for all packages referenced by the Update.TransactionAccepted.

    - *causal monotonicity*: given a Update.TransactionAccepted with an associated ledger time lt_tx, it holds that lt_tx >= lt_c for all c, where c is a contract used by the transaction and lt_c the ledger time of the Update.TransactionAccepted that created the contract. The ledger time of a transaction is specified in the corresponding TransactionMeta meta-data. Note that the ledger time of unrelated updates is not necessarily monotonically increasing. The creating transaction need not have a Update.TransactionAccepted even on this participant if the participant does not host a stakeholder of the contract, e.g., in the case of divulgence.

    - *time skew*: given a Update.TransactionAccepted with an associated ledger time lt_tx and a record time rt_tx, it holds that rt_TX - minSkew <= lt_TX <= rt_TX + maxSkew, where minSkew and maxSkew are parameters specified in the ledger com.daml.ledger.configuration.LedgerTimeModel of the last Update.ConfigurationChanged before the Update.TransactionAccepted.

    - *command deduplication*: Let there be a Update.TransactionAccepted with CompletionInfo or a Update.CommandRejected with CompletionInfo at offset off2. If off2's CompletionInfo.optDeduplicationPeriod is a api.DeduplicationPeriod.DeduplicationOffset, let off1 be the first offset after the deduplication offset. If the deduplication period is a api.DeduplicationPeriod.DeduplicationDuration, let off1 be the first offset whose record time is at most the duration before off2's record time (inclusive). Then there is no other Update.TransactionAccepted with CompletionInfo for the same CompletionInfo.changeId between the offsets off1 and off2 inclusive.

    So if a command submission has resulted in a Update.TransactionAccepted, other command submissions with the same SubmitterInfo.changeId must be deduplicated if the earlier's Update.TransactionAccepted falls within the latter's CompletionInfo.optDeduplicationPeriod.

    Implementations MAY extend the deduplication period from SubmitterInfo arbitrarily and reject a command submission as a duplicate even if its deduplication period does not include the earlier's Update.TransactionAccepted. A Update.CommandRejected completion does not trigger deduplication and implementations SHOULD process such resubmissions normally.

    - *finality*: If the corresponding WriteService acknowledges a submitted transaction or rejection with SubmissionResult.Acknowledged, the ReadService SHOULD make sure that it eventually produces a Update.TransactionAccepted or Update.CommandRejected with the corresponding CompletionInfo, even if there are crashes or lost network messages.

    The second class of properties relates multiple calls to ReadService.stateUpdates to each other. The class contains two properties: (1) a property that enables crash-fault tolerant Ledger API server implementations and (2) a property that enables Ledger API server implementations that are synchronized by a backing ledger.

    For crash-fault-tolerance, we require an implementation of ReadService.stateUpdates to support its consumer to resume consumption starting after the last offset up to which the consumer completed processing. Note that this offset can be before the offset of several of the latest delivered Updates in case the consumer did not complete their processing before crashing.

    Formally, we require that the above invariants also hold for any sequence of offset-and-update pairs

    us = takeUntilOffset(us_1, o_2) + takeUntilOffset(us_2, o_3) + ... + takeUntilOffset(us_N-1, o_N) + us_N

    where us_i = ReadService.stateUpdates(o_i) and lastOffsetOf(us_i) >= o_i+1. Here, us_i is the sequence of offset-and-update pairs sourced from a call to ReadService.stateUpdates and the side-condition formalizes that later calls must start from an offset before or equal to the last offset delivered in the previous call.

    For synchronization, we require that two parties hosted on separate participant nodes are in sync on transaction nodes and contracts that they can both see. The more formal definition is based on the notion of projections of transactions (see https://docs.daml.com/concepts/ledger-model/ledger-privacy.html), as follows.

    Assume that there is - a party A hosted at participant p1, - a party B hosted at participant p2, and - an accepted transaction with identifier tid evidenced to both participants p1 and p2 in their state update streams after the Update.PartyAddedToParticipant updates for A, respectively B. The projections of tx1 and tx2 to the nodes visible to both A and B is the same.

    Note that the transaction tx1 associated to tid on p1 is not required to be the same as the transaction tx2 associated to tid on p2, as these two participants do not necessarily host the same parties; and some implementations ensure data segregation on the ledger. Requiring only the projections to sets of parties to be equal leaves just enough leeway for this data segregation.

    Note further that the offsets of the transactions might not agree, as these offsets are participant-local.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  14. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  15. def toString(): String
    Definition Classes
    AnyRef → Any
  16. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  17. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from ReportsHealth

Inherited from AnyRef

Inherited from Any

Ungrouped