Documentation ¶
Index ¶
- Constants
- Variables
- func HashPair(left, right [32]byte) [32]byte
- func NewEVMEnv(contracts *Contracts, addrs *Addresses) (*vm.EVM, *state.StateDB)
- func PatchGo(f *elf.File, st *State) error
- func PatchStack(st *State) error
- func SE(dat uint32, idx uint32) uint32
- type Addresses
- type CachedPage
- type Contract
- type Contracts
- type HexU32
- type InstrumentedState
- type LoggingWriter
- type Memory
- func (m *Memory) AllocPage(pageIndex uint32) *CachedPage
- func (m *Memory) ForEachPage(fn func(pageIndex uint32, page *Page) error) error
- func (m *Memory) GetMemory(addr uint32) uint32
- func (m *Memory) Invalidate(addr uint32)
- func (m *Memory) MarshalJSON() ([]byte, error)
- func (m *Memory) MerkleProof(addr uint32) (out [28 * 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 uint32, count uint32) io.Reader
- func (m *Memory) SetMemory(addr uint32, v uint32)
- func (m *Memory) SetMemoryRange(addr uint32, r io.Reader) error
- func (m *Memory) UnmarshalJSON(data []byte) error
- func (m *Memory) Usage() string
- type Metadata
- type Page
- type PreimageOracle
- type State
- type StepWitness
- type Symbol
Constants ¶
View Source
const ( MipsEBADF = 0x9 MipsEINVAL = 0x16 )
View Source
const ( PageAddrSize = 12 PageKeySize = 32 - PageAddrSize PageSize = 1 << PageAddrSize PageAddrMask = PageSize - 1 MaxPageCount = 1 << PageKeySize PageKeyMask = MaxPageCount - 1 )
Note: 2**12 = 4 KiB, the min phys page size in the Go runtime.
Variables ¶
Functions ¶
func PatchStack ¶
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 uint32)
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 Contract ¶
type Contract struct { DeployedBytecode struct { Object hexutil.Bytes `json:"object"` SourceMap string `json:"sourceMap"` } `json:"deployedBytecode"` }
func LoadContract ¶
type Contracts ¶
func LoadContracts ¶
LoadContracts loads the Cannon contracts, from op-bindings package
func LoadContractsFromFiles ¶
LoadContractsFromFiles loads the Cannon contracts, from local filesystem
type HexU32 ¶
type HexU32 uint32
HexU32 to lazy-format integer attributes for logging
func (HexU32) MarshalText ¶
type InstrumentedState ¶
type InstrumentedState struct {
// contains filtered or unexported fields
}
func NewInstrumentedState ¶
func NewInstrumentedState(state *State, po PreimageOracle, stdOut, stdErr io.Writer) *InstrumentedState
func (*InstrumentedState) Step ¶
func (m *InstrumentedState) Step(proof bool) (wit *StepWitness, err error)
type LoggingWriter ¶
LoggingWriter is a simple util to wrap a logger, and expose an io Writer interface, for the program running within the VM to write to.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func (*Memory) AllocPage ¶
func (m *Memory) AllocPage(pageIndex uint32) *CachedPage
func (*Memory) ForEachPage ¶
func (*Memory) Invalidate ¶
func (*Memory) MarshalJSON ¶
func (*Memory) MerkleProof ¶
func (*Memory) MerkleRoot ¶
func (*Memory) MerkleizeSubtree ¶
func (*Memory) ReadMemoryRange ¶
func (*Memory) UnmarshalJSON ¶
type Metadata ¶
type Metadata struct {
Symbols []Symbol `json:"symbols"`
}
func (*Metadata) LookupSymbol ¶
type PreimageOracle ¶
type State ¶
type State struct { Memory *Memory `json:"memory"` PreimageKey common.Hash `json:"preimageKey"` PreimageOffset uint32 `json:"preimageOffset"` // note that the offset includes the 8-byte length prefix PC uint32 `json:"pc"` NextPC uint32 `json:"nextPC"` LO uint32 `json:"lo"` HI uint32 `json:"hi"` Heap uint32 `json:"heap"` // to handle mmap growth ExitCode uint8 `json:"exit"` Exited bool `json:"exited"` Step uint64 `json:"step"` Registers [32]uint32 `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"` }
func (*State) EncodeWitness ¶
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 uint32 }
func (*StepWitness) EncodePreimageOracleInput ¶
func (wit *StepWitness) EncodePreimageOracleInput() ([]byte, error)
func (*StepWitness) EncodeStepInput ¶
func (wit *StepWitness) EncodeStepInput() []byte
func (*StepWitness) HasPreimage ¶
func (wit *StepWitness) HasPreimage() bool
Click to show internal directories.
Click to hide internal directories.