Skip to content

Commit

Permalink
implement wait for prover funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Intizar-T committed Dec 26, 2024
1 parent e2038d6 commit c02369a
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions sequencer/coordinator/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"context"
"database/sql"
"fmt"
"math/big"
"sync"
"time"
"tokamak-sybil-resistance/batchbuilder"
"tokamak-sybil-resistance/common"
"tokamak-sybil-resistance/coordinator/prover"
"tokamak-sybil-resistance/database/historydb"
"tokamak-sybil-resistance/eth"
"tokamak-sybil-resistance/log"
"tokamak-sybil-resistance/synchronizer"
"tokamak-sybil-resistance/txselector"
Expand Down Expand Up @@ -301,24 +303,23 @@ func (p *Pipeline) setErrAtBatchNum(batchNum common.BatchNum) {
p.errAtBatchNum = batchNum
}

// TODO: implement
// waitServerProof gets the generated zkProof & sends it to the SmartContract
func (p *Pipeline) waitServerProof(ctx context.Context, batchInfo *BatchInfo) error {
// TODO: implement prometheus metrics
// defer metric.MeasureDuration(metric.WaitServerProof, batchInfo.ProofStart,
// batchInfo.BatchNum.BigInt().String(), strconv.Itoa(batchInfo.PipelineNum))

// proof, pubInputs, err := batchInfo.ServerProof.GetProof(ctx) // blocking call,
// // until not resolved don't continue. Returns when the proof server has calculated the proof
// if err != nil {
// return common.Wrap(err)
// }
// batchInfo.Proof = proof
// batchInfo.PublicInputs = pubInputs
// batchInfo.ForgeBatchArgs = prepareForgeBatchArgs(batchInfo)
// batchInfo.Debug.Status = StatusProof
// p.cfg.debugBatchStore(batchInfo)
// log.Infow("Pipeline: batch proof calculated", "batch", batchInfo.BatchNum)
proof, pubInputs, err := batchInfo.ServerProof.GetProof(ctx) // blocking call,
// until not resolved don't continue. Returns when the proof server has calculated the proof
if err != nil {
return common.Wrap(err)
}
batchInfo.Proof = proof
batchInfo.PublicInputs = pubInputs
batchInfo.ForgeBatchArgs = prepareForgeBatchArgs(batchInfo)
batchInfo.Debug.Status = StatusProof
p.cfg.debugBatchStore(batchInfo)
log.Infow("Pipeline: batch proof calculated", "batch", batchInfo.BatchNum)
return nil
}

Expand Down Expand Up @@ -439,3 +440,27 @@ func (p *Pipeline) SetSyncStatsVars(
case <-ctx.Done():
}
}

// TODO: discuss with the circuit team if new roots are necessary
func prepareForgeBatchArgs(batchInfo *BatchInfo) *eth.RollupForgeBatchArgs {
proof := batchInfo.Proof
// zki := batchInfo.ZKInputs
return &eth.RollupForgeBatchArgs{
// NewLastIdx: int64(zki.Metadata.NewLastIdxRaw),
// NewAccountRoot: zki.Metadata.NewStateRootRaw.BigInt(),
// NewVouchRoot: zki.Metadata.NewStateRootRaw.BigInt(),
// NewScoreRoot: zki.Metadata.NewStateRootRaw.BigInt(),
// NewExitRoot: zki.Metadata.NewExitRootRaw.BigInt(),
L1UserTxs: batchInfo.L1UserTxs,
L1CoordinatorTxsAuths: batchInfo.L1CoordinatorTxsAuths,
// Circuit selector
VerifierIdx: batchInfo.VerifierIdx,
ProofA: [2]*big.Int{proof.PiA[0], proof.PiA[1]},
// Implementation of the verifier need a swap on the proofB vector
ProofB: [2][2]*big.Int{
{proof.PiB[0][1], proof.PiB[0][0]},
{proof.PiB[1][1], proof.PiB[1][0]},
},
ProofC: [2]*big.Int{proof.PiC[0], proof.PiC[1]},
}
}

0 comments on commit c02369a

Please sign in to comment.