txs

package
v0.2.19-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSConfig

type CSConfig struct {
	BlockGasLimit      uint64
	NumTXsPerProposal  int
	OptFilterThreshold int
}

CSConfig is the config for the conservative state/cache.

type ConservativeState

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

ConservativeState provides the conservative version of the VM state by taking into accounts of nonce and balances for pending transactions in un-applied blocks and mempool.

func NewConservativeState

func NewConservativeState(state vmState, db *sql.Database, opts ...ConservativeStateOpt) *ConservativeState

NewConservativeState returns a ConservativeState.

func (*ConservativeState) AddToCache

func (cs *ConservativeState) AddToCache(ctx context.Context, tx *types.Transaction) error

AddToCache adds the provided transaction to the conservative cache.

func (*ConservativeState) AddToDB

func (cs *ConservativeState) AddToDB(tx *types.Transaction) error

AddToDB adds a transaction to the database.

func (*ConservativeState) ApplyLayer

func (cs *ConservativeState) ApplyLayer(ctx context.Context, block *types.Block) error

ApplyLayer applies the transactions specified by the ids to the state.

func (*ConservativeState) GetExecutableTxs

func (cs *ConservativeState) GetExecutableTxs(ids []types.TransactionID) ([]types.Transaction, error)

GetExecutableTxs retrieves a list of txs filtering transaction that were previously executed.

func (*ConservativeState) GetMeshHash

func (cs *ConservativeState) GetMeshHash(lid types.LayerID) (types.Hash32, error)

GetMeshHash gets the aggregated layer hash at the specified layer.

func (*ConservativeState) GetMeshTransaction

func (cs *ConservativeState) GetMeshTransaction(tid types.TransactionID) (*types.MeshTransaction, error)

GetMeshTransaction retrieves a tx by its id.

func (*ConservativeState) GetMeshTransactions

func (cs *ConservativeState) GetMeshTransactions(ids []types.TransactionID) ([]*types.MeshTransaction, map[types.TransactionID]struct{})

GetMeshTransactions retrieves a list of txs by their id's.

func (*ConservativeState) GetProjection

func (cs *ConservativeState) GetProjection(addr types.Address) (uint64, uint64)

GetProjection returns the projected nonce and balance for an account, including pending transactions that are paced in proposals/blocks but not yet applied to the state.

func (*ConservativeState) GetTransactionsByAddress

func (cs *ConservativeState) GetTransactionsByAddress(from, to types.LayerID, address types.Address) ([]*types.MeshTransaction, error)

GetTransactionsByAddress retrieves txs for a single address in between layers [from, to]. Guarantees that transaction will appear exactly once, even if origin and recipient is the same, and in insertion order.

func (*ConservativeState) HasTx

func (cs *ConservativeState) HasTx(tid types.TransactionID) (bool, error)

HasTx returns true if transaction exists in the cache.

func (*ConservativeState) LinkTXsWithBlock

func (cs *ConservativeState) LinkTXsWithBlock(lid types.LayerID, bid types.BlockID, tids []types.TransactionID) error

LinkTXsWithBlock associates the transactions to a block.

func (*ConservativeState) LinkTXsWithProposal

func (cs *ConservativeState) LinkTXsWithProposal(lid types.LayerID, pid types.ProposalID, tids []types.TransactionID) error

LinkTXsWithProposal associates the transactions to a proposal.

func (*ConservativeState) RevertState

func (cs *ConservativeState) RevertState(revertTo types.LayerID) error

RevertState reverts the VM state and database to the given layer.

func (*ConservativeState) SelectBlockTXs

func (cs *ConservativeState) SelectBlockTXs(lid types.LayerID, proposals []*types.Proposal) ([]types.TransactionID, error)

SelectBlockTXs combined the transactions in the proposals and put them in a stable order. the steps are:

  1. do optimistic filtering if the proposals agree on the mesh hash and state root this mean the following transactions will be filtered out. transactions that - fail nonce check - fail balance check - are already applied in previous layer if the proposals don't agree on the mesh hash and state root, we keep all transactions
  2. put the output of step 0 in a stable order
  3. pick the transactions in step 1 until the gas limit runs out.

func (*ConservativeState) SelectProposalTXs

func (cs *ConservativeState) SelectProposalTXs(lid types.LayerID, numEligibility int) []types.TransactionID

SelectProposalTXs picks a specific number of random txs for miner to pack in a proposal.

func (*ConservativeState) Validation

Validation initializes validation request.

type ConservativeStateOpt

type ConservativeStateOpt func(cs *ConservativeState)

ConservativeStateOpt for configuring conservative state.

func WithCSConfig

func WithCSConfig(cfg CSConfig) ConservativeStateOpt

WithCSConfig defines the config used for the conservative state.

func WithLogger

func WithLogger(logger log.Log) ConservativeStateOpt

WithLogger defines logger for conservative state.

type TxHandler

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

TxHandler handles the transactions received via gossip or sync.

func NewTxHandler

func NewTxHandler(s conservativeState, l log.Log) *TxHandler

NewTxHandler returns a new TxHandler.

func (*TxHandler) HandleBlockTransaction

func (th *TxHandler) HandleBlockTransaction(ctx context.Context, data []byte) error

HandleBlockTransaction handles transactions received as a reference to a block.

func (*TxHandler) HandleGossipTransaction

func (th *TxHandler) HandleGossipTransaction(ctx context.Context, _ p2p.Peer, msg []byte) pubsub.ValidationResult

HandleGossipTransaction handles data received on the transactions gossip channel.

func (*TxHandler) HandleProposalTransaction

func (th *TxHandler) HandleProposalTransaction(ctx context.Context, msg []byte) error

HandleProposalTransaction handles data received on the transactions synced as a part of proposal.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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