aggregator

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 44 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 AggLayerClient

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

AggLayerClient is the client that will be used to interact with the AggLayer

func NewAggLayerClient

func NewAggLayerClient(url string) *AggLayerClient

NewAggLayerClient returns a client ready to be used

func (*AggLayerClient) SendTx

func (c *AggLayerClient) SendTx(signedTx SignedTx) (common.Hash, error)

SendTx sends a signed transaction to the AggLayer

func (*AggLayerClient) WaitTxToBeMined

func (c *AggLayerClient) WaitTxToBeMined(hash common.Hash, ctx context.Context) error

WaitTxToBeMined waits for a transaction to be mined

type AgglayerClientInterface

type AgglayerClientInterface interface {
	SendTx(signedTx SignedTx) (common.Hash, error)
	WaitTxToBeMined(hash common.Hash, ctx context.Context) error
}

AgglayerClientInterface is the interface that defines the methods that the AggLayerClient will implement

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

	// BatchProofSanityCheckEnabled is a flag to enable the sanity check of the batch proof
	BatchProofSanityCheckEnabled bool `mapstructure:"BatchProofSanityCheckEnabled"`

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

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

	// SettlementBackend configuration defines how a final ZKP should be settled. Directly to L1 or over the Beethoven service.
	SettlementBackend SettlementBackend `mapstructure:"SettlementBackend" jsonschema:"enum=agglayer,enum=l1"`

	// SequencerPrivateKey Private key of the trusted sequencer
	SequencerPrivateKey types.KeystoreFileConfig `mapstructure:"SequencerPrivateKey"`

	// AggLayerTxTimeout is the interval time to wait for a tx to be mined from the agglayer
	AggLayerTxTimeout types.Duration `mapstructure:"AggLayerTxTimeout"`

	// AggLayerURL url of the agglayer service
	AggLayerURL string `mapstructure:"AggLayerURL"`

	// MaxWitnessRetrievalWorkers is the maximum number of workers that will be used to retrieve the witness
	MaxWitnessRetrievalWorkers int `mapstructure:"MaxWitnessRetrievalWorkers"`

	// SyncModeOnlyEnabled is a flag to enable the sync mode only
	// In this mode the aggregator will only sync from L1 and will not generate or read the data stream
	SyncModeOnlyEnabled bool `mapstructure:"SyncModeOnlyEnabled"`
}

Config represents the configuration of the aggregator

type SettlementBackend

type SettlementBackend string

SettlementBackend is the type of the settlement backend

const (
	// AggLayer settlement backend
	AggLayer SettlementBackend = "agglayer"

	// L1 settlement backend
	L1 SettlementBackend = "l1"
)

type SignedTx

type SignedTx struct {
	Tx        Tx             `json:"tx"`
	Signature types.ArgBytes `json:"signature"`
}

SignedTx is the struct that contains the signed batch transaction

func (*SignedTx) Signer

func (s *SignedTx) Signer() (common.Address, error)

Signer returns the address of the signer

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 Tx

type Tx struct {
	RollupID          uint32
	LastVerifiedBatch types.ArgUint64 `json:"lastVerifiedBatch"`
	NewVerifiedBatch  types.ArgUint64 `json:"newVerifiedBatch"`
	ZKP               ZKP             `json:"ZKP"`
}

Tx is the struct that contains the verified batch transaction

func (*Tx) Hash

func (t *Tx) Hash() common.Hash

Hash returns a hash that uniquely identifies the tx

func (*Tx) Sign

func (t *Tx) Sign(privateKey *ecdsa.PrivateKey) (*SignedTx, error)

Sign returns a signed batch by the private key

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

type ZKP

type ZKP struct {
	NewStateRoot     common.Hash    `json:"newStateRoot"`
	NewLocalExitRoot common.Hash    `json:"newLocalExitRoot"`
	Proof            types.ArgBytes `json:"proof"`
}

ZKP is the struct that contains the zero-knowledge proof

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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