From 6f05b7695744a979ee38604c7204cbbbab53330a Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 19:43:13 +0800 Subject: [PATCH] feat(prover): add some prover metrics for Alpha-4 protocol --- .github/workflows/docker.yml | 2 +- metrics/metrics.go | 3 +++ prover/prover.go | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1b1491c56..17a76238a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,7 @@ name: "Push docker image to GCR" on: push: - branches: [main] + branches: [main,more-prover-metrics] tags: - "v*" diff --git a/metrics/metrics.go b/metrics/metrics.go index b3633f737..f2110c350 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -40,6 +40,9 @@ var ( ProverSentProofCounter = metrics.NewRegisteredCounter("prover/proof/all/sent", nil) ProverSentValidProofCounter = metrics.NewRegisteredCounter("prover/proof/valid/sent", nil) ProverSentInvalidProofCounter = metrics.NewRegisteredCounter("prover/proof/invalid/sent", nil) + ProverProofsAssigned = metrics.NewRegisteredCounter("prover/proof/assigned", nil) + ProverSlashedCounter = metrics.NewRegisteredCounter("prover/slashed", nil) + ProverSlashedAmount = metrics.NewRegisteredCounter("prover/slashed/amount", nil) ProverReceivedProposedBlockGauge = metrics.NewRegisteredGauge("prover/proposed/received", nil) ProverReceivedProvenBlockGauge = metrics.NewRegisteredGauge("prover/proven/received", nil) ProverAllProofRewardGauge = metrics.NewRegisteredGauge("prover/allProofReward", nil) diff --git a/prover/prover.go b/prover/prover.go index b971f4d11..eef60a1d4 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -297,6 +297,8 @@ func (p *Prover) eventLoop() { case e := <-p.proverSlashedCh: if e.Addr.Hex() == p.proverAddress.Hex() { log.Info("Prover slashed", "address", e.Addr.Hex(), "amount", e.Amount) + metrics.ProverSlashedCounter.Inc(1) + metrics.ProverSlashedAmount.Inc(int64(e.Amount)) } case <-forceProvingTicker.C: reqProving() @@ -559,6 +561,8 @@ func (p *Prover) onBlockProposed( "prover", block.AssignedProver.Hex(), "proofWindowExpired", proofWindowExpired, ) + + metrics.ProverProofsAssigned.Inc(1) } ctx, cancelCtx := context.WithCancel(ctx)