Documentation ¶
Overview ¶
Package txs is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ShuffleWithNonceOrder(logger log.Log, rng *rand.Rand, numTXs int, ntxs []*NanoTX, ...) []types.TransactionID
- type CSConfig
- type Cache
- func (c *Cache) Add(ctx context.Context, db *sql.Database, tx *types.Transaction, ...) error
- func (c *Cache) ApplyLayer(ctx context.Context, db *sql.Database, lid types.LayerID, bid types.BlockID, ...) error
- func (c *Cache) BuildFromTXs(rst []*types.MeshTransaction, blockSeed []byte) error
- func (c *Cache) Get(tid types.TransactionID) *NanoTX
- func (c *Cache) GetMempool(logger log.Log) map[types.Address][]*NanoTX
- func (c *Cache) GetProjection(addr types.Address) (uint64, uint64)
- func (c *Cache) Has(tid types.TransactionID) bool
- func (c *Cache) LinkTXsWithBlock(db *sql.Database, lid types.LayerID, bid types.BlockID, ...) error
- func (c *Cache) LinkTXsWithProposal(db *sql.Database, lid types.LayerID, pid types.ProposalID, ...) error
- func (c *Cache) MoreInDB(addr types.Address) bool
- func (c *Cache) RevertToLayer(db *sql.Database, revertTo types.LayerID) error
- type ConservativeState
- func (cs *ConservativeState) AddToCache(ctx context.Context, tx *types.Transaction, received time.Time) error
- func (cs *ConservativeState) AddToDB(tx *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) RevertCache(revertTo types.LayerID) error
- func (cs *ConservativeState) SelectProposalTXs(lid types.LayerID, numEligibility int) []types.TransactionID
- func (cs *ConservativeState) UpdateCache(ctx context.Context, lid types.LayerID, bid types.BlockID, ...) error
- func (cs *ConservativeState) Validation(raw types.RawTx) system.ValidationRequest
- type ConservativeStateOpt
- type MockconStateCache
- type MockconStateCacheMockRecorder
- type MockconservativeState
- func (m *MockconservativeState) AddToCache(arg0 context.Context, arg1 *types.Transaction, arg2 time.Time) error
- func (m *MockconservativeState) AddToDB(arg0 *types.Transaction) error
- func (m *MockconservativeState) EXPECT() *MockconservativeStateMockRecorder
- func (m *MockconservativeState) GetMeshTransaction(arg0 types.TransactionID) (*types.MeshTransaction, error)
- func (m *MockconservativeState) HasTx(arg0 types.TransactionID) (bool, error)
- func (m *MockconservativeState) Validation(arg0 types.RawTx) system.ValidationRequest
- type MockconservativeStateMockRecorder
- func (mr *MockconservativeStateMockRecorder) AddToCache(arg0, arg1, arg2 interface{}) *conservativeStateAddToCacheCall
- func (mr *MockconservativeStateMockRecorder) AddToDB(arg0 interface{}) *conservativeStateAddToDBCall
- func (mr *MockconservativeStateMockRecorder) GetMeshTransaction(arg0 interface{}) *conservativeStateGetMeshTransactionCall
- func (mr *MockconservativeStateMockRecorder) HasTx(arg0 interface{}) *conservativeStateHasTxCall
- func (mr *MockconservativeStateMockRecorder) Validation(arg0 interface{}) *conservativeStateValidationCall
- type MockvmState
- func (m *MockvmState) EXPECT() *MockvmStateMockRecorder
- func (m *MockvmState) GetAllAccounts() ([]*types.Account, error)
- func (m *MockvmState) GetBalance(arg0 types.Address) (uint64, error)
- func (m *MockvmState) GetLayerApplied(arg0 types.TransactionID) (types.LayerID, error)
- func (m *MockvmState) GetLayerStateRoot(arg0 types.LayerID) (types.Hash32, error)
- func (m *MockvmState) GetNonce(arg0 types.Address) (types.Nonce, error)
- func (m *MockvmState) GetStateRoot() (types.Hash32, error)
- func (m *MockvmState) Validation(arg0 types.RawTx) system.ValidationRequest
- type MockvmStateMockRecorder
- func (mr *MockvmStateMockRecorder) GetAllAccounts() *vmStateGetAllAccountsCall
- func (mr *MockvmStateMockRecorder) GetBalance(arg0 interface{}) *vmStateGetBalanceCall
- func (mr *MockvmStateMockRecorder) GetLayerApplied(arg0 interface{}) *vmStateGetLayerAppliedCall
- func (mr *MockvmStateMockRecorder) GetLayerStateRoot(arg0 interface{}) *vmStateGetLayerStateRootCall
- func (mr *MockvmStateMockRecorder) GetNonce(arg0 interface{}) *vmStateGetNonceCall
- func (mr *MockvmStateMockRecorder) GetStateRoot() *vmStateGetStateRootCall
- func (mr *MockvmStateMockRecorder) Validation(arg0 interface{}) *vmStateValidationCall
- type NanoTX
- type TxHandler
- func (th *TxHandler) HandleBlockTransaction(_ context.Context, expHash types.Hash32, _ p2p.Peer, data []byte) error
- func (th *TxHandler) HandleGossipTransaction(ctx context.Context, peer p2p.Peer, msg []byte) error
- func (th *TxHandler) HandleProposalTransaction(ctx context.Context, expHash types.Hash32, _ p2p.Peer, msg []byte) error
- func (th *TxHandler) VerifyAndCacheTx(ctx context.Context, msg []byte) error
Constants ¶
const (
MinTXGas = uint64(1) // gas required for the most basic transaction
)
const (
RawFromDB = "raw"
)
Variables ¶
var ( RawTxCount = metrics.NewCounter( "raw_txs", namespace, "number of unparsed/raw transactions", []string{"outcome"}, ) )
Functions ¶
func ShuffleWithNonceOrder ¶
func ShuffleWithNonceOrder( logger log.Log, rng *rand.Rand, numTXs int, ntxs []*NanoTX, byAddrAndNonce map[types.Address][]*NanoTX, ) []types.TransactionID
ShuffleWithNonceOrder perform a Fisher-Yates shuffle on the transactions. note that after shuffling, the original list of transactions are no longer in nonce order within the same principal. we simply check which principal occupies the spot after the shuffle and retrieve their transactions in nonce order.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) ApplyLayer ¶
func (c *Cache) ApplyLayer( ctx context.Context, db *sql.Database, lid types.LayerID, bid types.BlockID, results []types.TransactionWithResult, ineffective []types.Transaction, ) error
ApplyLayer retires the applied transactions from the cache and updates the balances.
func (*Cache) BuildFromTXs ¶
func (c *Cache) BuildFromTXs(rst []*types.MeshTransaction, blockSeed []byte) error
BuildFromTXs builds the cache from the provided transactions.
func (*Cache) Get ¶
func (c *Cache) Get(tid types.TransactionID) *NanoTX
Get gets a transaction from the cache.
func (*Cache) GetMempool ¶
GetMempool returns all the transactions that eligible for a proposal/block.
func (*Cache) GetProjection ¶
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 (*Cache) Has ¶
func (c *Cache) Has(tid types.TransactionID) bool
Has returns true if transaction exists in the cache.
func (*Cache) LinkTXsWithBlock ¶
func (c *Cache) LinkTXsWithBlock(db *sql.Database, lid types.LayerID, bid types.BlockID, tids []types.TransactionID) error
LinkTXsWithBlock associates the transactions to a block.
func (*Cache) LinkTXsWithProposal ¶
func (c *Cache) LinkTXsWithProposal(db *sql.Database, lid types.LayerID, pid types.ProposalID, tids []types.TransactionID) error
LinkTXsWithProposal associates the transactions to a proposal.
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, received time.Time) 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) 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) RevertCache ¶
func (cs *ConservativeState) RevertCache(revertTo types.LayerID) error
RevertCache reverts the conservative cache to the given layer.
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) UpdateCache ¶
func (cs *ConservativeState) UpdateCache( ctx context.Context, lid types.LayerID, bid types.BlockID, results []types.TransactionWithResult, ineffective []types.Transaction, ) error
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 MockconStateCache ¶
type MockconStateCache struct {
// contains filtered or unexported fields
}
MockconStateCache is a mock of conStateCache interface.
func NewMockconStateCache ¶
func NewMockconStateCache(ctrl *gomock.Controller) *MockconStateCache
NewMockconStateCache creates a new mock instance.
func (*MockconStateCache) EXPECT ¶
func (m *MockconStateCache) EXPECT() *MockconStateCacheMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockconStateCache) GetMempool ¶
GetMempool mocks base method.
type MockconStateCacheMockRecorder ¶
type MockconStateCacheMockRecorder struct {
// contains filtered or unexported fields
}
MockconStateCacheMockRecorder is the mock recorder for MockconStateCache.
func (*MockconStateCacheMockRecorder) GetMempool ¶
func (mr *MockconStateCacheMockRecorder) GetMempool(arg0 interface{}) *conStateCacheGetMempoolCall
GetMempool indicates an expected call of GetMempool.
type MockconservativeState ¶
type MockconservativeState struct {
// contains filtered or unexported fields
}
MockconservativeState is a mock of conservativeState interface.
func NewMockconservativeState ¶
func NewMockconservativeState(ctrl *gomock.Controller) *MockconservativeState
NewMockconservativeState creates a new mock instance.
func (*MockconservativeState) AddToCache ¶
func (m *MockconservativeState) AddToCache(arg0 context.Context, arg1 *types.Transaction, arg2 time.Time) error
AddToCache mocks base method.
func (*MockconservativeState) AddToDB ¶
func (m *MockconservativeState) AddToDB(arg0 *types.Transaction) error
AddToDB mocks base method.
func (*MockconservativeState) EXPECT ¶
func (m *MockconservativeState) EXPECT() *MockconservativeStateMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockconservativeState) GetMeshTransaction ¶
func (m *MockconservativeState) GetMeshTransaction(arg0 types.TransactionID) (*types.MeshTransaction, error)
GetMeshTransaction mocks base method.
func (*MockconservativeState) HasTx ¶
func (m *MockconservativeState) HasTx(arg0 types.TransactionID) (bool, error)
HasTx mocks base method.
func (*MockconservativeState) Validation ¶
func (m *MockconservativeState) Validation(arg0 types.RawTx) system.ValidationRequest
Validation mocks base method.
type MockconservativeStateMockRecorder ¶
type MockconservativeStateMockRecorder struct {
// contains filtered or unexported fields
}
MockconservativeStateMockRecorder is the mock recorder for MockconservativeState.
func (*MockconservativeStateMockRecorder) AddToCache ¶
func (mr *MockconservativeStateMockRecorder) AddToCache(arg0, arg1, arg2 interface{}) *conservativeStateAddToCacheCall
AddToCache indicates an expected call of AddToCache.
func (*MockconservativeStateMockRecorder) AddToDB ¶
func (mr *MockconservativeStateMockRecorder) AddToDB(arg0 interface{}) *conservativeStateAddToDBCall
AddToDB indicates an expected call of AddToDB.
func (*MockconservativeStateMockRecorder) GetMeshTransaction ¶
func (mr *MockconservativeStateMockRecorder) GetMeshTransaction(arg0 interface{}) *conservativeStateGetMeshTransactionCall
GetMeshTransaction indicates an expected call of GetMeshTransaction.
func (*MockconservativeStateMockRecorder) HasTx ¶
func (mr *MockconservativeStateMockRecorder) HasTx(arg0 interface{}) *conservativeStateHasTxCall
HasTx indicates an expected call of HasTx.
func (*MockconservativeStateMockRecorder) Validation ¶
func (mr *MockconservativeStateMockRecorder) Validation(arg0 interface{}) *conservativeStateValidationCall
Validation indicates an expected call of Validation.
type MockvmState ¶
type MockvmState struct {
// contains filtered or unexported fields
}
MockvmState is a mock of vmState interface.
func NewMockvmState ¶
func NewMockvmState(ctrl *gomock.Controller) *MockvmState
NewMockvmState creates a new mock instance.
func (*MockvmState) EXPECT ¶
func (m *MockvmState) EXPECT() *MockvmStateMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockvmState) GetAllAccounts ¶
func (m *MockvmState) GetAllAccounts() ([]*types.Account, error)
GetAllAccounts mocks base method.
func (*MockvmState) GetBalance ¶
func (m *MockvmState) GetBalance(arg0 types.Address) (uint64, error)
GetBalance mocks base method.
func (*MockvmState) GetLayerApplied ¶
func (m *MockvmState) GetLayerApplied(arg0 types.TransactionID) (types.LayerID, error)
GetLayerApplied mocks base method.
func (*MockvmState) GetLayerStateRoot ¶
GetLayerStateRoot mocks base method.
func (*MockvmState) GetStateRoot ¶
func (m *MockvmState) GetStateRoot() (types.Hash32, error)
GetStateRoot mocks base method.
func (*MockvmState) Validation ¶
func (m *MockvmState) Validation(arg0 types.RawTx) system.ValidationRequest
Validation mocks base method.
type MockvmStateMockRecorder ¶
type MockvmStateMockRecorder struct {
// contains filtered or unexported fields
}
MockvmStateMockRecorder is the mock recorder for MockvmState.
func (*MockvmStateMockRecorder) GetAllAccounts ¶
func (mr *MockvmStateMockRecorder) GetAllAccounts() *vmStateGetAllAccountsCall
GetAllAccounts indicates an expected call of GetAllAccounts.
func (*MockvmStateMockRecorder) GetBalance ¶
func (mr *MockvmStateMockRecorder) GetBalance(arg0 interface{}) *vmStateGetBalanceCall
GetBalance indicates an expected call of GetBalance.
func (*MockvmStateMockRecorder) GetLayerApplied ¶
func (mr *MockvmStateMockRecorder) GetLayerApplied(arg0 interface{}) *vmStateGetLayerAppliedCall
GetLayerApplied indicates an expected call of GetLayerApplied.
func (*MockvmStateMockRecorder) GetLayerStateRoot ¶
func (mr *MockvmStateMockRecorder) GetLayerStateRoot(arg0 interface{}) *vmStateGetLayerStateRootCall
GetLayerStateRoot indicates an expected call of GetLayerStateRoot.
func (*MockvmStateMockRecorder) GetNonce ¶
func (mr *MockvmStateMockRecorder) GetNonce(arg0 interface{}) *vmStateGetNonceCall
GetNonce indicates an expected call of GetNonce.
func (*MockvmStateMockRecorder) GetStateRoot ¶
func (mr *MockvmStateMockRecorder) GetStateRoot() *vmStateGetStateRootCall
GetStateRoot indicates an expected call of GetStateRoot.
func (*MockvmStateMockRecorder) Validation ¶
func (mr *MockvmStateMockRecorder) Validation(arg0 interface{}) *vmStateValidationCall
Validation indicates an expected call of Validation.
type NanoTX ¶
type NanoTX struct { types.TxHeader ID types.TransactionID Received time.Time Block types.BlockID Layer types.LayerID }
NanoTX represents minimal info about a transaction for the conservative cache/mempool.
func NewNanoTX ¶
func NewNanoTX(mtx *types.MeshTransaction) *NanoTX
NewNanoTX converts a NanoTX instance from a MeshTransaction.
func (*NanoTX) Better ¶
Better returns true if this transaction takes priority than `other`. when the block seed is non-empty, this tx is being considered for a block. the block seed then is used to tie-break (deterministically) transactions for the same account/nonce.
func (*NanoTX) MaxSpending ¶
MaxSpending returns the maximal amount a transaction can spend.
func (*NanoTX) UpdateLayer ¶
UpdateLayer updates the layer of a transaction.
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 ¶
func (th *TxHandler) HandleBlockTransaction(_ context.Context, expHash types.Hash32, _ p2p.Peer, data []byte) error
HandleBlockTransaction handles transactions received as a reference to a block.
func (*TxHandler) HandleGossipTransaction ¶
HandleGossipTransaction handles data received on the transactions gossip channel.