Documentation ¶
Overview ¶
Package txpool is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ChainConfig(tx kv.Getter) (*chain.Config, error)
- func EncodeGetPooledTransactions66(hashes []byte, requestID uint64, encodeBuf []byte) ([]byte, error)
- func EncodeHashes(hashes []byte, encodeBuf []byte) []byte
- func EncodePooledTransactions66(txnsRlp [][]byte, requestID uint64, encodeBuf []byte) []byte
- func EncodeSender(nonce uint64, balance uint256.Int, buffer []byte)
- func EncodeSenderLengthForStorage(nonce uint64, balance uint256.Int) uint
- func EncodeTransactions(txnsRlp [][]byte, encodeBuf []byte) []byte
- func LastSeenBlock(tx kv.Getter) (uint64, error)
- func ParseGetPooledTransactions66(payload []byte, pos int, hashbuf []byte) (requestID uint64, hashes []byte, newPos int, err error)
- func ParseHash(payload []byte, pos int, hashbuf []byte) ([]byte, int, error)
- func ParseHashesCount(payload []byte, pos int) (count int, dataPos int, err error)
- func ParsePooledTransactions66(payload []byte, pos int, ctx *TxnParseContext, txnSlots *TxnSlots, ...) (requestID uint64, newPos int, err error)
- func ParseTransactions(payload []byte, pos int, ctx *TxnParseContext, txnSlots *TxnSlots, ...) (newPos int, err error)
- func PeekTransactionType(serialized []byte) (byte, error)
- func PutChainConfig(tx kv.Putter, cc *chain.Config, buf []byte) error
- func PutLastSeenBlock(tx kv.Putter, n uint64, buf []byte) error
- func SaveChainConfigIfNeed(ctx context.Context, coreDB kv.RoDB, poolDB kv.RwDB, force bool, ...) (cc *chain.Config, blockNum uint64, err error)
- func SortByNonceLess(a, b *metaTxn) bool
- func StartGrpc(txPoolServer txpool_proto.TxpoolServer, miningServer txpool_proto.MiningServer, ...) (*grpc.Server, error)
- type Addresses
- type Announcements
- func (a *Announcements) Append(t byte, size uint32, hash []byte)
- func (a *Announcements) AppendOther(other Announcements)
- func (a Announcements) At(i int) (byte, uint32, []byte)
- func (a Announcements) Copy() Announcements
- func (a Announcements) DedupCopy() Announcements
- func (a Announcements) DedupHashes() Hashes
- func (a Announcements) Hashes() Hashes
- func (a Announcements) Len() int
- func (a Announcements) Less(i, j int) bool
- func (a *Announcements) Reset()
- func (a Announcements) Swap(i, j int)
- type BestQueue
- type BySenderAndNonce
- type FeeCalculator
- type Fetch
- type GrpcDisabled
- func (*GrpcDisabled) Add(ctx context.Context, request *txpool_proto.AddRequest) (*txpool_proto.AddReply, error)
- func (*GrpcDisabled) All(ctx context.Context, request *txpool_proto.AllRequest) (*txpool_proto.AllReply, error)
- func (*GrpcDisabled) FindUnknown(ctx context.Context, hashes *txpool_proto.TxHashes) (*txpool_proto.TxHashes, error)
- func (*GrpcDisabled) Nonce(ctx context.Context, request *txpool_proto.NonceRequest) (*txpool_proto.NonceReply, error)
- func (*GrpcDisabled) OnAdd(request *txpool_proto.OnAddRequest, server txpool_proto.Txpool_OnAddServer) error
- func (*GrpcDisabled) Pending(ctx context.Context, empty *emptypb.Empty) (*txpool_proto.PendingReply, error)
- func (*GrpcDisabled) Status(ctx context.Context, request *txpool_proto.StatusRequest) (*txpool_proto.StatusReply, error)
- func (*GrpcDisabled) Transactions(ctx context.Context, request *txpool_proto.TransactionsRequest) (*txpool_proto.TransactionsReply, error)
- func (*GrpcDisabled) Version(ctx context.Context, empty *emptypb.Empty) (*typesproto.VersionReply, error)
- type GrpcServer
- func (s *GrpcServer) Add(ctx context.Context, in *txpool_proto.AddRequest) (*txpool_proto.AddReply, error)
- func (s *GrpcServer) All(ctx context.Context, _ *txpool_proto.AllRequest) (*txpool_proto.AllReply, error)
- func (s *GrpcServer) FindUnknown(ctx context.Context, in *txpool_proto.TxHashes) (*txpool_proto.TxHashes, error)
- func (s *GrpcServer) Nonce(ctx context.Context, in *txpool_proto.NonceRequest) (*txpool_proto.NonceReply, error)
- func (s *GrpcServer) OnAdd(req *txpool_proto.OnAddRequest, stream txpool_proto.Txpool_OnAddServer) error
- func (s *GrpcServer) Pending(ctx context.Context, _ *emptypb.Empty) (*txpool_proto.PendingReply, error)
- func (s *GrpcServer) Status(_ context.Context, _ *txpool_proto.StatusRequest) (*txpool_proto.StatusReply, error)
- func (s *GrpcServer) Transactions(ctx context.Context, in *txpool_proto.TransactionsRequest) (*txpool_proto.TransactionsReply, error)
- func (s *GrpcServer) Version(context.Context, *emptypb.Empty) (*typesproto.VersionReply, error)
- type Hashes
- type MockPool
- func (m *MockPool) AddLocalTxns(ctx context.Context, newTxns TxnSlots) ([]txpoolcfg.DiscardReason, error)
- func (m *MockPool) AddNewGoodPeer(peerID PeerID)
- func (m *MockPool) AddRemoteTxns(ctx context.Context, newTxns TxnSlots)
- func (m *MockPool) EXPECT() *MockPoolMockRecorder
- func (m *MockPool) FilterKnownIdHashes(tx kv.Tx, hashes Hashes) (Hashes, error)
- func (m *MockPool) GetRlp(tx kv.Tx, hash []byte) ([]byte, error)
- func (m *MockPool) IdHashKnown(tx kv.Tx, hash []byte) (bool, error)
- func (m *MockPool) OnNewBlock(ctx context.Context, stateChanges *remoteproto.StateChangeBatch, ...) error
- func (m *MockPool) Started() bool
- func (m *MockPool) ValidateSerializedTxn(serializedTxn []byte) error
- type MockPoolAddLocalTxnsCall
- func (c *MockPoolAddLocalTxnsCall) Do(f func(context.Context, TxnSlots) ([]txpoolcfg.DiscardReason, error)) *MockPoolAddLocalTxnsCall
- func (c *MockPoolAddLocalTxnsCall) DoAndReturn(f func(context.Context, TxnSlots) ([]txpoolcfg.DiscardReason, error)) *MockPoolAddLocalTxnsCall
- func (c *MockPoolAddLocalTxnsCall) Return(arg0 []txpoolcfg.DiscardReason, arg1 error) *MockPoolAddLocalTxnsCall
- type MockPoolAddNewGoodPeerCall
- type MockPoolAddRemoteTxnsCall
- type MockPoolFilterKnownIdHashesCall
- func (c *MockPoolFilterKnownIdHashesCall) Do(f func(kv.Tx, Hashes) (Hashes, error)) *MockPoolFilterKnownIdHashesCall
- func (c *MockPoolFilterKnownIdHashesCall) DoAndReturn(f func(kv.Tx, Hashes) (Hashes, error)) *MockPoolFilterKnownIdHashesCall
- func (c *MockPoolFilterKnownIdHashesCall) Return(unknownHashes Hashes, err error) *MockPoolFilterKnownIdHashesCall
- type MockPoolGetRlpCall
- type MockPoolIdHashKnownCall
- type MockPoolMockRecorder
- func (mr *MockPoolMockRecorder) AddLocalTxns(ctx, newTxns any) *MockPoolAddLocalTxnsCall
- func (mr *MockPoolMockRecorder) AddNewGoodPeer(peerID any) *MockPoolAddNewGoodPeerCall
- func (mr *MockPoolMockRecorder) AddRemoteTxns(ctx, newTxns any) *MockPoolAddRemoteTxnsCall
- func (mr *MockPoolMockRecorder) FilterKnownIdHashes(tx, hashes any) *MockPoolFilterKnownIdHashesCall
- func (mr *MockPoolMockRecorder) GetRlp(tx, hash any) *MockPoolGetRlpCall
- func (mr *MockPoolMockRecorder) IdHashKnown(tx, hash any) *MockPoolIdHashKnownCall
- func (mr *MockPoolMockRecorder) OnNewBlock(ctx, stateChanges, unwindTxns, unwindBlobTxns, minedTxns any) *MockPoolOnNewBlockCall
- func (mr *MockPoolMockRecorder) Started() *MockPoolStartedCall
- func (mr *MockPoolMockRecorder) ValidateSerializedTxn(serializedTxn any) *MockPoolValidateSerializedTxnCall
- type MockPoolOnNewBlockCall
- type MockPoolStartedCall
- type MockPoolValidateSerializedTxnCall
- func (c *MockPoolValidateSerializedTxnCall) Do(f func([]byte) error) *MockPoolValidateSerializedTxnCall
- func (c *MockPoolValidateSerializedTxnCall) DoAndReturn(f func([]byte) error) *MockPoolValidateSerializedTxnCall
- func (c *MockPoolValidateSerializedTxnCall) Return(arg0 error) *MockPoolValidateSerializedTxnCall
- type NewPooledTransactionHashesPacket
- type NewSlotsStreams
- type Option
- type PeerID
- type PendingPool
- func (p *PendingPool) Add(i *metaTxn, logger log.Logger)
- func (p *PendingPool) Best() *metaTxn
- func (p *PendingPool) DebugPrint(prefix string)
- func (p *PendingPool) EnforceBestInvariants()
- func (p *PendingPool) EnforceWorstInvariants()
- func (p *PendingPool) Len() int
- func (p *PendingPool) PopWorst() *metaTxn
- func (p *PendingPool) Remove(i *metaTxn, reason string, logger log.Logger)
- func (p *PendingPool) Updated(mt *metaTxn)
- func (p *PendingPool) Worst() *metaTxn
- type Pool
- type Send
- func (f *Send) AnnouncePooledTxns(types []byte, sizes []uint32, hashes Hashes, maxPeers uint64) (hashSentTo []int)
- func (f *Send) BroadcastPooledTxns(rlps [][]byte, maxPeers uint64) (txnSentTo []int)
- func (f *Send) PropagatePooledTxnsToPeersList(peers []PeerID, types []byte, sizes []uint32, hashes []byte)
- type Signature
- type StateChangesClient
- type SubPool
- func (p *SubPool) Add(i *metaTxn, reason string, logger log.Logger)
- func (p *SubPool) Best() *metaTxn
- func (p *SubPool) DebugPrint(prefix string)
- func (p *SubPool) EnforceInvariants()
- func (p *SubPool) Len() int
- func (p *SubPool) PopBest() *metaTxn
- func (p *SubPool) PopWorst() *metaTxn
- func (p *SubPool) Remove(i *metaTxn, reason string, logger log.Logger)
- func (p *SubPool) Updated(i *metaTxn)
- func (p *SubPool) Worst() *metaTxn
- type SubPoolMarker
- type SubPoolType
- type TxPool
- func (p *TxPool) AddLocalTxns(ctx context.Context, newTxns TxnSlots) ([]txpoolcfg.DiscardReason, error)
- func (p *TxPool) AddNewGoodPeer(peerID PeerID)
- func (p *TxPool) AddRemoteTxns(_ context.Context, newTxns TxnSlots)
- func (p *TxPool) AppendAllAnnouncements(types []byte, sizes []uint32, hashes []byte) ([]byte, []uint32, []byte)
- func (p *TxPool) AppendLocalAnnouncements(types []byte, sizes []uint32, hashes []byte) ([]byte, []uint32, []byte)
- func (p *TxPool) AppendRemoteAnnouncements(types []byte, sizes []uint32, hashes []byte) ([]byte, []uint32, []byte)
- func (p *TxPool) CountContent() (int, int, int)
- func (p *TxPool) FilterKnownIdHashes(tx kv.Tx, hashes Hashes) (unknownHashes Hashes, err error)
- func (p *TxPool) GetMaxBlobsPerBlock() uint64
- func (p *TxPool) GetRlp(tx kv.Tx, hash []byte) ([]byte, error)
- func (p *TxPool) IdHashKnown(tx kv.Tx, hash []byte) (bool, error)
- func (p *TxPool) IsLocal(idHash []byte) bool
- func (p *TxPool) NonceFromAddress(addr [20]byte) (nonce uint64, inPool bool)
- func (p *TxPool) OnNewBlock(ctx context.Context, stateChanges *remote.StateChangeBatch, ...) error
- func (p *TxPool) PeekBest(ctx context.Context, n int, txns *TxnsRlp, ...) (bool, error)
- func (p *TxPool) ProvideTxns(ctx context.Context, opts ...txnprovider.ProvideOption) ([]types.Transaction, error)
- func (p *TxPool) Run(ctx context.Context) error
- func (p *TxPool) Started() bool
- func (p *TxPool) ValidateSerializedTxn(serializedTxn []byte) error
- func (p *TxPool) YieldBest(ctx context.Context, n int, txns *TxnsRlp, ...) (bool, int, error)
- type TxnParseConfig
- type TxnParseContext
- func (ctx *TxnParseContext) ChainIDRequired() *TxnParseContext
- func (ctx *TxnParseContext) ParseTransaction(payload []byte, pos int, slot *TxnSlot, sender []byte, ...) (p int, err error)
- func (ctx *TxnParseContext) ValidateRLP(f func(txnRlp []byte) error)
- func (ctx *TxnParseContext) WithAllowPreEip2s(v bool)
- func (ctx *TxnParseContext) WithSender(v bool)
- type TxnSlot
- type TxnSlots
- type TxnsRlp
- type WorstQueue
Constants ¶
const ( LegacyTxnType byte = 0 AccessListTxnType byte = 1 // EIP-2930 DynamicFeeTxnType byte = 2 // EIP-1559 BlobTxnType byte = 3 // EIP-4844 SetCodeTxnType byte = 4 // EIP-7702 )
const DefaultBlockGasLimit = uint64(30000000)
Variables ¶
var ErrAlreadyKnown = errors.New("already known")
var ErrParseTxn = fmt.Errorf("%w transaction", rlp.ErrParse)
var ErrPoolDisabled = errors.New("TxPool Disabled")
var ErrRejected = errors.New("rejected")
var ErrRlpTooBig = errors.New("txn rlp too big")
var PoolChainConfigKey = []byte("chain_config")
var PoolLastSeenBlockKey = []byte("last_seen_block")
var PoolPendingBaseFeeKey = []byte("pending_base_fee")
var PoolPendingBlobFeeKey = []byte("pending_blob_fee")
var PoolStateVersion = []byte("state_version")
var TxPoolAPIVersion = &typesproto.VersionReply{Major: 1, Minor: 0, Patch: 0}
TxPoolAPIVersion
Functions ¶
func EncodeGetPooledTransactions66 ¶
func EncodeGetPooledTransactions66(hashes []byte, requestID uint64, encodeBuf []byte) ([]byte, error)
EncodeGetPooledTransactions66 produces encoding of GetPooledTransactions66 packet
func EncodeHashes ¶
EncodeHashes produces RLP encoding of given number of hashes, as RLP list It appends encoding to the given given slice (encodeBuf), reusing the space there is enough capacity. The first returned value is the slice where encodinfg
func EncodePooledTransactions66 ¶
TODO(eip-4844) wrappedWithBlobs = true?
func EncodeSender ¶
Encode the details of txn sender into the given "buffer" byte-slice that should be big enough
func EncodeTransactions ¶
TODO(eip-4844) wrappedWithBlobs = false?
func ParseHash ¶
ParseHash extracts the next hash from the RLP encoding (payload) from a given position. It appends the hash to the given slice, reusing the space if there is enough capacity The first returned value is the slice where hash is appended to. The second returned value is the new position in the RLP payload after the extraction of the hash.
func ParseHashesCount ¶
ParseHashesCount looks at the RLP length Prefix for list of 32-byte hashes and returns number of hashes in the list to expect
func ParseTransactions ¶
func PeekTransactionType ¶
func SaveChainConfigIfNeed ¶
func SortByNonceLess ¶
func SortByNonceLess(a, b *metaTxn) bool
func StartGrpc ¶
func StartGrpc(txPoolServer txpool_proto.TxpoolServer, miningServer txpool_proto.MiningServer, addr string, creds *credentials.TransportCredentials, logger log.Logger) (*grpc.Server, error)
Types ¶
type Addresses ¶
type Addresses []byte // flatten list of 20-byte addresses
type Announcements ¶
type Announcements struct {
// contains filtered or unexported fields
}
func (*Announcements) AppendOther ¶
func (a *Announcements) AppendOther(other Announcements)
func (Announcements) Copy ¶
func (a Announcements) Copy() Announcements
func (Announcements) DedupCopy ¶
func (a Announcements) DedupCopy() Announcements
DedupCopy sorts hashes, and creates deduplicated copy
func (Announcements) DedupHashes ¶
func (a Announcements) DedupHashes() Hashes
func (Announcements) Hashes ¶
func (a Announcements) Hashes() Hashes
func (Announcements) Len ¶
func (a Announcements) Len() int
func (Announcements) Less ¶
func (a Announcements) Less(i, j int) bool
func (*Announcements) Reset ¶
func (a *Announcements) Reset()
func (Announcements) Swap ¶
func (a Announcements) Swap(i, j int)
type BySenderAndNonce ¶
type BySenderAndNonce struct {
// contains filtered or unexported fields
}
BySenderAndNonce - designed to perform most expensive operation in TxPool: "recalculate all ephemeral fields of all transactions" by algo
- for all senders - iterate over all transactions in nonce growing order
Performances decisions:
- All senders stored inside 1 large BTree - because iterate over 1 BTree is faster than over map[senderId]BTree
- sortByNonce used as non-pointer wrapper - because iterate over BTree of pointers is 2x slower
type FeeCalculator ¶
type Fetch ¶
type Fetch struct {
// contains filtered or unexported fields
}
Fetch connects to sentry and implements eth/66 protocol regarding the transaction messages. It tries to "prime" the sentry with StatusData message containing given genesis hash and list of forks, but with zero max block and total difficulty Sentry should have a logic not to overwrite statusData with messages from txn pool
func NewFetch ¶
func NewFetch( ctx context.Context, sentryClients []sentry.SentryClient, pool Pool, stateChangesClient StateChangesClient, db kv.RwDB, chainID uint256.Int, logger log.Logger, opts ...Option, ) *Fetch
NewFetch creates a new fetch object that will work with given sentry clients. Since the SentryClient here is an interface, it is suitable for mocking in tests (mock will need to implement all the functions of the SentryClient interface).
func (*Fetch) ConnectCore ¶
func (f *Fetch) ConnectCore()
func (*Fetch) ConnectSentries ¶
func (f *Fetch) ConnectSentries()
ConnectSentries initialises connection to the sentry
type GrpcDisabled ¶
type GrpcDisabled struct {
txpool_proto.UnimplementedTxpoolServer
}
func (*GrpcDisabled) Add ¶
func (*GrpcDisabled) Add(ctx context.Context, request *txpool_proto.AddRequest) (*txpool_proto.AddReply, error)
func (*GrpcDisabled) All ¶
func (*GrpcDisabled) All(ctx context.Context, request *txpool_proto.AllRequest) (*txpool_proto.AllReply, error)
func (*GrpcDisabled) FindUnknown ¶
func (*GrpcDisabled) FindUnknown(ctx context.Context, hashes *txpool_proto.TxHashes) (*txpool_proto.TxHashes, error)
func (*GrpcDisabled) Nonce ¶
func (*GrpcDisabled) Nonce(ctx context.Context, request *txpool_proto.NonceRequest) (*txpool_proto.NonceReply, error)
func (*GrpcDisabled) OnAdd ¶
func (*GrpcDisabled) OnAdd(request *txpool_proto.OnAddRequest, server txpool_proto.Txpool_OnAddServer) error
func (*GrpcDisabled) Pending ¶
func (*GrpcDisabled) Pending(ctx context.Context, empty *emptypb.Empty) (*txpool_proto.PendingReply, error)
func (*GrpcDisabled) Status ¶
func (*GrpcDisabled) Status(ctx context.Context, request *txpool_proto.StatusRequest) (*txpool_proto.StatusReply, error)
func (*GrpcDisabled) Transactions ¶
func (*GrpcDisabled) Transactions(ctx context.Context, request *txpool_proto.TransactionsRequest) (*txpool_proto.TransactionsReply, error)
func (*GrpcDisabled) Version ¶
func (*GrpcDisabled) Version(ctx context.Context, empty *emptypb.Empty) (*typesproto.VersionReply, error)
type GrpcServer ¶
type GrpcServer struct { txpool_proto.UnimplementedTxpoolServer // contains filtered or unexported fields }
func NewGrpcServer ¶
func NewGrpcServer(ctx context.Context, txPool txPool, db kv.RoDB, newSlotsStreams *NewSlotsStreams, chainID uint256.Int, logger log.Logger) *GrpcServer
func (*GrpcServer) Add ¶
func (s *GrpcServer) Add(ctx context.Context, in *txpool_proto.AddRequest) (*txpool_proto.AddReply, error)
func (*GrpcServer) All ¶
func (s *GrpcServer) All(ctx context.Context, _ *txpool_proto.AllRequest) (*txpool_proto.AllReply, error)
func (*GrpcServer) FindUnknown ¶
func (s *GrpcServer) FindUnknown(ctx context.Context, in *txpool_proto.TxHashes) (*txpool_proto.TxHashes, error)
func (*GrpcServer) Nonce ¶
func (s *GrpcServer) Nonce(ctx context.Context, in *txpool_proto.NonceRequest) (*txpool_proto.NonceReply, error)
returns nonce for address
func (*GrpcServer) OnAdd ¶
func (s *GrpcServer) OnAdd(req *txpool_proto.OnAddRequest, stream txpool_proto.Txpool_OnAddServer) error
func (*GrpcServer) Pending ¶
func (s *GrpcServer) Pending(ctx context.Context, _ *emptypb.Empty) (*txpool_proto.PendingReply, error)
func (*GrpcServer) Status ¶
func (s *GrpcServer) Status(_ context.Context, _ *txpool_proto.StatusRequest) (*txpool_proto.StatusReply, error)
func (*GrpcServer) Transactions ¶
func (s *GrpcServer) Transactions(ctx context.Context, in *txpool_proto.TransactionsRequest) (*txpool_proto.TransactionsReply, error)
func (*GrpcServer) Version ¶
func (s *GrpcServer) Version(context.Context, *emptypb.Empty) (*typesproto.VersionReply, error)
type Hashes ¶
type Hashes []byte // flatten list of 32-byte hashes
type MockPool ¶
type MockPool struct {
// contains filtered or unexported fields
}
MockPool is a mock of Pool interface.
func NewMockPool ¶
func NewMockPool(ctrl *gomock.Controller) *MockPool
NewMockPool creates a new mock instance.
func (*MockPool) AddLocalTxns ¶
func (m *MockPool) AddLocalTxns(ctx context.Context, newTxns TxnSlots) ([]txpoolcfg.DiscardReason, error)
AddLocalTxns mocks base method.
func (*MockPool) AddNewGoodPeer ¶
AddNewGoodPeer mocks base method.
func (*MockPool) AddRemoteTxns ¶
AddRemoteTxns mocks base method.
func (*MockPool) EXPECT ¶
func (m *MockPool) EXPECT() *MockPoolMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPool) FilterKnownIdHashes ¶
FilterKnownIdHashes mocks base method.
func (*MockPool) IdHashKnown ¶
IdHashKnown mocks base method.
func (*MockPool) OnNewBlock ¶
func (m *MockPool) OnNewBlock(ctx context.Context, stateChanges *remoteproto.StateChangeBatch, unwindTxns, unwindBlobTxns, minedTxns TxnSlots) error
OnNewBlock mocks base method.
func (*MockPool) ValidateSerializedTxn ¶
ValidateSerializedTxn mocks base method.
type MockPoolAddLocalTxnsCall ¶
MockPoolAddLocalTxnsCall wrap *gomock.Call
func (*MockPoolAddLocalTxnsCall) Do ¶
func (c *MockPoolAddLocalTxnsCall) Do(f func(context.Context, TxnSlots) ([]txpoolcfg.DiscardReason, error)) *MockPoolAddLocalTxnsCall
Do rewrite *gomock.Call.Do
func (*MockPoolAddLocalTxnsCall) DoAndReturn ¶
func (c *MockPoolAddLocalTxnsCall) DoAndReturn(f func(context.Context, TxnSlots) ([]txpoolcfg.DiscardReason, error)) *MockPoolAddLocalTxnsCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolAddLocalTxnsCall) Return ¶
func (c *MockPoolAddLocalTxnsCall) Return(arg0 []txpoolcfg.DiscardReason, arg1 error) *MockPoolAddLocalTxnsCall
Return rewrite *gomock.Call.Return
type MockPoolAddNewGoodPeerCall ¶
MockPoolAddNewGoodPeerCall wrap *gomock.Call
func (*MockPoolAddNewGoodPeerCall) Do ¶
func (c *MockPoolAddNewGoodPeerCall) Do(f func(PeerID)) *MockPoolAddNewGoodPeerCall
Do rewrite *gomock.Call.Do
func (*MockPoolAddNewGoodPeerCall) DoAndReturn ¶
func (c *MockPoolAddNewGoodPeerCall) DoAndReturn(f func(PeerID)) *MockPoolAddNewGoodPeerCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolAddNewGoodPeerCall) Return ¶
func (c *MockPoolAddNewGoodPeerCall) Return() *MockPoolAddNewGoodPeerCall
Return rewrite *gomock.Call.Return
type MockPoolAddRemoteTxnsCall ¶
MockPoolAddRemoteTxnsCall wrap *gomock.Call
func (*MockPoolAddRemoteTxnsCall) Do ¶
func (c *MockPoolAddRemoteTxnsCall) Do(f func(context.Context, TxnSlots)) *MockPoolAddRemoteTxnsCall
Do rewrite *gomock.Call.Do
func (*MockPoolAddRemoteTxnsCall) DoAndReturn ¶
func (c *MockPoolAddRemoteTxnsCall) DoAndReturn(f func(context.Context, TxnSlots)) *MockPoolAddRemoteTxnsCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolAddRemoteTxnsCall) Return ¶
func (c *MockPoolAddRemoteTxnsCall) Return() *MockPoolAddRemoteTxnsCall
Return rewrite *gomock.Call.Return
type MockPoolFilterKnownIdHashesCall ¶
MockPoolFilterKnownIdHashesCall wrap *gomock.Call
func (*MockPoolFilterKnownIdHashesCall) Do ¶
func (c *MockPoolFilterKnownIdHashesCall) Do(f func(kv.Tx, Hashes) (Hashes, error)) *MockPoolFilterKnownIdHashesCall
Do rewrite *gomock.Call.Do
func (*MockPoolFilterKnownIdHashesCall) DoAndReturn ¶
func (c *MockPoolFilterKnownIdHashesCall) DoAndReturn(f func(kv.Tx, Hashes) (Hashes, error)) *MockPoolFilterKnownIdHashesCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolFilterKnownIdHashesCall) Return ¶
func (c *MockPoolFilterKnownIdHashesCall) Return(unknownHashes Hashes, err error) *MockPoolFilterKnownIdHashesCall
Return rewrite *gomock.Call.Return
type MockPoolGetRlpCall ¶
MockPoolGetRlpCall wrap *gomock.Call
func (*MockPoolGetRlpCall) Do ¶
func (c *MockPoolGetRlpCall) Do(f func(kv.Tx, []byte) ([]byte, error)) *MockPoolGetRlpCall
Do rewrite *gomock.Call.Do
func (*MockPoolGetRlpCall) DoAndReturn ¶
func (c *MockPoolGetRlpCall) DoAndReturn(f func(kv.Tx, []byte) ([]byte, error)) *MockPoolGetRlpCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolGetRlpCall) Return ¶
func (c *MockPoolGetRlpCall) Return(arg0 []byte, arg1 error) *MockPoolGetRlpCall
Return rewrite *gomock.Call.Return
type MockPoolIdHashKnownCall ¶
MockPoolIdHashKnownCall wrap *gomock.Call
func (*MockPoolIdHashKnownCall) Do ¶
func (c *MockPoolIdHashKnownCall) Do(f func(kv.Tx, []byte) (bool, error)) *MockPoolIdHashKnownCall
Do rewrite *gomock.Call.Do
func (*MockPoolIdHashKnownCall) DoAndReturn ¶
func (c *MockPoolIdHashKnownCall) DoAndReturn(f func(kv.Tx, []byte) (bool, error)) *MockPoolIdHashKnownCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolIdHashKnownCall) Return ¶
func (c *MockPoolIdHashKnownCall) Return(arg0 bool, arg1 error) *MockPoolIdHashKnownCall
Return rewrite *gomock.Call.Return
type MockPoolMockRecorder ¶
type MockPoolMockRecorder struct {
// contains filtered or unexported fields
}
MockPoolMockRecorder is the mock recorder for MockPool.
func (*MockPoolMockRecorder) AddLocalTxns ¶
func (mr *MockPoolMockRecorder) AddLocalTxns(ctx, newTxns any) *MockPoolAddLocalTxnsCall
AddLocalTxns indicates an expected call of AddLocalTxns.
func (*MockPoolMockRecorder) AddNewGoodPeer ¶
func (mr *MockPoolMockRecorder) AddNewGoodPeer(peerID any) *MockPoolAddNewGoodPeerCall
AddNewGoodPeer indicates an expected call of AddNewGoodPeer.
func (*MockPoolMockRecorder) AddRemoteTxns ¶
func (mr *MockPoolMockRecorder) AddRemoteTxns(ctx, newTxns any) *MockPoolAddRemoteTxnsCall
AddRemoteTxns indicates an expected call of AddRemoteTxns.
func (*MockPoolMockRecorder) FilterKnownIdHashes ¶
func (mr *MockPoolMockRecorder) FilterKnownIdHashes(tx, hashes any) *MockPoolFilterKnownIdHashesCall
FilterKnownIdHashes indicates an expected call of FilterKnownIdHashes.
func (*MockPoolMockRecorder) GetRlp ¶
func (mr *MockPoolMockRecorder) GetRlp(tx, hash any) *MockPoolGetRlpCall
GetRlp indicates an expected call of GetRlp.
func (*MockPoolMockRecorder) IdHashKnown ¶
func (mr *MockPoolMockRecorder) IdHashKnown(tx, hash any) *MockPoolIdHashKnownCall
IdHashKnown indicates an expected call of IdHashKnown.
func (*MockPoolMockRecorder) OnNewBlock ¶
func (mr *MockPoolMockRecorder) OnNewBlock(ctx, stateChanges, unwindTxns, unwindBlobTxns, minedTxns any) *MockPoolOnNewBlockCall
OnNewBlock indicates an expected call of OnNewBlock.
func (*MockPoolMockRecorder) Started ¶
func (mr *MockPoolMockRecorder) Started() *MockPoolStartedCall
Started indicates an expected call of Started.
func (*MockPoolMockRecorder) ValidateSerializedTxn ¶
func (mr *MockPoolMockRecorder) ValidateSerializedTxn(serializedTxn any) *MockPoolValidateSerializedTxnCall
ValidateSerializedTxn indicates an expected call of ValidateSerializedTxn.
type MockPoolOnNewBlockCall ¶
MockPoolOnNewBlockCall wrap *gomock.Call
func (*MockPoolOnNewBlockCall) Do ¶
func (c *MockPoolOnNewBlockCall) Do(f func(context.Context, *remoteproto.StateChangeBatch, TxnSlots, TxnSlots, TxnSlots) error) *MockPoolOnNewBlockCall
Do rewrite *gomock.Call.Do
func (*MockPoolOnNewBlockCall) DoAndReturn ¶
func (c *MockPoolOnNewBlockCall) DoAndReturn(f func(context.Context, *remoteproto.StateChangeBatch, TxnSlots, TxnSlots, TxnSlots) error) *MockPoolOnNewBlockCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolOnNewBlockCall) Return ¶
func (c *MockPoolOnNewBlockCall) Return(arg0 error) *MockPoolOnNewBlockCall
Return rewrite *gomock.Call.Return
type MockPoolStartedCall ¶
MockPoolStartedCall wrap *gomock.Call
func (*MockPoolStartedCall) Do ¶
func (c *MockPoolStartedCall) Do(f func() bool) *MockPoolStartedCall
Do rewrite *gomock.Call.Do
func (*MockPoolStartedCall) DoAndReturn ¶
func (c *MockPoolStartedCall) DoAndReturn(f func() bool) *MockPoolStartedCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolStartedCall) Return ¶
func (c *MockPoolStartedCall) Return(arg0 bool) *MockPoolStartedCall
Return rewrite *gomock.Call.Return
type MockPoolValidateSerializedTxnCall ¶
MockPoolValidateSerializedTxnCall wrap *gomock.Call
func (*MockPoolValidateSerializedTxnCall) Do ¶
func (c *MockPoolValidateSerializedTxnCall) Do(f func([]byte) error) *MockPoolValidateSerializedTxnCall
Do rewrite *gomock.Call.Do
func (*MockPoolValidateSerializedTxnCall) DoAndReturn ¶
func (c *MockPoolValidateSerializedTxnCall) DoAndReturn(f func([]byte) error) *MockPoolValidateSerializedTxnCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockPoolValidateSerializedTxnCall) Return ¶
func (c *MockPoolValidateSerializedTxnCall) Return(arg0 error) *MockPoolValidateSerializedTxnCall
Return rewrite *gomock.Call.Return
type NewSlotsStreams ¶
type NewSlotsStreams struct {
// contains filtered or unexported fields
}
NewSlotsStreams - it's safe to use this class as non-pointer
func (*NewSlotsStreams) Add ¶
func (s *NewSlotsStreams) Add(stream txpool_proto.Txpool_OnAddServer) (remove func())
func (*NewSlotsStreams) Broadcast ¶
func (s *NewSlotsStreams) Broadcast(reply *txpool_proto.OnAddReply, logger log.Logger)
type Option ¶
type Option func(*options)
func WithFeeCalculator ¶
func WithFeeCalculator(f FeeCalculator) Option
func WithP2PFetcherWg ¶
func WithP2PSenderWg ¶
func WithPoolDBInitializer ¶
func WithPoolDBInitializer(init poolDBInitializer) Option
type PeerID ¶
type PeerID *typesproto.H512
type PendingPool ¶
type PendingPool struct {
// contains filtered or unexported fields
}
PendingPool - is different from other pools - it's best is Slice instead of Heap It's more expensive to maintain "slice sort" invariant, but it allow do cheap copy of pending.best slice for mining (because we consider txns and metaTxn are immutable)
func NewPendingSubPool ¶
func NewPendingSubPool(t SubPoolType, limit int) *PendingPool
func (*PendingPool) Add ¶
func (p *PendingPool) Add(i *metaTxn, logger log.Logger)
func (*PendingPool) Best ¶
func (p *PendingPool) Best() *metaTxn
func (*PendingPool) DebugPrint ¶
func (p *PendingPool) DebugPrint(prefix string)
func (*PendingPool) EnforceBestInvariants ¶
func (p *PendingPool) EnforceBestInvariants()
func (*PendingPool) EnforceWorstInvariants ¶
func (p *PendingPool) EnforceWorstInvariants()
func (*PendingPool) Len ¶
func (p *PendingPool) Len() int
func (*PendingPool) PopWorst ¶
func (p *PendingPool) PopWorst() *metaTxn
func (*PendingPool) Remove ¶
func (p *PendingPool) Remove(i *metaTxn, reason string, logger log.Logger)
func (*PendingPool) Updated ¶
func (p *PendingPool) Updated(mt *metaTxn)
func (*PendingPool) Worst ¶
func (p *PendingPool) Worst() *metaTxn
type Pool ¶
type Pool interface { ValidateSerializedTxn(serializedTxn []byte) error // Handle 3 main events - new remote txns from p2p, new local txns from RPC, new blocks from execution layer AddRemoteTxns(ctx context.Context, newTxns TxnSlots) AddLocalTxns(ctx context.Context, newTxns TxnSlots) ([]txpoolcfg.DiscardReason, error) OnNewBlock(ctx context.Context, stateChanges *remote.StateChangeBatch, unwindTxns, unwindBlobTxns, minedTxns TxnSlots) error // IdHashKnown check whether transaction with given Id hash is known to the pool IdHashKnown(tx kv.Tx, hash []byte) (bool, error) FilterKnownIdHashes(tx kv.Tx, hashes Hashes) (unknownHashes Hashes, err error) Started() bool GetRlp(tx kv.Tx, hash []byte) ([]byte, error) AddNewGoodPeer(peerID PeerID) }
Pool is interface for the transaction pool This interface exists for the convenience of testing, and not yet because there are multiple implementations
type Send ¶
type Send struct {
// contains filtered or unexported fields
}
Send - does send concrete P2P messages to Sentry. Same as Fetch but for outbound traffic does not initiate any messages by self
func NewSend ¶
func NewSend(ctx context.Context, sentryClients []sentryproto.SentryClient, logger log.Logger, opts ...Option) *Send
func (*Send) AnnouncePooledTxns ¶
func (*Send) BroadcastPooledTxns ¶
Broadcast given RLPs to random peers
type StateChangesClient ¶
type StateChangesClient interface {
StateChanges(ctx context.Context, in *remote.StateChangeRequest, opts ...grpc.CallOption) (remote.KV_StateChangesClient, error)
}
type SubPool ¶
type SubPool struct {
// contains filtered or unexported fields
}
func NewSubPool ¶
func NewSubPool(t SubPoolType, limit int) *SubPool
func (*SubPool) DebugPrint ¶
func (*SubPool) EnforceInvariants ¶
func (p *SubPool) EnforceInvariants()
type SubPoolMarker ¶
type SubPoolMarker uint8
SubPoolMarker is an ordered bitset of five bits that's used to sort transactions into sub-pools. Bits meaning: 1. Absence of nonce gaps. Set to 1 for transactions whose nonce is N, state nonce for the sender is M, and there are transactions for all nonces between M and N from the same sender. Set to 0 is the transaction's nonce is divided from the state nonce by one or more nonce gaps. 2. Sufficient balance for gas. Set to 1 if the balance of sender's account in the state is B, nonce of the sender in the state is M, nonce of the transaction is N, and the sum of feeCap x gasLimit + transferred_value of all transactions from this sender with nonces N+1 ... M is no more than B. Set to 0 otherwise. In other words, this bit is set if there is currently a guarantee that the transaction and all its required prior transactions will be able to pay for gas. 3. Not too much gas: Set to 1 if the transaction doesn't use too much gas 4. Dynamic fee requirement. Set to 1 if feeCap of the transaction is no less than baseFee of the currently pending block. Set to 0 otherwise. 5. Local transaction. Set to 1 if transaction is local.
const ( NoNonceGaps SubPoolMarker = 0b010000 EnoughBalance SubPoolMarker = 0b001000 NotTooMuchGas SubPoolMarker = 0b000100 EnoughFeeCapBlock SubPoolMarker = 0b000010 IsLocal SubPoolMarker = 0b000001 BaseFeePoolBits = NoNonceGaps + EnoughBalance + NotTooMuchGas )
type SubPoolType ¶
type SubPoolType uint8
const BaseFeeSubPool SubPoolType = 2
const PendingSubPool SubPoolType = 1
const QueuedSubPool SubPoolType = 3
func (SubPoolType) String ¶
func (sp SubPoolType) String() string
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool - holds all pool-related data structures and lock-based tiny methods most of logic implemented by pure tests-friendly functions
txpool doesn't start any goroutines - "leave concurrency to user" design txpool has no DB-TX fields - "leave db transactions management to user" design txpool has _chainDB field - but it must maximize local state cache hit-rate - and perform minimum _chainDB transactions
It preserve TxnSlot objects immutable
func Assemble ¶
func Assemble( ctx context.Context, cfg txpoolcfg.Config, chainDB kv.RwDB, cache kvcache.Cache, sentryClients []sentryproto.SentryClient, stateChangesClient StateChangesClient, builderNotifyNewTxns func(), logger log.Logger, opts ...Option, ) (*TxPool, txpoolproto.TxpoolServer, error)
func New ¶
func New( ctx context.Context, newTxns chan Announcements, poolDB kv.RwDB, chainDB kv.RoDB, cfg txpoolcfg.Config, cache kvcache.Cache, chainID uint256.Int, shanghaiTime *big.Int, agraBlock *big.Int, cancunTime *big.Int, pragueTime *big.Int, blobSchedule *chain.BlobSchedule, sentryClients []sentryproto.SentryClient, stateChangesClient StateChangesClient, builderNotifyNewTxns func(), newSlotsStreams *NewSlotsStreams, logger log.Logger, opts ...Option, ) (*TxPool, error)
func (*TxPool) AddLocalTxns ¶
func (*TxPool) AddNewGoodPeer ¶
func (*TxPool) AppendAllAnnouncements ¶
func (*TxPool) AppendLocalAnnouncements ¶
func (*TxPool) AppendRemoteAnnouncements ¶
func (*TxPool) FilterKnownIdHashes ¶
func (*TxPool) GetMaxBlobsPerBlock ¶
func (*TxPool) NonceFromAddress ¶
func (*TxPool) OnNewBlock ¶
func (*TxPool) ProvideTxns ¶
func (p *TxPool) ProvideTxns(ctx context.Context, opts ...txnprovider.ProvideOption) ([]types.Transaction, error)
func (*TxPool) Run ¶
Run - does: send pending byHash to p2p:
- new byHash
- all pooled byHash to recently connected peers
- all local pooled byHash to random peers periodically
promote/demote transactions reorgs
func (*TxPool) ValidateSerializedTxn ¶
Check that the serialized txn should not exceed a certain max size
type TxnParseConfig ¶
type TxnParseContext ¶
type TxnParseContext struct { Signature Keccak2 hash.Hash Keccak1 hash.Hash Sig [65]byte Sighash [32]byte // contains filtered or unexported fields }
TxnParseContext is object that is required to parse transactions and turn transaction payload into TxnSlot objects usage of TxContext helps avoid extra memory allocations
func NewTxnParseContext ¶
func NewTxnParseContext(chainID uint256.Int) *TxnParseContext
func (*TxnParseContext) ChainIDRequired ¶
func (ctx *TxnParseContext) ChainIDRequired() *TxnParseContext
Set ChainID-Required flag in the Parse context and return it
func (*TxnParseContext) ParseTransaction ¶
func (ctx *TxnParseContext) ParseTransaction(payload []byte, pos int, slot *TxnSlot, sender []byte, hasEnvelope, wrappedWithBlobs bool, validateHash func([]byte) error) (p int, err error)
ParseTransaction extracts all the information from the transactions's payload (RLP) necessary to build TxnSlot. It also performs syntactic validation of the transactions. wrappedWithBlobs means that for blob (type 3) transactions the full version with blobs/commitments/proofs is expected (see https://eips.ethereum.org/EIPS/eip-4844#networking).
func (*TxnParseContext) ValidateRLP ¶
func (ctx *TxnParseContext) ValidateRLP(f func(txnRlp []byte) error)
Set the RLP validate function
func (*TxnParseContext) WithAllowPreEip2s ¶
func (ctx *TxnParseContext) WithAllowPreEip2s(v bool)
Set the AllowPreEIP2s flag
func (*TxnParseContext) WithSender ¶
func (ctx *TxnParseContext) WithSender(v bool)
Set the with sender flag
type TxnSlot ¶
type TxnSlot struct { Rlp []byte // Is set to nil after flushing to db, frees memory, later we look for it in the db, if needed Value uint256.Int // Value transferred by the transaction Tip uint256.Int // Maximum tip that transaction is giving to miner/block proposer FeeCap uint256.Int // Maximum fee that transaction burns and gives to the miner/block proposer SenderID uint64 // SenderID - require external mapping to it's address Nonce uint64 // Nonce of the transaction DataLen int // Length of transaction's data (for calculation of intrinsic gas) DataNonZeroLen int AccessListAddrCount int // Number of addresses in the access list AccessListStorCount int // Number of storage keys in the access list Gas uint64 // Gas limit of the transaction IDHash [32]byte // Transaction hash for the purposes of using it as a transaction Id Traced bool // Whether transaction needs to be traced throughout transaction pool code and generate debug printing Creation bool // Set to true if "To" field of the transaction is not set Type byte // Transaction type Size uint32 // Size of the payload (without the RLP string envelope for typed transactions) // EIP-4844: Shard Blob Transactions BlobFeeCap uint256.Int // max_fee_per_blob_gas BlobHashes []common.Hash Blobs [][]byte Commitments []gokzg4844.KZGCommitment Proofs []gokzg4844.KZGProof // EIP-7702: set code tx Authorizations []Signature AuthRaw [][]byte // rlp encoded chainID+address+nonce, used to recover authorization address in txpool }
TxnSlot contains information extracted from an Ethereum transaction, which is enough to manage it inside the transaction. Also, it contains some auxiliary information, like ephemeral fields, and indices within priority queues
type TxnSlots ¶
type WorstQueue ¶
type WorstQueue struct {
// contains filtered or unexported fields
}
func (*WorstQueue) Len ¶
func (p *WorstQueue) Len() int
func (*WorstQueue) Less ¶
func (p *WorstQueue) Less(i, j int) bool
func (*WorstQueue) Pop ¶
func (p *WorstQueue) Pop() interface{}
func (*WorstQueue) Push ¶
func (p *WorstQueue) Push(x interface{})
func (*WorstQueue) Swap ¶
func (p *WorstQueue) Swap(i, j int)