@@ -154,29 +154,43 @@ func (o *Operator) Start(ctx context.Context) error {
154154 }
155155 case newBatchLog := <- o .NewTaskCreatedChan :
156156 err := o .ProcessNewBatchLog (newBatchLog )
157+ // err := o.ProcessNewBatchLogV2(newBatchLog)
157158 if err != nil {
158159 o .Logger .Infof ("batch %x did not verify. Err: %v" , newBatchLog .BatchMerkleRoot , err )
159160 continue
160161 }
161- batchIdentifier := append (newBatchLog .BatchMerkleRoot [:], newBatchLog .SenderAddress [:]... )
162- var batchIdentifierHash = * (* [32 ]byte )(crypto .Keccak256 (batchIdentifier ))
163162
164- responseSignature := o .SignTaskResponse (batchIdentifierHash )
163+ // V2
164+ // batchIdentifier := append(newBatchLog.BatchMerkleRoot[:], newBatchLog.SenderAddress[:]...)
165+ // var batchIdentifierHash = *(*[32]byte)(crypto.Keccak256(batchIdentifier))
166+ // responseSignature := o.SignTaskResponse(batchIdentifierHash)
167+
168+ // V2
169+ // signedTaskResponse := types.SignedTaskResponse{
170+ // BatchIdentifierHash: batchIdentifierHash,
171+ // BatchMerkleRoot: newBatchLog.BatchMerkleRoot,
172+ // SenderAddress: newBatchLog.SenderAddress,
173+ // BlsSignature: *responseSignature,
174+ // OperatorId: o.OperatorId,
175+ // }
176+ // o.Logger.Infof("Signed Task Response to send: BatchIdentifierHash=%s, BatchMerkleRoot=%s, SenderAddress=%s",
177+ // hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
178+ // hex.EncodeToString(signedTaskResponse.BatchMerkleRoot[:]),
179+ // hex.EncodeToString(signedTaskResponse.SenderAddress[:]),
180+ // )
181+
182+
183+ responseSignature := o .SignTaskResponse (newBatchLog .BatchMerkleRoot )
165184 o .Logger .Debugf ("responseSignature about to send: %x" , responseSignature )
166185
167186 signedTaskResponse := types.SignedTaskResponse {
168- BatchIdentifierHash : batchIdentifierHash ,
169187 BatchMerkleRoot : newBatchLog .BatchMerkleRoot ,
170- SenderAddress : newBatchLog .SenderAddress ,
171188 BlsSignature : * responseSignature ,
172189 OperatorId : o .OperatorId ,
173190 }
174191
175- // o.Logger.Infof("Signed Task Response to send: %+v", signedTaskResponse)
176192 o .Logger .Infof ("Signed Task Response to send: BatchIdentifierHash=%s, BatchMerkleRoot=%s, SenderAddress=%s" ,
177- hex .EncodeToString (signedTaskResponse .BatchIdentifierHash [:]),
178193 hex .EncodeToString (signedTaskResponse .BatchMerkleRoot [:]),
179- hex .EncodeToString (signedTaskResponse .SenderAddress [:]),
180194 )
181195 go o .aggRpcClient .SendSignedTaskResponseToAggregator (& signedTaskResponse )
182196 }
@@ -187,6 +201,46 @@ func (o *Operator) Start(ctx context.Context) error {
187201// The TaskResponseHeader struct is the struct that is signed and sent to the contract as a task response.
188202func (o * Operator ) ProcessNewBatchLog (newBatchLog * servicemanager.ContractAlignedLayerServiceManagerNewBatch ) error {
189203
204+ o .Logger .Info ("Received new batch with proofs to verify" ,
205+ "batch merkle root" , "0x" + hex .EncodeToString (newBatchLog .BatchMerkleRoot [:]),
206+ )
207+
208+ ctx , cancel := context .WithTimeout (context .Background (), BatchDownloadTimeout )
209+ defer cancel ()
210+
211+ verificationDataBatch , err := o .getBatchFromS3 (ctx , newBatchLog .BatchDataPointer , newBatchLog .BatchMerkleRoot )
212+ if err != nil {
213+ o .Logger .Errorf ("Could not get proofs from S3 bucket: %v" , err )
214+ return err
215+ }
216+
217+ verificationDataBatchLen := len (verificationDataBatch )
218+ results := make (chan bool , verificationDataBatchLen )
219+ var wg sync.WaitGroup
220+ wg .Add (verificationDataBatchLen )
221+ for _ , verificationData := range verificationDataBatch {
222+ go func (data VerificationData ) {
223+ defer wg .Done ()
224+ o .verify (data , results )
225+ o .metrics .IncOperatorTaskResponses ()
226+ }(verificationData )
227+ }
228+
229+ go func () {
230+ wg .Wait ()
231+ close (results )
232+ }()
233+
234+ for result := range results {
235+ if ! result {
236+ return fmt .Errorf ("invalid proof" )
237+ }
238+ }
239+
240+ return nil
241+ }
242+ func (o * Operator ) ProcessNewBatchLogV2 (newBatchLog * servicemanager.ContractAlignedLayerServiceManagerNewBatchV2 ) error {
243+
190244 o .Logger .Info ("Received new batch with proofs to verify" ,
191245 "batch merkle root" , "0x" + hex .EncodeToString (newBatchLog .BatchMerkleRoot [:]),
192246 "sender address" , "0x" + hex .EncodeToString (newBatchLog .SenderAddress [:]),
0 commit comments