state

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MIT Imports: 21 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// POAABI defines the ABI of the POA smart-contract as needed by a consensus
	// module to check if an address is authorized
	POAABI       abi.ABI
	POAABISTRING string

	// POAADDR is the address of the POA smart-contract.
	POAADDR eth_common.Address
)
View Source
var (
	//CustomChainConfig accounts for the fact that EVM-Lite doesn't really have
	//a concetp of Chain, or Blocks (being consensus-agnostic). The EVM is
	//tightly coupled with this ChainConfig object (cf interpreter.go), so this
	//is a workaround that treats all blocks the same.
	CustomChainConfig = params.ChainConfig{
		ChainID:             big.NewInt(1),
		ConstantinopleBlock: big.NewInt(0),
	}
)
View Source
var (
	MIPMapLevels = []uint64{1000000, 500000, 100000, 50000, 1000}
)

Functions

func NewContext

func NewContext(origin common.Address,
	coinbase common.Address,
	gasLimit uint64,
	gasPrice *big.Int) vm.Context

Types

type DatabaseDeleter

type DatabaseDeleter interface {
	Delete(key []byte) error
}

DatabaseDeleter wraps the Delete method of a backing data store.

type DatabasePutter

type DatabasePutter interface {
	Put(key []byte, value []byte) error
}

DatabasePutter wraps the Put method of a backing data store.

type DatabaseReader

type DatabaseReader interface {
	Get(key []byte) (value []byte, err error)
}

DatabaseReader wraps the Get method of a backing data store.

type ReceiptPromise added in v0.3.1

type ReceiptPromise struct {
	Hash ethCommon.Hash

	// response channel
	RespCh *chan common.JsonReceipt
}

ReceiptPromise is a struct for asyncronous response to fetching a receipt

func NewReceiptPromise added in v0.3.1

func NewReceiptPromise(hash ethCommon.Hash) *ReceiptPromise

NewReceiptPromise is a factory method for a ReceiptPromise

func (*ReceiptPromise) Respond added in v0.3.1

func (p *ReceiptPromise) Respond(receipt common.JsonReceipt)

Respond handles resolving a JsonReceipt

func (*ReceiptPromise) ResponseChannel added in v0.3.1

func (p *ReceiptPromise) ResponseChannel() *chan common.JsonReceipt

ResponseChannel return the response channel for the promise

type State

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

func NewState

func NewState(dbFile string, dbCache int, genesisFile string, logger *logrus.Entry) (*State, error)

func (*State) ApplyTransaction

func (s *State) ApplyTransaction(
	txBytes []byte,
	txIndex int,
	blockHash common.Hash,
	coinbase common.Address) error

ApplyTransaction decodes a transaction and applies it to the WAS. It is meant to be called by the consensus system to apply transactions sequentially.

func (*State) Call

func (s *State) Call(callMsg ethTypes.Message) ([]byte, error)

Call executes a readonly transaction on the statedb. It is called by the service handlers

func (*State) CheckAuthorised

func (s *State) CheckAuthorised(addr common.Address) (bool, error)

CheckAuthorised queries the POA smart-contract to check if the address is authorised

func (*State) CheckTx

func (s *State) CheckTx(tx *ethTypes.Transaction) error

CheckTx attempts to apply a transaction to the TxPool's statedb. It is called by the Service handlers to check if a transaction is valid before submitting it to the consensus system. This also updates the sender's Nonce in the TxPool's statedb.

func (*State) Commit

func (s *State) Commit() (common.Hash, error)

Commit persists all pending state changes (in the WAS) to the DB, and resets the WAS and TxPool

func (*State) CreateGenesisAccounts

func (s *State) CreateGenesisAccounts() error

CreateGenesisAccounts reads the genesis.json file and creates the regular pre-funded accounts, as well as the POA smart-contract account.

func (*State) CreateReceiptPromise added in v0.3.1

func (s *State) CreateReceiptPromise(hash common.Hash) *ReceiptPromise

CreateReceiptPromise crates a new receipt promise

func (*State) Empty

func (s *State) Empty(addr common.Address) bool

Empty reports whether the account is non-existant or empty

func (*State) GetAuthorisingAbi

func (s *State) GetAuthorisingAbi() string

GetAuthorisingAbi returns the abi of the smart contract which handles the list of authorized peers

func (*State) GetAuthorisingAccount

func (s *State) GetAuthorisingAccount() string

GetAuthorisingAccount returns the address of the smart contract which handles the list of authorized peers

func (*State) GetBalance

func (s *State) GetBalance(addr common.Address) *big.Int

GetBalance returns an account's balance from the main ethState

func (*State) GetCode

func (s *State) GetCode(addr common.Address) []byte

GetCode returns an account's bytecode from the main ethState

func (*State) GetGasLimit

func (s *State) GetGasLimit() uint64

GetGasLimit returns the gas limit set between commit calls

func (*State) GetGenesis

func (s *State) GetGenesis() (bcommon.Genesis, error)

GetGenesis reads and unmarshals the genesis.json file

func (*State) GetNonce

func (s *State) GetNonce(addr common.Address) uint64

GetNonce returns an account's nonce from the main ethState

func (*State) GetPoolNonce

func (s *State) GetPoolNonce(addr common.Address) uint64

GetPoolNonce returns an account's nonce from the txpool's ethState

func (*State) GetReceipt

func (s *State) GetReceipt(txHash common.Hash) (*ethTypes.Receipt, error)

GetReceipt fetches transaction receipts by transaction hash directly from the DB

func (*State) GetReceiptPromises added in v0.3.1

func (s *State) GetReceiptPromises() map[common.Hash]*ReceiptPromise

GetReceiptPromises returns the promise mapping

func (*State) GetTransaction

func (s *State) GetTransaction(hash common.Hash) (*ethTypes.Transaction, error)

GetTransaction fetches transactions by hash directly from the DB.

func (*State) InitState

func (s *State) InitState() error

InitState initializes the statedb object, the write-ahead state, the transaction-pool, and creates genesis accounts.

type TxPool

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

func NewTxPool

func NewTxPool(ethState *ethState.StateDB,
	signer ethTypes.Signer,
	chainConfig params.ChainConfig,
	vmConfig vm.Config,
	gasLimit uint64,
	logger *logrus.Entry) *TxPool

func (*TxPool) CheckTx

func (p *TxPool) CheckTx(tx *ethTypes.Transaction) error

func (*TxPool) GetNonce

func (p *TxPool) GetNonce(addr common.Address) uint64

func (*TxPool) Reset

func (p *TxPool) Reset(root common.Hash) error

type WriteAheadState

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

WriteAheadState is a wrapper around a DB and StateDB object that applies transactions to the StateDB and only commits them to the DB upon Commit. It also handles persisting transactions, logs, and receipts to the DB. NOT THREAD SAFE

func NewWriteAheadState

func NewWriteAheadState(db ethdb.Database,
	root common.Hash,
	signer ethTypes.Signer,
	chainConfig params.ChainConfig,
	vmConfig vm.Config,
	gasLimit uint64,
	logger *logrus.Entry) (*WriteAheadState, error)

func (*WriteAheadState) ApplyTransaction

func (was *WriteAheadState) ApplyTransaction(
	tx ethTypes.Transaction,
	txIndex int,
	blockHash common.Hash,
	coinbase common.Address) error

func (*WriteAheadState) Commit

func (was *WriteAheadState) Commit() (common.Hash, error)

func (*WriteAheadState) Reset

func (was *WriteAheadState) Reset(root common.Hash) error

Jump to

Keyboard shortcuts

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