Documentation ¶
Index ¶
- Constants
- func AddressFromName(name string) (address crypto.Address)
- func Call(state State, params CallParams, ...) ([]byte, error)
- func CallFromSite(st State, dispatcher Dispatcher, site CallParams, target CallParams) ([]byte, error)
- func Connect(eds ...ExternalDispatcher)
- func CreateAccount(st acmstate.ReaderWriter, address crypto.Address) error
- func EnsurePermission(callFrame *CallFrame, address crypto.Address, perm permission.PermFlag) error
- func FireCallEvent(callFrame *CallFrame, callErr error, eventSink exec.EventSink, output []byte, ...) error
- func GetAccount(st acmstate.Reader, m Maybe, address crypto.Address) *acm.Account
- func HasPermission(st acmstate.Reader, address crypto.Address, perm permission.PermFlag) (bool, error)
- func InitChildCode(st acmstate.ReaderWriter, address crypto.Address, parent crypto.Address, ...) error
- func InitEVMCode(st acmstate.ReaderWriter, address crypto.Address, code []byte) error
- func InitWASMCode(st acmstate.ReaderWriter, address crypto.Address, code []byte) error
- func MustAccount(st acmstate.Reader, address crypto.Address) (*acm.Account, error)
- func MustGetAccount(st acmstate.Reader, m Maybe, address crypto.Address) *acm.Account
- func RemoveAccount(st acmstate.ReaderWriter, address crypto.Address) error
- func Transfer(st acmstate.ReaderWriter, from, to crypto.Address, amount *big.Int) error
- func UpdateAccount(st acmstate.ReaderWriter, address crypto.Address, ...) error
- func UpdateContractMeta(st acmstate.ReaderWriter, metaSt acmstate.MetadataWriter, ...) error
- func UseGasNegative(gasLeft *big.Int, gasToUse uint64) errors.CodedError
- type Blockchain
- type CallFrame
- func (st *CallFrame) CallStackDepth() uint64
- func (st *CallFrame) CreateAccount(creator, address crypto.Address) error
- func (st *CallFrame) NewFrame(cacheOptions ...acmstate.CacheOption) (*CallFrame, error)
- func (st *CallFrame) ReadOnly() *CallFrame
- func (st *CallFrame) Sync() error
- func (st *CallFrame) WithMaxCallStackDepth(max uint64) *CallFrame
- type CallParams
- type Callable
- type CallableFunc
- type Dispatcher
- type DispatcherFunc
- type Dispatchers
- type ExternalDispatcher
- type Externals
- type ExternalsStorage
- type Maybe
- type Memory
- type Native
- type Natives
- type Options
- type State
- type TestBlockchain
Constants ¶
const ( GasSha3 uint64 = 1 GasGetAccount uint64 = 1 GasStorageUpdate uint64 = 1 GasCreateAccount uint64 = 1 GasBaseOp uint64 = 0 // TODO: make this 1 GasStackOp uint64 = 1 GasEcRecover uint64 = 1 GasSha256Word uint64 = 1 GasSha256Base uint64 = 1 GasRipemd160Word uint64 = 1 GasRipemd160Base uint64 = 1 GasExpModWord uint64 = 1 GasExpModBase uint64 = 1 GasIdentityWord uint64 = 1 GasIdentityBase uint64 = 1 )
Variables ¶
This section is empty.
Functions ¶
func AddressFromName ¶
func Call ¶
func Call(state State, params CallParams, execute func(State, CallParams) ([]byte, error)) ([]byte, error)
Call provides a standard wrapper for implementing Callable.Call with appropriate error handling and event firing.
func CallFromSite ¶
func CallFromSite(st State, dispatcher Dispatcher, site CallParams, target CallParams) ([]byte, error)
func Connect ¶
func Connect(eds ...ExternalDispatcher)
Connect ExternalDispatchers eds to each other so that the underlying engines can mutually call contracts hosted by other dispatchers
func CreateAccount ¶
func CreateAccount(st acmstate.ReaderWriter, address crypto.Address) error
func EnsurePermission ¶
func FireCallEvent ¶
func HasPermission ¶
func HasPermission(st acmstate.Reader, address crypto.Address, perm permission.PermFlag) (bool, error)
CONTRACT: it is the duty of the contract writer to call known permissions we do not convey if a permission is not set (unlike in state/execution, where we guarantee HasPermission is called on known permissions and panics else) If the perm is not defined in the acc nor set by default in GlobalPermissions, this function returns false.
func InitChildCode ¶
func InitEVMCode ¶
func InitWASMCode ¶
func MustAccount ¶
func MustGetAccount ¶
Guaranteed to return a non-nil account, if the account does not exist returns a pointer to the zero-value of Account and pushes an error.
func RemoveAccount ¶
func RemoveAccount(st acmstate.ReaderWriter, address crypto.Address) error
func UpdateAccount ¶
func UpdateContractMeta ¶
func UpdateContractMeta(st acmstate.ReaderWriter, metaSt acmstate.MetadataWriter, address crypto.Address, payloadMeta []*payload.ContractMeta) error
func UseGasNegative ¶
func UseGasNegative(gasLeft *big.Int, gasToUse uint64) errors.CodedError
Try to deduct gasToUse from gasLeft. If ok return false, otherwise set err and return true.
Types ¶
type Blockchain ¶
type CallFrame ¶
type CallFrame struct { // Cache this State wraps *acmstate.Cache // contains filtered or unexported fields }
func NewCallFrame ¶
func NewCallFrame(st acmstate.ReaderWriter, cacheOptions ...acmstate.CacheOption) *CallFrame
Create a new CallFrame to hold state updates at a particular level in the call stack
func (*CallFrame) CallStackDepth ¶
func (*CallFrame) CreateAccount ¶
func (*CallFrame) NewFrame ¶
func (st *CallFrame) NewFrame(cacheOptions ...acmstate.CacheOption) (*CallFrame, error)
func (*CallFrame) WithMaxCallStackDepth ¶
type CallParams ¶
type Callable ¶
type Callable interface {
Call(state State, params CallParams) (output []byte, err error)
}
Effectively a contract, but can either represent a single function or a contract with multiple functions and a selector
type CallableFunc ¶
type CallableFunc func(st State, params CallParams) (output []byte, err error)
func (CallableFunc) Call ¶
func (c CallableFunc) Call(state State, params CallParams) (output []byte, err error)
type Dispatcher ¶
type DispatcherFunc ¶
type Dispatchers ¶
type Dispatchers []Dispatcher
func NewDispatchers ¶
func NewDispatchers(dispatchers ...Dispatcher) Dispatchers
type ExternalDispatcher ¶
type ExternalDispatcher interface { Dispatcher SetExternals(externals Dispatcher) }
An ExternalDispatcher is able to Dispatch accounts to external engines as well as Dispatch to itself
type Externals ¶
type Externals struct {
// contains filtered or unexported fields
}
An ExternalDispatcher is able to Dispatch accounts to external engines as well as Dispatch to itself
func (*Externals) SetExternals ¶
func (ed *Externals) SetExternals(externals Dispatcher)
type ExternalsStorage ¶
type ExternalsStorage struct { }
type Memory ¶
type Memory interface { // Read a value from the memory store starting at offset // (index of first byte will equal offset). The value will be returned as a // length-bytes byte slice. Returns an error if the memory cannot be read or // is not allocated. // // The value returned should be copy of any underlying memory, not a reference // to the underlying store. Read(offset, length *big.Int) []byte // Write a value to the memory starting at offset (the index of the first byte // written will equal offset). The value is provided as bytes to be written // consecutively to the memory store. Return an error if the memory cannot be // written or allocated. Write(offset *big.Int, value []byte) // Returns the current capacity of the memory. For dynamically allocating // memory this capacity can be used as a write offset that is guaranteed to be // unused. Solidity in particular makes this assumption when using MSIZE to // get the current allocated memory. Capacity() *big.Int }
Interface for a bounded linear memory indexed by a single *big.Int parameter for each byte in the memory.
func NewDynamicMemory ¶
Get a new DynamicMemory (note that although we take a maximumCapacity of uint64 we currently limit the maximum to int32 at runtime because we are using a single slice which we cannot guarantee to be indexable above int32 or all validators
type Native ¶
type Native interface { Callable SetExternals(externals Dispatcher) ContractMeta() []*acm.ContractMeta FullName() string Address() crypto.Address }
type Natives ¶
type Natives interface { ExternalDispatcher GetByAddress(address crypto.Address) Native }
type Options ¶
type Options struct { MemoryProvider func(errors.Sink) Memory Natives Natives Nonce []byte DebugOpcodes bool DumpTokens bool CallStackMaxDepth uint64 DataStackInitialCapacity uint64 DataStackMaxDepth uint64 Logger *logging.Logger }
Options are parameters that are generally stable across a hsc configuration. Defaults will be used for any zero values.
type TestBlockchain ¶
func (*TestBlockchain) BlockHash ¶
func (b *TestBlockchain) BlockHash(height uint64) ([]byte, error)
func (*TestBlockchain) ChainID ¶
func (V *TestBlockchain) ChainID() string
func (*TestBlockchain) LastBlockHeight ¶
func (b *TestBlockchain) LastBlockHeight() uint64
func (*TestBlockchain) LastBlockTime ¶
func (b *TestBlockchain) LastBlockTime() time.Time