txm

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: LGPL-3.0, MIT Imports: 43 Imported by: 1

Documentation

Index

Constants

View Source
const (
	APIStatusPending   = "PENDING"
	APIStatusIncluded  = "INCLUDED"
	APIStatusFailed    = "FAILED"
	APIStatusCancelled = "CANCELLED"
	APIStatusUnknown   = "UNKNOWN"
)

Variables

This section is empty.

Functions

func NewAttemptBuilder

func NewAttemptBuilder(priceMaxKey func(common.Address) *assets.Wei, estimator gas.EvmFeeEstimator, keystore keys.TxSigner) *attemptBuilder

func NewStuckTxDetector

func NewStuckTxDetector(lggr logger.Logger, chaintype chaintype.ChainType, config StuckTxDetectorConfig) *stuckTxDetector

func NewTxmMetrics

func NewTxmMetrics(chainID *big.Int) (*txmMetrics, error)

Types

type APIResponse

type APIResponse struct {
	Status string      `json:"status,omitempty"`
	Hash   common.Hash `json:"hash,omitempty"`
}

type AttemptBuilder

type AttemptBuilder interface {
	NewAttempt(context.Context, logger.Logger, *types.Transaction, bool) (*types.Attempt, error)
	NewBumpAttempt(context.Context, logger.Logger, *types.Transaction, types.Attempt) (*types.Attempt, error)
}

type Client

type Client interface {
	PendingNonceAt(context.Context, common.Address) (uint64, error)
	NonceAt(context.Context, common.Address, *big.Int) (uint64, error)
	SendTransaction(ctx context.Context, tx *types.Transaction, attempt *types.Attempt) error
}

type Config

type Config struct {
	EIP1559             bool
	BlockTime           time.Duration
	RetryBlockThreshold uint16
	EmptyTxLimitDefault uint64
}

type DummyKeystore

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

func NewKeystore

func NewKeystore(chainID *big.Int) *DummyKeystore

func (*DummyKeystore) Add

func (k *DummyKeystore) Add(privateKeyString string) error

func (*DummyKeystore) EnabledAddresses

func (k *DummyKeystore) EnabledAddresses(_ context.Context) (addresses []common.Address, err error)

func (*DummyKeystore) SignMessage

func (k *DummyKeystore) SignMessage(ctx context.Context, address common.Address, data []byte) ([]byte, error)

func (*DummyKeystore) SignTx

func (k *DummyKeystore) SignTx(_ context.Context, fromAddress common.Address, tx *types.Transaction) (*types.Transaction, error)

type ErrorHandler

type ErrorHandler interface {
	HandleError(*types.Transaction, error, AttemptBuilder, Client, TxStore, func(common.Address, uint64), bool) (err error)
}

type Keystore

type Keystore interface {
	EnabledAddressesForChain(ctx context.Context, chainID *big.Int) (addresses []common.Address, err error)
}

type NotEnabledError

type NotEnabledError = txmgr.NotEnabledError[common.Address]

type Orchestrator

type Orchestrator[
	BLOCK_HASH chains.Hashable,
	HEAD chains.Head[BLOCK_HASH],
] struct {
	services.StateMachine
	// contains filtered or unexported fields
}

Generics are necessary to keep TXMv2 backwards compatible

func NewTxmOrchestrator

func NewTxmOrchestrator[BLOCK_HASH chains.Hashable, HEAD chains.Head[BLOCK_HASH]](
	lggr logger.Logger,
	chainID *big.Int,
	txm *Txm,
	txStore OrchestratorTxStore,
	fwdMgr *forwarders.FwdMgr,
	keystore keys.Addresses,
	attemptBuilder OrchestratorAttemptBuilder[BLOCK_HASH, HEAD],
) *Orchestrator[BLOCK_HASH, HEAD]

func (*Orchestrator[BLOCK_HASH, HEAD]) CalculateFee

func (o *Orchestrator[BLOCK_HASH, HEAD]) CalculateFee(feeParts txmgr.FeeParts) *big.Int

func (*Orchestrator[BLOCK_HASH, HEAD]) Close

func (o *Orchestrator[BLOCK_HASH, HEAD]) Close() (merr error)

func (*Orchestrator[BLOCK_HASH, HEAD]) CountTransactionsByState

func (o *Orchestrator[BLOCK_HASH, HEAD]) CountTransactionsByState(ctx context.Context, state txmgrtypes.TxState) (uint32, error)

CountTransactionsByState was required for backwards compatibility and it's used only for unconfirmed transactions.

func (*Orchestrator[BLOCK_HASH, HEAD]) CreateTransaction

func (o *Orchestrator[BLOCK_HASH, HEAD]) CreateTransaction(ctx context.Context, request txmgrtypes.TxRequest[common.Address, common.Hash]) (tx txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee], err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) FindEarliestUnconfirmedBroadcastTime

func (o *Orchestrator[BLOCK_HASH, HEAD]) FindEarliestUnconfirmedBroadcastTime(ctx context.Context) (time nullv4.Time, err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) FindEarliestUnconfirmedTxAttemptBlock

func (o *Orchestrator[BLOCK_HASH, HEAD]) FindEarliestUnconfirmedTxAttemptBlock(ctx context.Context) (time nullv4.Int, err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) FindTxesByMetaFieldAndStates

func (o *Orchestrator[BLOCK_HASH, HEAD]) FindTxesByMetaFieldAndStates(ctx context.Context, metaField string, metaValue string, states []txmgrtypes.TxState, chainID *big.Int) (txs []*txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee], err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) FindTxesWithAttemptsAndReceiptsByIdsAndState

func (o *Orchestrator[BLOCK_HASH, HEAD]) FindTxesWithAttemptsAndReceiptsByIdsAndState(ctx context.Context, ids []int64, states []txmgrtypes.TxState, chainID *big.Int) (txs []*txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee], err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) FindTxesWithMetaFieldByReceiptBlockNum

func (o *Orchestrator[BLOCK_HASH, HEAD]) FindTxesWithMetaFieldByReceiptBlockNum(ctx context.Context, metaField string, blockNum int64, chainID *big.Int) (txs []*txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee], err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) FindTxesWithMetaFieldByStates

func (o *Orchestrator[BLOCK_HASH, HEAD]) FindTxesWithMetaFieldByStates(ctx context.Context, metaField string, states []txmgrtypes.TxState, chainID *big.Int) (txs []*txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee], err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) GetForwarderForEOA

func (o *Orchestrator[BLOCK_HASH, HEAD]) GetForwarderForEOA(ctx context.Context, eoa common.Address) (forwarder common.Address, err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) GetForwarderForEOAOCR2Feeds

func (o *Orchestrator[BLOCK_HASH, HEAD]) GetForwarderForEOAOCR2Feeds(ctx context.Context, eoa, ocr2AggregatorID common.Address) (forwarder common.Address, err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) GetTransactionFee

func (o *Orchestrator[BLOCK_HASH, HEAD]) GetTransactionFee(ctx context.Context, transactionID string) (fee *evm.TransactionFee, err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) GetTransactionReceipt

func (o *Orchestrator[BLOCK_HASH, HEAD]) GetTransactionReceipt(ctx context.Context, transactionID string) (receipt *txmgrtypes.ChainReceipt[BLOCK_HASH, BLOCK_HASH], err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) GetTransactionStatus

func (o *Orchestrator[BLOCK_HASH, HEAD]) GetTransactionStatus(ctx context.Context, transactionID string) (status commontypes.TransactionStatus, err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) HealthReport

func (o *Orchestrator[BLOCK_HASH, HEAD]) HealthReport() map[string]error

func (*Orchestrator[BLOCK_HASH, HEAD]) Name

func (o *Orchestrator[BLOCK_HASH, HEAD]) Name() string

func (*Orchestrator[BLOCK_HASH, HEAD]) OnNewLongestChain

func (o *Orchestrator[BLOCK_HASH, HEAD]) OnNewLongestChain(ctx context.Context, head HEAD)

func (*Orchestrator[BLOCK_HASH, HEAD]) RegisterResumeCallback

func (o *Orchestrator[BLOCK_HASH, HEAD]) RegisterResumeCallback(fn txmgr.ResumeCallback)

func (*Orchestrator[BLOCK_HASH, HEAD]) Reset

func (o *Orchestrator[BLOCK_HASH, HEAD]) Reset(addr common.Address, abandon bool) error

func (*Orchestrator[BLOCK_HASH, HEAD]) SendNativeToken

func (o *Orchestrator[BLOCK_HASH, HEAD]) SendNativeToken(ctx context.Context, chainID *big.Int, from, to common.Address, value big.Int, gasLimit uint64) (tx txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee], err error)

func (*Orchestrator[BLOCK_HASH, HEAD]) Start

func (o *Orchestrator[BLOCK_HASH, HEAD]) Start(ctx context.Context) error

func (*Orchestrator[BLOCK_HASH, HEAD]) Trigger

func (o *Orchestrator[BLOCK_HASH, HEAD]) Trigger(addr common.Address)

type OrchestratorAttemptBuilder

type OrchestratorAttemptBuilder[
	BLOCK_HASH chains.Hashable,
	HEAD chains.Head[BLOCK_HASH],
] interface {
	services.Service
	OnNewLongestChain(ctx context.Context, head HEAD)
}

type OrchestratorTxStore

type OrchestratorTxStore interface {
	Add(addresses ...common.Address) error
	FetchUnconfirmedTransactionAtNonceWithCount(context.Context, uint64, common.Address) (*txmtypes.Transaction, int, error)
	FindTxWithIdempotencyKey(context.Context, string) (*txmtypes.Transaction, error)
}

type StuckTxDetector

type StuckTxDetector interface {
	DetectStuckTransaction(ctx context.Context, tx *types.Transaction) (bool, error)
}

type StuckTxDetectorConfig

type StuckTxDetectorConfig struct {
	BlockTime             time.Duration
	StuckTxBlockThreshold uint32
	DetectionURL          string
	DualBroadcast         bool
}

type TxStore

type TxStore interface {
	AbandonPendingTransactions(context.Context, common.Address) error
	AppendAttemptToTransaction(context.Context, uint64, common.Address, *types.Attempt) error
	CreateEmptyUnconfirmedTransaction(context.Context, common.Address, uint64, uint64) (*types.Transaction, error)
	CreateTransaction(context.Context, *types.TxRequest) (*types.Transaction, error)
	FetchUnconfirmedTransactionAtNonceWithCount(context.Context, uint64, common.Address) (*types.Transaction, int, error)
	MarkConfirmedAndReorgedTransactions(context.Context, uint64, common.Address) ([]*types.Transaction, []uint64, error)
	MarkUnconfirmedTransactionPurgeable(context.Context, uint64, common.Address) error
	UpdateTransactionBroadcast(context.Context, uint64, uint64, common.Hash, common.Address) error
	UpdateUnstartedTransactionWithNonce(context.Context, common.Address, uint64) (*types.Transaction, error)

	// ErrorHandler
	DeleteAttemptForUnconfirmedTx(context.Context, uint64, *types.Attempt, common.Address) error
	MarkTxFatal(context.Context, *types.Transaction, common.Address) error
}

type Txm

type Txm struct {
	services.StateMachine
	// contains filtered or unexported fields
}

func NewTxm

func NewTxm(lggr logger.Logger, chainID *big.Int, client Client, attemptBuilder AttemptBuilder, txStore TxStore, stuckTxDetector StuckTxDetector, config Config, keystore keys.AddressLister) *Txm

func (*Txm) Abandon

func (t *Txm) Abandon(address common.Address) error

func (*Txm) Close

func (t *Txm) Close() error

func (*Txm) CreateTransaction

func (t *Txm) CreateTransaction(ctx context.Context, txRequest *types.TxRequest) (tx *types.Transaction, err error)

func (*Txm) HealthReport

func (t *Txm) HealthReport() map[string]error

func (*Txm) Start

func (t *Txm) Start(ctx context.Context) error

func (*Txm) Trigger

func (t *Txm) Trigger(address common.Address)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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