Skip to content

Commit

Permalink
Merge branch 'debugging' into alphanet
Browse files Browse the repository at this point in the history
  • Loading branch information
nibty committed Apr 19, 2024
2 parents 6e83447 + ba6803d commit 4bf7848
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions eventcheck/gaspowercheck/gas_power_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gaspowercheck

import (
"errors"
"github.com/ethereum/go-ethereum/metrics"
"math/big"
"time"

Expand All @@ -17,6 +18,8 @@ import (
var (
// ErrWrongGasPowerLeft indicates that event's GasPowerLeft is miscalculated.
ErrWrongGasPowerLeft = errors.New("event has wrong GasPowerLeft")

notEnoughGasPowerCounter = metrics.GetOrRegisterCounter("events/validate/wrong_gas_power", nil)
)

type ValidatorState struct {
Expand Down Expand Up @@ -173,6 +176,7 @@ func (v *Checker) Validate(e inter.EventI, selfParent inter.EventI) error {
}
for i := range gasPowers.Gas {
if e.GasPowerLeft().Gas[i]+e.GasPowerUsed() != gasPowers.Gas[i] { // GasPowerUsed is checked in basic_check
notEnoughGasPowerCounter.Inc(1)
return ErrWrongGasPowerLeft
}
}
Expand Down
4 changes: 4 additions & 0 deletions gossip/c_event_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gossip

import (
"errors"
"github.com/ethereum/go-ethereum/metrics"
"math/big"
"sync/atomic"

Expand All @@ -27,6 +28,8 @@ var (
errNonExistingEpoch = errors.New("epoch doesn't exist")
errSameEpoch = errors.New("epoch hasn't changed")
errDirtyEvmSnap = errors.New("EVM snapshot is dirty")

notEnoughGasPowerCounter = metrics.GetOrRegisterCounter("events/build/not_enough_gas_power", nil)
)

func (s *Service) buildEvent(e *inter.MutableEventPayload, onIndexed func()) error {
Expand Down Expand Up @@ -63,6 +66,7 @@ func (s *Service) buildEvent(e *inter.MutableEventPayload, onIndexed func()) err
return err
}
if e.GasPowerUsed() > availableGasPower.Min() {
notEnoughGasPowerCounter.Inc(1)
return emitter.ErrNotEnoughGasPower
}
e.SetGasPowerLeft(availableGasPower.Sub(e.GasPowerUsed()))
Expand Down

0 comments on commit 4bf7848

Please sign in to comment.