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

feat(prover): add some prover metrics for Alpha-4 protocol #319

Merged
merged 7 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ 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)
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
Expand Down
3 changes: 3 additions & 0 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 11 additions & 2 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -559,6 +561,8 @@ func (p *Prover) onBlockProposed(
"prover", block.AssignedProver.Hex(),
"proofWindowExpired", proofWindowExpired,
)

metrics.ProverProofsAssigned.Inc(1)
}

ctx, cancelCtx := context.WithCancel(ctx)
Expand Down Expand Up @@ -627,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
Expand Down