Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 12, 2024
1 parent 0ca169f commit 25b84cc
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 71 deletions.
18 changes: 9 additions & 9 deletions disperser/apiserver/server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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),
}
Expand Down Expand Up @@ -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 {
Expand Down
86 changes: 42 additions & 44 deletions disperser/cmd/apiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
27 changes: 10 additions & 17 deletions disperser/cmd/apiserver/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion disperser/cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func RunDisperserServer(ctx *cli.Context) error {
prover,
uint64(config.MaxNumSymbolsPerBlob),
config.OnchainStateRefreshInterval,
config.OffchainStatePruningInterval,
config.OffchainPruneInterval,
logger,
reg,
)
Expand Down
4 changes: 4 additions & 0 deletions inabox/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions inabox/deploy/env_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 25b84cc

Please sign in to comment.