disburser

package
v0.0.0-...-cbca9c8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDisbursements = 15

Variables

View Source
var (
	// DBMethodUpsertDeposits is a label for UpsertDeposits db method.
	DBMethodUpsertDeposits = prometheus.Labels{/* contains filtered or unexported fields */}

	// DBMethodConfirmedDeposits is a label for ConfirmedDeposits db method.
	DBMethodConfirmedDeposits = prometheus.Labels{/* contains filtered or unexported fields */}

	// DBMethodLastProcessedBlock is a label for LastProcessedBlock db method.
	DBMethodLastProcessedBlock = prometheus.Labels{/* contains filtered or unexported fields */}

	// DBMethodUpsertPendingTx is a label for UpsertPendingTx db method.
	DBMethodUpsertPendingTx = prometheus.Labels{/* contains filtered or unexported fields */}

	// DBMethodListPendingTxs is a label for ListPendingTxs db method.
	DBMethodListPendingTxs = prometheus.Labels{/* contains filtered or unexported fields */}

	// DBMethodUpsertDisbursement is a label for UpsertDisbursement db method.
	DBMethodUpsertDisbursement = prometheus.Labels{/* contains filtered or unexported fields */}

	// DBMethodLatestDisbursementID is a label for LatestDisbursementID db method.
	DBMethodLatestDisbursementID = prometheus.Labels{/* contains filtered or unexported fields */}

	// DBMethodDeletePendingTx is a label for DeletePendingTx db method.
	DBMethodDeletePendingTx = prometheus.Labels{/* contains filtered or unexported fields */}
)
View Source
var DefaultBackoff = &backoff.ExponentialBackOff{
	InitialInterval:     backoff.DefaultInitialInterval,
	RandomizationFactor: backoff.DefaultRandomizationFactor,
	Multiplier:          backoff.DefaultMultiplier,
	MaxInterval:         10 * time.Second,
	MaxElapsedTime:      time.Minute,
	Clock:               backoff.SystemClock,
}
View Source
var DisbursementFailedTopic = common.HexToHash(
	"0x9b478c095979d3d3a7d602ffd9ee1f0843204d853558ae0882c8fcc0a5bc78cf",
)

DisbursementFailedTopic is the topic hash for DisbursementFailed events.

View Source
var DisbursementSuccessTopic = common.HexToHash(
	"0xeaa22fd2d7b875476355b32cf719794faf9d91b66e73bc6375a053cace9caaee",
)

DisbursementSuccessTopic is the topic hash for DisbursementSuccess events.

Functions

func FindFilterStartBlockNumber

func FindFilterStartBlockNumber(params FilterStartBlockNumberParams) uint64

FindFilterStartBlockNumber returns the block height from which to begin filtering logs based on the relative heights of the chain, the contract deployment, and the last block that was processed.

func IsRetryableError

func IsRetryableError(err error) bool

Types

type Config

type Config struct {
	Name                 string
	L1Client             *ethclient.Client
	L2Client             *ethclient.Client
	Database             *db.Database
	MaxTxSize            uint64
	NumConfirmations     uint64
	DeployBlockNumber    uint64
	FilterQueryMaxBlocks uint64
	DepositAddr          common.Address
	DisburserAddr        common.Address
	ChainID              *big.Int
	PrivKey              *ecdsa.PrivateKey
	ChainMetricsEnable   bool
}

type Driver

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

func NewDriver

func NewDriver(cfg Config, parentCtx context.Context) (*Driver, error)

func (*Driver) ClearPendingTx

func (d *Driver) ClearPendingTx(
	ctx context.Context,
	txMgr txmgr.TxManager,
	l1Client *ethclient.Client,
) error

ClearPendingTx a publishes a transaction at the next available nonce in order to clear any transactions in the mempool left over from a prior running instance. When publishing to L2 there is no mempool so the transaction can't get stuck, thus the behavior is unimplemented.

func (*Driver) CraftBatchTx

func (d *Driver) CraftBatchTx(
	ctx context.Context,
	start, end, nonce *big.Int,
) (*types.Transaction, error)

CraftBatchTx transforms the L2 blocks between start and end into a batch transaction using the given nonce. A dummy gas price is used in the resulting transaction to use for size estimation.

NOTE: This method SHOULD NOT publish the resulting transaction.

func (*Driver) GetBatchBlockRange

func (d *Driver) GetBatchBlockRange(
	ctx context.Context) (*big.Int, *big.Int, error)

GetBatchBlockRange returns the start and end L2 block heights that need to be processed. Note that the end value is *exclusive*, therefore if the returned values are identical nothing needs to be processed.

func (*Driver) Metrics

func (d *Driver) Metrics() metrics.Metrics

Metrics returns the subservice telemetry object.

func (*Driver) Name

func (d *Driver) Name() string

Name is an identifier used to prefix logs for a particular service.

func (*Driver) SendTransaction

func (d *Driver) SendTransaction(
	ctx context.Context,
	tx *types.Transaction,
) error

SendTransaction injects a signed transaction into the pending pool for execution.

func (*Driver) UpdateGasPrice

func (d *Driver) UpdateGasPrice(
	ctx context.Context,
	tx *types.Transaction,
) (*types.Transaction, error)

UpdateGasPrice signs an otherwise identical txn to the one provided but with updated gas prices sampled from the existing network conditions.

NOTE: Thie method SHOULD NOT publish the resulting transaction.

func (*Driver) WalletAddr

func (d *Driver) WalletAddr() common.Address

WalletAddr is the wallet address used to pay for batch transaction fees.

type FilterStartBlockNumberParams

type FilterStartBlockNumberParams struct {
	// BlockNumber the current block height of the chain.
	BlockNumber uint64

	// NumConfirmations is the number of confirmations required to consider a
	// block final.
	NumConfirmations uint64

	// DeployBlockNumber is the deployment height of the Deposit contract.
	DeployBlockNumber uint64

	// LastProcessedBlockNumber is the height of the last processed block.
	//
	// NOTE: This will be nil on the first invocation, before blocks have been
	// ingested.
	LastProcessedBlockNumber *uint64
}

FilterStartBlockNumberParams holds the arguments passed to FindFilterStartBlockNumber.

type Metrics

type Metrics struct {
	*metrics.Base

	// FailedDatabaseMethods tracks the number of database failures for each
	// known database method.
	FailedDatabaseMethods *prometheus.CounterVec

	// DepositIDMismatch tracks whether or not our database is in sync with the
	// disrburser contract. 1 means in sync, 0 means out of sync.
	DepositIDMismatch prometheus.Gauge

	// MissingDisbursements tracks the number of deposits that are missing
	// disbursement below our supposed next deposit id.
	MissingDisbursements prometheus.Gauge

	// SuccessfulDisbursements tracks the number of disbursements that emit a
	// success event from a given tx.
	SuccessfulDisbursements prometheus.Counter

	// FailedDisbursements tracks the number of disbursements that emit a failed
	// event from a given tx.
	FailedDisbursements prometheus.Counter

	// PostgresLastDisbursedID tracks the latest disbursement id in postgres.
	PostgresLastDisbursedID prometheus.Gauge

	// ContractNextDisbursementID tracks the next disbursement id expected by
	// the disburser contract.
	ContractNextDisbursementID prometheus.Gauge

	// ContractNextDepositID tracks the next deposit id expected by the deposit
	// contract.
	ContractNextDepositID prometheus.Gauge

	// DisburserBalance tracks Teleportr's disburser account balance.
	DisburserBalance prometheus.Gauge

	// DepositContractBalance tracks Teleportr's deposit contract balance.
	DepositContractBalance prometheus.Gauge

	// FailedTXSubmissions tracks failed requests to eth_sendRawTransaction
	// during transaction submission.
	FailedTXSubmissions *prometheus.CounterVec
}

Metrics extends the BSS core metrics with additional metrics tracked by the sequencer driver.

func NewMetrics

func NewMetrics(subsystem string) *Metrics

NewMetrics initializes a new, extended metrics object.

Jump to

Keyboard shortcuts

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