gas

package
v0.6.2-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WasmCostsRegular       = 1
	WasmCostsDiv           = 16
	WasmCostsMul           = 4
	WasmCostsMem           = 2
	WasmCostsStaticU256    = 64
	WasmCostsStaticHash    = 64
	WasmCostsStaticAddress = 40
	/// Memory stipend. Amount of free memory (in 64kb pages) each contract can use for stack.
	WasmCostsInitialMem = 4096
	/// Grow memory cost, per page (64kb)
	WasmCostsGrowMem        = 8192
	WasmCostsMemcpy         = 1
	WasmCostsMaxStackHeight = 64 * 1024
	WasmCostsOpcodesMul     = 3
	WasmCostsOpcodesDiv     = 8
)
View Source
const ErrorDisableFloatingPoint = "Wasm contract error: disabled floating point"
View Source
const ErrorGasLimit = "Invocation resulted in gas limit violated"

Variables

This section is empty.

Functions

func InjectCounter

func InjectCounter(disassembly []disasm.Instr, module *wasm.Module, rule Gas) []disasm.Instr

Types

type BlockEntry

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

type BlockEntrys

type BlockEntrys []*BlockEntry

func (BlockEntrys) Len

func (block BlockEntrys) Len() int

func (BlockEntrys) Less

func (block BlockEntrys) Less(i, j int) bool

func (BlockEntrys) Swap

func (block BlockEntrys) Swap(i, j int)

type Counter

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

func NewCounter

func NewCounter() *Counter

func (*Counter) Begin

func (counter *Counter) Begin(cursor int)

func (*Counter) Finalize

func (counter *Counter) Finalize()

func (*Counter) Increment

func (counter *Counter) Increment(value uint64, index int)

type Gas

type Gas struct {
	Ops   map[byte]InstructionType
	Rules map[InstructionType]GasValue
}

func NewGas

func NewGas(disableFloatingPoint bool) Gas

func (Gas) GasCost

func (gas Gas) GasCost(op byte) uint64

type GasCounter

type GasCounter struct {
	Contract *contract.WASMContract
	GasTable params.GasTable
}

func NewGasCounter

func NewGasCounter(contract *contract.WASMContract, gasTable params.GasTable) GasCounter

func (GasCounter) AdjustedCharge

func (gas GasCounter) AdjustedCharge(amount uint64)

func (GasCounter) Charge

func (gas GasCounter) Charge(amount uint64)

func (GasCounter) ChargeGas

func (gas GasCounter) ChargeGas(amount uint64) bool

func (GasCounter) GasAssert

func (gas GasCounter) GasAssert()

func (GasCounter) GasCall

func (gas GasCounter) GasCall(address common.Address, value, gasLimit, blockNumber *big.Int, chainConfig *params.ChainConfig, statedb *state.StateDB) uint64

func (GasCounter) GasConcat

func (gas GasCounter) GasConcat(size uint64)

func (GasCounter) GasCostZero

func (gas GasCounter) GasCostZero()

func (GasCounter) GasEqual

func (gas GasCounter) GasEqual()

func (GasCounter) GasFastestStep

func (gas GasCounter) GasFastestStep()

func (GasCounter) GasFromI64

func (gas GasCounter) GasFromI64()

func (GasCounter) GasFromU64

func (gas GasCounter) GasFromU64()

func (GasCounter) GasGetBalanceFromAddress

func (gas GasCounter) GasGetBalanceFromAddress()

func (GasCounter) GasGetBlockHash

func (gas GasCounter) GasGetBlockHash()

func (GasCounter) GasGetBlockNumber

func (gas GasCounter) GasGetBlockNumber()

func (GasCounter) GasGetBlockProduser

func (gas GasCounter) GasGetBlockProduser()

func (GasCounter) GasGetContractAddress

func (gas GasCounter) GasGetContractAddress()

func (GasCounter) GasGetGas

func (gas GasCounter) GasGetGas()

func (GasCounter) GasGetGasLimit

func (gas GasCounter) GasGetGasLimit()

func (GasCounter) GasGetOrigin

func (gas GasCounter) GasGetOrigin()

func (GasCounter) GasGetSender

func (gas GasCounter) GasGetSender()

func (GasCounter) GasGetTimestamp

func (gas GasCounter) GasGetTimestamp()

func (GasCounter) GasGetValue

func (gas GasCounter) GasGetValue()

func (GasCounter) GasInitialMemory

func (gas GasCounter) GasInitialMemory(initial uint64)

func (GasCounter) GasLoad

func (gas GasCounter) GasLoad()

func (GasCounter) GasLog

func (gas GasCounter) GasLog(size uint64, topics uint64)

func (GasCounter) GasMemoryCost

func (gas GasCounter) GasMemoryCost(size uint64)

func (GasCounter) GasPow

func (gas GasCounter) GasPow(exponent *big.Int)

func (GasCounter) GasQuickStep

func (gas GasCounter) GasQuickStep()

func (GasCounter) GasReturnAddress

func (gas GasCounter) GasReturnAddress()

func (GasCounter) GasReturnHash

func (gas GasCounter) GasReturnHash()

func (GasCounter) GasReturnPointer

func (gas GasCounter) GasReturnPointer(size uint64)

func (GasCounter) GasReturnU256

func (gas GasCounter) GasReturnU256()

func (GasCounter) GasRevert

func (gas GasCounter) GasRevert()

func (GasCounter) GasSHA3

func (gas GasCounter) GasSHA3(size uint64)

todo 验证sha3 gas消耗,和evm保持一致

func (GasCounter) GasSendFromContract

func (gas GasCounter) GasSendFromContract()

func (GasCounter) GasStore

func (gas GasCounter) GasStore(stateDb *state.StateDB, contractAddr common.Address, loc common.Hash, value common.Hash)

func (GasCounter) GasToI64

func (gas GasCounter) GasToI64()

func (GasCounter) GasToU64

func (gas GasCounter) GasToU64()

type GasValue

type GasValue struct {
	Metering Metering
	Value    uint64
}

type InstructionType

type InstructionType int
const (
	InstructionTypeBit InstructionType = iota
	InstructionTypeAdd
	InstructionTypeMul
	InstructionTypeDiv
	InstructionTypeLoad
	InstructionTypeStore
	InstructionTypeConst
	InstructionTypeFloatConst
	InstructionTypeLocal
	InstructionTypeGlobal
	InstructionTypeControlFlow
	InstructionTypeIntegerComparsion
	InstructionTypeFloatComparsion
	InstructionTypeFloat
	InstructionTypeConversion
	InstructionTypeFloatConversion
	InstructionTypeReinterpretation
	InstructionTypeUnreachable
	InstructionTypeNop
	InstructionTypeCurrentMemory
	InstructionTypeGrowMemory
)

type Metering

type Metering int
const (
	MeteringRegular Metering = iota
	MeteringForbidden
	MeteringFixed
)

Jump to

Keyboard shortcuts

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