Documentation ¶
Index ¶
- Constants
- Variables
- func StepType() *ContainerTypeDef
- type Address
- type Bytes32View
- type CodeView
- type Config
- type ExecMode
- type HistView
- type InputView
- type MemoryView
- type Operation
- type OptiTracer
- func (o *OptiTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error)
- func (o *OptiTracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, ...)
- func (o *OptiTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, ...)
- func (o *OptiTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, ...)
- type Processor
- type RetDataView
- type Rules
- type StackView
- type Step
- type StepView
- func (v *StepView) CopyView() (*StepView, error)
- func (v *StepView) GetBaseFee() ([32]byte, error)
- func (v *StepView) GetBlockHashes() (*HistView, error)
- func (v *StepView) GetBlockNumber() (uint64, error)
- func (v *StepView) GetCallDepth() (uint64, error)
- func (v *StepView) GetCaller() (Address, error)
- func (v *StepView) GetCode() (*CodeView, error)
- func (v *StepView) GetCodeAddr() (Address, error)
- func (v *StepView) GetCodeHash() ([32]byte, error)
- func (v *StepView) GetCoinbase() (Address, error)
- func (v *StepView) GetCreate() (bool, error)
- func (v *StepView) GetDifficulty() ([32]byte, error)
- func (v *StepView) GetExecMode() (ExecMode, error)
- func (v *StepView) GetGas() (uint64, error)
- func (v *StepView) GetGasLimit() (uint64, error)
- func (v *StepView) GetGasPrice() (uint64, error)
- func (v *StepView) GetInput() (*InputView, error)
- func (v *StepView) GetMemDesired() (uint64, error)
- func (v *StepView) GetMemLastGas() (uint64, error)
- func (v *StepView) GetMemory() (*MemoryView, error)
- func (v *StepView) GetOp() (vm.OpCode, error)
- func (v *StepView) GetOrigin() (Address, error)
- func (v *StepView) GetPc() (uint64, error)
- func (v *StepView) GetReadOnly() (bool, error)
- func (v *StepView) GetRetData() (*RetDataView, error)
- func (v *StepView) GetReturnToStep() (uint64, error)
- func (v *StepView) GetStack() (*StackView, error)
- func (v *StepView) GetStateRoot() ([32]byte, error)
- func (v *StepView) GetSubData() (*SubDataView, error)
- func (v *StepView) GetSubIndex() (uint64, error)
- func (v *StepView) GetSubRemaining() (bool, error)
- func (v *StepView) GetTime() (uint64, error)
- func (v *StepView) GetTo() (Address, error)
- func (v *StepView) GetTxIndex() (uint64, error)
- func (v *StepView) GetValue() ([32]byte, error)
- func (step *StepView) IncrementPC() error
- func (step *StepView) ReturnGas(delta uint64) error
- func (v *StepView) SetBaseFee(p [32]byte) error
- func (v *StepView) SetBlockHashes(p *HistView) error
- func (v *StepView) SetBlockNumber(p uint64) error
- func (v *StepView) SetCallDepth(p uint64) error
- func (v *StepView) SetCaller(p Address) error
- func (v *StepView) SetCode(p *CodeView) error
- func (v *StepView) SetCodeAddr(p Address) error
- func (v *StepView) SetCodeHash(p [32]byte) error
- func (v *StepView) SetCoinbase(p Address) error
- func (v *StepView) SetCreate(p bool) error
- func (v *StepView) SetDifficulty(p [32]byte) error
- func (v *StepView) SetExecMode(p ExecMode) error
- func (v *StepView) SetGas(p uint64) error
- func (v *StepView) SetGasLimit(p uint64) error
- func (v *StepView) SetGasPrice(p uint64) error
- func (v *StepView) SetInput(p *InputView) error
- func (v *StepView) SetMemDesired(p uint64) error
- func (v *StepView) SetMemLastGas(p uint64) error
- func (v *StepView) SetMemory(p *MemoryView) error
- func (v *StepView) SetOp(p vm.OpCode) error
- func (v *StepView) SetOrigin(p Address) error
- func (v *StepView) SetPc(p uint64) error
- func (v *StepView) SetReadOnly(p bool) error
- func (v *StepView) SetRetData(p *RetDataView) error
- func (v *StepView) SetReturnToStep(p uint64) error
- func (v *StepView) SetStack(p *StackView) error
- func (v *StepView) SetStateRoot(p [32]byte) error
- func (v *StepView) SetSubData(p *SubDataView) error
- func (v *StepView) SetSubIndex(p uint64) error
- func (v *StepView) SetSubRemaining(p bool) error
- func (v *StepView) SetTime(p uint64) error
- func (v *StepView) SetTo(p Address) error
- func (v *StepView) SetTxIndex(p uint64) error
- func (v *StepView) SetValue(p [32]byte) error
- func (step *StepView) UseGas(delta uint64) (ok bool, err error)
- type Steps
- type StepsTrace
- type SubDataView
- type VerifierStateDB
- type WritableStepsTrace
Constants ¶
const ( GasQuickStep uint64 = 2 GasFastestStep uint64 = 3 GasFastStep uint64 = 5 GasMidStep uint64 = 8 GasSlowStep uint64 = 10 GasExtStep uint64 = 20 )
Gas costs
const ( ExecBlockPre = iota // TODO: check transaction is included, check fee params, signature validity, etc. ExecTxInclusion ExecTxSig ExecTxFeesPre // Call pre-processing (increment call depth) ExecCallPre // Interpreter loop consists of stack/memory/gas checks, and then opcode execution. ExecOpcodeLoad ExecValidateStack ExecReadOnlyCheck ExecConstantGas ExecCalcMemorySize ExecDynamicGas ExecUpdateMemorySize // when done running, continue with ExecOpcodeLoad. Or any error ExecOpcodeRun // Any error should follow up with running call-post processing ExecCallPost // Stops execution ExecSTOP // TODO: charge tx fees ExecTxFeesPost // TODO: maybe enumerate errors separately, generalize them? ExecErrStackUnderflow ExecErrStackOverflow ExecErrWriteProtection ExecErrOutOfGas ExecErrGasUintOverflow )
const AddressType = SmallByteVecMeta(20)
const Bytes32Type = RootType
Variables ¶
var CodeType = BasicListType(ByteType, 0x6000)
See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md ~24.5 KB
var HistType = VectorType(RootType, 256)
256 most recent block hashes, "recent history", are available for direct access in the EVM
var InputType = ListType(ByteType, 100_000_000)
Assuming a tx input can be max 400M gas, and 4 gas is paid per zero byte, then put a 100M limit on input.
var MemoryType = ListType(ByteType, 64<<20)
TODO: 64 MB memory maximum enough or too much? Every 2x makes the tree a layer deeper, but otherwise not much cost for unused space
var RetDataType = ListType(Bytes32Type, 64<<20)
Needs to be as big as memory, all of it can be returned
var StackType = ListType(Bytes32Type, 1024)
EVM stack is max 1024 words
var SubDataType = VectorType(Bytes32Type, 1024)
1024 words to track sub-step progress. Not to be confused with the memory scratchpad slots. TODO: any operations that need more scratch space?
Functions ¶
Types ¶
type Bytes32View ¶
type Bytes32View = RootView
type ExecMode ¶
type ExecMode byte
The interpreter is a pure function: given the last step, and optional access to a previous step, it can compute the next step. The execution mode distinguishes the various tasks around just regular opcode execution.
type MemoryView ¶
type MemoryView struct {
*ComplexListView
}
func AsMemoryView ¶
func AsMemoryView(v View, err error) (*MemoryView, error)
func (*MemoryView) AppendZeroByte ¶
func (v *MemoryView) AppendZeroByte() error
func (*MemoryView) AppendZeroBytes32 ¶
func (v *MemoryView) AppendZeroBytes32() error
type Operation ¶
type Operation struct { Proc Processor // contains filtered or unexported fields }
func DefaultJumpTable ¶
func DefaultJumpTable() [256]*Operation
type OptiTracer ¶
type OptiTracer struct {
Steps []*Step
}
func (*OptiTracer) CaptureEnd ¶
func (*OptiTracer) CaptureFault ¶
func (*OptiTracer) CaptureStart ¶
func (*OptiTracer) CaptureState ¶
type Processor ¶
type Processor func(trac StepsTrace) (*StepView, error)
Takes a trace, and produces the next step
type RetDataView ¶
type RetDataView struct {
*ComplexListView
}
func AsRetDataView ¶
func AsRetDataView(v View, err error) (*RetDataView, error)
func EmptyReturnData ¶
func EmptyReturnData() *RetDataView
type Step ¶
type Step struct { Data *StepView // nil if unused AccountProof [][]byte // nil if unused, requires account-proof StorageProof [][]byte }
func (*Step) MultiProof ¶
type StepView ¶
type StepView struct {
*ContainerView
}
func OpPop ¶
func OpPop(trac StepsTrace) (*StepView, error)
func OpStop ¶
func OpStop(trac StepsTrace) (*StepView, error)
func (*StepView) GetBaseFee ¶
func (*StepView) GetBlockHashes ¶
func (*StepView) GetBlockNumber ¶
func (*StepView) GetCallDepth ¶
func (*StepView) GetCodeAddr ¶
func (*StepView) GetCodeHash ¶
func (*StepView) GetCoinbase ¶
func (*StepView) GetDifficulty ¶
func (*StepView) GetExecMode ¶
func (*StepView) GetGasLimit ¶
func (*StepView) GetGasPrice ¶
func (*StepView) GetMemDesired ¶
func (*StepView) GetMemLastGas ¶
func (*StepView) GetMemory ¶
func (v *StepView) GetMemory() (*MemoryView, error)
func (*StepView) GetReadOnly ¶
func (*StepView) GetRetData ¶
func (v *StepView) GetRetData() (*RetDataView, error)
func (*StepView) GetReturnToStep ¶
func (*StepView) GetStateRoot ¶
func (*StepView) GetSubData ¶
func (v *StepView) GetSubData() (*SubDataView, error)
func (*StepView) GetSubIndex ¶
func (*StepView) GetSubRemaining ¶
func (*StepView) GetTxIndex ¶
func (*StepView) IncrementPC ¶
func (*StepView) SetBaseFee ¶
func (*StepView) SetBlockHashes ¶
func (*StepView) SetBlockNumber ¶
func (*StepView) SetCallDepth ¶
func (*StepView) SetCodeAddr ¶
func (*StepView) SetCodeHash ¶
func (*StepView) SetCoinbase ¶
func (*StepView) SetDifficulty ¶
func (*StepView) SetExecMode ¶
func (*StepView) SetGasLimit ¶
func (*StepView) SetGasPrice ¶
func (*StepView) SetMemDesired ¶
func (*StepView) SetMemLastGas ¶
func (*StepView) SetMemory ¶
func (v *StepView) SetMemory(p *MemoryView) error
func (*StepView) SetReadOnly ¶
func (*StepView) SetRetData ¶
func (v *StepView) SetRetData(p *RetDataView) error
func (*StepView) SetReturnToStep ¶
func (*StepView) SetStateRoot ¶
func (*StepView) SetSubData ¶
func (v *StepView) SetSubData(p *SubDataView) error
func (*StepView) SetSubIndex ¶
func (*StepView) SetSubRemaining ¶
func (*StepView) SetTxIndex ¶
type StepsTrace ¶
type StepsTrace interface { // nil if empty steps Last() *StepView // nil if invalid index ByIndex(i uint64) *StepView Length() uint64 }
func GenerateProof ¶
type SubDataView ¶
type SubDataView struct {
*ComplexVectorView
}
func AsSubDataView ¶
func AsSubDataView(v View, err error) (*SubDataView, error)
type VerifierStateDB ¶
type WritableStepsTrace ¶
type WritableStepsTrace interface { StepsTrace Append(step *StepView) error }