ride

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Undefined = EvaluationError(iota)
	UserError
	RuntimeError
	InternalInvocationError
	EvaluationFailure
	ComplexityLimitExceed
)
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.
)

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, "BurnTransaction": 10, "CreateAliasTransaction": 9, "DataEntry": 2, "DataTransaction": 9, "ExchangeTransaction": 14, "GenesisTransaction": 6, "IssueTransaction": 14, "LeaseCancelTransaction": 9, "LeaseTransaction": 10, "MassTransferTransaction": 13, "Order": 14, "PaymentTransaction": 10, "ReissueTransaction": 11, "SetAssetScriptTransaction": 10, "SetScriptTransaction": 9, "SponsorFeeTransaction": 10, "TransferTransaction": 13, "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{} /* 148 elements not displayed */
View Source
var CatalogueV4 = map[string]int{} /* 247 elements not displayed */
View Source
var CatalogueV5 = map[string]int{} /* 288 elements not displayed */
View Source
var CatalogueV6 = map[string]int{} /* 302 elements not displayed */
View Source
var CatalogueV7 = map[string]int{} /* 302 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 ConstantsV6 = []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 ConstantsV7 = []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 EvaluationCatalogueV2EvaluatorV1 = map[string]int{"!": 2, "!=": 5, "-": 2, "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": 0, "Alias": 0, "AssetPair": 0, "BurnTransaction": 0, "CreateAliasTransaction": 0, "DataEntry": 0, "DataTransaction": 0, "ExchangeTransaction": 0, "GenesisTransaction": 0, "IssueTransaction": 0, "LeaseCancelTransaction": 0, "LeaseTransaction": 0, "MassTransferTransaction": 0, "Order": 0, "PaymentTransaction": 0, "ReissueTransaction": 0, "SetAssetScriptTransaction": 0, "SetScriptTransaction": 0, "SponsorFeeTransaction": 0, "TransferTransaction": 0, "addressFromPublicKey": 65, "addressFromString": 20, "dropRight": 6, "dropRightBytes": 6, "extract": 5, "getBinary": 9, "getBoolean": 9, "getInteger": 9, "getString": 9, "isDefined": 7, "takeRight": 6, "takeRightBytes": 6, "throw": 2, "wavesBalance": 102}
View Source
var EvaluationCatalogueV2EvaluatorV2 = 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": 1, "BurnTransaction": 1, "CreateAliasTransaction": 1, "DataEntry": 1, "DataTransaction": 1, "ExchangeTransaction": 1, "GenesisTransaction": 1, "IssueTransaction": 1, "LeaseCancelTransaction": 1, "LeaseTransaction": 1, "MassTransferTransaction": 1, "Order": 1, "PaymentTransaction": 1, "ReissueTransaction": 1, "SetAssetScriptTransaction": 1, "SetScriptTransaction": 1, "SponsorFeeTransaction": 1, "TransferTransaction": 1, "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 EvaluationCatalogueV3EvaluatorV1 = map[string]int{} /* 148 elements not displayed */
View Source
var EvaluationCatalogueV3EvaluatorV2 = map[string]int{} /* 148 elements not displayed */
View Source
var EvaluationCatalogueV4EvaluatorV1 = map[string]int{} /* 247 elements not displayed */
View Source
var EvaluationCatalogueV4EvaluatorV2 = map[string]int{} /* 247 elements not displayed */
View Source
var EvaluationCatalogueV5EvaluatorV1 = map[string]int{} /* 288 elements not displayed */
View Source
var EvaluationCatalogueV5EvaluatorV2 = map[string]int{} /* 288 elements not displayed */
View Source
var EvaluationCatalogueV6EvaluatorV1 = map[string]int{} /* 302 elements not displayed */
View Source
var EvaluationCatalogueV6EvaluatorV2 = map[string]int{} /* 302 elements not displayed */
View Source
var EvaluationCatalogueV7EvaluatorV1 = map[string]int{} /* 302 elements not displayed */
View Source
var EvaluationCatalogueV7EvaluatorV2 = map[string]int{} /* 302 elements not displayed */

Functions

func EvaluationErrorCallStack added in v0.10.0

func EvaluationErrorCallStack(err error) []string

func EvaluationErrorPush added in v0.10.0

func EvaluationErrorPush(err error, format string, args ...interface{}) error

func EvaluationErrorSetComplexity added in v0.10.4

func EvaluationErrorSetComplexity(err error, complexity int) error

func EvaluationErrorSpentComplexity added in v0.10.0

func EvaluationErrorSpentComplexity(err error) int

func MaxAssetVerifierComplexity added in v0.10.4

func MaxAssetVerifierComplexity(v ast.LibraryVersion) uint32

func MaxChainInvokeComplexityByVersion added in v0.10.4

func MaxChainInvokeComplexityByVersion(version ast.LibraryVersion) (uint32, error)

func MaxVerifierComplexity added in v0.10.4

func MaxVerifierComplexity(rideV5Activated bool) uint32

Types

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

type DAppScript

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

func (*DAppScript) Run

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

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, internalPaymentsValidationHeight uint64,
	blockV5, rideV6, consensusImprovements, blockRewardDistribution, invokeExpression bool,
) (*EvaluationEnvironment, error)

func NewEnvironmentWithWrappedState added in v0.9.0

func NewEnvironmentWithWrappedState(
	env *EvaluationEnvironment,
	payments proto.ScriptPayments,
	sender proto.WavesAddress,
	isProtobufTransaction bool,
	rootScriptLibVersion ast.LibraryVersion,
	checkSenderBalance bool,
) (*EvaluationEnvironment, error)

func (*EvaluationEnvironment) ChooseMaxDataEntriesSize added in v0.10.0

func (e *EvaluationEnvironment) ChooseMaxDataEntriesSize(isRideV5 bool)

func (*EvaluationEnvironment) ChooseSizeCheck added in v0.9.0

func (e *EvaluationEnvironment) ChooseSizeCheck(v ast.LibraryVersion)

func (*EvaluationEnvironment) ChooseTakeString added in v0.9.0

func (e *EvaluationEnvironment) ChooseTakeString(isRideV5 bool)

func (*EvaluationEnvironment) SetEthereumInvoke added in v0.10.0

func (e *EvaluationEnvironment) SetEthereumInvoke(tx *proto.EthereumTransaction, v ast.LibraryVersion, payments []proto.ScriptPayment) error

func (*EvaluationEnvironment) SetInvoke added in v0.9.0

func (*EvaluationEnvironment) SetLastBlockFromBlockInfo added in v0.10.6

func (e *EvaluationEnvironment) SetLastBlockFromBlockInfo(info *proto.BlockInfo) error

func (*EvaluationEnvironment) SetLimit added in v0.10.4

func (e *EvaluationEnvironment) SetLimit(limit uint32)

func (*EvaluationEnvironment) SetThisFromAddress added in v0.9.0

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

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 EvaluationError added in v0.10.0

type EvaluationError uint

func GetEvaluationErrorType added in v0.10.0

func GetEvaluationErrorType(err error) EvaluationError

func (EvaluationError) Errorf added in v0.10.0

func (e EvaluationError) Errorf(msg string, args ...interface{}) error

func (EvaluationError) New added in v0.10.0

func (e EvaluationError) New(msg string) error

func (EvaluationError) Wrap added in v0.10.0

func (e EvaluationError) Wrap(err error, msg string) error

func (EvaluationError) Wrapf added in v0.10.0

func (e EvaluationError) Wrapf(err error, msg string, args ...interface{}) error

type Result added in v0.9.0

type Result interface {
	Result() bool
	ScriptActions() []proto.ScriptAction
	Complexity() int
	// contains filtered or unexported methods
}

func CallFunction

func CallFunction(env environment, tree *ast.Tree, fc proto.FunctionCall) (Result, error)

func CallVerifier

func CallVerifier(env environment, tree *ast.Tree) (Result, error)

type RideScript

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

func Compile

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

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

type SimpleScript

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

func (*SimpleScript) Run

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

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 *ast.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,
	localActionsCountValidator *proto.ActionsCountValidator,
) ([]proto.ScriptAction, error)

func (*WrappedState) EstimatorVersion added in v0.9.0

func (ws *WrappedState) EstimatorVersion() (int, 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) NewestAddrByAlias added in v0.9.0

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

func (*WrappedState) NewestAssetBalance added in v0.10.0

func (ws *WrappedState) NewestAssetBalance(account proto.Recipient, assetID crypto.Digest) (uint64, error)

func (*WrappedState) NewestAssetBalanceByAddressID added in v0.10.0

func (ws *WrappedState) NewestAssetBalanceByAddressID(id proto.AddressID, asset crypto.Digest) (uint64, error)

func (*WrappedState) NewestAssetInfo added in v0.9.0

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

func (*WrappedState) NewestAssetIsSponsored added in v0.9.0

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

func (*WrappedState) NewestBlockInfoByHeight added in v0.10.6

func (ws *WrappedState) NewestBlockInfoByHeight(height proto.Height) (*proto.BlockInfo, error)

func (*WrappedState) NewestFullAssetInfo added in v0.9.0

func (ws *WrappedState) NewestFullAssetInfo(asset 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) 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.WavesAddress, error)

func (*WrappedState) NewestScriptByAccount added in v0.10.0

func (ws *WrappedState) NewestScriptByAccount(account proto.Recipient) (*ast.Tree, error)

func (*WrappedState) NewestScriptByAsset added in v0.9.0

func (ws *WrappedState) NewestScriptByAsset(asset crypto.Digest) (*ast.Tree, error)

func (*WrappedState) NewestScriptBytesByAccount added in v0.10.0

func (ws *WrappedState) NewestScriptBytesByAccount(account proto.Recipient) (proto.Script, error)

func (*WrappedState) NewestScriptPKByAddr added in v0.9.0

func (ws *WrappedState) NewestScriptPKByAddr(addr proto.WavesAddress) (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) NewestWavesBalance added in v0.10.0

func (ws *WrappedState) NewestWavesBalance(account proto.Recipient) (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)

func (*WrappedState) WavesBalanceProfile added in v0.10.0

func (ws *WrappedState) WavesBalanceProfile(id proto.AddressID) (*types.WavesBalanceProfile, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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