diff --git a/beacon-chain/db/kv/archive.go b/beacon-chain/db/kv/archive.go index cfddf6c91..65f15b5ba 100644 --- a/beacon-chain/db/kv/archive.go +++ b/beacon-chain/db/kv/archive.go @@ -92,7 +92,7 @@ func (k *Store) ArchivedBalances(ctx context.Context, epoch uint64) ([]uint64, e if enc == nil { return nil } - target = unmarshalBalances(enc) + target = unmarshalBalances(ctx, enc) return nil }) return target, err @@ -103,7 +103,7 @@ func (k *Store) SaveArchivedBalances(ctx context.Context, epoch uint64, balances ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveArchivedBalances") defer span.End() buf := bytesutil.Uint64ToBytes(epoch) - enc := marshalBalances(balances) + enc := marshalBalances(ctx, balances) return k.db.Update(func(tx *bolt.Tx) error { bucket := tx.Bucket(archivedBalancesBucket) return bucket.Put(buf, enc) @@ -144,7 +144,10 @@ func (k *Store) SaveArchivedValidatorParticipation(ctx context.Context, epoch ui }) } -func marshalBalances(bals []uint64) []byte { +func marshalBalances(ctx context.Context, bals []uint64) []byte { + ctx, span := trace.StartSpan(ctx, "BeaconDB.marshalBalances") + defer span.End() + res := make([]byte, len(bals)*8) offset := 0 for i := 0; i < len(bals); i++ { @@ -154,7 +157,10 @@ func marshalBalances(bals []uint64) []byte { return res } -func unmarshalBalances(bals []byte) []uint64 { +func unmarshalBalances(ctx context.Context, bals []byte) []uint64 { + ctx, span := trace.StartSpan(ctx, "BeaconDB.unmarshalBalances") + defer span.End() + numItems := len(bals) / 8 res := make([]uint64, numItems) offset := 0 diff --git a/beacon-chain/db/kv/archived_point.go b/beacon-chain/db/kv/archived_point.go index b421349af..53bdfb134 100644 --- a/beacon-chain/db/kv/archived_point.go +++ b/beacon-chain/db/kv/archived_point.go @@ -22,7 +22,7 @@ func (k *Store) SaveArchivedPointRoot(ctx context.Context, blockRoot [32]byte, i // SaveLastArchivedIndex to the db. func (k *Store) SaveLastArchivedIndex(ctx context.Context, index uint64) error { - ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveHeadBlockRoot") + ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveLastArchivedIndex") defer span.End() return k.db.Update(func(tx *bolt.Tx) error { bucket := tx.Bucket(archivedIndexRootBucket) @@ -72,7 +72,7 @@ func (k *Store) LastArchivedIndexRoot(ctx context.Context) [32]byte { // ArchivedPointRoot returns the block root of an archived point from the DB. // This is essential for cold state management and to restore a cold state. func (k *Store) ArchivedPointRoot(ctx context.Context, index uint64) [32]byte { - ctx, span := trace.StartSpan(ctx, "BeaconDB.ArchivePointRoot") + ctx, span := trace.StartSpan(ctx, "BeaconDB.ArchivedPointRoot") defer span.End() var blockRoot []byte