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 InstrMapping
- type InstrumentedState
- type LineCol
- 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 SourceMap
- type SourceMapTracer
- func (s *SourceMapTracer) CaptureEnd(output []byte, gasUsed uint64, err error)
- func (s *SourceMapTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, ...)
- func (s *SourceMapTracer) CaptureExit(output []byte, gasUsed uint64, err error)
- func (s *SourceMapTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, ...)
- func (s *SourceMapTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, ...)
- func (s *SourceMapTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, ...)
- func (s *SourceMapTracer) CaptureTxEnd(restGas uint64)
- func (s *SourceMapTracer) CaptureTxStart(gasLimit uint64)
- 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 minimum page-size in Unicorn for mmap as well as the Go runtime min phys page size.
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 ¶
type HexU32 ¶
type HexU32 uint32
HexU32 to lazy-format integer attributes for logging
func (HexU32) MarshalText ¶
type InstrMapping ¶
type InstrMapping struct { S int32 // start offset in bytes within source (negative when non-existent!) L int32 // length in bytes within source (negative when non-existent!) F int32 // file index of source (negative when non-existent!) J byte // jump type (i=into, o=out, -=regular) M int32 // modifier depth }
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 SourceMap ¶
type SourceMap struct { // source names Sources []string // per source, source offset -> line/col PosData [][]LineCol // per bytecode byte, byte index -> instr Instr []InstrMapping }
func ParseSourceMap ¶
ParseSourceMap parses a solidity sourcemap: mapping bytecode indices to source references. See https://docs.soliditylang.org/en/latest/internals/source_mappings.html
func (*SourceMap) FormattedInfo ¶
type SourceMapTracer ¶
type SourceMapTracer struct {
// contains filtered or unexported fields
}
func NewSourceMapTracer ¶
func (*SourceMapTracer) CaptureEnd ¶
func (s *SourceMapTracer) CaptureEnd(output []byte, gasUsed uint64, err error)
func (*SourceMapTracer) CaptureEnter ¶
func (*SourceMapTracer) CaptureExit ¶
func (s *SourceMapTracer) CaptureExit(output []byte, gasUsed uint64, err error)
func (*SourceMapTracer) CaptureFault ¶
func (s *SourceMapTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error)
func (*SourceMapTracer) CaptureStart ¶
func (*SourceMapTracer) CaptureState ¶
func (s *SourceMapTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error)
func (*SourceMapTracer) CaptureTxEnd ¶
func (s *SourceMapTracer) CaptureTxEnd(restGas uint64)
func (*SourceMapTracer) CaptureTxStart ¶
func (s *SourceMapTracer) CaptureTxStart(gasLimit uint64)
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.