Documentation ¶
Index ¶
- type CSConfig
- type ConservativeState
- func (cs *ConservativeState) AddToCache(ctx context.Context, tx *types.Transaction) error
- func (cs *ConservativeState) AddToDB(tx *types.Transaction) error
- func (cs *ConservativeState) ApplyLayer(ctx context.Context, block *types.Block) error
- func (cs *ConservativeState) GetExecutableTxs(ids []types.TransactionID) ([]types.Transaction, error)
- func (cs *ConservativeState) GetMeshHash(lid types.LayerID) (types.Hash32, error)
- func (cs *ConservativeState) GetMeshTransaction(tid types.TransactionID) (*types.MeshTransaction, error)
- func (cs *ConservativeState) GetMeshTransactions(ids []types.TransactionID) ([]*types.MeshTransaction, map[types.TransactionID]struct{})
- func (cs *ConservativeState) GetProjection(addr types.Address) (uint64, uint64)
- func (cs *ConservativeState) GetTransactionsByAddress(from, to types.LayerID, address types.Address) ([]*types.MeshTransaction, error)
- func (cs *ConservativeState) HasTx(tid types.TransactionID) (bool, error)
- func (cs *ConservativeState) LinkTXsWithBlock(lid types.LayerID, bid types.BlockID, tids []types.TransactionID) error
- func (cs *ConservativeState) LinkTXsWithProposal(lid types.LayerID, pid types.ProposalID, tids []types.TransactionID) error
- func (cs *ConservativeState) RevertState(revertTo types.LayerID) (types.Hash32, error)
- func (cs *ConservativeState) SelectBlockTXs(lid types.LayerID, proposals []*types.Proposal) ([]types.TransactionID, error)
- func (cs *ConservativeState) SelectProposalTXs(lid types.LayerID, numEligibility int) []types.TransactionID
- func (cs *ConservativeState) Validation(raw types.RawTx) system.ValidationRequest
- type ConservativeStateOpt
- type TxHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
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 ¶
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 ¶
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:
- 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
- put the output of step 0 in a stable order
- 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 ¶
func (cs *ConservativeState) Validation(raw types.RawTx) system.ValidationRequest
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 ¶
NewTxHandler returns a new TxHandler.
func (*TxHandler) HandleBlockTransaction ¶
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.