tx

package
v0.0.0-...-ffe42a1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Window - Dataset size for moving average
	Window = 100
	// MinDelay - minimum delay before first try
	MinDelay = 100 * time.Millisecond
	// MaxDelay - maximum delay between tries
	MaxDelay = 10 * time.Second
	// Factor - exponential backoff factor
	Factor = 1.3
	// InitialDelayFraction - start with a large faction of the current average
	InitialDelayFraction = 0.8
	// FirstRetryFraction - then retry with exponential backoff using a fraction of that initial delay
	FirstRetryDelayFraction = 0.15
	// TracerFrequency - run an aggressive txn every X txns, and reset average
	TracerFrequency = 25
	// TracerDivisor - when a tracer runs, it runs at this division of the average
	TracerDivisor = 5
	// ResetThreshold - if a tracer comes in below this threshold of the average, we reset
	ResetThreshold = 0.3
)

Intention is that these values are a good baseline for the low-level exponential backoff retry of getting transaction receipts up to a maximum time. The maximum time is configured outside of this code, as when a transction receipt never comes back we cannot infer anything about the timing of successful transactions

Variables

This section is empty.

Functions

func CobraInitTxnProcessor

func CobraInitTxnProcessor(cmd *cobra.Command, txconf *TxnProcessorConf)

CobraInitTxnProcessor sets the standard command-line parameters for the txnprocessor

Types

type AddressBook

type AddressBook interface {
	// contains filtered or unexported methods
}

AddressBook looks up RPC URLs based on a remote registry, and optionally resolves hostnames to IP addresses using a hosts file

func NewAddressBook

func NewAddressBook(conf *AddressBookConf, rpcConf *eth.RPCConf) AddressBook

NewAddressBook constructor

type AddressBookConf

type AddressBookConf struct {
	utils.HTTPRequesterConf
	AddressbookURLPrefix    string                   `json:"urlPrefix"`
	HostsFile               string                   `json:"hostsFile"`
	PropNames               AddressBookPropNamesConf `json:"propNames"`
	RetryDelaySec           *int                     `json:"retryDelaySec,omitempty"`
	HealthcheckFrequencySec *int                     `json:"healthcheckFrequencySec,omitempty"`
	MaxRetries              *int                     `json:"maxRetries,omitempty"`
}

AddressBookConf configuration

type AddressBookPropNamesConf

type AddressBookPropNamesConf struct {
	RPCEndpoint string `json:"endpoint"`
}

AddressBookPropNamesConf configures the JSON property names to extract from the GET response on the API

type HDWallet

type HDWallet interface {
	SignerFor(request *HDWalletRequest) (eth.TXSigner, error)
}

HDWallet interface

type HDWalletConf

type HDWalletConf struct {
	utils.HTTPRequesterConf
	// URLTemplate is a go template such as: "https://someconstant-{{.InstanceID}}/api/v1/{{.WalletID}}/{{.Index}}"
	URLTemplate string                `json:"urlTemplate"`
	ChainID     string                `json:"chainID"`
	PropNames   HDWalletConfPropNames `json:"propNames"`
}

HDWalletConf configuration

type HDWalletConfPropNames

type HDWalletConfPropNames struct {
	Address    string `json:"address"`
	PrivateKey string `json:"privateKey"`
}

HDWalletConfPropNames prop names for processing JSON responses

type HDWalletRequest

type HDWalletRequest struct {
	InstanceID string
	WalletID   string
	Index      string
}

HDWalletRequest is the struct that is extracted from a specially formatted 'from' string, by IsHDWalletRequest

func IsHDWalletRequest

func IsHDWalletRequest(fromAddr string) *HDWalletRequest

IsHDWalletRequest validates a from address to see if it is a HD wallet signing request

type TxnContext

type TxnContext interface {
	// Return the Go context
	Context() context.Context
	// Get the headers of the message
	Headers() *messages.CommonHeaders
	// Unmarshal the supplied message into a give type
	Unmarshal(msg interface{}) error
	// Send an error reply
	SendErrorReply(status int, err error)
	// Send an error reply
	SendErrorReplyWithTX(status int, err error, txHash string)
	// Send an error reply
	SendErrorReplyWithGapFill(status int, err error, gapFillTxHash string, gapFillSucceeded bool)
	// Send a reply that can be marshaled into bytes.
	// Sets all the common headers on behalf of the caller, based on the request context
	Reply(replyMsg messages.ReplyWithHeaders)
	// Get a string summary
	String() string
}

TxnContext is passed for each message that arrives at the bridge

type TxnDelayTracker

type TxnDelayTracker interface {
	GetInitialDelay() (delay time.Duration)
	GetRetryDelay(initialDelay time.Duration, retry int) (delay time.Duration)
	ReportSuccess(timeTaken time.Duration)
}

TxnDelayTracker - helps manage delays when checking for txn receipts

func NewTxnDelayTracker

func NewTxnDelayTracker() TxnDelayTracker

NewTxnDelayTracker - constructs a new tracker

type TxnProcessor

type TxnProcessor interface {
	OnMessage(TxnContext)
	Init(eth.RPCClient)
	ResolveAddress(from string) (resolvedFrom string, err error)
	SetReceiptStoreForIdempotencyCheck(receiptStore receipts.ReceiptStorePersistence)
}

TxnProcessor interface is called for each message, as is responsible for tracking all in-flight messages

func NewTxnProcessor

func NewTxnProcessor(conf *TxnProcessorConf, rpcConf *eth.RPCConf) TxnProcessor

NewTxnProcessor constructor for message procss

type TxnProcessorConf

type TxnProcessorConf struct {
	eth.EthCommonConf
	AlwaysManageNonce   bool            `json:"alwaysManageNonce"`
	AttemptGapFill      bool            `json:"attemptGapFill"`
	MaxTXWaitTime       int             `json:"maxTXWaitTime"`
	SendConcurrency     int             `json:"sendConcurrency"`
	OrionPrivateAPIS    bool            `json:"orionPrivateAPIs"`
	HexValuesInReceipt  bool            `json:"hexValuesInReceipt"`
	AddressBookConf     AddressBookConf `json:"addressBook"`
	HDWalletConf        HDWalletConf    `json:"hdWallet"`
	SendRetryForce      bool            `json:"sendRetryForce,omitempty"`
	SendRetryDelayMinMS *int            `json:"sendRetryDelayMinMS,omitempty"`
	SendRetryDelayMaxMS *int            `json:"sendRetryDelayMaxMS,omitempty"`
	SendRetryMax        *int            `json:"sendRetryMax,omitempty"`
	SendRetryFactor     *float64        `json:"sendRetryFactor,omitempty"`
}

TxnProcessorConf configuration for the message processor

Jump to

Keyboard shortcuts

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