Documentation ¶
Index ¶
- Constants
- func Get(st *Stack, n int) *big.Int
- func GetWord256(st *Stack, n int) Word256
- func Min(x, y uint64) uint64
- func SafeAdd(x, y uint64) (uint64, bool)
- func SafeMul(x, y uint64) (uint64, bool)
- func SafeSub(x, y uint64) (uint64, bool)
- type CVM
- func (vm *CVM) Contract(code []byte) *CVMContract
- func (vm *CVM) Dispatch(acc *acm.Account) engine.Callable
- func (vm *CVM) Execute(st acmstate.ReaderWriter, blockchain engine.Blockchain, ...) ([]byte, error)
- func (vm *CVM) GetRefund() uint64
- func (vm *CVM) SetExternals(externals engine.Dispatcher)
- func (vm *CVM) SetLogger(logger *logging.Logger)
- func (vm *CVM) SetNonce(nonce []byte)
- type CVMContract
- type CVMOptions
Constants ¶
const ( // Basic gas units GasBase uint64 = 2 GasVeryLow uint64 = 3 GasLow uint64 = 5 GasMid uint64 = 8 GasHigh uint64 = 10 GasExtStep uint64 = 20 // homestead extcode cost // Constantinople GasExtcodeSize uint64 = 700 GasExtcodeCopy uint64 = 700 GasExtcodeHash uint64 = 700 GasBalance uint64 = 700 GasSLoad uint64 = 800 GasCalls uint64 = 700 GasSelfdestruct uint64 = 5000 GasExpByte uint64 = 50 GasCreateBySelfdestruct uint64 = 25000 CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. Sha3Gas uint64 = 30 // Once per SHA3 operation. Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data. SstoreSetGas uint64 = 20000 // Once per SLOAD operation. SstoreResetGas uint64 = 5000 // Once per SSTORE operation if the zeroness changes from zero. SstoreClearGas uint64 = 5000 // Once per SSTORE operation if the zeroness doesn't change. SstoreRefundGas uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero. NetSstoreNoopGas uint64 = 200 // Once per SSTORE operation if the value doesn't change. JumpdestGas uint64 = 1 // Once per JUMPDEST operation. CallGas uint64 = 40 // Once per CALL operation & message call transaction. ExpGas uint64 = 10 // Once per EXP instruction LogGas uint64 = 375 // Per LOG* operation. CopyGas uint64 = 3 // LogTopicGas uint64 = 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. CreateGas uint64 = 32000 // Once per CREATE operation & contract-creation transaction. SelfdestructRefundGas uint64 = 24000 // Refunded following a suicide operation. MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. ExtcodeCopyBase = 20 )
These are based on Ethereum yellow paper.
Variables ¶
This section is empty.
Functions ¶
func GetWord256 ¶
func GetWord256(st *Stack, n int) Word256
GetWord256 is similar with Get, but returns with Word256 type (default type in the Stack).
func SafeAdd ¶
SafeAdd add x and y and sets the overflow flag. of==true means an overflow has occurred.
Types ¶
type CVM ¶
type CVM struct {
// contains filtered or unexported fields
}
func NewCVM ¶
func NewCVM(options CVMOptions) *CVM
func (*CVM) Contract ¶
func (vm *CVM) Contract(code []byte) *CVMContract
Contract returns a CVMContract with the provided CVM and code.
func (*CVM) Execute ¶
func (vm *CVM) Execute(st acmstate.ReaderWriter, blockchain engine.Blockchain, eventSink exec.EventSink, params engine.CallParams, code []byte) ([]byte, error)
Initiate an EVM call against the provided state pushing events to eventSink. code should contain the EVM bytecode, input the CallData (readable by CALLDATALOAD), value the amount of native token to transfer with the call an quantity metering the number of computational steps available to the execution according to the gas schedule.
func (*CVM) SetExternals ¶
func (vm *CVM) SetExternals(externals engine.Dispatcher)
SetExternals sets external callables to be added to the engine for mutual contract calling.
type CVMContract ¶
type CVMContract struct { *CVM // contains filtered or unexported fields }
CVMContract is the basic VM and code pair needed to make contract calls in CVM.
func (*CVMContract) Call ¶
func (c *CVMContract) Call(state engine.State, params engine.CallParams) ([]byte, error)
Call executes the CVM contract call with the given state of the blockchain and parameters.
type CVMOptions ¶
type CVMOptions struct { MemoryProvider func(errors.Sink) gasMemory Natives *native.Natives Nonce []byte DebugOpcodes bool DumpTokens bool CallStackMaxDepth uint64 DataStackInitialCapacity uint64 DataStackMaxDepth uint64 Logger *logging.Logger }
CVMOptions are parameters that are generally stable across a burrow configuration. Defaults will be used for any zero values.