aggregator

package
v0.3.3-RC3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ProfitabilityBase checks matic 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"`
}

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, maticCollateral *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 matic 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, maticCollateral *big.Int) (bool, error)

IsProfitable checks matic 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