Skip to content

Commit

Permalink
Some style edits
Browse files Browse the repository at this point in the history
  • Loading branch information
taco-paco committed Feb 28, 2024
1 parent 18b4197 commit cf0182b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
1 change: 1 addition & 0 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions aggregator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var (
)

func main() {

app := cli.NewApp()
app.Flags = config.Flags
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate)
Expand All @@ -37,7 +36,6 @@ func main() {
}

func aggregatorMain(ctx *cli.Context) error {

log.Println("Initializing Aggregator")
config, err := config.NewConfig(ctx)
if err != nil {
Expand All @@ -62,5 +60,4 @@ func aggregatorMain(ctx *cli.Context) error {
}

return nil

}
1 change: 0 additions & 1 deletion aggregator/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
57 changes: 34 additions & 23 deletions core/chainio/avs_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
//}
1 change: 0 additions & 1 deletion operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cf0182b

Please sign in to comment.