txexec

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 15 Imported by: 6

Documentation

Overview

Package txexec implements all transaction executors.

Package txexec implements all transaction executors.

Package txexec implements all transaction executors.

Package txexec implements all transaction executors.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonceNotAllowed           = errors.New("nonce not allowed")
	ErrNonceNotAllowedTooNew     = errors.New("nonce not allowed(too new)")
	ErrNonceNotAllowedContained  = errors.New("nonce not allowed(contained)")
	ErrNonceNotAllowedTooOld     = errors.New("nonce not allowed(too old)")
	ErrNonceSetNotFound          = errors.New("nonceSet not found")
	ErrInsufficientBalance       = errors.New("insufficient balance")
	ErrSimpleTxHasNoTarget       = errors.New("simple transaction has no target")
	ErrInsufficientBalanceForGas = errors.New("insufficient balance to pay for gas")
	ErrOutOfGas                  = errors.New("out of gas")
	ErrCodeStoreOutOfGas         = errors.New("contract creation code storage out of gas")
	ErrWasmExec                  = errors.New("wasm exec return error")
	ErrTransferIsNotAllowed      = errors.New("transfer is not allowed")
)

Functions

func CacheTxSender

func CacheTxSender(txs types.Transactions, signer types.Signer, threadNum int)

func CallWasmContract

func CallWasmContract(codePointer unsafe.Pointer, codeLength int, actionPointer unsafe.Pointer, actionLength int, fromAddrPointer unsafe.Pointer, toAddrPointer unsafe.Pointer, ownerPointer unsafe.Pointer, amount uint64, remainedGas *uint64, callbackParamKey uint64) int

func CanTransfer

func CanTransfer(db *state.StateDB, addr common.Address, amount *big.Int, round uint64) bool

CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.

func IntrinsicGas

func IntrinsicGas(data []byte, contractCreation bool) (uint64, error)

IntrinsicGas computes the 'intrinsic gas' for a message with the given data.

func Pointer2Address

func Pointer2Address(pointer unsafe.Pointer) (common.Address, error)

func Pointer2Slice

func Pointer2Slice(pointer unsafe.Pointer, length int) ([]byte, error)

func SimpleApplyMessage

func SimpleApplyMessage(prevStateDb *state.StateDB, statedb *state.StateDB, round uint64, msg Message, gp *types.GasPool, maxBitLength uint64, coinbase common.Address, callbackParamKey uint64) ([]byte, uint64, error)

func Transfer

func Transfer(db *state.StateDB, sender, recipient common.Address, amount *big.Int)

Transfer subtracts amount from sender and adds amount to recipient using the given Db

func WasmApplyMessage

func WasmApplyMessage(prevStateDb *state.StateDB, statedb *state.StateDB, round uint64, msg Message, gp *types.GasPool, maxBitLength uint64, coinbase common.Address, callbackParamKey uint64) ([]byte, uint64, bool, error)

Types

type Message

type Message interface {
	From() common.Address
	To() *common.Address

	GasPrice() *big.Int
	Gas() uint64
	Value() *big.Int

	Nonce() uint64
	CheckNonce() bool
	Data() []byte
}

Message represents a message sent to a contract.

type SimpleExecutor

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

func (*SimpleExecutor) ApplyTransaction

func (e *SimpleExecutor) ApplyTransaction(prevStateDb *state.StateDB, state *state.StateDB, tx *types.Transaction, block *types.Block, gp *types.GasPool, usedGas *uint64, callbackParamKey uint64) (*types.Receipt, uint64, common.Address, error)

ApplyTransaction attempts to apply a transaction to the given state database and uses the input parameters for its environment. It returns the receipt for the transaction, gas used and an error if the transaction failed, indicating the block was invalid.

func (*SimpleExecutor) ExecuteTransaction

func (e *SimpleExecutor) ExecuteTransaction(prevStateDb *state.StateDB, state *state.StateDB, tx *types.Transaction, block *types.Block, gp *types.GasPool, usedGas *uint64, callbackParamKey uint64) (*types.Receipt, common.Address, error)

func (*SimpleExecutor) ExecuteTransactions

func (e *SimpleExecutor) ExecuteTransactions(txs types.Transactions, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, txPackageIndex uint32, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, int)

func (*SimpleExecutor) ExecuteTxPackage

func (e *SimpleExecutor) ExecuteTxPackage(txPackageIndex uint32, txPackage *types.TxPackage, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, bool)

func (*SimpleExecutor) ExecuteTxPackages

func (e *SimpleExecutor) ExecuteTxPackages(txpkgs types.TxPackages, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, int)

type StateTransition

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

The State Transitioning Model

A state transition is a change made when a transaction is applied to the current world state The state transitioning model does all the necessary work to work out a valid new state root.

1) Nonce handling 2) Pre pay gas 3) Create a new state object if the recipient is \0*32 4) Value transfer == If contract creation ==

4a) Attempt to run transaction data
4b) If valid, use result as code for the new state object

== end ==

func NewStateTransition

func NewStateTransition(prevStateDb *state.StateDB, statedb *state.StateDB, round uint64, msg Message, gp *types.GasPool, nonceSet *nonces.NonceSet, maxBitLength uint64, callbackParamKey uint64) *StateTransition

NewStateTransition initialises and returns a new state transition object.

func (*StateTransition) SimpleTransitionDb

func (st *StateTransition) SimpleTransitionDb(coinbase common.Address) (ret []byte, usedGas uint64, err error)

func (*StateTransition) WasmTransitionDb

func (st *StateTransition) WasmTransitionDb(coinbase common.Address) (ret []byte, usedGas uint64, wasmFailed bool, err error)

type TxExecResult

type TxExecResult struct {
	StateDb  *state.StateDB
	Receipts types.Receipts
}

type TxExecutor

type TxExecutor interface {
	ExecuteTxPackages(txpkgs types.TxPackages, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, int)
	ExecuteTransactions(txs types.Transactions, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, txPackageIndex uint32, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, int)
}

func NewExecutor

func NewExecutor(exeType string, maxBitLength uint64, signer types.Signer) TxExecutor

func NewSimpleExecutor

func NewSimpleExecutor(signer types.Signer, maxBitLength uint64) TxExecutor

func NewWasmExecutor

func NewWasmExecutor(signer types.Signer, maxBitLength uint64) TxExecutor

type WasmExecutor

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

func (*WasmExecutor) ApplyTransaction

func (e *WasmExecutor) ApplyTransaction(prevStateDb *state.StateDB, state *state.StateDB, tx *types.Transaction, block *types.Block, gp *types.GasPool, usedGas *uint64, maxBitLength uint64, callbackParamKey uint64) (*types.Receipt, uint64, common.Address, error)

ApplyTransaction attempts to apply a transaction to the given state database and uses the input parameters for its environment. It returns the receipt for the transaction, gas used and an error if the transaction failed, indicating the block was invalid.

func (*WasmExecutor) ExecuteTransaction

func (e *WasmExecutor) ExecuteTransaction(prevStateDb *state.StateDB, state *state.StateDB, tx *types.Transaction, block *types.Block, gp *types.GasPool, usedGas *uint64, callbackParamKey uint64) (*types.Receipt, common.Address, error)

func (*WasmExecutor) ExecuteTransactions

func (e *WasmExecutor) ExecuteTransactions(txs types.Transactions, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, txPackageIndex uint32, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, int)

func (*WasmExecutor) ExecuteTxPackage

func (e *WasmExecutor) ExecuteTxPackage(txPackageIndex uint32, txPackage *types.TxPackage, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, bool)

func (*WasmExecutor) ExecuteTxPackages

func (e *WasmExecutor) ExecuteTxPackages(txpkgs types.TxPackages, prevStateDb *state.StateDB, state *state.StateDB, receipts types.Receipts, block *types.Block, executedTxs []*types.TxWithIndex, usedGas *uint64, allLogs []*types.Log, gasPool *types.GasPool, callbackParamKey uint64) ([]*types.TxWithIndex, []*types.Log, types.Receipts, int)

Jump to

Keyboard shortcuts

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