aggregator

package
v0.6.1-RC3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ProfitabilityBase checks pol collateral with min reward
	ProfitabilityBase = "base"
	// ProfitabilityAcceptAll validate batch anyway and don't check anything
	ProfitabilityAcceptAll = "acceptall"
)

Variables

This section is empty.

Functions

func FirstToUpper

func FirstToUpper(s string) string

FirstToUpper returns the string passed as argument with the first letter in uppercase.

Types

type Aggregator

type Aggregator struct {
	prover.UnimplementedAggregatorServiceServer

	State                   stateInterface
	EthTxManager            ethTxManager
	Ethman                  etherman
	ProfitabilityChecker    aggregatorTxProfitabilityChecker
	TimeSendFinalProof      time.Time
	TimeCleanupLockedProofs types.Duration
	StateDBMutex            *sync.Mutex
	TimeSendFinalProofMutex *sync.RWMutex
	// contains filtered or unexported fields
}

Aggregator represents an aggregator

func New

func New(
	cfg Config,
	stateInterface stateInterface,
	ethTxManager ethTxManager,
	etherman etherman,
) (Aggregator, error)

New creates a new aggregator.

func (*Aggregator) Channel

Channel implements the bi-directional communication channel between the Prover client and the Aggregator server.

func (*Aggregator) Start

func (a *Aggregator) Start(ctx context.Context) error

Start starts the aggregator

func (*Aggregator) Stop

func (a *Aggregator) Stop()

Stop stops the Aggregator server.

type Config

type Config struct {
	// Host for the grpc server
	Host string `mapstructure:"Host"`
	// Port for the grpc server
	Port int `mapstructure:"Port"`

	// RetryTime is the time the aggregator main loop sleeps if there are no proofs to aggregate
	// or batches to generate proofs. It is also used in the isSynced loop
	RetryTime types.Duration `mapstructure:"RetryTime"`

	// VerifyProofInterval is the interval of time to verify/send an proof in L1
	VerifyProofInterval types.Duration `mapstructure:"VerifyProofInterval"`

	// ProofStatePollingInterval is the interval time to polling the prover about the generation state of a proof
	ProofStatePollingInterval types.Duration `mapstructure:"ProofStatePollingInterval"`

	// TxProfitabilityCheckerType type for checking is it profitable for aggregator to validate batch
	// possible values: base/acceptall
	TxProfitabilityCheckerType TxProfitabilityCheckerType `mapstructure:"TxProfitabilityCheckerType"`

	// TxProfitabilityMinReward min reward for base tx profitability checker when aggregator will validate batch
	// this parameter is used for the base tx profitability checker
	TxProfitabilityMinReward TokenAmountWithDecimals `mapstructure:"TxProfitabilityMinReward"`

	// IntervalAfterWhichBatchConsolidateAnyway this is interval for the main sequencer, that will check if there is no transactions
	IntervalAfterWhichBatchConsolidateAnyway types.Duration `mapstructure:"IntervalAfterWhichBatchConsolidateAnyway"`

	// ChainID is the L2 ChainID provided by the Network Config
	ChainID uint64

	// ForkID is the L2 ForkID provided by the Network Config
	ForkId uint64

	// SenderAddress defines which private key the eth tx manager needs to use
	// to sign the L1 txs
	SenderAddress string `mapstructure:"SenderAddress"`

	// CleanupLockedProofsInterval is the interval of time to clean up locked proofs.
	CleanupLockedProofsInterval types.Duration `mapstructure:"CleanupLockedProofsInterval"`

	// GeneratingProofCleanupThreshold represents the time interval after
	// which a proof in generating state is considered to be stuck and
	// allowed to be cleared.
	GeneratingProofCleanupThreshold string `mapstructure:"GeneratingProofCleanupThreshold"`

	// GasOffset is the amount of gas to be added to the gas estimation in order
	// to provide an amount that is higher than the estimated one. This is used
	// to avoid the TX getting reverted in case something has changed in the network
	// state after the estimation which can cause the TX to require more gas to be
	// executed.
	//
	// ex:
	// gas estimation: 1000
	// gas offset: 100
	// final gas: 1100
	GasOffset uint64 `mapstructure:"GasOffset"`

	// UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog
	UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"`

	// BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch
	BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"`
}

Config represents the configuration of the aggregator

type TokenAmountWithDecimals

type TokenAmountWithDecimals struct {
	*big.Int `validate:"required"`
}

TokenAmountWithDecimals is a wrapper type that parses token amount with decimals to big int

func (*TokenAmountWithDecimals) UnmarshalText

func (t *TokenAmountWithDecimals) UnmarshalText(data []byte) error

UnmarshalText unmarshal token amount from float string to big int

type TxProfitabilityCheckerAcceptAll

type TxProfitabilityCheckerAcceptAll struct {
	State                             stateInterface
	IntervalAfterWhichBatchSentAnyway time.Duration
}

TxProfitabilityCheckerAcceptAll validate batch anyway and don't check anything

func NewTxProfitabilityCheckerAcceptAll

func NewTxProfitabilityCheckerAcceptAll(state stateInterface, interval time.Duration) *TxProfitabilityCheckerAcceptAll

NewTxProfitabilityCheckerAcceptAll init tx profitability checker that accept all txs

func (*TxProfitabilityCheckerAcceptAll) IsProfitable

func (pc *TxProfitabilityCheckerAcceptAll) IsProfitable(ctx context.Context, polCollateral *big.Int) (bool, error)

IsProfitable validate batch anyway and don't check anything

type TxProfitabilityCheckerBase

type TxProfitabilityCheckerBase struct {
	State                             stateInterface
	IntervalAfterWhichBatchSentAnyway time.Duration
	MinReward                         *big.Int
}

TxProfitabilityCheckerBase checks pol collateral with min reward

func NewTxProfitabilityCheckerBase

func NewTxProfitabilityCheckerBase(state stateInterface, interval time.Duration, minReward *big.Int) *TxProfitabilityCheckerBase

NewTxProfitabilityCheckerBase init base tx profitability checker

func (*TxProfitabilityCheckerBase) IsProfitable

func (pc *TxProfitabilityCheckerBase) IsProfitable(ctx context.Context, polCollateral *big.Int) (bool, error)

IsProfitable checks pol collateral with min reward

type TxProfitabilityCheckerType

type TxProfitabilityCheckerType string

TxProfitabilityCheckerType checks profitability of batch validation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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