ScalusTag

scalus.uplc.ScalusTag
object ScalusTag

Marker injected into a compiled UPLC program to identify it as Scalus-generated.

The tag replaces the first (error) node of the program with [(error) (con integer 3)]. The argument of an application is never evaluated when the function position is error, and an (error) node reached on a successful run would make the script fail, so every (error) node in a script that succeeds is unreachable by construction. The tag therefore costs zero execution budget: only the 3 extra bytes of the constant. (On the failing path it adds one Apply step, but that transaction is invalid anyway.)

3 is Scalus's compiler id in CIP-171 (compiler_type = 3, constructor #6.124).

A program with no (error) node - a pure computation that cannot fail - has nowhere to carry a free tag and is left untagged.

This is the same mechanism Aiken uses (delay [(error) (force (error))], the branch its validators take when the body returns False) and a cheaper variant of plu-ts's dead case branch (case (constr 0) (con integer 42)).

Injection must happen after the UPLC optimizer has run, so that the set of (error) nodes is final.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ScalusTag.type

Members list

Value members

Concrete methods

def isLegacyTagged(term: Term): Boolean

True if term carries the pre-1.1 root wrapper [(lam _ body) (con string "S")].

True if term carries the pre-1.1 root wrapper [(lam _ body) (con string "S")].

Attributes

def isTagged(term: Term): Boolean

True if term carries a Scalus tag, in either the current or the legacy shape.

True if term carries a Scalus tag, in either the current or the legacy shape.

Attributes

def wrap(term: Term): Term

Tags term by marking its first (error) node. Returns term unchanged if it has none.

Tags term by marking its first (error) node. Returns term unchanged if it has none.

Attributes

Concrete fields

The payload used by the pre-1.1 root-wrapper tag, still present in deployed scripts.

The payload used by the pre-1.1 root-wrapper tag, still present in deployed scripts.

Attributes

The constant payload used as the tag marker.

The constant payload used as the tag marker.

Attributes