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.
- Alphabetic
- By Inheritance
- Engine
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Engine(config: EngineConfig = Engine.StableConfig)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clearPackages(): Unit
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- 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.
- def computeInterfaceView(templateId: Identifier, argument: Value, interfaceId: Identifier)(implicit loggingContext: LoggingContext): Result[Versioned[Value]]
Given a contract argument of the given template id, calculate the interface view of that API.
- val config: EngineConfig
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def info: EngineInfo
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- 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.
- def reinterpret(submitters: Set[Party], command: ReplayCommand, 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 theTx.MetaData
component of the output is always set toempty
. - def replay(submitters: Set[Party], tx: SubmittedTransaction, ledgerEffectiveTime: Timestamp, participantId: ParticipantId, submissionTime: Timestamp, submissionSeed: Hash)(implicit loggingContext: LoggingContext): Result[(SubmittedTransaction, Metadata)]
- def submit(submitters: Set[Party], readAs: Set[Party], cmds: ApiCommands, disclosures: ImmArray[DisclosedContract] = ImmArray.empty, participantId: ParticipantId, submissionSeed: Hash)(implicit loggingContext: LoggingContext): Result[(SubmittedTransaction, Metadata)]
Executes commands
cmds
under the authority ofsubmitters
, with additional readersreadAs
, and returns one of the following:Executes commands
cmds
under the authority ofsubmitters
, with additional readersreadAs
, and returns one of the following:-
ResultDone(tx)
ifcmds
could be successfully executed, wheretx
is the resulting transaction. The transactiontx
conforms to the Daml model consisting of the packages that have been supplied viaResultNeedPackage.resume
to this Engine. The transactiontx
is internally consistent. -
ResultNeedContract(contractId, resume)
if the contract referenced bycontractId
is needed to executecmds
. -
ResultNeedPackage(packageId, resume)
if the package referenced bypackageId
is needed to executecmds
. -
ResultError
if the execution ofcmds
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.
-
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- 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
- 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.
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated