execution

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const BlockingTimeoutSeconds = 30
View Source
const GasLimit = uint64(1000000)

TODO: make configurable

Variables

This section is empty.

Functions

func HasPermission

func HasPermission(accountGetter state.AccountGetter, acc acm.Account, perm ptypes.PermFlag, logger *logging.Logger) bool

Get permission on an account or fall back to global value

func NameRegDecode

func NameRegDecode(r io.Reader, n *int, err *error) interface{}

func NameRegEncode

func NameRegEncode(o interface{}, w io.Writer, n *int, err *error)

func VMOptions

func VMOptions(vmOptions ...func(*evm.VM)) func(*executor)

Types

type Accounts

type Accounts struct {
	burrow_sync.RingMutex
	state.Reader
	// contains filtered or unexported fields
}

Accounts pairs an underlying state.Reader with a KeyClient to provide a signing variant of an account it also maintains a lock over addresses to provide a linearisation of signing events using SequentialSigningAccount

func NewAccounts

func NewAccounts(reader state.Reader, keyClient keys.KeyClient, mutexCount int) *Accounts

func (*Accounts) SequentialSigningAccount

func (accs *Accounts) SequentialSigningAccount(address acm.Address) *SequentialSigningAccount

func (*Accounts) SequentialSigningAccountFromPrivateKey

func (accs *Accounts) SequentialSigningAccountFromPrivateKey(privateKeyBytes []byte) (*SequentialSigningAccount, error)

func (*Accounts) SigningAccount

func (accs *Accounts) SigningAccount(address acm.Address, signer acm.Signer) (*SigningAccount, error)

type BatchCommitter

type BatchCommitter interface {
	BatchExecutor
	// Commit execution results to underlying State and provide opportunity
	// to mutate state before it is saved
	Commit() (stateHash []byte, err error)
}

Executes transactions

func NewBatchCommitter

func NewBatchCommitter(backend *State, chainID string, tip bcm.Tip, publisher event.Publisher, logger *logging.Logger,
	options ...ExecutionOption) BatchCommitter

type BatchExecutor

type BatchExecutor interface {
	// Provides access to write lock for a BatchExecutor so reads can be prevented for the duration of a commit
	sync.Locker
	state.Reader
	// Execute transaction against block cache (i.e. block buffer)
	Execute(tx txs.Tx) error
	// Reset executor to underlying State
	Reset() error
}

func NewBatchChecker

func NewBatchChecker(backend *State, chainID string, tip bcm.Tip, logger *logging.Logger,
	options ...ExecutionOption) BatchExecutor

Wraps a cache of what is variously known as the 'check cache' and 'mempool'

type Call

type Call struct {
	Return  []byte
	GasUsed uint64
}

type ExecutionConfig

type ExecutionConfig struct {
	VMOptions []VMOption `json:",omitempty" toml:",omitempty"`
}

func DefaultExecutionConfig

func DefaultExecutionConfig() *ExecutionConfig

func (*ExecutionConfig) ExecutionOptions

func (ec *ExecutionConfig) ExecutionOptions() ([]ExecutionOption, error)

type ExecutionOption

type ExecutionOption func(*executor)

type InvalidTxError

type InvalidTxError struct {
	Tx     txs.Tx
	Reason error
}

func (InvalidTxError) Error

func (txErr InvalidTxError) Error() string

type NameRegCache

type NameRegCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

The NameRegCache helps prevent unnecessary IAVLTree updates and garbage generation.

func NewNameRegCache

func NewNameRegCache(backend NameRegGetter) *NameRegCache

Returns a NameRegCache that wraps an underlying NameRegCacheGetter to use on a cache miss, can write to an output NameRegWriter via Sync. Not goroutine safe, use syncStateCache if you need concurrent access

func (*NameRegCache) Backend

func (cache *NameRegCache) Backend() NameRegGetter

func (*NameRegCache) Flush

func (cache *NameRegCache) Flush(state NameRegWriter) error

Syncs the NameRegCache and Resets it to use NameRegWriter as the backend NameRegGetter

func (*NameRegCache) GetNameRegEntry

func (cache *NameRegCache) GetNameRegEntry(name string) (*NameRegEntry, error)

func (*NameRegCache) RemoveNameRegEntry

func (cache *NameRegCache) RemoveNameRegEntry(name string) error

func (*NameRegCache) Reset

func (cache *NameRegCache) Reset(backend NameRegGetter)

Resets the cache to empty initialising the backing map to the same size as the previous iteration.

func (*NameRegCache) Sync

func (cache *NameRegCache) Sync(state NameRegWriter) error

Writes whatever is in the cache to the output NameRegWriter state. Does not flush the cache, to do that call Reset() after Sync or use Flusth if your wish to use the output state as your next backend

func (*NameRegCache) UpdateNameRegEntry

func (cache *NameRegCache) UpdateNameRegEntry(entry *NameRegEntry) error

type NameRegEntry

type NameRegEntry struct {
	// registered name for the entry
	Name string
	// address that created the entry
	Owner account.Address
	// data to store under this name
	Data string
	// block at which this entry expires
	Expires uint64
}

NameReg provides a global key value store based on Name, Data pairs that are subject to expiry and ownership by an account.

func DecodeNameRegEntry

func DecodeNameRegEntry(entryBytes []byte) *NameRegEntry

type NameRegGetter

type NameRegGetter interface {
	GetNameRegEntry(name string) (*NameRegEntry, error)
}

type NameRegIterable

type NameRegIterable interface {
	NameRegGetter
	IterateNameRegEntries(consumer func(*NameRegEntry) (stop bool)) (stopped bool, err error)
}

type NameRegUpdater

type NameRegUpdater interface {
	// Updates the name entry creating it if it does not exist
	UpdateNameRegEntry(entry *NameRegEntry) error
	// Remove the name entry
	RemoveNameRegEntry(name string) error
}

type NameRegWriter

type NameRegWriter interface {
	NameRegGetter
	NameRegUpdater
}

type SequentialSigningAccount

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

func (*SequentialSigningAccount) Lock

type SigningAccount

type SigningAccount struct {
	acm.Account
	acm.Signer
}

type State

type State struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func LoadState

func LoadState(db dbm.DB, hash []byte) (*State, error)

Tries to load the execution state from DB, returns nil with no error if no state found

func MakeGenesisState

func MakeGenesisState(db dbm.DB, genesisDoc *genesis.GenesisDoc) (*State, error)

Make genesis state from GenesisDoc and save to DB

func NewState

func NewState(db dbm.DB) *State

func (*State) Copy

func (s *State) Copy(db dbm.DB) *State

Creates a copy of the database to the supplied db

func (*State) GetAccount

func (s *State) GetAccount(address acm.Address) (acm.Account, error)

Returns nil if account does not exist with given address.

func (*State) GetNameRegEntry

func (s *State) GetNameRegEntry(name string) (*NameRegEntry, error)

func (*State) GetStorage

func (s *State) GetStorage(address acm.Address, key binary.Word256) (binary.Word256, error)

func (*State) Hash

func (s *State) Hash() []byte

Computes the state hash, also computed on save where it is returned

func (*State) IterateAccounts

func (s *State) IterateAccounts(consumer func(acm.Account) (stop bool)) (stopped bool, err error)

func (*State) IterateNameRegEntries

func (s *State) IterateNameRegEntries(consumer func(*NameRegEntry) (stop bool)) (stopped bool, err error)

func (*State) IterateStorage

func (s *State) IterateStorage(address acm.Address,
	consumer func(key, value binary.Word256) (stop bool)) (stopped bool, err error)

func (*State) RemoveAccount

func (s *State) RemoveAccount(address acm.Address) error

func (*State) RemoveNameRegEntry

func (s *State) RemoveNameRegEntry(name string) error

func (*State) Save

func (s *State) Save() error

func (*State) SetStorage

func (s *State) SetStorage(address acm.Address, key, value binary.Word256) error

func (*State) UpdateAccount

func (s *State) UpdateAccount(account acm.Account) error

func (*State) UpdateNameRegEntry

func (s *State) UpdateNameRegEntry(entry *NameRegEntry) error

type Transactor

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

Transactor is the controller/middleware for the v0 RPC

func NewTransactor

func NewTransactor(tip blockchain.Tip, eventEmitter event.Emitter,
	broadcastTxAsync func(tx txs.Tx, callback func(res *abci_types.Response)) error,
	logger *logging.Logger) *Transactor

func (*Transactor) BroadcastTx

func (trans *Transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error)

Broadcast a transaction and waits for a response from the mempool. Transactions to BroadcastTx will block during various mempool operations (managed by Tendermint) including mempool Reap, Commit, and recheckTx.

func (*Transactor) BroadcastTxAsync

func (trans *Transactor) BroadcastTxAsync(tx txs.Tx, callback func(res *abci_types.Response)) error

func (*Transactor) Call

func (trans *Transactor) Call(reader state.Reader, fromAddress, toAddress acm.Address,
	data []byte) (call *Call, err error)

Run a contract's code on an isolated and unpersisted state Cannot be used to create new contracts

func (*Transactor) CallCode

func (trans *Transactor) CallCode(reader state.Reader, fromAddress acm.Address, code, data []byte) (*Call, error)

Run the given code on an isolated and unpersisted state Cannot be used to create new contracts.

func (*Transactor) Send

func (trans *Transactor) Send(sequentialSigningAccount *SequentialSigningAccount, toAddress acm.Address,
	amount uint64) (*txs.Receipt, error)

func (*Transactor) SendAndHold

func (trans *Transactor) SendAndHold(sequentialSigningAccount *SequentialSigningAccount, toAddress acm.Address,
	amount uint64) (*txs.Receipt, error)

func (*Transactor) SignTx

func (trans *Transactor) SignTx(tx txs.Tx, signingAccounts []acm.AddressableSigner) (txs.Tx, error)

Sign a transaction

func (*Transactor) Transact

func (trans *Transactor) Transact(sequentialSigningAccount *SequentialSigningAccount, address *acm.Address, data []byte,
	gasLimit, fee uint64) (*txs.Receipt, error)

Orders calls to BroadcastTx using lock (waits for response from core before releasing)

func (*Transactor) TransactAndHold

func (trans *Transactor) TransactAndHold(sequentialSigningAccount *SequentialSigningAccount, address *acm.Address, data []byte, gasLimit,
	fee uint64) (*evm_events.EventDataCall, error)

func (*Transactor) TransactNameReg

func (trans *Transactor) TransactNameReg(sequentialSigningAccount *SequentialSigningAccount, name, data string, amount,
	fee uint64) (*txs.Receipt, error)

type UnlockFunc

type UnlockFunc func()

type VMOption

type VMOption string
const (
	DebugOpcodes VMOption = "DebugOpcodes"
	DumpTokens   VMOption = "DumpTokens"
)

Directories

Path Synopsis
evm
abi
asm

Jump to

Keyboard shortcuts

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