Documentation ¶
Index ¶
- Constants
- func FirstToUpper(s string) string
- type Aggregator
- type Config
- type EthTxManagerClient
- type Etherman
- type ProverInterface
- type RPCInterface
- type SettlementBackend
- type StateInterface
- type TokenAmountWithDecimals
- type TxProfitabilityCheckerAcceptAll
- type TxProfitabilityCheckerBase
- type TxProfitabilityCheckerType
Constants ¶
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 ¶
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, logger *log.Logger, stateInterface StateInterface, etherman Etherman) (*Aggregator, error)
New creates a new aggregator.
func (*Aggregator) Channel ¶
func (a *Aggregator) Channel(stream prover.AggregatorService_ChannelServer) error
Channel implements the bi-directional communication channel between the Prover client and 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 is the interval duration for the main sequencer to check // if there are no transactions. If there are no transactions in this interval, the sequencer will // consolidate the batch anyway. 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"` //nolint:stylecheck // 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"` // RPCURL is the URL of the RPC server RPCURL string `mapstructure:"RPCURL"` // WitnessURL is the URL of the witness server WitnessURL string `mapstructure:"WitnessURL"` // 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"` // 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. // It can be settled directly to L1 or over Agglayer. 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"` // SyncModeOnlyEnabled is a flag that activates sync mode exclusively. // When enabled, the aggregator will sync data only from L1 and will not generate or read the data stream. SyncModeOnlyEnabled bool `mapstructure:"SyncModeOnlyEnabled"` }
Config represents the configuration of the aggregator
type EthTxManagerClient ¶ added in v0.3.0
type EthTxManagerClient interface { Add( ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *ethtypes.BlobTxSidecar, ) (common.Hash, error) AddWithGas( ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *ethtypes.BlobTxSidecar, gas uint64, ) (common.Hash, error) EncodeBlobData(data []byte) (kzg4844.Blob, error) MakeBlobSidecar(blobs []kzg4844.Blob) *ethtypes.BlobTxSidecar ProcessPendingMonitoredTxs(ctx context.Context, resultHandler ethtxmanager.ResultHandler) Remove(ctx context.Context, id common.Hash) error RemoveAll(ctx context.Context) error Result(ctx context.Context, id common.Hash) (ethtxtypes.MonitoredTxResult, error) ResultsByStatus(ctx context.Context, statuses []ethtxtypes.MonitoredTxStatus) ([]ethtxtypes.MonitoredTxResult, error) Start() Stop() }
EthTxManagerClient represents the eth tx manager interface
type Etherman ¶ added in v0.3.0
type Etherman interface { GetRollupId() uint32 GetLatestVerifiedBatchNum() (uint64, error) BuildTrustedVerifyBatchesTxData( lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address, ) (to *common.Address, data []byte, err error) GetLatestBlockHeader(ctx context.Context) (*ethtypes.Header, error) GetBatchAccInputHash(ctx context.Context, batchNumber uint64) (common.Hash, error) HeaderByNumber(ctx context.Context, number *big.Int) (*ethtypes.Header, error) }
Etherman contains the methods required to interact with ethereum
type ProverInterface ¶ added in v0.3.0
type ProverInterface interface { Name() string ID() string Addr() string IsIdle() (bool, error) BatchProof(input *prover.StatelessInputProver) (*string, error) AggregatedProof(inputProof1, inputProof2 string) (*string, error) FinalProof(inputProof string, aggregatorAddr string) (*string, error) WaitRecursiveProof(ctx context.Context, proofID string) (string, common.Hash, common.Hash, error) WaitFinalProof(ctx context.Context, proofID string) (*prover.FinalProof, error) }
type RPCInterface ¶
type RPCInterface interface { GetBatch(batchNumber uint64) (*types.RPCBatch, error) GetWitness(batchNumber uint64, fullWitness bool) ([]byte, error) }
Consumer interfaces required by the package.
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" // TenToThePowerOf18 represents 1000000000000000000 TenToThePowerOf18 = 1000000000000000000 )
type StateInterface ¶ added in v0.3.0
type StateInterface interface { BeginStateTransaction(ctx context.Context) (pgx.Tx, error) CheckProofContainsCompleteSequences(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) (bool, error) GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error) GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error) AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) CheckProofExistsForBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (bool, error) AddSequence(ctx context.Context, sequence state.Sequence, dbTx pgx.Tx) error }
StateInterface gathers the methods to interact with the state.
type TokenAmountWithDecimals ¶
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