send the verified preimages

pull/4513/head
Diego Nava 1 year ago
parent 8824e42136
commit 0fadfe3e18
No known key found for this signature in database
GPG Key ID: 61AFC8738DA8B8B1
  1. 2
      cmd/harmony/main.go
  2. 14
      consensus/metrics.go
  3. 21
      core/preimages.go

@ -505,7 +505,7 @@ func setupNodeAndRun(hc harmonyconfig.HarmonyConfig) {
}
go func() {
core.WritePreimagesMetricsIntoPrometheus(currentNode.Blockchain().ChainDb(), currentNode.Consensus.UpdatePreimageGenerationMetrics)
core.WritePreimagesMetricsIntoPrometheus(currentNode.Blockchain(), currentNode.Consensus.UpdatePreimageGenerationMetrics)
}()
go listenOSSigAndShutDown(currentNode)

@ -25,7 +25,14 @@ var (
Help: "the last block for which pre-image generation ran locally",
},
)
verifiedPreimagesGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "hmy",
Subsystem: "blockchain",
Name: "verified_preimages",
Help: "the number of verified preimages",
},
)
lastPreimageImportGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "hmy",
@ -129,7 +136,7 @@ func (consensus *Consensus) UpdateLeaderMetrics(numCommits float64, blockNum flo
consensusCounterVec.With(prometheus.Labels{"consensus": "num_commits"}).Add(numCommits)
consensusGaugeVec.With(prometheus.Labels{"consensus": "num_commits"}).Set(numCommits)
}
func (consensus *Consensus) UpdatePreimageGenerationMetrics(preimageStart, preimageEnd, lastPreimageImport uint64) {
func (consensus *Consensus) UpdatePreimageGenerationMetrics(preimageStart, preimageEnd, lastPreimageImport, verifiedAddresses uint64) {
if lastPreimageImport > 0 {
lastPreimageImportGauge.Set(float64(lastPreimageImport))
}
@ -139,6 +146,9 @@ func (consensus *Consensus) UpdatePreimageGenerationMetrics(preimageStart, preim
if preimageEnd > 0 {
preimageEndGauge.Set(float64(preimageEnd))
}
if verifiedAddresses > 0 {
verifiedPreimagesGauge.Set(float64(verifiedAddresses))
}
}
// AddPubkeyMetrics add the list of blskeys to prometheus metrics

@ -6,11 +6,11 @@ import (
"io"
"os"
"strconv"
"time"
"github.com/ethereum/go-ethereum/common"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/core/rawdb"
"github.com/harmony-one/harmony/core/state"
@ -339,10 +339,25 @@ func VerifyPreimages(header *block.Header, chain BlockChain) (uint64, error) {
return existingPreimages, nil
}
func WritePreimagesMetricsIntoPrometheus(dbReader ethdb.Database, sendMetrics func(preimageStart, preimageEnd, lastPreimageImport uint64)) {
func WritePreimagesMetricsIntoPrometheus(chain BlockChain, sendMetrics func(preimageStart, preimageEnd, lastPreimageImport, verifiedAddresses uint64)) {
if chain.ShardID() < 2 {
return
}
ticker := time.NewTicker(time.Minute * 5)
dbReader := chain.ChainDb()
for {
select {
case <-ticker.C:
lastImport, _ := rawdb.ReadPreimageImportBlock(dbReader)
startBlock, _ := rawdb.ReadPreImageStartBlock(dbReader)
endBlock, _ := rawdb.ReadPreImageEndBlock(dbReader)
sendMetrics(startBlock, endBlock, lastImport)
chain.CurrentBlock().NumberU64()
verify, _ := VerifyPreimages(chain.CurrentBlock().Header(), chain)
sendMetrics(startBlock, endBlock, lastImport, verify)
}
}
}

Loading…
Cancel
Save