diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 2c57e4727..654917043 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -46,6 +46,7 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//cmd/beacon-chain/flags:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", @@ -57,7 +58,6 @@ go_library( "//shared/params:go_default_library", "//shared/slotutil:go_default_library", "//shared/timeutils:go_default_library", - "//shared/traceutil:go_default_library", "//shared/version:go_default_library", "@com_github_emicklei_dot//:go_default_library", "@com_github_pkg_errors//:go_default_library", diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index 0e34f2b20..f8f8238fa 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -10,13 +10,13 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -114,7 +114,7 @@ func (s *Service) VerifyBlkDescendant(ctx context.Context, root [32]byte) error err := fmt.Errorf("block %#x is not a descendent of the current finalized block slot %d, %#x != %#x", bytesutil.Trunc(root[:]), finalizedBlk.Slot(), bytesutil.Trunc(bFinalizedRoot), bytesutil.Trunc(fRoot[:])) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } return nil diff --git a/beacon-chain/blockchain/receive_block.go b/beacon-chain/blockchain/receive_block.go index 3a0b861cb..a0de0852f 100644 --- a/beacon-chain/blockchain/receive_block.go +++ b/beacon-chain/blockchain/receive_block.go @@ -8,10 +8,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/feed" statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/timeutils" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -39,7 +39,7 @@ func (s *Service) ReceiveBlock(ctx context.Context, block block.SignedBeaconBloc // Apply state transition on the new block. if err := s.onBlock(ctx, blockCopy, blockRoot); err != nil { err := errors.Wrap(err, "could not process block") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -99,14 +99,14 @@ func (s *Service) ReceiveBlockBatch(ctx context.Context, blocks []block.SignedBe fCheckpoints, jCheckpoints, err := s.onBlockBatch(ctx, blocks, blkRoots) if err != nil { err := errors.Wrap(err, "could not process block in batch") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } for i, b := range blocks { blockCopy := b.Copy() if err = s.handleBlockAfterBatchVerify(ctx, blockCopy, blkRoots[i], fCheckpoints[i], jCheckpoints[i]); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } // Send notification of the processed block to the state feed. diff --git a/beacon-chain/core/epoch/precompute/BUILD.bazel b/beacon-chain/core/epoch/precompute/BUILD.bazel index 869687345..7e892e6db 100644 --- a/beacon-chain/core/epoch/precompute/BUILD.bazel +++ b/beacon-chain/core/epoch/precompute/BUILD.bazel @@ -19,11 +19,11 @@ go_library( "//beacon-chain/core:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/state:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//shared/attestationutil:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", - "//shared/traceutil:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", "@io_opencensus_go//trace:go_default_library", diff --git a/beacon-chain/core/epoch/precompute/attestation.go b/beacon-chain/core/epoch/precompute/attestation.go index 709d1ecb0..9dbb247c0 100644 --- a/beacon-chain/core/epoch/precompute/attestation.go +++ b/beacon-chain/core/epoch/precompute/attestation.go @@ -9,10 +9,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/attestationutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -44,12 +44,12 @@ func ProcessAttestations( } v.IsCurrentEpochAttester, v.IsCurrentEpochTargetAttester, err = AttestedCurrentEpoch(state, a) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, nil, errors.Wrap(err, "could not check validator attested current epoch") } v.IsPrevEpochAttester, v.IsPrevEpochTargetAttester, v.IsPrevEpochHeadAttester, err = AttestedPrevEpoch(state, a) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, nil, errors.Wrap(err, "could not check validator attested previous epoch") } diff --git a/beacon-chain/core/transition/BUILD.bazel b/beacon-chain/core/transition/BUILD.bazel index 98bfc4b5a..0b36368ed 100644 --- a/beacon-chain/core/transition/BUILD.bazel +++ b/beacon-chain/core/transition/BUILD.bazel @@ -36,6 +36,7 @@ go_library( "//beacon-chain/core/validators:go_default_library", "//beacon-chain/state:go_default_library", "//beacon-chain/state/v1:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//shared/bls:go_default_library", @@ -44,7 +45,6 @@ go_library( "//shared/hashutil:go_default_library", "//shared/mathutil:go_default_library", "//shared/params:go_default_library", - "//shared/traceutil:go_default_library", "//shared/version:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", diff --git a/beacon-chain/core/transition/transition.go b/beacon-chain/core/transition/transition.go index b50ddc905..c8f864600 100644 --- a/beacon-chain/core/transition/transition.go +++ b/beacon-chain/core/transition/transition.go @@ -17,10 +17,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/prysmaticlabs/prysm/shared/version" "go.opencensus.io/trace" ) @@ -115,7 +115,7 @@ func ProcessSlot(ctx context.Context, state state.BeaconState) (state.BeaconStat } prevBlockRoot, err := state.LatestBlockHeader().HashTreeRoot() if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not determine prev block root") } // Cache the block root. @@ -181,7 +181,7 @@ func ProcessSlots(ctx context.Context, state state.BeaconState, slot types.Slot) // The block must have a higher slot than parent state. if state.Slot() >= slot { err := fmt.Errorf("expected state.slot %d < slot %d", state.Slot(), slot) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, err } @@ -215,14 +215,14 @@ func ProcessSlots(ctx context.Context, state state.BeaconState, slot types.Slot) } defer func() { if err := SkipSlotCache.MarkNotInProgress(key); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) log.WithError(err).Error("Failed to mark skip slot no longer in progress") } }() for state.Slot() < slot { if ctx.Err() != nil { - traceutil.AnnotateError(span, ctx.Err()) + tracing.AnnotateError(span, ctx.Err()) // Cache last best value. if highestSlot < state.Slot() { if err := SkipSlotCache.Put(ctx, key, state); err != nil { @@ -233,7 +233,7 @@ func ProcessSlots(ctx context.Context, state state.BeaconState, slot types.Slot) } state, err = ProcessSlot(ctx, state) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process slot") } if CanProcessEpoch(state) { @@ -241,13 +241,13 @@ func ProcessSlots(ctx context.Context, state state.BeaconState, slot types.Slot) case version.Phase0: state, err = ProcessEpochPrecompute(ctx, state) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process epoch with optimizations") } case version.Altair: state, err = altair.ProcessEpoch(ctx, state) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process epoch") } default: @@ -255,14 +255,14 @@ func ProcessSlots(ctx context.Context, state state.BeaconState, slot types.Slot) } } if err := state.SetSlot(state.Slot() + 1); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "failed to increment state slot") } if CanUpgradeToAltair(state.Slot()) { state, err = altair.UpgradeToAltair(ctx, state) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, err } } @@ -271,7 +271,7 @@ func ProcessSlots(ctx context.Context, state state.BeaconState, slot types.Slot) if highestSlot < state.Slot() { if err := SkipSlotCache.Put(ctx, key, state); err != nil { log.WithError(err).Error("Failed to put skip slot cache value") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } } diff --git a/beacon-chain/core/transition/transition_no_verify_sig.go b/beacon-chain/core/transition/transition_no_verify_sig.go index 67d271dec..dc1f87b6b 100644 --- a/beacon-chain/core/transition/transition_no_verify_sig.go +++ b/beacon-chain/core/transition/transition_no_verify_sig.go @@ -12,10 +12,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/transition/interop" v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/prysmaticlabs/prysm/shared/version" "go.opencensus.io/trace" ) @@ -120,7 +120,7 @@ func CalculateStateRoot( ctx, span := trace.StartSpan(ctx, "core.state.CalculateStateRoot") defer span.End() if ctx.Err() != nil { - traceutil.AnnotateError(span, ctx.Err()) + tracing.AnnotateError(span, ctx.Err()) return [32]byte{}, ctx.Err() } if state == nil || state.IsNil() { @@ -207,12 +207,12 @@ func ProcessBlockNoVerifyAnySig( bSet, err := b.BlockSignatureSet(state, blk.ProposerIndex(), signed.Signature(), blk.HashTreeRoot) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, nil, errors.Wrap(err, "could not retrieve block signature set") } rSet, err := b.RandaoSignatureSet(state, signed.Block().Body().RandaoReveal()) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, nil, errors.Wrap(err, "could not retrieve randao signature set") } aSet, err := b.AttestationSignatureSet(ctx, state, signed.Block().Body().Attestations()) @@ -302,25 +302,25 @@ func ProcessBlockForStateRoot( } state, err = b.ProcessBlockHeaderNoVerify(state, blk.Slot(), blk.ProposerIndex(), blk.ParentRoot(), bodyRoot[:]) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process block header") } state, err = b.ProcessRandaoNoVerify(state, signed.Block().Body().RandaoReveal()) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not verify and process randao") } state, err = b.ProcessEth1DataInBlock(ctx, state, signed.Block().Body().Eth1Data()) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process eth1 data") } state, err = ProcessOperationsNoVerifyAttsSigs(ctx, state, signed) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process block operation") } diff --git a/beacon-chain/db/iface/BUILD.bazel b/beacon-chain/db/iface/BUILD.bazel index bbb509561..d089b14a3 100644 --- a/beacon-chain/db/iface/BUILD.bazel +++ b/beacon-chain/db/iface/BUILD.bazel @@ -13,9 +13,9 @@ go_library( "//beacon-chain/db/filters:go_default_library", "//beacon-chain/slasher/types:go_default_library", "//beacon-chain/state:go_default_library", + "//monitoring/backup:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", - "//shared/backuputil:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", ], diff --git a/beacon-chain/db/iface/interface.go b/beacon-chain/db/iface/interface.go index a93841204..cc602e213 100644 --- a/beacon-chain/db/iface/interface.go +++ b/beacon-chain/db/iface/interface.go @@ -12,11 +12,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/backup" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" - "github.com/prysmaticlabs/prysm/shared/backuputil" ) // ReadOnlyDatabase defines a struct which only has read access to database methods. @@ -151,7 +151,7 @@ type SlasherDatabase interface { // Database interface with full access. type Database interface { io.Closer - backuputil.BackupExporter + backup.BackupExporter HeadAccessDatabase DatabasePath() string diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index 64cecbfb7..b41012977 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -43,6 +43,8 @@ go_library( "//beacon-chain/state/genesis:go_default_library", "//beacon-chain/state/v1:go_default_library", "//beacon-chain/state/v2:go_default_library", + "//monitoring/progress:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", @@ -50,9 +52,7 @@ go_library( "//shared/featureconfig:go_default_library", "//shared/fileutil:go_default_library", "//shared/params:go_default_library", - "//shared/progressutil:go_default_library", "//shared/sliceutil:go_default_library", - "//shared/traceutil:go_default_library", "//shared/version:go_default_library", "@com_github_dgraph_io_ristretto//:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", diff --git a/beacon-chain/db/kv/finalized_block_roots.go b/beacon-chain/db/kv/finalized_block_roots.go index 14c55b7e2..b923ec653 100644 --- a/beacon-chain/db/kv/finalized_block_roots.go +++ b/beacon-chain/db/kv/finalized_block_roots.go @@ -6,11 +6,11 @@ import ( "fmt" "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" + "github.com/prysmaticlabs/prysm/monitoring/tracing" dbpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/traceutil" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" ) @@ -52,7 +52,7 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec previousFinalizedCheckpoint := ðpb.Checkpoint{} if b := bkt.Get(previousFinalizedCheckpointKey); b != nil { if err := decode(ctx, b, previousFinalizedCheckpoint); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } } @@ -62,12 +62,12 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec SetEndEpoch(checkpoint.Epoch+1), ) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } for _, root := range blockRoots { if err := bkt.Delete(root[:]); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } } @@ -81,12 +81,12 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec signedBlock, err := s.Block(ctx, bytesutil.ToBytes32(root)) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } if signedBlock == nil || signedBlock.IsNil() || signedBlock.Block().IsNil() { err := fmt.Errorf("missing block in database: block root=%#x", root) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } block := signedBlock.Block() @@ -98,11 +98,11 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec enc, err := encode(ctx, container) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } if err := bkt.Put(root, enc); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -110,17 +110,17 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec if parentBytes := bkt.Get(block.ParentRoot()); parentBytes != nil { parent := &dbpb.FinalizedBlockRootContainer{} if err := decode(ctx, parentBytes, parent); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } parent.ChildRoot = root enc, err := encode(ctx, parent) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } if err := bkt.Put(block.ParentRoot(), enc); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } break @@ -132,7 +132,7 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec // Upsert blocks from the current finalized epoch. roots, err := s.BlockRoots(ctx, filters.NewFilter().SetStartEpoch(checkpoint.Epoch).SetEndEpoch(checkpoint.Epoch+1)) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } for _, root := range roots { @@ -141,7 +141,7 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec continue } if err := bkt.Put(root, containerFinalizedButNotCanonical); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } } @@ -149,7 +149,7 @@ func (s *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, chec // Update previous checkpoint enc, err := encode(ctx, checkpoint) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -175,7 +175,7 @@ func (s *Store) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool { return nil }) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } return exists } @@ -198,7 +198,7 @@ func (s *Store) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (bl } ctr := &dbpb.FinalizedBlockRootContainer{} if err := decode(ctx, blkBytes, ctr); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } enc := tx.Bucket(blocksBucket).Get(ctr.ChildRoot) @@ -209,6 +209,6 @@ func (s *Store) FinalizedChildBlock(ctx context.Context, blockRoot [32]byte) (bl blk, err = unmarshalBlock(ctx, enc) return err }) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return blk, err } diff --git a/beacon-chain/db/kv/migration_state_validators.go b/beacon-chain/db/kv/migration_state_validators.go index 60d74eadd..08b692522 100644 --- a/beacon-chain/db/kv/migration_state_validators.go +++ b/beacon-chain/db/kv/migration_state_validators.go @@ -8,9 +8,9 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/golang/snappy" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/monitoring/progress" v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/progressutil" bolt "go.etcd.io/bbolt" ) @@ -75,7 +75,7 @@ func migrateStateValidators(ctx context.Context, db *bolt.DB) error { log.Infof("total keys = %d", len(keys)) // prepare the progress bar with the total count of the keys to migrate - bar := progressutil.InitializeProgressBar(len(keys), "Migrating state validators to new schema.") + bar := progress.InitializeProgressBar(len(keys), "Migrating state validators to new schema.") batchNo := 0 for batchIndex := 0; batchIndex < len(keys); batchIndex += batchSize { diff --git a/beacon-chain/db/kv/powchain.go b/beacon-chain/db/kv/powchain.go index d5edff14c..b09078078 100644 --- a/beacon-chain/db/kv/powchain.go +++ b/beacon-chain/db/kv/powchain.go @@ -4,8 +4,8 @@ import ( "context" "errors" + "github.com/prysmaticlabs/prysm/monitoring/tracing" v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/traceutil" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" "google.golang.org/protobuf/proto" @@ -18,7 +18,7 @@ func (s *Store) SavePowchainData(ctx context.Context, data *v2.ETH1ChainData) er if data == nil { err := errors.New("cannot save nil eth1data") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -30,7 +30,7 @@ func (s *Store) SavePowchainData(ctx context.Context, data *v2.ETH1ChainData) er } return bkt.Put(powchainDataKey, enc) }) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } diff --git a/beacon-chain/db/kv/state.go b/beacon-chain/db/kv/state.go index 71e105987..2b2bd8cb8 100644 --- a/beacon-chain/db/kv/state.go +++ b/beacon-chain/db/kv/state.go @@ -13,12 +13,12 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/genesis" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" v2 "github.com/prysmaticlabs/prysm/beacon-chain/state/v2" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" ) @@ -52,7 +52,7 @@ func (s *Store) GenesisState(ctx context.Context) (state.BeaconState, error) { cached, err := genesis.State(params.BeaconConfig().ConfigName) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, err } span.AddAttributes(trace.BoolAttribute("cache_hit", cached != nil)) diff --git a/beacon-chain/node/BUILD.bazel b/beacon-chain/node/BUILD.bazel index 3dcd04166..8df215f53 100644 --- a/beacon-chain/node/BUILD.bazel +++ b/beacon-chain/node/BUILD.bazel @@ -36,8 +36,10 @@ go_library( "//beacon-chain/sync:go_default_library", "//beacon-chain/sync/initial-sync:go_default_library", "//cmd/beacon-chain/flags:go_default_library", + "//monitoring/backup:go_default_library", + "//monitoring/prometheus:go_default_library", + "//monitoring/tracing:go_default_library", "//shared:go_default_library", - "//shared/backuputil:go_default_library", "//shared/cmd:go_default_library", "//shared/debug:go_default_library", "//shared/event:go_default_library", @@ -45,9 +47,7 @@ go_library( "//shared/gateway:go_default_library", "//shared/params:go_default_library", "//shared/prereq:go_default_library", - "//shared/prometheus:go_default_library", "//shared/sliceutil:go_default_library", - "//shared/tracing:go_default_library", "//shared/version:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_pkg_errors//:go_default_library", diff --git a/beacon-chain/node/config.go b/beacon-chain/node/config.go index 9435c4321..355086d96 100644 --- a/beacon-chain/node/config.go +++ b/beacon-chain/node/config.go @@ -3,14 +3,14 @@ package node import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" + tracing2 "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/tracing" "github.com/urfave/cli/v2" ) func configureTracing(cliCtx *cli.Context) error { - return tracing.Setup( + return tracing2.Setup( "beacon-chain", // service name cliCtx.String(cmd.TracingProcessNameFlag.Name), cliCtx.String(cmd.TracingEndpointFlag.Name), diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index a0601908f..f93511471 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -38,8 +38,9 @@ import ( regularsync "github.com/prysmaticlabs/prysm/beacon-chain/sync" initialsync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" + "github.com/prysmaticlabs/prysm/monitoring/backup" + "github.com/prysmaticlabs/prysm/monitoring/prometheus" "github.com/prysmaticlabs/prysm/shared" - "github.com/prysmaticlabs/prysm/shared/backuputil" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/debug" "github.com/prysmaticlabs/prysm/shared/event" @@ -47,7 +48,6 @@ import ( "github.com/prysmaticlabs/prysm/shared/gateway" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/prereq" - "github.com/prysmaticlabs/prysm/shared/prometheus" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/version" "github.com/sirupsen/logrus" @@ -631,7 +631,7 @@ func (b *BeaconNode) registerPrometheusService(cliCtx *cli.Context) error { additionalHandlers, prometheus.Handler{ Path: "/db/backup", - Handler: backuputil.BackupHandler(b.db, cliCtx.String(cmd.BackupWebhookOutputDir.Name)), + Handler: backup.BackupHandler(b.db, cliCtx.String(cmd.BackupWebhookOutputDir.Name)), }, ) } diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index 5cf18fb64..c3a949eee 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -53,6 +53,7 @@ go_library( "//beacon-chain/p2p/peers/scorers:go_default_library", "//beacon-chain/p2p/types:go_default_library", "//cmd/beacon-chain/flags:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/metadata:go_default_library", "//proto/prysm/v1alpha1/wrapper:go_default_library", @@ -67,7 +68,6 @@ go_library( "//shared/runutil:go_default_library", "//shared/slotutil:go_default_library", "//shared/timeutils:go_default_library", - "//shared/traceutil:go_default_library", "//shared/version:go_default_library", "@com_github_ethereum_go_ethereum//crypto:go_default_library", "@com_github_ethereum_go_ethereum//p2p/discover:go_default_library", diff --git a/beacon-chain/p2p/broadcaster.go b/beacon-chain/p2p/broadcaster.go index 293d61a0b..7d384a32b 100644 --- a/beacon-chain/p2p/broadcaster.go +++ b/beacon-chain/p2p/broadcaster.go @@ -11,11 +11,11 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/altair" + "github.com/prysmaticlabs/prysm/monitoring/tracing" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/hashutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" "google.golang.org/protobuf/proto" ) @@ -37,13 +37,13 @@ func (s *Service) Broadcast(ctx context.Context, msg proto.Message) error { forkDigest, err := s.currentForkDigest() if err != nil { err := errors.Wrap(err, "could not retrieve fork digest") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } topic, ok := GossipTypeMapping[reflect.TypeOf(msg)] if !ok { - traceutil.AnnotateError(span, ErrMessageNotMapped) + tracing.AnnotateError(span, ErrMessageNotMapped) return ErrMessageNotMapped } castMsg, ok := msg.(ssz.Marshaler) @@ -61,7 +61,7 @@ func (s *Service) BroadcastAttestation(ctx context.Context, subnet uint64, att * forkDigest, err := s.currentForkDigest() if err != nil { err := errors.Wrap(err, "could not retrieve fork digest") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -79,7 +79,7 @@ func (s *Service) BroadcastSyncCommitteeMessage(ctx context.Context, subnet uint forkDigest, err := s.currentForkDigest() if err != nil { err := errors.Wrap(err, "could not retrieve fork digest") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -125,7 +125,7 @@ func (s *Service) broadcastAttestation(ctx context.Context, subnet uint64, att * return errors.New("failed to find peers for subnet") }(); err != nil { log.WithError(err).Error("Failed to find peers") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } } // In the event our attestation is outdated and beyond the @@ -138,7 +138,7 @@ func (s *Service) broadcastAttestation(ctx context.Context, subnet uint64, att * if err := s.broadcastObject(ctx, att, attestationToTopic(subnet, forkDigest)); err != nil { log.WithError(err).Error("Failed to broadcast attestation") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } } @@ -181,7 +181,7 @@ func (s *Service) broadcastSyncCommittee(ctx context.Context, subnet uint64, sMs return errors.New("failed to find peers for subnet") }(); err != nil { log.WithError(err).Error("Failed to find peers") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } } // In the event our sync message is outdated and beyond the @@ -193,7 +193,7 @@ func (s *Service) broadcastSyncCommittee(ctx context.Context, subnet uint64, sMs if err := s.broadcastObject(ctx, sMsg, syncCommitteeToTopic(subnet, forkDigest)); err != nil { log.WithError(err).Error("Failed to broadcast sync committee message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } } @@ -207,7 +207,7 @@ func (s *Service) broadcastObject(ctx context.Context, obj ssz.Marshaler, topic buf := new(bytes.Buffer) if _, err := s.Encoding().EncodeGossip(buf, obj); err != nil { err := errors.Wrap(err, "could not encode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -218,7 +218,7 @@ func (s *Service) broadcastObject(ctx context.Context, obj ssz.Marshaler, topic } if err := s.PublishToTopic(ctx, topic+s.Encoding().ProtocolSuffix(), buf.Bytes()); err != nil { err := errors.Wrap(err, "could not publish message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } return nil diff --git a/beacon-chain/p2p/sender.go b/beacon-chain/p2p/sender.go index f1b51712e..311c5a888 100644 --- a/beacon-chain/p2p/sender.go +++ b/beacon-chain/p2p/sender.go @@ -9,7 +9,7 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/protocol" "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/shared/traceutil" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/sirupsen/logrus" "go.opencensus.io/trace" ) @@ -38,7 +38,7 @@ func (s *Service) Send(ctx context.Context, message interface{}, baseTopic strin stream, err := s.host.NewStream(ctx, pid, protocol.ID(topic)) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return nil, err } // do not encode anything if we are sending a metadata request @@ -48,7 +48,7 @@ func (s *Service) Send(ctx context.Context, message interface{}, baseTopic strin return nil, errors.Errorf("%T does not support the ssz marshaller interface", message) } if _, err := s.Encoding().EncodeWithMaxLength(stream, castedMsg); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) _err := stream.Reset() _ = _err return nil, err @@ -57,7 +57,7 @@ func (s *Service) Send(ctx context.Context, message interface{}, baseTopic strin // Close stream for writing. if err := stream.CloseWrite(); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) _err := stream.Reset() _ = _err return nil, err diff --git a/beacon-chain/powchain/BUILD.bazel b/beacon-chain/powchain/BUILD.bazel index f9cca31a3..ba41e4c63 100644 --- a/beacon-chain/powchain/BUILD.bazel +++ b/beacon-chain/powchain/BUILD.bazel @@ -31,16 +31,16 @@ go_library( "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/state/v1:go_default_library", "//contracts/deposit-contract:go_default_library", + "//monitoring/clientstats:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/clientstats:go_default_library", "//shared/hashutil:go_default_library", "//shared/httputils:go_default_library", "//shared/httputils/authorizationmethod:go_default_library", "//shared/logutil:go_default_library", "//shared/params:go_default_library", "//shared/timeutils:go_default_library", - "//shared/traceutil:go_default_library", "//shared/trieutil:go_default_library", "@com_github_ethereum_go_ethereum//:go_default_library", "@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library", @@ -83,10 +83,10 @@ go_test( "//beacon-chain/powchain/testing:go_default_library", "//beacon-chain/powchain/types:go_default_library", "//contracts/deposit-contract:go_default_library", + "//monitoring/clientstats:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", - "//shared/clientstats:go_default_library", "//shared/event:go_default_library", "//shared/httputils:go_default_library", "//shared/httputils/authorizationmethod:go_default_library", diff --git a/beacon-chain/powchain/block_reader.go b/beacon-chain/powchain/block_reader.go index f99881c81..33ecaeb86 100644 --- a/beacon-chain/powchain/block_reader.go +++ b/beacon-chain/powchain/block_reader.go @@ -8,8 +8,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/beacon-chain/powchain/types" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -76,7 +76,7 @@ func (s *Service) BlockHashByHeight(ctx context.Context, height *big.Int) (commo if s.eth1DataFetcher == nil { err := errors.New("nil eth1DataFetcher") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return [32]byte{}, err } @@ -96,7 +96,7 @@ func (s *Service) BlockTimeByHeight(ctx context.Context, height *big.Int) (uint6 defer span.End() if s.eth1DataFetcher == nil { err := errors.New("nil eth1DataFetcher") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return 0, err } diff --git a/beacon-chain/powchain/prometheus.go b/beacon-chain/powchain/prometheus.go index 29de86c02..e62d14fc2 100644 --- a/beacon-chain/powchain/prometheus.go +++ b/beacon-chain/powchain/prometheus.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/prometheus/client_golang/prometheus" - "github.com/prysmaticlabs/prysm/shared/clientstats" + "github.com/prysmaticlabs/prysm/monitoring/clientstats" ) type BeaconNodeStatsUpdater interface { diff --git a/beacon-chain/powchain/service.go b/beacon-chain/powchain/service.go index 967d520b5..51d29337a 100644 --- a/beacon-chain/powchain/service.go +++ b/beacon-chain/powchain/service.go @@ -33,10 +33,10 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract" + "github.com/prysmaticlabs/prysm/monitoring/clientstats" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/clientstats" "github.com/prysmaticlabs/prysm/shared/httputils" "github.com/prysmaticlabs/prysm/shared/httputils/authorizationmethod" "github.com/prysmaticlabs/prysm/shared/logutil" diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index 0d5d9b89e..21b0bfa57 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -19,9 +19,9 @@ import ( dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing" contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract" + "github.com/prysmaticlabs/prysm/monitoring/clientstats" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/clientstats" "github.com/prysmaticlabs/prysm/shared/event" "github.com/prysmaticlabs/prysm/shared/httputils" "github.com/prysmaticlabs/prysm/shared/params" diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index 2d1034eef..097fda009 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -34,12 +34,12 @@ go_library( "//beacon-chain/rpc/statefetcher:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/sync:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/eth/service:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//shared/featureconfig:go_default_library", "//shared/logutil:go_default_library", "//shared/params:go_default_library", - "//shared/traceutil:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//tracing/opentracing:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index 4038c8e0f..f2d7cb961 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -41,6 +41,7 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//beacon-chain/sync:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", @@ -59,7 +60,6 @@ go_library( "//shared/rand:go_default_library", "//shared/slotutil:go_default_library", "//shared/timeutils:go_default_library", - "//shared/traceutil:go_default_library", "//shared/trieutil:go_default_library", "//shared/version:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/status.go b/beacon-chain/rpc/prysm/v1alpha1/validator/status.go index c69899b2d..5a66f9f5a 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/status.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/status.go @@ -8,11 +8,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/depositutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -238,14 +238,14 @@ func (vs *Server) validatorStatus( } vStatus, idx, err := statusForPubKey(headState, pubKey) if err != nil && err != errPubkeyDoesNotExist { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return resp, nonExistentIndex } resp.Status = vStatus if err != errPubkeyDoesNotExist { val, err := headState.ValidatorAtIndexReadOnly(idx) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return resp, idx } resp.ActivationEpoch = val.ActivationEpoch() diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index 244f235ab..4950f4b73 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -38,12 +38,12 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/rpc/statefetcher" "github.com/prysmaticlabs/prysm/beacon-chain/state/stategen" chainSync "github.com/prysmaticlabs/prysm/beacon-chain/sync" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service" ethpbv1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/logutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/sirupsen/logrus" "go.opencensus.io/plugin/ocgrpc" "google.golang.org/grpc" @@ -136,7 +136,7 @@ func (s *Service) Start() { grpc.StatsHandler(&ocgrpc.ServerHandler{}), grpc.StreamInterceptor(middleware.ChainStreamServer( recovery.StreamServerInterceptor( - recovery.WithRecoveryHandlerContext(traceutil.RecoveryHandlerFunc), + recovery.WithRecoveryHandlerContext(tracing.RecoveryHandlerFunc), ), grpc_prometheus.StreamServerInterceptor, grpc_opentracing.StreamServerInterceptor(), @@ -144,7 +144,7 @@ func (s *Service) Start() { )), grpc.UnaryInterceptor(middleware.ChainUnaryServer( recovery.UnaryServerInterceptor( - recovery.WithRecoveryHandlerContext(traceutil.RecoveryHandlerFunc), + recovery.WithRecoveryHandlerContext(tracing.RecoveryHandlerFunc), ), grpc_prometheus.UnaryServerInterceptor, grpc_opentracing.UnaryServerInterceptor(), diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 0d5f65e74..52d8c78da 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -74,6 +74,7 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/stategen:go_default_library", "//cmd/beacon-chain/flags:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//proto/prysm/v1alpha1/metadata:go_default_library", @@ -94,7 +95,6 @@ go_library( "//shared/slotutil:go_default_library", "//shared/sszutil:go_default_library", "//shared/timeutils:go_default_library", - "//shared/traceutil:go_default_library", "//shared/version:go_default_library", "@com_github_ferranbt_fastssz//:go_default_library", "@com_github_hashicorp_golang_lru//:go_default_library", diff --git a/beacon-chain/sync/pending_blocks_queue.go b/beacon-chain/sync/pending_blocks_queue.go index 8f87762df..786eb3c6c 100644 --- a/beacon-chain/sync/pending_blocks_queue.go +++ b/beacon-chain/sync/pending_blocks_queue.go @@ -12,6 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" @@ -19,7 +20,6 @@ import ( "github.com/prysmaticlabs/prysm/shared/runutil" "github.com/prysmaticlabs/prysm/shared/slotutil" "github.com/prysmaticlabs/prysm/shared/sszutil" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/sirupsen/logrus" "github.com/trailofbits/go-mutexasserts" "go.opencensus.io/trace" @@ -95,7 +95,7 @@ func (s *Service) processPendingBlocks(ctx context.Context) error { blkRoot, err := b.Block().HashTreeRoot() if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) span.End() return err } @@ -142,7 +142,7 @@ func (s *Service) processPendingBlocks(ctx context.Context) error { if err := s.validateBeaconBlock(ctx, b, blkRoot); err != nil { log.Debugf("Could not validate block from slot %d: %v", b.Block().Slot(), err) s.setBadBlock(ctx, blkRoot) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) // In the next iteration of the queue, this block will be removed from // the pending queue as it has been marked as a 'bad' block. span.End() @@ -152,7 +152,7 @@ func (s *Service) processPendingBlocks(ctx context.Context) error { if err := s.cfg.Chain.ReceiveBlock(ctx, b, blkRoot); err != nil { log.Debugf("Could not process block from slot %d: %v", b.Block().Slot(), err) s.setBadBlock(ctx, blkRoot) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) // In the next iteration of the queue, this block will be removed from // the pending queue as it has been marked as a 'bad' block. span.End() @@ -206,7 +206,7 @@ func (s *Service) sendBatchRootRequest(ctx context.Context, roots [][32]byte, ra req = roots[:params.BeaconNetworkConfig().MaxRequestBlocks] } if err := s.sendRecentBeaconBlocksRequest(ctx, &req, pid); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) log.Debugf("Could not send recent block request: %v", err) } newRoots := make([][32]byte, 0, len(roots)) diff --git a/beacon-chain/sync/rpc.go b/beacon-chain/sync/rpc.go index 5abf05f0e..3f81949b4 100644 --- a/beacon-chain/sync/rpc.go +++ b/beacon-chain/sync/rpc.go @@ -13,9 +13,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -175,7 +175,7 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) { if err != p2ptypes.ErrWrongForkDigestVersion { log.WithError(err).Debug("Could not handle p2p RPC") } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } return } @@ -193,11 +193,11 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) { // Debug logs for goodbye/status errors if strings.Contains(topic, p2p.RPCGoodByeTopicV1) || strings.Contains(topic, p2p.RPCStatusTopicV1) { log.WithError(err).Debug("Could not decode goodbye stream message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } log.WithError(err).Debug("Could not decode stream message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } if err := handle(ctx, msg, stream); err != nil { @@ -205,7 +205,7 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) { if err != p2ptypes.ErrWrongForkDigestVersion { log.WithError(err).Debug("Could not handle p2p RPC") } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } } else { nTyp := reflect.New(t) @@ -216,7 +216,7 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) { } if err := s.cfg.P2P.Encoding().DecodeWithMaxLength(stream, msg); err != nil { log.WithError(err).Debug("Could not decode stream message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } if err := handle(ctx, nTyp.Elem().Interface(), stream); err != nil { @@ -224,7 +224,7 @@ func (s *Service) registerRPC(baseTopic string, handle rpcHandler) { if err != p2ptypes.ErrWrongForkDigestVersion { log.WithError(err).Debug("Could not handle p2p RPC") } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) } } }) diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range.go b/beacon-chain/sync/rpc_beacon_blocks_by_range.go index 05d509157..f01510408 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range.go @@ -10,11 +10,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/db/filters" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" + "github.com/prysmaticlabs/prysm/monitoring/tracing" pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -37,7 +37,7 @@ func (s *Service) beaconBlocksByRangeRPCHandler(ctx context.Context, msg interfa if err := s.validateRangeRequest(m); err != nil { s.writeErrorResponseToStream(responseCodeInvalidRequest, err.Error(), stream) s.cfg.P2P.Peers().Scorers().BadResponsesScorer().Increment(stream.Conn().RemotePeer()) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -72,14 +72,14 @@ func (s *Service) beaconBlocksByRangeRPCHandler(ctx context.Context, msg interfa var prevRoot [32]byte for startSlot <= endReqSlot { if err := s.rateLimiter.validateRequest(stream, allowedBlocksPerSecond); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } if endSlot-startSlot > rangeLimit { s.writeErrorResponseToStream(responseCodeInvalidRequest, p2ptypes.ErrInvalidRequest.Error(), stream) err := p2ptypes.ErrInvalidRequest - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } @@ -127,7 +127,7 @@ func (s *Service) writeBlockRangeToStream(ctx context.Context, startSlot, endSlo if err != nil { log.WithError(err).Debug("Could not retrieve blocks") s.writeErrorResponseToStream(responseCodeServerError, p2ptypes.ErrGeneric.Error(), stream) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } // handle genesis case @@ -136,7 +136,7 @@ func (s *Service) writeBlockRangeToStream(ctx context.Context, startSlot, endSlo if err != nil { log.WithError(err).Debug("Could not retrieve genesis block") s.writeErrorResponseToStream(responseCodeServerError, p2ptypes.ErrGeneric.Error(), stream) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } blks = append([]block.SignedBeaconBlock{genBlock}, blks...) @@ -147,7 +147,7 @@ func (s *Service) writeBlockRangeToStream(ctx context.Context, startSlot, endSlo blks, roots, err = s.dedupBlocksAndRoots(blks, roots) if err != nil { s.writeErrorResponseToStream(responseCodeServerError, p2ptypes.ErrGeneric.Error(), stream) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } blks, roots = s.sortBlocksAndRoots(blks, roots) @@ -155,7 +155,7 @@ func (s *Service) writeBlockRangeToStream(ctx context.Context, startSlot, endSlo blks, err = s.filterBlocks(ctx, blks, roots, prevRoot, step, startSlot) if err != nil && err != p2ptypes.ErrInvalidParent { s.writeErrorResponseToStream(responseCodeServerError, p2ptypes.ErrGeneric.Error(), stream) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return err } for _, b := range blks { @@ -165,7 +165,7 @@ func (s *Service) writeBlockRangeToStream(ctx context.Context, startSlot, endSlo if chunkErr := s.chunkBlockWriter(stream, b); chunkErr != nil { log.WithError(chunkErr).Debug("Could not send a chunked response") s.writeErrorResponseToStream(responseCodeServerError, p2ptypes.ErrGeneric.Error(), stream) - traceutil.AnnotateError(span, chunkErr) + tracing.AnnotateError(span, chunkErr) return chunkErr } diff --git a/beacon-chain/sync/subscriber.go b/beacon-chain/sync/subscriber.go index 52e360117..da373d31d 100644 --- a/beacon-chain/sync/subscriber.go +++ b/beacon-chain/sync/subscriber.go @@ -15,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/messagehandler" @@ -22,7 +23,6 @@ import ( "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/sliceutil" "github.com/prysmaticlabs/prysm/shared/slotutil" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" "google.golang.org/protobuf/proto" ) @@ -169,7 +169,7 @@ func (s *Service) subscribeWithBase(topic string, validator pubsub.ValidatorEx, defer func() { if r := recover(); r != nil { - traceutil.AnnotateError(span, fmt.Errorf("panic occurred: %v", r)) + tracing.AnnotateError(span, fmt.Errorf("panic occurred: %v", r)) log.WithField("error", r).Error("Panic occurred") debug.PrintStack() } @@ -184,7 +184,7 @@ func (s *Service) subscribeWithBase(topic string, validator pubsub.ValidatorEx, } if err := handle(ctx, msg.ValidatorData.(proto.Message)); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) log.WithError(err).Debug("Could not handle p2p pubsub") messageFailedProcessingCounter.WithLabelValues(topic).Inc() return diff --git a/beacon-chain/sync/validate_aggregate_proof.go b/beacon-chain/sync/validate_aggregate_proof.go index 712815150..d07614100 100644 --- a/beacon-chain/sync/validate_aggregate_proof.go +++ b/beacon-chain/sync/validate_aggregate_proof.go @@ -15,11 +15,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/transition" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -42,7 +42,7 @@ func (s *Service) validateAggregateAndProof(ctx context.Context, pid peer.ID, ms raw, err := s.decodePubsubMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } m, ok := raw.(*ethpb.SignedAggregateAttestationAndProof) @@ -73,7 +73,7 @@ func (s *Service) validateAggregateAndProof(ctx context.Context, pid peer.ID, ms // processing tolerance. if err := helpers.ValidateAttestationTime(m.Message.Aggregate.Data.Slot, s.cfg.Chain.GenesisTime(), earlyAttestationProcessingTolerance); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } @@ -91,7 +91,7 @@ func (s *Service) validateAggregateAndProof(ctx context.Context, pid peer.ID, ms // Verify aggregate attestation has not already been seen via aggregate gossip, within a block, or through the creation locally. seen, err := s.cfg.AttPool.HasAggregatedAttestation(m.Message.Aggregate) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } if seen { @@ -122,19 +122,19 @@ func (s *Service) validateAggregatedAtt(ctx context.Context, signed *ethpb.Signe // to weird edge cases during verification. The attestation technically could be used to add value to a block, // but it's invalid in the spirit of the protocol. Here we choose safety over profit. if err := s.cfg.Chain.VerifyLmdFfgConsistency(ctx, signed.Message.Aggregate); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } // Verify current finalized checkpoint is an ancestor of the block defined by the attestation's beacon block root. if err := s.cfg.Chain.VerifyFinalizedConsistency(ctx, signed.Message.Aggregate.Data.BeaconBlockRoot); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } bs, err := s.cfg.Chain.AttestationPreState(ctx, signed.Message.Aggregate) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } @@ -147,21 +147,21 @@ func (s *Service) validateAggregatedAtt(ctx context.Context, signed *ethpb.Signe } bs, err = transition.ProcessSlots(ctx, bs, startSlot) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } } // Verify validator index is within the beacon committee. if err := validateIndexInCommittee(ctx, bs, signed.Message.Aggregate, signed.Message.AggregatorIndex); err != nil { - traceutil.AnnotateError(span, errors.Wrapf(err, "Could not validate index in committee")) + tracing.AnnotateError(span, errors.Wrapf(err, "Could not validate index in committee")) return pubsub.ValidationReject } // Verify selection proof reflects to the right validator. selectionSigSet, err := validateSelectionIndex(ctx, bs, signed.Message.Aggregate.Data, signed.Message.AggregatorIndex, signed.Message.SelectionProof) if err != nil { - traceutil.AnnotateError(span, errors.Wrapf(err, "Could not validate selection for validator %d", signed.Message.AggregatorIndex)) + tracing.AnnotateError(span, errors.Wrapf(err, "Could not validate selection for validator %d", signed.Message.AggregatorIndex)) return pubsub.ValidationReject } @@ -169,23 +169,23 @@ func (s *Service) validateAggregatedAtt(ctx context.Context, signed *ethpb.Signe // We use batch verify here to save compute. aggregatorSigSet, err := aggSigSet(bs, signed) if err != nil { - traceutil.AnnotateError(span, errors.Wrapf(err, "Could not get aggregator sig set %d", signed.Message.AggregatorIndex)) + tracing.AnnotateError(span, errors.Wrapf(err, "Could not get aggregator sig set %d", signed.Message.AggregatorIndex)) return pubsub.ValidationIgnore } attSigSet, err := blocks.AttestationSignatureSet(ctx, bs, []*ethpb.Attestation{signed.Message.Aggregate}) if err != nil { - traceutil.AnnotateError(span, errors.Wrapf(err, "Could not verify aggregator signature %d", signed.Message.AggregatorIndex)) + tracing.AnnotateError(span, errors.Wrapf(err, "Could not verify aggregator signature %d", signed.Message.AggregatorIndex)) return pubsub.ValidationIgnore } set := bls.NewSet() set.Join(selectionSigSet).Join(aggregatorSigSet).Join(attSigSet) valid, err := set.Verify() if err != nil { - traceutil.AnnotateError(span, errors.Errorf("Could not join signature set")) + tracing.AnnotateError(span, errors.Errorf("Could not join signature set")) return pubsub.ValidationIgnore } if !valid { - traceutil.AnnotateError(span, errors.Errorf("Could not verify selection or aggregator or attestation signature")) + tracing.AnnotateError(span, errors.Errorf("Could not verify selection or aggregator or attestation signature")) return pubsub.ValidationReject } diff --git a/beacon-chain/sync/validate_attester_slashing.go b/beacon-chain/sync/validate_attester_slashing.go index ce7dd6885..23a0b8096 100644 --- a/beacon-chain/sync/validate_attester_slashing.go +++ b/beacon-chain/sync/validate_attester_slashing.go @@ -6,9 +6,9 @@ import ( "github.com/libp2p/go-libp2p-core/peer" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/sliceutil" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -32,7 +32,7 @@ func (s *Service) validateAttesterSlashing(ctx context.Context, pid peer.ID, msg m, err := s.decodePubsubMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } slashing, ok := m.(*ethpb.AttesterSlashing) diff --git a/beacon-chain/sync/validate_beacon_attestation.go b/beacon-chain/sync/validate_beacon_attestation.go index 125032f67..c681da6ae 100644 --- a/beacon-chain/sync/validate_beacon_attestation.go +++ b/beacon-chain/sync/validate_beacon_attestation.go @@ -16,9 +16,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/monitoring/tracing" eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -47,7 +47,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(ctx context.Context, p m, err := s.decodePubsubMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } @@ -73,7 +73,7 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(ctx context.Context, p // processing tolerance. if err := helpers.ValidateAttestationTime(att.Data.Slot, s.cfg.Chain.GenesisTime(), earlyAttestationProcessingTolerance); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } if err := helpers.ValidateSlotTargetEpoch(att.Data); err != nil { @@ -101,18 +101,18 @@ func (s *Service) validateCommitteeIndexBeaconAttestation(ctx context.Context, p } if err := s.cfg.Chain.VerifyFinalizedConsistency(ctx, att.Data.BeaconBlockRoot); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } if err := s.cfg.Chain.VerifyLmdFfgConsistency(ctx, att); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } preState, err := s.cfg.Chain.AttestationPreState(ctx, att) if err != nil { log.WithError(err).Error("Could not to retrieve pre state") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } @@ -141,7 +141,7 @@ func (s *Service) validateUnaggregatedAttTopic(ctx context.Context, a *eth.Attes valCount, err := helpers.ActiveValidatorCount(bs, core.SlotToEpoch(a.Data.Slot)) if err != nil { log.WithError(err).Error("Could not retrieve active validator count") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } count := helpers.SlotCommitteeCount(valCount) @@ -153,7 +153,7 @@ func (s *Service) validateUnaggregatedAttTopic(ctx context.Context, a *eth.Attes digest, err := s.currentForkDigest() if err != nil { log.WithError(err).Error("Could not compute fork digest") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } if !strings.HasPrefix(t, fmt.Sprintf(format, digest, subnet)) { @@ -171,7 +171,7 @@ func (s *Service) validateUnaggregatedAttWithState(ctx context.Context, a *eth.A committee, err := helpers.BeaconCommitteeFromState(bs, a.Data.Slot, a.Data.CommitteeIndex) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } @@ -189,7 +189,7 @@ func (s *Service) validateUnaggregatedAttWithState(ctx context.Context, a *eth.A if err := blocks.VerifyAttestationSignature(ctx, bs, a); err != nil { log.WithError(err).Debug("Could not verify attestation") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } diff --git a/beacon-chain/sync/validate_beacon_blocks.go b/beacon-chain/sync/validate_beacon_blocks.go index 7f16da298..bd0f462cb 100644 --- a/beacon-chain/sync/validate_beacon_blocks.go +++ b/beacon-chain/sync/validate_beacon_blocks.go @@ -15,11 +15,11 @@ import ( blockfeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/block" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/transition" + "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/timeutils" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/sirupsen/logrus" "go.opencensus.io/trace" ) @@ -46,7 +46,7 @@ func (s *Service) validateBeaconBlockPubSub(ctx context.Context, pid peer.ID, ms m, err := s.decodePubsubMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } diff --git a/beacon-chain/sync/validate_proposer_slashing.go b/beacon-chain/sync/validate_proposer_slashing.go index 403df0cde..515fb7ab9 100644 --- a/beacon-chain/sync/validate_proposer_slashing.go +++ b/beacon-chain/sync/validate_proposer_slashing.go @@ -7,8 +7,8 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -32,7 +32,7 @@ func (s *Service) validateProposerSlashing(ctx context.Context, pid peer.ID, msg m, err := s.decodePubsubMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } diff --git a/beacon-chain/sync/validate_sync_committee_message.go b/beacon-chain/sync/validate_sync_committee_message.go index d0b84c086..bdd5dbefe 100644 --- a/beacon-chain/sync/validate_sync_committee_message.go +++ b/beacon-chain/sync/validate_sync_committee_message.go @@ -13,11 +13,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/p2p" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -63,7 +63,7 @@ func (s *Service) validateSyncCommitteeMessage( m, err := s.readSyncCommitteeMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } @@ -74,13 +74,13 @@ func (s *Service) validateSyncCommitteeMessage( s.cfg.Chain.GenesisTime(), params.BeaconNetworkConfig().MaximumGossipClockDisparity, ); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } committeeIndices, err := s.cfg.Chain.HeadCurrentSyncCommitteeIndices(ctx, m.ValidatorIndex, m.Slot) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } @@ -159,7 +159,7 @@ func (s *Service) rejectIncorrectSyncCommittee( isValid := false digest, err := s.currentForkDigest() if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } @@ -213,13 +213,13 @@ func (s *Service) rejectInvalidSyncCommitteeSignature(m *ethpb.SyncCommitteeMess // since the failure is locally derived. d, err := s.cfg.Chain.HeadSyncCommitteeDomain(ctx, m.Slot) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } rawBytes := p2ptypes.SSZBytes(m.BlockRoot) sigRoot, err := helpers.ComputeSigningRoot(&rawBytes, d) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } @@ -227,21 +227,21 @@ func (s *Service) rejectInvalidSyncCommitteeSignature(m *ethpb.SyncCommitteeMess // that is on such a different fork than our chain. pubKey, err := s.cfg.Chain.HeadValidatorIndexToPublicKey(ctx, m.ValidatorIndex) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } // We reject a malformed signature from bytes according to the p2p specification. blsSig, err := bls.SignatureFromBytes(m.Signature) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } // Ignore a malformed public key from bytes according to the p2p specification. pKey, err := bls.PublicKeyFromBytes(pubKey[:]) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } diff --git a/beacon-chain/sync/validate_sync_contribution_proof.go b/beacon-chain/sync/validate_sync_contribution_proof.go index d7b82f630..f111ba53a 100644 --- a/beacon-chain/sync/validate_sync_contribution_proof.go +++ b/beacon-chain/sync/validate_sync_contribution_proof.go @@ -9,11 +9,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -51,13 +51,13 @@ func (s *Service) validateSyncContributionAndProof(ctx context.Context, pid peer m, err := s.readSyncContributionMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } // The contribution's slot is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance). if err := altair.ValidateSyncMessageTime(m.Message.Contribution.Slot, s.cfg.Chain.GenesisTime(), params.BeaconNetworkConfig().MaximumGossipClockDisparity); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } // Validate the message's data according to the p2p specification. @@ -152,11 +152,11 @@ func (s *Service) rejectInvalidIndexInSubCommittee(m *ethpb.SignedContributionAn // The aggregator's validator index is in the declared subcommittee of the current sync committee. committeeIndices, err := s.cfg.Chain.HeadCurrentSyncCommitteeIndices(ctx, m.Message.AggregatorIndex, m.Message.Contribution.Slot) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } if len(committeeIndices) == 0 { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } isValid := false @@ -180,7 +180,7 @@ func (s *Service) rejectInvalidSelectionProof(m *ethpb.SignedContributionAndProo defer span.End() // The `contribution_and_proof.selection_proof` is a valid signature of the `SyncAggregatorSelectionData`. if err := s.verifySyncSelectionData(ctx, m.Message); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } return pubsub.ValidationAccept @@ -194,7 +194,7 @@ func (s *Service) rejectInvalidContributionSignature(m *ethpb.SignedContribution // The aggregator signature, `signed_contribution_and_proof.signature`, is valid. d, err := s.cfg.Chain.HeadSyncContributionProofDomain(ctx, m.Message.Contribution.Slot) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } pubkey, err := s.cfg.Chain.HeadValidatorIndexToPublicKey(ctx, m.Message.AggregatorIndex) @@ -202,7 +202,7 @@ func (s *Service) rejectInvalidContributionSignature(m *ethpb.SignedContribution return pubsub.ValidationIgnore } if err := helpers.VerifySigningRoot(m.Message, pubkey[:], m.Signature, d); err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } return pubsub.ValidationAccept @@ -230,7 +230,7 @@ func (s *Service) rejectInvalidSyncAggregateSignature(m *ethpb.SignedContributio if bVector.BitAt(uint64(i)) { pubK, err := bls.PublicKeyFromBytes(pk) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } activePubkeys = append(activePubkeys, pubK) @@ -238,18 +238,18 @@ func (s *Service) rejectInvalidSyncAggregateSignature(m *ethpb.SignedContributio } sig, err := bls.SignatureFromBytes(m.Message.Contribution.Signature) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } d, err := s.cfg.Chain.HeadSyncCommitteeDomain(ctx, m.Message.Contribution.Slot) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } rawBytes := p2ptypes.SSZBytes(m.Message.Contribution.BlockRoot) sigRoot, err := helpers.ComputeSigningRoot(&rawBytes, d) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationIgnore } verified := sig.Eth2FastAggregateVerify(activePubkeys, sigRoot) diff --git a/beacon-chain/sync/validate_voluntary_exit.go b/beacon-chain/sync/validate_voluntary_exit.go index f22047e93..31d66ec72 100644 --- a/beacon-chain/sync/validate_voluntary_exit.go +++ b/beacon-chain/sync/validate_voluntary_exit.go @@ -7,8 +7,8 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" ) @@ -32,7 +32,7 @@ func (s *Service) validateVoluntaryExit(ctx context.Context, pid peer.ID, msg *p m, err := s.decodePubsubMessage(msg) if err != nil { log.WithError(err).Debug("Could not decode message") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return pubsub.ValidationReject } diff --git a/cmd/beacon-chain/BUILD.bazel b/cmd/beacon-chain/BUILD.bazel index 0669d02d8..162d79b48 100644 --- a/cmd/beacon-chain/BUILD.bazel +++ b/cmd/beacon-chain/BUILD.bazel @@ -18,11 +18,11 @@ go_library( "//beacon-chain/node:go_default_library", "//cmd/beacon-chain/db:go_default_library", "//cmd/beacon-chain/flags:go_default_library", + "//monitoring/journald:go_default_library", "//shared/cmd:go_default_library", "//shared/debug:go_default_library", "//shared/featureconfig:go_default_library", "//shared/fileutil:go_default_library", - "//shared/journald:go_default_library", "//shared/logutil:go_default_library", "//shared/maxprocs:go_default_library", "//shared/tos:go_default_library", diff --git a/cmd/beacon-chain/main.go b/cmd/beacon-chain/main.go index bfe3032aa..dd1355cd8 100644 --- a/cmd/beacon-chain/main.go +++ b/cmd/beacon-chain/main.go @@ -14,11 +14,11 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/node" dbcommands "github.com/prysmaticlabs/prysm/cmd/beacon-chain/db" "github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags" + "github.com/prysmaticlabs/prysm/monitoring/journald" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/debug" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/fileutil" - "github.com/prysmaticlabs/prysm/shared/journald" "github.com/prysmaticlabs/prysm/shared/logutil" _ "github.com/prysmaticlabs/prysm/shared/maxprocs" "github.com/prysmaticlabs/prysm/shared/tos" diff --git a/cmd/client-stats/BUILD.bazel b/cmd/client-stats/BUILD.bazel index c3cbd3d0d..9c21b4231 100644 --- a/cmd/client-stats/BUILD.bazel +++ b/cmd/client-stats/BUILD.bazel @@ -12,9 +12,9 @@ go_library( visibility = ["//visibility:private"], deps = [ "//cmd/client-stats/flags:go_default_library", - "//shared/clientstats:go_default_library", + "//monitoring/clientstats:go_default_library", + "//monitoring/journald:go_default_library", "//shared/cmd:go_default_library", - "//shared/journald:go_default_library", "//shared/logutil:go_default_library", "//shared/version:go_default_library", "@com_github_joonix_log//:go_default_library", diff --git a/cmd/client-stats/main.go b/cmd/client-stats/main.go index 5bf2ac023..b55ee3540 100644 --- a/cmd/client-stats/main.go +++ b/cmd/client-stats/main.go @@ -8,9 +8,9 @@ import ( joonix "github.com/joonix/log" "github.com/prysmaticlabs/prysm/cmd/client-stats/flags" - "github.com/prysmaticlabs/prysm/shared/clientstats" + "github.com/prysmaticlabs/prysm/monitoring/clientstats" + "github.com/prysmaticlabs/prysm/monitoring/journald" "github.com/prysmaticlabs/prysm/shared/cmd" - "github.com/prysmaticlabs/prysm/shared/journald" "github.com/prysmaticlabs/prysm/shared/logutil" "github.com/prysmaticlabs/prysm/shared/version" "github.com/sirupsen/logrus" diff --git a/cmd/slasher/BUILD.bazel b/cmd/slasher/BUILD.bazel index 0f7cb0eea..4c677dde3 100644 --- a/cmd/slasher/BUILD.bazel +++ b/cmd/slasher/BUILD.bazel @@ -15,10 +15,10 @@ go_library( visibility = ["//slasher:__subpackages__"], deps = [ "//cmd/slasher/flags:go_default_library", + "//monitoring/journald:go_default_library", "//shared/cmd:go_default_library", "//shared/debug:go_default_library", "//shared/featureconfig:go_default_library", - "//shared/journald:go_default_library", "//shared/logutil:go_default_library", "//shared/tos:go_default_library", "//shared/version:go_default_library", diff --git a/cmd/slasher/main.go b/cmd/slasher/main.go index fa8c7330d..678254310 100644 --- a/cmd/slasher/main.go +++ b/cmd/slasher/main.go @@ -10,10 +10,10 @@ import ( joonix "github.com/joonix/log" "github.com/prysmaticlabs/prysm/cmd/slasher/flags" + "github.com/prysmaticlabs/prysm/monitoring/journald" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/debug" "github.com/prysmaticlabs/prysm/shared/featureconfig" - "github.com/prysmaticlabs/prysm/shared/journald" "github.com/prysmaticlabs/prysm/shared/logutil" "github.com/prysmaticlabs/prysm/shared/tos" "github.com/prysmaticlabs/prysm/shared/version" diff --git a/cmd/validator/BUILD.bazel b/cmd/validator/BUILD.bazel index c8fe36979..3fd38d1c6 100644 --- a/cmd/validator/BUILD.bazel +++ b/cmd/validator/BUILD.bazel @@ -20,11 +20,11 @@ go_library( "//cmd/validator/flags:go_default_library", "//cmd/validator/slashing-protection:go_default_library", "//cmd/validator/wallet:go_default_library", + "//monitoring/journald:go_default_library", "//shared/cmd:go_default_library", "//shared/debug:go_default_library", "//shared/featureconfig:go_default_library", "//shared/fileutil:go_default_library", - "//shared/journald:go_default_library", "//shared/logutil:go_default_library", "//shared/maxprocs:go_default_library", "//shared/tos:go_default_library", diff --git a/cmd/validator/main.go b/cmd/validator/main.go index 9c3d0e797..1128fa84a 100644 --- a/cmd/validator/main.go +++ b/cmd/validator/main.go @@ -16,11 +16,11 @@ import ( "github.com/prysmaticlabs/prysm/cmd/validator/flags" slashingprotectioncommands "github.com/prysmaticlabs/prysm/cmd/validator/slashing-protection" walletcommands "github.com/prysmaticlabs/prysm/cmd/validator/wallet" + "github.com/prysmaticlabs/prysm/monitoring/journald" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/debug" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/fileutil" - "github.com/prysmaticlabs/prysm/shared/journald" "github.com/prysmaticlabs/prysm/shared/logutil" _ "github.com/prysmaticlabs/prysm/shared/maxprocs" "github.com/prysmaticlabs/prysm/shared/tos" diff --git a/shared/backuputil/BUILD.bazel b/monitoring/backup/BUILD.bazel similarity index 77% rename from shared/backuputil/BUILD.bazel rename to monitoring/backup/BUILD.bazel index 40524b16e..2fc96425b 100644 --- a/shared/backuputil/BUILD.bazel +++ b/monitoring/backup/BUILD.bazel @@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = ["http_backup_handler.go"], - importpath = "github.com/prysmaticlabs/prysm/shared/backuputil", + importpath = "github.com/prysmaticlabs/prysm/monitoring/backup", visibility = ["//visibility:public"], deps = ["@com_github_sirupsen_logrus//:go_default_library"], ) diff --git a/shared/backuputil/http_backup_handler.go b/monitoring/backup/http_backup_handler.go similarity index 98% rename from shared/backuputil/http_backup_handler.go rename to monitoring/backup/http_backup_handler.go index 91528d5e7..f33f2c378 100644 --- a/shared/backuputil/http_backup_handler.go +++ b/monitoring/backup/http_backup_handler.go @@ -1,4 +1,4 @@ -package backuputil +package backup import ( "context" diff --git a/shared/clientstats/BUILD.bazel b/monitoring/clientstats/BUILD.bazel similarity index 91% rename from shared/clientstats/BUILD.bazel rename to monitoring/clientstats/BUILD.bazel index 201353b60..590d7fde1 100644 --- a/shared/clientstats/BUILD.bazel +++ b/monitoring/clientstats/BUILD.bazel @@ -8,7 +8,7 @@ go_library( "types.go", "updaters.go", ], - importpath = "github.com/prysmaticlabs/prysm/shared/clientstats", + importpath = "github.com/prysmaticlabs/prysm/monitoring/clientstats", visibility = ["//visibility:public"], deps = [ "//proto/prysm/v1alpha1:go_default_library", diff --git a/shared/clientstats/README.md b/monitoring/clientstats/README.md similarity index 100% rename from shared/clientstats/README.md rename to monitoring/clientstats/README.md diff --git a/shared/clientstats/interfaces.go b/monitoring/clientstats/interfaces.go similarity index 100% rename from shared/clientstats/interfaces.go rename to monitoring/clientstats/interfaces.go diff --git a/shared/clientstats/scrapers.go b/monitoring/clientstats/scrapers.go similarity index 100% rename from shared/clientstats/scrapers.go rename to monitoring/clientstats/scrapers.go diff --git a/shared/clientstats/scrapers_test.go b/monitoring/clientstats/scrapers_test.go similarity index 100% rename from shared/clientstats/scrapers_test.go rename to monitoring/clientstats/scrapers_test.go diff --git a/shared/clientstats/types.go b/monitoring/clientstats/types.go similarity index 100% rename from shared/clientstats/types.go rename to monitoring/clientstats/types.go diff --git a/shared/clientstats/updaters.go b/monitoring/clientstats/updaters.go similarity index 100% rename from shared/clientstats/updaters.go rename to monitoring/clientstats/updaters.go diff --git a/shared/journald/BUILD.bazel b/monitoring/journald/BUILD.bazel similarity index 88% rename from shared/journald/BUILD.bazel rename to monitoring/journald/BUILD.bazel index 4475bf931..d2544de49 100644 --- a/shared/journald/BUILD.bazel +++ b/monitoring/journald/BUILD.bazel @@ -6,7 +6,7 @@ go_library( "journald.go", "journald_linux.go", ], - importpath = "github.com/prysmaticlabs/prysm/shared/journald", + importpath = "github.com/prysmaticlabs/prysm/monitoring/journald", visibility = ["//visibility:public"], deps = select({ "@io_bazel_rules_go//go/platform:android": [ diff --git a/shared/journald/journald.go b/monitoring/journald/journald.go similarity index 100% rename from shared/journald/journald.go rename to monitoring/journald/journald.go diff --git a/shared/journald/journald_linux.go b/monitoring/journald/journald_linux.go similarity index 100% rename from shared/journald/journald_linux.go rename to monitoring/journald/journald_linux.go diff --git a/shared/progressutil/BUILD.bazel b/monitoring/progress/BUILD.bazel similarity index 81% rename from shared/progressutil/BUILD.bazel rename to monitoring/progress/BUILD.bazel index 4d9daa509..2a5fd2372 100644 --- a/shared/progressutil/BUILD.bazel +++ b/monitoring/progress/BUILD.bazel @@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = ["progress.go"], - importpath = "github.com/prysmaticlabs/prysm/shared/progressutil", + importpath = "github.com/prysmaticlabs/prysm/monitoring/progress", visibility = ["//visibility:public"], deps = [ "@com_github_k0kubun_go_ansi//:go_default_library", diff --git a/shared/progressutil/progress.go b/monitoring/progress/progress.go similarity index 97% rename from shared/progressutil/progress.go rename to monitoring/progress/progress.go index a2272af48..e4cffa4ad 100644 --- a/shared/progressutil/progress.go +++ b/monitoring/progress/progress.go @@ -1,4 +1,4 @@ -package progressutil +package progress import ( "fmt" diff --git a/shared/prometheus/BUILD.bazel b/monitoring/prometheus/BUILD.bazel similarity index 93% rename from shared/prometheus/BUILD.bazel rename to monitoring/prometheus/BUILD.bazel index 04fa44b26..f1cd502d7 100644 --- a/shared/prometheus/BUILD.bazel +++ b/monitoring/prometheus/BUILD.bazel @@ -8,7 +8,7 @@ go_library( "service.go", "simple_server.go", ], - importpath = "github.com/prysmaticlabs/prysm/shared/prometheus", + importpath = "github.com/prysmaticlabs/prysm/monitoring/prometheus", visibility = ["//visibility:public"], deps = [ "//shared:go_default_library", diff --git a/shared/prometheus/README.md b/monitoring/prometheus/README.md similarity index 100% rename from shared/prometheus/README.md rename to monitoring/prometheus/README.md diff --git a/shared/prometheus/content_negotiation.go b/monitoring/prometheus/content_negotiation.go similarity index 100% rename from shared/prometheus/content_negotiation.go rename to monitoring/prometheus/content_negotiation.go diff --git a/shared/prometheus/logrus_collector.go b/monitoring/prometheus/logrus_collector.go similarity index 100% rename from shared/prometheus/logrus_collector.go rename to monitoring/prometheus/logrus_collector.go diff --git a/shared/prometheus/logrus_collector_test.go b/monitoring/prometheus/logrus_collector_test.go similarity index 98% rename from shared/prometheus/logrus_collector_test.go rename to monitoring/prometheus/logrus_collector_test.go index 2ae9a3ae8..440c12f22 100644 --- a/shared/prometheus/logrus_collector_test.go +++ b/monitoring/prometheus/logrus_collector_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/prysmaticlabs/prysm/shared/prometheus" + "github.com/prysmaticlabs/prysm/monitoring/prometheus" "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" log "github.com/sirupsen/logrus" diff --git a/shared/prometheus/service.go b/monitoring/prometheus/service.go similarity index 100% rename from shared/prometheus/service.go rename to monitoring/prometheus/service.go diff --git a/shared/prometheus/service_test.go b/monitoring/prometheus/service_test.go similarity index 100% rename from shared/prometheus/service_test.go rename to monitoring/prometheus/service_test.go diff --git a/shared/prometheus/simple_server.go b/monitoring/prometheus/simple_server.go similarity index 100% rename from shared/prometheus/simple_server.go rename to monitoring/prometheus/simple_server.go diff --git a/shared/tracing/BUILD.bazel b/monitoring/tracing/BUILD.bazel similarity index 69% rename from shared/tracing/BUILD.bazel rename to monitoring/tracing/BUILD.bazel index a2a65f992..e3799fb94 100644 --- a/shared/tracing/BUILD.bazel +++ b/monitoring/tracing/BUILD.bazel @@ -2,8 +2,12 @@ load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", - srcs = ["tracer.go"], - importpath = "github.com/prysmaticlabs/prysm/shared/tracing", + srcs = [ + "errors.go", + "recovery_interceptor_option.go", + "tracer.go", + ], + importpath = "github.com/prysmaticlabs/prysm/monitoring/tracing", visibility = ["//visibility:public"], deps = [ "//shared/version:go_default_library", diff --git a/shared/tracing/README.md b/monitoring/tracing/README.md similarity index 100% rename from shared/tracing/README.md rename to monitoring/tracing/README.md diff --git a/shared/traceutil/errors.go b/monitoring/tracing/errors.go similarity index 79% rename from shared/traceutil/errors.go rename to monitoring/tracing/errors.go index 2af444831..642573104 100644 --- a/shared/traceutil/errors.go +++ b/monitoring/tracing/errors.go @@ -1,5 +1,5 @@ -// Package traceutil includes useful functions for opentracing annotations. -package traceutil +// Package tracing includes useful functions for opentracing annotations. +package tracing import ( "go.opencensus.io/trace" diff --git a/shared/traceutil/recovery_interceptor_option.go b/monitoring/tracing/recovery_interceptor_option.go similarity index 97% rename from shared/traceutil/recovery_interceptor_option.go rename to monitoring/tracing/recovery_interceptor_option.go index b39f79994..a93146981 100644 --- a/shared/traceutil/recovery_interceptor_option.go +++ b/monitoring/tracing/recovery_interceptor_option.go @@ -1,4 +1,4 @@ -package traceutil +package tracing import ( "context" diff --git a/shared/tracing/tracer.go b/monitoring/tracing/tracer.go similarity index 100% rename from shared/tracing/tracer.go rename to monitoring/tracing/tracer.go diff --git a/shared/traceutil/BUILD.bazel b/shared/traceutil/BUILD.bazel deleted file mode 100644 index fcafb3e0b..000000000 --- a/shared/traceutil/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -load("@prysm//tools/go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "errors.go", - "recovery_interceptor_option.go", - ], - importpath = "github.com/prysmaticlabs/prysm/shared/traceutil", - visibility = ["//visibility:public"], - deps = [ - "@com_github_sirupsen_logrus//:go_default_library", - "@io_opencensus_go//trace:go_default_library", - ], -) diff --git a/slasher/db/iface/BUILD.bazel b/slasher/db/iface/BUILD.bazel index fabc53a38..0f6768004 100644 --- a/slasher/db/iface/BUILD.bazel +++ b/slasher/db/iface/BUILD.bazel @@ -6,8 +6,8 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/slasher/db/iface", visibility = ["//slasher/db:__subpackages__"], deps = [ + "//monitoring/backup:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/backuputil:go_default_library", "//slasher/db/types:go_default_library", "//slasher/detection/attestations/types:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", diff --git a/slasher/db/iface/interface.go b/slasher/db/iface/interface.go index 9f26ada6f..cd648a784 100644 --- a/slasher/db/iface/interface.go +++ b/slasher/db/iface/interface.go @@ -8,9 +8,9 @@ import ( "io" types "github.com/prysmaticlabs/eth2-types" + "github.com/prysmaticlabs/prysm/monitoring/backup" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" slashpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/backuputil" dbtypes "github.com/prysmaticlabs/prysm/slasher/db/types" slashertypes "github.com/prysmaticlabs/prysm/slasher/detection/attestations/types" ) @@ -99,7 +99,7 @@ type FullAccessDatabase interface { // Database represents a full access database with the proper DB helper functions. type Database interface { io.Closer - backuputil.BackupExporter + backup.BackupExporter FullAccessDatabase DatabasePath() string ClearDB() error diff --git a/slasher/node/BUILD.bazel b/slasher/node/BUILD.bazel index 37f6e585f..8cefde00a 100644 --- a/slasher/node/BUILD.bazel +++ b/slasher/node/BUILD.bazel @@ -13,16 +13,16 @@ go_library( ], deps = [ "//cmd/slasher/flags:go_default_library", + "//monitoring/backup:go_default_library", + "//monitoring/prometheus:go_default_library", + "//monitoring/tracing:go_default_library", "//shared:go_default_library", - "//shared/backuputil:go_default_library", "//shared/cmd:go_default_library", "//shared/debug:go_default_library", "//shared/event:go_default_library", "//shared/featureconfig:go_default_library", "//shared/params:go_default_library", "//shared/prereq:go_default_library", - "//shared/prometheus:go_default_library", - "//shared/tracing:go_default_library", "//shared/version:go_default_library", "//slasher/beaconclient:go_default_library", "//slasher/db:go_default_library", diff --git a/slasher/node/node.go b/slasher/node/node.go index c83c59945..99d8f4d3a 100644 --- a/slasher/node/node.go +++ b/slasher/node/node.go @@ -14,16 +14,16 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/cmd/slasher/flags" + "github.com/prysmaticlabs/prysm/monitoring/backup" + "github.com/prysmaticlabs/prysm/monitoring/prometheus" + tracing2 "github.com/prysmaticlabs/prysm/monitoring/tracing" "github.com/prysmaticlabs/prysm/shared" - "github.com/prysmaticlabs/prysm/shared/backuputil" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/debug" "github.com/prysmaticlabs/prysm/shared/event" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/prereq" - "github.com/prysmaticlabs/prysm/shared/prometheus" - "github.com/prysmaticlabs/prysm/shared/tracing" "github.com/prysmaticlabs/prysm/shared/version" "github.com/prysmaticlabs/prysm/slasher/beaconclient" "github.com/prysmaticlabs/prysm/slasher/db" @@ -52,7 +52,7 @@ type SlasherNode struct { // New creates a new node instance, sets up configuration options, // and registers every required service. func New(cliCtx *cli.Context) (*SlasherNode, error) { - if err := tracing.Setup( + if err := tracing2.Setup( "slasher", // Service name. cliCtx.String(cmd.TracingProcessNameFlag.Name), cliCtx.String(cmd.TracingEndpointFlag.Name), @@ -165,7 +165,7 @@ func (n *SlasherNode) registerPrometheusService(cliCtx *cli.Context) error { additionalHandlers, prometheus.Handler{ Path: "/db/backup", - Handler: backuputil.BackupHandler(n.db, cliCtx.String(cmd.BackupWebhookOutputDir.Name)), + Handler: backup.BackupHandler(n.db, cliCtx.String(cmd.BackupWebhookOutputDir.Name)), }, ) } diff --git a/slasher/rpc/BUILD.bazel b/slasher/rpc/BUILD.bazel index 812bee388..a25e4f71e 100644 --- a/slasher/rpc/BUILD.bazel +++ b/slasher/rpc/BUILD.bazel @@ -12,12 +12,12 @@ go_library( deps = [ "//beacon-chain/core:go_default_library", "//beacon-chain/core/helpers:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//shared/attestationutil:go_default_library", "//shared/bls:go_default_library", "//shared/p2putils:go_default_library", "//shared/params:go_default_library", - "//shared/traceutil:go_default_library", "//slasher/beaconclient:go_default_library", "//slasher/db:go_default_library", "//slasher/detection:go_default_library", diff --git a/slasher/rpc/service.go b/slasher/rpc/service.go index 48acf80e4..3d7f7e8b4 100644 --- a/slasher/rpc/service.go +++ b/slasher/rpc/service.go @@ -12,8 +12,8 @@ import ( recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "github.com/prysmaticlabs/prysm/monitoring/tracing" slashpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/prysmaticlabs/prysm/slasher/beaconclient" "github.com/prysmaticlabs/prysm/slasher/db" "github.com/prysmaticlabs/prysm/slasher/detection" @@ -70,14 +70,14 @@ func (s *Service) Start() { grpc.StatsHandler(&ocgrpc.ServerHandler{}), grpc.StreamInterceptor(middleware.ChainStreamServer( recovery.StreamServerInterceptor( - recovery.WithRecoveryHandlerContext(traceutil.RecoveryHandlerFunc), + recovery.WithRecoveryHandlerContext(tracing.RecoveryHandlerFunc), ), grpc_prometheus.StreamServerInterceptor, grpc_opentracing.StreamServerInterceptor(), )), grpc.UnaryInterceptor(middleware.ChainUnaryServer( recovery.UnaryServerInterceptor( - recovery.WithRecoveryHandlerContext(traceutil.RecoveryHandlerFunc), + recovery.WithRecoveryHandlerContext(tracing.RecoveryHandlerFunc), ), grpc_prometheus.UnaryServerInterceptor, grpc_opentracing.UnaryServerInterceptor(), diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 3861864cc..c2271b888 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -24,6 +24,7 @@ go_library( "//beacon-chain/core:go_default_library", "//beacon-chain/core/altair:go_default_library", "//beacon-chain/core/helpers:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/block:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", @@ -43,7 +44,6 @@ go_library( "//shared/slashutil:go_default_library", "//shared/slotutil:go_default_library", "//shared/timeutils:go_default_library", - "//shared/traceutil:go_default_library", "//shared/version:go_default_library", "//validator/accounts/iface:go_default_library", "//validator/accounts/wallet:go_default_library", diff --git a/validator/client/aggregate.go b/validator/client/aggregate.go index 1ee20bf3e..3c2e8bf42 100644 --- a/validator/client/aggregate.go +++ b/validator/client/aggregate.go @@ -8,13 +8,13 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" "github.com/prysmaticlabs/prysm/shared/timeutils" - "github.com/prysmaticlabs/prysm/shared/traceutil" "go.opencensus.io/trace" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -163,7 +163,7 @@ func (v *validator) waitToSlotTwoThirds(ctx context.Context, slot types.Slot) { defer t.Stop() select { case <-ctx.Done(): - traceutil.AnnotateError(span, ctx.Err()) + tracing.AnnotateError(span, ctx.Err()) return case <-t.C: return diff --git a/validator/client/attest.go b/validator/client/attest.go index 29634d553..6aa2c2889 100644 --- a/validator/client/attest.go +++ b/validator/client/attest.go @@ -11,6 +11,7 @@ import ( types "github.com/prysmaticlabs/eth2-types" "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" @@ -21,7 +22,6 @@ import ( "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" "github.com/prysmaticlabs/prysm/shared/timeutils" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/prysmaticlabs/prysm/validator/client/iface" "github.com/sirupsen/logrus" "go.opencensus.io/trace" @@ -41,13 +41,13 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK var b strings.Builder if err := b.WriteByte(byte(iface.RoleAttester)); err != nil { log.WithError(err).Error("Could not write role byte for lock key") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } _, err := b.Write(pubKey[:]) if err != nil { log.WithError(err).Error("Could not write pubkey bytes for lock key") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } lock := mputil.NewMultilock(b.String()) @@ -62,7 +62,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK if v.emitAccountMetrics { ValidatorAttestFailVec.WithLabelValues(fmtKey).Inc() } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } if len(duty.Committee) == 0 { @@ -80,7 +80,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK if v.emitAccountMetrics { ValidatorAttestFailVec.WithLabelValues(fmtKey).Inc() } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } @@ -95,7 +95,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK if v.emitAccountMetrics { ValidatorAttestFailVec.WithLabelValues(fmtKey).Inc() } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } @@ -105,7 +105,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK if v.emitAccountMetrics { ValidatorAttestFailVec.WithLabelValues(fmtKey).Inc() } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } @@ -141,7 +141,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK log.WithFields( attestationLogFields(pubKey, indexedAtt), ).Debug("Attempted slashable attestation details") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } attResp, err := v.validatorClient.ProposeAttestation(ctx, attestation) @@ -150,7 +150,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK if v.emitAccountMetrics { ValidatorAttestFailVec.WithLabelValues(fmtKey).Inc() } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } @@ -159,7 +159,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot types.Slot, pubK if v.emitAccountMetrics { ValidatorAttestFailVec.WithLabelValues(fmtKey).Inc() } - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } @@ -280,7 +280,7 @@ func (v *validator) waitOneThirdOrValidBlock(ctx context.Context, slot types.Slo } } case <-ctx.Done(): - traceutil.AnnotateError(span, ctx.Err()) + tracing.AnnotateError(span, ctx.Err()) return case <-sub.Err(): log.Error("Subscriber closed, exiting goroutine") diff --git a/validator/client/sync_committee.go b/validator/client/sync_committee.go index 383fd9ac7..bd122ee10 100644 --- a/validator/client/sync_committee.go +++ b/validator/client/sync_committee.go @@ -10,12 +10,12 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core" "github.com/prysmaticlabs/prysm/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/shared/bls" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/sirupsen/logrus" "go.opencensus.io/trace" ) @@ -31,7 +31,7 @@ func (v *validator) SubmitSyncCommitteeMessage(ctx context.Context, slot types.S res, err := v.validatorClient.GetSyncMessageBlockRoot(ctx, &emptypb.Empty{}) if err != nil { log.WithError(err).Error("Could not request sync message block root to sign") - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return } diff --git a/validator/client/wait_for_activation.go b/validator/client/wait_for_activation.go index 87e1f4f45..4b330aabc 100644 --- a/validator/client/wait_for_activation.go +++ b/validator/client/wait_for_activation.go @@ -6,12 +6,12 @@ import ( "time" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/prysmaticlabs/prysm/validator/keymanager/remote" "go.opencensus.io/trace" ) @@ -80,7 +80,7 @@ func (v *validator) waitForActivation(ctx context.Context, accountsChangedChan < } stream, err := v.validatorClient.WaitForActivation(ctx, req) if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) attempts := streamAttempts(ctx) log.WithError(err).WithField("attempts", attempts). Error("Stream broken while waiting for activation. Reconnecting...") @@ -150,7 +150,7 @@ func (v *validator) waitForActivation(ctx context.Context, accountsChangedChan < return errors.Wrap(ctx.Err(), "context has been canceled so shutting down the loop") } if err != nil { - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) attempts := streamAttempts(ctx) log.WithError(err).WithField("attempts", attempts). Error("Stream broken while waiting for activation. Reconnecting...") diff --git a/validator/db/iface/BUILD.bazel b/validator/db/iface/BUILD.bazel index 4e2c3c767..c244c5f41 100644 --- a/validator/db/iface/BUILD.bazel +++ b/validator/db/iface/BUILD.bazel @@ -7,8 +7,8 @@ go_library( # Other packages must use github.com/prysmaticlabs/prysm/validator/db.Database alias. visibility = ["//validator/db:__subpackages__"], deps = [ + "//monitoring/backup:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//shared/backuputil:go_default_library", "//validator/db/kv:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", ], diff --git a/validator/db/iface/interface.go b/validator/db/iface/interface.go index d43eb1c48..491f199f0 100644 --- a/validator/db/iface/interface.go +++ b/validator/db/iface/interface.go @@ -6,8 +6,8 @@ import ( "io" types "github.com/prysmaticlabs/eth2-types" + "github.com/prysmaticlabs/prysm/monitoring/backup" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/shared/backuputil" "github.com/prysmaticlabs/prysm/validator/db/kv" ) @@ -17,7 +17,7 @@ var _ = ValidatorDB(&kv.Store{}) // ValidatorDB defines the necessary methods for a Prysm validator DB. type ValidatorDB interface { io.Closer - backuputil.BackupExporter + backup.BackupExporter DatabasePath() string ClearDB() error RunUpMigrations(ctx context.Context) error diff --git a/validator/db/kv/BUILD.bazel b/validator/db/kv/BUILD.bazel index ea1f40738..a4f352816 100644 --- a/validator/db/kv/BUILD.bazel +++ b/validator/db/kv/BUILD.bazel @@ -22,6 +22,8 @@ go_library( visibility = ["//validator:__subpackages__"], deps = [ "//beacon-chain/core:go_default_library", + "//monitoring/progress:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//shared/abool:go_default_library", "//shared/bytesutil:go_default_library", @@ -29,9 +31,7 @@ go_library( "//shared/featureconfig:go_default_library", "//shared/fileutil:go_default_library", "//shared/params:go_default_library", - "//shared/progressutil:go_default_library", "//shared/slashutil:go_default_library", - "//shared/traceutil:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prysmaticlabs_eth2_types//:go_default_library", diff --git a/validator/db/kv/attester_protection.go b/validator/db/kv/attester_protection.go index 21765aa44..478f2c143 100644 --- a/validator/db/kv/attester_protection.go +++ b/validator/db/kv/attester_protection.go @@ -8,10 +8,10 @@ import ( "github.com/pkg/errors" types "github.com/prysmaticlabs/eth2-types" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/slashutil" - "github.com/prysmaticlabs/prysm/shared/traceutil" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" ) @@ -187,7 +187,7 @@ func (s *Store) CheckSlashableAttestation( return nil }) - traceutil.AnnotateError(span, err) + tracing.AnnotateError(span, err) return slashKind, err } diff --git a/validator/db/kv/migration_optimal_attester_protection.go b/validator/db/kv/migration_optimal_attester_protection.go index a3e8dde6d..411a5321c 100644 --- a/validator/db/kv/migration_optimal_attester_protection.go +++ b/validator/db/kv/migration_optimal_attester_protection.go @@ -5,9 +5,9 @@ import ( "context" types "github.com/prysmaticlabs/eth2-types" + "github.com/prysmaticlabs/prysm/monitoring/progress" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/progressutil" bolt "go.etcd.io/bbolt" ) @@ -59,7 +59,7 @@ func (s *Store) migrateOptimalAttesterProtectionUp(ctx context.Context) error { return err } - bar := progressutil.InitializeProgressBar(numKeys, "Migrating attesting history to more efficient format") + bar := progress.InitializeProgressBar(numKeys, "Migrating attesting history to more efficient format") for i, publicKey := range publicKeyBytes { attestingHistory := deprecatedEncodedAttestingHistory(attestingHistoryBytes[i]) err = s.db.Update(func(tx *bolt.Tx) error { @@ -193,7 +193,7 @@ func (s *Store) migrateOptimalAttesterProtectionDown(ctx context.Context) error if bkt == nil { return nil } - bar := progressutil.InitializeProgressBar(len(pubKeys), "Migrating attesting history to old format") + bar := progress.InitializeProgressBar(len(pubKeys), "Migrating attesting history to old format") for _, pubKey := range pubKeys { // Now we write the attesting history using the data we extracted // from the buckets accordingly. diff --git a/validator/db/kv/migration_source_target_epochs_bucket.go b/validator/db/kv/migration_source_target_epochs_bucket.go index 561e78155..6bd089257 100644 --- a/validator/db/kv/migration_source_target_epochs_bucket.go +++ b/validator/db/kv/migration_source_target_epochs_bucket.go @@ -4,7 +4,7 @@ import ( "bytes" "context" - "github.com/prysmaticlabs/prysm/shared/progressutil" + "github.com/prysmaticlabs/prysm/monitoring/progress" bolt "go.etcd.io/bbolt" ) @@ -43,7 +43,7 @@ func (s *Store) migrateSourceTargetEpochsBucketUp(ctx context.Context) error { // If we did a single transaction for all public keys, resource use might be too high, // and if we do a single one per key, the migration will take too long. batchedKeys := batchPublicKeys(publicKeyBytes, publicKeyMigrationBatchSize) - bar := progressutil.InitializeProgressBar( + bar := progress.InitializeProgressBar( len(batchedKeys), "Adding optimizations for validator slashing protection", ) for _, batch := range batchedKeys { diff --git a/validator/node/BUILD.bazel b/validator/node/BUILD.bazel index 34c9057a0..53c4b1d90 100644 --- a/validator/node/BUILD.bazel +++ b/validator/node/BUILD.bazel @@ -29,10 +29,12 @@ go_library( ], deps = [ "//cmd/validator/flags:go_default_library", + "//monitoring/backup:go_default_library", + "//monitoring/prometheus:go_default_library", + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", "//shared:go_default_library", - "//shared/backuputil:go_default_library", "//shared/cmd:go_default_library", "//shared/debug:go_default_library", "//shared/event:go_default_library", @@ -41,8 +43,6 @@ go_library( "//shared/gateway:go_default_library", "//shared/params:go_default_library", "//shared/prereq:go_default_library", - "//shared/prometheus:go_default_library", - "//shared/tracing:go_default_library", "//shared/version:go_default_library", "//validator/accounts/iface:go_default_library", "//validator/accounts/wallet:go_default_library", diff --git a/validator/node/node.go b/validator/node/node.go index 3b367c586..542de6611 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -17,10 +17,12 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/cmd/validator/flags" + "github.com/prysmaticlabs/prysm/monitoring/backup" + "github.com/prysmaticlabs/prysm/monitoring/prometheus" + tracing2 "github.com/prysmaticlabs/prysm/monitoring/tracing" pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/shared" - "github.com/prysmaticlabs/prysm/shared/backuputil" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/debug" "github.com/prysmaticlabs/prysm/shared/event" @@ -29,8 +31,6 @@ import ( "github.com/prysmaticlabs/prysm/shared/gateway" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/prereq" - "github.com/prysmaticlabs/prysm/shared/prometheus" - "github.com/prysmaticlabs/prysm/shared/tracing" "github.com/prysmaticlabs/prysm/shared/version" accountsiface "github.com/prysmaticlabs/prysm/validator/accounts/iface" "github.com/prysmaticlabs/prysm/validator/accounts/wallet" @@ -64,7 +64,7 @@ type ValidatorClient struct { // NewValidatorClient creates a new instance of the Prysm validator client. func NewValidatorClient(cliCtx *cli.Context) (*ValidatorClient, error) { - if err := tracing.Setup( + if err := tracing2.Setup( "validator", // service name cliCtx.String(cmd.TracingProcessNameFlag.Name), cliCtx.String(cmd.TracingEndpointFlag.Name), @@ -370,7 +370,7 @@ func (c *ValidatorClient) registerPrometheusService(cliCtx *cli.Context) error { additionalHandlers, prometheus.Handler{ Path: "/db/backup", - Handler: backuputil.BackupHandler(c.db, cliCtx.String(cmd.BackupWebhookOutputDir.Name)), + Handler: backup.BackupHandler(c.db, cliCtx.String(cmd.BackupWebhookOutputDir.Name)), }, ) } diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index fcf5e0db4..e774e8cd1 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -16,6 +16,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/validator/rpc", visibility = ["//validator:__subpackages__"], deps = [ + "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", "//shared/bls:go_default_library", @@ -30,7 +31,6 @@ go_library( "//shared/promptutil:go_default_library", "//shared/rand:go_default_library", "//shared/timeutils:go_default_library", - "//shared/traceutil:go_default_library", "//shared/version:go_default_library", "//validator/accounts:go_default_library", "//validator/accounts/iface:go_default_library", diff --git a/validator/rpc/server.go b/validator/rpc/server.go index aeb4e4e91..4acbd7375 100644 --- a/validator/rpc/server.go +++ b/validator/rpc/server.go @@ -11,13 +11,13 @@ import ( recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "github.com/prysmaticlabs/prysm/monitoring/tracing" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/shared/event" "github.com/prysmaticlabs/prysm/shared/logutil" "github.com/prysmaticlabs/prysm/shared/rand" - "github.com/prysmaticlabs/prysm/shared/traceutil" "github.com/prysmaticlabs/prysm/validator/accounts/wallet" "github.com/prysmaticlabs/prysm/validator/client" "github.com/prysmaticlabs/prysm/validator/db" @@ -147,7 +147,7 @@ func (s *Server) Start() { grpc.StatsHandler(&ocgrpc.ServerHandler{}), grpc.UnaryInterceptor(middleware.ChainUnaryServer( recovery.UnaryServerInterceptor( - recovery.WithRecoveryHandlerContext(traceutil.RecoveryHandlerFunc), + recovery.WithRecoveryHandlerContext(tracing.RecoveryHandlerFunc), ), grpc_prometheus.UnaryServerInterceptor, grpc_opentracing.UnaryServerInterceptor(), diff --git a/validator/slashing-protection/local/standard-protection-format/BUILD.bazel b/validator/slashing-protection/local/standard-protection-format/BUILD.bazel index 69600196f..5df274068 100644 --- a/validator/slashing-protection/local/standard-protection-format/BUILD.bazel +++ b/validator/slashing-protection/local/standard-protection-format/BUILD.bazel @@ -11,10 +11,10 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/validator/slashing-protection/local/standard-protection-format", visibility = ["//validator:__subpackages__"], deps = [ + "//monitoring/progress:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//shared/bytesutil:go_default_library", "//shared/params:go_default_library", - "//shared/progressutil:go_default_library", "//shared/slashutil:go_default_library", "//validator/db:go_default_library", "//validator/db/kv:go_default_library", diff --git a/validator/slashing-protection/local/standard-protection-format/export.go b/validator/slashing-protection/local/standard-protection-format/export.go index c2da2a4c7..ae5dbb6c5 100644 --- a/validator/slashing-protection/local/standard-protection-format/export.go +++ b/validator/slashing-protection/local/standard-protection-format/export.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/monitoring/progress" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/progressutil" "github.com/prysmaticlabs/prysm/validator/db" "github.com/prysmaticlabs/prysm/validator/slashing-protection/local/standard-protection-format/format" ) @@ -41,7 +41,7 @@ func ExportStandardProtectionJSON(ctx context.Context, validatorDB db.Database) dataByPubKey := make(map[[48]byte]*format.ProtectionData) // Extract the signed proposals by public key. - progress := progressutil.InitializeProgressBar( + bar := progress.InitializeProgressBar( len(proposedPublicKeys), "Extracting signed blocks by validator public key", ) for _, pubKey := range proposedPublicKeys { @@ -58,13 +58,13 @@ func ExportStandardProtectionJSON(ctx context.Context, validatorDB db.Database) SignedBlocks: signedBlocks, SignedAttestations: nil, } - if err := progress.Add(1); err != nil { + if err := bar.Add(1); err != nil { return nil, err } } // Extract the signed attestations by public key. - progress = progressutil.InitializeProgressBar( + bar = progress.InitializeProgressBar( len(attestedPublicKeys), "Extracting signed attestations by validator public key", ) for _, pubKey := range attestedPublicKeys { @@ -85,7 +85,7 @@ func ExportStandardProtectionJSON(ctx context.Context, validatorDB db.Database) SignedAttestations: signedAttestations, } } - if err := progress.Add(1); err != nil { + if err := bar.Add(1); err != nil { return nil, err } }