execution

package
v0.0.0-...-25a45d7 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockingTimeout     = 10 * time.Second
	SubscribeBufferSize = 10
)

Variables

This section is empty.

Functions

func CallCodeSim

func CallCodeSim(reader state.Reader, tip bcm.BlockchainInfo, fromAddress, address crypto.Address, code, data []byte,
	logger *logging.Logger) (*exec.TxExecution, error)

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

func CallSim

func CallSim(reader state.Reader, tip bcm.BlockchainInfo, fromAddress, address crypto.Address, data []byte,
	logger *logging.Logger) (*exec.TxExecution, error)

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

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 crypto.Address) (*SequentialSigningAccount, error)

func (*Accounts) SigningAccount

func (accs *Accounts) SigningAccount(address crypto.Address) (*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(blockHash []byte, blockTime time.Time, header *abciTypes.Header) (stateHash []byte, err error)
}

Executes transactions

func NewBatchCommitter

func NewBatchCommitter(backend ExecutorState, blockchain *bcm.Blockchain, emitter 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)
	Executor
	// Reset executor to underlying State
	Reset() error
}

func NewBatchChecker

func NewBatchChecker(backend ExecutorState, blockchain *bcm.Blockchain, logger *logging.Logger,
	options ...ExecutionOption) BatchExecutor

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

type CommitID

type CommitID struct {
	Hash    binary.HexBytes
	Version int64
}

func (CommitID) String

func (cid CommitID) String() string

type ExecutionConfig

type ExecutionConfig struct {
	CallStackMaxDepth        uint64
	DataStackInitialCapacity uint64
	DataStackMaxDepth        uint64
	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 Executor

type Executor interface {
	Execute(txEnv *txs.Envelope) (*exec.TxExecution, error)
}

type ExecutorState

type ExecutorState interface {
	Update(updater func(ws Updatable) error) (hash []byte, version int64, err error)
	names.Reader
	proposal.Reader
	state.IterableReader
}

type SequentialSigningAccount

type SequentialSigningAccount struct {
	Address crypto.Address
	// contains filtered or unexported fields
}

func (*SequentialSigningAccount) Lock

type SigningAccount

type SigningAccount struct {
	*acm.Account
	crypto.Signer
}

type State

type State struct {

	// Values not reassigned
	sync.RWMutex
	// contains filtered or unexported fields
}

Writers to state are responsible for calling State.Lock() before calling

func LoadState

func LoadState(db dbm.DB, version int64) (*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

Create a new State object

func (*State) CommitID

func (s *State) CommitID(version int64) (*CommitID, error)

func (*State) Copy

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

Creates a copy of the database to the supplied db

func (*State) GetAccount

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

Returns nil if account does not exist with given address.

func (*State) GetAccountStats

func (s *State) GetAccountStats() state.AccountStats

func (*State) GetBlock

func (s *State) GetBlock(height uint64) (*exec.BlockExecution, error)

func (*State) GetBlocks

func (s *State) GetBlocks(startHeight, endHeight uint64, consumer func(*exec.BlockExecution) (stop bool)) (stopped bool, err error)

func (*State) GetName

func (s *State) GetName(name string) (*names.Entry, error)

func (*State) GetProposal

func (s *State) GetProposal(proposalHash []byte) (*payload.Ballot, error)

func (*State) GetStorage

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

func (*State) GetTx

func (s *State) GetTx(txHash []byte) (*exec.TxExecution, error)

func (*State) Hash

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

func (*State) IterateAccounts

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

func (*State) IterateNames

func (s *State) IterateNames(consumer func(*names.Entry) (stop bool)) (stopped bool, err error)

func (*State) IterateProposals

func (s *State) IterateProposals(consumer func(proposalHash []byte, proposal *payload.Ballot) (stop bool)) (stopped bool, err error)

func (*State) IterateStorage

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

func (*State) Update

func (s *State) Update(updater func(up Updatable) error) ([]byte, int64, error)

Perform updates to state whilst holding the write lock, allows a commit to hold the write lock across multiple operations while preventing interlaced reads and writes

func (*State) Version

func (s *State) Version() int64

type Transactor

type Transactor struct {
	Tip             bcm.BlockchainInfo
	Subscribable    event.Subscribable
	MempoolAccounts *Accounts
	// contains filtered or unexported fields
}

Transactor is responsible for helping to formulate, sign, and broadcast transactions to tendermint

The BroadcastTx* methods are able to work against the mempool Accounts (pending) state rather than the committed (final) Accounts state and can assign a sequence number based on all of the txs seen since the last block - provided these transactions are successfully committed (via DeliverTx) then subsequent transactions will have valid sequence numbers. This allows Burrow to coordinate sequencing and signing for a key it holds or is provided - it is down to the key-holder to manage the mutual information between transactions concurrent within a new block window.

func NewTransactor

func NewTransactor(tip bcm.BlockchainInfo, subscribable event.Subscribable, mempoolAccounts *Accounts,
	checkTxAsync func(tx tmTypes.Tx, cb func(*abciTypes.Response)) error, txEncoder txs.Encoder,
	logger *logging.Logger) *Transactor

func (*Transactor) BroadcastTxAsync

func (trans *Transactor) BroadcastTxAsync(txEnv *txs.Envelope) (*txs.Receipt, error)

Broadcast a transaction without waiting for confirmation - will attempt to sign server-side and set sequence numbers if no signatures are provided

func (*Transactor) BroadcastTxSync

func (trans *Transactor) BroadcastTxSync(ctx context.Context, txEnv *txs.Envelope) (*exec.TxExecution, error)

func (*Transactor) CallCodeSim

func (trans *Transactor) CallCodeSim(fromAddress crypto.Address, code, data []byte) (*exec.TxExecution, error)

func (*Transactor) CallSim

func (trans *Transactor) CallSim(fromAddress, address crypto.Address, data []byte) (*exec.TxExecution, error)

func (*Transactor) CheckTxAsync

func (trans *Transactor) CheckTxAsync(txEnv *txs.Envelope, callback func(res *abciTypes.Response)) error

func (*Transactor) CheckTxAsyncRaw

func (trans *Transactor) CheckTxAsyncRaw(txBytes []byte, callback func(res *abciTypes.Response)) error

func (*Transactor) CheckTxSync

func (trans *Transactor) CheckTxSync(txEnv *txs.Envelope) (*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) CheckTxSyncRaw

func (trans *Transactor) CheckTxSyncRaw(txBytes []byte) (*txs.Receipt, error)

func (*Transactor) MaybeSignTxMempool

func (trans *Transactor) MaybeSignTxMempool(txEnv *txs.Envelope) (UnlockFunc, error)

func (*Transactor) SignTx

func (trans *Transactor) SignTx(txEnv *txs.Envelope) (*txs.Envelope, error)

func (*Transactor) SignTxMempool

func (trans *Transactor) SignTxMempool(txEnv *txs.Envelope) (*txs.Envelope, UnlockFunc, error)

type UnlockFunc

type UnlockFunc func()

type Updatable

type Updatable interface {
	state.Writer
	names.Writer
	AddBlock(blockExecution *exec.BlockExecution) error
}

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