Documentation
¶
Index ¶
- Constants
- Variables
- func BindValueTrace(val any, trace *cell.Trace) any
- func IsHandledException(err error) bool
- func IsSuccessExitCode(code int64) bool
- type AgainContinuation
- type ArgExtContinuation
- type CellManager
- func (m *CellManager) BeginParse(cl *cell.Cell) (*cell.Slice, error)
- func (m *CellManager) BeginParseAlreadyLoaded(cl *cell.Cell) (*cell.Slice, error)
- func (m *CellManager) BeginParseAlreadyLoadedNoCreate(cl *cell.Cell) (*cell.Slice, error)
- func (m *CellManager) BeginParseAlreadyLoadedRaw(cl *cell.Cell) (*cell.Slice, error)
- func (m *CellManager) BeginParseSpecial(cl *cell.Cell) (*cell.Slice, bool, error)
- func (m *CellManager) ChildTrace(int) *cell.Trace
- func (m *CellManager) Init(state *State)
- func (m *CellManager) IsCellLoaded(cl *cell.Cell) bool
- func (m *CellManager) IsCellLoadedKey(key cell.Hash) bool
- func (m *CellManager) LoadRef(sl *cell.Slice) (*cell.Slice, error)
- func (m *CellManager) LoadRefCell(sl *cell.Slice) (*cell.Cell, error)
- func (m *CellManager) LoadTrace() *cell.Trace
- func (m *CellManager) OnCreate()
- func (m *CellManager) OnLoad(c *cell.Cell)
- func (m *CellManager) PendingError() error
- func (m *CellManager) RegisterCellCreate() error
- func (m *CellManager) RegisterCellLoad(cl *cell.Cell) error
- func (m *CellManager) RegisterCellLoadKey(key cell.Hash) error
- func (m *CellManager) Trace() *cell.Trace
- func (m *CellManager) TraceAlreadyLoaded() *cell.Trace
- type ChildRunner
- type ChildVMConfig
- type CommittedState
- type Continuation
- type ControlData
- type ExcQuitContinuation
- type Gas
- func (g *Gas) ChangeBase(base int64)
- func (g *Gas) ChangeLimit(limit int64)
- func (g *Gas) Check() error
- func (g *Gas) Consume(amount int64) error
- func (g *Gas) ConsumeFree(amount int64)
- func (g *Gas) FlushFree() error
- func (g *Gas) SetLimits(max, limit int64, credit ...int64)
- func (g *Gas) Used() int64
- type GasConfig
- type GasPricedOp
- type HandledException
- type NaN
- type Null
- type OP
- type OPGetter
- type OrdinaryContinuation
- type PushIntContinuation
- type QuitContinuation
- type Register
- type RepeatContinuation
- type SendMsgAction
- type Stack
- func (s *Stack) Checkpoint() StackCheckpoint
- func (s *Stack) Clear()
- func (s *Stack) Copy() *Stack
- func (s *Stack) Drop(num int) error
- func (s *Stack) DropAfter(num int) error
- func (s *Stack) DropMany(num, offs int) error
- func (s *Stack) Exchange(a, b int) error
- func (s *Stack) FromTop(offset int) (int, error)
- func (s *Stack) Get(at int) (any, error)
- func (s *Stack) Len() int
- func (s *Stack) MoveFrom(from *Stack, num int) error
- func (s *Stack) PopAny() (any, error)
- func (s *Stack) PopBool() (bool, error)
- func (s *Stack) PopBuilder() (*cell.Builder, error)
- func (s *Stack) PopCell() (*cell.Cell, error)
- func (s *Stack) PopContinuation() (Continuation, error)
- func (s *Stack) PopInt() (*big.Int, error)
- func (s *Stack) PopIntFinite() (*big.Int, error)
- func (s *Stack) PopIntFiniteRead() (*big.Int, error)
- func (s *Stack) PopIntRange(min, max int64) (*big.Int, error)
- func (s *Stack) PopIntRangeInt64(min, max int64) (int64, error)
- func (s *Stack) PopIntRead() (*big.Int, error)
- func (s *Stack) PopMaybeCell() (*cell.Cell, error)
- func (s *Stack) PopMaybeTupleRange(max int) (*tuple.Tuple, error)
- func (s *Stack) PopSlice() (*cell.Slice, error)
- func (s *Stack) PopSwapAt(at int) error
- func (s *Stack) PopTuple() (tuple.Tuple, error)
- func (s *Stack) PopTupleRange(max int, min ...int) (tuple.Tuple, error)
- func (s *Stack) PushAny(val any) error
- func (s *Stack) PushAt(at int) error
- func (s *Stack) PushBool(val bool) error
- func (s *Stack) PushBuilder(val *cell.Builder) error
- func (s *Stack) PushCell(val *cell.Cell) error
- func (s *Stack) PushContinuation(val Continuation) error
- func (s *Stack) PushHostValue(val any) error
- func (s *Stack) PushInt(val *big.Int) error
- func (s *Stack) PushIntQuiet(val *big.Int) error
- func (s *Stack) PushMaybeTuple(t *tuple.Tuple) error
- func (s *Stack) PushOwnedBuilder(val *cell.Builder) error
- func (s *Stack) PushOwnedInt(val *big.Int) error
- func (s *Stack) PushOwnedIntQuiet(val *big.Int) error
- func (s *Stack) PushOwnedSlice(val *cell.Slice) error
- func (s *Stack) PushOwnedValue(val any) error
- func (s *Stack) PushSlice(val *cell.Slice) error
- func (s *Stack) PushSmallInt(val int64) error
- func (s *Stack) PushTuple(t tuple.Tuple) error
- func (s *Stack) Restore(src *Stack)
- func (s *Stack) RestoreCheckpoint(cp StackCheckpoint)
- func (s *Stack) Reverse(from, to int) error
- func (s *Stack) Rotate(from, to int) error
- func (s *Stack) SetTrace(trace *cell.Trace)
- func (s *Stack) Snapshot() *Stack
- func (s *Stack) SplitTop(top, drop int) (*Stack, error)
- func (s *Stack) String() string
- func (s *Stack) WithoutTrace(trace *cell.Trace) *Stack
- type StackCheckpoint
- type State
- func (s *State) Call(c Continuation) error
- func (s *State) CallArgs(c Continuation, passArgs, retArgs int) error
- func (s *State) CheckGas() error
- func (s *State) ConsumeFreeGas(amount int64)
- func (s *State) ConsumeGas(amount int64) error
- func (s *State) ConsumeStackGas(stk *Stack) error
- func (s *State) ConsumeStackGasLen(depth int) error
- func (s *State) ConsumeTupleGasLen(length int) error
- func (s *State) ExtractCurrentContinuation(saveCR, stackCopy, ccArgs int) (*OrdinaryContinuation, error)
- func (s *State) FlushFreeGas() error
- func (s *State) ForceCommitCurrent() error
- func (s *State) GetGlobal(idx int) (any, error)
- func (s *State) GetParam(idx int) (any, error)
- func (s *State) GetUnpackedConfigTuple() (tuple.Tuple, error)
- func (s *State) HandleOutOfGas() error
- func (s *State) InitForExecution()
- func (s *State) Jump(c Continuation) error
- func (s *State) JumpArgs(c Continuation, passArgs int) error
- func (s *State) JumpTo(c Continuation) (err error)
- func (s *State) LoadLibraryByHash(hash []byte) (*cell.Cell, error)
- func (s *State) PrepareExecution(code *cell.Slice)
- func (s *State) PushTupleCharged(t tuple.Tuple) error
- func (s *State) RegisterCellLoadFreeKey(key cell.Hash) bool
- func (s *State) RegisterGetExtraBalanceCall() bool
- func (s *State) RegisterSignatureCheckCall() error
- func (s *State) ResolveLibraryCell(cl *cell.Cell) (*cell.Cell, error)
- func (s *State) Return(args ...int) error
- func (s *State) ReturnAlt(args ...int) error
- func (s *State) RunChild(child *State) (int64, error)
- func (s *State) RunChildVM(cfg ChildVMConfig) error
- func (s *State) SetC7(t tuple.Tuple) error
- func (s *State) SetChildRunner(fn ChildRunner)
- func (s *State) SetGasLimit(limit int64) error
- func (s *State) SetGlobal(idx int, val any) error
- func (s *State) SetLibraries(libs ...*cell.Cell)
- func (s *State) SetMaxDataDepth(depth uint16)
- func (s *State) SetMaxLibraryLoads(limit uint32)
- func (s *State) ThrowException(code *big.Int, arg ...any) error
- func (s *State) Trace(msg string)
- func (s *State) TraceEnabled() bool
- func (s *State) TraceOpcode(opcode string)
- func (s *State) TraceStack(prefix string, stack *Stack)
- func (s *State) Tracef(format string, args ...any)
- func (s *State) TryCommitCurrent() bool
- func (s *State) UpdateC7(fn func(tuple.Tuple) (tuple.Tuple, error)) error
- type TraceHook
- type TraceStep
- type UntilContinuation
- type VersionedOp
- type WhileContinuation
Constants ¶
const ( GasInfinite int64 = 1<<63 - 1 MaxSupportedGlobalVersion = 15 CellLoadGasPrice = 100 CellReloadGasPrice = 25 CellCreateGasPrice = 500 ExceptionGasPrice = 50 InstructionBaseGasPrice = 10 TupleEntryGasPrice = 1 ImplicitJmprefGasPrice = 10 ImplicitRetGasPrice = 5 FreeStackDepth = 32 StackEntryGasPrice = 1 RunvmGasPrice = 40 HashExtEntryGasPrice = 1 GetExtraBalanceCheapCount = 5 GetExtraBalanceCheapMaxGas = 200 FreeNestedContJump = 8 Rist255MulGasPrice = 2000 Rist255MulbaseGasPrice = 750 Rist255AddGasPrice = 600 Rist255FromhashGasPrice = 600 Rist255ValidateGasPrice = 200 EcrecoverGasPrice = 1500 Secp256k1XonlyPubkeyTweakAddGasPrice = 1250 SignatureCheckFreeCount = 10 SignatureCheckGasPrice = 4000 P256SignatureCheckGasPrice = 3500 BlsVerifyGasPrice = 61000 BlsAggregateBaseGasPrice = -2650 BlsAggregateElementGasPrice = 4350 BlsFastAggregateVerifyBaseGasPrice = 58000 BlsFastAggregateVerifyElementGasPrice = 3000 BlsAggregateVerifyBaseGasPrice = 38500 BlsAggregateVerifyElementGasPrice = 22500 BlsG1AddSubGasPrice = 3900 BlsG1NegGasPrice = 750 BlsG1MulGasPrice = 5200 BlsMapToG1GasPrice = 2350 BlsG1InGroupGasPrice = 2950 BlsG2AddSubGasPrice = 6100 BlsG2NegGasPrice = 1550 BlsG2MulGasPrice = 10550 BlsMapToG2GasPrice = 7950 BlsG2InGroupGasPrice = 4250 BlsG1MultiexpBaseGasPrice = 11375 BlsG1MultiexpCoef1GasPrice = 630 BlsG1MultiexpCoef2GasPrice = 8820 BlsG2MultiexpBaseGasPrice = 30388 BlsG2MultiexpCoef1GasPrice = 1280 BlsG2MultiexpCoef2GasPrice = 22840 BlsPairingBaseGasPrice = 20000 BlsPairingElementGasPrice = 11800 )
Gas prices constants.
const CP = -1
const ControlDataAllArgs = -1
const MaxDataDepth = 512
Variables ¶
var ErrCorruptedOpcode = errors.New("corrupted opcode")
var ErrStopOnAccept = errors.New("stop on accept")
var List []OPGetter
Functions ¶
func BindValueTrace ¶ added in v1.18.0
BindValueTrace returns val ready to live on a stack or in c7 bound to the given cell trace: slices and builders are copied with the trace attached (snapshotting their cursor), tuples are rebound recursively and typed nil pointers collapse to plain nil, except a null slice reference whose slice tag is observable in legacy TVM behavior. Values that already carry the trace are returned as-is. A nil trace returns val unchanged.
func IsHandledException ¶ added in v1.18.0
IsHandledException is an allocation-free errors.As for HandledException.
func IsSuccessExitCode ¶
Types ¶
type AgainContinuation ¶
type AgainContinuation struct {
Body Continuation
}
func (*AgainContinuation) Copy ¶
func (c *AgainContinuation) Copy() Continuation
func (*AgainContinuation) GetControlData ¶
func (c *AgainContinuation) GetControlData() *ControlData
func (*AgainContinuation) Jump ¶
func (c *AgainContinuation) Jump(state *State) (Continuation, error)
type ArgExtContinuation ¶
type ArgExtContinuation struct {
Data ControlData
Ext Continuation
}
func (*ArgExtContinuation) Copy ¶
func (c *ArgExtContinuation) Copy() Continuation
func (*ArgExtContinuation) GetControlData ¶
func (c *ArgExtContinuation) GetControlData() *ControlData
func (*ArgExtContinuation) Jump ¶
func (c *ArgExtContinuation) Jump(state *State) (Continuation, error)
type CellManager ¶
type CellManager struct {
// contains filtered or unexported fields
}
func (*CellManager) BeginParse ¶
func (*CellManager) BeginParseAlreadyLoaded ¶
func (*CellManager) BeginParseAlreadyLoadedNoCreate ¶
func (*CellManager) BeginParseAlreadyLoadedRaw ¶
func (*CellManager) BeginParseSpecial ¶
func (*CellManager) ChildTrace ¶ added in v1.18.0
func (m *CellManager) ChildTrace(int) *cell.Trace
ChildTrace implements cell.TraceListener for the gas trace: children stay on the same gas trace.
func (*CellManager) Init ¶
func (m *CellManager) Init(state *State)
func (*CellManager) IsCellLoaded ¶
func (m *CellManager) IsCellLoaded(cl *cell.Cell) bool
func (*CellManager) IsCellLoadedKey ¶
func (m *CellManager) IsCellLoadedKey(key cell.Hash) bool
func (*CellManager) LoadRefCell ¶
func (*CellManager) LoadTrace ¶
func (m *CellManager) LoadTrace() *cell.Trace
func (*CellManager) OnCreate ¶ added in v1.18.0
func (m *CellManager) OnCreate()
OnCreate implements cell.TraceListener for the gas trace, charging cell create gas with the same sticky-error semantics as OnLoad.
func (*CellManager) OnLoad ¶ added in v1.18.0
func (m *CellManager) OnLoad(c *cell.Cell)
OnLoad implements cell.TraceListener for the gas trace: it charges cell load gas, latching the first gas error so later events keep the original failure.
func (*CellManager) PendingError ¶
func (m *CellManager) PendingError() error
func (*CellManager) RegisterCellCreate ¶
func (m *CellManager) RegisterCellCreate() error
func (*CellManager) RegisterCellLoad ¶
func (m *CellManager) RegisterCellLoad(cl *cell.Cell) error
func (*CellManager) RegisterCellLoadKey ¶
func (m *CellManager) RegisterCellLoadKey(key cell.Hash) error
func (*CellManager) Trace ¶
func (m *CellManager) Trace() *cell.Trace
func (*CellManager) TraceAlreadyLoaded ¶
func (m *CellManager) TraceAlreadyLoaded() *cell.Trace
type ChildRunner ¶
type ChildVMConfig ¶
type CommittedState ¶
type Continuation ¶
type Continuation interface {
GetControlData() *ControlData
Jump(state *State) (Continuation, error)
Copy() Continuation
}
func ForceControlData ¶
func ForceControlData(cont Continuation) Continuation
type ControlData ¶
func (ControlData) Copy ¶
func (c ControlData) Copy() ControlData
type ExcQuitContinuation ¶
type ExcQuitContinuation struct{}
func (*ExcQuitContinuation) Copy ¶
func (c *ExcQuitContinuation) Copy() Continuation
func (*ExcQuitContinuation) GetControlData ¶
func (c *ExcQuitContinuation) GetControlData() *ControlData
func (*ExcQuitContinuation) Jump ¶
func (c *ExcQuitContinuation) Jump(state *State) (Continuation, error)
type Gas ¶
type Gas struct {
Max int64
Limit int64
Credit int64
Remaining int64
Base int64
FreeConsumed int64
}
func GasWithLimit ¶
func (*Gas) ChangeBase ¶
func (*Gas) ChangeLimit ¶
func (*Gas) ConsumeFree ¶
type GasPricedOp ¶
type GasPricedOp interface {
InstructionBits() int64
}
type HandledException ¶
func (HandledException) Error ¶
func (e HandledException) Error() string
func (HandledException) Unwrap ¶
func (e HandledException) Unwrap() error
type OrdinaryContinuation ¶
type OrdinaryContinuation struct {
Data ControlData
Code *cell.Slice
}
func (*OrdinaryContinuation) Copy ¶
func (c *OrdinaryContinuation) Copy() Continuation
func (*OrdinaryContinuation) GetControlData ¶
func (c *OrdinaryContinuation) GetControlData() *ControlData
func (*OrdinaryContinuation) Jump ¶
func (c *OrdinaryContinuation) Jump(state *State) (Continuation, error)
type PushIntContinuation ¶
type PushIntContinuation struct {
Int int64
Next Continuation
}
func (*PushIntContinuation) Copy ¶
func (c *PushIntContinuation) Copy() Continuation
func (*PushIntContinuation) GetControlData ¶
func (c *PushIntContinuation) GetControlData() *ControlData
func (*PushIntContinuation) Jump ¶
func (c *PushIntContinuation) Jump(state *State) (Continuation, error)
type QuitContinuation ¶
type QuitContinuation struct {
ExitCode int64
}
func (*QuitContinuation) Copy ¶
func (c *QuitContinuation) Copy() Continuation
func (*QuitContinuation) GetControlData ¶
func (c *QuitContinuation) GetControlData() *ControlData
func (*QuitContinuation) Jump ¶
func (c *QuitContinuation) Jump(state *State) (Continuation, error)
type Register ¶
type Register struct {
C [4]Continuation
D [2]*cell.Cell
C7 tuple.Tuple
}
func (*Register) AdjustWith ¶
type RepeatContinuation ¶
type RepeatContinuation struct {
Count int64
Body Continuation
After Continuation
}
func (*RepeatContinuation) Copy ¶
func (c *RepeatContinuation) Copy() Continuation
func (*RepeatContinuation) GetControlData ¶
func (c *RepeatContinuation) GetControlData() *ControlData
func (*RepeatContinuation) Jump ¶
func (c *RepeatContinuation) Jump(state *State) (Continuation, error)
type SendMsgAction ¶
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
func (*Stack) Checkpoint ¶
func (s *Stack) Checkpoint() StackCheckpoint
func (*Stack) PopContinuation ¶
func (s *Stack) PopContinuation() (Continuation, error)
func (*Stack) PopIntFiniteRead ¶ added in v1.18.0
PopIntFiniteRead is the finite variant of PopIntRead: the caller must not mutate the result.
func (*Stack) PopIntRangeInt64 ¶ added in v1.18.0
func (*Stack) PopIntRead ¶ added in v1.18.0
PopIntRead pops an integer for read-only use: shared static instances are returned as-is instead of a defensive copy, so the caller must not mutate the result. nil result means NaN.
func (*Stack) PopMaybeTupleRange ¶
func (*Stack) PopTupleRange ¶
func (*Stack) PushContinuation ¶
func (s *Stack) PushContinuation(val Continuation) error
func (*Stack) PushHostValue ¶
PushHostValue accepts values already encoded with TVM stack types.
func (*Stack) PushOwnedBuilder ¶
PushOwnedBuilder pushes a builder the caller no longer shares elsewhere. Unlike PushBuilder, it binds stack trace in-place and skips a defensive copy.
func (*Stack) PushOwnedInt ¶ added in v1.18.0
PushOwnedInt pushes an integer the caller no longer shares elsewhere. Unlike PushInt, it keeps non-static values in-place and skips a defensive copy.
func (*Stack) PushOwnedIntQuiet ¶ added in v1.18.0
PushOwnedIntQuiet is the quiet variant of PushOwnedInt.
func (*Stack) PushOwnedSlice ¶
PushOwnedSlice pushes a slice the caller no longer shares elsewhere. Unlike PushSlice, it binds stack trace in-place and skips a defensive copy.
func (*Stack) PushOwnedValue ¶ added in v1.18.0
PushOwnedValue pushes a value that was already removed from this VM stack.
func (*Stack) PushSmallInt ¶ added in v1.18.0
func (*Stack) RestoreCheckpoint ¶
func (s *Stack) RestoreCheckpoint(cp StackCheckpoint)
type StackCheckpoint ¶
type StackCheckpoint struct {
// contains filtered or unexported fields
}
type State ¶
type State struct {
GlobalVersion int
CP int
CurrentCode *cell.Slice
Reg Register
Gas Gas
Cells CellManager
Libraries []*cell.Cell
Stack *Stack
Steps uint32
StopOnAccept bool
TraceHook TraceHook
SignatureCheckAlwaysSucceed bool
SignatureCheckCounter uint32
GetExtraBalanceCounter uint32
Committed CommittedState
// contains filtered or unexported fields
}
func NewExecutionState ¶
func (*State) Call ¶
func (s *State) Call(c Continuation) error
func (*State) ConsumeFreeGas ¶
func (*State) ConsumeGas ¶
func (*State) ConsumeStackGas ¶
func (*State) ConsumeStackGasLen ¶
func (*State) ConsumeTupleGasLen ¶
func (*State) ExtractCurrentContinuation ¶
func (s *State) ExtractCurrentContinuation(saveCR, stackCopy, ccArgs int) (*OrdinaryContinuation, error)
func (*State) FlushFreeGas ¶
func (*State) ForceCommitCurrent ¶
func (*State) GetUnpackedConfigTuple ¶
func (*State) HandleOutOfGas ¶
func (*State) InitForExecution ¶
func (s *State) InitForExecution()
func (*State) Jump ¶
func (s *State) Jump(c Continuation) error
func (*State) JumpTo ¶
func (s *State) JumpTo(c Continuation) (err error)
func (*State) LoadLibraryByHash ¶
func (*State) PrepareExecution ¶
func (*State) RegisterGetExtraBalanceCall ¶
func (*State) RegisterSignatureCheckCall ¶ added in v1.18.0
func (*State) ResolveLibraryCell ¶
func (*State) RunChildVM ¶
func (s *State) RunChildVM(cfg ChildVMConfig) error
func (*State) SetChildRunner ¶
func (s *State) SetChildRunner(fn ChildRunner)
func (*State) SetGasLimit ¶
func (*State) SetLibraries ¶
func (*State) SetMaxDataDepth ¶ added in v1.18.0
func (*State) SetMaxLibraryLoads ¶ added in v1.18.0
func (*State) TraceEnabled ¶ added in v1.18.0
func (*State) TraceOpcode ¶ added in v1.18.0
func (*State) TraceStack ¶ added in v1.18.0
func (*State) TryCommitCurrent ¶
type UntilContinuation ¶
type UntilContinuation struct {
Body Continuation
After Continuation
}
func (*UntilContinuation) Copy ¶
func (c *UntilContinuation) Copy() Continuation
func (*UntilContinuation) GetControlData ¶
func (c *UntilContinuation) GetControlData() *ControlData
func (*UntilContinuation) Jump ¶
func (c *UntilContinuation) Jump(state *State) (Continuation, error)
type VersionedOp ¶ added in v1.18.0
type VersionedOp interface {
MinGlobalVersion() int
}
type WhileContinuation ¶
type WhileContinuation struct {
CheckCond bool
Body Continuation
Cond Continuation
After Continuation
// contains filtered or unexported fields
}
func (*WhileContinuation) Copy ¶
func (c *WhileContinuation) Copy() Continuation
func (*WhileContinuation) GetControlData ¶
func (c *WhileContinuation) GetControlData() *ControlData
func (*WhileContinuation) Jump ¶
func (c *WhileContinuation) Jump(state *State) (Continuation, error)