From cf0182b6d3a32f021ff9deafff1e7976fe39147f Mon Sep 17 00:00:00 2001 From: edwin Date: Wed, 28 Feb 2024 14:50:10 +0700 Subject: [PATCH] Some style edits --- aggregator/aggregator.go | 1 + aggregator/cmd/main.go | 3 -- aggregator/rpc_server.go | 1 - core/chainio/avs_writer.go | 57 +++++++++++++++++++++++--------------- operator/operator.go | 1 - 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index c2bd3718a..806fa7dea 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -297,6 +297,7 @@ func (agg *Aggregator) handleStateRootUpdateReachedQuorum(blsAggServiceResp type agg.logger.Error("Aggregator could not store message aggregation") return } + } func (agg *Aggregator) handleOperatorSetUpdateReachedQuorum(blsAggServiceResp types.MessageBlsAggregationServiceResponse) { diff --git a/aggregator/cmd/main.go b/aggregator/cmd/main.go index 6367cf62e..1f9b2415b 100644 --- a/aggregator/cmd/main.go +++ b/aggregator/cmd/main.go @@ -21,7 +21,6 @@ var ( ) func main() { - app := cli.NewApp() app.Flags = config.Flags app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate) @@ -37,7 +36,6 @@ func main() { } func aggregatorMain(ctx *cli.Context) error { - log.Println("Initializing Aggregator") config, err := config.NewConfig(ctx) if err != nil { @@ -62,5 +60,4 @@ func aggregatorMain(ctx *cli.Context) error { } return nil - } diff --git a/aggregator/rpc_server.go b/aggregator/rpc_server.go index bd461be44..f81ced465 100644 --- a/aggregator/rpc_server.go +++ b/aggregator/rpc_server.go @@ -26,7 +26,6 @@ var ( ) func (agg *Aggregator) startServer() error { - err := rpc.Register(agg) if err != nil { agg.logger.Fatal("Format of service TaskManager isn't correct. ", "err", err) diff --git a/core/chainio/avs_writer.go b/core/chainio/avs_writer.go index d957df80e..21d027a3c 100644 --- a/core/chainio/avs_writer.go +++ b/core/chainio/avs_writer.go @@ -76,74 +76,85 @@ func NewAvsWriter(avsRegistryWriter avsregistry.AvsRegistryWriter, avsServiceBin } // returns the tx receipt, as well as the task index (which it gets from parsing the tx receipt logs) -func (w *AvsWriter) SendNewCheckpointTask(ctx context.Context, fromTimestamp uint64, toTimestamp uint64, quorumThreshold uint32, quorumNumbers []byte) (taskmanager.CheckpointTask, uint32, error) { - txOpts, err := w.TxMgr.GetNoSendTxOpts() +func (avsWriter *AvsWriter) SendNewCheckpointTask(ctx context.Context, fromTimestamp uint64, toTimestamp uint64, quorumThreshold uint32, quorumNumbers []byte) (taskmanager.CheckpointTask, uint32, error) { + txOpts, err := avsWriter.TxMgr.GetNoSendTxOpts() if err != nil { - w.logger.Errorf("Error getting tx opts") + avsWriter.logger.Errorf("Error getting tx opts") return taskmanager.CheckpointTask{}, 0, err } - tx, err := w.AvsContractBindings.TaskManager.CreateCheckpointTask(txOpts, fromTimestamp, toTimestamp, quorumThreshold, quorumNumbers) + tx, err := avsWriter.AvsContractBindings.TaskManager.CreateCheckpointTask(txOpts, fromTimestamp, toTimestamp, quorumThreshold, quorumNumbers) if err != nil { - w.logger.Errorf("Error assembling CreateCheckpointTask tx") + avsWriter.logger.Errorf("Error assembling CreateCheckpointTask tx") return taskmanager.CheckpointTask{}, 0, err } - receipt, err := w.TxMgr.Send(ctx, tx) + receipt, err := avsWriter.TxMgr.Send(ctx, tx) if err != nil { - w.logger.Errorf("Error submitting CreateCheckpointTask tx") + avsWriter.logger.Errorf("Error submitting CreateCheckpointTask tx") return taskmanager.CheckpointTask{}, 0, err } - checkpointTaskCreatedEvent, err := w.AvsContractBindings.TaskManager.ContractSFFLTaskManagerFilterer.ParseCheckpointTaskCreated(*receipt.Logs[0]) + checkpointTaskCreatedEvent, err := avsWriter.AvsContractBindings.TaskManager.ContractSFFLTaskManagerFilterer.ParseCheckpointTaskCreated(*receipt.Logs[0]) if err != nil { - w.logger.Error("Aggregator failed to parse new task created event", "err", err) + avsWriter.logger.Error("Aggregator failed to parse new task created event", "err", err) return taskmanager.CheckpointTask{}, 0, err } return checkpointTaskCreatedEvent.Task, checkpointTaskCreatedEvent.TaskIndex, nil } -func (w *AvsWriter) SendAggregatedResponse( +func (avsWriter *AvsWriter) SendAggregatedResponse( ctx context.Context, task taskmanager.CheckpointTask, taskResponse taskmanager.CheckpointTaskResponse, nonSignerStakesAndSignature taskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, ) (*types.Receipt, error) { - txOpts, err := w.TxMgr.GetNoSendTxOpts() + txOpts, err := avsWriter.TxMgr.GetNoSendTxOpts() if err != nil { - w.logger.Errorf("Error getting tx opts") + avsWriter.logger.Errorf("Error getting tx opts") return nil, err } - tx, err := w.AvsContractBindings.TaskManager.RespondToCheckpointTask(txOpts, task, taskResponse, nonSignerStakesAndSignature) + tx, err := avsWriter.AvsContractBindings.TaskManager.RespondToCheckpointTask(txOpts, task, taskResponse, nonSignerStakesAndSignature) if err != nil { - w.logger.Error("Error submitting SubmitTaskResponse tx while calling respondToTask", "err", err) + avsWriter.logger.Error("Error submitting SubmitTaskResponse tx while calling respondToTask", "err", err) return nil, err } - receipt, err := w.TxMgr.Send(ctx, tx) + receipt, err := avsWriter.TxMgr.Send(ctx, tx) if err != nil { - w.logger.Errorf("Error submitting CreateCheckpointTask tx") + avsWriter.logger.Errorf("Error submitting CreateCheckpointTask tx") return nil, err } return receipt, nil } -func (w *AvsWriter) RaiseChallenge( +func (avsWriter *AvsWriter) RaiseChallenge( ctx context.Context, task taskmanager.CheckpointTask, taskResponse taskmanager.CheckpointTaskResponse, taskResponseMetadata taskmanager.CheckpointTaskResponseMetadata, pubkeysOfNonSigningOperators []taskmanager.BN254G1Point, ) (*types.Receipt, error) { - txOpts, err := w.TxMgr.GetNoSendTxOpts() + txOpts, err := avsWriter.TxMgr.GetNoSendTxOpts() if err != nil { - w.logger.Errorf("Error getting tx opts") + avsWriter.logger.Errorf("Error getting tx opts") return nil, err } - tx, err := w.AvsContractBindings.TaskManager.RaiseAndResolveCheckpointChallenge(txOpts, task, taskResponse, taskResponseMetadata, pubkeysOfNonSigningOperators) + tx, err := avsWriter.AvsContractBindings.TaskManager.RaiseAndResolveCheckpointChallenge(txOpts, task, taskResponse, taskResponseMetadata, pubkeysOfNonSigningOperators) if err != nil { - w.logger.Errorf("Error assembling RaiseChallenge tx") + avsWriter.logger.Errorf("Error assembling RaiseChallenge tx") return nil, err } - receipt, err := w.TxMgr.Send(ctx, tx) + receipt, err := avsWriter.TxMgr.Send(ctx, tx) if err != nil { - w.logger.Errorf("Error submitting CreateCheckpointTask tx") + avsWriter.logger.Errorf("Error submitting CreateCheckpointTask tx") return nil, err } return receipt, nil } + +//func (avsWriter *AvsWriter) SendOperatorSetUpdate() (*types.Receipt, error) { +// txOpts, err := avsWriter.TxMgr.GetNoSendTxOpts() +// if err != nil { +// avsWriter.logger.Errorf("Error getting tx opts") +// return nil, err +// } +// +// tx, err := avsWriter.AvsContractBindings.RegistryCoordinator.UpdateOperators() +// return nil, nil +//} diff --git a/operator/operator.go b/operator/operator.go index 608f1e466..5b0fa3bba 100644 --- a/operator/operator.go +++ b/operator/operator.go @@ -41,7 +41,6 @@ type Operator struct { config types.NodeConfig logger logging.Logger ethClient eth.EthClient - // TODO(samlaf): remove both avsWriter and eigenlayerWrite from operator // they are only used for registration, so we should make a special registration package // this way, auditing this operator code makes it obvious that operators don't need to // write to the chain during the course of their normal operations