mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
QSP58, QSP59 - Fix DB spans (#6352)
* Fix spans * Merge refs/heads/master into qsp58-59
This commit is contained in:
parent
368af7e53f
commit
5c8da7a1c4
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user