Skip to content

Commit

Permalink
Add spans to pre and post att signing updates (#8079)
Browse files Browse the repository at this point in the history
* Add spans to pre and post att signing updates

* span on db method

* Add span to isNewAttSlashable
  • Loading branch information
prestonvanloon committed Dec 9, 2020
1 parent c5770a2 commit c96db1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions validator/client/attest_protect.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import (
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/validator/db/kv"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)

var failedAttLocalProtectionErr = "attempted to make slashable attestation, rejected by local slashing protection"
var failedPreAttSignExternalErr = "attempted to make slashable attestation, rejected by external slasher service"
var failedPostAttSignExternalErr = "external slasher service detected a submitted slashable attestation"

func (v *validator) preAttSignValidations(ctx context.Context, indexedAtt *ethpb.IndexedAttestation, pubKey [48]byte) error {
ctx, span := trace.StartSpan(ctx, "validator.preAttSignUpdate")
defer span.End()

fmtKey := fmt.Sprintf("%#x", pubKey[:])
v.attesterHistoryByPubKeyLock.RLock()
attesterHistory, ok := v.attesterHistoryByPubKey[pubKey]
Expand Down Expand Up @@ -68,6 +72,9 @@ func (v *validator) preAttSignValidations(ctx context.Context, indexedAtt *ethpb
}

func (v *validator) postAttSignUpdate(ctx context.Context, indexedAtt *ethpb.IndexedAttestation, pubKey [48]byte, signingRoot [32]byte) error {
ctx, span := trace.StartSpan(ctx, "validator.postAttSignUpdate")
defer span.End()

fmtKey := fmt.Sprintf("%#x", pubKey[:])
v.attesterHistoryByPubKeyLock.Lock()
defer v.attesterHistoryByPubKeyLock.Unlock()
Expand Down Expand Up @@ -141,6 +148,9 @@ func isNewAttSlashable(
targetEpoch uint64,
signingRoot [32]byte,
) (bool, error) {
ctx, span := trace.StartSpan(ctx, "isNewAttSlashable")
defer span.End()

if history == nil {
return false, nil
}
Expand Down
4 changes: 4 additions & 0 deletions validator/db/kv/historical_attestations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
log "github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)

const (
Expand Down Expand Up @@ -134,6 +135,9 @@ func MarkAllAsAttestedSinceLatestWrittenEpoch(
incomingTarget uint64,
incomingAtt *HistoryData,
) (EncHistoryData, error) {
ctx, span := trace.StartSpan(ctx, "kv.MarkAllAttestedSinceLastWrittenEpoch")
defer span.End()

wsPeriod := params.BeaconConfig().WeakSubjectivityPeriod
latestEpochWritten, err := hist.GetLatestEpochWritten(ctx)
if err != nil {
Expand Down

0 comments on commit c96db1a

Please sign in to comment.