From 6d84d143a2a87838f8ccdcd9e00e8d684ea7b429 Mon Sep 17 00:00:00 2001 From: Pantani Date: Tue, 23 Mar 2021 01:40:45 -0300 Subject: [PATCH] Measure the server proof duration --- coordinator/batch.go | 1 + coordinator/pipeline.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/coordinator/batch.go b/coordinator/batch.go index 8df15d8..75f35ad 100644 --- a/coordinator/batch.go +++ b/coordinator/batch.go @@ -80,6 +80,7 @@ type BatchInfo struct { PipelineNum int BatchNum common.BatchNum ServerProof prover.Client + ProofStart time.Time ZKInputs *common.ZKInputs Proof *prover.Proof PublicInputs []*big.Int diff --git a/coordinator/pipeline.go b/coordinator/pipeline.go index aa690b4..939815e 100644 --- a/coordinator/pipeline.go +++ b/coordinator/pipeline.go @@ -5,6 +5,7 @@ import ( "database/sql" "fmt" "math/big" + "strconv" "sync" "time" @@ -14,6 +15,7 @@ import ( "github.com/hermeznetwork/hermez-node/db/l2db" "github.com/hermeznetwork/hermez-node/eth" "github.com/hermeznetwork/hermez-node/log" + "github.com/hermeznetwork/hermez-node/metric" "github.com/hermeznetwork/hermez-node/prover" "github.com/hermeznetwork/hermez-node/synchronizer" "github.com/hermeznetwork/hermez-node/txselector" @@ -246,6 +248,7 @@ func (p *Pipeline) handleForgeBatch(ctx context.Context, // 3. Send the ZKInputs to the proof server batchInfo.ServerProof = serverProof + batchInfo.ProofStart = time.Now() if err := p.sendServerProof(ctx, batchInfo); ctx.Err() != nil { return nil, ctx.Err() } else if err != nil { @@ -602,6 +605,9 @@ func (p *Pipeline) forgeBatch(batchNum common.BatchNum) (batchInfo *BatchInfo, // waitServerProof gets the generated zkProof & sends it to the SmartContract func (p *Pipeline) waitServerProof(ctx context.Context, batchInfo *BatchInfo) error { + 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 {