@@ -71,6 +71,9 @@ type ProofReceiverLogic struct {
7171 validateFailureProverTaskStatusNotOk prometheus.Counter
7272 validateFailureProverTaskTimeout prometheus.Counter
7373 validateFailureProverTaskHaveVerifier prometheus.Counter
74+ proverSpeed * prometheus.GaugeVec
75+ provingTime prometheus.Gauge
76+ evmCyclePerGas prometheus.Gauge
7477
7578 ChunkTask provertask.ProverTask
7679 BundleTask provertask.ProverTask
@@ -79,6 +82,7 @@ type ProofReceiverLogic struct {
7982
8083// NewSubmitProofReceiverLogic create a proof receiver logic
8184func NewSubmitProofReceiverLogic (cfg * config.ProverManager , chainCfg * params.ChainConfig , db * gorm.DB , vf * verifier.Verifier , reg prometheus.Registerer ) * ProofReceiverLogic {
85+
8286 return & ProofReceiverLogic {
8387 chunkOrm : orm .NewChunk (db ),
8488 batchOrm : orm .NewBatch (db ),
@@ -133,6 +137,18 @@ func NewSubmitProofReceiverLogic(cfg *config.ProverManager, chainCfg *params.Cha
133137 Name : "coordinator_validate_failure_submit_have_been_verifier" ,
134138 Help : "Total number of submit proof validate failure proof have been verifier." ,
135139 }),
140+ evmCyclePerGas : promauto .With (reg ).NewGauge (prometheus.GaugeOpts {
141+ Name : "evm_circuit_cycle_per_gas" ,
142+ Help : "VM cycles cost for a gas unit cost in evm execution" ,
143+ }),
144+ provingTime : promauto .With (reg ).NewGauge (prometheus.GaugeOpts {
145+ Name : "chunk_proving_time" ,
146+ Help : "Wall clock time for chunk proving in second" ,
147+ }),
148+ proverSpeed : promauto .With (reg ).NewGaugeVec (prometheus.GaugeOpts {
149+ Name : "prover_speed" ,
150+ Help : "Cycle against running time of prover (in mhz)" ,
151+ }, []string {"type" , "phase" }),
136152 }
137153}
138154
@@ -204,12 +220,34 @@ func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofParameter coor
204220 return unmarshalErr
205221 }
206222 success , verifyErr = m .verifier .VerifyChunkProof (chunkProof , hardForkName )
223+ if stat := chunkProof .VmProof .Stat ; stat != nil {
224+ if g , _ := m .proverSpeed .GetMetricWithLabelValues ("chunk" , "exec" ); g != nil && stat .ExecutionTimeMills > 0 {
225+ g .Set (float64 (stat .TotalCycle ) / float64 (stat .ExecutionTimeMills * 1000 ))
226+ }
227+ if g , _ := m .proverSpeed .GetMetricWithLabelValues ("chunk" , "proving" ); g != nil && stat .ProvingTimeMills > 0 {
228+ g .Set (float64 (stat .TotalCycle ) / float64 (stat .ProvingTimeMills * 1000 ))
229+ }
230+ if chunkProof .MetaData .TotalGasUsed > 0 {
231+ cycle_per_gas := float64 (stat .TotalCycle ) / float64 (chunkProof .MetaData .TotalGasUsed )
232+ m .evmCyclePerGas .Set (cycle_per_gas )
233+ }
234+ m .provingTime .Set (float64 (stat .ProvingTimeMills ) / 1000 )
235+ }
236+
207237 case message .ProofTypeBatch :
208238 batchProof := & message.OpenVMBatchProof {}
209239 if unmarshalErr := json .Unmarshal ([]byte (proofParameter .Proof ), & batchProof ); unmarshalErr != nil {
210240 return unmarshalErr
211241 }
212242 success , verifyErr = m .verifier .VerifyBatchProof (batchProof , hardForkName )
243+ if stat := batchProof .VmProof .Stat ; stat != nil {
244+ if g , _ := m .proverSpeed .GetMetricWithLabelValues ("batch" , "exec" ); g != nil && stat .ExecutionTimeMills > 0 {
245+ g .Set (float64 (stat .TotalCycle ) / float64 (stat .ExecutionTimeMills * 1000 ))
246+ }
247+ if g , _ := m .proverSpeed .GetMetricWithLabelValues ("batch" , "proving" ); g != nil && stat .ProvingTimeMills > 0 {
248+ g .Set (float64 (stat .TotalCycle ) / float64 (stat .ProvingTimeMills * 1000 ))
249+ }
250+ }
213251 case message .ProofTypeBundle :
214252 bundleProof := & message.OpenVMBundleProof {}
215253 if unmarshalErr := json .Unmarshal ([]byte (proofParameter .Proof ), & bundleProof ); unmarshalErr != nil {
0 commit comments