class Engine extends AnyRef

Allows for evaluating Commands and validating Transactions.

This class does not dereference contract ids or package ids on its own. Instead, when an instance of this class needs to dereference a contract id or package id, it returns a ResultNeedContract or ResultNeedPackage to the caller. The caller can then resume the computation by calling result.resume. The engine may or may not cache and reuse the provided contract instance or package.

The caller must dereference contract and package ids consistently, i.e., if the same engine returns result1 and result2, result1 and result2 request to dereference the same contract or package id, and the caller invokes result1.resume(x1) and result2.resume(x2), then x1 must equal x2.

The caller may deference ids inconsistently across different engines. Namely, if two different engines return result1 and result2, then the caller may call result1.resume(x1) and result2.resume(x2) with x1 != x2, even if result1 and result2 request to dereference the same id.

The class requires a pseudo random generator (nextRandomInt) to randomize the submission time. This generator does not have to be cryptographically secure.

This class is thread safe as long nextRandomInt is.

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

Instance Constructors

  1. new Engine(config: EngineConfig = Engine.StableConfig)

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 clearPackages(): Unit
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  7. def compiledPackages(): CompiledPackages

    Note: it's important we return a com.daml.lf.CompiledPackages, and not a ConcurrentCompiledPackages, otherwise people would be able to modify them.

  8. val config: EngineConfig
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  13. def info: EngineInfo
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  18. def preloadPackage(pkgId: PackageId, pkg: Package): Result[Unit]

    This function can be used to give a package to the engine pre-emptively, rather than having the engine to ask about it through ResultNeedPackage.

    This function can be used to give a package to the engine pre-emptively, rather than having the engine to ask about it through ResultNeedPackage.

    Returns a Result because the package might need another package to be loaded.

  19. def reinterpret(submitters: Set[Party], command: Command, nodeSeed: Option[Hash], submissionTime: Timestamp, ledgerEffectiveTime: Timestamp)(implicit loggingContext: LoggingContext): Result[(SubmittedTransaction, Metadata)]

    Behaves like submit, but it takes a single command argument.

    Behaves like submit, but it takes a single command argument. It can be used to reinterpret partially an already interpreted transaction.

    If the command would fail with an unhandled exception, we return a transaction containing a single rollback node. (This is achieving by compiling with unsafeCompileForReinterpretation which wraps the command with a catch-everything exception handler.)

    nodeSeed is the seed of the Create and Exercise node as generated during submission. If undefined the contract IDs are derive using V0 scheme. The value of nodeSeed does not matter for other kind of nodes.

    The reinterpretation does not recompute the package dependencies, so the field usedPackages in the Tx.MetaData component of the output is always set to empty.

  20. def replay(submitters: Set[Party], tx: SubmittedTransaction, ledgerEffectiveTime: Timestamp, participantId: ParticipantId, submissionTime: Timestamp, submissionSeed: Hash)(implicit loggingContext: LoggingContext): Result[(SubmittedTransaction, Metadata)]
  21. def submit(submitters: Set[Party], readAs: Set[Party], cmds: Commands, participantId: ParticipantId, submissionSeed: Hash)(implicit loggingContext: LoggingContext): Result[(SubmittedTransaction, Metadata)]

    Executes commands cmds under the authority of submitters, with additional readers readAs, and returns one of the following:

    Executes commands cmds under the authority of submitters, with additional readers readAs, and returns one of the following:

    • ResultDone(tx) if cmds could be successfully executed, where tx is the resulting transaction. The transaction tx conforms to the Daml model consisting of the packages that have been supplied via ResultNeedPackage.resume to this Engine. The transaction tx is internally consistent.
    • ResultNeedContract(contractId, resume) if the contract referenced by contractId is needed to execute cmds.
    • ResultNeedPackage(packageId, resume) if the package referenced by packageId is needed to execute cmds.
    • ResultError if the execution of cmds fails. The execution may fail due to an error during Daml evaluation (e.g. execution of "abort") or because the caller has not provided a required contract instance or package.

    transactionSeed is the master hash used to derive node and contractId discriminator. If left undefined, no discriminator will be generated.

    This method does perform authorization checks

    The resulting transaction is annotated with packages required to validate it.

  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. def validate(submitters: Set[Party], tx: SubmittedTransaction, ledgerEffectiveTime: Timestamp, participantId: ParticipantId, submissionTime: Timestamp, submissionSeed: Hash)(implicit loggingContext: LoggingContext): Result[Unit]

    Check if the given transaction is a valid result of some single-submitter command.

    Check if the given transaction is a valid result of some single-submitter command.

    Formally, for all tx, pcs, pkgs, keys: evaluate(validate(tx, ledgerEffectiveTime)) == ResultDone(()) <==> exists cmds. evaluate(submit(cmds)) = tx where: evaluate(result) = result.consume(pcs, pkgs, keys)

    A transaction may contain relative contract IDs and still pass validation, but not in the root nodes.

    This is enforced since commands cannot contain relative contract ids, and we check that root nodes come from commands.

    tx

    a complete unblinded Transaction to be validated

    ledgerEffectiveTime

    time when the transaction is claimed to be submitted

  25. def validatePackages(pkgs: Map[PackageId, Package]): Either[Error.Package.Error, Unit]

    This method checks a set of packages is self-consistent (it contains all its dependencies), contains only well-formed packages (See Daml-LF spec for more details) and uses only the allowed language versions (as described by the engine config).

    This method checks a set of packages is self-consistent (it contains all its dependencies), contains only well-formed packages (See Daml-LF spec for more details) and uses only the allowed language versions (as described by the engine config). This is not affected by config.packageValidation flag. Package in pkgIds but not in pkgs are assumed to be preloaded.

  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  28. 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 AnyRef

Inherited from Any

Ungrouped