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, 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, 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, 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 selectionCfg := &txselector.SelectionConfig{
411 MaxL1UserTxs: common.RollupConstMaxL1UserTx,
412 TxProcessorConfig: p.cfg.TxProcessorConfig,
413 }
414
415 var poolL2Txs []common.PoolL2Tx
416 var discardedL2Txs []common.PoolL2Tx
417 var l1UserTxsExtra, l1CoordTxs []common.L1Tx
418 var auths [][]byte
419 var coordIdxs []common.Idx
420
421 // Check if the slot is not yet fulfilled
422 slotCommitted := false
423 if p.stats.Sync.Auction.CurrentSlot.ForgerCommitment ||
424 p.stats.Sync.Auction.CurrentSlot.SlotNum == p.state.lastSlotForged {
425 slotCommitted = true
426 }
427
428 // If we haven't reached the ForgeDelay, skip forging the batch
429 if slotCommitted && now.Sub(p.lastForgeTime) < p.cfg.ForgeDelay {
430 return nil, errForgeBeforeDelay
431 }
432
433 // 1. Decide if we forge L2Tx or L1+L2Tx
434 if p.shouldL1L2Batch(batchInfo) {
435 batchInfo.L1Batch = true
436 if p.state.lastForgeL1TxsNum != p.stats.Sync.LastForgeL1TxsNum {
437 return nil, tracerr.Wrap(errLastL1BatchNotSynced)
438 }
439 // 2a: L1+L2 txs
440 l1UserTxs, err := p.historyDB.GetUnforgedL1UserTxs(p.state.lastForgeL1TxsNum + 1)
441 if err != nil {
442 return nil, tracerr.Wrap(err)
443 }
444 coordIdxs, auths, l1UserTxsExtra, l1CoordTxs, poolL2Txs, discardedL2Txs, err =
445 p.txSelector.GetL1L2TxSelection(selectionCfg, l1UserTxs)
446 if err != nil {
447 return nil, tracerr.Wrap(err)
448 }
449 } else {
450 // 2b: only L2 txs
451 coordIdxs, auths, l1CoordTxs, poolL2Txs, discardedL2Txs, err =
452 p.txSelector.GetL2TxSelection(selectionCfg)
453 if err != nil {
454 return nil, tracerr.Wrap(err)
455 }
456 l1UserTxsExtra = nil
457 }
458
459 // If there are no txs to forge, no l1UserTxs in the open queue to
460 // freeze, and we haven't reached the ForgeNoTxsDelay, skip forging the
461 // batch.
462 if slotCommitted && now.Sub(p.lastForgeTime) < p.cfg.ForgeNoTxsDelay {
463 noTxs := false
464 if len(l1UserTxsExtra) == 0 && len(l1CoordTxs) == 0 && len(poolL2Txs) == 0 {
465 if batchInfo.L1Batch {
466 // Query the number of unforged L1UserTxs
467 // (either in a open queue or in a frozen
468 // not-yet-forged queue).
469 count, err := p.historyDB.GetUnforgedL1UserTxsCount()
470 if err != nil {
471 return nil, tracerr.Wrap(err)
472 }
473 // If there are future L1UserTxs, we forge a
474 // batch to advance the queues to be able to
475 // forge the L1UserTxs in the future.
476 // Otherwise, skip.
477 if count == 0 {
478 noTxs = true
479 }
480 } else {
481 noTxs = true
482 }
483 }
484 if noTxs {
485 if err := p.txSelector.Reset(batchInfo.BatchNum-1, false); err != nil {
486 return nil, tracerr.Wrap(err)
487 }
488 return nil, errForgeNoTxsBeforeDelay
489 }
490 }
491
492 if batchInfo.L1Batch {
493 p.state.lastScheduledL1BatchBlockNum = p.stats.Eth.LastBlock.Num + 1
494 p.state.lastForgeL1TxsNum++
495 }
496
497 // 3. Save metadata from TxSelector output for BatchNum
498 batchInfo.L1UserTxsExtra = l1UserTxsExtra
499 batchInfo.L1CoordTxs = l1CoordTxs
500 batchInfo.L1CoordinatorTxsAuths = auths
501 batchInfo.CoordIdxs = coordIdxs
502 batchInfo.VerifierIdx = p.cfg.VerifierIdx
503
504 if err := p.l2DB.StartForging(common.TxIDsFromPoolL2Txs(poolL2Txs),
505 batchInfo.BatchNum); err != nil {
506 return nil, tracerr.Wrap(err)
507 }
508 if err := p.l2DB.UpdateTxsInfo(discardedL2Txs); err != nil {
509 return nil, tracerr.Wrap(err)
510 }
511
512 // Invalidate transactions that become invalid beause of
513 // the poolL2Txs selected. Will mark as invalid the txs that have a
514 // (fromIdx, nonce) which already appears in the selected txs (includes
515 // all the nonces smaller than the current one)
516 err = p.l2DB.InvalidateOldNonces(idxsNonceFromPoolL2Txs(poolL2Txs), batchInfo.BatchNum)
517 if err != nil {
518 return nil, tracerr.Wrap(err)
519 }
520
521 // 4. Call BatchBuilder with TxSelector output
522 configBatch := &batchbuilder.ConfigBatch{
523 TxProcessorConfig: p.cfg.TxProcessorConfig,
524 }
525 zkInputs, err := p.batchBuilder.BuildBatch(coordIdxs, configBatch, l1UserTxsExtra,
526 l1CoordTxs, poolL2Txs)
527 if err != nil {
528 return nil, tracerr.Wrap(err)
529 }
530 l2Txs, err := common.PoolL2TxsToL2Txs(poolL2Txs) // NOTE: This is a big uggly, find a better way
531 if err != nil {
532 return nil, tracerr.Wrap(err)
533 }
534 batchInfo.L2Txs = l2Txs
535
536 // 5. Save metadata from BatchBuilder output for BatchNum
537 batchInfo.ZKInputs = zkInputs
538 batchInfo.Debug.Status = StatusForged
539 p.cfg.debugBatchStore(batchInfo)
540 log.Infow("Pipeline: batch forged internally", "batch", batchInfo.BatchNum)
541
542 p.state.lastSlotForged = p.stats.Sync.Auction.CurrentSlot.SlotNum
543
544 return batchInfo, nil
545}
546
547// waitServerProof gets the generated zkProof & sends it to the SmartContract
548func (p *Pipeline) waitServerProof(ctx context.Context, batchInfo *BatchInfo) error {
549 proof, pubInputs, err := batchInfo.ServerProof.GetProof(ctx) // blocking call,
550 // until not resolved don't continue. Returns when the proof server has calculated the proof
551 if err != nil {
552 return tracerr.Wrap(err)
553 }
554 batchInfo.Proof = proof
555 batchInfo.PublicInputs = pubInputs
556 batchInfo.ForgeBatchArgs = prepareForgeBatchArgs(batchInfo)
557 batchInfo.Debug.Status = StatusProof
558 p.cfg.debugBatchStore(batchInfo)
559 log.Infow("Pipeline: batch proof calculated", "batch", batchInfo.BatchNum)
560 return nil
561}
562
563func (p *Pipeline) shouldL1L2Batch(batchInfo *BatchInfo) bool {
564 // Take the lastL1BatchBlockNum as the biggest between the last
565 // scheduled one, and the synchronized one.
566 lastL1BatchBlockNum := p.state.lastScheduledL1BatchBlockNum
567 if p.stats.Sync.LastL1BatchBlock > lastL1BatchBlockNum {
568 lastL1BatchBlockNum = p.stats.Sync.LastL1BatchBlock
569 }
570 // Set Debug information
571 batchInfo.Debug.LastScheduledL1BatchBlockNum = p.state.lastScheduledL1BatchBlockNum
572 batchInfo.Debug.LastL1BatchBlock = p.stats.Sync.LastL1BatchBlock
573 batchInfo.Debug.LastL1BatchBlockDelta = p.stats.Eth.LastBlock.Num + 1 - lastL1BatchBlockNum
574 batchInfo.Debug.L1BatchBlockScheduleDeadline =
575 int64(float64(p.vars.Rollup.ForgeL1L2BatchTimeout-1) * p.cfg.L1BatchTimeoutPerc)
576 // Return true if we have passed the l1BatchTimeoutPerc portion of the
577 // range before the l1batch timeout.
578 return p.stats.Eth.LastBlock.Num+1-lastL1BatchBlockNum >=
579 int64(float64(p.vars.Rollup.ForgeL1L2BatchTimeout-1)*p.cfg.L1BatchTimeoutPerc)
580}
581
582func prepareForgeBatchArgs(batchInfo *BatchInfo) *eth.RollupForgeBatchArgs {
583 proof := batchInfo.Proof
584 zki := batchInfo.ZKInputs
585 return ð.RollupForgeBatchArgs{
586 NewLastIdx: int64(zki.Metadata.NewLastIdxRaw),
587 NewStRoot: zki.Metadata.NewStateRootRaw.BigInt(),
588 NewExitRoot: zki.Metadata.NewExitRootRaw.BigInt(),
589 L1UserTxs: batchInfo.L1UserTxsExtra,
590 L1CoordinatorTxs: batchInfo.L1CoordTxs,
591 L1CoordinatorTxsAuths: batchInfo.L1CoordinatorTxsAuths,
592 L2TxsData: batchInfo.L2Txs,
593 FeeIdxCoordinator: batchInfo.CoordIdxs,
594 // Circuit selector
595 VerifierIdx: batchInfo.VerifierIdx,
596 L1Batch: batchInfo.L1Batch,
597 ProofA: [2]*big.Int{proof.PiA[0], proof.PiA[1]},
598 // Implementation of the verifier need a swap on the proofB vector
599 ProofB: [2][2]*big.Int{
600 {proof.PiB[0][1], proof.PiB[0][0]},
601 {proof.PiB[1][1], proof.PiB[1][0]},
602 },
603 ProofC: [2]*big.Int{proof.PiC[0], proof.PiC[1]},
604 }
605}