From 25b84cc7d5294193c01104d537f15842bddb9c6f Mon Sep 17 00:00:00 2001 From: hopeyen Date: Thu, 12 Dec 2024 13:06:52 -0800 Subject: [PATCH] fix: tests --- disperser/apiserver/server_v2.go | 18 +++--- disperser/cmd/apiserver/config.go | 86 +++++++++++++------------- disperser/cmd/apiserver/flags/flags.go | 27 +++----- disperser/cmd/apiserver/main.go | 2 +- inabox/deploy/config.go | 4 ++ inabox/deploy/env_vars.go | 4 ++ 6 files changed, 70 insertions(+), 71 deletions(-) diff --git a/disperser/apiserver/server_v2.go b/disperser/apiserver/server_v2.go index d5a04e458..6727815f9 100644 --- a/disperser/apiserver/server_v2.go +++ b/disperser/apiserver/server_v2.go @@ -54,10 +54,10 @@ type DispersalServerV2 struct { logger logging.Logger // state - onchainState atomic.Pointer[OnchainState] - maxNumSymbolsPerBlob uint64 - onchainStateRefreshInterval time.Duration - offchainStatePruningInterval time.Duration + onchainState atomic.Pointer[OnchainState] + maxNumSymbolsPerBlob uint64 + onchainStateRefreshInterval time.Duration + OffchainPruneInterval time.Duration metrics *metricsV2 } @@ -73,7 +73,7 @@ func NewDispersalServerV2( prover encoding.Prover, maxNumSymbolsPerBlob uint64, onchainStateRefreshInterval time.Duration, - offchainStatePruningInterval time.Duration, + OffchainPruneInterval time.Duration, _logger logging.Logger, registry *prometheus.Registry, ) *DispersalServerV2 { @@ -90,9 +90,9 @@ func NewDispersalServerV2( prover: prover, logger: logger, - maxNumSymbolsPerBlob: maxNumSymbolsPerBlob, - onchainStateRefreshInterval: onchainStateRefreshInterval, - offchainStatePruningInterval: offchainStatePruningInterval, + maxNumSymbolsPerBlob: maxNumSymbolsPerBlob, + onchainStateRefreshInterval: onchainStateRefreshInterval, + OffchainPruneInterval: OffchainPruneInterval, metrics: newAPIServerV2Metrics(registry), } @@ -140,7 +140,7 @@ func (s *DispersalServerV2) Start(ctx context.Context) error { }() go func() { - ticker := time.NewTicker(s.offchainStatePruningInterval) + ticker := time.NewTicker(s.OffchainPruneInterval) defer ticker.Stop() for { diff --git a/disperser/cmd/apiserver/config.go b/disperser/cmd/apiserver/config.go index 7434fec2a..72ab68402 100644 --- a/disperser/cmd/apiserver/config.go +++ b/disperser/cmd/apiserver/config.go @@ -24,31 +24,30 @@ const ( ) type Config struct { - DisperserVersion DisperserVersion - AwsClientConfig aws.ClientConfig - BlobstoreConfig blobstore.Config - ServerConfig disperser.ServerConfig - LoggerConfig common.LoggerConfig - MetricsConfig disperser.MetricsConfig - RatelimiterConfig ratelimit.Config - RateConfig apiserver.RateConfig - EncodingConfig kzg.KzgConfig - EnableRatelimiter bool - EnablePaymentMeterer bool - OnchainUpdateInterval int - OffchainPruneInterval int - OffchainMaxOnDemandStorage int - ChainReadTimeout int - ReservationsTableName string - OnDemandTableName string - GlobalRateTableName string - BucketTableName string - BucketStoreSize int - EthClientConfig geth.EthClientConfig - MaxBlobSize int - MaxNumSymbolsPerBlob uint - OnchainStateRefreshInterval time.Duration - OffchainStatePruningInterval time.Duration + DisperserVersion DisperserVersion + AwsClientConfig aws.ClientConfig + BlobstoreConfig blobstore.Config + ServerConfig disperser.ServerConfig + LoggerConfig common.LoggerConfig + MetricsConfig disperser.MetricsConfig + RatelimiterConfig ratelimit.Config + RateConfig apiserver.RateConfig + EncodingConfig kzg.KzgConfig + EnableRatelimiter bool + EnablePaymentMeterer bool + OnchainUpdateInterval int + OffchainMaxOnDemandStorage int + ChainReadTimeout int + ReservationsTableName string + OnDemandTableName string + GlobalRateTableName string + BucketTableName string + BucketStoreSize int + EthClientConfig geth.EthClientConfig + MaxBlobSize int + MaxNumSymbolsPerBlob uint + OnchainStateRefreshInterval time.Duration + OffchainPruneInterval time.Duration BLSOperatorStateRetrieverAddr string EigenDAServiceManagerAddr string @@ -112,25 +111,24 @@ func NewConfig(ctx *cli.Context) (Config, error) { HTTPPort: ctx.GlobalString(flags.MetricsHTTPPort.Name), EnableMetrics: ctx.GlobalBool(flags.EnableMetrics.Name), }, - RatelimiterConfig: ratelimiterConfig, - RateConfig: rateConfig, - EncodingConfig: encodingConfig, - EnableRatelimiter: ctx.GlobalBool(flags.EnableRatelimiter.Name), - EnablePaymentMeterer: ctx.GlobalBool(flags.EnablePaymentMeterer.Name), - ReservationsTableName: ctx.GlobalString(flags.ReservationsTableName.Name), - OnDemandTableName: ctx.GlobalString(flags.OnDemandTableName.Name), - GlobalRateTableName: ctx.GlobalString(flags.GlobalRateTableName.Name), - BucketTableName: ctx.GlobalString(flags.BucketTableName.Name), - BucketStoreSize: ctx.GlobalInt(flags.BucketStoreSize.Name), - OnchainUpdateInterval: ctx.GlobalInt(flags.OnchainUpdateInterval.Name), - OffchainPruneInterval: ctx.GlobalInt(flags.OffchainPruneInterval.Name), - OffchainMaxOnDemandStorage: ctx.GlobalInt(flags.OffchainMaxOnDemandStorage.Name), - ChainReadTimeout: ctx.GlobalInt(flags.ChainReadTimeout.Name), - EthClientConfig: geth.ReadEthClientConfigRPCOnly(ctx), - MaxBlobSize: ctx.GlobalInt(flags.MaxBlobSize.Name), - MaxNumSymbolsPerBlob: ctx.GlobalUint(flags.MaxNumSymbolsPerBlob.Name), - OnchainStateRefreshInterval: ctx.GlobalDuration(flags.OnchainStateRefreshInterval.Name), - OffchainStatePruningInterval: ctx.GlobalDuration(flags.OffchainStatePruningInterval.Name), + RatelimiterConfig: ratelimiterConfig, + RateConfig: rateConfig, + EncodingConfig: encodingConfig, + EnableRatelimiter: ctx.GlobalBool(flags.EnableRatelimiter.Name), + EnablePaymentMeterer: ctx.GlobalBool(flags.EnablePaymentMeterer.Name), + ReservationsTableName: ctx.GlobalString(flags.ReservationsTableName.Name), + OnDemandTableName: ctx.GlobalString(flags.OnDemandTableName.Name), + GlobalRateTableName: ctx.GlobalString(flags.GlobalRateTableName.Name), + BucketTableName: ctx.GlobalString(flags.BucketTableName.Name), + BucketStoreSize: ctx.GlobalInt(flags.BucketStoreSize.Name), + OnchainUpdateInterval: ctx.GlobalInt(flags.OnchainUpdateInterval.Name), + ChainReadTimeout: ctx.GlobalInt(flags.ChainReadTimeout.Name), + EthClientConfig: geth.ReadEthClientConfigRPCOnly(ctx), + MaxBlobSize: ctx.GlobalInt(flags.MaxBlobSize.Name), + MaxNumSymbolsPerBlob: ctx.GlobalUint(flags.MaxNumSymbolsPerBlob.Name), + OnchainStateRefreshInterval: ctx.GlobalDuration(flags.OnchainStateRefreshInterval.Name), + OffchainPruneInterval: ctx.GlobalDuration(flags.OffchainPruneInterval.Name), + OffchainMaxOnDemandStorage: ctx.GlobalInt(flags.OffchainMaxOnDemandStorage.Name), BLSOperatorStateRetrieverAddr: ctx.GlobalString(flags.BlsOperatorStateRetrieverFlag.Name), EigenDAServiceManagerAddr: ctx.GlobalString(flags.EigenDAServiceManagerFlag.Name), diff --git a/disperser/cmd/apiserver/flags/flags.go b/disperser/cmd/apiserver/flags/flags.go index 7a32dea79..25b1fa11d 100644 --- a/disperser/cmd/apiserver/flags/flags.go +++ b/disperser/cmd/apiserver/flags/flags.go @@ -114,20 +114,6 @@ var ( EnvVar: common.PrefixEnvVar(envVarPrefix, "ONCHAIN_UPDATE_INTERVAL"), Required: false, } - OffchainPruneInterval = cli.DurationFlag{ - Name: common.PrefixFlag(FlagPrefix, "offchain-prune-interval"), - Usage: "update interval for pruning the off-chain state", - Value: 2 * time.Minute, - EnvVar: common.PrefixEnvVar(envVarPrefix, "OFFCHAIN_PRUNE_INTERVAL"), - Required: false, - } - OffchainMaxOnDemandStorage = cli.UintFlag{ - Name: common.PrefixFlag(FlagPrefix, "offchain-max-on-demand-storage"), - Usage: "max number of on-demand payments to store in the off-chain state", - Value: 100, - EnvVar: common.PrefixEnvVar(envVarPrefix, "OFFCHAIN_MAX_ON_DEMAND_STORAGE"), - Required: false, - } ChainReadTimeout = cli.UintFlag{ Name: common.PrefixFlag(FlagPrefix, "chain-read-timeout"), Usage: "timeout for reading from the chain", @@ -160,14 +146,21 @@ var ( Usage: "The interval at which to refresh the onchain state. This flag is only relevant in v2", Required: false, EnvVar: common.PrefixEnvVar(envVarPrefix, "ONCHAIN_STATE_REFRESH_INTERVAL"), - Value: 1 * time.Hour, + Value: 2 * time.Minute, } - OffchainStatePruningInterval = cli.DurationFlag{ + OffchainPruneInterval = cli.DurationFlag{ Name: common.PrefixFlag(FlagPrefix, "offchain-state-pruning-interval"), Usage: "The interval at which to prune the outdated offchain state. This flag is only relevant in v2", Required: false, EnvVar: common.PrefixEnvVar(envVarPrefix, "OFFCHAIN_STATE_PRUNING_INTERVAL"), - Value: 1 * time.Hour, + Value: 2 * time.Minute, + } + OffchainMaxOnDemandStorage = cli.UintFlag{ + Name: common.PrefixFlag(FlagPrefix, "offchain-max-on-demand-storage"), + Usage: "max number of on-demand payments to store in the off-chain state", + Value: 100, + EnvVar: common.PrefixEnvVar(envVarPrefix, "OFFCHAIN_MAX_ON_DEMAND_STORAGE"), + Required: false, } MaxNumSymbolsPerBlob = cli.UintFlag{ Name: common.PrefixFlag(FlagPrefix, "max-num-symbols-per-blob"), diff --git a/disperser/cmd/apiserver/main.go b/disperser/cmd/apiserver/main.go index 06e12b441..cde37cb16 100644 --- a/disperser/cmd/apiserver/main.go +++ b/disperser/cmd/apiserver/main.go @@ -182,7 +182,7 @@ func RunDisperserServer(ctx *cli.Context) error { prover, uint64(config.MaxNumSymbolsPerBlob), config.OnchainStateRefreshInterval, - config.OffchainStatePruningInterval, + config.OffchainPruneInterval, logger, reg, ) diff --git a/inabox/deploy/config.go b/inabox/deploy/config.go index a97e73154..49fe576ad 100644 --- a/inabox/deploy/config.go +++ b/inabox/deploy/config.go @@ -222,6 +222,10 @@ func (env *Config) generateDisperserV2Vars(ind int, logPath, dbPath, grpcPort st DISPERSER_SERVER_BUCKET_MULTIPLIERS: "1", DISPERSER_SERVER_COUNT_FAILED: "true", + DISPERSER_SERVER_ONCHAIN_STATE_REFRESH_INTERVAL: "2m", + DISPERSER_SERVER_OFFCHAIN_STATE_PRUNING_INTERVAL: "2m", + DISPERSER_SERVER_OFFCHAIN_MAX_ON_DEMAND_STORAGE: "100", + DISPERSER_SERVER_BLS_OPERATOR_STATE_RETRIVER: env.EigenDA.OperatorStateRetreiver, DISPERSER_SERVER_EIGENDA_SERVICE_MANAGER: env.EigenDA.ServiceManager, DISPERSER_SERVER_DISPERSER_VERSION: "2", diff --git a/inabox/deploy/env_vars.go b/inabox/deploy/env_vars.go index e55984eb0..6e4526b6b 100644 --- a/inabox/deploy/env_vars.go +++ b/inabox/deploy/env_vars.go @@ -39,6 +39,10 @@ type DisperserVars struct { DISPERSER_SERVER_ONCHAIN_STATE_REFRESH_INTERVAL string + DISPERSER_SERVER_OFFCHAIN_STATE_PRUNING_INTERVAL string + + DISPERSER_SERVER_OFFCHAIN_MAX_ON_DEMAND_STORAGE string + DISPERSER_SERVER_MAX_NUM_SYMBOLS_PER_BLOB string DISPERSER_SERVER_PPROF_HTTP_PORT string