vm

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultMaxSteps = 4_000_000
	DefaultMaxGas   = 100_000_000
)

Variables

This section is empty.

Functions

func CompileSierraToCasm added in v0.16.7

func CompileSierraToCasm(sierra *starknet.SierraClass) (*starknet.CasmClass, error)

CompileSierraToCasm compiles a Sierra class to CASM in-process via the Rust FFI.

func JunoAddExecutionSteps added in v0.12.1

func JunoAddExecutionSteps(readerHandle C.uintptr_t, execSteps C.ulonglong)

func JunoAppendActualFee added in v0.6.0

func JunoAppendActualFee(readerHandle C.uintptr_t, ptr unsafe.Pointer)

func JunoAppendDAGas added in v0.13.0

func JunoAppendDAGas(readerHandle C.uintptr_t, ptr, ptr2 unsafe.Pointer)

func JunoAppendGasConsumed

func JunoAppendGasConsumed(readerHandle C.uintptr_t, ptr, ptr2, ptr3 unsafe.Pointer)

func JunoAppendInitialReads added in v0.15.20

func JunoAppendInitialReads(readerHandle C.uintptr_t, jsonBytes *C.void, bytesLen C.size_t)

func JunoAppendReceipt added in v0.14.3

func JunoAppendReceipt(readerHandle C.uintptr_t, jsonBytes *C.void, bytesLen C.size_t)

func JunoAppendResponse

func JunoAppendResponse(readerHandle C.uintptr_t, ptr unsafe.Pointer)

func JunoAppendStateDiff added in v0.14.3

func JunoAppendStateDiff(readerHandle C.uintptr_t, jsonBytes *C.void, bytesLen C.size_t)

func JunoAppendTrace added in v0.6.0

func JunoAppendTrace(readerHandle C.uintptr_t, jsonBytes *C.void, bytesLen C.size_t)

func JunoFree

func JunoFree(ptr unsafe.Pointer)

func JunoReportError

func JunoReportError(readerHandle C.uintptr_t, txnIndex C.long, str *C.char, executionFailed C.uchar)

func JunoStateGetClassHashAt

func JunoStateGetClassHashAt(readerHandle C.uintptr_t, contractAddress, buffer unsafe.Pointer) C.int

func JunoStateGetCompiledClass

func JunoStateGetCompiledClass(
	readerHandle C.uintptr_t,
	classHash unsafe.Pointer,
	declaredAt *C.uint64_t,
) unsafe.Pointer

func JunoStateGetCompiledClassHash added in v0.15.11

func JunoStateGetCompiledClassHash(
	readerHandle C.uintptr_t,
	classHash,
	buffer unsafe.Pointer,
) C.int

func JunoStateGetCompiledClassHashV2 added in v0.15.11

func JunoStateGetCompiledClassHashV2(
	readerHandle C.uintptr_t,
	classHash,
	buffer unsafe.Pointer,
) C.int

func JunoStateGetNonceAt

func JunoStateGetNonceAt(readerHandle C.uintptr_t, contractAddress, buffer unsafe.Pointer) C.int

func JunoStateGetStorageAt

func JunoStateGetStorageAt(readerHandle C.uintptr_t, contractAddress, storageLocation, buffer unsafe.Pointer) C.int

func SetVersionedConstants added in v0.12.0

func SetVersionedConstants(filename string) error

Types

type BlockInfo added in v0.11.0

type BlockInfo struct {
	Header                *core.Header
	BlockHashToBeRevealed *felt.Felt
}

type BuildBlockOptions added in v0.16.1

type BuildBlockOptions struct {
	SkipChargeFee bool
	SkipValidate  bool
	ErrOnRevert   bool
}

BuildBlockOptions carries flags used when producing a block (builder or genesis bootstrap).

type CallInfo added in v0.11.0

type CallInfo struct {
	ContractAddress *felt.Address
	ClassHash       *felt.ClassHash
	Selector        *felt.Felt
	Calldata        []felt.Felt
}

type CallResult added in v0.13.0

type CallResult struct {
	Result          []*felt.Felt
	StateDiff       StateDiff
	ExecutionFailed bool
}

type ChainInfo added in v0.15.7

type ChainInfo struct {
	ChainID           string
	FeeTokenAddresses starknet.FeeTokenAddresses
}

type ComputationResources added in v0.11.0

type ComputationResources struct {
	Steps        uint64 `json:"steps"`
	MemoryHoles  uint64 `json:"memory_holes,omitempty"`
	Pedersen     uint64 `json:"pedersen_builtin_applications,omitempty"`
	RangeCheck   uint64 `json:"range_check_builtin_applications,omitempty"`
	Bitwise      uint64 `json:"bitwise_builtin_applications,omitempty"`
	Ecdsa        uint64 `json:"ecdsa_builtin_applications,omitempty"`
	EcOp         uint64 `json:"ec_op_builtin_applications,omitempty"`
	Keccak       uint64 `json:"keccak_builtin_applications,omitempty"`
	Poseidon     uint64 `json:"poseidon_builtin_applications,omitempty"`
	SegmentArena uint64 `json:"segment_arena_builtin,omitempty"`
	AddMod       uint64 `json:"add_mod_builtin,omitempty"`
	MulMod       uint64 `json:"mul_mod_builtin,omitempty"`
	RangeCheck96 uint64 `json:"range_check_96_builtin,omitempty"`
	Output       uint64 `json:"output_builtin,omitempty"`
}

type DataAvailability added in v0.11.0

type DataAvailability struct {
	L1Gas     uint64 `json:"l1_gas"`
	L1DataGas uint64 `json:"l1_data_gas"`
}

func NewDataAvailability added in v0.11.1

func NewDataAvailability(gasConsumed, dataGasConsumed *felt.Felt, mode core.L1DAMode) DataAvailability

type DataAvailabilityMode added in v0.8.0

type DataAvailabilityMode uint32
const (
	DAModeL1 DataAvailabilityMode = iota
	DAModeL2
)

func (DataAvailabilityMode) MarshalText added in v0.11.0

func (m DataAvailabilityMode) MarshalText() ([]byte, error)

type DeclaredClass added in v0.9.3

type DeclaredClass struct {
	ClassHash         felt.SierraClassHash `json:"class_hash"`
	CompiledClassHash felt.CasmClassHash   `json:"compiled_class_hash"`
}

type DeployedContract added in v0.9.3

type DeployedContract struct {
	Address   felt.Address   `json:"address"`
	ClassHash felt.ClassHash `json:"class_hash"`
}

type Entry added in v0.9.3

type Entry struct {
	Key   felt.Felt `json:"key"`
	Value felt.Felt `json:"value"`
}

type EstimateFeeOptions added in v0.16.1

type EstimateFeeOptions struct {
	SkipValidate       bool
	ReturnInitialReads bool
}

EstimateFeeOptions carries the flags relevant to RPC estimateFee.

type ExecuteInvocation added in v0.9.3

type ExecuteInvocation struct {
	RevertReason        string `json:"revert_reason"`
	*FunctionInvocation `json:",omitempty"`
}

func (ExecuteInvocation) MarshalJSON added in v0.9.3

func (e ExecuteInvocation) MarshalJSON() ([]byte, error)

type ExecutionResources added in v0.9.3

type ExecutionResources struct {
	L1Gas     uint64 `json:"l1_gas"`
	L1DataGas uint64 `json:"l1_data_gas"`
	L2Gas     uint64 `json:"l2_gas"`

	ComputationResources
	DataAvailability *DataAvailability `json:"data_availability,omitempty"`
}

type ExecutionResults added in v0.13.0

type ExecutionResults struct {
	OverallFees      []*felt.Felt
	DataAvailability []core.DataAvailability
	GasConsumed      []core.GasConsumed
	Traces           []TransactionTrace
	NumSteps         uint64
	Receipts         []TransactionReceipt
	InitialReads     *InitialReads
}

type FunctionInvocation added in v0.9.3

type FunctionInvocation struct {
	ContractAddress    felt.Address           `json:"contract_address"`
	EntryPointSelector *felt.Felt             `json:"entry_point_selector,omitempty"`
	Calldata           []felt.Felt            `json:"calldata"`
	CallerAddress      felt.Address           `json:"caller_address"`
	ClassHash          *felt.ClassHash        `json:"class_hash,omitempty"`
	EntryPointType     string                 `json:"entry_point_type,omitempty"`
	CallType           string                 `json:"call_type,omitempty"`
	Result             []felt.Felt            `json:"result"`
	Calls              []FunctionInvocation   `json:"calls"`
	Events             []OrderedEvent         `json:"events"`
	Messages           []OrderedL2toL1Message `json:"messages"`
	ExecutionResources *ExecutionResources    `json:"execution_resources,omitempty"`
	IsReverted         bool                   `json:"is_reverted,omitempty"`
}

type GasConsumed added in v0.14.3

type GasConsumed struct {
	L1Gas     uint64 `json:"l1_gas"`
	L1DataGas uint64 `json:"l1_data_gas"`
}

type InitialReads added in v0.15.20

type InitialReads struct {
	Storage           []InitialReadsStorageEntry          `json:"storage"`
	Nonces            []InitialReadsNonceEntry            `json:"nonces"`
	ClassHashes       []InitialReadsClassHashEntry        `json:"class_hashes"`
	DeclaredContracts []InitialReadsDeclaredContractEntry `json:"declared_contracts"`
}

type InitialReadsClassHashEntry added in v0.15.20

type InitialReadsClassHashEntry struct {
	ContractAddress felt.Address   `json:"contract_address"`
	ClassHash       felt.ClassHash `json:"class_hash"`
}

type InitialReadsDeclaredContractEntry added in v0.15.20

type InitialReadsDeclaredContractEntry struct {
	ClassHash  felt.ClassHash `json:"class_hash"`
	IsDeclared bool           `json:"is_declared"`
}

type InitialReadsNonceEntry added in v0.15.20

type InitialReadsNonceEntry struct {
	ContractAddress felt.Address `json:"contract_address"`
	Nonce           felt.Felt    `json:"nonce"`
}

type InitialReadsStorageEntry added in v0.15.20

type InitialReadsStorageEntry struct {
	ContractAddress felt.Address `json:"contract_address"`
	Key             felt.Felt    `json:"key"`
	Value           felt.Felt    `json:"value"`
}

type MigratedCompiledClass added in v0.15.10

type MigratedCompiledClass struct {
	ClassHash         felt.SierraClassHash `json:"class_hash"`
	CompiledClassHash felt.CasmClassHash   `json:"compiled_class_hash"`
}

type Nonce added in v0.9.3

type Nonce struct {
	ContractAddress felt.Address `json:"contract_address"`
	Nonce           felt.Felt    `json:"nonce"`
}

type OrderedEvent added in v0.9.3

type OrderedEvent struct {
	Order uint64        `json:"order"`
	From  *felt.Address `json:"from_address,omitempty"`
	Keys  []felt.Felt   `json:"keys"`
	Data  []felt.Felt   `json:"data"`
}

type OrderedL2toL1Message added in v0.9.3

type OrderedL2toL1Message struct {
	Order   uint64        `json:"order"`
	From    *felt.Address `json:"from_address,omitempty"`
	To      *felt.Address `json:"to_address"`
	Payload []felt.Felt   `json:"payload"`
}

type ReplacedClass added in v0.9.3

type ReplacedClass struct {
	ContractAddress felt.Address   `json:"contract_address"`
	ClassHash       felt.ClassHash `json:"class_hash"`
}

type Resource added in v0.8.0

type Resource uint32
const (
	ResourceL1Gas Resource = iota + 1
	ResourceL2Gas
	ResourceL1DataGas
)

func (Resource) MarshalText added in v0.8.0

func (r Resource) MarshalText() ([]byte, error)

type ResourceBounds added in v0.8.0

type ResourceBounds struct {
	MaxAmount       *felt.Felt `json:"max_amount"`
	MaxPricePerUnit *felt.Felt `json:"max_price_per_unit"`
}

type SimulateOptions added in v0.16.1

type SimulateOptions struct {
	SkipChargeFee      bool
	SkipValidate       bool
	ErrOnRevert        bool
	ReturnInitialReads bool
}

SimulateOptions carries the flags relevant to RPC simulate.

type StateDiff added in v0.9.3

type StateDiff struct {
	StorageDiffs              []StorageDiff           `json:"storage_diffs"`
	Nonces                    []Nonce                 `json:"nonces"`
	DeployedContracts         []DeployedContract      `json:"deployed_contracts"`
	DeprecatedDeclaredClasses []*felt.ClassHash       `json:"deprecated_declared_classes"`
	DeclaredClasses           []DeclaredClass         `json:"declared_classes"`
	ReplacedClasses           []ReplacedClass         `json:"replaced_classes"`
	MigratedCompiledClasses   []MigratedCompiledClass `json:"migrated_compiled_classes"`
}

type StorageDiff added in v0.9.3

type StorageDiff struct {
	Address        felt.Address `json:"address"`
	StorageEntries []Entry      `json:"storage_entries"`
}

type TraceOptions added in v0.16.1

type TraceOptions struct {
	ReturnInitialReads bool
}

TraceOptions carries the flags relevant to replaying an existing block.

type Transaction added in v0.8.0

type Transaction struct {
	Version               *felt.Felt                   `json:"version,omitempty"`
	ContractAddress       *felt.Address                `json:"contract_address,omitempty"`
	ContractAddressSalt   *felt.Felt                   `json:"contract_address_salt,omitempty"`
	ClassHash             *felt.ClassHash              `json:"class_hash,omitempty"`
	ConstructorCallData   *felt.Slice[felt.Felt]       `json:"constructor_calldata,omitempty"`
	SenderAddress         *felt.Address                `json:"sender_address,omitempty"`
	MaxFee                *felt.Felt                   `json:"max_fee,omitempty"`
	Signature             *felt.Slice[felt.Felt]       `json:"signature,omitempty"`
	CallData              *felt.Slice[felt.Felt]       `json:"calldata,omitempty"`
	EntryPointSelector    *felt.Felt                   `json:"entry_point_selector,omitempty"`
	Nonce                 *felt.Felt                   `json:"nonce,omitempty"`
	CompiledClassHash     *felt.CasmClassHash          `json:"compiled_class_hash,omitempty"`
	ResourceBounds        *map[Resource]ResourceBounds `json:"resource_bounds,omitempty"`
	Tip                   *felt.Felt                   `json:"tip,omitempty"`
	NonceDAMode           *DataAvailabilityMode        `json:"nonce_data_availability_mode,omitempty"`
	FeeDAMode             *DataAvailabilityMode        `json:"fee_data_availability_mode,omitempty"`
	AccountDeploymentData *felt.Slice[felt.Felt]       `json:"account_deployment_data,omitempty"`
	PaymasterData         *felt.Slice[felt.Felt]       `json:"paymaster_data,omitempty"`
	ProofFacts            *[]felt.Felt                 `json:"proof_facts,omitempty"`
}

type TransactionExecutionError added in v0.8.0

type TransactionExecutionError struct {
	Index uint64
	Cause json.RawMessage
}

func (TransactionExecutionError) Error added in v0.8.0

type TransactionReceipt added in v0.14.3

type TransactionReceipt struct {
	Fee   *felt.Felt
	Gas   GasConsumed
	DAGas DataAvailability
}

type TransactionTrace added in v0.9.3

type TransactionTrace struct {
	Type                  TransactionType     `json:"type,omitempty"`
	ValidateInvocation    *FunctionInvocation `json:"validate_invocation,omitempty"`
	ExecuteInvocation     *ExecuteInvocation  `json:"execute_invocation,omitempty"`
	FeeTransferInvocation *FunctionInvocation `json:"fee_transfer_invocation,omitempty"`
	ConstructorInvocation *FunctionInvocation `json:"constructor_invocation,omitempty"`
	FunctionInvocation    *ExecuteInvocation  `json:"function_invocation,omitempty"`
	StateDiff             *StateDiff          `json:"state_diff,omitempty"`
	ExecutionResources    *ExecutionResources `json:"execution_resources,omitempty"`
}

func (*TransactionTrace) AllEvents added in v0.9.3

func (t *TransactionTrace) AllEvents() []OrderedEvent

func (*TransactionTrace) AllMessages added in v0.9.3

func (t *TransactionTrace) AllMessages() []OrderedL2toL1Message

func (*TransactionTrace) RevertReason added in v0.9.3

func (t *TransactionTrace) RevertReason() string

func (*TransactionTrace) TotalExecutionResources added in v0.9.3

func (t *TransactionTrace) TotalExecutionResources() *ExecutionResources

Todo: this was deleted during RP refactoring. However, the builder pkg needs it. Think about if we can handle this more elegantly.

type TransactionType added in v0.9.3

type TransactionType uint8
const (
	Invalid TransactionType = iota
	TxnDeclare
	TxnDeploy
	TxnDeployAccount
	TxnInvoke
	TxnL1Handler
)

func (TransactionType) MarshalText added in v0.11.0

func (t TransactionType) MarshalText() ([]byte, error)

func (TransactionType) String added in v0.9.3

func (t TransactionType) String() string

func (*TransactionType) UnmarshalJSON added in v0.9.3

func (t *TransactionType) UnmarshalJSON(data []byte) error

type VM added in v0.5.0

type VM interface {
	Call(
		callInfo *CallInfo,
		blockInfo *BlockInfo,
		state core.StateReader,
		maxSteps uint64,
		maxGas uint64,
		structuredErrStack,
		returnStateDiff bool,
	) (CallResult, error)
	Simulate(
		txns []core.Transaction,
		declaredClasses []core.ClassDefinition,
		blockInfo *BlockInfo,
		state core.StateReader,
		opts SimulateOptions,
	) (ExecutionResults, error)
	EstimateFee(
		txns []core.Transaction,
		declaredClasses []core.ClassDefinition,
		blockInfo *BlockInfo,
		state core.StateReader,
		opts EstimateFeeOptions,
	) (ExecutionResults, error)
	Trace(
		txns []core.Transaction,
		declaredClasses []core.ClassDefinition,
		paidFeesOnL1 []*felt.Felt,
		blockInfo *BlockInfo,
		state core.StateReader,
		opts TraceOptions,
	) (ExecutionResults, error)
	BuildBlock(
		txns []core.Transaction,
		declaredClasses []core.ClassDefinition,
		paidFeesOnL1 []*felt.Felt,
		blockInfo *BlockInfo,
		state core.StateReader,
		opts BuildBlockOptions,
	) (ExecutionResults, error)
}

func New added in v0.5.0

func New(chainInfo *ChainInfo, concurrencyMode bool, logger log.StructuredLogger) VM

Jump to

Keyboard shortcuts

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