Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
fix#14826 Add Proof Generation Metric.
Browse files Browse the repository at this point in the history
  • Loading branch information
00x-dx committed Oct 1, 2023
1 parent ff8c6b2 commit b1eafce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var (
ProverProofsAssigned = metrics.NewRegisteredCounter("prover/proof/assigned", nil)
ProverReceivedProposedBlockGauge = metrics.NewRegisteredGauge("prover/proposed/received", nil)
ProverReceivedProvenBlockGauge = metrics.NewRegisteredGauge("prover/proven/received", nil)
// TODO: Look-out for the last 8 proof generation times.
ProofGenerationTime = metrics.NewRegisteredHistogram("prover/proof/generation/time", nil, metrics.NewUniformSample(8))
)

// Serve starts the metrics server on the given address, will be closed when the given
Expand Down
12 changes: 8 additions & 4 deletions prover/proof_producer/zkevm_rpcd_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/taikoxyz/taiko-client/metrics"
"io"
"math/big"
"net/http"
Expand Down Expand Up @@ -165,9 +166,10 @@ func (p *ZkevmRpcdProducer) RequestProof(
// callProverDaemon keeps polling the proverd service to get the requested proof.
func (p *ZkevmRpcdProducer) callProverDaemon(ctx context.Context, opts *ProofRequestOptions) ([]byte, uint64, error) {
var (
proof []byte
degree uint64
start = time.Now()
proof []byte
degree uint64
start = time.Now()
proofGenerationTime time.Duration
)
if err := backoff.Retry(func() error {
if ctx.Err() != nil {
Expand All @@ -194,11 +196,13 @@ func (p *ZkevmRpcdProducer) callProverDaemon(ctx context.Context, opts *ProofReq

proof = common.Hex2Bytes(proofOutput)
degree = output.Aggregation.Degree
log.Info("Proof generated", "height", opts.Height, "degree", degree, "time", time.Since(start))
proofGenerationTime = time.Since(start)
log.Info("Proof generated", "height", opts.Height, "degree", degree, "time", proofGenerationTime)
return nil
}, backoff.NewConstantBackOff(proofPollingInterval)); err != nil {
return nil, 0, err
}
metrics.ProofGenerationTime.Update(proofGenerationTime.Nanoseconds())
return proof, degree, nil
}

Expand Down

0 comments on commit b1eafce

Please sign in to comment.