Skip to content

Commit

Permalink
Adjust the churn approval interval (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Aug 7, 2024
1 parent 4dbd6de commit 18bfd0f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
5 changes: 3 additions & 2 deletions inabox/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ func (env *Config) generateChurnerVars(ind int, graphUrl, logPath, grpcPort stri
CHURNER_GRAPH_URL: graphUrl,
CHURNER_INDEXER_PULL_INTERVAL: "1s",

CHURNER_ENABLE_METRICS: "true",
CHURNER_METRICS_HTTP_PORT: "9095",
CHURNER_ENABLE_METRICS: "true",
CHURNER_METRICS_HTTP_PORT: "9095",
CHURNER_CHURN_APPROVAL_INTERVAL: "900s",
}

env.applyDefaults(&v, "CHURNER", "churner", ind)
Expand Down
2 changes: 2 additions & 0 deletions inabox/deploy/env_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ type ChurnerVars struct {

CHURNER_PER_PUBLIC_KEY_RATE_LIMIT string

CHURNER_CHURN_APPROVAL_INTERVAL string

CHURNER_METRICS_HTTP_PORT string

CHURNER_CHAIN_RPC string
Expand Down
23 changes: 13 additions & 10 deletions operators/churner/churner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import (
)

var (
bipMultiplier = big.NewInt(10000)
secondsTillExpiry = 3600 * time.Second
bipMultiplier = big.NewInt(10000)
)

type ChurnRequest struct {
Expand Down Expand Up @@ -50,9 +49,10 @@ type churner struct {
Transactor core.Transactor
QuorumCount uint8

privateKey *ecdsa.PrivateKey
logger logging.Logger
metrics *Metrics
privateKey *ecdsa.PrivateKey
logger logging.Logger
metrics *Metrics
churnApprovalInterval time.Duration
}

func NewChurner(
Expand All @@ -67,14 +67,17 @@ func NewChurner(
return nil, err
}

logger.Info("Churner created with config", "ChurnApprovalInterval", config.ChurnApprovalInterval)

return &churner{
Indexer: indexer,
Transactor: transactor,
QuorumCount: 0,

privateKey: privateKey,
logger: logger.With("component", "Churner"),
metrics: metrics,
privateKey: privateKey,
logger: logger.With("component", "Churner"),
metrics: metrics,
churnApprovalInterval: config.ChurnApprovalInterval,
}, nil
}

Expand Down Expand Up @@ -285,8 +288,8 @@ func (c *churner) sign(ctx context.Context, operatorToRegisterAddress gethcommon
var salt [32]byte
copy(salt[:], saltKeccak256)

// set expiry to 3600s in the future
expiry := big.NewInt(now.Add(secondsTillExpiry).Unix())
// set expiry to ChurnApprovalInterval in the future
expiry := big.NewInt(now.Add(c.churnApprovalInterval).Unix())

// sign and return signature
hashToSign, err := c.Transactor.CalculateOperatorChurnApprovalDigestHash(ctx, operatorToRegisterAddress, operatorToRegisterId, operatorsToChurn, salt, expiry)
Expand Down
2 changes: 2 additions & 0 deletions operators/churner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Config struct {
EigenDAServiceManagerAddr string

PerPublicKeyRateLimit time.Duration
ChurnApprovalInterval time.Duration
}

func NewConfig(ctx *cli.Context) (*Config, error) {
Expand All @@ -34,6 +35,7 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
BLSOperatorStateRetrieverAddr: ctx.GlobalString(flags.BlsOperatorStateRetrieverFlag.Name),
EigenDAServiceManagerAddr: ctx.GlobalString(flags.EigenDAServiceManagerFlag.Name),
PerPublicKeyRateLimit: ctx.GlobalDuration(flags.PerPublicKeyRateLimit.Name),
ChurnApprovalInterval: ctx.GlobalDuration(flags.ChurnApprovalInterval.Name),
MetricsConfig: MetricsConfig{
HTTPPort: ctx.GlobalString(flags.MetricsHTTPPort.Name),
EnableMetrics: ctx.GlobalBool(flags.EnableMetrics.Name),
Expand Down
8 changes: 8 additions & 0 deletions operators/churner/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ var (
Value: "9100",
EnvVar: common.PrefixEnvVar(envPrefix, "METRICS_HTTP_PORT"),
}
ChurnApprovalInterval = cli.DurationFlag{
Name: common.PrefixFlag(FlagPrefix, "churn-approval-interval"),
Usage: "If this interval is N mins, the churner will only approve a new churn request N mins after the previous approval",
Required: false,
EnvVar: common.PrefixEnvVar(envPrefix, "CHURN_APPROVAL_INTERVAL"),
Value: 15 * time.Minute,
}
)

var requiredFlags = []cli.Flag{
Expand All @@ -78,6 +85,7 @@ var requiredFlags = []cli.Flag{
var optionalFlags = []cli.Flag{
PerPublicKeyRateLimit,
MetricsHTTPPort,
ChurnApprovalInterval,
}

// Flags contains the list of configuration options available to the binary.
Expand Down
4 changes: 3 additions & 1 deletion operators/churner/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"math/big"
"testing"
"time"

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/geth"
Expand Down Expand Up @@ -92,7 +93,7 @@ func TestChurn(t *testing.T) {
// retry prior to expiry should fail
_, err = s.Churn(ctx, request)
assert.NotNil(t, err)
assert.Equal(t, err.Error(), "rpc error: code = ResourceExhausted desc = previous approval not expired, retry in 3600 seconds")
assert.Equal(t, err.Error(), "rpc error: code = ResourceExhausted desc = previous approval not expired, retry in 900 seconds")
}

func TestChurnWithInvalidQuorum(t *testing.T) {
Expand Down Expand Up @@ -169,6 +170,7 @@ func newTestServer(t *testing.T) *churner.Server {
PrivateKeyString: churnerPrivateKeyHex,
NumRetries: numRetries,
},
ChurnApprovalInterval: 15 * time.Minute,
}

var err error
Expand Down
1 change: 1 addition & 0 deletions operators/churner/tests/churner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func newTestServer(t *testing.T) *churner.Server {
LoggerConfig: common.DefaultLoggerConfig(),
BLSOperatorStateRetrieverAddr: testConfig.EigenDA.OperatorStateRetreiver,
EigenDAServiceManagerAddr: testConfig.EigenDA.ServiceManager,
ChurnApprovalInterval: 15 * time.Minute,
}

operatorTransactorChurner, err := createTransactorFromScratch(
Expand Down

0 comments on commit 18bfd0f

Please sign in to comment.