aggregator

package
v0.0.2-RC20 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 38 Imported by: 0

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
	// contains filtered or unexported fields
}

Aggregator represents an aggregator

func New

func New(ctx context.Context, cfg Config, stateInterface stateInterface, 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 `mapstructure:"ForkId"`

	// 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"`

	// WitnessURL is the URL of the witness server
	WitnessURL string `mapstructure:"WitnessURL"`

	// LERContract is the contract address to get the LER from
	LERContract string `mapstructure:"LERContract"`

	// UseL1BatchData is a flag to enable the use of L1 batch data in the aggregator
	UseL1BatchData bool `mapstructure:"UseL1BatchData"`

	// UseFullWitness is a flag to enable the use of full witness in the aggregator
	UseFullWitness bool `mapstructure:"UseFullWitness"`

	// DB is the database configuration
	DB db.Config `mapstructure:"DB"`

	// StreamClient is the config for the stream client
	StreamClient StreamClientCfg `mapstructure:"StreamClient"`

	// EthTxManager is the config for the ethtxmanager
	EthTxManager ethtxmanager.Config `mapstructure:"EthTxManager"`

	// Log is the log configuration
	Log log.Config `mapstructure:"Log"`

	// Synchornizer config
	Synchronizer syncronizerConfig.Config `mapstructure:"Synchronizer"`
}

Config represents the configuration of the aggregator

type StreamClientCfg

type StreamClientCfg struct {
	// Datastream server to connect
	Server string `mapstructure:"Server"`
	// Log is the log configuration
	Log log.Config `mapstructure:"Log"`
}

StreamClientCfg contains the data streamer's configuration properties

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