From 6f05b7695744a979ee38604c7204cbbbab53330a Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 19:43:13 +0800 Subject: [PATCH 1/7] 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) From 89ff950f39bb98881fff3d8777cb40b39350aa2d Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 19:44:13 +0800 Subject: [PATCH 2/7] feat: update workflow --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 17a76238a..1b1491c56 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,more-prover-metrics] + branches: [main] tags: - "v*" From ad946409b225a1374657602e5cbc9f990e6c8bd3 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 22:10:40 +0800 Subject: [PATCH 3/7] feat: update reward metrics --- .github/workflows/docker.yml | 2 +- metrics/metrics.go | 2 +- prover/prover.go | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1b1491c56..d18db0ecc 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 f2110c350..7583afa4b 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -45,8 +45,8 @@ var ( ProverSlashedAmount = metrics.NewRegisteredCounter("prover/slashed/amount", nil) ProverReceivedProposedBlockGauge = metrics.NewRegisteredGauge("prover/proposed/received", nil) ProverReceivedProvenBlockGauge = metrics.NewRegisteredGauge("prover/proven/received", nil) + ProverProofRewardGauge = metrics.NewRegisteredGauge("prover/proofReward", nil) ProverAllProofRewardGauge = metrics.NewRegisteredGauge("prover/allProofReward", nil) - ProverNormalProofRewardGauge = metrics.NewRegisteredGauge("prover/normalProofReward", nil) ) // Serve starts the metrics server on the given address, will be closed when the given diff --git a/prover/prover.go b/prover/prover.go index eef60a1d4..5d3647413 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -631,10 +631,15 @@ func (p *Prover) submitProofOp(ctx context.Context, proofWithHeader *proofProduc func (p *Prover) onBlockVerified(ctx context.Context, event *bindings.TaikoL1ClientBlockVerified) error { metrics.ProverLatestVerifiedIDGauge.Update(event.BlockId.Int64()) + var reward int64 if event.ProofReward > math.MaxInt64 { - metrics.ProverAllProofRewardGauge.Update(math.MaxInt64) + reward = math.MaxInt64 } else { - metrics.ProverAllProofRewardGauge.Update(int64(event.ProofReward)) + reward = int64(event.ProofReward) + } + metrics.ProverAllProofRewardGauge.Update(reward) + if event.Prover == p.proverAddress { + metrics.ProverProofRewardGauge.Update(reward) } p.latestVerifiedL1Height = event.Raw.BlockNumber From b96c7dd036d47e889f6d1888587b26cc6168f79c Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 22:10:58 +0800 Subject: [PATCH 4/7] feat: update workflow --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d18db0ecc..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,more-prover-metrics)] + branches: [main,more-prover-metrics] tags: - "v*" From e7258541522a8108ba65cdeb57fdf0e849d40dbe Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 22:11:10 +0800 Subject: [PATCH 5/7] feat: update workflow --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 17a76238a..1b1491c56 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,more-prover-metrics] + branches: [main] tags: - "v*" From 2263f2306bf4d034b5445d7cb9ae1b18ef097e5c Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 22:14:00 +0800 Subject: [PATCH 6/7] feat: update workflow --- .github/workflows/docker.yml | 2 +- proposer/proposer.go | 3 +++ 2 files changed, 4 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/proposer/proposer.go b/proposer/proposer.go index 89f47ab2b..f75bf9c42 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -184,6 +184,9 @@ func (p *Proposer) ProposeOp(ctx context.Context) error { } log.Info("Comparing proposer TKO balance to block fee", "proposer", p.l1ProposerAddress.Hex()) + if err := p.CheckTaikoTokenBalance(); err != nil { + return fmt.Errorf("failed to check token balance: %w", err) + } // Wait until L2 execution engine is synced at first. if err := p.rpc.WaitTillL2ExecutionEngineSynced(ctx); err != nil { From 83e364e5c5ff4154aeb69536b0158b9d67f7776b Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Jul 2023 22:14:07 +0800 Subject: [PATCH 7/7] feat: update workflow --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 17a76238a..1b1491c56 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,more-prover-metrics] + branches: [main] tags: - "v*"