Documentation ¶
Index ¶
- Constants
- func HashPair(left, right [32]byte) [32]byte
- func PatchVM(f *elf.File, vmState *VMState) error
- type CachedPage
- type InstrumentedState
- type LocalContext
- type Memory
- func (m *Memory) AllocPage(pageIndex uint64) *CachedPage
- func (m *Memory) ForEachPage(fn func(pageIndex uint64, page *Page) error) error
- func (m *Memory) GetUnaligned(addr uint64, dest []byte)
- func (m *Memory) Invalidate(addr uint64)
- func (m *Memory) MarshalJSON() ([]byte, error)
- func (m *Memory) MerkleProof(addr uint64) (out [ProofLen * 32]byte)
- func (m *Memory) MerkleRoot() [32]byte
- func (m *Memory) MerkleizeSubtree(gindex uint64) [32]byte
- func (m *Memory) PageCount() int
- func (m *Memory) ReadMemoryRange(addr uint64, count uint64) io.Reader
- func (m *Memory) SetMemoryRange(addr uint64, r io.Reader) error
- func (m *Memory) SetUnaligned(addr uint64, dat []byte)
- func (m *Memory) UnmarshalJSON(data []byte) error
- func (m *Memory) Usage() string
- type Page
- type PreimageOracle
- type SortedSymbols
- type StateWitness
- type StepWitness
- type U256
- type U64
- type UnrecognizedResourceErr
- type UnrecognizedSyscallErr
- type UnsupportedSyscallErr
- type VMState
Constants ¶
View Source
const ( PageAddrSize = 12 PageKeySize = 64 - PageAddrSize PageSize = 1 << PageAddrSize PageAddrMask = PageSize - 1 MaxPageCount = 1 << PageKeySize PageKeyMask = MaxPageCount - 1 ProofLen = 64 - 4 )
Note: 2**12 = 4 KiB, the minimum page-size in Unicorn for mmap as well as the Go runtime min phys page size.
View Source
const ( VMStatusValid = 0 VMStatusInvalid = 1 VMStatusPanic = 2 VMStatusUnfinished = 3 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CachedPage ¶
type CachedPage struct { Data *Page // intermediate nodes only Cache [PageSize / 32][32]byte // true if the intermediate node is valid Ok [PageSize / 32]bool }
func (*CachedPage) Invalidate ¶
func (p *CachedPage) Invalidate(pageAddr uint64)
func (*CachedPage) InvalidateFull ¶
func (p *CachedPage) InvalidateFull()
func (*CachedPage) MerkleRoot ¶
func (p *CachedPage) MerkleRoot() [32]byte
func (*CachedPage) MerkleizeSubtree ¶
func (p *CachedPage) MerkleizeSubtree(gindex uint64) [32]byte
type InstrumentedState ¶
type InstrumentedState struct {
// contains filtered or unexported fields
}
func NewInstrumentedState ¶
func NewInstrumentedState(state *VMState, po PreimageOracle, stdOut, stdErr io.Writer) *InstrumentedState
func (*InstrumentedState) LastPreimage ¶
func (m *InstrumentedState) LastPreimage() ([32]byte, []byte, uint64)
func (*InstrumentedState) Step ¶
func (m *InstrumentedState) Step(proof bool) (wit *StepWitness, err error)
type LocalContext ¶
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func (*Memory) AllocPage ¶
func (m *Memory) AllocPage(pageIndex uint64) *CachedPage
func (*Memory) ForEachPage ¶
func (*Memory) GetUnaligned ¶
func (*Memory) Invalidate ¶
func (*Memory) MarshalJSON ¶
func (*Memory) MerkleRoot ¶
func (*Memory) MerkleizeSubtree ¶
func (*Memory) ReadMemoryRange ¶
func (*Memory) SetUnaligned ¶
TODO: we never do unaligned writes, this should be simplified
func (*Memory) UnmarshalJSON ¶
type PreimageOracle ¶
type SortedSymbols ¶
func (SortedSymbols) FindSymbol ¶
func (s SortedSymbols) FindSymbol(addr uint64) elf.Symbol
FindSymbol finds the symbol that intersects with the given addr, or nil if none exists
type StateWitness ¶
type StateWitness []byte
type StepWitness ¶
type StepWitness struct { // encoded state witness State []byte MemProof []byte PreimageKey [32]byte // zeroed when no pre-image is accessed PreimageValue []byte // including the 8-byte length prefix PreimageOffset uint64 }
func (*StepWitness) EncodePreimageOracleInput ¶
func (wit *StepWitness) EncodePreimageOracleInput(localContext LocalContext) ([]byte, error)
func (*StepWitness) EncodeStepInput ¶
func (wit *StepWitness) EncodeStepInput(localContext LocalContext) ([]byte, error)
func (*StepWitness) HasPreimage ¶
func (wit *StepWitness) HasPreimage() bool
type UnrecognizedResourceErr ¶
type UnrecognizedResourceErr struct {
Resource U64
}
func (*UnrecognizedResourceErr) Error ¶
func (e *UnrecognizedResourceErr) Error() string
type UnrecognizedSyscallErr ¶
type UnrecognizedSyscallErr struct {
SyscallNum U64
}
func (*UnrecognizedSyscallErr) Error ¶
func (e *UnrecognizedSyscallErr) Error() string
type UnsupportedSyscallErr ¶
type UnsupportedSyscallErr struct {
SyscallNum U64
}
func (*UnsupportedSyscallErr) Error ¶
func (e *UnsupportedSyscallErr) Error() string
type VMState ¶
type VMState struct { Memory *Memory `json:"memory"` PreimageKey common.Hash `json:"preimageKey"` PreimageOffset uint64 `json:"preimageOffset"` PC uint64 `json:"pc"` ExitCode uint8 `json:"exit"` Exited bool `json:"exited"` Step uint64 `json:"step"` Heap uint64 `json:"heap"` // for mmap to keep allocating new anon memory LoadReservation uint64 `json:"loadReservation"` Registers [32]uint64 `json:"registers"` // LastHint is optional metadata, and not part of the VM state itself. // It is used to remember the last pre-image hint, // so a VM can start from any state without fetching prior pre-images, // and instead just repeat the last hint on setup, // to make sure pre-image requests can be served. // The first 4 bytes are a uin32 length prefix. // Warning: the hint MAY NOT BE COMPLETE. I.e. this is buffered, // and should only be read when len(LastHint) > 4 && uint32(LastHint[:4]) <= len(LastHint[4:]) LastHint hexutil.Bytes `json:"lastHint,omitempty"` // VMState must hold these values because if not, we must ask FPVM again to // compute these values. Witness []byte `json:"witness,omitempty"` StateHash common.Hash `json:"stateHash,omitempty"` }
func NewVMState ¶
func NewVMState() *VMState
func (*VMState) EncodeWitness ¶
func (state *VMState) EncodeWitness() StateWitness
func (*VMState) SetWitnessAndStateHash ¶
Click to show internal directories.
Click to hide internal directories.