Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nonsigning rate threshold control to ejector #601

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions disperser/cmd/dataapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Config struct {
ServerMode string
AllowOrigins []string
EjectionToken string
NonsigningRateThreshold int

BLSOperatorStateRetrieverAddr string
EigenDAServiceManagerAddr string
Expand Down Expand Up @@ -76,8 +77,10 @@ func NewConfig(ctx *cli.Context) (Config, error) {
Secret: ctx.GlobalString(flags.PrometheusServerSecretFlag.Name),
Cluster: ctx.GlobalString(flags.PrometheusMetricsClusterLabelFlag.Name),
},
AllowOrigins: ctx.GlobalStringSlice(flags.AllowOriginsFlag.Name),
EjectionToken: ejectionToken,
AllowOrigins: ctx.GlobalStringSlice(flags.AllowOriginsFlag.Name),
EjectionToken: ejectionToken,
NonsigningRateThreshold: ctx.GlobalInt(flags.NonsigningRateThresholdFlag.Name),

MetricsConfig: dataapi.MetricsConfig{
HTTPPort: ctx.GlobalString(flags.MetricsHTTPPort.Name),
EnableMetrics: ctx.GlobalBool(flags.EnableMetricsFlag.Name),
Expand Down
8 changes: 8 additions & 0 deletions disperser/cmd/dataapi/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ var (
Value: 6 * time.Minute,
EnvVar: common.PrefixEnvVar(envVarPrefix, "TRANSACTION_TIMEOUT"),
}
NonsigningRateThresholdFlag = cli.IntFlag{
Name: common.PrefixFlag(FlagPrefix, "nonsigning-rate-threshold"),
Usage: "only operators with nonsigning rate >= this threshold are eligible for ejection, this value must be in range [10, 100], any value not in this range means disabling this flag",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabling the flag means, eject based on regular SLA?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, no additional conditions to affect the standard SLA and ejection flow.

Required: false,
Value: -1,
EnvVar: common.PrefixEnvVar(envVarPrefix, "NONSIGNING_RATE_THRESHOLD"),
}
)

var requiredFlags = []cli.Flag{
Expand All @@ -172,6 +179,7 @@ var requiredFlags = []cli.Flag{
var optionalFlags = []cli.Flag{
ServerModeFlag,
MetricsHTTPPort,
NonsigningRateThresholdFlag,
}

// Flags contains the list of configuration options available to the binary.
Expand Down
2 changes: 1 addition & 1 deletion disperser/cmd/dataapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func RunDataApi(ctx *cli.Context) error {
subgraphClient,
tx,
chainState,
dataapi.NewEjector(wallet, client, logger, tx, metrics, config.TxnTimeout),
dataapi.NewEjector(wallet, client, logger, tx, metrics, config.TxnTimeout, config.NonsigningRateThreshold),
logger,
metrics,
nil,
Expand Down
33 changes: 20 additions & 13 deletions disperser/dataapi/ejector.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,27 @@ func computePerfScore(metric *OperatorNonsigningPercentageMetrics) float64 {
}

type Ejector struct {
wallet walletsdk.Wallet
ethClient common.EthClient
logger logging.Logger
transactor core.Transactor
metrics *Metrics
txnTimeout time.Duration
wallet walletsdk.Wallet
ethClient common.EthClient
logger logging.Logger
transactor core.Transactor
metrics *Metrics
txnTimeout time.Duration
nonsigningRateThreshold int

// For serializing the ejection requests.
mu sync.Mutex
}

func NewEjector(wallet walletsdk.Wallet, ethClient common.EthClient, logger logging.Logger, tx core.Transactor, metrics *Metrics, txnTimeout time.Duration) *Ejector {
func NewEjector(wallet walletsdk.Wallet, ethClient common.EthClient, logger logging.Logger, tx core.Transactor, metrics *Metrics, txnTimeout time.Duration, nonsigningRateThreshold int) *Ejector {
return &Ejector{
wallet: wallet,
ethClient: ethClient,
logger: logger.With("component", "Ejector"),
transactor: tx,
metrics: metrics,
txnTimeout: txnTimeout,
wallet: wallet,
ethClient: ethClient,
logger: logger.With("component", "Ejector"),
transactor: tx,
metrics: metrics,
txnTimeout: txnTimeout,
nonsigningRateThreshold: nonsigningRateThreshold,
}
}

Expand All @@ -82,6 +84,11 @@ func (e *Ejector) Eject(ctx context.Context, nonsigningRate *OperatorsNonsigning

nonsigners := make([]*OperatorNonsigningPercentageMetrics, 0)
for _, metric := range nonsigningRate.Data {
// If nonsigningRateThreshold is set and valid, we will only eject operators with
// nonsigning rate >= nonsigningRateThreshold.
if e.nonsigningRateThreshold >= 10 && e.nonsigningRateThreshold <= 100 && metric.Percentage < float64(e.nonsigningRateThreshold) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if e.nonsigningRateThreshold is 9, then regular SLA is enforced.
then if e.nonsigningRateThreshold is 50, then we enable the relaxed ejection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In first case: e.nonsigningRateThreshold will have no effect, it will just perform regular ejection

In second case: it'll eject an operator if 1) the operator violates SLA; AND 2) the operator's nonsigning rate >= 50%

Note: when it's regular ejection, only condition 1) is used

continue
}
// Collect only the nonsigners who violate the SLA.
if metric.Percentage/100.0 > 1-stakeShareToSLA(metric.StakePercentage/100.0) {
nonsigners = append(nonsigners, metric)
Expand Down
2 changes: 1 addition & 1 deletion disperser/dataapi/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func getEjector(t *testing.T) *ejectorComponents {
ctrl := gomock.NewController(t)
w := sdkmock.NewMockWallet(ctrl)
ethClient := &commonmock.MockEthClient{}
ejector := dataapi.NewEjector(w, ethClient, mockLogger, mockTx, metrics, 100*time.Millisecond)
ejector := dataapi.NewEjector(w, ethClient, mockLogger, mockTx, metrics, 100*time.Millisecond, -1)
return &ejectorComponents{
wallet: w,
ethClient: ethClient,
Expand Down
Loading