Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove dynamic metric labels about fast finality #1572

Merged
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
8 changes: 4 additions & 4 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ var (
diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures
diffNoTurn = big.NewInt(1) // Block difficulty for out-of-turn signatures
// 100 native token
maxSystemBalance = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether))
verifyVoteAttestationFailedGauge = metrics.NewRegisteredGauge("parlia/verifyVoteAttestationFailed", nil)
updateAttestationFailedGauge = metrics.NewRegisteredGauge("parlia/updateAttestationFailed", nil)
maxSystemBalance = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether))
verifyVoteAttestationErrorCounter = metrics.NewRegisteredCounter("parlia/verifyVoteAttestation/error", nil)
updateAttestationErrorCounter = metrics.NewRegisteredCounter("parlia/updateAttestation/error", nil)

systemContracts = map[common.Address]bool{
common.HexToAddress(systemcontracts.ValidatorContract): true,
Expand Down Expand Up @@ -599,7 +599,7 @@ func (p *Parlia) verifyCascadingFields(chain consensus.ChainHeaderReader, header

// Verify vote attestation for fast finality.
if err := p.verifyVoteAttestation(chain, header, parents); err != nil {
verifyVoteAttestationFailedGauge.Inc(1)
verifyVoteAttestationErrorCounter.Inc(1)
if chain.Config().IsPlato(header.Number) {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (s *Snapshot) updateAttestation(header *types.Header, chainConfig *params.C
if targetHash != header.ParentHash || targetNumber+1 != header.Number.Uint64() {
log.Warn("updateAttestation failed", "error", fmt.Errorf("invalid attestation, target mismatch, expected block: %d, hash: %s; real block: %d, hash: %s",
header.Number.Uint64()-1, header.ParentHash, targetNumber, targetHash))
updateAttestationFailedGauge.Inc(1)
updateAttestationErrorCounter.Inc(1)
return
}

Expand Down
2 changes: 1 addition & 1 deletion core/vote/vote_journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type VoteJournal struct {
voteDataBuffer *lru.Cache
}

var voteJournalError = metrics.NewRegisteredGauge("voteJournal/local", nil)
var voteJournalErrorCounter = metrics.NewRegisteredCounter("voteJournal/error", nil)

func NewVoteJournal(filePath string) (*VoteJournal, error) {
walLog, err := wal.Open(filePath, &wal.Options{
Expand Down
15 changes: 6 additions & 9 deletions core/vote/vote_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/ethereum/go-ethereum/params"
)

var votesManagerCounter = metrics.NewRegisteredCounter("votesManager/local", nil)

// VoteManager will handle the vote produced by self.
type VoteManager struct {
mux *event.TypeMux
Expand Down Expand Up @@ -138,19 +140,19 @@ func (voteManager *VoteManager) loop() {
voteMessage.Data.SourceHash = sourceHash

if err := voteManager.signer.SignVote(voteMessage); err != nil {
log.Error("Failed to sign vote", "err", err)
votesSigningErrorMetric(vote.TargetNumber, vote.TargetHash).Inc(1)
log.Error("Failed to sign vote", "err", err, "votedBlockNumber", voteMessage.Data.TargetNumber, "votedBlockHash", voteMessage.Data.TargetHash, "voteMessageHash", voteMessage.Hash())
votesSigningErrorCounter.Inc(1)
continue
}
if err := voteManager.journal.WriteVote(voteMessage); err != nil {
log.Error("Failed to write vote into journal", "err", err)
voteJournalError.Inc(1)
voteJournalErrorCounter.Inc(1)
continue
}

log.Debug("vote manager produced vote", "votedBlockNumber", voteMessage.Data.TargetNumber, "votedBlockHash", voteMessage.Data.TargetHash, "voteMessageHash", voteMessage.Hash())
voteManager.pool.PutVote(voteMessage)
votesManagerMetric(vote.TargetNumber, vote.TargetHash).Inc(1)
votesManagerCounter.Inc(1)
}
case <-voteManager.chainHeadSub.Err():
log.Debug("voteManager subscribed chainHead failed")
Expand Down Expand Up @@ -217,8 +219,3 @@ func (voteManager *VoteManager) UnderRules(header *types.Header) (bool, uint64,
log.Debug("All three rules check passed")
return true, sourceNumber, sourceHash
}

// Metrics to monitor if voteManager worked in the expetected logic.
func votesManagerMetric(blockNumber uint64, blockHash common.Hash) metrics.Gauge {
return metrics.GetOrRegisterGauge(fmt.Sprintf("voteManager/blockNumber/%d/blockHash/%s", blockNumber, blockHash), nil)
}
14 changes: 7 additions & 7 deletions core/vote/vote_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const (
)

var (
localCurVotesGauge = metrics.NewRegisteredGauge("curVotes/local", nil)
localFutureVotesGauge = metrics.NewRegisteredGauge("futureVotes/local", nil)
localCurVotesCounter = metrics.NewRegisteredCounter("curVotes/local", nil)
localFutureVotesCounter = metrics.NewRegisteredCounter("futureVotes/local", nil)

localReceivedVotesGauge = metrics.NewRegisteredGauge("receivedVotes/local", nil)

Expand Down Expand Up @@ -203,9 +203,9 @@ func (pool *VotePool) putVote(m map[common.Hash]*VoteBox, votesPq *votesPriority
log.Debug("VoteHash put into votepool is:", "voteHash", voteHash)

if isFutureVote {
localFutureVotesGauge.Inc(1)
localFutureVotesCounter.Inc(1)
} else {
localCurVotesGauge.Inc(1)
localCurVotesCounter.Inc(1)
}
localReceivedVotesGauge.Update(int64(pool.receivedVotes.Cardinality()))
}
Expand Down Expand Up @@ -278,8 +278,8 @@ func (pool *VotePool) transfer(blockHash common.Hash) {

delete(futureVotes, blockHash)

localCurVotesGauge.Inc(int64(len(validVotes)))
localFutureVotesGauge.Dec(int64(len(voteBox.voteMessages)))
localCurVotesCounter.Inc(int64(len(validVotes)))
localFutureVotesCounter.Dec(int64(len(voteBox.voteMessages)))
}

// Prune old data of duplicationSet, curVotePq and curVotesMap.
Expand All @@ -304,7 +304,7 @@ func (pool *VotePool) prune(latestBlockNumber uint64) {
// Prune curVotes Map.
delete(curVotes, blockHash)

localCurVotesGauge.Dec(int64(len(voteMessages)))
localCurVotesCounter.Dec(int64(len(voteMessages)))
localReceivedVotesGauge.Update(int64(pool.receivedVotes.Cardinality()))
}
}
Expand Down
8 changes: 2 additions & 6 deletions core/vote/vote_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/prysmaticlabs/prysm/v3/validator/accounts/wallet"
"github.com/prysmaticlabs/prysm/v3/validator/keymanager"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
Expand All @@ -24,6 +23,8 @@ const (
voteSignerTimeout = time.Second * 5
)

var votesSigningErrorCounter = metrics.NewRegisteredCounter("votesSigner/error", nil)

type VoteSigner struct {
km *keymanager.IKeymanager
pubKey [48]byte
Expand Down Expand Up @@ -103,8 +104,3 @@ func (signer *VoteSigner) SignVote(vote *types.VoteEnvelope) error {
copy(vote.Signature[:], signature.Marshal()[:])
return nil
}

// Metrics to indicate if there's any failed signing.
func votesSigningErrorMetric(blockNumber uint64, blockHash common.Hash) metrics.Gauge {
return metrics.GetOrRegisterGauge(fmt.Sprintf("voteSigning/blockNumber/%d/blockHash/%s", blockNumber, blockHash), nil)
}