Serialized bytes of this tree.
The default equality of case class is overridden to exclude complexity
.
The default equality of case class is overridden to exclude complexity
.
Structural complexity estimation of this tree.
Structural complexity estimation of this tree.
ComplexityTable
If isConstantSegregation == true contains the constants for which there may be ConstantPlaceholders in the tree.
If isConstantSegregation == true contains the constants for which there may be ConstantPlaceholders in the tree. If isConstantSegregation == false this array should be empty and any placeholder in the tree will lead to exception.
Returns true if the tree contains at least one deserialization operation, false otherwise.
the first byte of serialized byte array which determines interpretation of the rest of the array
On the right side it has valid expression of SigmaProp
type.
On the right side it has valid expression of SigmaProp
type. Or alternatively,
on the left side, it has unparsed bytes along with the ValidationException,
which caused the deserializer to fail.
Right(tree)
if isConstantSegregation == true contains ConstantPlaceholder
instead of some Constant nodes. Otherwise, it may not contain placeholders.
It is possible to have both constants and placeholders in the tree, but for every placeholder
there should be a constant in constants
array.
Serialized proposition expression of SigmaProp type with ConstantPlaceholder nodes instead of Constant nodes
Get proposition expression from this contract.
Get proposition expression from this contract.
When root.isRight then
if replaceConstants == false this is the same as root.right.get
.
Otherwise, it is equivalent to root.right.get
where all placeholders are replaced by Constants.
When root.isLeft then
throws the error from UnparsedErgoTree.
It does so on every usage of proposition
because the lazy value remains uninitialized.
Then it throws the error from UnparsedErgoTree.
Then it throws the error from UnparsedErgoTree.
It does so on every usage of proposition
because the lazy value remains uninitialized.
(Since version v2.1) Use toProposition instead
The root of ErgoScript IR. Serialized instances of this class are self sufficient and can be passed around. ErgoTreeSerializer defines top-level serialization format of the scripts. The interpretation of the byte array depend on the first
header
byte, which uses VLQ encoding up to 30 bits. Currently we define meaning for only first byte, which may be extended in future versions. 7 6 5 4 3 2 1 0 ------------------------- | | | | | | | | | ------------------------- Bit 7 == 1 if the header contains more than 1 byte (default == 0) Bit 6 - reserved for GZIP compression (should be 0) Bit 5 == 1 - reserved for context dependent costing (should be = 0) Bit 4 == 1 if constant segregation is used for this ErgoTree (default = 0) (see https://github.com/ScorexFoundation/sigmastate-interpreter/issues/264) Bit 3 == 1 if size of the whole tree is serialized after the header byte (default = 0) Bits 2-0 - language version (current version == 0)Currently we don't specify interpretation for the second and other bytes of the header. We reserve the possibility to extend header by using Bit 7 == 1 and chain additional bytes as in VLQ. Once the new bytes are required, a new version of the language should be created and implemented. That new language will give an interpretation for the new bytes.
Consistency between fields is ensured by private constructor and factory methods in
ErgoTree
object. For performance reasons, ErgoTreeSerializer can be configured to perform additional constant segregation. In such a case after deserialization there may be more constants segregated. This is done for example to support caching optimization described in #264 mentioned above.The default behavior of ErgoTreeSerializer is to preserve original structure of ErgoTree and check consistency. In case of any inconsistency the serializer throws exception.