Skip to content

Commit

Permalink
[minibatch] Add feature flag on batcher (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim authored Jul 12, 2024
1 parent 660f0f1 commit e22b250
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions disperser/cmd/batcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type Config struct {

BLSOperatorStateRetrieverAddr string
EigenDAServiceManagerAddr string

EnableMinibatch bool
}

func NewConfig(ctx *cli.Context) (Config, error) {
Expand Down Expand Up @@ -85,6 +87,7 @@ func NewConfig(ctx *cli.Context) (Config, error) {
IndexerDataDir: ctx.GlobalString(flags.IndexerDataDirFlag.Name),
IndexerConfig: indexer.ReadIndexerConfig(ctx),
KMSKeyConfig: kmsConfig,
EnableMinibatch: ctx.Bool(flags.EnableMinibatchFlag.Name),
}
return config, nil
}
9 changes: 9 additions & 0 deletions disperser/cmd/batcher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ var (
EnvVar: common.PrefixEnvVar(envVarPrefix, "FINALIZATION_BLOCK_DELAY"),
Value: 75,
}
// EnableMinibatchFlag is a flag to enable minibatch processing
// Defaults to false
EnableMinibatchFlag = cli.BoolFlag{
Name: common.PrefixFlag(FlagPrefix, "enable-minibatch"),
Usage: "Enable minibatch processing",
Required: false,
EnvVar: common.PrefixEnvVar(envVarPrefix, "ENABLE_MINIBATCH"),
}
)

var requiredFlags = []cli.Flag{
Expand Down Expand Up @@ -225,6 +233,7 @@ var optionalFlags = []cli.Flag{
TargetNumChunksFlag,
MaxBlobsToFetchFromStoreFlag,
FinalizationBlockDelayFlag,
EnableMinibatchFlag,
}

// Flags contains the list of configuration options available to the binary.
Expand Down
21 changes: 12 additions & 9 deletions disperser/cmd/batcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ func RunBatcher(ctx *cli.Context) error {
}
finalizer := batcher.NewFinalizer(config.TimeoutConfig.ChainReadTimeout, config.BatcherConfig.FinalizerInterval, queue, client, rpcClient, config.BatcherConfig.MaxNumRetriesPerBlob, 1000, config.BatcherConfig.FinalizerPoolSize, logger, metrics.FinalizerMetrics)
txnManager := batcher.NewTxnManager(client, wallet, config.EthClientConfig.NumConfirmations, 20, config.TimeoutConfig.TxnBroadcastTimeout, config.TimeoutConfig.ChainWriteTimeout, logger, metrics.TxnManagerMetrics)
batcher, err := batcher.NewBatcher(config.BatcherConfig, config.TimeoutConfig, queue, dispatcher, ics, asgn, encoderClient, agg, client, finalizer, tx, txnManager, logger, metrics, handleBatchLivenessChan)
if err != nil {
return err
}

// Enable Metrics Block
if config.MetricsConfig.EnableMetrics {
Expand All @@ -242,18 +238,25 @@ func RunBatcher(ctx *cli.Context) error {
logger.Info("Enabled metrics for Batcher", "socket", httpSocket)
}

err = batcher.Start(context.Background())
if err != nil {
return err
if config.EnableMinibatch {
// TODO: implement and run batchConfirmer for minibatch
return errors.New("minibatch is not supported")
} else {
batcher, err := batcher.NewBatcher(config.BatcherConfig, config.TimeoutConfig, queue, dispatcher, ics, asgn, encoderClient, agg, client, finalizer, tx, txnManager, logger, metrics, handleBatchLivenessChan)
if err != nil {
return err
}
err = batcher.Start(context.Background())
if err != nil {
return err
}
}

// Signal readiness
if _, err := os.Create(readinessProbePath); err != nil {
log.Printf("Failed to create readiness file: %v at path %v \n", err, readinessProbePath)
}

return nil

}

// process liveness signal from handleBatch Go Routine
Expand Down

0 comments on commit e22b250

Please sign in to comment.