Skip to content

Commit

Permalink
Revert "Regen historical states for new-state-mgmt compatibility (#…
Browse files Browse the repository at this point in the history
…5261)"

This reverts commit df9a534.
  • Loading branch information
terencechain committed Apr 1, 2020
1 parent f88deed commit 05d3085
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 277 deletions.
4 changes: 0 additions & 4 deletions beacon-chain/blockchain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,6 @@ func (s *Service) pruneGarbageState(ctx context.Context, slot uint64) error {
return err
}

if err := s.beaconDB.SaveLastArchivedIndex(ctx, 0); err != nil {
return err
}

return nil
}

Expand Down
5 changes: 1 addition & 4 deletions beacon-chain/db/kv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ go_library(
"attestations.go",
"backup.go",
"blocks.go",
"check_historical_state.go",
"check_state.go",
"checkpoint.go",
"deposit_contract.go",
"encoding.go",
"finalized_block_roots.go",
"kv.go",
"operations.go",
"powchain.go",
"regen_historical_states.go",
"schema.go",
"slashings.go",
"state.go",
Expand All @@ -29,15 +28,13 @@ go_library(
deps = [
"//beacon-chain/cache:go_default_library",
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/state:go_default_library",
"//beacon-chain/db/filters:go_default_library",
"//beacon-chain/db/iface:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/stateutil:go_default_library",
"//proto/beacon/db:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/cmd:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/params:go_default_library",
"//shared/sliceutil:go_default_library",
Expand Down
16 changes: 0 additions & 16 deletions beacon-chain/db/kv/archived_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kv

import (
"context"
"encoding/binary"

"github.com/prysmaticlabs/prysm/shared/bytesutil"
bolt "go.etcd.io/bbolt"
Expand Down Expand Up @@ -30,21 +29,6 @@ func (k *Store) SaveLastArchivedIndex(ctx context.Context, index uint64) error {
})
}

// LastArchivedIndex from the db.
func (k *Store) LastArchivedIndex(ctx context.Context) (uint64, error) {
ctx, span := trace.StartSpan(ctx, "BeaconDB.LastArchivedIndex")
defer span.End()
var index uint64
err := k.db.Update(func(tx *bolt.Tx) error {
bucket := tx.Bucket(archivedIndexRootBucket)
b := bucket.Get(lastArchivedIndexKey)
index = binary.LittleEndian.Uint64(b)
return nil
})

return index, err
}

// LastArchivedIndexRoot from the db.
func (k *Store) LastArchivedIndexRoot(ctx context.Context) [32]byte {
ctx, span := trace.StartSpan(ctx, "BeaconDB.LastArchivedIndexRoot")
Expand Down
55 changes: 0 additions & 55 deletions beacon-chain/db/kv/check_historical_state.go

This file was deleted.

33 changes: 33 additions & 0 deletions beacon-chain/db/kv/check_state.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package kv

import (
"errors"

"github.com/prysmaticlabs/prysm/shared/featureconfig"
bolt "go.etcd.io/bbolt"
)

var historicalStateDeletedKey = []byte("historical-states-deleted")

func (kv *Store) ensureNewStateServiceCompatible() error {
if !featureconfig.Get().NewStateMgmt {
return kv.db.Update(func(tx *bolt.Tx) error {
bkt := tx.Bucket(newStateServiceCompatibleBucket)
return bkt.Put(historicalStateDeletedKey, []byte{0x01})
})
}

var historicalStateDeleted bool
kv.db.View(func(tx *bolt.Tx) error {
bkt := tx.Bucket(newStateServiceCompatibleBucket)
v := bkt.Get(historicalStateDeletedKey)
historicalStateDeleted = len(v) == 1 && v[0] == 0x01
return nil
})

if historicalStateDeleted {
return errors.New("historical states were pruned in db, do not run with flag --new-state-mgmt")
}

return nil
}
3 changes: 1 addition & 2 deletions beacon-chain/db/kv/kv.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kv

import (
"context"
"os"
"path"
"sync"
Expand Down Expand Up @@ -121,7 +120,7 @@ func NewKVStore(dirPath string, stateSummaryCache *cache.StateSummaryCache) (*St
return nil, err
}

if err := kv.ensureNewStateServiceCompatible(context.Background()); err != nil {
if err := kv.ensureNewStateServiceCompatible(); err != nil {
return nil, err
}

Expand Down
194 changes: 0 additions & 194 deletions beacon-chain/db/kv/regen_historical_states.go

This file was deleted.

2 changes: 0 additions & 2 deletions shared/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ type BeaconChainConfig struct {
EmptySignature [96]byte // EmptySignature is used to represent a zeroed out BLS Signature.
DefaultPageSize int // DefaultPageSize defines the default page size for RPC server request.
MaxPeersToSync int // MaxPeersToSync describes the limit for number of peers in round robin sync.
SlotsPerArchivedPoint uint64 // SlotsPerArchivedPoint defines the number of slots per one archived point.

// Slasher constants.
WeakSubjectivityPeriod uint64 // WeakSubjectivityPeriod defines the time period expressed in number of epochs were proof of stake network should validate block headers and attestations for slashable events.
Expand Down Expand Up @@ -201,7 +200,6 @@ var defaultBeaconConfig = &BeaconChainConfig{
EmptySignature: [96]byte{},
DefaultPageSize: 250,
MaxPeersToSync: 15,
SlotsPerArchivedPoint: 256,

// Slasher related values.
WeakSubjectivityPeriod: 54000,
Expand Down

0 comments on commit 05d3085

Please sign in to comment.