runner

package
v0.0.0-...-fae330d Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEntryCodeInstructions

func GetEntryCodeInstructions(function starknet.EntryPointByFunction, finalizeForProof bool) ([]*fp.Element, map[uint64][]hinter.Hinter, error)

func GetFooterInstructions

func GetFooterInstructions() []*fp.Element

Types

type AirMemorySegmentEntry

type AirMemorySegmentEntry struct {
	BeginAddr uint64 `json:"begin_addr"`
	StopPtr   uint64 `json:"stop_ptr"`
}

type AirPrivateInput

type AirPrivateInput struct {
	TracePath  string                                 `json:"trace_path"`
	MemoryPath string                                 `json:"memory_path"`
	Pedersen   []builtins.AirPrivateBuiltinPedersen   `json:"pedersen"`
	RangeCheck []builtins.AirPrivateBuiltinRangeCheck `json:"range_check"`
	Ecdsa      []builtins.AirPrivateBuiltinECDSA      `json:"ecdsa"`
	Bitwise    []builtins.AirPrivateBuiltinBitwise    `json:"bitwise"`
	EcOp       []builtins.AirPrivateBuiltinEcOp       `json:"ec_op"`
	Keccak     []builtins.AirPrivateBuiltinKeccak     `json:"keccak"`
	Poseidon   []builtins.AirPrivateBuiltinPoseidon   `json:"poseidon"`
}

type AirPublicInput

type AirPublicInput struct {
	Layout         string                           `json:"layout"`
	RcMin          uint16                           `json:"rc_min"`
	RcMax          uint16                           `json:"rc_max"`
	NSteps         int                              `json:"n_steps"`
	DynamicParams  interface{}                      `json:"dynamic_params"`
	MemorySegments map[string]AirMemorySegmentEntry `json:"memory_segments"`
	PublicMemory   []AirPublicMemoryEntry           `json:"public_memory"`
}

type AirPublicMemoryEntry

type AirPublicMemoryEntry struct {
	Address uint16 `json:"address"`
	Value   string `json:"value"`
	Page    uint16 `json:"page"`
}

type CairoProgram

type CairoProgram struct{}

type CairoRunner

type CairoRunner struct{}

type InlineCasmContext

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

func (*InlineCasmContext) AddInlineCASM

func (ctx *InlineCasmContext) AddInlineCASM(code string)

type Program

type Program struct {
	// the bytecode in string format
	Bytecode []*fp.Element
	// given a string it returns the pc for that function call
	Entrypoints map[string]uint64
	// it stores the start and end label pcs
	Labels map[string]uint64
	// builtins
	Builtins []builtins.BuiltinType
}

func AssembleProgram

func AssembleProgram(cairoProgram *starknet.StarknetProgram) (Program, map[uint64][]hinter.Hinter, error)

func LoadCairoProgram

func LoadCairoProgram(cairoProgram *sn.StarknetProgram) (*Program, error)

func LoadCairoZeroProgram

func LoadCairoZeroProgram(cairoZeroJson *zero.ZeroProgram) (*Program, error)

type Runner

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

func NewRunner

func NewRunner(program *Program, hints map[uint64][]hinter.Hinter, runnerMode RunnerMode, collectTrace bool, maxsteps uint64, layoutName string, userArgs []starknet.CairoFuncArgs) (Runner, error)

Creates a new Runner of a Cairo Zero program

func (*Runner) BuildMemory

func (runner *Runner) BuildMemory() ([]byte, error)

BuildMemory relocates the memory and returns it

func (*Runner) BuildTrace

func (runner *Runner) BuildTrace() ([]byte, error)

BuildTrace relocates the trace and returns it

func (*Runner) EndRun

func (runner *Runner) EndRun() error

EndRun is responsible for running the additional steps after the program was executed, until the checkUsedCells doesn't return any error. Since this vm always finishes the run of the program at the number of steps that is a power of two in the proof mode, there is no need to run additional steps before the loop.

func (*Runner) FinalizeSegments

func (runner *Runner) FinalizeSegments() error

FinalizeSegments calculates the final size of the builtins segments, using number of allocated instances and memory cells per builtin instance. Additionally it sets the final size of the program segment to the program size.

func (*Runner) GetAirPrivateInput

func (runner *Runner) GetAirPrivateInput(tracePath, memoryPath string) (AirPrivateInput, error)

func (*Runner) GetAirPublicInput

func (runner *Runner) GetAirPublicInput() (AirPublicInput, error)

func (*Runner) Output

func (runner *Runner) Output() []*fp.Element

Gives the output of the last run. Panics if there hasn't been any runs yet.

func (*Runner) Run

func (runner *Runner) Run() error

func (*Runner) RunEntryPoint

func (runner *Runner) RunEntryPoint(pc uint64) error

RunEntryPoint is like Run, but it executes the program starting from the given PC offset. This PC offset is expected to be a start from some function inside the loaded program.

func (*Runner) RunFor

func (runner *Runner) RunFor(steps uint64) error

run until the vm step count reaches the `steps` parameter

func (*Runner) RunUntilPc

func (runner *Runner) RunUntilPc(pc *mem.MemoryAddress) error

run until the program counter equals the `pc` parameter

type RunnerMode

type RunnerMode uint8
const (
	ExecutionModeZero RunnerMode = iota + 1
	ProofModeZero
	ExecutionModeCairo
	ProofModeCairo
)

type TokenGasCost

type TokenGasCost uint8
const (
	ConstToken TokenGasCost = iota + 1
	PedersenToken
	PoseidonToken
	BitwiseToken
	EcOpToken
	AddModToken
	MulModToken
)

Jump to

Keyboard shortcuts

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