ride

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpHalt         byte = iota //00 - Halts program execution. No parameters.
	OpReturn                   //01 - Returns from declaration to stored position. No parameters.
	OpPush                     //02 - Put constant on stack. One parameter: constant ID.
	OpPop                      //03 - Removes value from stack. No parameters.
	OpTrue                     //04 - Put True value on stack. No parameters.
	OpFalse                    //05 - Put False value on stack. No parameters.
	OpJump                     //06 - Moves instruction pointer to new position. One parameter: new position.
	OpJumpIfFalse              //07 - Moves instruction pointer to new position if value on stack is False. One parameter: new position.
	OpProperty                 //08 - Puts value of object's property on stack. One parameter: constant ID that holds name of the property.
	OpExternalCall             //09 - Call a standard library function. Two parameters: function ID, number of arguments.
	OpCall                     //0a - Call a function declared at given address. Two parameters: position of function declaration, number of arguments.
	OpGlobal                   //0b - Load global constant. One parameter: global constant ID.
	OpLoad                     //0c - Evaluates an expression that declared at address. One parameter: position of declaration.
	OpLoadLocal                //0d - Load an argument of function call on stack. One parameter: argument number.
	OpRef                      //0e - Put reference to expression/function on stack. One parameter: position of declaration.
)
View Source
const MaxChainInvokeComplexity = 26000

Variables

View Source
var CatalogueV2 = map[string]int{"!": 11, "!=": 26, "-": 9, "0": 1, "1": 1, "100": 1, "1000": 100, "1001": 100, "1003": 100, "101": 1, "102": 1, "103": 1, "104": 1, "1040": 10, "1041": 10, "1042": 10, "1043": 10, "105": 1, "1050": 100, "1051": 100, "1052": 100, "1053": 100, "106": 1, "1060": 100, "107": 1, "2": 1, "200": 1, "201": 1, "202": 1, "203": 10, "300": 10, "303": 1, "304": 1, "305": 1, "400": 2, "401": 2, "410": 1, "411": 1, "412": 1, "420": 1, "421": 1, "500": 100, "501": 10, "502": 10, "503": 10, "600": 10, "601": 10, "602": 10, "603": 10, "Address": 1, "Alias": 1, "AssetPair": 2, "DataEntry": 2, "DataTransaction": 9, "addressFromPublicKey": 82, "addressFromString": 124, "dropRight": 19, "dropRightBytes": 19, "extract": 13, "getBinary": 30, "getBoolean": 30, "getInteger": 30, "getString": 30, "isDefined": 35, "takeRight": 19, "takeRightBytes": 19, "throw": 2, "wavesBalance": 109}
View Source
var CatalogueV3 = map[string]int{} /* 128 elements not displayed */
View Source
var CatalogueV4 = map[string]int{} /* 226 elements not displayed */
View Source
var CatalogueV5 = map[string]int{} /* 266 elements not displayed */
View Source
var ConstantsV1 = []string{"height", "tx", "unit"}
View Source
var ConstantsV2 = []string{"Buy", "CEILING", "DOWN", "FLOOR", "HALFDOWN", "HALFEVEN", "HALFUP", "Sell", "UP", "height", "nil", "tx", "unit"}
View Source
var ConstantsV3 = []string{"Buy", "CEILING", "DOWN", "FLOOR", "HALFDOWN", "HALFEVEN", "HALFUP", "MD5", "NOALG", "SHA1", "SHA224", "SHA256", "SHA3224", "SHA3256", "SHA3384", "SHA3512", "SHA384", "SHA512", "Sell", "UP", "height", "lastBlock", "nil", "this", "tx", "unit"}
View Source
var ConstantsV4 = []string{"Buy", "CEILING", "DOWN", "FLOOR", "HALFDOWN", "HALFEVEN", "HALFUP", "MD5", "NOALG", "SHA1", "SHA224", "SHA256", "SHA3224", "SHA3256", "SHA3384", "SHA3512", "SHA384", "SHA512", "Sell", "UP", "height", "lastBlock", "nil", "this", "tx", "unit"}
View Source
var ConstantsV5 = []string{"Buy", "CEILING", "DOWN", "FLOOR", "HALFEVEN", "HALFUP", "MD5", "NOALG", "SHA1", "SHA224", "SHA256", "SHA3224", "SHA3256", "SHA3384", "SHA3512", "SHA384", "SHA512", "Sell", "height", "lastBlock", "nil", "this", "tx", "unit"}
View Source
var FreeFunctionsV2 = map[string]struct{}{"Address": {}, "Alias": {}, "AssetPair": {}, "DataEntry": {}, "DataTransaction": {}}
View Source
var FreeFunctionsV3 = map[string]struct{}{"Address": {}, "Alias": {}, "AssetPair": {}, "DataEntry": {}, "DataTransaction": {}, "WriteSet": {}, "TransferSet": {}, "ScriptTransfer": {}, "ScriptResult": {}}
View Source
var FreeFunctionsV4 = map[string]struct{}{"Address": {}, "Alias": {}, "AssetPair": {}, "DataEntry": {}, "DataTransaction": {}, "WriteSet": {}, "TransferSet": {}, "ScriptTransfer": {}, "ScriptResult": {}, "IntegerEntry": {}, "BooleanEntry": {}, "BinaryEntry": {}, "StringEntry": {}, "DeleteEntry": {}, "Reissue": {}, "Burn": {}, "SponsorFee": {}, "AttachedPayment": {}}
View Source
var FreeFunctionsV5 = map[string]struct{}{"Address": {}, "Alias": {}, "AssetPair": {}, "DataEntry": {}, "DataTransaction": {}, "WriteSet": {}, "TransferSet": {}, "ScriptTransfer": {}, "ScriptResult": {}, "IntegerEntry": {}, "BooleanEntry": {}, "BinaryEntry": {}, "StringEntry": {}, "DeleteEntry": {}, "Reissue": {}, "Burn": {}, "SponsorFee": {}, "AttachedPayment": {}, "LeaseCancel": {}}

Functions

func IsDApp

func IsDApp(data []byte) bool

Types

type AssignmentNode

type AssignmentNode struct {
	Name       string
	Expression Node
	Block      Node
}

func NewAssignmentNode

func NewAssignmentNode(name string, expression, block Node) *AssignmentNode

func (*AssignmentNode) SetBlock

func (n *AssignmentNode) SetBlock(node Node)

type BooleanNode

type BooleanNode struct {
	Value bool
}

func NewBooleanNode

func NewBooleanNode(v bool) *BooleanNode

func (*BooleanNode) SetBlock

func (*BooleanNode) SetBlock(Node)

type BytesNode

type BytesNode struct {
	Value []byte
}

func NewBytesNode

func NewBytesNode(v []byte) *BytesNode

func (*BytesNode) SetBlock

func (*BytesNode) SetBlock(Node)

type ConditionalNode

type ConditionalNode struct {
	Condition       Node
	TrueExpression  Node
	FalseExpression Node
}

func NewConditionalNode

func NewConditionalNode(condition, trueExpression, falseExpression Node) *ConditionalNode

func (*ConditionalNode) SetBlock

func (*ConditionalNode) SetBlock(Node)

type DAppResult

type DAppResult struct {
	// contains filtered or unexported fields
}

func (DAppResult) Complexity added in v0.9.0

func (r DAppResult) Complexity() int

func (DAppResult) Result

func (r DAppResult) Result() bool

func (DAppResult) ScriptActions

func (r DAppResult) ScriptActions() []proto.ScriptAction

func (DAppResult) UserError

func (r DAppResult) UserError() string

type DAppScript

type DAppScript struct {
	LibVersion  int
	Code        []byte
	Constants   []rideType
	EntryPoints map[string]callable
}

func (*DAppScript) Run

func (s *DAppScript) Run(env Environment) (Result, error)

type Environment

type Environment interface {
	// contains filtered or unexported methods
}

type EvaluationEnvironment added in v0.9.0

type EvaluationEnvironment struct {
	// contains filtered or unexported fields
}

func NewEnvironment

func NewEnvironment(scheme proto.Scheme, state types.SmartState) (*EvaluationEnvironment, error)

func NewEnvironmentWithWrappedState added in v0.9.0

func NewEnvironmentWithWrappedState(env *EvaluationEnvironment, payments proto.ScriptPayments, callerPK crypto.PublicKey) (*EvaluationEnvironment, error)

func (*EvaluationEnvironment) ChooseSizeCheck added in v0.9.0

func (e *EvaluationEnvironment) ChooseSizeCheck(v int)

func (*EvaluationEnvironment) ChooseTakeString added in v0.9.0

func (e *EvaluationEnvironment) ChooseTakeString(isRideV5 bool) error

func (*EvaluationEnvironment) SetInvoke added in v0.9.0

func (*EvaluationEnvironment) SetLastBlock added in v0.9.0

func (e *EvaluationEnvironment) SetLastBlock(info *proto.BlockInfo)

func (*EvaluationEnvironment) SetThisFromAddress added in v0.9.0

func (e *EvaluationEnvironment) SetThisFromAddress(addr proto.Address)

func (*EvaluationEnvironment) SetThisFromAssetInfo added in v0.9.0

func (e *EvaluationEnvironment) SetThisFromAssetInfo(info *proto.AssetInfo)

func (*EvaluationEnvironment) SetThisFromFullAssetInfo added in v0.9.0

func (e *EvaluationEnvironment) SetThisFromFullAssetInfo(info *proto.FullAssetInfo)

func (*EvaluationEnvironment) SetTimestamp added in v0.9.0

func (e *EvaluationEnvironment) SetTimestamp(timestamp uint64)

func (*EvaluationEnvironment) SetTransaction added in v0.9.0

func (e *EvaluationEnvironment) SetTransaction(tx proto.Transaction) error

func (*EvaluationEnvironment) SetTransactionFromOrder added in v0.9.0

func (e *EvaluationEnvironment) SetTransactionFromOrder(order proto.Order) error

func (*EvaluationEnvironment) SetTransactionFromScriptAction added in v0.9.0

func (e *EvaluationEnvironment) SetTransactionFromScriptAction(action proto.ScriptAction, pk crypto.PublicKey, id crypto.Digest, ts uint64) error

func (*EvaluationEnvironment) SetTransactionFromScriptTransfer added in v0.9.0

func (e *EvaluationEnvironment) SetTransactionFromScriptTransfer(transfer *proto.FullScriptTransfer)

func (*EvaluationEnvironment) SetTransactionWithoutProofs added in v0.9.0

func (e *EvaluationEnvironment) SetTransactionWithoutProofs(tx proto.Transaction) error

type FunctionCallNode

type FunctionCallNode struct {
	Name      string
	Arguments []Node
}

func NewFunctionCallNode

func NewFunctionCallNode(name string, arguments []Node) *FunctionCallNode

func (*FunctionCallNode) SetBlock

func (*FunctionCallNode) SetBlock(Node)

type FunctionDeclarationNode

type FunctionDeclarationNode struct {
	Name      string
	Arguments []string
	Body      Node
	Block     Node
	// contains filtered or unexported fields
}

func NewFunctionDeclarationNode

func NewFunctionDeclarationNode(name string, arguments []string, body, block Node) *FunctionDeclarationNode

func (*FunctionDeclarationNode) SetBlock

func (n *FunctionDeclarationNode) SetBlock(node Node)

type LongNode

type LongNode struct {
	Value int64
}

func NewLongNode

func NewLongNode(v int64) *LongNode

func (*LongNode) SetBlock

func (*LongNode) SetBlock(Node)

type Node

type Node interface {
	SetBlock(node Node)
	// contains filtered or unexported methods
}

type PropertyNode

type PropertyNode struct {
	Name   string
	Object Node
}

func NewPropertyNode

func NewPropertyNode(name string, object Node) *PropertyNode

func (*PropertyNode) SetBlock

func (*PropertyNode) SetBlock(Node)

type ReferenceNode

type ReferenceNode struct {
	Name string
}

func NewReferenceNode

func NewReferenceNode(name string) *ReferenceNode

func (*ReferenceNode) SetBlock

func (*ReferenceNode) SetBlock(Node)

type Result added in v0.9.0

type Result interface {
	Result() bool
	UserError() string

	ScriptActions() []proto.ScriptAction
	Complexity() int
	// contains filtered or unexported methods
}

func CallFunction

func CallFunction(env Environment, tree *Tree, name string, args proto.Arguments) (Result, error)

func CallVerifier

func CallVerifier(env Environment, tree *Tree) (Result, error)

type RideScript

type RideScript interface {
	Run(env Environment) (Result, error)
	// contains filtered or unexported methods
}

func Compile

func Compile(tree *Tree) (RideScript, error)

type ScriptMeta

type ScriptMeta struct {
	Version int
	Bytes   []byte
}

type ScriptResult

type ScriptResult struct {
	// contains filtered or unexported fields
}

func (ScriptResult) Complexity added in v0.9.0

func (r ScriptResult) Complexity() int

func (ScriptResult) Result

func (r ScriptResult) Result() bool

func (ScriptResult) ScriptActions

func (r ScriptResult) ScriptActions() []proto.ScriptAction

func (ScriptResult) UserError

func (r ScriptResult) UserError() string

type SimpleScript

type SimpleScript struct {
	LibVersion int
	EntryPoint int
	Code       []byte
	Constants  []rideType
}

func (*SimpleScript) Run

func (s *SimpleScript) Run(env Environment) (Result, error)

type StringNode

type StringNode struct {
	Value string
}

func NewStringNode

func NewStringNode(v string) *StringNode

func (*StringNode) SetBlock

func (*StringNode) SetBlock(Node)

type Tree

type Tree struct {
	Digest       [32]byte
	AppVersion   int
	LibVersion   int
	HasBlockV2   bool
	Meta         ScriptMeta
	Declarations []Node
	Functions    []Node
	Verifier     Node
}

func Parse

func Parse(source []byte) (*Tree, error)

func (*Tree) HasVerifier

func (t *Tree) HasVerifier() bool

func (*Tree) IsDApp

func (t *Tree) IsDApp() bool

type TreeEstimation

type TreeEstimation struct {
	Estimation int            `cbor:"0,keyasint"`
	Verifier   int            `cbor:"1,keyasint,omitempty"`
	Functions  map[string]int `cbor:"2,keyasint,omitempty"`
}

func EstimateTree

func EstimateTree(tree *Tree, v int) (TreeEstimation, error)

type WrappedState added in v0.9.0

type WrappedState struct {
	// contains filtered or unexported fields
}

func (*WrappedState) AddingBlockHeight added in v0.9.0

func (ws *WrappedState) AddingBlockHeight() (uint64, error)

func (*WrappedState) ApplyToState added in v0.9.0

func (ws *WrappedState) ApplyToState(actions []proto.ScriptAction, env Environment) ([]proto.ScriptAction, error)

func (*WrappedState) BlockVRF added in v0.9.0

func (ws *WrappedState) BlockVRF(blockHeader *proto.BlockHeader, height proto.Height) ([]byte, error)

func (*WrappedState) EstimatorVersion added in v0.9.0

func (ws *WrappedState) EstimatorVersion() (int, error)

func (*WrappedState) GetByteTree added in v0.9.0

func (ws *WrappedState) GetByteTree(recipient proto.Recipient) (proto.Script, error)

func (*WrappedState) IsNotFound added in v0.9.0

func (ws *WrappedState) IsNotFound(err error) bool

func (*WrappedState) IsStateUntouched added in v0.9.0

func (ws *WrappedState) IsStateUntouched(account proto.Recipient) (bool, error)

func (*WrappedState) NewestAccountBalance added in v0.9.0

func (ws *WrappedState) NewestAccountBalance(account proto.Recipient, assetID []byte) (uint64, error)

func (*WrappedState) NewestAddrByAlias added in v0.9.0

func (ws *WrappedState) NewestAddrByAlias(alias proto.Alias) (proto.Address, error)

func (*WrappedState) NewestAssetInfo added in v0.9.0

func (ws *WrappedState) NewestAssetInfo(assetID crypto.Digest) (*proto.AssetInfo, error)

func (*WrappedState) NewestAssetIsSponsored added in v0.9.0

func (ws *WrappedState) NewestAssetIsSponsored(assetID crypto.Digest) (bool, error)

func (*WrappedState) NewestFullAssetInfo added in v0.9.0

func (ws *WrappedState) NewestFullAssetInfo(assetID crypto.Digest) (*proto.FullAssetInfo, error)

func (*WrappedState) NewestFullWavesBalance added in v0.9.0

func (ws *WrappedState) NewestFullWavesBalance(account proto.Recipient) (*proto.FullWavesBalance, error)

func (*WrappedState) NewestHeaderByHeight added in v0.9.0

func (ws *WrappedState) NewestHeaderByHeight(height proto.Height) (*proto.BlockHeader, error)

func (*WrappedState) NewestLeasingInfo added in v0.9.0

func (ws *WrappedState) NewestLeasingInfo(id crypto.Digest) (*proto.LeaseInfo, error)

func (*WrappedState) NewestRecipientToAddress added in v0.9.0

func (ws *WrappedState) NewestRecipientToAddress(recipient proto.Recipient) (*proto.Address, error)

func (*WrappedState) NewestScriptByAsset added in v0.9.0

func (ws *WrappedState) NewestScriptByAsset(asset proto.OptionalAsset) (proto.Script, error)

func (*WrappedState) NewestScriptPKByAddr added in v0.9.0

func (ws *WrappedState) NewestScriptPKByAddr(addr proto.Address) (crypto.PublicKey, error)

func (*WrappedState) NewestTransactionByID added in v0.9.0

func (ws *WrappedState) NewestTransactionByID(id []byte) (proto.Transaction, error)

func (*WrappedState) NewestTransactionHeightByID added in v0.9.0

func (ws *WrappedState) NewestTransactionHeightByID(id []byte) (uint64, error)

func (*WrappedState) RetrieveNewestBinaryEntry added in v0.9.0

func (ws *WrappedState) RetrieveNewestBinaryEntry(account proto.Recipient, key string) (*proto.BinaryDataEntry, error)

func (*WrappedState) RetrieveNewestBooleanEntry added in v0.9.0

func (ws *WrappedState) RetrieveNewestBooleanEntry(account proto.Recipient, key string) (*proto.BooleanDataEntry, error)

func (*WrappedState) RetrieveNewestIntegerEntry added in v0.9.0

func (ws *WrappedState) RetrieveNewestIntegerEntry(account proto.Recipient, key string) (*proto.IntegerDataEntry, error)

func (*WrappedState) RetrieveNewestStringEntry added in v0.9.0

func (ws *WrappedState) RetrieveNewestStringEntry(account proto.Recipient, key string) (*proto.StringDataEntry, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL