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