Represents blockchain data context for ErgoTree evaluation
Segregated constants from ErgoTree, to lookup them from ConstantPlaceholder evaluation.
Accumulates computation costs.
Performs operations profiling and time measurements (if enabled in settings).
Settings to be used during evaluation.
Adds the given cost to the coster
.
Adds the given cost to the coster
. If tracing is enabled, associates the cost with
the given operation.
kind of the cost to be added to coster
operation descriptor to associate the cost with (when costTracingEnabled)
Adds the given cost to the coster
.
Adds the given cost to the coster
. If tracing is enabled, associates the cost with
the given operation.
kind of the cost to be added to coster
the operation descriptor to associate the cost with (when costTracingEnabled)
operation executed under the given cost
Adds the cost to the coster
.
Adds the cost to the coster
. See the other overload for details.
Adds the cost to the coster
.
Adds the cost to the coster
. If tracing is enabled, creates a new cost item with
the given operation descriptor and cost kind. If time measuring is enabled also
performs profiling.
WARNING: The cost is accumulated AFTER the block is executed. Each usage of this method should be accompanied with a proof of why this cannot lead to unbounded execution (see all usages).
the cost descriptor to be used to compute the cost based on the
actual number of items returned by the block
the operation to associate the cost with (when costTracingEnabled)
operation executed under the given cost descriptors, returns the actual number of items processed
Adds the cost to the coster
.
Adds the cost to the coster
. See the other overload for details.
Adds the given cost to the coster
.
Adds the given cost to the coster
. If tracing is enabled, creates a new cost item
with the given operation.
result type of the operation
the cost to be added to coster
for each item
the number of items
the operation to associate the cost with (when costTracingEnabled)
operation executed under the given cost
Adds the given cost to the coster
.
Adds the given cost to the coster
. If tracing is enabled, creates a new cost item
with the given operation.
the cost to be added to coster
for each item
the number of items
the operation to associate the cost with (when costTracingEnabled)
Add the cost given by the cost descriptor and the type to the accumulator and associate it with this operation descriptor.
Add the cost given by the cost descriptor and the type to the accumulator and associate it with this operation descriptor.
descriptor of the cost
specific type for which the cost should be computed by this descriptor (see costFunc method)
operation which is associated with this cost
Segregated constants from ErgoTree, to lookup them from ConstantPlaceholder evaluation.
Represents blockchain data context for ErgoTree evaluation
Accumulates computation costs.
Accumulates computation costs.
Evaluates the given expression in the given data environment.
Evaluates the given expression in the given data environment and accrue the cost
into the coster
of this evaluator.
Evaluates the given expression in the given data environment and accrue the cost
into the coster
of this evaluator.
the value of the expression and the total accumulated cost in the coster.
The returned cost includes the initial cost accumulated in the coster
prior to calling this method.
Performs operations profiling and time measurements (if enabled in settings).
Settings to be used during evaluation.
Implements a simple and fast direct-style interpreter of ErgoTrees.
### Motivation ErgoTree is a simple declarative intermediate representation for Ergo contracts. It is designed to be compact in serialized form and directly executable, i.e. no additional transformation is necessary before it can be efficiently executed.
This class implements a big-step recursive interpreter that works directly with ErgoTree HOAS. Because of this the evaluator is very simple and follows denotational semantics of ErgoTree (see https://ergoplatform.org/docs/ErgoTree.pdf). Or, the other way around, this implementation of ErgoTreeEvaluator is purely functional with immutable data structures and can be used as definition of ErgoTree's semantics.
### Implementation ErgoTreeEvaluator takes ErgoTree directly as it is deserialized as part of a transaction. No additional transformation is performed. ErgoTree is interpreted directly and all the intermediate data is stored in the runtime types. The runtime types are such types as special.collection.Coll, special.sigma.SigmaProp, special.sigma.AvlTree, BigInt, etc. It also use immutable Map to keep current DataEnv of computed ValDefs, as result only addition is used from the map, and deletion is essentially a garbage collection.
### Performance Since this interpreter directly works with SigmaDsl types (Coll, BigInt, SigmaProp etc), it turns out to be very fast. Since it also does JIT style costing instead of AOT style, it is 5-6x faster than existing implementation.