app

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocAward

func AllocAward(wasm *wasm.WASM, logger log.Logger) error

func ApplyMessage

func ApplyMessage(vmenv vm.VmInterface, msg types.IMessage, tokenAddr common.Address) ([]byte, uint64, uint64, *big.Int, error, error)

func ApplyUTXOMessage

func ApplyUTXOMessage(vmenv vm.VmInterface, tx *types.UTXOTransaction, tokenAddr common.Address) ([]byte, uint64, uint64, *big.Int, error, error)

ApplyMessage computes the new state by applying the given message against the old state within the environment.

ApplyMessage returns the bytes returned by any EVM execution (if it took place), the gas used (which includes gas refunds) and an error if it failed. An error always indicates a core error meaning that the message would always fail for that particular state and would never be accepted within a block.

func CallWasmContract

func CallWasmContract(wasm *wasm.WASM, sender, contractAddr common.Address, amount *big.Int, input []byte, logger log.Logger) ([]byte, error)

CallWasmContract only be used by chain inner to call wasm contract directly

func GetCoefficient

func GetCoefficient(statedb types.StateDB, logger log.Logger) *types.Coefficient

func HashForIndex

func HashForIndex(x interface{}) (h common.Hash)

HashForIndex cal the key for contractTx

func IntrinsicGas

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

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

func SetPoceeds

func SetPoceeds(wasm *wasm.WASM, coinbase common.Address, amount *big.Int, logger log.Logger) error

Types

type AwardHandle

type AwardHandle func(wasm *wasm.WASM, logger log.Logger) error

type LinkApplication

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

func NewLinkApplication

func NewLinkApplication(db dbm.DB, bc *blockchain.BlockStore, utxoStore *utxo.UtxoStore,
	txService txmgr.CrossState, eventbus *types.EventBus, isTrie bool, brs *blockchain.BalanceRecordStore, poceedHandle PoceedHandle, awardHandle AwardHandle) (*LinkApplication, error)

func (*LinkApplication) Block

func (app *LinkApplication) Block() *types.Block

func (*LinkApplication) BlockChain

func (app *LinkApplication) BlockChain() types.BlockChain

func (*LinkApplication) CheckBlock

func (app *LinkApplication) CheckBlock(block *types.Block) bool

func (*LinkApplication) CheckBlockInCommit

func (app *LinkApplication) CheckBlockInCommit(block *types.Block) bool

XXX DEPRECATED

func (*LinkApplication) CheckTx

func (app *LinkApplication) CheckTx(tx types.Tx, checkBasic bool) error

CheckTx assumes that txs' signature has been verified before.

func (*LinkApplication) CommitBlock

func (app *LinkApplication) CommitBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit, fastsync bool) ([]*types.Validator, error)

func (*LinkApplication) CreateBlock

func (app *LinkApplication) CreateBlock(height uint64, maxTxs int, gasLimit uint64, timeUnix uint64) *types.Block

func (*LinkApplication) GetBalance

func (app *LinkApplication) GetBalance(addr common.Address) *big.Int

func (*LinkApplication) GetLastChangedVals

func (app *LinkApplication) GetLastChangedVals() (height uint64, vals []*types.Validator)

func (*LinkApplication) GetLatestStateDB

func (app *LinkApplication) GetLatestStateDB() *state.StateDB

func (*LinkApplication) GetNonce

func (app *LinkApplication) GetNonce(addr common.Address) uint64

func (*LinkApplication) GetPendingBlock

func (app *LinkApplication) GetPendingBlock() *types.Block

func (*LinkApplication) GetPendingStateDB

func (app *LinkApplication) GetPendingStateDB() *state.StateDB

func (*LinkApplication) GetRecoverValidators

func (app *LinkApplication) GetRecoverValidators(height uint64) []*types.Validator

GetRecoverValidators return both white list and candidates

func (*LinkApplication) GetStorageRoot

func (app *LinkApplication) GetStorageRoot(addr common.Address) common.Hash

func (*LinkApplication) GetUTXOGas

func (app *LinkApplication) GetUTXOGas() uint64

func (*LinkApplication) GetValidators

func (app *LinkApplication) GetValidators(height uint64) []*types.Validator

func (*LinkApplication) Height

func (app *LinkApplication) Height() uint64

func (*LinkApplication) IsWasmContract

func (app *LinkApplication) IsWasmContract(data []byte) bool

func (*LinkApplication) LoadBlock

func (app *LinkApplication) LoadBlock(height uint64) *types.Block

func (*LinkApplication) LoadBlockCommit

func (app *LinkApplication) LoadBlockCommit(height uint64) *types.Commit

func (*LinkApplication) LoadBlockMeta

func (app *LinkApplication) LoadBlockMeta(height uint64) *types.BlockMeta

func (*LinkApplication) LoadBlockPart

func (app *LinkApplication) LoadBlockPart(height uint64, index int) *types.Part

func (*LinkApplication) LoadSeenCommit

func (app *LinkApplication) LoadSeenCommit(height uint64) *types.Commit

func (*LinkApplication) LockState

func (app *LinkApplication) LockState()

func (*LinkApplication) Mempool

func (app *LinkApplication) Mempool() types.Mempool

func (*LinkApplication) PreRunBlock

func (app *LinkApplication) PreRunBlock(block *types.Block)

func (*LinkApplication) SetConm

func (app *LinkApplication) SetConm(conM *p2p.ConManager)

func (*LinkApplication) SetLastChangedVals

func (app *LinkApplication) SetLastChangedVals(height uint64, vals []*types.Validator)

func (*LinkApplication) SetLogger

func (app *LinkApplication) SetLogger(l log.Logger)

func (*LinkApplication) SetMempool

func (app *LinkApplication) SetMempool(mempool types.Mempool)

func (*LinkApplication) State

func (app *LinkApplication) State() types.State

func (*LinkApplication) TxMgr

func (app *LinkApplication) TxMgr() types.TxMgr

func (*LinkApplication) UTXOStore

func (app *LinkApplication) UTXOStore() types.UTXOStore

func (*LinkApplication) UnlockState

func (app *LinkApplication) UnlockState()

type MockMempool

type MockMempool struct {
	mock.Mock
}

MockMempool is an autogenerated mock type for the MockMempool type

func (*MockMempool) KeyImageExists

func (_m *MockMempool) KeyImageExists(key lktypes.Key) bool

KeyImageExists provides a mock function with given fields: key

func (*MockMempool) KeyImagePush

func (_m *MockMempool) KeyImagePush(key lktypes.Key) bool

KeyImagePush provides a mock function with given fields: key

func (*MockMempool) KeyImageReset

func (_m *MockMempool) KeyImageReset()

KeyImageReset provides a mock function with given fields:

func (*MockMempool) Lock

func (_m *MockMempool) Lock()

Lock provides a mock function with given fields:

func (*MockMempool) Reap

func (_m *MockMempool) Reap(maxTxs int) types.Txs

Reap provides a mock function with given fields: maxTxs

func (*MockMempool) Unlock

func (_m *MockMempool) Unlock()

Unlock provides a mock function with given fields:

func (*MockMempool) Update

func (_m *MockMempool) Update(height uint64, txs types.Txs, keyImages []*lktypes.Key) error

Update provides a mock function with given fields: height, txs, keyImages

func (*MockMempool) VerifyTxFromCache

func (_m *MockMempool) VerifyTxFromCache(hash common.Hash) (*common.Address, bool)

VerifyTxFromCache provides a mock function with given fields: hash

type PoceedHandle

type PoceedHandle func(wasm *wasm.WASM, coinbase common.Address, amount *big.Int, logger log.Logger) error

type ProcessResult

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

func (*ProcessResult) GetReceipts

func (p *ProcessResult) GetReceipts() *types.Receipts

func (*ProcessResult) GetTxsResult

func (p *ProcessResult) GetTxsResult() *types.TxsResult

type Processor

type Processor interface {
	Process(block *types.Block, statedb *state.StateDB, cfg evm.Config) (types.Receipts, []*types.Log, uint64, []types.Tx, []*types.UTXOOutputData, []*lctypes.Key, *types.BlockBalanceRecords, error)
}

Processor is an interface for processing blocks using a given initial state.

Process takes the block to be processed and the statedb upon which the initial state is based. It should return the receipts generated, amount of gas used in the process and return an error if any of the internal rules failed.

type StateProcessor

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

StateProcessor is a basic Processor, which takes care of transitioning state from one point to another.

StateProcessor implements Processor.

func NewStateProcessor

func NewStateProcessor(bc *blockchain.BlockStore) *StateProcessor

NewStateProcessor initialises a new StateProcessor.

func (*StateProcessor) Process

Process processes the state changes according to the Ethereum rules by running the transaction messages using the statedb and applying any rewards to both the processor (coinbase) and any included uncles.

Process returns the receipts and logs accumulated during the process and returns the amount of gas that was used in the process. If any of the transactions failed to execute due to insufficient gas it will return an error.

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 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 == 5) Run Script section 6) Derive new state root

func NewStateTransition

func NewStateTransition(vmenv vm.VmInterface, msg types.IMessage, tx types.Tx, tokenAddr common.Address) *StateTransition

NewStateTransition initialises and returns a new state transition object.

func (*StateTransition) Transition

func (st *StateTransition) Transition() (ret []byte, usedGas uint64, byteCodeGas uint64, fee *big.Int, vmerr error, err error)

func (*StateTransition) TransitionDb

func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, byteCodeGas uint64, fee *big.Int, vmerr error, err error)

TransitionDb will transition the state by applying the current message and returning the result including the the used gas. It returns an error if it failed. An error indicates a consensus issue.

func (*StateTransition) UTXOTransitionDb

func (st *StateTransition) UTXOTransitionDb() (ret []byte, usedGas uint64, byteCodeGas uint64, fee *big.Int, vmerr error, err error)

if AccountInput => UTXOOutput, collect All Fee if AccountInput => UTXOOutput + AccountOutput, collect Fee by vm consume or gas policy if UTXOInput => AccountOutput + UTXOOutput, collect Fee by vm consume or gas policy

Jump to

Keyboard shortcuts

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