Skip to content

require opt-in to enable event monitoring #182

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

Merged
merged 2 commits into from
Mar 11, 2025
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
4 changes: 4 additions & 0 deletions config/operator_sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ db_path: /tmp/ap-avs-operator
target_chain:
eth_rpc_url: <sepolia-chain-rpc>
eth_ws_url: <websocket-sepolia-chain-rpc>

enabled_features:
# event trigger requires a dedicated rpc node with websocket to listen to all on-chain event. Depend on your RPC provider, this may require significant billing so we disable by default
event_trigger: false
11 changes: 9 additions & 2 deletions operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ type OperatorConfig struct {
Password string `yaml:"password"`
TLSCertFilePath string `yaml:"tls_cert_file_path"`
} `yaml:"bls_remote_signer"`

EnabledFeatures struct {
EventTrigger bool `yaml:"event_trigger"`
} `yaml:"enabled_features"`
}

type Operator struct {
Expand Down Expand Up @@ -192,11 +196,12 @@ func NewOperatorFromConfig(c OperatorConfig) (*Operator, error) {
// Setup Node Api
nodeApi := nodeapi.NewNodeApi(AVS_NAME, version.Get(), c.NodeApiIpPortAddress, logger)

logger.Infof("%s operator version %s", AVS_NAME, version.Get())
logger.Info("starting operator", "version", version.Get(), "commit", version.Commit())

var ethRpcClient *eth.InstrumentedClient
var ethWsClient *eth.InstrumentedClient

logger.Debug("initialize rpc call collector")
rpcCallsCollector := rpccalls.NewCollector(AVS_NAME, reg)
if c.EnableMetrics {
ethRpcClient, err = eth.NewInstrumentedClient(c.EthRpcUrl, rpcCallsCollector)
Expand Down Expand Up @@ -225,6 +230,7 @@ func NewOperatorFromConfig(c OperatorConfig) (*Operator, error) {
var blsRemoteSigner blssignerV1.SignerClient
var blsKeyPair *bls.KeyPair
if c.BlsRemoteSigner.GrpcUrl != "" {
logger.Debug("initialize remote signer", "grpc_url", c.BlsRemoteSigner.GrpcUrl)
logger.Info("creating signer client", "url", c.BlsRemoteSigner.GrpcUrl, "publickey", c.BlsRemoteSigner.PublicKey)
creds := insecure.NewCredentials()
if c.BlsRemoteSigner.TLSCertFilePath != "" {
Expand Down Expand Up @@ -253,6 +259,7 @@ func NewOperatorFromConfig(c OperatorConfig) (*Operator, error) {
}

chainId, err := ethRpcClient.ChainID(context.Background())
logger.Infof("detect EigenLayer on chain id %d", chainId)
if err != nil {
logger.Error("Cannot get chainId", "err", err)
return nil, err
Expand Down Expand Up @@ -529,4 +536,4 @@ func (o *Operator) GetSignature(ctx context.Context, message []byte) (*blscrypto
}

return sig, nil
}
}
8 changes: 7 additions & 1 deletion operator/worker_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ func (o *Operator) runWorkLoop(ctx context.Context) error {
o.timeTrigger = triggerengine.NewTimeTrigger(timeTriggerCh, o.logger)

o.blockTrigger.Run(ctx)
o.eventTrigger.Run(ctx)
o.timeTrigger.Run(ctx)

// Event trigger can be costly, so we require an opt-in
if o.config.EnabledFeatures.EventTrigger {
o.eventTrigger.Run(ctx)
} else {
o.logger.Info("event trigger not enable, skip initialize event monitoring")
}

// Establish a connection with gRPC server where new task will be pushed automatically
o.logger.Info("open channel to grpc to receive check")
go o.StreamMessages()
Expand Down