vmcontext

package
v0.6.1-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

README

Structure of the ledger in Stardust VM

Please find the link to the actual document here.

The document will be moved upon completion of the Stardust refactoring

Documentation

Index

Constants

View Source
const (
	// OffLedgerNonceStrictOrderTolerance how many steps back the nonce is considered too old
	// within this limit order of nonces is not checked
	OffLedgerNonceStrictOrderTolerance = 10_000
	// ExpiryUnlockSafetyWindowDuration creates safety window around time assumption,
	// the UTXO won't be consumed to avoid race conditions
	ExpiryUnlockSafetyWindowDuration  = 1 * time.Minute
	ExpiryUnlockSafetyWindowMilestone = 3
)
View Source
const MaxPostedOutputsInOneRequest = 4

Variables

This section is empty.

Functions

func CheckNonce added in v0.3.0

func CheckNonce(req isc.OffLedgerRequest, maxAssumedNonce uint64) error

func NewSandbox

func NewSandbox(vmctx *VMContext) isc.Sandbox

Types

type StateUpdate

type StateUpdate struct {
	Mutations *buffered.Mutations
}

func NewStateUpdate

func NewStateUpdate() *StateUpdate

NewStateUpdate creates a state update with timestamp mutation, if provided

func (*StateUpdate) Bytes

func (su *StateUpdate) Bytes() []byte

func (*StateUpdate) Clone

func (su *StateUpdate) Clone() *StateUpdate

func (*StateUpdate) Read

func (su *StateUpdate) Read(r io.Reader) error

func (*StateUpdate) Write

func (su *StateUpdate) Write(w io.Writer) error

type VMContext

type VMContext struct {
	NumPostedOutputs int // how many outputs has been posted in the request
	// 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 batch. 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() isc.AgentID

func (*VMContext) AgentID added in v0.3.0

func (vmctx *VMContext) AgentID() isc.AgentID

func (*VMContext) AllowanceAvailable added in v0.3.0

func (vmctx *VMContext) AllowanceAvailable() *isc.Assets

func (*VMContext) AssertConsistentGasTotals added in v0.3.0

func (vmctx *VMContext) AssertConsistentGasTotals()

func (*VMContext) BlockContext added in v0.2.0

func (vmctx *VMContext) BlockContext() interface{}

func (*VMContext) BuildTransactionEssence added in v0.2.0

func (vmctx *VMContext) BuildTransactionEssence(stateCommitment *state.L1Commitment, assertTxbuilderBalanced bool) (*iotago.TransactionEssence, []byte)

func (*VMContext) Call

func (vmctx *VMContext) Call(targetContract, epCode isc.Hname, params dict.Dict, allowance *isc.Assets) dict.Dict

Call implements sandbox logic of the call between contracts on-chain

func (*VMContext) Caller

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

func (*VMContext) ChainID

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

func (*VMContext) ChainInfo

func (vmctx *VMContext) ChainInfo() *isc.ChainInfo

func (*VMContext) ChainOwnerID

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

func (*VMContext) CloseVMContext added in v0.2.0

func (vmctx *VMContext) CloseVMContext(numRequests, numSuccess, numOffLedger uint16) (uint32, *state.L1Commitment, time.Time, iotago.Address)

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

func (*VMContext) CreateNewFoundry added in v0.3.0

func (vmctx *VMContext) CreateNewFoundry(scheme iotago.TokenScheme, metadata []byte) (uint32, uint64)

func (*VMContext) CurrentContractHname

func (vmctx *VMContext) CurrentContractHname() isc.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)

DeployContract deploys contract by its program hash with the name and description specific to the instance

func (*VMContext) DestroyFoundry added in v0.3.0

func (vmctx *VMContext) DestroyFoundry(sn uint32) uint64

func (*VMContext) Entropy

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

func (*VMContext) EstimateRequiredStorageDeposit added in v0.3.0

func (vmctx *VMContext) EstimateRequiredStorageDeposit(par isc.RequestParameters) uint64

func (*VMContext) GasBudgetLeft added in v0.3.0

func (vmctx *VMContext) GasBudgetLeft() uint64

func (*VMContext) GasBurn added in v0.3.0

func (vmctx *VMContext) GasBurn(burnCode gas.BurnCode, par ...uint64)

func (*VMContext) GasBurnEnable added in v0.3.0

func (vmctx *VMContext) GasBurnEnable(enable bool)

func (*VMContext) GasBurned added in v0.3.0

func (vmctx *VMContext) GasBurned() uint64

func (*VMContext) GetAccountNFTs added in v0.3.0

func (vmctx *VMContext) GetAccountNFTs(agentID isc.AgentID) (ret []iotago.NFTID)

func (*VMContext) GetBaseTokensBalance added in v0.3.0

func (vmctx *VMContext) GetBaseTokensBalance(agentID isc.AgentID) uint64

func (*VMContext) GetContractRecord added in v0.3.0

func (vmctx *VMContext) GetContractRecord(contractHname isc.Hname) (ret *root.ContractRecord)

func (*VMContext) GetNFTData added in v0.3.0

func (vmctx *VMContext) GetNFTData(nftID iotago.NFTID) (ret *isc.NFT)

func (*VMContext) GetNativeTokenBalance added in v0.3.0

func (vmctx *VMContext) GetNativeTokenBalance(agentID isc.AgentID, nativeTokenID iotago.NativeTokenID) *big.Int

func (*VMContext) GetNativeTokenBalanceTotal added in v0.3.0

func (vmctx *VMContext) GetNativeTokenBalanceTotal(nativeTokenID iotago.NativeTokenID) *big.Int

func (*VMContext) GetNativeTokens

func (vmctx *VMContext) GetNativeTokens(agentID isc.AgentID) iotago.NativeTokens

func (*VMContext) GetSenderTokenBalanceForFees added in v0.3.0

func (vmctx *VMContext) GetSenderTokenBalanceForFees() uint64

func (*VMContext) HasEnoughForAllowance added in v0.3.0

func (vmctx *VMContext) HasEnoughForAllowance(agentID isc.AgentID, allowance *isc.Assets) bool

func (*VMContext) Infof

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

func (*VMContext) IsCoreAccount added in v0.3.0

func (vmctx *VMContext) IsCoreAccount(agentID isc.AgentID) bool

func (*VMContext) LocateProgram added in v0.3.0

func (vmctx *VMContext) LocateProgram(programHash hashing.HashValue) (vmtype string, binary []byte, err error)

func (*VMContext) ModifyFoundrySupply added in v0.3.0

func (vmctx *VMContext) ModifyFoundrySupply(sn uint32, delta *big.Int) int64

func (*VMContext) MustSaveEvent added in v0.2.0

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

func (*VMContext) MyAgentID

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

func (*VMContext) OpenBlockContexts added in v0.3.0

func (vmctx *VMContext) OpenBlockContexts()

OpenBlockContexts calls the block context open function for all subscribed core contracts

func (*VMContext) Panicf

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

func (*VMContext) Params

func (vmctx *VMContext) Params() *isc.Params

func (*VMContext) Processors added in v0.3.0

func (vmctx *VMContext) Processors() *processors.Cache

func (*VMContext) RegisterError added in v0.3.0

func (vmctx *VMContext) RegisterError(messageFormat string) *isc.VMErrorTemplate

func (*VMContext) Request added in v0.2.0

func (vmctx *VMContext) Request() isc.Calldata

func (*VMContext) RunTheRequest

func (vmctx *VMContext) RunTheRequest(req isc.Request, requestIndex uint16) (*vm.RequestResult, error)

RunTheRequest processes each isc.Request in the batch

func (*VMContext) Send added in v0.2.0

func (vmctx *VMContext) Send(par isc.RequestParameters)

Send implements sandbox function of sending cross-chain request

func (*VMContext) SetBlockContext added in v0.3.0

func (vmctx *VMContext) SetBlockContext(bctx interface{})

func (*VMContext) State

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

func (*VMContext) StateAnchor added in v0.3.0

func (vmctx *VMContext) StateAnchor() *isc.StateAnchor

func (*VMContext) StateMetadata

func (vmctx *VMContext) StateMetadata(stateCommitment *state.L1Commitment) []byte

func (*VMContext) StateReader added in v0.3.0

func (vmctx *VMContext) StateReader() kv.KVStoreReader

func (*VMContext) Timestamp

func (vmctx *VMContext) Timestamp() time.Time

func (*VMContext) TransferAllowedFunds added in v0.3.0

func (vmctx *VMContext) TransferAllowedFunds(target isc.AgentID, transfer ...*isc.Assets) *isc.Assets

TransferAllowedFunds transfers funds within the budget set by the Allowance() to the existing target account on chain

func (*VMContext) TryLoadContract added in v0.3.0

func (vmctx *VMContext) TryLoadContract(programHash hashing.HashValue) error

func (*VMContext) Warnf added in v0.3.0

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

Directories

Path Synopsis
Package vmtxbuilder implements AnchorTransactionBuilder, a transaction builder used by the VM to construct anchor transaction.
Package vmtxbuilder implements AnchorTransactionBuilder, a transaction builder used by the VM to construct anchor transaction.

Jump to

Keyboard shortcuts

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