Documentation
¶
Index ¶
- type BasicBudget
- type Budget
- type EL
- type IncludedTx
- type Includer
- type IsthmusCostOracle
- type Limit
- type Monitor
- type NoOpResubmitterObserver
- type OPCostOracle
- type Persistent
- type PersistentOption
- type PkSigner
- type RPCClient
- type ReceiptGetter
- type Resubmitter
- type ResubmitterObserver
- type ResubmitterOption
- type Sender
- type Signer
- type TxBudget
- type TxBudgetOption
- type UnlimitedBudget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicBudget ¶ added in v1.13.5
type Budget ¶
type Budget interface {
// BeforeResubmit is called before the transaction is resubmitted. It allows the cost to be
// re-estimated in case of any changes (e.g., nonce increments affecting DA cost).
BeforeResubmit(oldBudgetedCost eth.ETH, tx *types.Transaction) (newBudgetedCost eth.ETH, err error)
// AfterCancel is called after the transaction is canceled, providing a chance to refund the
// cost.
AfterCancel(budgetedCost eth.ETH, tx *types.Transaction)
// AfterIncluded is called after the transaction is included, giving an opportunity to refund
// the difference between the budgeted cost and the actual cost.
AfterIncluded(budgetedCost eth.ETH, tx *IncludedTx)
}
Budget tracks costs throughout a tranaction's lifecycle.
type EL ¶
type EL interface {
Sender
ReceiptGetter
}
EL represents an EVM execution layer. It is responsible for handling transport errors, such as HTTP 429s.
type IncludedTx ¶
type IncludedTx struct {
Transaction *types.Transaction
Receipt *types.Receipt
}
type IsthmusCostOracle ¶ added in v1.13.5
type IsthmusCostOracle struct {
// contains filtered or unexported fields
}
IsthmusCostOracle implements OPCostOracle only for the Isthmus hard fork.
func NewIsthmusCostOracle ¶ added in v1.13.5
func NewIsthmusCostOracle(client RPCClient, blockTime time.Duration) *IsthmusCostOracle
func (*IsthmusCostOracle) OPCost ¶ added in v1.13.5
func (i *IsthmusCostOracle) OPCost(tx *types.Transaction) *big.Int
func (*IsthmusCostOracle) SetParams ¶ added in v1.13.5
func (i *IsthmusCostOracle) SetParams(ctx context.Context) error
func (*IsthmusCostOracle) Start ¶ added in v1.13.5
func (i *IsthmusCostOracle) Start(ctx context.Context)
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is a ReceiptGetter that will continue looking for a receipt even when it doesn't find it right away.
func NewMonitor ¶
func NewMonitor(inner ReceiptGetter, blockTime time.Duration) *Monitor
type NoOpResubmitterObserver ¶
type NoOpResubmitterObserver struct{}
func (NoOpResubmitterObserver) SubmissionError ¶
func (NoOpResubmitterObserver) SubmissionError(error)
type OPCostOracle ¶ added in v1.13.5
type OPCostOracle interface {
// OPCost returns the total OP-specific costs for tx, such as the L1 cost and operator cost.
OPCost(*types.Transaction) *big.Int
}
type Persistent ¶
type Persistent struct {
// contains filtered or unexported fields
}
Persistent is an Includer that persists transactions to an execution layer.
func NewPersistent ¶
func NewPersistent(signer Signer, el EL, opts ...PersistentOption) *Persistent
NewPersistent creates a Persistent Includer. It assumes el is reliable:
- el.SendTransaction guarantees mempool inclusion without the possibility of eviction.
- el.TransactionReceipt will return a valid receipt if one eventually exists.
func (*Persistent) Include ¶
func (p *Persistent) Include(ctx context.Context, tx types.TxData) (*IncludedTx, error)
Include attempts to persist tx to p's EL, updating its budget in real time throughout the transaction lifecycle. It fails to include a transaction in the event of an error from the context, budget, signer, or EL. It tries to recover from EL nonce and fee errors by adjusting those parameters accordingly.
type PersistentOption ¶
type PersistentOption func(cfg *persistentConfig)
func WithBudget ¶
func WithBudget(budget Budget) PersistentOption
WithBudget adds a budget to the Includer. The default is unlimited.
func WithStartNonce ¶
func WithStartNonce(nonce uint64) PersistentOption
WithStartNonce instructs the Persistent includer to use nonce as a starting nonce. The default is zero.
type PkSigner ¶
type PkSigner struct {
// contains filtered or unexported fields
}
func NewPkSigner ¶
func NewPkSigner(pk *ecdsa.PrivateKey, chainID *big.Int) *PkSigner
func (*PkSigner) Sign ¶
func (s *PkSigner) Sign(_ context.Context, tx *types.Transaction) (*types.Transaction, error)
type ReceiptGetter ¶
type Resubmitter ¶
type Resubmitter struct {
// contains filtered or unexported fields
}
func NewResubmitter ¶
func NewResubmitter(inner Sender, blockTime time.Duration, opts ...ResubmitterOption) *Resubmitter
func (*Resubmitter) SendTransaction ¶
func (r *Resubmitter) SendTransaction(ctx context.Context, tx *types.Transaction) error
SendTransaction implements Sender. It will continue resubmitting unless an error is hit that the resubmitter considers unfixable with resubmissions alone (e.g., requiring modifications to tx) See fatalErrs for the list of these errors.
type ResubmitterObserver ¶
type ResubmitterObserver interface {
SubmissionError(error)
}
type ResubmitterOption ¶
type ResubmitterOption func(*resubmitterConfig)
func WithObserver ¶
func WithObserver(observer ResubmitterObserver) ResubmitterOption
type Signer ¶
type Signer interface {
Sign(context.Context, *types.Transaction) (*types.Transaction, error)
}
type TxBudget ¶ added in v1.13.5
type TxBudget struct {
// contains filtered or unexported fields
}
TxBudget provides budgeting helpers oriented around a transaction's lifecycle.
func NewTxBudget ¶ added in v1.13.5
func NewTxBudget(inner BasicBudget, opts ...TxBudgetOption) *TxBudget
func (*TxBudget) AfterCancel ¶ added in v1.13.5
func (b *TxBudget) AfterCancel(cost eth.ETH, _ *types.Transaction)
AfterCancel credits cost.
func (*TxBudget) AfterIncluded ¶ added in v1.13.5
func (b *TxBudget) AfterIncluded(budgetedCost eth.ETH, tx *IncludedTx)
AfterIncluded credits the difference between the budgeted cost and the actual cost. It is assumed that the budgeted cost is always greater than the actual cost.
func (*TxBudget) BeforeResubmit ¶ added in v1.13.5
BeforeResubmit calculates the cost of tx. If the new cost is greather than oldCost, it debits the difference. If the new cost is less than oldCost, it credits the difference.
type TxBudgetOption ¶ added in v1.13.5
type TxBudgetOption func(*txBudgetConfig)
func WithOPCostOracle ¶ added in v1.13.5
func WithOPCostOracle(oracle OPCostOracle) TxBudgetOption
type UnlimitedBudget ¶ added in v1.13.5
type UnlimitedBudget struct{}
func (UnlimitedBudget) AfterCancel ¶ added in v1.13.5
func (UnlimitedBudget) AfterCancel(_ eth.ETH, _ *types.Transaction)
func (UnlimitedBudget) AfterIncluded ¶ added in v1.13.5
func (UnlimitedBudget) AfterIncluded(_ eth.ETH, _ *IncludedTx)
func (UnlimitedBudget) BeforeResubmit ¶ added in v1.13.5
func (n UnlimitedBudget) BeforeResubmit(oldCost eth.ETH, _ *types.Transaction) (eth.ETH, error)