arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
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 calls p.forgeBatch to forge the batch and get the zkInputs,
202// and then waits for an available proof server and sends the zkInputs to it so
203// that the proof computation begins.
204func (p *Pipeline) handleForgeBatch(ctx context.Context, batchNum common.BatchNum) (*BatchInfo, error) {
205	p.mutexL2DBUpdateDelete.Lock()
206	batchInfo, err := p.forgeBatch(batchNum)
207	p.mutexL2DBUpdateDelete.Unlock()
208	if ctx.Err() != nil {
209		return nil, ctx.Err()
210	} else if err != nil {
211		if tracerr.Unwrap(err) == errLastL1BatchNotSynced {
212			log.Warnw("forgeBatch: scheduled L1Batch too early", "err", err,
213				"lastForgeL1TxsNum", p.state.lastForgeL1TxsNum,
214				"syncLastForgeL1TxsNum", p.stats.Sync.LastForgeL1TxsNum)
215		} else if tracerr.Unwrap(err) == errForgeNoTxsBeforeDelay ||
216			tracerr.Unwrap(err) == errForgeBeforeDelay {
217			// no log
218		} else {
219			log.Errorw("forgeBatch", "err", err)
220		}
221		return nil, err
222	}
223	// 6. Wait for an available server proof (blocking call)
224	serverProof, err := p.proversPool.Get(ctx)
225	if ctx.Err() != nil {
226		return nil, ctx.Err()
227	} else if err != nil {
228		log.Errorw("proversPool.Get", "err", err)
229		return nil, err
230	}
231	batchInfo.ServerProof = serverProof
232	if err := p.sendServerProof(ctx, batchInfo); ctx.Err() != nil {
233		return nil, ctx.Err()
234	} else if err != nil {
235		log.Errorw("sendServerProof", "err", err)
236		batchInfo.ServerProof = nil
237		p.proversPool.Add(ctx, serverProof)
238		return nil, err
239	}
240	return batchInfo, nil
241}
242
243// Start the forging pipeline
244func (p *Pipeline) Start(batchNum common.BatchNum,
245	stats *synchronizer.Stats, vars *synchronizer.SCVariables) error {
246	if p.started {
247		log.Fatal("Pipeline already started")
248	}
249	p.started = true
250
251	if err := p.reset(batchNum, stats, vars); err != nil {
252		return tracerr.Wrap(err)
253	}
254	p.ctx, p.cancel = context.WithCancel(context.Background())
255
256	queueSize := 1
257	batchChSentServerProof := make(chan *BatchInfo, queueSize)
258
259	p.wg.Add(1)
260	go func() {
261		waitCh := time.After(zeroDuration)
262		for {
263			select {
264			case <-p.ctx.Done():
265				log.Info("Pipeline forgeBatch loop done")
266				p.wg.Done()
267				return
268			case statsVars := <-p.statsVarsCh:
269				p.stats = statsVars.Stats
270				p.syncSCVars(statsVars.Vars)
271			case <-waitCh:
272				// Once errAtBatchNum != 0, we stop forging
273				// batches because there's been an error and we
274				// wait for the pipeline to be stopped.
275				if p.getErrAtBatchNum() != 0 {
276					waitCh = time.After(p.cfg.ForgeRetryInterval)
277					continue
278				}
279				batchNum = p.state.batchNum + 1
280				batchInfo, err := p.handleForgeBatch(p.ctx, batchNum)
281				if p.ctx.Err() != nil {
282					waitCh = time.After(p.cfg.ForgeRetryInterval)
283					continue
284				} else if tracerr.Unwrap(err) == errLastL1BatchNotSynced ||
285					tracerr.Unwrap(err) == errForgeNoTxsBeforeDelay ||
286					tracerr.Unwrap(err) == errForgeBeforeDelay {
287					waitCh = time.After(p.cfg.ForgeRetryInterval)
288					continue
289				} else if err != nil {
290					p.setErrAtBatchNum(batchNum)
291					p.coord.SendMsg(p.ctx, MsgStopPipeline{
292						Reason: fmt.Sprintf(
293							"Pipeline.handleForgBatch: %v", err),
294						FailedBatchNum: batchNum,
295					})
296					waitCh = time.After(p.cfg.ForgeRetryInterval)
297					continue
298				}
299				p.lastForgeTime = time.Now()
300
301				p.state.batchNum = batchNum
302				select {
303				case batchChSentServerProof <- batchInfo:
304				case <-p.ctx.Done():
305				}
306				waitCh = time.After(zeroDuration)
307			}
308		}
309	}()
310
311	p.wg.Add(1)
312	go func() {
313		for {
314			select {
315			case <-p.ctx.Done():
316				log.Info("Pipeline waitServerProofSendEth loop done")
317				p.wg.Done()
318				return
319			case batchInfo := <-batchChSentServerProof:
320				// Once errAtBatchNum != 0, we stop forging
321				// batches because there's been an error and we
322				// wait for the pipeline to be stopped.
323				if p.getErrAtBatchNum() != 0 {
324					continue
325				}
326				err := p.waitServerProof(p.ctx, batchInfo)
327				if p.ctx.Err() != nil {
328					continue
329				} else if err != nil {
330					log.Errorw("waitServerProof", "err", err)
331					p.setErrAtBatchNum(batchInfo.BatchNum)
332					p.coord.SendMsg(p.ctx, MsgStopPipeline{
333						Reason: fmt.Sprintf(
334							"Pipeline.waitServerProof: %v", err),
335						FailedBatchNum: batchInfo.BatchNum,
336					})
337					continue
338				}
339				// We are done with this serverProof, add it back to the pool
340				p.proversPool.Add(p.ctx, batchInfo.ServerProof)
341				// batchInfo.ServerProof = nil
342				p.txManager.AddBatch(p.ctx, batchInfo)
343			}
344		}
345	}()
346	return nil
347}
348
349// Stop the forging pipeline
350func (p *Pipeline) Stop(ctx context.Context) {
351	if !p.started {
352		log.Fatal("Pipeline already stopped")
353	}
354	p.started = false
355	log.Info("Stopping Pipeline...")
356	p.cancel()
357	p.wg.Wait()
358	for _, prover := range p.provers {
359		if err := prover.Cancel(ctx); ctx.Err() != nil {
360			continue
361		} else if err != nil {
362			log.Errorw("prover.Cancel", "err", err)
363		}
364	}
365}
366
367// sendServerProof sends the circuit inputs to the proof server
368func (p *Pipeline) sendServerProof(ctx context.Context, batchInfo *BatchInfo) error {
369	p.cfg.debugBatchStore(batchInfo)
370
371	// 7. Call the selected idle server proof with BatchBuilder output,
372	// save server proof info for batchNum
373	if err := batchInfo.ServerProof.CalculateProof(ctx, batchInfo.ZKInputs); err != nil {
374		return tracerr.Wrap(err)
375	}
376	return nil
377}
378
379// forgeBatch forges the batchNum batch.
380func (p *Pipeline) forgeBatch(batchNum common.BatchNum) (batchInfo *BatchInfo, err error) {
381	// remove transactions from the pool that have been there for too long
382	_, err = p.purger.InvalidateMaybe(p.l2DB, p.txSelector.LocalAccountsDB(),
383		p.stats.Sync.LastBlock.Num, int64(batchNum))
384	if err != nil {
385		return nil, tracerr.Wrap(err)
386	}
387	_, err = p.purger.PurgeMaybe(p.l2DB, p.stats.Sync.LastBlock.Num, int64(batchNum))
388	if err != nil {
389		return nil, tracerr.Wrap(err)
390	}
391	// Structure to accumulate data and metadata of the batch
392	now := time.Now()
393	batchInfo = &BatchInfo{PipelineNum: p.num, BatchNum: batchNum}
394	batchInfo.Debug.StartTimestamp = now
395	batchInfo.Debug.StartBlockNum = p.stats.Eth.LastBlock.Num + 1
396
397	selectionCfg := &txselector.SelectionConfig{
398		MaxL1UserTxs:      common.RollupConstMaxL1UserTx,
399		TxProcessorConfig: p.cfg.TxProcessorConfig,
400	}
401
402	var poolL2Txs []common.PoolL2Tx
403	var discardedL2Txs []common.PoolL2Tx
404	var l1UserTxsExtra, l1CoordTxs []common.L1Tx
405	var auths [][]byte
406	var coordIdxs []common.Idx
407
408	// Check if the slot is not yet fulfilled
409	slotCommitted := false
410	if p.stats.Sync.Auction.CurrentSlot.ForgerCommitment ||
411		p.stats.Sync.Auction.CurrentSlot.SlotNum == p.state.lastSlotForged {
412		slotCommitted = true
413	}
414
415	// If we haven't reached the ForgeDelay, skip forging the batch
416	if slotCommitted && now.Sub(p.lastForgeTime) < p.cfg.ForgeDelay {
417		return nil, errForgeBeforeDelay
418	}
419
420	// 1. Decide if we forge L2Tx or L1+L2Tx
421	if p.shouldL1L2Batch(batchInfo) {
422		batchInfo.L1Batch = true
423		if p.state.lastForgeL1TxsNum != p.stats.Sync.LastForgeL1TxsNum {
424			return nil, tracerr.Wrap(errLastL1BatchNotSynced)
425		}
426		// 2a: L1+L2 txs
427		l1UserTxs, err := p.historyDB.GetUnforgedL1UserTxs(p.state.lastForgeL1TxsNum + 1)
428		if err != nil {
429			return nil, tracerr.Wrap(err)
430		}
431		coordIdxs, auths, l1UserTxsExtra, l1CoordTxs, poolL2Txs, discardedL2Txs, err =
432			p.txSelector.GetL1L2TxSelection(selectionCfg, l1UserTxs)
433		if err != nil {
434			return nil, tracerr.Wrap(err)
435		}
436	} else {
437		// 2b: only L2 txs
438		coordIdxs, auths, l1CoordTxs, poolL2Txs, discardedL2Txs, err =
439			p.txSelector.GetL2TxSelection(selectionCfg)
440		if err != nil {
441			return nil, tracerr.Wrap(err)
442		}
443		l1UserTxsExtra = nil
444	}
445
446	// If there are no txs to forge, no l1UserTxs in the open queue to
447	// freeze, and we haven't reached the ForgeNoTxsDelay, skip forging the
448	// batch.
449	if slotCommitted && now.Sub(p.lastForgeTime) < p.cfg.ForgeNoTxsDelay {
450		noTxs := false
451		if len(l1UserTxsExtra) == 0 && len(l1CoordTxs) == 0 && len(poolL2Txs) == 0 {
452			if batchInfo.L1Batch {
453				// Query the L1UserTxs in the queue following
454				// the one we are trying to forge.
455				nextL1UserTxs, err := p.historyDB.GetUnforgedL1UserTxs(
456					p.state.lastForgeL1TxsNum + 1)
457				if err != nil {
458					return nil, tracerr.Wrap(err)
459				}
460				// If there are future L1UserTxs, we forge a
461				// batch to advance the queues and forge the
462				// L1UserTxs in the future.  Otherwise, skip.
463				if len(nextL1UserTxs) == 0 {
464					noTxs = true
465				}
466			} else {
467				noTxs = true
468			}
469		}
470		if noTxs {
471			if err := p.txSelector.Reset(batchInfo.BatchNum-1, false); err != nil {
472				return nil, tracerr.Wrap(err)
473			}
474			return nil, errForgeNoTxsBeforeDelay
475		}
476	}
477
478	if batchInfo.L1Batch {
479		p.state.lastScheduledL1BatchBlockNum = p.stats.Eth.LastBlock.Num + 1
480		p.state.lastForgeL1TxsNum++
481	}
482
483	// 3.  Save metadata from TxSelector output for BatchNum
484	batchInfo.L1UserTxsExtra = l1UserTxsExtra
485	batchInfo.L1CoordTxs = l1CoordTxs
486	batchInfo.L1CoordinatorTxsAuths = auths
487	batchInfo.CoordIdxs = coordIdxs
488	batchInfo.VerifierIdx = p.cfg.VerifierIdx
489
490	if err := p.l2DB.StartForging(common.TxIDsFromPoolL2Txs(poolL2Txs), batchInfo.BatchNum); err != nil {
491		return nil, tracerr.Wrap(err)
492	}
493	if err := p.l2DB.UpdateTxsInfo(discardedL2Txs); err != nil {
494		return nil, tracerr.Wrap(err)
495	}
496
497	// Invalidate transactions that become invalid beause of
498	// the poolL2Txs selected.  Will mark as invalid the txs that have a
499	// (fromIdx, nonce) which already appears in the selected txs (includes
500	// all the nonces smaller than the current one)
501	err = p.l2DB.InvalidateOldNonces(idxsNonceFromPoolL2Txs(poolL2Txs), batchInfo.BatchNum)
502	if err != nil {
503		return nil, tracerr.Wrap(err)
504	}
505
506	// 4. Call BatchBuilder with TxSelector output
507	configBatch := &batchbuilder.ConfigBatch{
508		TxProcessorConfig: p.cfg.TxProcessorConfig,
509	}
510	zkInputs, err := p.batchBuilder.BuildBatch(coordIdxs, configBatch, l1UserTxsExtra,
511		l1CoordTxs, poolL2Txs)
512	if err != nil {
513		return nil, tracerr.Wrap(err)
514	}
515	l2Txs, err := common.PoolL2TxsToL2Txs(poolL2Txs) // NOTE: This is a big uggly, find a better way
516	if err != nil {
517		return nil, tracerr.Wrap(err)
518	}
519	batchInfo.L2Txs = l2Txs
520
521	// 5. Save metadata from BatchBuilder output for BatchNum
522	batchInfo.ZKInputs = zkInputs
523	batchInfo.Debug.Status = StatusForged
524	p.cfg.debugBatchStore(batchInfo)
525	log.Infow("Pipeline: batch forged internally", "batch", batchInfo.BatchNum)
526
527	p.state.lastSlotForged = p.stats.Sync.Auction.CurrentSlot.SlotNum
528
529	return batchInfo, nil
530}
531
532// waitServerProof gets the generated zkProof & sends it to the SmartContract
533func (p *Pipeline) waitServerProof(ctx context.Context, batchInfo *BatchInfo) error {
534	proof, pubInputs, err := batchInfo.ServerProof.GetProof(ctx) // blocking call, until not resolved don't continue. Returns when the proof server has calculated the proof
535	if err != nil {
536		return tracerr.Wrap(err)
537	}
538	batchInfo.Proof = proof
539	batchInfo.PublicInputs = pubInputs
540	batchInfo.ForgeBatchArgs = prepareForgeBatchArgs(batchInfo)
541	batchInfo.Debug.Status = StatusProof
542	p.cfg.debugBatchStore(batchInfo)
543	log.Infow("Pipeline: batch proof calculated", "batch", batchInfo.BatchNum)
544	return nil
545}
546
547func (p *Pipeline) shouldL1L2Batch(batchInfo *BatchInfo) bool {
548	// Take the lastL1BatchBlockNum as the biggest between the last
549	// scheduled one, and the synchronized one.
550	lastL1BatchBlockNum := p.state.lastScheduledL1BatchBlockNum
551	if p.stats.Sync.LastL1BatchBlock > lastL1BatchBlockNum {
552		lastL1BatchBlockNum = p.stats.Sync.LastL1BatchBlock
553	}
554	// Set Debug information
555	batchInfo.Debug.LastScheduledL1BatchBlockNum = p.state.lastScheduledL1BatchBlockNum
556	batchInfo.Debug.LastL1BatchBlock = p.stats.Sync.LastL1BatchBlock
557	batchInfo.Debug.LastL1BatchBlockDelta = p.stats.Eth.LastBlock.Num + 1 - lastL1BatchBlockNum
558	batchInfo.Debug.L1BatchBlockScheduleDeadline =
559		int64(float64(p.vars.Rollup.ForgeL1L2BatchTimeout-1) * p.cfg.L1BatchTimeoutPerc)
560	// Return true if we have passed the l1BatchTimeoutPerc portion of the
561	// range before the l1batch timeout.
562	return p.stats.Eth.LastBlock.Num+1-lastL1BatchBlockNum >=
563		int64(float64(p.vars.Rollup.ForgeL1L2BatchTimeout-1)*p.cfg.L1BatchTimeoutPerc)
564}
565
566func prepareForgeBatchArgs(batchInfo *BatchInfo) *eth.RollupForgeBatchArgs {
567	proof := batchInfo.Proof
568	zki := batchInfo.ZKInputs
569	return &eth.RollupForgeBatchArgs{
570		NewLastIdx:            int64(zki.Metadata.NewLastIdxRaw),
571		NewStRoot:             zki.Metadata.NewStateRootRaw.BigInt(),
572		NewExitRoot:           zki.Metadata.NewExitRootRaw.BigInt(),
573		L1UserTxs:             batchInfo.L1UserTxsExtra,
574		L1CoordinatorTxs:      batchInfo.L1CoordTxs,
575		L1CoordinatorTxsAuths: batchInfo.L1CoordinatorTxsAuths,
576		L2TxsData:             batchInfo.L2Txs,
577		FeeIdxCoordinator:     batchInfo.CoordIdxs,
578		// Circuit selector
579		VerifierIdx: batchInfo.VerifierIdx,
580		L1Batch:     batchInfo.L1Batch,
581		ProofA:      [2]*big.Int{proof.PiA[0], proof.PiA[1]},
582		// Implementation of the verifier need a swap on the proofB vector
583		ProofB: [2][2]*big.Int{
584			{proof.PiB[0][1], proof.PiB[0][0]},
585			{proof.PiB[1][1], proof.PiB[1][0]},
586		},
587		ProofC: [2]*big.Int{proof.PiC[0], proof.PiC[1]},
588	}
589}