Documentation
¶
Index ¶
- Variables
- type APIRateLimitConfig
- type AggLayerClientCertificateIDQuerier
- type AggLayerClientGetEpochConfiguration
- type AggLayerClientRecoveryQuerier
- type AgglayerClientCache
- func (c *AgglayerClientCache) GetCertificateHeader(ctx context.Context, certificateID common.Hash) (*agglayertypes.CertificateHeader, error)
- func (c *AgglayerClientCache) GetEpochConfiguration(ctx context.Context) (*agglayertypes.ClockConfiguration, error)
- func (c *AgglayerClientCache) GetLatestPendingCertificateHeader(ctx context.Context, networkID uint32) (*agglayertypes.CertificateHeader, error)
- func (c *AgglayerClientCache) GetLatestSettledCertificateHeader(ctx context.Context, networkID uint32) (*agglayertypes.CertificateHeader, error)
- func (c *AgglayerClientCache) GetNetworkInfo(ctx context.Context, networkID uint32) (agglayertypes.NetworkInfo, error)
- func (c *AgglayerClientCache) SendCertificate(ctx context.Context, certificate *agglayertypes.Certificate) (common.Hash, error)
- type AgglayerClientInterface
- type CacheConfig
- type ClientConfig
- type RateLimitWrapper
- func (r *RateLimitWrapper) GetCertificateHeader(ctx context.Context, certificateHash ethCommon.Hash) (*types.CertificateHeader, error)
- func (r *RateLimitWrapper) GetEpochConfiguration(ctx context.Context) (*types.ClockConfiguration, error)
- func (r *RateLimitWrapper) GetLatestPendingCertificateHeader(ctx context.Context, networkID uint32) (*types.CertificateHeader, error)
- func (r *RateLimitWrapper) GetLatestSettledCertificateHeader(ctx context.Context, networkID uint32) (*types.CertificateHeader, error)
- func (r *RateLimitWrapper) GetNetworkInfo(ctx context.Context, networkID uint32) (types.NetworkInfo, error)
- func (r *RateLimitWrapper) SendCertificate(ctx context.Context, certificate *types.Certificate) (ethCommon.Hash, error)
- func (r *RateLimitWrapper) String() string
- type SignedTx
- type Tx
- type ZKP
Constants ¶
This section is empty.
Variables ¶
var ErrAgglayerRateLimitExceeded = errors.New("agglayer rate limit exceeded")
Functions ¶
This section is empty.
Types ¶
type APIRateLimitConfig ¶ added in v0.7.0
type APIRateLimitConfig struct {
// MethodName is the name of the API method (e.g., "SendCertificate", "GetEpochConfiguration")
MethodName string `mapstructure:"MethodName"`
// RateLimit is the rate limiting configuration for this method
RateLimit common.RateLimitConfig `mapstructure:"RateLimit"`
}
APIRateLimitConfig defines rate limiting configuration for specific API methods
func (APIRateLimitConfig) String ¶ added in v0.7.0
func (a APIRateLimitConfig) String() string
String returns a string representation of the APIRateLimitConfig
type AggLayerClientCertificateIDQuerier ¶ added in v0.7.0
type AggLayerClientGetEpochConfiguration ¶
type AggLayerClientGetEpochConfiguration interface {
GetEpochConfiguration(ctx context.Context) (*types.ClockConfiguration, error)
}
type AggLayerClientRecoveryQuerier ¶ added in v0.0.2
type AgglayerClientCache ¶ added in v0.7.0
type AgglayerClientCache struct {
// contains filtered or unexported fields
}
AgglayerClientCache provides a caching layer for agglayer client using a TTL (time-to-live) cache. It interacts with an AgglayerClientInterface to fetch certificate headers as needed and stores them in a cache keyed by common.Hash. This helps reduce redundant network calls and improves performance by serving frequently accessed certificate headers from the cache.
func NewCertificateCache ¶ added in v0.7.0
func NewCertificateCache( agglayerClient AgglayerClientInterface, ttl time.Duration, capacity uint64) *AgglayerClientCache
NewCertificateCache creates and returns a new AgglayerClientCache instance with the specified Agglayer client, time-to-live (TTL) duration for cache entries, and maximum cache capacity. The cache stores certificate headers indexed by their hash and automatically evicts entries based on the provided TTL and capacity constraints.
func (*AgglayerClientCache) GetCertificateHeader ¶ added in v0.7.0
func (c *AgglayerClientCache) GetCertificateHeader( ctx context.Context, certificateID common.Hash) (*agglayertypes.CertificateHeader, error)
GetCertificateHeader retrieves the certificate header associated with the given certificateID. It first attempts to fetch the certificate header from the local cache. If the header is not present in the cache, it fetches it from the agglayer client, stores it in the cache with the default TTL, and then returns it. Returns an error if the certificate header cannot be retrieved from the agglayer client.
Parameters:
- ctx: The context for controlling cancellation and deadlines.
- certificateID: The unique identifier (hash) of the certificate.
Returns:
- *agglayertypes.CertificateHeader: The retrieved certificate header.
- error: An error if the certificate header could not be retrieved.
func (*AgglayerClientCache) GetEpochConfiguration ¶ added in v0.7.0
func (c *AgglayerClientCache) GetEpochConfiguration(ctx context.Context) (*agglayertypes.ClockConfiguration, error)
GetEpochConfiguration retrieves the current epoch configuration from the Agglayer client. (no cache)
func (*AgglayerClientCache) GetLatestPendingCertificateHeader ¶ added in v0.7.0
func (c *AgglayerClientCache) GetLatestPendingCertificateHeader(ctx context.Context, networkID uint32) (*agglayertypes.CertificateHeader, error)
GetLatestPendingCertificateHeader retrieves the latest pending certificate header for a given network ID. (no cache)
func (*AgglayerClientCache) GetLatestSettledCertificateHeader ¶ added in v0.7.0
func (c *AgglayerClientCache) GetLatestSettledCertificateHeader(ctx context.Context, networkID uint32) (*agglayertypes.CertificateHeader, error)
GetLatestSettledCertificateHeader retrieves the latest settled certificate header for a given network ID. (no cache)
func (*AgglayerClientCache) GetNetworkInfo ¶ added in v0.7.0
func (c *AgglayerClientCache) GetNetworkInfo( ctx context.Context, networkID uint32) (agglayertypes.NetworkInfo, error)
GetNetworkInfo retrieves the network state for a given network ID from the Agglayer client. (no cache)
func (*AgglayerClientCache) SendCertificate ¶ added in v0.7.0
func (c *AgglayerClientCache) SendCertificate( ctx context.Context, certificate *agglayertypes.Certificate) (common.Hash, error)
SendCertificate sends a certificate to the Agglayer client. (no cache)
type AgglayerClientInterface ¶
type AgglayerClientInterface interface {
SendCertificate(ctx context.Context, certificate *types.Certificate) (common.Hash, error)
GetCertificateHeader(ctx context.Context, certificateHash common.Hash) (*types.CertificateHeader, error)
GetNetworkInfo(ctx context.Context, networkID uint32) (types.NetworkInfo, error)
AggLayerClientGetEpochConfiguration
AggLayerClientRecoveryQuerier
AggLayerClientCertificateIDQuerier
}
AgglayerClientInterface is the interface that defines the methods that the AggLayerClient will implement
func NewAgglayerClient ¶ added in v0.7.0
func NewAgglayerClient(cfg ClientConfig, logger aggkitcommon.Logger) (AgglayerClientInterface, error)
type CacheConfig ¶ added in v0.7.0
type CacheConfig struct {
// TTL that an item is valid in the cache before it is considered stale.
TTL types.Duration
// Capacity is the maximum number of items that can be stored in the cache.
// If the cache exceeds this capacity, it will evict the least recently used items.
Capacity uint64
}
func (*CacheConfig) String ¶ added in v0.7.0
func (c *CacheConfig) String() string
func (*CacheConfig) Validate ¶ added in v0.7.0
func (c *CacheConfig) Validate() error
Validate checks if the configuration cache settings are valid.
type ClientConfig ¶ added in v0.7.0
type ClientConfig struct {
GRPC *aggkitgrpc.ClientConfig
Cached bool
ConfigurationCache *CacheConfig
// APIRateLimits defines rate limiting configuration for specific API methods
// If empty, no rate limiting is applied
APIRateLimits []APIRateLimitConfig `mapstructure:"APIRateLimits"`
}
func (*ClientConfig) String ¶ added in v0.7.0
func (c *ClientConfig) String() string
func (*ClientConfig) Validate ¶ added in v0.7.0
func (c *ClientConfig) Validate() error
Validate checks if the client configuration is valid.
type RateLimitWrapper ¶ added in v0.7.0
type RateLimitWrapper struct {
// contains filtered or unexported fields
}
RateLimitWrapper wraps an AgglayerClientInterface and applies rate limiting based on configuration
func NewRateLimitWrapper ¶ added in v0.7.0
func NewRateLimitWrapper( client AgglayerClientInterface, config ClientConfig, logger aggkitcommon.Logger, ) *RateLimitWrapper
NewRateLimitWrapper creates a new rate limiting wrapper around an agglayer client
func (*RateLimitWrapper) GetCertificateHeader ¶ added in v0.7.0
func (r *RateLimitWrapper) GetCertificateHeader( ctx context.Context, certificateHash ethCommon.Hash, ) (*types.CertificateHeader, error)
GetCertificateHeader gets a certificate header with rate limiting
func (*RateLimitWrapper) GetEpochConfiguration ¶ added in v0.7.0
func (r *RateLimitWrapper) GetEpochConfiguration(ctx context.Context) (*types.ClockConfiguration, error)
GetEpochConfiguration gets epoch configuration with rate limiting
func (*RateLimitWrapper) GetLatestPendingCertificateHeader ¶ added in v0.7.0
func (r *RateLimitWrapper) GetLatestPendingCertificateHeader( ctx context.Context, networkID uint32, ) (*types.CertificateHeader, error)
GetLatestPendingCertificateHeader gets the latest pending certificate header with rate limiting
func (*RateLimitWrapper) GetLatestSettledCertificateHeader ¶ added in v0.7.0
func (r *RateLimitWrapper) GetLatestSettledCertificateHeader( ctx context.Context, networkID uint32, ) (*types.CertificateHeader, error)
GetLatestSettledCertificateHeader gets the latest settled certificate header with rate limiting
func (*RateLimitWrapper) GetNetworkInfo ¶ added in v0.7.0
func (r *RateLimitWrapper) GetNetworkInfo( ctx context.Context, networkID uint32, ) (types.NetworkInfo, error)
GetNetworkInfo gets a network info with rate limiting
func (*RateLimitWrapper) SendCertificate ¶ added in v0.7.0
func (r *RateLimitWrapper) SendCertificate( ctx context.Context, certificate *types.Certificate, ) (ethCommon.Hash, error)
SendCertificate sends a certificate to the AggLayer with rate limiting
func (*RateLimitWrapper) String ¶ added in v0.7.0
func (r *RateLimitWrapper) String() string
String returns a string representation of the rate limit wrapper
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