hermez-node/coordinator/pipeline.go
coordinator/pipeline.goRaw
1package coordinator
2
3import (
4 "context"
5 "database/sql"
6 "fmt"
7 "math/big"
8 "sync"
9 "time"
10
11 "github.com/hermeznetwork/hermez-node/batchbuilder"
12 "github.com/hermeznetwork/hermez-node/common"
13 "github.com/hermeznetwork/hermez-node/db/historydb"
14 "github.com/hermeznetwork/hermez-node/db/l2db"
15 "github.com/hermeznetwork/hermez-node/eth"
16 "github.com/hermeznetwork/hermez-node/log"
17 "github.com/hermeznetwork/hermez-node/prover"
18 "github.com/hermeznetwork/hermez-node/synchronizer"
19 "github.com/hermeznetwork/hermez-node/txselector"
20 "github.com/hermeznetwork/tracerr"
21)
22
23type statsVars struct {
24 Stats synchronizer.Stats
25 Vars synchronizer.SCVariablesPtr
26}
27
28type state struct {
29 batchNum common.BatchNum
30 lastScheduledL1BatchBlockNum int64
31 lastForgeL1TxsNum int64
32 lastSlotForged int64
33}
34
35// Pipeline manages the forging of batches with parallel server proofs
36type Pipeline struct {
37 num int
38 cfg Config
39 consts synchronizer.SCConsts
40
41 // state
42 state state
43 started bool
44 rw sync.RWMutex
45 errAtBatchNum common.BatchNum
46 lastForgeTime time.Time
47
48 proversPool *ProversPool
49 provers []prover.Client
50 coord *Coordinator
51 txManager *TxManager
52 historyDB *historydb.HistoryDB
53 l2DB *l2db.L2DB
54 txSelector *txselector.TxSelector
55 batchBuilder *batchbuilder.BatchBuilder
56 mutexL2DBUpdateDelete *sync.Mutex
57 purger *Purger
58
59 stats synchronizer.Stats
60 vars synchronizer.SCVariables
61 statsVarsCh chan statsVars
62
63 ctx context.Context
64 wg sync.WaitGroup
65 cancel context.CancelFunc
66}
67
68func (p *Pipeline) setErrAtBatchNum(batchNum common.BatchNum) {
69 p.rw.Lock()
70 defer p.rw.Unlock()
71 p.errAtBatchNum = batchNum
72}
73
74func (p *Pipeline) getErrAtBatchNum() common.BatchNum {
75 p.rw.RLock()
76 defer p.rw.RUnlock()
77 return p.errAtBatchNum
78}
79
80// NewPipeline creates a new Pipeline
81func NewPipeline(ctx context.Context,
82 cfg Config,
83 num int, // Pipeline sequential number
84 historyDB *historydb.HistoryDB,
85 l2DB *l2db.L2DB,
86 txSelector *txselector.TxSelector,
87 batchBuilder *batchbuilder.BatchBuilder,
88 mutexL2DBUpdateDelete *sync.Mutex,
89 purger *Purger,
90 coord *Coordinator,
91 txManager *TxManager,
92 provers []prover.Client,
93 scConsts *synchronizer.SCConsts,
94) (*Pipeline, error) {
95 proversPool := NewProversPool(len(provers))
96 proversPoolSize := 0
97 for _, prover := range provers {
98 if err := prover.WaitReady(ctx); err != nil {
99 log.Errorw("prover.WaitReady", "err", err)
100 } else {
101 proversPool.Add(ctx, prover)
102 proversPoolSize++
103 }
104 }
105 if proversPoolSize == 0 {
106 return nil, tracerr.Wrap(fmt.Errorf("no provers in the pool"))
107 }
108 return &Pipeline{
109 num: num,
110 cfg: cfg,
111 historyDB: historyDB,
112 l2DB: l2DB,
113 txSelector: txSelector,
114 batchBuilder: batchBuilder,
115 provers: provers,
116 proversPool: proversPool,
117 mutexL2DBUpdateDelete: mutexL2DBUpdateDelete,
118 purger: purger,
119 coord: coord,
120 txManager: txManager,
121 consts: *scConsts,
122 statsVarsCh: make(chan statsVars, queueLen),
123 }, nil
124}
125
126// SetSyncStatsVars is a thread safe method to sets the synchronizer Stats
127func (p *Pipeline) SetSyncStatsVars(ctx context.Context, stats *synchronizer.Stats, vars *synchronizer.SCVariablesPtr) {
128 select {
129 case p.statsVarsCh <- statsVars{Stats: *stats, Vars: *vars}:
130 case <-ctx.Done():
131 }
132}
133
134// reset pipeline state
135func (p *Pipeline) reset(batchNum common.BatchNum,
136 stats *synchronizer.Stats, vars *synchronizer.SCVariables) error {
137 p.state = state{
138 batchNum: batchNum,
139 lastForgeL1TxsNum: stats.Sync.LastForgeL1TxsNum,
140 lastScheduledL1BatchBlockNum: 0,
141 lastSlotForged: -1,
142 }
143 p.stats = *stats
144 p.vars = *vars
145
146 // Reset the StateDB in TxSelector and BatchBuilder from the
147 // synchronizer only if the checkpoint we reset from either:
148 // a. Doesn't exist in the TxSelector/BatchBuilder
149 // b. The batch has already been synced by the synchronizer and has a
150 // different MTRoot than the BatchBuilder
151 // Otherwise, reset from the local checkpoint.
152
153 // First attempt to reset from local checkpoint if such checkpoint exists
154 existsTxSelector, err := p.txSelector.LocalAccountsDB().CheckpointExists(p.state.batchNum)
155 if err != nil {
156 return tracerr.Wrap(err)
157 }
158 fromSynchronizerTxSelector := !existsTxSelector
159 if err := p.txSelector.Reset(p.state.batchNum, fromSynchronizerTxSelector); err != nil {
160 return tracerr.Wrap(err)
161 }
162 existsBatchBuilder, err := p.batchBuilder.LocalStateDB().CheckpointExists(p.state.batchNum)
163 if err != nil {
164 return tracerr.Wrap(err)
165 }
166 fromSynchronizerBatchBuilder := !existsBatchBuilder
167 if err := p.batchBuilder.Reset(p.state.batchNum, fromSynchronizerBatchBuilder); err != nil {
168 return tracerr.Wrap(err)
169 }
170
171 // After reset, check that if the batch exists in the historyDB, the
172 // stateRoot matches with the local one, if not, force a reset from
173 // synchronizer
174 batch, err := p.historyDB.GetBatch(p.state.batchNum)
175 if tracerr.Unwrap(err) == sql.ErrNoRows {
176 // nothing to do
177 } else if err != nil {
178 return tracerr.Wrap(err)
179 } else {
180 localStateRoot := p.batchBuilder.LocalStateDB().MT.Root().BigInt()
181 if batch.StateRoot.Cmp(localStateRoot) != 0 {
182 log.Debugw("localStateRoot (%v) != historyDB stateRoot (%v). "+
183 "Forcing reset from Synchronizer", localStateRoot, batch.StateRoot)
184 // StateRoot from synchronizer doesn't match StateRoot
185 // from batchBuilder, force a reset from synchronizer
186 if err := p.txSelector.Reset(p.state.batchNum, true); err != nil {
187 return tracerr.Wrap(err)
188 }
189 if err := p.batchBuilder.Reset(p.state.batchNum, true); err != nil {
190 return tracerr.Wrap(err)
191 }
192 }
193 }
194 return nil
195}
196
197func (p *Pipeline) syncSCVars(vars synchronizer.SCVariablesPtr) {
198 updateSCVars(&p.vars, vars)
199}
200
201// handleForgeBatch waits for an available proof server, calls p.forgeBatch to
202// forge the batch and get the zkInputs, and then sends the zkInputs to the
203// selected proof server so that the proof computation begins.
204func (p *Pipeline) handleForgeBatch(ctx context.Context,
205 batchNum common.BatchNum) (batchInfo *BatchInfo, err error) {
206 // 1. Wait for an available serverProof (blocking call)
207 serverProof, err := p.proversPool.Get(ctx)
208 if ctx.Err() != nil {
209 return nil, ctx.Err()
210 } else if err != nil {
211 log.Errorw("proversPool.Get", "err", err)
212 return nil, err
213 }
214 defer func() {
215 // If we encounter any error (notice that this function returns
216 // errors to notify that a batch is not forged not only because
217 // of unexpected errors but also due to benign causes), add the
218 // serverProof back to the pool
219 if err != nil {
220 p.proversPool.Add(ctx, serverProof)
221 }
222 }()
223
224 // 2. Forge the batch internally (make a selection of txs and prepare
225 // all the smart contract arguments)
226 p.mutexL2DBUpdateDelete.Lock()
227 batchInfo, err = p.forgeBatch(batchNum)
228 p.mutexL2DBUpdateDelete.Unlock()
229 if ctx.Err() != nil {
230 return nil, ctx.Err()
231 } else if err != nil {
232 if tracerr.Unwrap(err) == errLastL1BatchNotSynced {
233 log.Warnw("forgeBatch: scheduled L1Batch too early", "err", err,
234 "lastForgeL1TxsNum", p.state.lastForgeL1TxsNum,
235 "syncLastForgeL1TxsNum", p.stats.Sync.LastForgeL1TxsNum)
236 } else if tracerr.Unwrap(err) == errForgeNoTxsBeforeDelay ||
237 tracerr.Unwrap(err) == errForgeBeforeDelay {
238 // no log
239 } else {
240 log.Errorw("forgeBatch", "err", err)
241 }
242 return nil, err
243 }
244
245 // 3. Send the ZKInputs to the proof server
246 batchInfo.ServerProof = serverProof
247 if err := p.sendServerProof(ctx, batchInfo); ctx.Err() != nil {
248 return nil, ctx.Err()
249 } else if err != nil {
250 log.Errorw("sendServerProof", "err", err)
251 return nil, err
252 }
253 return batchInfo, nil
254}
255
256// Start the forging pipeline
257func (p *Pipeline) Start(batchNum common.BatchNum,
258 stats *synchronizer.Stats, vars *synchronizer.SCVariables) error {
259 if p.started {
260 log.Fatal("Pipeline already started")
261 }
262 p.started = true
263
264 if err := p.reset(batchNum, stats, vars); err != nil {
265 return tracerr.Wrap(err)
266 }
267 p.ctx, p.cancel = context.WithCancel(context.Background())
268
269 queueSize := 1
270 batchChSentServerProof := make(chan *BatchInfo, queueSize)
271
272 p.wg.Add(1)
273 go func() {
274 waitCh := time.After(zeroDuration)
275 for {
276 select {
277 case <-p.ctx.Done():
278 log.Info("Pipeline forgeBatch loop done")
279 p.wg.Done()
280 return
281 case statsVars := <-p.statsVarsCh:
282 p.stats = statsVars.Stats
283 p.syncSCVars(statsVars.Vars)
284 case <-waitCh:
285 // Once errAtBatchNum != 0, we stop forging
286 // batches because there's been an error and we
287 // wait for the pipeline to be stopped.
288 if p.getErrAtBatchNum() != 0 {
289 waitCh = time.After(p.cfg.ForgeRetryInterval)
290 continue
291 }
292 batchNum = p.state.batchNum + 1
293 batchInfo, err := p.handleForgeBatch(p.ctx, batchNum)
294 if p.ctx.Err() != nil {
295 waitCh = time.After(p.cfg.ForgeRetryInterval)
296 continue
297 } else if tracerr.Unwrap(err) == errLastL1BatchNotSynced ||
298 tracerr.Unwrap(err) == errForgeNoTxsBeforeDelay ||
299 tracerr.Unwrap(err) == errForgeBeforeDelay {
300 waitCh = time.After(p.cfg.ForgeRetryInterval)
301 continue
302 } else if err != nil {
303 p.setErrAtBatchNum(batchNum)
304 p.coord.SendMsg(p.ctx, MsgStopPipeline{
305 Reason: fmt.Sprintf(
306 "Pipeline.handleForgBatch: %v", err),
307 FailedBatchNum: batchNum,
308 })
309 waitCh = time.After(p.cfg.ForgeRetryInterval)
310 continue
311 }
312 p.lastForgeTime = time.Now()
313
314 p.state.batchNum = batchNum
315 select {
316 case batchChSentServerProof <- batchInfo:
317 case <-p.ctx.Done():
318 }
319 waitCh = time.After(zeroDuration)
320 }
321 }
322 }()
323
324 p.wg.Add(1)
325 go func() {
326 for {
327 select {
328 case <-p.ctx.Done():
329 log.Info("Pipeline waitServerProofSendEth loop done")
330 p.wg.Done()
331 return
332 case batchInfo := <-batchChSentServerProof:
333 // Once errAtBatchNum != 0, we stop forging
334 // batches because there's been an error and we
335 // wait for the pipeline to be stopped.
336 if p.getErrAtBatchNum() != 0 {
337 continue
338 }
339 err := p.waitServerProof(p.ctx, batchInfo)
340 if p.ctx.Err() != nil {
341 continue
342 } else if err != nil {
343 log.Errorw("waitServerProof", "err", err)
344 p.setErrAtBatchNum(batchInfo.BatchNum)
345 p.coord.SendMsg(p.ctx, MsgStopPipeline{
346 Reason: fmt.Sprintf(
347 "Pipeline.waitServerProof: %v", err),
348 FailedBatchNum: batchInfo.BatchNum,
349 })
350 continue
351 }
352 // We are done with this serverProof, add it back to the pool
353 p.proversPool.Add(p.ctx, batchInfo.ServerProof)
354 p.txManager.AddBatch(p.ctx, batchInfo)
355 }
356 }
357 }()
358 return nil
359}
360
361// Stop the forging pipeline
362func (p *Pipeline) Stop(ctx context.Context) {
363 if !p.started {
364 log.Fatal("Pipeline already stopped")
365 }
366 p.started = false
367 log.Info("Stopping Pipeline...")
368 p.cancel()
369 p.wg.Wait()
370 for _, prover := range p.provers {
371 if err := prover.Cancel(ctx); ctx.Err() != nil {
372 continue
373 } else if err != nil {
374 log.Errorw("prover.Cancel", "err", err)
375 }
376 }
377}
378
379// sendServerProof sends the circuit inputs to the proof server
380func (p *Pipeline) sendServerProof(ctx context.Context, batchInfo *BatchInfo) error {
381 p.cfg.debugBatchStore(batchInfo)
382
383 // 7. Call the selected idle server proof with BatchBuilder output,
384 // save server proof info for batchNum
385 if err := batchInfo.ServerProof.CalculateProof(ctx, batchInfo.ZKInputs); err != nil {
386 return tracerr.Wrap(err)
387 }
388 return nil
389}
390
391// forgeBatch forges the batchNum batch.
392func (p *Pipeline) forgeBatch(batchNum common.BatchNum) (batchInfo *BatchInfo, err error) {
393 // remove transactions from the pool that have been there for too long
394 _, err = p.purger.InvalidateMaybe(p.l2DB, p.txSelector.LocalAccountsDB(),
395 p.stats.Sync.LastBlock.Num, int64(batchNum))
396 if err != nil {
397 return nil, tracerr.Wrap(err)
398 }
399 _, err = p.purger.PurgeMaybe(p.l2DB, p.stats.Sync.LastBlock.Num, int64(batchNum))
400 if err != nil {
401 return nil, tracerr.Wrap(err)
402 }
403 // Structure to accumulate data and metadata of the batch
404 now := time.Now()
405 batchInfo = &BatchInfo{PipelineNum: p.num, BatchNum: batchNum}
406 batchInfo.Debug.StartTimestamp = now
407 batchInfo.Debug.StartBlockNum = p.stats.Eth.LastBlock.Num + 1
408
409 selectionCfg := &txselector.SelectionConfig{
410 MaxL1UserTxs: common.RollupConstMaxL1UserTx,
411 TxProcessorConfig: p.cfg.TxProcessorConfig,
412 }
413
414 var poolL2Txs []common.PoolL2Tx
415 var discardedL2Txs []common.PoolL2Tx
416 var l1UserTxsExtra, l1CoordTxs []common.L1Tx
417 var auths [][]byte
418 var coordIdxs []common.Idx
419
420 // Check if the slot is not yet fulfilled
421 slotCommitted := false
422 if p.stats.Sync.Auction.CurrentSlot.ForgerCommitment ||
423 p.stats.Sync.Auction.CurrentSlot.SlotNum == p.state.lastSlotForged {
424 slotCommitted = true
425 }
426
427 // If we haven't reached the ForgeDelay, skip forging the batch
428 if slotCommitted && now.Sub(p.lastForgeTime) < p.cfg.ForgeDelay {
429 return nil, errForgeBeforeDelay
430 }
431
432 // 1. Decide if we forge L2Tx or L1+L2Tx
433 if p.shouldL1L2Batch(batchInfo) {
434 batchInfo.L1Batch = true
435 if p.state.lastForgeL1TxsNum != p.stats.Sync.LastForgeL1TxsNum {
436 return nil, tracerr.Wrap(errLastL1BatchNotSynced)
437 }
438 // 2a: L1+L2 txs
439 l1UserTxs, err := p.historyDB.GetUnforgedL1UserTxs(p.state.lastForgeL1TxsNum + 1)
440 if err != nil {
441 return nil, tracerr.Wrap(err)
442 }
443 coordIdxs, auths, l1UserTxsExtra, l1CoordTxs, poolL2Txs, discardedL2Txs, err =
444 p.txSelector.GetL1L2TxSelection(selectionCfg, l1UserTxs)
445 if err != nil {
446 return nil, tracerr.Wrap(err)
447 }
448 } else {
449 // 2b: only L2 txs
450 coordIdxs, auths, l1CoordTxs, poolL2Txs, discardedL2Txs, err =
451 p.txSelector.GetL2TxSelection(selectionCfg)
452 if err != nil {
453 return nil, tracerr.Wrap(err)
454 }
455 l1UserTxsExtra = nil
456 }
457
458 // If there are no txs to forge, no l1UserTxs in the open queue to
459 // freeze, and we haven't reached the ForgeNoTxsDelay, skip forging the
460 // batch.
461 if slotCommitted && now.Sub(p.lastForgeTime) < p.cfg.ForgeNoTxsDelay {
462 noTxs := false
463 if len(l1UserTxsExtra) == 0 && len(l1CoordTxs) == 0 && len(poolL2Txs) == 0 {
464 if batchInfo.L1Batch {
465 // Query the L1UserTxs in the queue following
466 // the one we are trying to forge.
467 nextL1UserTxs, err := p.historyDB.GetUnforgedL1UserTxs(
468 p.state.lastForgeL1TxsNum + 1)
469 if err != nil {
470 return nil, tracerr.Wrap(err)
471 }
472 // If there are future L1UserTxs, we forge a
473 // batch to advance the queues and forge the
474 // L1UserTxs in the future. Otherwise, skip.
475 if len(nextL1UserTxs) == 0 {
476 noTxs = true
477 }
478 } else {
479 noTxs = true
480 }
481 }
482 if noTxs {
483 if err := p.txSelector.Reset(batchInfo.BatchNum-1, false); err != nil {
484 return nil, tracerr.Wrap(err)
485 }
486 return nil, errForgeNoTxsBeforeDelay
487 }
488 }
489
490 if batchInfo.L1Batch {
491 p.state.lastScheduledL1BatchBlockNum = p.stats.Eth.LastBlock.Num + 1
492 p.state.lastForgeL1TxsNum++
493 }
494
495 // 3. Save metadata from TxSelector output for BatchNum
496 batchInfo.L1UserTxsExtra = l1UserTxsExtra
497 batchInfo.L1CoordTxs = l1CoordTxs
498 batchInfo.L1CoordinatorTxsAuths = auths
499 batchInfo.CoordIdxs = coordIdxs
500 batchInfo.VerifierIdx = p.cfg.VerifierIdx
501
502 if err := p.l2DB.StartForging(common.TxIDsFromPoolL2Txs(poolL2Txs), batchInfo.BatchNum); err != nil {
503 return nil, tracerr.Wrap(err)
504 }
505 if err := p.l2DB.UpdateTxsInfo(discardedL2Txs); err != nil {
506 return nil, tracerr.Wrap(err)
507 }
508
509 // Invalidate transactions that become invalid beause of
510 // the poolL2Txs selected. Will mark as invalid the txs that have a
511 // (fromIdx, nonce) which already appears in the selected txs (includes
512 // all the nonces smaller than the current one)
513 err = p.l2DB.InvalidateOldNonces(idxsNonceFromPoolL2Txs(poolL2Txs), batchInfo.BatchNum)
514 if err != nil {
515 return nil, tracerr.Wrap(err)
516 }
517
518 // 4. Call BatchBuilder with TxSelector output
519 configBatch := &batchbuilder.ConfigBatch{
520 TxProcessorConfig: p.cfg.TxProcessorConfig,
521 }
522 zkInputs, err := p.batchBuilder.BuildBatch(coordIdxs, configBatch, l1UserTxsExtra,
523 l1CoordTxs, poolL2Txs)
524 if err != nil {
525 return nil, tracerr.Wrap(err)
526 }
527 l2Txs, err := common.PoolL2TxsToL2Txs(poolL2Txs) // NOTE: This is a big uggly, find a better way
528 if err != nil {
529 return nil, tracerr.Wrap(err)
530 }
531 batchInfo.L2Txs = l2Txs
532
533 // 5. Save metadata from BatchBuilder output for BatchNum
534 batchInfo.ZKInputs = zkInputs
535 batchInfo.Debug.Status = StatusForged
536 p.cfg.debugBatchStore(batchInfo)
537 log.Infow("Pipeline: batch forged internally", "batch", batchInfo.BatchNum)
538
539 p.state.lastSlotForged = p.stats.Sync.Auction.CurrentSlot.SlotNum
540
541 return batchInfo, nil
542}
543
544// waitServerProof gets the generated zkProof & sends it to the SmartContract
545func (p *Pipeline) waitServerProof(ctx context.Context, batchInfo *BatchInfo) error {
546 proof, pubInputs, err := batchInfo.ServerProof.GetProof(ctx) // blocking call, until not resolved don't continue. Returns when the proof server has calculated the proof
547 if err != nil {
548 return tracerr.Wrap(err)
549 }
550 batchInfo.Proof = proof
551 batchInfo.PublicInputs = pubInputs
552 batchInfo.ForgeBatchArgs = prepareForgeBatchArgs(batchInfo)
553 batchInfo.Debug.Status = StatusProof
554 p.cfg.debugBatchStore(batchInfo)
555 log.Infow("Pipeline: batch proof calculated", "batch", batchInfo.BatchNum)
556 return nil
557}
558
559func (p *Pipeline) shouldL1L2Batch(batchInfo *BatchInfo) bool {
560 // Take the lastL1BatchBlockNum as the biggest between the last
561 // scheduled one, and the synchronized one.
562 lastL1BatchBlockNum := p.state.lastScheduledL1BatchBlockNum
563 if p.stats.Sync.LastL1BatchBlock > lastL1BatchBlockNum {
564 lastL1BatchBlockNum = p.stats.Sync.LastL1BatchBlock
565 }
566 // Set Debug information
567 batchInfo.Debug.LastScheduledL1BatchBlockNum = p.state.lastScheduledL1BatchBlockNum
568 batchInfo.Debug.LastL1BatchBlock = p.stats.Sync.LastL1BatchBlock
569 batchInfo.Debug.LastL1BatchBlockDelta = p.stats.Eth.LastBlock.Num + 1 - lastL1BatchBlockNum
570 batchInfo.Debug.L1BatchBlockScheduleDeadline =
571 int64(float64(p.vars.Rollup.ForgeL1L2BatchTimeout-1) * p.cfg.L1BatchTimeoutPerc)
572 // Return true if we have passed the l1BatchTimeoutPerc portion of the
573 // range before the l1batch timeout.
574 return p.stats.Eth.LastBlock.Num+1-lastL1BatchBlockNum >=
575 int64(float64(p.vars.Rollup.ForgeL1L2BatchTimeout-1)*p.cfg.L1BatchTimeoutPerc)
576}
577
578func prepareForgeBatchArgs(batchInfo *BatchInfo) *eth.RollupForgeBatchArgs {
579 proof := batchInfo.Proof
580 zki := batchInfo.ZKInputs
581 return ð.RollupForgeBatchArgs{
582 NewLastIdx: int64(zki.Metadata.NewLastIdxRaw),
583 NewStRoot: zki.Metadata.NewStateRootRaw.BigInt(),
584 NewExitRoot: zki.Metadata.NewExitRootRaw.BigInt(),
585 L1UserTxs: batchInfo.L1UserTxsExtra,
586 L1CoordinatorTxs: batchInfo.L1CoordTxs,
587 L1CoordinatorTxsAuths: batchInfo.L1CoordinatorTxsAuths,
588 L2TxsData: batchInfo.L2Txs,
589 FeeIdxCoordinator: batchInfo.CoordIdxs,
590 // Circuit selector
591 VerifierIdx: batchInfo.VerifierIdx,
592 L1Batch: batchInfo.L1Batch,
593 ProofA: [2]*big.Int{proof.PiA[0], proof.PiA[1]},
594 // Implementation of the verifier need a swap on the proofB vector
595 ProofB: [2][2]*big.Int{
596 {proof.PiB[0][1], proof.PiB[0][0]},
597 {proof.PiB[1][1], proof.PiB[1][0]},
598 },
599 ProofC: [2]*big.Int{proof.PiC[0], proof.PiC[1]},
600 }
601}