diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index 52da9bfdf..16fc14fa6 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -18,7 +18,7 @@ import ( "github.com/NethermindEth/near-sffl/core/chainio" "github.com/NethermindEth/near-sffl/core/config" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" ) const ( @@ -69,9 +69,9 @@ type Aggregator struct { avsWriter chainio.AvsWriterer // aggregation related fields blsAggregationService blsagg.BlsAggregationService - tasks map[types.TaskIndex]cstaskmanager.CheckpointTask + tasks map[types.TaskIndex]taskmanager.CheckpointTask tasksMu sync.RWMutex - taskResponses map[types.TaskIndex]map[sdktypes.TaskResponseDigest]cstaskmanager.CheckpointTaskResponse + taskResponses map[types.TaskIndex]map[sdktypes.TaskResponseDigest]taskmanager.CheckpointTaskResponse taskResponsesMu sync.RWMutex } @@ -113,8 +113,8 @@ func NewAggregator(c *config.Config) (*Aggregator, error) { serverIpPortAddr: c.AggregatorServerIpPortAddr, avsWriter: avsWriter, blsAggregationService: blsAggregationService, - tasks: make(map[types.TaskIndex]cstaskmanager.CheckpointTask), - taskResponses: make(map[types.TaskIndex]map[sdktypes.TaskResponseDigest]cstaskmanager.CheckpointTaskResponse), + tasks: make(map[types.TaskIndex]taskmanager.CheckpointTask), + taskResponses: make(map[types.TaskIndex]map[sdktypes.TaskResponseDigest]taskmanager.CheckpointTaskResponse), }, nil } @@ -161,15 +161,15 @@ func (agg *Aggregator) sendAggregatedResponseToContract(blsAggServiceResp blsagg // panicing to help with debugging (fail fast), but we shouldn't panic if we run this in production panic(blsAggServiceResp.Err) } - nonSignerPubkeys := []cstaskmanager.BN254G1Point{} + nonSignerPubkeys := []taskmanager.BN254G1Point{} for _, nonSignerPubkey := range blsAggServiceResp.NonSignersPubkeysG1 { nonSignerPubkeys = append(nonSignerPubkeys, core.ConvertToBN254G1Point(nonSignerPubkey)) } - quorumApks := []cstaskmanager.BN254G1Point{} + quorumApks := []taskmanager.BN254G1Point{} for _, quorumApk := range blsAggServiceResp.QuorumApksG1 { quorumApks = append(quorumApks, core.ConvertToBN254G1Point(quorumApk)) } - nonSignerStakesAndSignature := cstaskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature{ + nonSignerStakesAndSignature := taskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature{ NonSignerPubkeys: nonSignerPubkeys, QuorumApks: quorumApks, ApkG2: core.ConvertToBN254G2Point(blsAggServiceResp.SignersApkG2), diff --git a/aggregator/aggregator_test.go b/aggregator/aggregator_test.go index 2f3a630b9..a7cd95cf4 100644 --- a/aggregator/aggregator_test.go +++ b/aggregator/aggregator_test.go @@ -19,7 +19,7 @@ import ( "github.com/NethermindEth/near-sffl/aggregator/mocks" "github.com/NethermindEth/near-sffl/aggregator/types" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" chainiomocks "github.com/NethermindEth/near-sffl/core/chainio/mocks" ) @@ -88,8 +88,8 @@ func createMockAggregator( logger: logger, avsWriter: mockAvsWriter, blsAggregationService: mockBlsAggregationService, - tasks: make(map[types.TaskIndex]cstaskmanager.CheckpointTask), - taskResponses: make(map[types.TaskIndex]map[sdktypes.TaskResponseDigest]cstaskmanager.CheckpointTaskResponse), + tasks: make(map[types.TaskIndex]taskmanager.CheckpointTask), + taskResponses: make(map[types.TaskIndex]map[sdktypes.TaskResponseDigest]taskmanager.CheckpointTaskResponse), } return aggregator, mockAvsWriter, mockBlsAggregationService, nil } diff --git a/aggregator/mocks/chain.go b/aggregator/mocks/chain.go index 40a39247e..869db1f82 100644 --- a/aggregator/mocks/chain.go +++ b/aggregator/mocks/chain.go @@ -6,13 +6,13 @@ import ( opstateretriever "github.com/Layr-Labs/eigensdk-go/contracts/bindings/OperatorStateRetriever" "github.com/Layr-Labs/eigensdk-go/crypto/bls" "github.com/NethermindEth/near-sffl/aggregator/types" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" ) // ====== TaskManager Mocks ====== -func MockSendNewCheckpointTask(blockNum, taskNum uint32, fromNearBlock, toNearBlock uint64) (cstaskmanager.CheckpointTask, uint32, error) { - task := cstaskmanager.CheckpointTask{ +func MockSendNewCheckpointTask(blockNum, taskNum uint32, fromNearBlock, toNearBlock uint64) (taskmanager.CheckpointTask, uint32, error) { + task := taskmanager.CheckpointTask{ FromNearBlock: fromNearBlock, ToNearBlock: toNearBlock, TaskCreatedBlock: blockNum, diff --git a/aggregator/rpc_server.go b/aggregator/rpc_server.go index 4d9a0829d..31b64124d 100644 --- a/aggregator/rpc_server.go +++ b/aggregator/rpc_server.go @@ -6,7 +6,7 @@ import ( "net/http" "net/rpc" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/NethermindEth/near-sffl/core" "github.com/Layr-Labs/eigensdk-go/crypto/bls" @@ -38,7 +38,7 @@ func (agg *Aggregator) startServer(ctx context.Context) error { } type SignedCheckpointTaskResponse struct { - TaskResponse cstaskmanager.CheckpointTaskResponse + TaskResponse taskmanager.CheckpointTaskResponse BlsSignature bls.Signature OperatorId bls.OperatorId } @@ -56,7 +56,7 @@ func (agg *Aggregator) ProcessSignedCheckpointTaskResponse(signedCheckpointTaskR } agg.taskResponsesMu.Lock() if _, ok := agg.taskResponses[taskIndex]; !ok { - agg.taskResponses[taskIndex] = make(map[sdktypes.TaskResponseDigest]cstaskmanager.CheckpointTaskResponse) + agg.taskResponses[taskIndex] = make(map[sdktypes.TaskResponseDigest]taskmanager.CheckpointTaskResponse) } if _, ok := agg.taskResponses[taskIndex][taskResponseDigest]; !ok { agg.taskResponses[taskIndex][taskResponseDigest] = signedCheckpointTaskResponse.TaskResponse diff --git a/aggregator/rpc_server_test.go b/aggregator/rpc_server_test.go index 405489447..b5d44eeeb 100644 --- a/aggregator/rpc_server_test.go +++ b/aggregator/rpc_server_test.go @@ -13,7 +13,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/crypto/bls" sdktypes "github.com/Layr-Labs/eigensdk-go/types" "github.com/NethermindEth/near-sffl/aggregator/types" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/NethermindEth/near-sffl/core" ) @@ -74,7 +74,7 @@ func keccak256(num uint64) [32]byte { // mocks an operator signing on a task response func createMockSignedCheckpointTaskResponse(mockTask MockTask, keypair bls.KeyPair) (*SignedCheckpointTaskResponse, error) { - taskResponse := &cstaskmanager.CheckpointTaskResponse{ + taskResponse := &taskmanager.CheckpointTaskResponse{ ReferenceTaskIndex: mockTask.TaskNum, StateRootUpdatesRoot: keccak256(mockTask.FromNearBlock), OperatorSetUpdatesRoot: keccak256(mockTask.ToNearBlock), diff --git a/core/chainio/avs_reader.go b/core/chainio/avs_reader.go index db5abeffb..13a25fc2f 100644 --- a/core/chainio/avs_reader.go +++ b/core/chainio/avs_reader.go @@ -11,7 +11,7 @@ import ( logging "github.com/Layr-Labs/eigensdk-go/logging" erc20mock "github.com/NethermindEth/near-sffl/contracts/bindings/ERC20Mock" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/NethermindEth/near-sffl/core/config" ) @@ -19,8 +19,8 @@ type AvsReaderer interface { sdkavsregistry.AvsRegistryReader CheckSignatures( - ctx context.Context, msgHash [32]byte, quorumNumbers []byte, referenceBlockNumber uint32, nonSignerStakesAndSignature cstaskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, - ) (cstaskmanager.IBLSSignatureCheckerQuorumStakeTotals, error) + ctx context.Context, msgHash [32]byte, quorumNumbers []byte, referenceBlockNumber uint32, nonSignerStakesAndSignature taskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, + ) (taskmanager.IBLSSignatureCheckerQuorumStakeTotals, error) GetErc20Mock(ctx context.Context, tokenAddr gethcommon.Address) (*erc20mock.ContractERC20Mock, error) } @@ -55,13 +55,13 @@ func NewAvsReader(avsRegistryReader sdkavsregistry.AvsRegistryReader, avsService } func (r *AvsReader) CheckSignatures( - ctx context.Context, msgHash [32]byte, quorumNumbers []byte, referenceBlockNumber uint32, nonSignerStakesAndSignature cstaskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, -) (cstaskmanager.IBLSSignatureCheckerQuorumStakeTotals, error) { + ctx context.Context, msgHash [32]byte, quorumNumbers []byte, referenceBlockNumber uint32, nonSignerStakesAndSignature taskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, +) (taskmanager.IBLSSignatureCheckerQuorumStakeTotals, error) { stakeTotalsPerQuorum, _, err := r.AvsServiceBindings.TaskManager.CheckSignatures( &bind.CallOpts{}, msgHash, quorumNumbers, referenceBlockNumber, nonSignerStakesAndSignature, ) if err != nil { - return cstaskmanager.IBLSSignatureCheckerQuorumStakeTotals{}, err + return taskmanager.IBLSSignatureCheckerQuorumStakeTotals{}, err } return stakeTotalsPerQuorum, nil } diff --git a/core/chainio/avs_subscriber.go b/core/chainio/avs_subscriber.go index 9ebb232bb..7ba03af1c 100644 --- a/core/chainio/avs_subscriber.go +++ b/core/chainio/avs_subscriber.go @@ -9,14 +9,14 @@ import ( "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" sdklogging "github.com/Layr-Labs/eigensdk-go/logging" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/NethermindEth/near-sffl/core/config" ) type AvsSubscriberer interface { - SubscribeToNewTasks(checkpointTaskCreatedChan chan *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated) event.Subscription - SubscribeToTaskResponses(taskResponseLogs chan *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskResponded) event.Subscription - ParseCheckpointTaskResponded(rawLog types.Log) (*cstaskmanager.ContractSFFLTaskManagerCheckpointTaskResponded, error) + SubscribeToNewTasks(checkpointTaskCreatedChan chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated) event.Subscription + SubscribeToTaskResponses(taskResponseLogs chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskResponded) event.Subscription + ParseCheckpointTaskResponded(rawLog types.Log) (*taskmanager.ContractSFFLTaskManagerCheckpointTaskResponded, error) } // Subscribers use a ws connection instead of http connection like Readers @@ -53,7 +53,7 @@ func NewAvsSubscriber(avsContractBindings *AvsManagersBindings, logger sdkloggin } } -func (s *AvsSubscriber) SubscribeToNewTasks(checkpointTaskCreatedChan chan *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated) event.Subscription { +func (s *AvsSubscriber) SubscribeToNewTasks(checkpointTaskCreatedChan chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated) event.Subscription { sub, err := s.AvsContractBindings.TaskManager.WatchCheckpointTaskCreated( &bind.WatchOpts{}, checkpointTaskCreatedChan, nil, ) @@ -64,7 +64,7 @@ func (s *AvsSubscriber) SubscribeToNewTasks(checkpointTaskCreatedChan chan *csta return sub } -func (s *AvsSubscriber) SubscribeToTaskResponses(taskResponseChan chan *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskResponded) event.Subscription { +func (s *AvsSubscriber) SubscribeToTaskResponses(taskResponseChan chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskResponded) event.Subscription { sub, err := s.AvsContractBindings.TaskManager.WatchCheckpointTaskResponded( &bind.WatchOpts{}, taskResponseChan, ) @@ -75,6 +75,6 @@ func (s *AvsSubscriber) SubscribeToTaskResponses(taskResponseChan chan *cstaskma return sub } -func (s *AvsSubscriber) ParseCheckpointTaskResponded(rawLog types.Log) (*cstaskmanager.ContractSFFLTaskManagerCheckpointTaskResponded, error) { +func (s *AvsSubscriber) ParseCheckpointTaskResponded(rawLog types.Log) (*taskmanager.ContractSFFLTaskManagerCheckpointTaskResponded, error) { return s.AvsContractBindings.TaskManager.ContractSFFLTaskManagerFilterer.ParseCheckpointTaskResponded(rawLog) } diff --git a/core/chainio/avs_writer.go b/core/chainio/avs_writer.go index f2b8ec487..9da9edfb4 100644 --- a/core/chainio/avs_writer.go +++ b/core/chainio/avs_writer.go @@ -11,7 +11,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" logging "github.com/Layr-Labs/eigensdk-go/logging" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/NethermindEth/near-sffl/core/config" ) @@ -24,18 +24,18 @@ type AvsWriterer interface { toNearBlock uint64, quorumThreshold uint32, quorumNumbers []byte, - ) (cstaskmanager.CheckpointTask, uint32, error) + ) (taskmanager.CheckpointTask, uint32, error) RaiseChallenge( ctx context.Context, - task cstaskmanager.CheckpointTask, - taskResponse cstaskmanager.CheckpointTaskResponse, - taskResponseMetadata cstaskmanager.CheckpointTaskResponseMetadata, - pubkeysOfNonSigningOperators []cstaskmanager.BN254G1Point, + task taskmanager.CheckpointTask, + taskResponse taskmanager.CheckpointTaskResponse, + taskResponseMetadata taskmanager.CheckpointTaskResponseMetadata, + pubkeysOfNonSigningOperators []taskmanager.BN254G1Point, ) (*types.Receipt, error) SendAggregatedResponse(ctx context.Context, - task cstaskmanager.CheckpointTask, - taskResponse cstaskmanager.CheckpointTaskResponse, - nonSignerStakesAndSignature cstaskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, + task taskmanager.CheckpointTask, + taskResponse taskmanager.CheckpointTaskResponse, + nonSignerStakesAndSignature taskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, ) (*types.Receipt, error) } @@ -75,34 +75,34 @@ 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, fromNearBlock uint64, toNearBlock uint64, quorumThreshold uint32, quorumNumbers []byte) (cstaskmanager.CheckpointTask, uint32, error) { +func (w *AvsWriter) SendNewCheckpointTask(ctx context.Context, fromNearBlock uint64, toNearBlock uint64, quorumThreshold uint32, quorumNumbers []byte) (taskmanager.CheckpointTask, uint32, error) { txOpts, err := w.TxMgr.GetNoSendTxOpts() if err != nil { w.logger.Errorf("Error getting tx opts") - return cstaskmanager.CheckpointTask{}, 0, err + return taskmanager.CheckpointTask{}, 0, err } tx, err := w.AvsContractBindings.TaskManager.CreateCheckpointTask(txOpts, fromNearBlock, toNearBlock, quorumThreshold, quorumNumbers) if err != nil { w.logger.Errorf("Error assembling CreateCheckpointTask tx") - return cstaskmanager.CheckpointTask{}, 0, err + return taskmanager.CheckpointTask{}, 0, err } receipt, err := w.TxMgr.Send(ctx, tx) if err != nil { w.logger.Errorf("Error submitting CreateCheckpointTask tx") - return cstaskmanager.CheckpointTask{}, 0, err + return taskmanager.CheckpointTask{}, 0, err } checkpointTaskCreatedEvent, err := w.AvsContractBindings.TaskManager.ContractSFFLTaskManagerFilterer.ParseCheckpointTaskCreated(*receipt.Logs[0]) if err != nil { w.logger.Error("Aggregator failed to parse new task created event", "err", err) - return cstaskmanager.CheckpointTask{}, 0, err + return taskmanager.CheckpointTask{}, 0, err } return checkpointTaskCreatedEvent.Task, checkpointTaskCreatedEvent.TaskIndex, nil } func (w *AvsWriter) SendAggregatedResponse( - ctx context.Context, task cstaskmanager.CheckpointTask, - taskResponse cstaskmanager.CheckpointTaskResponse, - nonSignerStakesAndSignature cstaskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, + ctx context.Context, task taskmanager.CheckpointTask, + taskResponse taskmanager.CheckpointTaskResponse, + nonSignerStakesAndSignature taskmanager.IBLSSignatureCheckerNonSignerStakesAndSignature, ) (*types.Receipt, error) { txOpts, err := w.TxMgr.GetNoSendTxOpts() if err != nil { @@ -124,10 +124,10 @@ func (w *AvsWriter) SendAggregatedResponse( func (w *AvsWriter) RaiseChallenge( ctx context.Context, - task cstaskmanager.CheckpointTask, - taskResponse cstaskmanager.CheckpointTaskResponse, - taskResponseMetadata cstaskmanager.CheckpointTaskResponseMetadata, - pubkeysOfNonSigningOperators []cstaskmanager.BN254G1Point, + task taskmanager.CheckpointTask, + taskResponse taskmanager.CheckpointTaskResponse, + taskResponseMetadata taskmanager.CheckpointTaskResponseMetadata, + pubkeysOfNonSigningOperators []taskmanager.BN254G1Point, ) (*types.Receipt, error) { txOpts, err := w.TxMgr.GetNoSendTxOpts() if err != nil { diff --git a/core/chainio/bindings.go b/core/chainio/bindings.go index b06db2cb4..a582834b2 100644 --- a/core/chainio/bindings.go +++ b/core/chainio/bindings.go @@ -11,11 +11,11 @@ import ( regcoord "github.com/Layr-Labs/eigensdk-go/contracts/bindings/RegistryCoordinator" erc20mock "github.com/NethermindEth/near-sffl/contracts/bindings/ERC20Mock" csservicemanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLServiceManager" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" ) type AvsManagersBindings struct { - TaskManager *cstaskmanager.ContractSFFLTaskManager + TaskManager *taskmanager.ContractSFFLTaskManager ServiceManager *csservicemanager.ContractSFFLServiceManager ethClient eth.EthClient logger logging.Logger @@ -41,7 +41,7 @@ func NewAvsManagersBindings(registryCoordinatorAddr, operatorStateRetrieverAddr logger.Error("Failed to fetch TaskManager address", "err", err) return nil, err } - contractTaskManager, err := cstaskmanager.NewContractSFFLTaskManager(taskManagerAddr, ethclient) + contractTaskManager, err := taskmanager.NewContractSFFLTaskManager(taskManagerAddr, ethclient) if err != nil { logger.Error("Failed to fetch ISFFLTaskManager contract", "err", err) return nil, err diff --git a/core/utils.go b/core/utils.go index 31d812e7c..2e9b962cb 100644 --- a/core/utils.go +++ b/core/utils.go @@ -4,16 +4,16 @@ import ( "math/big" "github.com/Layr-Labs/eigensdk-go/crypto/bls" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/ethereum/go-ethereum/accounts/abi" "golang.org/x/crypto/sha3" ) -// this hardcodes abi.encode() for cstaskmanager.CheckpointTaskResponse +// this hardcodes abi.encode() for taskmanager.CheckpointTaskResponse // unclear why abigen doesn't provide this out of the box... -func AbiEncodeCheckpointTaskResponse(h *cstaskmanager.CheckpointTaskResponse) ([]byte, error) { +func AbiEncodeCheckpointTaskResponse(h *taskmanager.CheckpointTaskResponse) ([]byte, error) { - // The order here has to match the field ordering of cstaskmanager.CheckpointTaskResponse + // The order here has to match the field ordering of taskmanager.CheckpointTaskResponse taskResponseType, err := abi.NewType("tuple", "", []abi.ArgumentMarshaling{ { Name: "referenceTaskIndex", @@ -46,7 +46,7 @@ func AbiEncodeCheckpointTaskResponse(h *cstaskmanager.CheckpointTaskResponse) ([ } // GetCheckpointTaskResponseDigest returns the hash of the TaskResponse, which is what operators sign over -func GetCheckpointTaskResponseDigest(h *cstaskmanager.CheckpointTaskResponse) ([32]byte, error) { +func GetCheckpointTaskResponseDigest(h *taskmanager.CheckpointTaskResponse) ([32]byte, error) { encodeTaskResponseByte, err := AbiEncodeCheckpointTaskResponse(h) if err != nil { @@ -66,16 +66,16 @@ func GetCheckpointTaskResponseDigest(h *cstaskmanager.CheckpointTaskResponse) ([ // BN254.sol is a library, so bindings for G1 Points and G2 Points are only generated // in every contract that imports that library. Thus the output here will need to be // type casted if G1Point is needed to interface with another contract (eg: BLSPublicKeyCompendium.sol) -func ConvertToBN254G1Point(input *bls.G1Point) cstaskmanager.BN254G1Point { - output := cstaskmanager.BN254G1Point{ +func ConvertToBN254G1Point(input *bls.G1Point) taskmanager.BN254G1Point { + output := taskmanager.BN254G1Point{ X: input.X.BigInt(big.NewInt(0)), Y: input.Y.BigInt(big.NewInt(0)), } return output } -func ConvertToBN254G2Point(input *bls.G2Point) cstaskmanager.BN254G2Point { - output := cstaskmanager.BN254G2Point{ +func ConvertToBN254G2Point(input *bls.G2Point) taskmanager.BN254G2Point { + output := taskmanager.BN254G2Point{ X: [2]*big.Int{input.X.A1.BigInt(big.NewInt(0)), input.X.A0.BigInt(big.NewInt(0))}, Y: [2]*big.Int{input.Y.A1.BigInt(big.NewInt(0)), input.Y.A0.BigInt(big.NewInt(0))}, } diff --git a/operator/operator.go b/operator/operator.go index 80810ee97..d70f99225 100644 --- a/operator/operator.go +++ b/operator/operator.go @@ -10,7 +10,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/NethermindEth/near-sffl/aggregator" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/NethermindEth/near-sffl/core" "github.com/NethermindEth/near-sffl/core/chainio" "github.com/NethermindEth/near-sffl/metrics" @@ -56,7 +56,7 @@ type Operator struct { operatorId bls.OperatorId operatorAddr common.Address // receive new tasks in this chan (typically from listening to onchain event) - checkpointTaskCreatedChan chan *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated + checkpointTaskCreatedChan chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated // ip address of aggregator aggregatorServerIpPortAddr string // rpc client to send signed task responses to aggregator @@ -213,7 +213,7 @@ func NewOperatorFromConfig(c types.NodeConfig) (*Operator, error) { operatorAddr: common.HexToAddress(c.OperatorAddress), aggregatorServerIpPortAddr: c.AggregatorServerIpPortAddress, aggregatorRpcClient: aggregatorRpcClient, - checkpointTaskCreatedChan: make(chan *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated), + checkpointTaskCreatedChan: make(chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated), sfflServiceManagerAddr: common.HexToAddress(c.AVSRegistryCoordinatorAddress), operatorId: [32]byte{0}, // this is set below @@ -302,7 +302,7 @@ func (o *Operator) Start(ctx context.Context) error { // Takes a CheckpointTaskCreatedLog struct as input and returns a TaskResponseHeader struct. // The TaskResponseHeader struct is the struct that is signed and sent to the contract as a task response. -func (o *Operator) ProcessCheckpointTaskCreatedLog(checkpointTaskCreatedLog *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated) *cstaskmanager.CheckpointTaskResponse { +func (o *Operator) ProcessCheckpointTaskCreatedLog(checkpointTaskCreatedLog *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated) *taskmanager.CheckpointTaskResponse { o.logger.Debug("Received new task", "task", checkpointTaskCreatedLog) o.logger.Info("Received new task", "fromNearBlock", checkpointTaskCreatedLog.Task.FromNearBlock, @@ -315,7 +315,7 @@ func (o *Operator) ProcessCheckpointTaskCreatedLog(checkpointTaskCreatedLog *cst // TODO: build SMT based on stored message agreements and update the test - taskResponse := &cstaskmanager.CheckpointTaskResponse{ + taskResponse := &taskmanager.CheckpointTaskResponse{ ReferenceTaskIndex: checkpointTaskCreatedLog.TaskIndex, StateRootUpdatesRoot: [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, OperatorSetUpdatesRoot: [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -323,7 +323,7 @@ func (o *Operator) ProcessCheckpointTaskCreatedLog(checkpointTaskCreatedLog *cst return taskResponse } -func (o *Operator) SignTaskResponse(taskResponse *cstaskmanager.CheckpointTaskResponse) (*aggregator.SignedCheckpointTaskResponse, error) { +func (o *Operator) SignTaskResponse(taskResponse *taskmanager.CheckpointTaskResponse) (*aggregator.SignedCheckpointTaskResponse, error) { taskResponseHash, err := core.GetCheckpointTaskResponseDigest(taskResponse) if err != nil { o.logger.Error("Error getting task response header hash. skipping task (this is not expected and should be investigated)", "err", err) diff --git a/operator/operator_test.go b/operator/operator_test.go index 8eb207f27..0cd6ee60b 100644 --- a/operator/operator_test.go +++ b/operator/operator_test.go @@ -16,7 +16,7 @@ import ( "github.com/NethermindEth/near-sffl/aggregator" aggtypes "github.com/NethermindEth/near-sffl/aggregator/types" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" chainiomocks "github.com/NethermindEth/near-sffl/core/chainio/mocks" operatormocks "github.com/NethermindEth/near-sffl/operator/mocks" ) @@ -30,9 +30,9 @@ func TestOperator(t *testing.T) { var fromNearBlock = uint64(3) var toNearBlock = uint64(4) - newTaskCreatedLog := &cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated{ + newTaskCreatedLog := &taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated{ TaskIndex: taskIndex, - Task: cstaskmanager.CheckpointTask{ + Task: taskmanager.CheckpointTask{ FromNearBlock: fromNearBlock, ToNearBlock: toNearBlock, TaskCreatedBlock: 1000, @@ -42,7 +42,7 @@ func TestOperator(t *testing.T) { Raw: types.Log{}, } got := operator.ProcessCheckpointTaskCreatedLog(newTaskCreatedLog) - want := &cstaskmanager.CheckpointTaskResponse{ + want := &taskmanager.CheckpointTaskResponse{ ReferenceTaskIndex: taskIndex, StateRootUpdatesRoot: [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, OperatorSetUpdatesRoot: [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -55,9 +55,9 @@ func TestOperator(t *testing.T) { var toNearBlock = uint64(4) // new task event - newTaskCreatedEvent := &cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated{ + newTaskCreatedEvent := &taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated{ TaskIndex: taskIndex, - Task: cstaskmanager.CheckpointTask{ + Task: taskmanager.CheckpointTask{ FromNearBlock: fromNearBlock, ToNearBlock: toNearBlock, TaskCreatedBlock: 1000, @@ -73,7 +73,7 @@ func TestOperator(t *testing.T) { assert.True(t, ok) signedTaskResponse := &aggregator.SignedCheckpointTaskResponse{ - TaskResponse: cstaskmanager.CheckpointTaskResponse{ + TaskResponse: taskmanager.CheckpointTaskResponse{ ReferenceTaskIndex: taskIndex, StateRootUpdatesRoot: [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, OperatorSetUpdatesRoot: [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, diff --git a/operator/registration_test.go b/operator/registration_test.go index ad91390c3..1e60105d7 100644 --- a/operator/registration_test.go +++ b/operator/registration_test.go @@ -9,7 +9,7 @@ import ( "github.com/Layr-Labs/eigensdk-go/crypto/bls" sdklogging "github.com/Layr-Labs/eigensdk-go/logging" - cstaskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" + taskmanager "github.com/NethermindEth/near-sffl/contracts/bindings/SFFLTaskManager" "github.com/NethermindEth/near-sffl/metrics" "github.com/NethermindEth/near-sffl/tests" ) @@ -47,7 +47,7 @@ func createMockOperator() (*Operator, error) { blsKeypair: operatorKeypair, metricsReg: reg, metrics: noopMetrics, - checkpointTaskCreatedChan: make(chan *cstaskmanager.ContractSFFLTaskManagerCheckpointTaskCreated), + checkpointTaskCreatedChan: make(chan *taskmanager.ContractSFFLTaskManagerCheckpointTaskCreated), operatorId: MOCK_OPERATOR_ID, } return operator, nil