aggsender

package
v0.2.0-beta7-bridge-tmp Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0, MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AutomaticBlockInterval = time.Second * 0
)

Variables

View Source
var ErrAgglayerInconsistence = errors.New("recovery: agglayer inconsistence")

Functions

func NewCertificateInfoFromAgglayerCertHeader

func NewCertificateInfoFromAgglayerCertHeader(c *agglayertypes.CertificateHeader) *types.CertificateInfo

Types

type AggSender

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

AggSender is a component that will send certificates to the aggLayer

func New

func New(
	ctx context.Context,
	logger *log.Logger,
	cfg Config,
	aggLayerClient agglayer.AgglayerClientInterface,
	l1InfoTreeSyncer *l1infotreesync.L1InfoTreeSync,
	l2Syncer types.L2BridgeSyncer,
	epochNotifier types.EpochNotifier,
	l1Client types.EthClient,
	l2Client types.EthClient) (*AggSender, error)

New returns a new AggSender instance

func (*AggSender) GetRPCServices

func (a *AggSender) GetRPCServices() []jRPC.Service

GetRPCServices returns the list of services that the RPC provider exposes

func (*AggSender) Info

func (a *AggSender) Info() types.AggsenderInfo

func (*AggSender) Start

func (a *AggSender) Start(ctx context.Context)

Start starts the AggSender

type BlockNotifierPolling

type BlockNotifierPolling struct {
	types.GenericSubscriber[types.EventNewBlock]
	// contains filtered or unexported fields
}

func NewBlockNotifierPolling

func NewBlockNotifierPolling(ethClient types.EthClient,
	config ConfigBlockNotifierPolling,
	logger aggkitcommon.Logger,
	subscriber types.GenericSubscriber[types.EventNewBlock]) (*BlockNotifierPolling, error)

NewBlockNotifierPolling creates a new BlockNotifierPolling. if param `subscriber` is nil a new GenericSubscriberImpl[types.EventNewBlock] will be created. To use this class you need to subscribe and each time that a new block appear the subscriber will be notified through the channel. (check unit tests TestExploratoryBlockNotifierPolling for more information)

func (*BlockNotifierPolling) GetCurrentBlockNumber added in v0.0.2

func (b *BlockNotifierPolling) GetCurrentBlockNumber() uint64

func (*BlockNotifierPolling) Start

func (b *BlockNotifierPolling) Start(ctx context.Context)

Start starts the BlockNotifierPolling blocking the current goroutine

func (*BlockNotifierPolling) String

func (b *BlockNotifierPolling) String() string

type Config

type Config struct {
	// StoragePath is the path of the sqlite db on which the AggSender will store the data
	StoragePath string `mapstructure:"StoragePath"`
	// AggLayerURL is the URL of the AggLayer
	AggLayerURL string `mapstructure:"AggLayerURL"`
	// AggsenderPrivateKey is the private key which is used to sign certificates
	AggsenderPrivateKey signertypes.SignerConfig `mapstructure:"AggsenderPrivateKey"`
	// URLRPCL2 is the URL of the L2 RPC node
	URLRPCL2 string `mapstructure:"URLRPCL2"`
	// BlockFinality indicates which finality the AggLayer follows
	BlockFinality string `` //nolint:lll
	/* 134-byte string literal not displayed */
	// EpochNotificationPercentage indicates the percentage of the epoch
	// the AggSender should send the certificate
	// 0 -> Begin
	// 50 -> Middle
	EpochNotificationPercentage uint `mapstructure:"EpochNotificationPercentage"`
	// MaxRetriesStoreCertificate is the maximum number of retries to store a certificate
	// 0 is infinite
	MaxRetriesStoreCertificate int `mapstructure:"MaxRetriesStoreCertificate"`
	// DelayBeetweenRetries is the delay between retries:
	//  is used on store Certificate and also in initial check
	DelayBeetweenRetries types.Duration `mapstructure:"DelayBeetweenRetries"`
	// KeepCertificatesHistory is a flag to keep the certificates history on storage
	KeepCertificatesHistory bool `mapstructure:"KeepCertificatesHistory"`
	// MaxCertSize is the maximum size of the certificate (the emitted certificate cannot be bigger that this size)
	// 0 is infinite
	MaxCertSize uint `mapstructure:"MaxCertSize"`
	// BridgeMetadataAsHash is a flag to import the bridge metadata as hash
	BridgeMetadataAsHash bool `mapstructure:"BridgeMetadataAsHash"`
	// DryRun is a flag to enable the dry run mode
	// in this mode the AggSender will not send the certificates to Agglayer
	DryRun bool `mapstructure:"DryRun"`
	// EnableRPC is a flag to enable the RPC for aggsender
	EnableRPC bool `mapstructure:"EnableRPC"`
	// AggchainProofURL is the URL of the AggkitProver
	AggchainProofURL string `mapstructure:"AggchainProofURL"`
	// Mode is the mode of the AggSender (regular pessimistic proof mode or the aggchain proof mode)
	Mode string `jsonschema:"enum=PessimisticProof, enum=AggchainProof" mapstructure:"Mode"`
	// CheckStatusCertificateInterval is the interval at which the AggSender will check the certificate status in Agglayer
	CheckStatusCertificateInterval types.Duration `mapstructure:"CheckStatusCertificateInterval"`
	// RetryCertAfterInError when a cert pass to 'InError'
	// state the AggSender will try to resend it immediately
	RetryCertAfterInError bool `mapstructure:"RetryCertAfterInError"`
	// MaxEpochPercentageAllowedToSendCertificate is the percentage of the epoch
	// after which the AggSender is forbidden to send the certificate.
	// If value==0  || value >= 100 the check is disabled
	// 0 -> Begin
	// 50 -> Middle
	// 100 -> End
	MaxEpochPercentageAllowedToSendCertificate uint `mapstructure:"MaxEpochPercentageAllowedToSendCertificate"`
	// MaxSubmitCertificateRate is the maximum rate of certificate submission allowed
	MaxSubmitCertificateRate common.RateLimitConfig `mapstructure:"MaxSubmitCertificateRate"`
	// GlobalExitRootL2Addr is the address of the GlobalExitRootManager contract on l2 sovereign chain
	// this address is needed for the AggchainProof mode of the AggSender
	GlobalExitRootL2Addr ethCommon.Address `mapstructure:"GlobalExitRootL2"`
	// GenerateAggchainProofTimeout is the timeout to wait for the aggkit-prover to generate the AggchainProof
	GenerateAggchainProofTimeout types.Duration `mapstructure:"GenerateAggchainProofTimeout"`
	// SovereignRollupAddr is the address of the sovereign rollup contract on L1
	SovereignRollupAddr ethCommon.Address `mapstructure:"SovereignRollupAddr"`
	// RequireStorageContentCompatibility is true it's mandatory that data stored in the database
	// is compatible with the running environment
	RequireStorageContentCompatibility bool `mapstructure:"RequireStorageContentCompatibility"`
}

Config is the configuration for the AggSender

func (Config) CheckCertConfigBriefString added in v0.0.2

func (c Config) CheckCertConfigBriefString() string

func (Config) String

func (c Config) String() string

String returns a string representation of the Config

type ConfigBlockNotifierPolling

type ConfigBlockNotifierPolling struct {
	// BlockFinalityType is the finality of the block to be notified
	BlockFinalityType etherman.BlockNumberFinality
	// CheckNewBlockInterval is the interval at which the AggSender will check for new blocks
	// if is 0 it will be calculated automatically
	CheckNewBlockInterval time.Duration
}

type ConfigEpochNotifierPerBlock

type ConfigEpochNotifierPerBlock struct {
	StartingEpochBlock uint64
	NumBlockPerEpoch   uint

	// EpochNotificationPercentage
	// 0 -> begin new Epoch
	// 50 -> middle of epoch
	// 100 -> end of epoch (same as 0)
	EpochNotificationPercentage uint
}

func NewConfigEpochNotifierPerBlock

func NewConfigEpochNotifierPerBlock(ctx context.Context,
	aggLayer agglayer.AggLayerClientGetEpochConfiguration,
	epochNotificationPercentage uint) (*ConfigEpochNotifierPerBlock, error)

func (*ConfigEpochNotifierPerBlock) String

func (c *ConfigEpochNotifierPerBlock) String() string

func (*ConfigEpochNotifierPerBlock) Validate

func (c *ConfigEpochNotifierPerBlock) Validate() error

type EpochNotifierPerBlock

type EpochNotifierPerBlock struct {
	Config ConfigEpochNotifierPerBlock
	types.GenericSubscriber[types.EpochEvent]
	// contains filtered or unexported fields
}

func (*EpochNotifierPerBlock) GetEpochStatus added in v0.0.2

func (e *EpochNotifierPerBlock) GetEpochStatus() types.EpochStatus

GetCurrentStatus returns the current status of the epoch

func (*EpochNotifierPerBlock) Start

func (e *EpochNotifierPerBlock) Start(ctx context.Context)

Start starts the notifier synchronously

func (*EpochNotifierPerBlock) StartAsync

func (e *EpochNotifierPerBlock) StartAsync(ctx context.Context)

StartAsync starts the notifier in a goroutine

func (*EpochNotifierPerBlock) String

func (e *EpochNotifierPerBlock) String() string

type ExtraInfoEventEpoch

type ExtraInfoEventEpoch struct {
	PendingBlocks int
}

func (*ExtraInfoEventEpoch) String

func (e *ExtraInfoEventEpoch) String() string

type GenericSubscriberImpl

type GenericSubscriberImpl[T any] struct {
	// contains filtered or unexported fields
}

func NewGenericSubscriberImpl

func NewGenericSubscriberImpl[T any]() *GenericSubscriberImpl[T]

func (*GenericSubscriberImpl[T]) Publish

func (g *GenericSubscriberImpl[T]) Publish(data T)

func (*GenericSubscriberImpl[T]) Subscribe

func (g *GenericSubscriberImpl[T]) Subscribe(subscriberName string) <-chan T

type InitialStatus added in v0.0.2

type InitialStatus struct {
	SettledCert *agglayertypes.CertificateHeader
	PendingCert *agglayertypes.CertificateHeader
	LocalCert   *types.CertificateInfo
	// contains filtered or unexported fields
}

func NewInitialStatus added in v0.0.2

func NewInitialStatus(ctx context.Context,
	log types.Logger, networkID uint32,
	storage db.AggSenderStorage,
	aggLayerClient agglayer.AggLayerClientRecoveryQuerier) (*InitialStatus, error)

NewInitialStatus creates a new InitialStatus object, get the data from AggLayer and local storage

func (*InitialStatus) LogData added in v0.0.2

func (i *InitialStatus) LogData()

LogData logs the data from the InitialStatus object

func (*InitialStatus) Process added in v0.0.2

func (i *InitialStatus) Process() (*InitialStatusResult, error)

Process checks the last certificates from agglayer vs local certificates and returns the action to take

type InitialStatusAction added in v0.0.2

type InitialStatusAction int
const (
	InitialStatusActionNone InitialStatusAction = iota
	InitialStatusActionUpdateCurrentCert
	InitialStatusActionInsertNewCert
)

func (InitialStatusAction) String added in v0.0.2

func (i InitialStatusAction) String() string

String representation of the enum

type InitialStatusResult added in v0.0.2

type InitialStatusResult struct {
	Action  InitialStatusAction
	Message string
	Cert    *agglayertypes.CertificateHeader
}

func (*InitialStatusResult) String added in v0.0.2

func (i *InitialStatusResult) String() string

type RateLimiter added in v0.0.2

type RateLimiter interface {
	Call(msg string, allowToSleep bool) *time.Duration
	String() string
}

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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