vmcontext

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0, BSD-2-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const OffLedgerNonceStrictOrderTolerance = 10000

TODO temporary place for the constant. In the future must be shared with pruning module

the number is approximate assumed maximum number of requests in the batch
The node must guarantee at least this number of last requests processed recorded in the state
for each address

Variables

View Source
var (
	NewSandbox     func(vmctx *VMContext) iscp.Sandbox
	NewSandboxView func(vmctx *VMContext) iscp.SandboxView
)
View Source
var (
	MaxBlockOutputCount = uint8(ledgerstate.MaxOutputCount - 1) // -1 for the chain transition output
	MaxBlockInputCount  = uint8(ledgerstate.MaxInputCount - 2)  // // 125 (126 limit -1 for the previous state utxo)
)
View Source
var ErrContractNotFound = errors.New("contract not found")

Functions

func Accrue added in v0.2.0

func Accrue(ctx iscp.Sandbox, target *iscp.AgentID, tokens colored.Balances) error

Accrue calls "deposit" entry point of the accounts contract. Can only be called from full sandbox context

Types

type VMContext

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

VMContext represents state of the chain during one run of the VM while processing a batch of requests. VMContext object mutates with each request in the bathc. The VMContext is created from immutable vm.VMTask object and UTXO state of the chain address contained in the statetxbuilder.Builder

func CreateVMContext added in v0.2.0

func CreateVMContext(task *vm.VMTask) *VMContext

CreateVMContext creates a context for the whole batch run

func (*VMContext) AccountID added in v0.2.0

func (vmctx *VMContext) AccountID() *iscp.AgentID

func (*VMContext) BlockContext added in v0.2.0

func (vmctx *VMContext) BlockContext(ctx iscp.Sandbox, construct func(ctx iscp.Sandbox) interface{}, onClose func(interface{})) interface{}

func (*VMContext) BuildTransactionEssence added in v0.2.0

func (vmctx *VMContext) BuildTransactionEssence(stateHash hashing.HashValue, timestamp time.Time) (*ledgerstate.TransactionEssence, error)

func (*VMContext) Call

func (vmctx *VMContext) Call(targetContract, epCode iscp.Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error)

Call

func (*VMContext) Caller

func (vmctx *VMContext) Caller() *iscp.AgentID

func (*VMContext) ChainID

func (vmctx *VMContext) ChainID() *iscp.ChainID

func (*VMContext) ChainOwnerID

func (vmctx *VMContext) ChainOwnerID() *iscp.AgentID

func (*VMContext) CloseVMContext added in v0.2.0

func (vmctx *VMContext) CloseVMContext(numRequests, numSuccess, numOffLedger uint16) (uint32, hashing.HashValue, time.Time, ledgerstate.Address)

CloseVMContext does the closing actions on the block return nil for normal block and rotation address for rotation block

func (*VMContext) ContractCreator

func (vmctx *VMContext) ContractCreator() *iscp.AgentID

func (*VMContext) CurrentContractHname

func (vmctx *VMContext) CurrentContractHname() iscp.Hname

func (*VMContext) Debugf

func (vmctx *VMContext) Debugf(format string, params ...interface{})

func (*VMContext) DeployContract

func (vmctx *VMContext) DeployContract(programHash hashing.HashValue, name, description string, initParams dict.Dict) error

DeployContract deploys contract by its program hash - if called from 'root' contract only loads VM from binary - otherwise calls 'root' contract 'DeployContract' entry point to do the job.

func (*VMContext) Entropy

func (vmctx *VMContext) Entropy() hashing.HashValue

func (*VMContext) GetBalance

func (vmctx *VMContext) GetBalance(col colored.Color) uint64

func (*VMContext) GetIncoming

func (vmctx *VMContext) GetIncoming() colored.Balances

func (*VMContext) GetMyBalances

func (vmctx *VMContext) GetMyBalances() colored.Balances

func (*VMContext) GetResult

func (vmctx *VMContext) GetResult() (dict.Dict, colored.Balances, error, bool)

func (*VMContext) GoverningAddress added in v0.2.0

func (vmctx *VMContext) GoverningAddress() ledgerstate.Address

func (*VMContext) Infof

func (vmctx *VMContext) Infof(format string, params ...interface{})

func (*VMContext) IsRequestContext

func (vmctx *VMContext) IsRequestContext() bool

func (*VMContext) Minted added in v0.2.0

func (vmctx *VMContext) Minted() colored.Balances

func (*VMContext) MustSaveEvent added in v0.2.0

func (vmctx *VMContext) MustSaveEvent(contract iscp.Hname, msg string)

func (*VMContext) MyAgentID

func (vmctx *VMContext) MyAgentID() *iscp.AgentID

func (*VMContext) OutputID added in v0.2.0

func (vmctx *VMContext) OutputID() ledgerstate.OutputID

func (*VMContext) Panicf

func (vmctx *VMContext) Panicf(format string, params ...interface{})

func (*VMContext) Params

func (vmctx *VMContext) Params() dict.Dict

func (*VMContext) Request added in v0.2.0

func (vmctx *VMContext) Request() iscp.Request

func (*VMContext) RunTheRequest

func (vmctx *VMContext) RunTheRequest(req iscp.Request, requestIndex uint16)

RunTheRequest processes any request based on the Extended output, even if it doesn't parse correctly as a SC request

func (*VMContext) Send added in v0.2.0

func (vmctx *VMContext) Send(target ledgerstate.Address, tokens colored.Balances, metadata *iscp.SendMetadata, options ...iscp.SendOptions) bool

func (*VMContext) State

func (vmctx *VMContext) State() kv.KVStore

func (*VMContext) StateAddress added in v0.2.0

func (vmctx *VMContext) StateAddress() ledgerstate.Address

- anchor properties

func (*VMContext) StateHash added in v0.2.0

func (vmctx *VMContext) StateHash() hashing.HashValue

func (*VMContext) StateIndex added in v0.2.0

func (vmctx *VMContext) StateIndex() uint32

func (*VMContext) Timestamp

func (vmctx *VMContext) Timestamp() int64

Jump to

Keyboard shortcuts

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