mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Move state pkg to stateV0 pkg (#8620)
* Move state pkg to stateV0 pkg
* Build.bazel
* Remove unused RootsArrayHashTreeRoot
* Revert "Remove unused RootsArrayHashTreeRoot"
This reverts commit bf0bda30d1.
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -42,8 +42,8 @@ go_library(
|
||||
"//beacon-chain/operations/voluntaryexits:go_default_library",
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/powchain:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -75,7 +75,7 @@ func (s *Service) FinalizedCheckpt() *ethpb.Checkpoint {
|
||||
return ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]}
|
||||
}
|
||||
|
||||
return state.CopyCheckpoint(s.finalizedCheckpt)
|
||||
return stateV0.CopyCheckpoint(s.finalizedCheckpt)
|
||||
}
|
||||
|
||||
// CurrentJustifiedCheckpt returns the current justified checkpoint from head state.
|
||||
@@ -84,7 +84,7 @@ func (s *Service) CurrentJustifiedCheckpt() *ethpb.Checkpoint {
|
||||
return ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]}
|
||||
}
|
||||
|
||||
return state.CopyCheckpoint(s.justifiedCheckpt)
|
||||
return stateV0.CopyCheckpoint(s.justifiedCheckpt)
|
||||
}
|
||||
|
||||
// PreviousJustifiedCheckpt returns the previous justified checkpoint from head state.
|
||||
@@ -93,7 +93,7 @@ func (s *Service) PreviousJustifiedCheckpt() *ethpb.Checkpoint {
|
||||
return ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]}
|
||||
}
|
||||
|
||||
return state.CopyCheckpoint(s.prevJustifiedCheckpt)
|
||||
return stateV0.CopyCheckpoint(s.prevJustifiedCheckpt)
|
||||
}
|
||||
|
||||
// HeadSlot returns the slot of the head of the chain.
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -104,7 +104,7 @@ func TestPrevJustifiedCheckpt_GenesisRootOk(t *testing.T) {
|
||||
|
||||
func TestHeadSlot_CanRetrieve(t *testing.T) {
|
||||
c := &Service{}
|
||||
s, err := state.InitializeFromProto(&pb.BeaconState{})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{})
|
||||
require.NoError(t, err)
|
||||
c.head = &head{slot: 100, state: s}
|
||||
assert.Equal(t, types.Slot(100), c.HeadSlot())
|
||||
@@ -136,7 +136,7 @@ func TestHeadRoot_UseDB(t *testing.T) {
|
||||
func TestHeadBlock_CanRetrieve(t *testing.T) {
|
||||
b := testutil.NewBeaconBlock()
|
||||
b.Block.Slot = 1
|
||||
s, err := state.InitializeFromProto(&pb.BeaconState{})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{block: b, state: s}
|
||||
@@ -147,7 +147,7 @@ func TestHeadBlock_CanRetrieve(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHeadState_CanRetrieve(t *testing.T) {
|
||||
s, err := state.InitializeFromProto(&pb.BeaconState{Slot: 2, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: 2, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{state: s}
|
||||
@@ -164,7 +164,7 @@ func TestGenesisTime_CanRetrieve(t *testing.T) {
|
||||
|
||||
func TestCurrentFork_CanRetrieve(t *testing.T) {
|
||||
f := &pb.Fork{Epoch: 999}
|
||||
s, err := state.InitializeFromProto(&pb.BeaconState{Fork: f})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{Fork: f})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{state: s}
|
||||
@@ -189,7 +189,7 @@ func TestGenesisValidatorRoot_CanRetrieve(t *testing.T) {
|
||||
c := &Service{}
|
||||
assert.Equal(t, [32]byte{}, c.GenesisValidatorRoot(), "Did not get correct genesis validator root")
|
||||
|
||||
s, err := state.InitializeFromProto(&pb.BeaconState{GenesisValidatorsRoot: []byte{'a'}})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{GenesisValidatorsRoot: []byte{'a'}})
|
||||
require.NoError(t, err)
|
||||
c.head = &head{state: s}
|
||||
assert.Equal(t, [32]byte{'a'}, c.GenesisValidatorRoot(), "Did not get correct genesis validator root")
|
||||
@@ -203,7 +203,7 @@ func TestHeadETH1Data_Nil(t *testing.T) {
|
||||
|
||||
func TestHeadETH1Data_CanRetrieve(t *testing.T) {
|
||||
d := ðpb.Eth1Data{DepositCount: 999}
|
||||
s, err := state.InitializeFromProto(&pb.BeaconState{Eth1Data: d})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{Eth1Data: d})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{state: s}
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -161,7 +161,7 @@ func (s *Service) saveHeadNoDB(ctx context.Context, b *ethpb.SignedBeaconBlock,
|
||||
return nil
|
||||
}
|
||||
|
||||
s.setHeadInitialSync(r, stateTrie.CopySignedBeaconBlock(b), hs)
|
||||
s.setHeadInitialSync(r, stateV0.CopySignedBeaconBlock(b), hs)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ func (s *Service) setHead(root [32]byte, block *ethpb.SignedBeaconBlock, state i
|
||||
s.head = &head{
|
||||
slot: block.Block.Slot,
|
||||
root: root,
|
||||
block: stateTrie.CopySignedBeaconBlock(block),
|
||||
block: stateV0.CopySignedBeaconBlock(block),
|
||||
state: state.Copy(),
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func (s *Service) setHeadInitialSync(root [32]byte, block *ethpb.SignedBeaconBlo
|
||||
s.head = &head{
|
||||
slot: block.Block.Slot,
|
||||
root: root,
|
||||
block: stateTrie.CopySignedBeaconBlock(block),
|
||||
block: stateV0.CopySignedBeaconBlock(block),
|
||||
state: state,
|
||||
}
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func (s *Service) headRoot() [32]byte {
|
||||
// It does a full copy on head block for immutability.
|
||||
// This is a lock free version.
|
||||
func (s *Service) headBlock() *ethpb.SignedBeaconBlock {
|
||||
return stateTrie.CopySignedBeaconBlock(s.head.block)
|
||||
return stateV0.CopySignedBeaconBlock(s.head.block)
|
||||
}
|
||||
|
||||
// This returns the head state.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -46,7 +46,7 @@ func (s *Service) onAttestation(ctx context.Context, a *ethpb.Attestation) error
|
||||
if err := helpers.ValidateSlotTargetEpoch(a.Data); err != nil {
|
||||
return err
|
||||
}
|
||||
tgt := stateTrie.CopyCheckpoint(a.Data.Target)
|
||||
tgt := stateV0.CopyCheckpoint(a.Data.Target)
|
||||
|
||||
// Note that target root check is ignored here because it was performed in sync's validation pipeline:
|
||||
// validate_aggregate_proof.go and validate_beacon_attestation.go
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
@@ -251,7 +251,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) {
|
||||
service, err := NewService(ctx, cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
s, err := stateTrie.InitializeFromProto(&pb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
require.NoError(t, err)
|
||||
|
||||
genesisStateRoot := [32]byte{}
|
||||
@@ -303,7 +303,7 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) {
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
|
||||
b.Block.ParentRoot = gRoot[:]
|
||||
s, err := stateTrie.InitializeFromProto(&pb.BeaconState{Slot: 1})
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: 1})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: 1, Root: gRoot[:]}))
|
||||
require.NoError(t, service.cfg.StateGen.SaveState(ctx, gRoot, s))
|
||||
@@ -899,7 +899,7 @@ func TestHandleEpochBoundary_BadMetrics(t *testing.T) {
|
||||
s, err := testutil.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, s.SetSlot(1))
|
||||
service.head = &head{state: (*stateTrie.BeaconState)(nil)}
|
||||
service.head = &head{state: (*stateV0.BeaconState)(nil)}
|
||||
|
||||
require.ErrorContains(t, "failed to initialize precompute: nil inner state", service.handleEpochBoundary(ctx, s))
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
|
||||
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
"github.com/prysmaticlabs/prysm/shared/traceutil"
|
||||
@@ -35,7 +35,7 @@ func (s *Service) ReceiveBlock(ctx context.Context, block *ethpb.SignedBeaconBlo
|
||||
ctx, span := trace.StartSpan(ctx, "blockChain.ReceiveBlock")
|
||||
defer span.End()
|
||||
receivedTime := timeutils.Now()
|
||||
blockCopy := stateTrie.CopySignedBeaconBlock(block)
|
||||
blockCopy := stateV0.CopySignedBeaconBlock(block)
|
||||
|
||||
// Apply state transition on the new block.
|
||||
if err := s.onBlock(ctx, blockCopy, blockRoot); err != nil {
|
||||
@@ -100,7 +100,7 @@ func (s *Service) ReceiveBlockBatch(ctx context.Context, blocks []*ethpb.SignedB
|
||||
}
|
||||
|
||||
for i, b := range blocks {
|
||||
blockCopy := stateTrie.CopySignedBeaconBlock(b)
|
||||
blockCopy := stateV0.CopySignedBeaconBlock(b)
|
||||
if err = s.handleBlockAfterBatchVerify(ctx, blockCopy, blkRoots[i], fCheckpoints[i], jCheckpoints[i]); err != nil {
|
||||
traceutil.AnnotateError(span, err)
|
||||
return err
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
@@ -167,14 +167,14 @@ func (s *Service) Start() {
|
||||
}
|
||||
|
||||
// Resume fork choice.
|
||||
s.justifiedCheckpt = stateTrie.CopyCheckpoint(justifiedCheckpoint)
|
||||
s.justifiedCheckpt = stateV0.CopyCheckpoint(justifiedCheckpoint)
|
||||
if err := s.cacheJustifiedStateBalances(s.ctx, s.ensureRootNotZeros(bytesutil.ToBytes32(s.justifiedCheckpt.Root))); err != nil {
|
||||
log.Fatalf("Could not cache justified state balances: %v", err)
|
||||
}
|
||||
s.prevJustifiedCheckpt = stateTrie.CopyCheckpoint(justifiedCheckpoint)
|
||||
s.bestJustifiedCheckpt = stateTrie.CopyCheckpoint(justifiedCheckpoint)
|
||||
s.finalizedCheckpt = stateTrie.CopyCheckpoint(finalizedCheckpoint)
|
||||
s.prevFinalizedCheckpt = stateTrie.CopyCheckpoint(finalizedCheckpoint)
|
||||
s.prevJustifiedCheckpt = stateV0.CopyCheckpoint(justifiedCheckpoint)
|
||||
s.bestJustifiedCheckpt = stateV0.CopyCheckpoint(justifiedCheckpoint)
|
||||
s.finalizedCheckpt = stateV0.CopyCheckpoint(finalizedCheckpoint)
|
||||
s.prevFinalizedCheckpt = stateV0.CopyCheckpoint(finalizedCheckpoint)
|
||||
s.resumeForkChoice(justifiedCheckpoint, finalizedCheckpoint)
|
||||
|
||||
ss, err := helpers.StartSlot(s.finalizedCheckpt.Epoch)
|
||||
@@ -372,14 +372,14 @@ func (s *Service) saveGenesisData(ctx context.Context, genesisState iface.Beacon
|
||||
// Finalized checkpoint at genesis is a zero hash.
|
||||
genesisCheckpoint := genesisState.FinalizedCheckpoint()
|
||||
|
||||
s.justifiedCheckpt = stateTrie.CopyCheckpoint(genesisCheckpoint)
|
||||
s.justifiedCheckpt = stateV0.CopyCheckpoint(genesisCheckpoint)
|
||||
if err := s.cacheJustifiedStateBalances(ctx, genesisBlkRoot); err != nil {
|
||||
return err
|
||||
}
|
||||
s.prevJustifiedCheckpt = stateTrie.CopyCheckpoint(genesisCheckpoint)
|
||||
s.bestJustifiedCheckpt = stateTrie.CopyCheckpoint(genesisCheckpoint)
|
||||
s.finalizedCheckpt = stateTrie.CopyCheckpoint(genesisCheckpoint)
|
||||
s.prevFinalizedCheckpt = stateTrie.CopyCheckpoint(genesisCheckpoint)
|
||||
s.prevJustifiedCheckpt = stateV0.CopyCheckpoint(genesisCheckpoint)
|
||||
s.bestJustifiedCheckpt = stateV0.CopyCheckpoint(genesisCheckpoint)
|
||||
s.finalizedCheckpt = stateV0.CopyCheckpoint(genesisCheckpoint)
|
||||
s.prevFinalizedCheckpt = stateV0.CopyCheckpoint(genesisCheckpoint)
|
||||
|
||||
if err := s.cfg.ForkChoiceStore.ProcessBlock(ctx,
|
||||
genesisBlk.Block.Slot,
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
||||
protodb "github.com/prysmaticlabs/prysm/proto/beacon/db"
|
||||
@@ -70,7 +70,7 @@ func setupBeaconChain(t *testing.T, beaconDB db.Database) *Service {
|
||||
var web3Service *powchain.Service
|
||||
var err error
|
||||
bState, _ := testutil.DeterministicGenesisState(t, 10)
|
||||
pbState, err := beaconstate.ProtobufBeaconState(bState.InnerStateUnsafe())
|
||||
pbState, err := stateV0.ProtobufBeaconState(bState.InnerStateUnsafe())
|
||||
require.NoError(t, err)
|
||||
err = beaconDB.SavePowchainData(ctx, &protodb.ETH1ChainData{
|
||||
BeaconState: pbState,
|
||||
@@ -506,7 +506,7 @@ func BenchmarkHasBlockForkChoiceStore(b *testing.B) {
|
||||
r, err := block.Block.HashTreeRoot()
|
||||
require.NoError(b, err)
|
||||
bs := &pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}}
|
||||
beaconState, err := beaconstate.InitializeFromProto(bs)
|
||||
beaconState, err := stateV0.InitializeFromProto(bs)
|
||||
require.NoError(b, err)
|
||||
require.NoError(b, s.insertBlockAndAttestationsToForkChoiceStore(ctx, block.Block, r, beaconState))
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ go_library(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/db:go_default_library",
|
||||
"//beacon-chain/forkchoice/protoarray:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/event:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/event"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -150,7 +150,7 @@ func (mon *MockOperationNotifier) OperationFeed() *event.Feed {
|
||||
// ReceiveBlockInitialSync mocks ReceiveBlockInitialSync method in chain service.
|
||||
func (s *ChainService) ReceiveBlockInitialSync(ctx context.Context, block *ethpb.SignedBeaconBlock, _ [32]byte) error {
|
||||
if s.State == nil {
|
||||
s.State = &stateTrie.BeaconState{}
|
||||
s.State = &stateV0.BeaconState{}
|
||||
}
|
||||
if !bytes.Equal(s.Root, block.Block.ParentRoot) {
|
||||
return errors.Errorf("wanted %#x but got %#x", s.Root, block.Block.ParentRoot)
|
||||
@@ -177,7 +177,7 @@ func (s *ChainService) ReceiveBlockInitialSync(ctx context.Context, block *ethpb
|
||||
// ReceiveBlockBatch processes blocks in batches from initial-sync.
|
||||
func (s *ChainService) ReceiveBlockBatch(ctx context.Context, blks []*ethpb.SignedBeaconBlock, _ [][32]byte) error {
|
||||
if s.State == nil {
|
||||
s.State = &stateTrie.BeaconState{}
|
||||
s.State = &stateV0.BeaconState{}
|
||||
}
|
||||
for _, block := range blks {
|
||||
if !bytes.Equal(s.Root, block.Block.ParentRoot) {
|
||||
@@ -206,7 +206,7 @@ func (s *ChainService) ReceiveBlockBatch(ctx context.Context, blks []*ethpb.Sign
|
||||
// ReceiveBlock mocks ReceiveBlock method in chain service.
|
||||
func (s *ChainService) ReceiveBlock(ctx context.Context, block *ethpb.SignedBeaconBlock, _ [32]byte) error {
|
||||
if s.State == nil {
|
||||
s.State = &stateTrie.BeaconState{}
|
||||
s.State = &stateV0.BeaconState{}
|
||||
}
|
||||
if !bytes.Equal(s.Root, block.Block.ParentRoot) {
|
||||
return errors.Errorf("wanted %#x but got %#x", s.Root, block.Block.ParentRoot)
|
||||
|
||||
4
beacon-chain/cache/BUILD.bazel
vendored
4
beacon-chain/cache/BUILD.bazel
vendored
@@ -31,8 +31,8 @@ go_library(
|
||||
"//tools:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//shared/hashutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/sliceutil:go_default_library",
|
||||
@@ -62,8 +62,8 @@ go_test(
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
4
beacon-chain/cache/attestation_data.go
vendored
4
beacon-chain/cache/attestation_data.go
vendored
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
@@ -98,7 +98,7 @@ func (c *AttestationCache) Get(ctx context.Context, req *ethpb.AttestationDataRe
|
||||
|
||||
if exists && item != nil && item.(*attestationReqResWrapper).res != nil {
|
||||
attestationCacheHit.Inc()
|
||||
return state.CopyAttestationData(item.(*attestationReqResWrapper).res), nil
|
||||
return stateV0.CopyAttestationData(item.(*attestationReqResWrapper).res), nil
|
||||
}
|
||||
attestationCacheMiss.Inc()
|
||||
return nil, nil
|
||||
|
||||
12
beacon-chain/cache/checkpoint_state_test.go
vendored
12
beacon-chain/cache/checkpoint_state_test.go
vendored
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -19,7 +19,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
|
||||
cache := NewCheckpointStateCache()
|
||||
|
||||
cp1 := ðpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'A'}, 32)}
|
||||
st, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
st, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:],
|
||||
Slot: 64,
|
||||
})
|
||||
@@ -34,16 +34,16 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
|
||||
state, err = cache.StateByCheckpoint(cp1)
|
||||
require.NoError(t, err)
|
||||
|
||||
pbState1, err := stateTrie.ProtobufBeaconState(state.InnerStateUnsafe())
|
||||
pbState1, err := stateV0.ProtobufBeaconState(state.InnerStateUnsafe())
|
||||
require.NoError(t, err)
|
||||
pbState2, err := stateTrie.ProtobufBeaconState(st.InnerStateUnsafe())
|
||||
pbState2, err := stateV0.ProtobufBeaconState(st.InnerStateUnsafe())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState1, pbState2) {
|
||||
t.Error("incorrectly cached state")
|
||||
}
|
||||
|
||||
cp2 := ðpb.Checkpoint{Epoch: 2, Root: bytesutil.PadTo([]byte{'B'}, 32)}
|
||||
st2, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
st2, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 128,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -60,7 +60,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
|
||||
|
||||
func TestCheckpointStateCache_MaxSize(t *testing.T) {
|
||||
c := NewCheckpointStateCache()
|
||||
st, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
st, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
4
beacon-chain/cache/skip_slot_cache_test.go
vendored
4
beacon-chain/cache/skip_slot_cache_test.go
vendored
@@ -5,8 +5,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -23,7 +23,7 @@ func TestSkipSlotCache_RoundTrip(t *testing.T) {
|
||||
|
||||
require.NoError(t, c.MarkInProgress(r))
|
||||
|
||||
state, err = stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
state, err = stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 10,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -26,8 +26,8 @@ go_library(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
@@ -72,8 +72,8 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/aggregation:go_default_library",
|
||||
"//shared/aggregation/attestations:go_default_library",
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -37,7 +37,7 @@ func TestProcessAttestationNoVerifySignature_BeaconFuzzIssue78(t *testing.T) {
|
||||
if err := spb.UnmarshalSSZ(stateData); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
st, err := state.InitializeFromProtoUnsafe(spb)
|
||||
st, err := stateV0.InitializeFromProtoUnsafe(spb)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/aggregation"
|
||||
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
|
||||
@@ -466,7 +466,7 @@ func TestConvertToIndexed_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 5,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -524,7 +524,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 5,
|
||||
Validators: validators,
|
||||
Fork: &pb.Fork{
|
||||
@@ -611,7 +611,7 @@ func TestValidateIndexedAttestation_AboveMaxLength(t *testing.T) {
|
||||
}
|
||||
|
||||
want := "validator indices count exceeds MAX_VALIDATORS_PER_COMMITTEE"
|
||||
err := blocks.VerifyIndexedAttestation(context.Background(), &stateTrie.BeaconState{}, indexedAtt1)
|
||||
err := blocks.VerifyIndexedAttestation(context.Background(), &stateV0.BeaconState{}, indexedAtt1)
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -46,7 +46,7 @@ func TestProcessAttesterSlashings_DataNotSlashable(t *testing.T) {
|
||||
var registry []*ethpb.Validator
|
||||
currentSlot := types.Slot(0)
|
||||
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: currentSlot,
|
||||
})
|
||||
@@ -65,7 +65,7 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T)
|
||||
var registry []*ethpb.Validator
|
||||
currentSlot := types.Slot(0)
|
||||
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: currentSlot,
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
fuzz "github.com/google/gofuzz"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -22,7 +22,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(att)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
_, err = ProcessAttestationNoVerifySignature(ctx, s, att)
|
||||
_ = err
|
||||
@@ -38,7 +38,7 @@ func TestFuzzProcessBlockHeader_10000(t *testing.T) {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(block)
|
||||
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
_, err = ProcessBlockHeader(context.Background(), s, block)
|
||||
_ = err
|
||||
@@ -72,7 +72,7 @@ func TestFuzzverifyDepositDataSigningRoot_10000(t *testing.T) {
|
||||
func TestFuzzProcessEth1DataInBlock_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
b := ð.SignedBeaconBlock{}
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
@@ -103,7 +103,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) {
|
||||
for i := 0; i < 100000; i++ {
|
||||
fuzzer.Fuzz(eth1data)
|
||||
fuzzer.Fuzz(&stateVotes)
|
||||
s, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Eth1DataVotes: stateVotes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -121,7 +121,7 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(block)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
_, err = ProcessBlockHeaderNoVerify(s, block)
|
||||
_ = err
|
||||
@@ -136,7 +136,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessRandao(context.Background(), s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -153,7 +153,7 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(blockBody)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessRandaoNoVerify(s, blockBody)
|
||||
if err != nil && r != nil {
|
||||
@@ -170,7 +170,7 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessProposerSlashings(ctx, s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -186,7 +186,7 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(proposerSlashing)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
err = VerifyProposerSlashing(s, proposerSlashing)
|
||||
_ = err
|
||||
@@ -201,7 +201,7 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessAttesterSlashings(ctx, s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -218,7 +218,7 @@ func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(attesterSlashing)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
err = VerifyAttesterSlashing(ctx, s, attesterSlashing)
|
||||
_ = err
|
||||
@@ -255,7 +255,7 @@ func TestFuzzProcessAttestations_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessAttestations(ctx, s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -272,7 +272,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessAttestationsNoVerifySignature(ctx, s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -289,7 +289,7 @@ func TestFuzzProcessAttestation_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(attestation)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessAttestation(ctx, s, attestation)
|
||||
if err != nil && r != nil {
|
||||
@@ -306,7 +306,7 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(idxAttestation)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
err = VerifyIndexedAttestation(ctx, s, idxAttestation)
|
||||
_ = err
|
||||
@@ -321,7 +321,7 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(attestation)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
err = VerifyAttestationSignature(ctx, s, attestation)
|
||||
_ = err
|
||||
@@ -336,7 +336,7 @@ func TestFuzzProcessDeposits_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessDeposits(ctx, s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -354,7 +354,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(deposit)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessPreGenesisDeposits(ctx, s, []*eth.Deposit{deposit})
|
||||
if err != nil && r != nil {
|
||||
@@ -371,7 +371,7 @@ func TestFuzzProcessDeposit_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(deposit)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessDeposit(s, deposit, true)
|
||||
if err != nil && r != nil {
|
||||
@@ -387,7 +387,7 @@ func TestFuzzverifyDeposit_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(deposit)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
err = verifyDeposit(s, deposit)
|
||||
_ = err
|
||||
@@ -402,7 +402,7 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessVoluntaryExits(ctx, s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -418,7 +418,7 @@ func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) {
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
fuzzer.Fuzz(b)
|
||||
s, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
r, err := ProcessVoluntaryExits(context.Background(), s, b)
|
||||
if err != nil && r != nil {
|
||||
@@ -430,7 +430,7 @@ func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) {
|
||||
func TestFuzzVerifyExit_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
ve := ð.SignedVoluntaryExit{}
|
||||
val := stateTrie.ReadOnlyValidator{}
|
||||
val := stateV0.ReadOnlyValidator{}
|
||||
fork := &pb.Fork{}
|
||||
var slot types.Slot
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -40,7 +40,7 @@ func TestProcessDeposits_SameValidatorMultipleDepositsSameBlock(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
@@ -80,7 +80,7 @@ func TestProcessDeposits_MerkleBranchFailsVerification(t *testing.T) {
|
||||
Deposits: []*ethpb.Deposit{deposit},
|
||||
},
|
||||
}
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
DepositRoot: []byte{0},
|
||||
BlockHash: []byte{1},
|
||||
@@ -111,7 +111,7 @@ func TestProcessDeposits_AddsNewValidatorDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
@@ -174,7 +174,7 @@ func TestProcessDeposits_RepeatedDeposit_IncreasesValidatorBalance(t *testing.T)
|
||||
}
|
||||
balances := []uint64{0, 50}
|
||||
root := depositTrie.Root()
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
@@ -202,7 +202,7 @@ func TestProcessDeposit_AddsNewValidatorDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
@@ -244,7 +244,7 @@ func TestProcessDeposit_SkipsInvalidDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
@@ -300,7 +300,7 @@ func TestPreGenesisDeposits_SkipInvalidDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"errors"
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
@@ -62,7 +62,7 @@ func AreEth1DataEqual(a, b *ethpb.Eth1Data) bool {
|
||||
// votes to see if they match the eth1data.
|
||||
func Eth1DataHasEnoughSupport(beaconState iface.ReadOnlyBeaconState, data *ethpb.Eth1Data) (bool, error) {
|
||||
voteCount := uint64(0)
|
||||
data = stateTrie.CopyETH1Data(data)
|
||||
data = stateV0.CopyETH1Data(data)
|
||||
|
||||
for _, vote := range beaconState.Eth1DataVotes() {
|
||||
if AreEth1DataEqual(vote, data) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -70,7 +70,7 @@ func TestEth1DataHasEnoughSupport(t *testing.T) {
|
||||
c.EpochsPerEth1VotingPeriod = tt.votingPeriodLength
|
||||
params.OverrideBeaconConfig(c)
|
||||
|
||||
s, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Eth1DataVotes: tt.stateVotes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -160,7 +160,7 @@ func TestAreEth1DataEqual(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessEth1Data_SetsCorrectly(t *testing.T) {
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -180,7 +180,7 @@ func TestProcessEth1Data_SetsCorrectly(t *testing.T) {
|
||||
for i := uint64(0); i < period; i++ {
|
||||
processedState, err := blocks.ProcessEth1DataInBlock(context.Background(), beaconState, b)
|
||||
require.NoError(t, err)
|
||||
beaconState, ok = processedState.(*beaconstate.BeaconState)
|
||||
beaconState, ok = processedState.(*stateV0.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ func TestProcessEth1Data_SetsCorrectly(t *testing.T) {
|
||||
if len(newETH1DataVotes) <= 1 {
|
||||
t.Error("Expected new ETH1 data votes to have length > 1")
|
||||
}
|
||||
if !proto.Equal(beaconState.Eth1Data(), beaconstate.CopyETH1Data(b.Block.Body.Eth1Data)) {
|
||||
if !proto.Equal(beaconState.Eth1Data(), stateV0.CopyETH1Data(b.Block.Body.Eth1Data)) {
|
||||
t.Errorf(
|
||||
"Expected latest eth1 data to have been set to %v, received %v",
|
||||
b.Block.Body.Eth1Data,
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -31,7 +31,7 @@ func TestProcessVoluntaryExits_NotActiveLongEnoughToExit(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
},
|
||||
}
|
||||
state, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: 10,
|
||||
})
|
||||
@@ -61,7 +61,7 @@ func TestProcessVoluntaryExits_ExitAlreadySubmitted(t *testing.T) {
|
||||
ExitEpoch: 10,
|
||||
},
|
||||
}
|
||||
state, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: 0,
|
||||
})
|
||||
@@ -93,7 +93,7 @@ func TestProcessVoluntaryExits_AppliesCorrectStatus(t *testing.T) {
|
||||
ActivationEpoch: 0,
|
||||
},
|
||||
}
|
||||
state, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Fork: &pb.Fork{
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
@@ -24,7 +24,7 @@ func TestVerifyProposerSlashing_BeaconFuzzIssue91(t *testing.T) {
|
||||
err = rawState.UnmarshalSSZ(file)
|
||||
require.NoError(t, err)
|
||||
|
||||
st, err := stateTrie.InitializeFromProtoUnsafe(rawState)
|
||||
st, err := stateV0.InitializeFromProtoUnsafe(rawState)
|
||||
require.NoError(t, err)
|
||||
|
||||
file, err = ioutil.ReadFile("testdata/beaconfuzz_91_proposer_slashing.ssz")
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -117,7 +117,7 @@ func TestProcessProposerSlashings_ValidatorNotSlashable(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: currentSlot,
|
||||
})
|
||||
|
||||
@@ -36,8 +36,8 @@ go_test(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/core/state/stateutils:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/params/spectest:go_default_library",
|
||||
@@ -72,8 +72,8 @@ go_test(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/core/state/stateutils:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/params/spectest:go_default_library",
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params/spectest"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -33,7 +33,7 @@ func runBlockHeaderTest(t *testing.T, config string) {
|
||||
require.NoError(t, err)
|
||||
preBeaconStateBase := &pb.BeaconState{}
|
||||
require.NoError(t, preBeaconStateBase.UnmarshalSSZ(preBeaconStateFile), "Failed to unmarshal")
|
||||
preBeaconState, err := stateTrie.InitializeFromProto(preBeaconStateBase)
|
||||
preBeaconState, err := stateV0.InitializeFromProto(preBeaconStateBase)
|
||||
require.NoError(t, err)
|
||||
|
||||
// If the post.ssz is not present, it means the test should fail on our end.
|
||||
@@ -55,7 +55,7 @@ func runBlockHeaderTest(t *testing.T, config string) {
|
||||
|
||||
postBeaconState := &pb.BeaconState{}
|
||||
require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateFile), "Failed to unmarshal")
|
||||
pbState, err := stateTrie.ProtobufBeaconState(beaconState.CloneInnerState())
|
||||
pbState, err := stateV0.ProtobufBeaconState(beaconState.CloneInnerState())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
diff, _ := messagediff.PrettyDiff(beaconState.CloneInnerState(), postBeaconState)
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params/spectest"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -39,7 +39,7 @@ func runBlockProcessingTest(t *testing.T, config string) {
|
||||
require.NoError(t, err)
|
||||
beaconStateBase := &pb.BeaconState{}
|
||||
require.NoError(t, beaconStateBase.UnmarshalSSZ(preBeaconStateFile), "Failed to unmarshal")
|
||||
beaconState, err := stateTrie.InitializeFromProto(beaconStateBase)
|
||||
beaconState, err := stateV0.InitializeFromProto(beaconStateBase)
|
||||
require.NoError(t, err)
|
||||
|
||||
file, err := testutil.BazelFileBytes(testsFolderPath, folder.Name(), "meta.yaml")
|
||||
@@ -61,7 +61,7 @@ func runBlockProcessingTest(t *testing.T, config string) {
|
||||
if transitionError != nil {
|
||||
break
|
||||
}
|
||||
beaconState, ok = processedState.(*stateTrie.BeaconState)
|
||||
beaconState, ok = processedState.(*stateV0.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func runBlockProcessingTest(t *testing.T, config string) {
|
||||
|
||||
postBeaconState := &pb.BeaconState{}
|
||||
require.NoError(t, postBeaconState.UnmarshalSSZ(postBeaconStateFile), "Failed to unmarshal")
|
||||
pbState, err := stateTrie.ProtobufBeaconState(beaconState.InnerStateUnsafe())
|
||||
pbState, err := stateV0.ProtobufBeaconState(beaconState.InnerStateUnsafe())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
diff, _ := messagediff.PrettyDiff(beaconState.InnerStateUnsafe(), postBeaconState)
|
||||
|
||||
@@ -9,8 +9,8 @@ go_library(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/mathutil:go_default_library",
|
||||
@@ -31,8 +31,8 @@ go_test(
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil:go_default_library",
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
||||
@@ -261,7 +261,7 @@ func ProcessFinalUpdates(state iface.BeaconState) (iface.BeaconState, error) {
|
||||
balance := bals[idx]
|
||||
|
||||
if balance+downwardThreshold < val.EffectiveBalance || val.EffectiveBalance+upwardThreshold < balance {
|
||||
newVal := stateTrie.CopyValidator(val)
|
||||
newVal := stateV0.CopyValidator(val)
|
||||
newVal.EffectiveBalance = maxEffBalance
|
||||
if newVal.EffectiveBalance > balance-balance%effBalanceInc {
|
||||
newVal.EffectiveBalance = balance - balance%effBalanceInc
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
fuzz "github.com/google/gofuzz"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
@@ -15,7 +15,7 @@ func TestFuzzFinalUpdates_10000(t *testing.T) {
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(base)
|
||||
s, err := beaconstate.InitializeFromProtoUnsafe(base)
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(base)
|
||||
require.NoError(t, err)
|
||||
_, err = ProcessFinalUpdates(s)
|
||||
_ = err
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -43,7 +43,7 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
indices, err := epoch.UnslashedAttestingIndices(beaconState, atts)
|
||||
@@ -89,7 +89,7 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
indices, err := epoch.UnslashedAttestingIndices(beaconState, atts)
|
||||
@@ -135,7 +135,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) {
|
||||
Validators: validators,
|
||||
Balances: balances,
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
balance, err := epoch.AttestingBalance(beaconState, atts)
|
||||
@@ -161,7 +161,7 @@ func TestBaseReward_AccurateRewards(t *testing.T) {
|
||||
{ExitEpoch: params.BeaconConfig().FarFutureEpoch, EffectiveBalance: tt.b}},
|
||||
Balances: []uint64{tt.a},
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
c, err := epoch.BaseReward(beaconState, 0)
|
||||
require.NoError(t, err)
|
||||
@@ -176,7 +176,7 @@ func TestProcessSlashings_NotSlashed(t *testing.T) {
|
||||
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
|
||||
Slashings: []uint64{0, 1e9},
|
||||
}
|
||||
s, err := state.InitializeFromProto(base)
|
||||
s, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := epoch.ProcessSlashings(s)
|
||||
require.NoError(t, err)
|
||||
@@ -254,7 +254,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
original := proto.Clone(tt.state)
|
||||
s, err := state.InitializeFromProto(tt.state)
|
||||
s, err := stateV0.InitializeFromProto(tt.state)
|
||||
require.NoError(t, err)
|
||||
newState, err := epoch.ProcessSlashings(s)
|
||||
require.NoError(t, err)
|
||||
@@ -312,7 +312,7 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
|
||||
},
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := epoch.ProcessRegistryUpdates(beaconState)
|
||||
require.NoError(t, err)
|
||||
@@ -335,7 +335,7 @@ func TestProcessRegistryUpdates_EligibleToActivate(t *testing.T) {
|
||||
ActivationEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
})
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
currentEpoch := helpers.CurrentEpoch(beaconState)
|
||||
newState, err := epoch.ProcessRegistryUpdates(beaconState)
|
||||
@@ -364,7 +364,7 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
|
||||
},
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := epoch.ProcessRegistryUpdates(beaconState)
|
||||
require.NoError(t, err)
|
||||
@@ -388,7 +388,7 @@ func TestProcessRegistryUpdates_ValidatorsEjected(t *testing.T) {
|
||||
},
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := epoch.ProcessRegistryUpdates(beaconState)
|
||||
require.NoError(t, err)
|
||||
@@ -413,7 +413,7 @@ func TestProcessRegistryUpdates_CanExits(t *testing.T) {
|
||||
},
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := epoch.ProcessRegistryUpdates(beaconState)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -41,7 +41,7 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/core/epoch:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/mathutil:go_default_library",
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -37,7 +37,7 @@ func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *test
|
||||
Balances: []uint64{a, a, a, a}, // validator total balance should be 128000000000
|
||||
BlockRoots: blockRoots,
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
attestedBalance := 4 * uint64(e) * 3 / 2
|
||||
b := &precompute.Balance{PrevEpochTargetAttested: attestedBalance}
|
||||
@@ -74,7 +74,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyCurrentEpoch(t *te
|
||||
Balances: []uint64{a, a, a, a}, // validator total balance should be 128000000000
|
||||
BlockRoots: blockRoots,
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
attestedBalance := 4 * uint64(e) * 3 / 2
|
||||
b := &precompute.Balance{PrevEpochTargetAttested: attestedBalance}
|
||||
@@ -110,7 +110,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyPrevEpoch(t *testi
|
||||
Balances: []uint64{a, a, a, a}, // validator total balance should be 128000000000
|
||||
BlockRoots: blockRoots, FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
attestedBalance := 4 * uint64(e) * 3 / 2
|
||||
b := &precompute.Balance{PrevEpochTargetAttested: attestedBalance}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
ffe := params.BeaconConfig().FarFutureEpoch
|
||||
s, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch,
|
||||
// Validator 0 is slashed
|
||||
// Validator 1 is withdrawable
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -34,7 +34,7 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) {
|
||||
}
|
||||
base.PreviousEpochAttestations = atts
|
||||
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
vp, bp, err := New(context.Background(), beaconState)
|
||||
@@ -44,7 +44,7 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) {
|
||||
|
||||
processedState, err := ProcessRewardsAndPenaltiesPrecompute(beaconState, bp, vp)
|
||||
require.NoError(t, err)
|
||||
beaconState, ok := processedState.(*state.BeaconState)
|
||||
beaconState, ok := processedState.(*stateV0.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
// Indices that voted everything except for head, lost a bit money
|
||||
@@ -78,7 +78,7 @@ func TestAttestationDeltaPrecompute(t *testing.T) {
|
||||
}
|
||||
}
|
||||
base.PreviousEpochAttestations = atts
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
slashedAttestedIndices := []types.ValidatorIndex{1413}
|
||||
for _, i := range slashedAttestedIndices {
|
||||
@@ -162,7 +162,7 @@ func TestAttestationDeltas_ZeroEpoch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
base.PreviousEpochAttestations = atts
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
pVals, pBal, err := New(context.Background(), beaconState)
|
||||
@@ -200,7 +200,7 @@ func TestAttestationDeltas_ZeroInclusionDelay(t *testing.T) {
|
||||
}
|
||||
}
|
||||
base.PreviousEpochAttestations = atts
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
pVals, pBal, err := New(context.Background(), beaconState)
|
||||
@@ -226,7 +226,7 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing.
|
||||
}
|
||||
base.PreviousEpochAttestations = atts
|
||||
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconState.SetSlot(params.BeaconConfig().SlotsPerEpoch*10))
|
||||
|
||||
@@ -300,7 +300,7 @@ func TestProposerDeltaPrecompute_HappyCase(t *testing.T) {
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(10)
|
||||
base := buildState(e, validatorCount)
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
proposerIndex := types.ValidatorIndex(1)
|
||||
@@ -322,7 +322,7 @@ func TestProposerDeltaPrecompute_ValidatorIndexOutOfRange(t *testing.T) {
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(10)
|
||||
base := buildState(e, validatorCount)
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
proposerIndex := types.ValidatorIndex(validatorCount)
|
||||
@@ -338,7 +338,7 @@ func TestProposerDeltaPrecompute_SlashedCase(t *testing.T) {
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(10)
|
||||
base := buildState(e, validatorCount)
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
proposerIndex := types.ValidatorIndex(1)
|
||||
@@ -354,7 +354,7 @@ func TestProposerDeltaPrecompute_SlashedCase(t *testing.T) {
|
||||
func TestFinalityDelay(t *testing.T) {
|
||||
base := buildState(params.BeaconConfig().SlotsPerEpoch*10, 1)
|
||||
base.FinalizedCheckpoint = ðpb.Checkpoint{Epoch: 3}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
prevEpoch := types.Epoch(0)
|
||||
finalizedEpoch := types.Epoch(0)
|
||||
@@ -384,7 +384,7 @@ func TestFinalityDelay(t *testing.T) {
|
||||
func TestIsInInactivityLeak(t *testing.T) {
|
||||
base := buildState(params.BeaconConfig().SlotsPerEpoch*10, 1)
|
||||
base.FinalizedCheckpoint = ðpb.Checkpoint{Epoch: 3}
|
||||
beaconState, err := state.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
prevEpoch := types.Epoch(0)
|
||||
finalizedEpoch := types.Epoch(0)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) {
|
||||
s, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: []*ethpb.Validator{{Slashed: true}},
|
||||
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
|
||||
@@ -30,7 +30,7 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) {
|
||||
s, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: []*ethpb.Validator{{}},
|
||||
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
|
||||
@@ -124,7 +124,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
|
||||
pBal := &precompute.Balance{ActiveCurrentEpoch: ab}
|
||||
|
||||
original := proto.Clone(tt.state)
|
||||
state, err := beaconstate.InitializeFromProto(tt.state)
|
||||
state, err := stateV0.InitializeFromProto(tt.state)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, precompute.ProcessSlashingsPrecompute(state, pBal))
|
||||
assert.Equal(t, tt.want, state.Balances()[0], "ProcessSlashings({%v}) = newState; newState.Balances[0] = %d; wanted %d", original, state.Balances()[0])
|
||||
|
||||
@@ -29,7 +29,7 @@ go_test(
|
||||
"//beacon-chain/core/epoch:go_default_library",
|
||||
"//beacon-chain/core/epoch/precompute:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/params/spectest:go_default_library",
|
||||
@@ -62,7 +62,7 @@ go_test(
|
||||
"//beacon-chain/core/epoch:go_default_library",
|
||||
"//beacon-chain/core/epoch/precompute:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/params/spectest:go_default_library",
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params/spectest"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -44,7 +44,7 @@ func runPrecomputeRewardsAndPenaltiesTest(t *testing.T, testFolderPath string) {
|
||||
require.NoError(t, err)
|
||||
preBeaconStateBase := &pb.BeaconState{}
|
||||
require.NoError(t, preBeaconStateBase.UnmarshalSSZ(preBeaconStateFile), "Failed to unmarshal")
|
||||
preBeaconState, err := beaconstate.InitializeFromProto(preBeaconStateBase)
|
||||
preBeaconState, err := stateV0.InitializeFromProto(preBeaconStateBase)
|
||||
require.NoError(t, err)
|
||||
|
||||
vp, bp, err := precompute.New(ctx, preBeaconState)
|
||||
|
||||
@@ -28,8 +28,8 @@ go_test(
|
||||
"//beacon-chain/core/epoch:go_default_library",
|
||||
"//beacon-chain/core/epoch/precompute:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/params/spectest:go_default_library",
|
||||
@@ -61,8 +61,8 @@ go_test(
|
||||
"//beacon-chain/core/epoch:go_default_library",
|
||||
"//beacon-chain/core/epoch/precompute:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/params/spectest:go_default_library",
|
||||
|
||||
@@ -67,7 +67,7 @@ go_test(
|
||||
shard_count = 2,
|
||||
deps = [
|
||||
"//beacon-chain/cache:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -98,7 +98,7 @@ func TestAttestation_ComputeSubnetForAttestation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 200,
|
||||
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -61,7 +61,7 @@ func TestBlockRootAtSlot_CorrectBlockRoot(t *testing.T) {
|
||||
for i, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||
s.Slot = tt.stateSlot
|
||||
state, err := beaconstate.InitializeFromProto(s)
|
||||
state, err := stateV0.InitializeFromProto(s)
|
||||
require.NoError(t, err)
|
||||
wantedSlot := tt.slot
|
||||
result, err := helpers.BlockRootAtSlot(state, wantedSlot)
|
||||
@@ -111,7 +111,7 @@ func TestBlockRootAtSlot_OutOfBounds(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
state.Slot = tt.stateSlot
|
||||
s, err := beaconstate.InitializeFromProto(state)
|
||||
s, err := stateV0.InitializeFromProto(state)
|
||||
require.NoError(t, err)
|
||||
_, err = helpers.BlockRootAtSlot(s, tt.slot)
|
||||
assert.ErrorContains(t, tt.expectedErr, err)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
@@ -35,7 +35,7 @@ func TestComputeCommittee_WithoutCache(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 200,
|
||||
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
@@ -91,7 +91,7 @@ func TestVerifyBitfieldLength_OK(t *testing.T) {
|
||||
func TestCommitteeAssignments_CannotRetrieveFutureEpoch(t *testing.T) {
|
||||
ClearCache()
|
||||
epoch := types.Epoch(1)
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 0, // Epoch 0.
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -111,7 +111,7 @@ func TestCommitteeAssignments_NoProposerForSlot0(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -142,7 +142,7 @@ func TestCommitteeAssignments_CanRetrieve(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -219,7 +219,7 @@ func TestCommitteeAssignments_CannotRetrieveFuture(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -243,7 +243,7 @@ func TestCommitteeAssignments_EverySlotHasMin1Proposer(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 2 * params.BeaconConfig().SlotsPerEpoch, // epoch 2
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -280,7 +280,7 @@ func TestVerifyAttestationBitfieldLengths_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: activeRoots,
|
||||
})
|
||||
@@ -378,7 +378,7 @@ func TestShuffledIndices_ShuffleRightLength(t *testing.T) {
|
||||
}
|
||||
indices[i] = uint64(i)
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -411,7 +411,7 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) {
|
||||
}
|
||||
indices[i] = i
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -435,7 +435,7 @@ func BenchmarkComputeCommittee300000_WithPreCache(b *testing.B) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -469,7 +469,7 @@ func BenchmarkComputeCommittee3000000_WithPreCache(b *testing.B) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -503,7 +503,7 @@ func BenchmarkComputeCommittee128000_WithOutPreCache(b *testing.B) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -538,7 +538,7 @@ func BenchmarkComputeCommittee1000000_WithOutCache(b *testing.B) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -573,7 +573,7 @@ func BenchmarkComputeCommittee4000000_WithOutCache(b *testing.B) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -610,7 +610,7 @@ func TestBeaconCommitteeFromState_UpdateCacheForPreviousEpoch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -635,7 +635,7 @@ func TestPrecomputeProposerIndices_Ok(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -20,7 +20,7 @@ func TestRandaoMix_OK(t *testing.T) {
|
||||
binary.LittleEndian.PutUint64(intInBytes, uint64(i))
|
||||
randaoMixes[i] = intInBytes
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{RandaoMixes: randaoMixes})
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{RandaoMixes: randaoMixes})
|
||||
require.NoError(t, err)
|
||||
tests := []struct {
|
||||
epoch types.Epoch
|
||||
@@ -54,7 +54,7 @@ func TestRandaoMix_CopyOK(t *testing.T) {
|
||||
binary.LittleEndian.PutUint64(intInBytes, uint64(i))
|
||||
randaoMixes[i] = intInBytes
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{RandaoMixes: randaoMixes})
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{RandaoMixes: randaoMixes})
|
||||
require.NoError(t, err)
|
||||
tests := []struct {
|
||||
epoch types.Epoch
|
||||
@@ -95,7 +95,7 @@ func TestGenerateSeed_OK(t *testing.T) {
|
||||
randaoMixes[i] = intInBytes
|
||||
}
|
||||
slot := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().MinSeedLookahead * 10))
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
RandaoMixes: randaoMixes,
|
||||
Slot: slot,
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTotalBalance_OK(t *testing.T) {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
{EffectiveBalance: 27 * 1e9}, {EffectiveBalance: 28 * 1e9},
|
||||
{EffectiveBalance: 32 * 1e9}, {EffectiveBalance: 40 * 1e9},
|
||||
}})
|
||||
@@ -26,7 +26,7 @@ func TestTotalBalance_OK(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTotalBalance_ReturnsEffectiveBalanceIncrement(t *testing.T) {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{}})
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{}})
|
||||
require.NoError(t, err)
|
||||
|
||||
balance := TotalBalance(state, []types.ValidatorIndex{})
|
||||
@@ -35,7 +35,7 @@ func TestTotalBalance_ReturnsEffectiveBalanceIncrement(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTotalActiveBalance_OK(t *testing.T) {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
{
|
||||
EffectiveBalance: 32 * 1e9,
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
@@ -74,7 +74,7 @@ func TestGetBalance_OK(t *testing.T) {
|
||||
{i: 2, b: []uint64{0, 0, 0}},
|
||||
}
|
||||
for _, test := range tests {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{Balances: test.b})
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{Balances: test.b})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, test.b[test.i], state.Balances()[test.i], "Incorrect Validator balance")
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func TestIncreaseBalance_OK(t *testing.T) {
|
||||
{i: 2, b: []uint64{27 * 1e9, 28 * 1e9, 32 * 1e9}, nb: 33 * 1e9, eb: 65 * 1e9},
|
||||
}
|
||||
for _, test := range tests {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 4}},
|
||||
Balances: test.b,
|
||||
@@ -116,7 +116,7 @@ func TestDecreaseBalance_OK(t *testing.T) {
|
||||
{i: 3, b: []uint64{27 * 1e9, 28 * 1e9, 1, 28 * 1e9}, nb: 28 * 1e9, eb: 0},
|
||||
}
|
||||
for _, test := range tests {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 3}},
|
||||
Balances: test.b,
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -42,7 +42,7 @@ func TestCurrentEpoch_OK(t *testing.T) {
|
||||
{slot: 200, epoch: 6},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.epoch, CurrentEpoch(state), "ActiveCurrentEpoch(%d)", state.Slot())
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func TestPrevEpoch_OK(t *testing.T) {
|
||||
{slot: 2 * params.BeaconConfig().SlotsPerEpoch, epoch: 1},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.epoch, PrevEpoch(state), "ActivePrevEpoch(%d)", state.Slot())
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func TestNextEpoch_OK(t *testing.T) {
|
||||
{slot: 200, epoch: types.Epoch(200/params.BeaconConfig().SlotsPerEpoch + 1)},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.epoch, NextEpoch(state), "NextEpoch(%d)", state.Slot())
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
@@ -45,7 +45,7 @@ func TestIsActiveValidatorUsingTrie_OK(t *testing.T) {
|
||||
{a: 64, b: true},
|
||||
}
|
||||
val := ðpb.Validator{ActivationEpoch: 10, ExitEpoch: 100}
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{val}})
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{val}})
|
||||
require.NoError(t, err)
|
||||
for _, test := range tests {
|
||||
readOnlyVal, err := beaconState.ValidatorAtIndexReadOnly(0)
|
||||
@@ -210,7 +210,7 @@ func TestIsSlashableValidatorUsingTrie_OK(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{test.validator}})
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{test.validator}})
|
||||
require.NoError(t, err)
|
||||
readOnlyVal, err := beaconState.ValidatorAtIndexReadOnly(0)
|
||||
require.NoError(t, err)
|
||||
@@ -234,7 +234,7 @@ func TestBeaconProposerIndex_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 0,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -293,7 +293,7 @@ func TestBeaconProposerIndex_BadState(t *testing.T) {
|
||||
roots[i] = make([]byte, 32)
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 0,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -317,7 +317,7 @@ func TestComputeProposerIndex_Compatibility(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -364,7 +364,7 @@ func TestActiveValidatorCount_Genesis(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -400,7 +400,7 @@ func TestChurnLimit_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Slot: 1,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -589,7 +589,7 @@ func TestActiveValidatorIndices(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
s, err := beaconstate.InitializeFromProto(tt.args.state)
|
||||
s, err := stateV0.InitializeFromProto(tt.args.state)
|
||||
require.NoError(t, err)
|
||||
got, err := ActiveValidatorIndices(s, tt.args.epoch)
|
||||
if tt.wantedErr != "" {
|
||||
@@ -714,7 +714,7 @@ func TestComputeProposerIndex(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
bState := &pb.BeaconState{Validators: tt.args.validators}
|
||||
stTrie, err := beaconstate.InitializeFromProtoUnsafe(bState)
|
||||
stTrie, err := stateV0.InitializeFromProtoUnsafe(bState)
|
||||
require.NoError(t, err)
|
||||
got, err := ComputeProposerIndex(stTrie, tt.args.indices, tt.args.seed)
|
||||
if tt.wantedErr != "" {
|
||||
@@ -771,7 +771,7 @@ func TestIsIsEligibleForActivation(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
s, err := beaconstate.InitializeFromProto(tt.state)
|
||||
s, err := stateV0.InitializeFromProto(tt.state)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.want, IsEligibleForActivation(s, tt.validator), "IsEligibleForActivation()")
|
||||
})
|
||||
|
||||
@@ -30,8 +30,8 @@ go_library(
|
||||
"//beacon-chain/core/epoch/precompute:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state/interop:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
@@ -72,8 +72,8 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/core/blocks:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/benchutil:go_default_library",
|
||||
@@ -113,7 +113,7 @@ go_test(
|
||||
"//beacon-chain/core/blocks:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/benchutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/benchutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -110,7 +110,7 @@ func BenchmarkHashTreeRootState_FullState(b *testing.B) {
|
||||
func BenchmarkMarshalState_FullState(b *testing.B) {
|
||||
beaconState, err := benchutil.PreGenState2FullEpochs()
|
||||
require.NoError(b, err)
|
||||
natState, err := state.ProtobufBeaconState(beaconState.InnerStateUnsafe())
|
||||
natState, err := stateV0.ProtobufBeaconState(beaconState.InnerStateUnsafe())
|
||||
require.NoError(b, err)
|
||||
b.Run("Proto_Marshal", func(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
@@ -134,7 +134,7 @@ func BenchmarkMarshalState_FullState(b *testing.B) {
|
||||
func BenchmarkUnmarshalState_FullState(b *testing.B) {
|
||||
beaconState, err := benchutil.PreGenState2FullEpochs()
|
||||
require.NoError(b, err)
|
||||
natState, err := state.ProtobufBeaconState(beaconState.InnerStateUnsafe())
|
||||
natState, err := stateV0.ProtobufBeaconState(beaconState.InnerStateUnsafe())
|
||||
require.NoError(b, err)
|
||||
protoObject, err := proto.Marshal(natState)
|
||||
require.NoError(b, err)
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -18,9 +18,9 @@ func TestSkipSlotCache_OK(t *testing.T) {
|
||||
state.SkipSlotCache.Enable()
|
||||
defer state.SkipSlotCache.Disable()
|
||||
bState, privs := testutil.DeterministicGenesisState(t, params.MinimalSpecConfig().MinGenesisActiveValidatorCount)
|
||||
pbState, err := beaconstate.ProtobufBeaconState(bState.CloneInnerState())
|
||||
pbState, err := stateV0.ProtobufBeaconState(bState.CloneInnerState())
|
||||
require.NoError(t, err)
|
||||
originalState, err := beaconstate.InitializeFromProto(pbState)
|
||||
originalState, err := stateV0.InitializeFromProto(pbState)
|
||||
require.NoError(t, err)
|
||||
|
||||
blkCfg := testutil.DefaultBlockGenConfig()
|
||||
@@ -32,7 +32,7 @@ func TestSkipSlotCache_OK(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
executedState, err := state.ExecuteStateTransition(context.Background(), originalState, blk)
|
||||
require.NoError(t, err, "Could not run state transition")
|
||||
originalState, ok := executedState.(*beaconstate.BeaconState)
|
||||
originalState, ok := executedState.(*stateV0.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
bState, err = state.ExecuteStateTransition(context.Background(), bState, blk)
|
||||
require.NoError(t, err, "Could not process state transition")
|
||||
@@ -42,9 +42,9 @@ func TestSkipSlotCache_OK(t *testing.T) {
|
||||
|
||||
func TestSkipSlotCache_ConcurrentMixup(t *testing.T) {
|
||||
bState, privs := testutil.DeterministicGenesisState(t, params.MinimalSpecConfig().MinGenesisActiveValidatorCount)
|
||||
pbState, err := beaconstate.ProtobufBeaconState(bState.CloneInnerState())
|
||||
pbState, err := stateV0.ProtobufBeaconState(bState.CloneInnerState())
|
||||
require.NoError(t, err)
|
||||
originalState, err := beaconstate.InitializeFromProto(pbState)
|
||||
originalState, err := stateV0.InitializeFromProto(pbState)
|
||||
require.NoError(t, err)
|
||||
|
||||
blkCfg := testutil.DefaultBlockGenConfig()
|
||||
@@ -58,7 +58,7 @@ func TestSkipSlotCache_ConcurrentMixup(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
executedState, err := state.ExecuteStateTransition(context.Background(), originalState, blk)
|
||||
require.NoError(t, err, "Could not run state transition")
|
||||
originalState, ok := executedState.(*beaconstate.BeaconState)
|
||||
originalState, ok := executedState.(*stateV0.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
// Create two shallow but different forks
|
||||
|
||||
@@ -25,7 +25,7 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
@@ -59,7 +59,7 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params/spectest"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -30,7 +30,7 @@ func runSlotProcessingTests(t *testing.T, config string) {
|
||||
require.NoError(t, err)
|
||||
base := &pb.BeaconState{}
|
||||
require.NoError(t, base.UnmarshalSSZ(preBeaconStateFile), "Failed to unmarshal")
|
||||
beaconState, err := beaconstate.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
file, err := testutil.BazelFileBytes(testsFolderPath, folder.Name(), "slots.yaml")
|
||||
@@ -46,7 +46,7 @@ func runSlotProcessingTests(t *testing.T, config string) {
|
||||
postState, err := state.ProcessSlots(context.Background(), beaconState, beaconState.Slot().Add(uint64(slotsCount)))
|
||||
require.NoError(t, err)
|
||||
|
||||
pbState, err := beaconstate.ProtobufBeaconState(postState.CloneInnerState())
|
||||
pbState, err := stateV0.ProtobufBeaconState(postState.CloneInnerState())
|
||||
require.NoError(t, err)
|
||||
if !proto.Equal(pbState, postBeaconState) {
|
||||
diff, _ := messagediff.PrettyDiff(beaconState, postBeaconState)
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
b "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/trieutil"
|
||||
@@ -136,7 +136,7 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState,
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateTrie.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateV0.ValidatorRegistryRoot(preState.Validators())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
@@ -206,7 +206,7 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState,
|
||||
BodyRoot: bodyRoot[:],
|
||||
}
|
||||
|
||||
return stateTrie.InitializeFromProto(state)
|
||||
return stateV0.InitializeFromProto(state)
|
||||
}
|
||||
|
||||
// EmptyGenesisState returns an empty beacon state object.
|
||||
@@ -233,7 +233,7 @@ func EmptyGenesisState() (iface.BeaconState, error) {
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{},
|
||||
Eth1DepositIndex: 0,
|
||||
}
|
||||
return stateTrie.InitializeFromProto(state)
|
||||
return stateV0.InitializeFromProto(state)
|
||||
}
|
||||
|
||||
// IsValidGenesisState gets called whenever there's a deposit event,
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
fuzz "github.com/google/gofuzz"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
)
|
||||
|
||||
func TestGenesisBeaconState_1000(t *testing.T) {
|
||||
@@ -36,7 +36,7 @@ func TestOptimizedGenesisBeaconState_1000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
var genesisTime uint64
|
||||
preState := &stateTrie.BeaconState{}
|
||||
preState := &stateV0.BeaconState{}
|
||||
eth1Data := ðpb.Eth1Data{}
|
||||
for i := 0; i < 1000; i++ {
|
||||
fuzzer.Fuzz(&genesisTime)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -94,9 +94,9 @@ func TestGenesisState_HashEquality(t *testing.T) {
|
||||
state2, err := state.GenesisBeaconState(deposits, 0, ðpb.Eth1Data{BlockHash: make([]byte, 32)})
|
||||
require.NoError(t, err)
|
||||
|
||||
pbState1, err := beaconstate.ProtobufBeaconState(state1.CloneInnerState())
|
||||
pbState1, err := stateV0.ProtobufBeaconState(state1.CloneInnerState())
|
||||
require.NoError(t, err)
|
||||
pbState2, err := beaconstate.ProtobufBeaconState(state2.CloneInnerState())
|
||||
pbState2, err := stateV0.ProtobufBeaconState(state2.CloneInnerState())
|
||||
require.NoError(t, err)
|
||||
|
||||
root1, err1 := hashutil.HashProto(pbState1)
|
||||
|
||||
@@ -22,7 +22,7 @@ go_test(
|
||||
srcs = ["validator_index_map_test.go"],
|
||||
deps = [
|
||||
":go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/stateutils"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -24,7 +24,7 @@ func TestValidatorIndexMap_OK(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
fuzz "github.com/google/gofuzz"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
)
|
||||
|
||||
func TestFuzzExecuteStateTransition_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
sb := ðpb.SignedBeaconBlock{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
@@ -32,7 +32,7 @@ func TestFuzzCalculateStateRoot_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
sb := ðpb.SignedBeaconBlock{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
@@ -50,7 +50,7 @@ func TestFuzzProcessSlot_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
for i := 0; i < 1000; i++ {
|
||||
@@ -66,7 +66,7 @@ func TestFuzzProcessSlots_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
slot := types.Slot(0)
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
@@ -84,7 +84,7 @@ func TestFuzzProcessBlock_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
sb := ðpb.SignedBeaconBlock{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
@@ -102,7 +102,7 @@ func TestFuzzProcessOperations_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
bb := ðpb.SignedBeaconBlock{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
@@ -120,7 +120,7 @@ func TestFuzzprocessOperationsNoVerify_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
bb := ðpb.SignedBeaconBlock{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
@@ -137,7 +137,7 @@ func TestFuzzprocessOperationsNoVerify_1000(t *testing.T) {
|
||||
func TestFuzzverifyOperationLengths_10000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
bb := ðpb.SignedBeaconBlock{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
@@ -152,7 +152,7 @@ func TestFuzzverifyOperationLengths_10000(t *testing.T) {
|
||||
func TestFuzzCanProcessEpoch_10000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -165,7 +165,7 @@ func TestFuzzProcessEpochPrecompute_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
for i := 0; i < 1000; i++ {
|
||||
@@ -181,7 +181,7 @@ func TestFuzzProcessBlockForStateRoot_1000(t *testing.T) {
|
||||
SkipSlotCache.Disable()
|
||||
defer SkipSlotCache.Enable()
|
||||
ctx := context.Background()
|
||||
state := &stateTrie.BeaconState{}
|
||||
state := &stateV0.BeaconState{}
|
||||
sb := ðpb.SignedBeaconBlock{}
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
fuzzer.NilChance(0.1)
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
@@ -35,7 +35,7 @@ func TestExecuteStateTransition_IncorrectSlot(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
Slot: 5,
|
||||
}
|
||||
beaconState, err := beaconstate.InitializeFromProto(base)
|
||||
beaconState, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
block := ðpb.SignedBeaconBlock{
|
||||
Block: ðpb.BeaconBlock{
|
||||
@@ -518,7 +518,7 @@ func TestProcessEpochPrecompute_CanProcess(t *testing.T) {
|
||||
CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
Validators: []*ethpb.Validator{},
|
||||
}
|
||||
s, err := beaconstate.InitializeFromProto(base)
|
||||
s, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := state.ProcessEpochPrecompute(context.Background(), s)
|
||||
require.NoError(t, err)
|
||||
@@ -564,7 +564,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) {
|
||||
CurrentVersion: []byte{0, 0, 0, 0},
|
||||
},
|
||||
}
|
||||
s, err := beaconstate.InitializeFromProto(base)
|
||||
s, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(b, err)
|
||||
|
||||
// Set up proposer slashing object for block
|
||||
@@ -790,7 +790,7 @@ func TestCanProcessEpoch_TrueOnEpochs(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
b := &pb.BeaconState{Slot: tt.slot}
|
||||
s, err := beaconstate.InitializeFromProto(b)
|
||||
s, err := stateV0.InitializeFromProto(b)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.canProcessEpoch, state.CanProcessEpoch(s), "CanProcessEpoch(%d)", tt.slot)
|
||||
}
|
||||
@@ -807,7 +807,7 @@ func TestProcessBlock_OverMaxProposerSlashings(t *testing.T) {
|
||||
}
|
||||
want := fmt.Sprintf("number of proposer slashings (%d) in block body exceeds allowed threshold of %d",
|
||||
len(b.Block.Body.ProposerSlashings), params.BeaconConfig().MaxProposerSlashings)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &beaconstate.BeaconState{}, b)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &stateV0.BeaconState{}, b)
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
@@ -822,7 +822,7 @@ func TestProcessBlock_OverMaxAttesterSlashings(t *testing.T) {
|
||||
}
|
||||
want := fmt.Sprintf("number of attester slashings (%d) in block body exceeds allowed threshold of %d",
|
||||
len(b.Block.Body.AttesterSlashings), params.BeaconConfig().MaxAttesterSlashings)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &beaconstate.BeaconState{}, b)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &stateV0.BeaconState{}, b)
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
@@ -836,7 +836,7 @@ func TestProcessBlock_OverMaxAttestations(t *testing.T) {
|
||||
}
|
||||
want := fmt.Sprintf("number of attestations (%d) in block body exceeds allowed threshold of %d",
|
||||
len(b.Block.Body.Attestations), params.BeaconConfig().MaxAttestations)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &beaconstate.BeaconState{}, b)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &stateV0.BeaconState{}, b)
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
@@ -851,7 +851,7 @@ func TestProcessBlock_OverMaxVoluntaryExits(t *testing.T) {
|
||||
}
|
||||
want := fmt.Sprintf("number of voluntary exits (%d) in block body exceeds allowed threshold of %d",
|
||||
len(b.Block.Body.VoluntaryExits), maxExits)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &beaconstate.BeaconState{}, b)
|
||||
_, err := state.VerifyOperationLengths(context.Background(), &stateV0.BeaconState{}, b)
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
@@ -860,7 +860,7 @@ func TestProcessBlock_IncorrectDeposits(t *testing.T) {
|
||||
Eth1Data: ðpb.Eth1Data{DepositCount: 100},
|
||||
Eth1DepositIndex: 98,
|
||||
}
|
||||
s, err := beaconstate.InitializeFromProto(base)
|
||||
s, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
b := ðpb.SignedBeaconBlock{
|
||||
Block: ðpb.BeaconBlock{
|
||||
@@ -877,7 +877,7 @@ func TestProcessBlock_IncorrectDeposits(t *testing.T) {
|
||||
|
||||
func TestProcessSlots_SameSlotAsParentState(t *testing.T) {
|
||||
slot := types.Slot(2)
|
||||
parentState, err := beaconstate.InitializeFromProto(&pb.BeaconState{Slot: slot})
|
||||
parentState, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: slot})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = state.ProcessSlots(context.Background(), parentState, slot)
|
||||
@@ -886,7 +886,7 @@ func TestProcessSlots_SameSlotAsParentState(t *testing.T) {
|
||||
|
||||
func TestProcessSlots_LowerSlotAsParentState(t *testing.T) {
|
||||
slot := types.Slot(2)
|
||||
parentState, err := beaconstate.InitializeFromProto(&pb.BeaconState{Slot: slot})
|
||||
parentState, err := stateV0.InitializeFromProto(&pb.BeaconState{Slot: slot})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = state.ProcessSlots(context.Background(), parentState, slot-1)
|
||||
|
||||
@@ -23,7 +23,7 @@ go_test(
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -44,7 +44,7 @@ func TestInitiateValidatorExit_AlreadyExited(t *testing.T) {
|
||||
base := &pb.BeaconState{Validators: []*ethpb.Validator{{
|
||||
ExitEpoch: exitEpoch},
|
||||
}}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := InitiateValidatorExit(state, 0)
|
||||
require.NoError(t, err)
|
||||
@@ -62,7 +62,7 @@ func TestInitiateValidatorExit_ProperExit(t *testing.T) {
|
||||
{ExitEpoch: exitedEpoch + 2},
|
||||
{ExitEpoch: params.BeaconConfig().FarFutureEpoch},
|
||||
}}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := InitiateValidatorExit(state, idx)
|
||||
require.NoError(t, err)
|
||||
@@ -81,7 +81,7 @@ func TestInitiateValidatorExit_ChurnOverflow(t *testing.T) {
|
||||
{ExitEpoch: exitedEpoch + 2}, // overflow here
|
||||
{ExitEpoch: params.BeaconConfig().FarFutureEpoch},
|
||||
}}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
newState, err := InitiateValidatorExit(state, idx)
|
||||
require.NoError(t, err)
|
||||
@@ -116,7 +116,7 @@ func TestSlashValidator_OK(t *testing.T) {
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
Balances: balances,
|
||||
}
|
||||
state, err := beaconstate.InitializeFromProto(base)
|
||||
state, err := stateV0.InitializeFromProto(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
slashedIdx := types.ValidatorIndex(2)
|
||||
@@ -127,7 +127,7 @@ func TestSlashValidator_OK(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
slashedState, err := SlashValidator(state, slashedIdx)
|
||||
require.NoError(t, err, "Could not slash validator")
|
||||
state, ok := slashedState.(*beaconstate.BeaconState)
|
||||
state, ok := slashedState.(*stateV0.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
v, err := state.ValidatorAtIndex(slashedIdx)
|
||||
@@ -201,7 +201,7 @@ func TestActivatedValidatorIndices(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
s, err := beaconstate.InitializeFromProto(tt.state)
|
||||
s, err := stateV0.InitializeFromProto(tt.state)
|
||||
require.NoError(t, err)
|
||||
activatedIndices := ActivatedValidatorIndices(helpers.CurrentEpoch(s), tt.state.Validators)
|
||||
assert.DeepEqual(t, tt.wanted, activatedIndices)
|
||||
@@ -255,7 +255,7 @@ func TestSlashedValidatorIndices(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
s, err := beaconstate.InitializeFromProto(tt.state)
|
||||
s, err := stateV0.InitializeFromProto(tt.state)
|
||||
require.NoError(t, err)
|
||||
slashedIndices := SlashedValidatorIndices(helpers.CurrentEpoch(s), tt.state.Validators)
|
||||
assert.DeepEqual(t, tt.wanted, slashedIndices)
|
||||
@@ -315,7 +315,7 @@ func TestExitedValidatorIndices(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
s, err := beaconstate.InitializeFromProto(tt.state)
|
||||
s, err := stateV0.InitializeFromProto(tt.state)
|
||||
require.NoError(t, err)
|
||||
activeCount, err := helpers.ActiveValidatorCount(s, helpers.PrevEpoch(s))
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -35,8 +35,8 @@ go_library(
|
||||
"//beacon-chain/core/helpers: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/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/db:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
bolt "go.etcd.io/bbolt"
|
||||
@@ -35,7 +35,7 @@ func (s *Store) State(ctx context.Context, blockRoot [32]byte) (iface.BeaconStat
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return state.InitializeFromProtoUnsafe(st)
|
||||
return stateV0.InitializeFromProtoUnsafe(st)
|
||||
}
|
||||
|
||||
// GenesisState returns the genesis state in beacon chain.
|
||||
@@ -65,7 +65,7 @@ func (s *Store) GenesisState(ctx context.Context) (iface.BeaconState, error) {
|
||||
if st == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return state.InitializeFromProtoUnsafe(st)
|
||||
return stateV0.InitializeFromProtoUnsafe(st)
|
||||
}
|
||||
|
||||
// SaveState stores a state to the db using block's signing root which was used to generate the state.
|
||||
@@ -85,7 +85,7 @@ func (s *Store) SaveStates(ctx context.Context, states []iface.ReadOnlyBeaconSta
|
||||
}
|
||||
multipleEncs := make([][]byte, len(states))
|
||||
for i, st := range states {
|
||||
pbState, err := state.ProtobufBeaconState(st.InnerStateUnsafe())
|
||||
pbState, err := stateV0.ProtobufBeaconState(st.InnerStateUnsafe())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ go_library(
|
||||
"//beacon-chain/core/blocks:go_default_library",
|
||||
"//beacon-chain/db:go_default_library",
|
||||
"//beacon-chain/powchain:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared:go_default_library",
|
||||
"//shared/interop:go_default_library",
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared"
|
||||
"github.com/prysmaticlabs/prysm/shared/interop"
|
||||
@@ -76,7 +76,7 @@ func NewService(ctx context.Context, cfg *Config) *Service {
|
||||
if err := genesisState.UnmarshalSSZ(data); err != nil {
|
||||
log.Fatalf("Could not unmarshal pre-loaded state: %v", err)
|
||||
}
|
||||
genesisTrie, err := stateTrie.InitializeFromProto(genesisState)
|
||||
genesisTrie, err := stateV0.InitializeFromProto(genesisState)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not get state trie: %v", err)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func NewService(ctx context.Context, cfg *Config) *Service {
|
||||
if err != nil {
|
||||
log.Fatalf("Could not generate interop genesis state: %v", err)
|
||||
}
|
||||
genesisTrie, err := stateTrie.InitializeFromProto(genesisState)
|
||||
genesisTrie, err := stateV0.InitializeFromProto(genesisState)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not get state trie: %v", err)
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (s *Service) ChainStartEth1Data() *ethpb.Eth1Data {
|
||||
|
||||
// PreGenesisState returns an empty beacon state.
|
||||
func (s *Service) PreGenesisState() iface.BeaconState {
|
||||
return &stateTrie.BeaconState{}
|
||||
return &stateV0.BeaconState{}
|
||||
}
|
||||
|
||||
// ClearPreGenesisData --
|
||||
|
||||
@@ -19,7 +19,7 @@ go_library(
|
||||
],
|
||||
deps = [
|
||||
"//beacon-chain/operations/attestations/kv:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//shared/aggregation/attestations:go_default_library",
|
||||
"//shared/hashutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -15,7 +15,7 @@ go_library(
|
||||
visibility = ["//beacon-chain:__subpackages__"],
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//shared/aggregation/attestations:go_default_library",
|
||||
"//shared/hashutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/trace"
|
||||
@@ -120,7 +120,7 @@ func (c *AttCaches) SaveAggregatedAttestation(att *ethpb.Attestation) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not tree hash attestation")
|
||||
}
|
||||
copiedAtt := stateTrie.CopyAttestation(att)
|
||||
copiedAtt := stateV0.CopyAttestation(att)
|
||||
c.aggregatedAttLock.Lock()
|
||||
defer c.aggregatedAttLock.Unlock()
|
||||
atts, ok := c.aggregatedAtt[r]
|
||||
|
||||
@@ -3,7 +3,7 @@ package kv
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
)
|
||||
|
||||
// SaveBlockAttestation saves an block attestation in cache.
|
||||
@@ -30,7 +30,7 @@ func (c *AttCaches) SaveBlockAttestation(att *ethpb.Attestation) error {
|
||||
}
|
||||
}
|
||||
|
||||
c.blockAtt[r] = append(atts, stateTrie.CopyAttestation(att))
|
||||
c.blockAtt[r] = append(atts, stateV0.CopyAttestation(att))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package kv
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
)
|
||||
|
||||
// SaveForkchoiceAttestation saves an forkchoice attestation in cache.
|
||||
@@ -16,7 +16,7 @@ func (c *AttCaches) SaveForkchoiceAttestation(att *ethpb.Attestation) error {
|
||||
return errors.Wrap(err, "could not tree hash attestation")
|
||||
}
|
||||
|
||||
att = stateTrie.CopyAttestation(att)
|
||||
att = stateV0.CopyAttestation(att)
|
||||
c.forkchoiceAttLock.Lock()
|
||||
defer c.forkchoiceAttLock.Unlock()
|
||||
c.forkchoiceAtt[r] = att
|
||||
@@ -42,7 +42,7 @@ func (c *AttCaches) ForkchoiceAttestations() []*ethpb.Attestation {
|
||||
|
||||
atts := make([]*ethpb.Attestation, 0, len(c.forkchoiceAtt))
|
||||
for _, att := range c.forkchoiceAtt {
|
||||
atts = append(atts, stateTrie.CopyAttestation(att) /* Copied */)
|
||||
atts = append(atts, stateV0.CopyAttestation(att) /* Copied */)
|
||||
}
|
||||
|
||||
return atts
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ func (c *AttCaches) SaveUnaggregatedAttestation(att *ethpb.Attestation) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not tree hash attestation")
|
||||
}
|
||||
att = stateTrie.CopyAttestation(att) // Copied.
|
||||
att = stateV0.CopyAttestation(att) // Copied.
|
||||
c.unAggregateAttLock.Lock()
|
||||
defer c.unAggregateAttLock.Unlock()
|
||||
c.unAggregatedAtt[r] = att
|
||||
@@ -63,7 +63,7 @@ func (c *AttCaches) UnaggregatedAttestations() ([]*ethpb.Attestation, error) {
|
||||
return nil, err
|
||||
}
|
||||
if !seen {
|
||||
atts = append(atts, stateTrie.CopyAttestation(att) /* Copied */)
|
||||
atts = append(atts, stateV0.CopyAttestation(att) /* Copied */)
|
||||
}
|
||||
}
|
||||
return atts, nil
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/slotutil"
|
||||
@@ -88,7 +88,7 @@ func (s *Service) batchForkChoiceAtts(ctx context.Context) error {
|
||||
func (s *Service) aggregateAndSaveForkChoiceAtts(atts []*ethpb.Attestation) error {
|
||||
clonedAtts := make([]*ethpb.Attestation, len(atts))
|
||||
for i, a := range atts {
|
||||
clonedAtts[i] = stateTrie.CopyAttestation(a)
|
||||
clonedAtts[i] = stateV0.CopyAttestation(a)
|
||||
}
|
||||
aggregatedAtts, err := attaggregation.Aggregate(clonedAtts)
|
||||
if err != nil {
|
||||
|
||||
@@ -29,7 +29,7 @@ go_test(
|
||||
srcs = ["service_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/require:go_default_library",
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -270,7 +270,7 @@ func TestPool_InsertVoluntaryExit(t *testing.T) {
|
||||
p := &Pool{
|
||||
pending: tt.fields.pending,
|
||||
}
|
||||
s, err := beaconstate.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: validators})
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: validators})
|
||||
require.NoError(t, err)
|
||||
p.InsertVoluntaryExit(ctx, s, tt.args.exit)
|
||||
if len(p.pending) != len(tt.want) {
|
||||
@@ -521,7 +521,7 @@ func TestPool_PendingExits(t *testing.T) {
|
||||
p := &Pool{
|
||||
pending: tt.fields.pending,
|
||||
}
|
||||
s, err := beaconstate.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: []*ethpb.Validator{{ExitEpoch: params.BeaconConfig().FarFutureEpoch}}})
|
||||
s, err := stateV0.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: []*ethpb.Validator{{ExitEpoch: params.BeaconConfig().FarFutureEpoch}}})
|
||||
require.NoError(t, err)
|
||||
if got := p.PendingExits(s, tt.args.slot, tt.fields.noLimit); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("PendingExits() = %v, want %v", got, tt.want)
|
||||
|
||||
@@ -25,8 +25,8 @@ go_library(
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/db:go_default_library",
|
||||
"//beacon-chain/powchain/types:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//contracts/deposit-contract:go_default_library",
|
||||
"//proto/beacon/db:go_default_library",
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
|
||||
protodb "github.com/prysmaticlabs/prysm/proto/beacon/db"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -531,7 +531,7 @@ func (s *Service) checkForChainstart(blockHash [32]byte, blockNumber *big.Int, b
|
||||
|
||||
// save all powchain related metadata to disk.
|
||||
func (s *Service) savePowchainData(ctx context.Context) error {
|
||||
pbState, err := state.ProtobufBeaconState(s.preGenesisState.InnerStateUnsafe())
|
||||
pbState, err := stateV0.ProtobufBeaconState(s.preGenesisState.InnerStateUnsafe())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain/types"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
|
||||
protodb "github.com/prysmaticlabs/prysm/proto/beacon/db"
|
||||
@@ -229,7 +229,7 @@ func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error
|
||||
s.depositTrie = trieutil.CreateTrieFromProto(eth1Data.Trie)
|
||||
s.chainStartData = eth1Data.ChainstartData
|
||||
if !reflect.ValueOf(eth1Data.BeaconState).IsZero() {
|
||||
s.preGenesisState, err = stateTrie.InitializeFromProto(eth1Data.BeaconState)
|
||||
s.preGenesisState, err = stateV0.InitializeFromProto(eth1Data.BeaconState)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Could not initialize state trie")
|
||||
}
|
||||
@@ -292,7 +292,7 @@ func (s *Service) ChainStartDeposits() []*ethpb.Deposit {
|
||||
// ClearPreGenesisData clears out the stored chainstart deposits and beacon state.
|
||||
func (s *Service) ClearPreGenesisData() {
|
||||
s.chainStartData.ChainstartDeposits = []*ethpb.Deposit{}
|
||||
s.preGenesisState = &stateTrie.BeaconState{}
|
||||
s.preGenesisState = &stateV0.BeaconState{}
|
||||
}
|
||||
|
||||
// ChainStartEth1Data returns the eth1 data at chainstart.
|
||||
|
||||
@@ -11,8 +11,8 @@ go_library(
|
||||
visibility = ["//beacon-chain:__subpackages__"],
|
||||
deps = [
|
||||
"//beacon-chain/powchain/types:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/event:go_default_library",
|
||||
"//shared/trieutil:go_default_library",
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain/types"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/shared/event"
|
||||
"github.com/prysmaticlabs/prysm/shared/trieutil"
|
||||
)
|
||||
@@ -76,7 +76,7 @@ func (f *FaultyMockPOWChain) ChainStartEth1Data() *ethpb.Eth1Data {
|
||||
|
||||
// PreGenesisState --
|
||||
func (f *FaultyMockPOWChain) PreGenesisState() iface.BeaconState {
|
||||
return &beaconstate.BeaconState{}
|
||||
return &stateV0.BeaconState{}
|
||||
}
|
||||
|
||||
// ClearPreGenesisData --
|
||||
|
||||
@@ -89,8 +89,8 @@ go_test(
|
||||
"//beacon-chain/operations/attestations:go_default_library",
|
||||
"//beacon-chain/operations/slashings:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/sync/initial-sync/testing:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
|
||||
@@ -38,7 +38,7 @@ func TestServer_ListAttestations_NoResults(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
st, err := stateTrie.InitializeFromProto(&pbp2p.BeaconState{
|
||||
st, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: 0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -66,7 +66,7 @@ func TestServer_ListAttestations_Genesis(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
st, err := stateTrie.InitializeFromProto(&pbp2p.BeaconState{
|
||||
st, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: 0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -392,7 +392,7 @@ func TestServer_GetChainHead(t *testing.T) {
|
||||
pjRoot, err := prevJustifiedBlock.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
|
||||
s, err := stateTrie.InitializeFromProto(&pbp2p.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: 1,
|
||||
PreviousJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 3, Root: pjRoot[:]},
|
||||
CurrentJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 2, Root: jRoot[:]},
|
||||
@@ -482,7 +482,7 @@ func TestServer_StreamChainHead_OnHeadUpdated(t *testing.T) {
|
||||
pjRoot, err := prevJustifiedBlock.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
|
||||
s, err := stateTrie.InitializeFromProto(&pbp2p.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: 1,
|
||||
PreviousJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 3, Root: pjRoot[:]},
|
||||
CurrentJustifiedCheckpoint: ðpb.Checkpoint{Epoch: 2, Root: jRoot[:]},
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
@@ -1273,7 +1273,7 @@ func TestServer_GetValidatorActiveSetChanges(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_GetValidatorQueue_PendingActivation(t *testing.T) {
|
||||
headState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
headState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
ActivationEpoch: helpers.ActivationExitEpoch(0),
|
||||
@@ -1372,7 +1372,7 @@ func TestServer_GetValidatorQueue_ExitedValidatorLeavesQueue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_GetValidatorQueue_PendingExit(t *testing.T) {
|
||||
headState, err := stateTrie.InitializeFromProto(&pb.BeaconState{
|
||||
headState, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
ActivationEpoch: 0,
|
||||
@@ -1461,7 +1461,7 @@ func TestServer_GetValidatorParticipation_UnknownState(t *testing.T) {
|
||||
slots := params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch))
|
||||
mockStateGen := &stategen.MockStateManager{
|
||||
StatesBySlot: map[types.Slot]iface.BeaconState{
|
||||
0: (*stateTrie.BeaconState)(nil),
|
||||
0: (*stateV0.BeaconState)(nil),
|
||||
},
|
||||
}
|
||||
bs := &Server{
|
||||
|
||||
@@ -34,8 +34,8 @@ go_library(
|
||||
"//beacon-chain/operations/voluntaryexits:go_default_library",
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/powchain:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/sync:go_default_library",
|
||||
"//proto/beacon/db:go_default_library",
|
||||
@@ -97,8 +97,8 @@ go_test(
|
||||
"//beacon-chain/operations/voluntaryexits:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/powchain/testing:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stateV0:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/sync/initial-sync/testing:go_default_library",
|
||||
"//proto/beacon/db:go_default_library",
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
|
||||
mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
|
||||
@@ -31,7 +31,7 @@ func TestSubmitAggregateAndProof_Syncing(t *testing.T) {
|
||||
db := dbutil.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
s := &beaconstate.BeaconState{}
|
||||
s := &stateV0.BeaconState{}
|
||||
|
||||
aggregatorServer := &Server{
|
||||
HeadFetcher: &mock.ChainService{State: s},
|
||||
@@ -49,7 +49,7 @@ func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) {
|
||||
db := dbutil.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
s, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -73,7 +73,7 @@ func TestSubmitAggregateAndProof_IsAggregatorAndNoAtts(t *testing.T) {
|
||||
db := dbutil.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
s, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
s, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
Validators: []*ethpb.Validator{
|
||||
{PublicKey: pubKey(0)},
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed/operation"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
@@ -182,7 +182,7 @@ func (vs *Server) ProposeAttestation(ctx context.Context, att *ethpb.Attestation
|
||||
|
||||
go func() {
|
||||
ctx = trace.NewContext(context.Background(), trace.FromContext(ctx))
|
||||
attCopy := stateTrie.CopyAttestation(att)
|
||||
attCopy := stateV0.CopyAttestation(att)
|
||||
if err := vs.AttPool.SaveUnaggregatedAttestation(attCopy); err != nil {
|
||||
log.WithError(err).Error("Could not handle attestation in operations service")
|
||||
return
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
|
||||
mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
@@ -281,7 +281,7 @@ func TestAttestationDataAtSlot_HandlesFarAwayJustifiedEpoch(t *testing.T) {
|
||||
|
||||
func TestAttestationDataSlot_handlesInProgressRequest(t *testing.T) {
|
||||
s := &pbp2p.BeaconState{Slot: 100}
|
||||
state, err := beaconstate.InitializeFromProto(s)
|
||||
state, err := stateV0.InitializeFromProto(s)
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
chainService := &mock.ChainService{
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits"
|
||||
mockp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
|
||||
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
||||
dbpb "github.com/prysmaticlabs/prysm/proto/beacon/db"
|
||||
@@ -377,7 +377,7 @@ func TestProposer_PendingDeposits_OutsideEth1FollowWindow(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
BlockHash: bytesutil.PadTo([]byte("0x0"), 32),
|
||||
DepositRoot: make([]byte, 32),
|
||||
@@ -505,7 +505,7 @@ func TestProposer_PendingDeposits_FollowsCorrectEth1Block(t *testing.T) {
|
||||
votes = append(votes, vote)
|
||||
}
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
BlockHash: []byte("0x0"),
|
||||
DepositRoot: make([]byte, 32),
|
||||
@@ -716,7 +716,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanMax(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
BlockHash: bytesutil.PadTo([]byte("0x0"), 32),
|
||||
DepositRoot: make([]byte, 32),
|
||||
@@ -810,7 +810,7 @@ func TestProposer_PendingDeposits_CantReturnMoreThanDepositCount(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
BlockHash: bytesutil.PadTo([]byte("0x0"), 32),
|
||||
DepositRoot: make([]byte, 32),
|
||||
@@ -904,7 +904,7 @@ func TestProposer_DepositTrie_UtilizesCachedFinalizedDeposits(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
BlockHash: bytesutil.PadTo([]byte("0x0"), 32),
|
||||
DepositRoot: make([]byte, 32),
|
||||
@@ -1098,7 +1098,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(52, earliestValidTime+2, []byte("second")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("first"), DepositCount: 1},
|
||||
@@ -1133,7 +1133,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(52, earliestValidTime+2, []byte("second")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("earliest"), DepositCount: 1},
|
||||
@@ -1168,7 +1168,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(51, earliestValidTime+1, []byte("first")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("first"), DepositCount: 1},
|
||||
@@ -1204,7 +1204,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(51, earliestValidTime+1, []byte("first")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("before_range"), DepositCount: 1},
|
||||
@@ -1240,7 +1240,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(100, latestValidTime, []byte("latest")).
|
||||
InsertBlock(101, latestValidTime+1, []byte("after_range"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("first"), DepositCount: 1},
|
||||
@@ -1276,7 +1276,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(52, earliestValidTime+2, []byte("second")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("unknown"), DepositCount: 1},
|
||||
@@ -1310,7 +1310,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(49, earliestValidTime-1, []byte("before_range")).
|
||||
InsertBlock(101, latestValidTime+1, []byte("after_range"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1342,7 +1342,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(52, earliestValidTime+2, []byte("second")).
|
||||
InsertBlock(101, latestValidTime+1, []byte("after_range"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("before_range"), DepositCount: 1},
|
||||
@@ -1376,7 +1376,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(50, earliestValidTime, []byte("earliest")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{}})
|
||||
require.NoError(t, err)
|
||||
@@ -1406,7 +1406,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(50, earliestValidTime, []byte("earliest")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -1439,7 +1439,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(52, earliestValidTime+2, []byte("second")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("first"), DepositCount: 1},
|
||||
@@ -1474,7 +1474,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
InsertBlock(52, earliestValidTime+2, []byte("second")).
|
||||
InsertBlock(100, latestValidTime, []byte("latest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("no_new_deposits"), DepositCount: 0},
|
||||
@@ -1506,7 +1506,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
t.Run("only one block at earliest valid time - choose this block", func(t *testing.T) {
|
||||
p := mockPOW.NewPOWChain().InsertBlock(50, earliestValidTime, []byte("earliest"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("earliest"), DepositCount: 1},
|
||||
@@ -1540,7 +1540,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
// because of earliest block increment in the algorithm.
|
||||
InsertBlock(50, earliestValidTime+1, []byte("first"))
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("before_range"), DepositCount: 1},
|
||||
@@ -1579,7 +1579,7 @@ func TestProposer_Eth1Data_MajorityVote(t *testing.T) {
|
||||
depositCache, err := depositcache.New()
|
||||
require.NoError(t, err)
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: slot,
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{
|
||||
{BlockHash: []byte("earliest"), DepositCount: 1},
|
||||
@@ -1730,7 +1730,7 @@ func TestProposer_Deposits_ReturnsEmptyList_IfLatestEth1DataEqGenesisEth1Block(t
|
||||
GenesisEth1Block: height,
|
||||
}
|
||||
|
||||
beaconState, err := beaconstate.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
BlockHash: bytesutil.PadTo([]byte("0x0"), 32),
|
||||
DepositRoot: make([]byte, 32),
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -48,7 +48,7 @@ func BenchmarkProposerAtts_sortByProfitability(b *testing.B) {
|
||||
runner := func(atts []*ethpb.Attestation) {
|
||||
attsCopy := make(proposerAtts, len(atts))
|
||||
for i, att := range atts {
|
||||
attsCopy[i] = stateTrie.CopyAttestation(att)
|
||||
attsCopy[i] = stateV0.CopyAttestation(att)
|
||||
}
|
||||
attsCopy.sortByProfitability()
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -58,7 +58,7 @@ func TestWaitForActivation_ContextClosed(t *testing.T) {
|
||||
db := dbutil.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
beaconState, err := stateTrie.InitializeFromProto(&pbp2p.BeaconState{
|
||||
beaconState, err := stateV0.InitializeFromProto(&pbp2p.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: []*ethpb.Validator{},
|
||||
})
|
||||
@@ -151,7 +151,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
depositCache.InsertDeposit(ctx, deposit, 10 /*blockNum*/, 0, depositTrie.Root())
|
||||
trie, err := stateTrie.InitializeFromProtoUnsafe(beaconState)
|
||||
trie, err := stateV0.InitializeFromProtoUnsafe(beaconState)
|
||||
require.NoError(t, err)
|
||||
vs := &Server{
|
||||
BeaconDB: db,
|
||||
@@ -234,7 +234,7 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) {
|
||||
block := testutil.NewBeaconBlock()
|
||||
genesisRoot, err := block.Block.HashTreeRoot()
|
||||
require.NoError(t, err, "Could not get signing root")
|
||||
trie, err := stateTrie.InitializeFromProtoUnsafe(beaconState)
|
||||
trie, err := stateV0.InitializeFromProtoUnsafe(beaconState)
|
||||
require.NoError(t, err)
|
||||
vs := &Server{
|
||||
BeaconDB: db,
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
||||
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -43,7 +43,7 @@ func TestValidatorStatus_DepositedEth1(t *testing.T) {
|
||||
0: uint64(height),
|
||||
},
|
||||
}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{})
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(&pbp2p.BeaconState{})
|
||||
require.NoError(t, err)
|
||||
vs := &Server{
|
||||
BeaconDB: db,
|
||||
@@ -88,7 +88,7 @@ func TestValidatorStatus_Deposited(t *testing.T) {
|
||||
0: uint64(height),
|
||||
},
|
||||
}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
PublicKey: pubKey1,
|
||||
@@ -140,7 +140,7 @@ func TestValidatorStatus_PartiallyDeposited(t *testing.T) {
|
||||
0: uint64(height),
|
||||
},
|
||||
}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
PublicKey: pubKey1,
|
||||
@@ -272,7 +272,7 @@ func TestValidatorStatus_Active(t *testing.T) {
|
||||
WithdrawableEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
PublicKey: pubKey},
|
||||
}}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
|
||||
timestamp := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix()
|
||||
@@ -328,7 +328,7 @@ func TestValidatorStatus_Exiting(t *testing.T) {
|
||||
ExitEpoch: exitEpoch,
|
||||
WithdrawableEpoch: withdrawableEpoch},
|
||||
}}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
depData := ðpb.Deposit_Data{
|
||||
PublicKey: pubKey,
|
||||
@@ -388,7 +388,7 @@ func TestValidatorStatus_Slashing(t *testing.T) {
|
||||
PublicKey: pubKey,
|
||||
WithdrawableEpoch: epoch + 1},
|
||||
}}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(state)
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(state)
|
||||
require.NoError(t, err)
|
||||
depData := ðpb.Deposit_Data{
|
||||
PublicKey: pubKey,
|
||||
@@ -498,7 +498,7 @@ func TestValidatorStatus_UnknownStatus(t *testing.T) {
|
||||
depositCache, err := depositcache.New()
|
||||
require.NoError(t, err)
|
||||
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
Slot: 0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -525,7 +525,7 @@ func TestActivationStatus_OK(t *testing.T) {
|
||||
deposits, _, err := testutil.DeterministicDepositsAndKeys(4)
|
||||
require.NoError(t, err)
|
||||
pubKeys := [][]byte{deposits[0].Data.PublicKey, deposits[1].Data.PublicKey, deposits[2].Data.PublicKey, deposits[3].Data.PublicKey}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
Slot: 4000,
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -726,7 +726,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) {
|
||||
deposits[4].Data.PublicKey,
|
||||
deposits[5].Data.PublicKey,
|
||||
}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
|
||||
Slot: 4000,
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -865,7 +865,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(beaconState)
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(beaconState)
|
||||
require.NoError(t, err)
|
||||
block := testutil.NewBeaconBlock()
|
||||
genesisRoot, err := block.Block.HashTreeRoot()
|
||||
@@ -941,7 +941,7 @@ func TestValidatorStatus_Invalid(t *testing.T) {
|
||||
0: uint64(height),
|
||||
},
|
||||
}
|
||||
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{})
|
||||
stateObj, err := stateV0.InitializeFromProtoUnsafe(&pbp2p.BeaconState{})
|
||||
require.NoError(t, err)
|
||||
vs := &Server{
|
||||
BeaconDB: db,
|
||||
|
||||
@@ -19,7 +19,7 @@ go_library(
|
||||
"types.go",
|
||||
"validator_getters.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/state",
|
||||
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0",
|
||||
visibility = [
|
||||
"//beacon-chain:__subpackages__",
|
||||
"//fuzz:__pkg__",
|
||||
@@ -1,4 +1,4 @@
|
||||
package state
|
||||
package stateV0
|
||||
|
||||
import (
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
@@ -37,4 +37,4 @@
|
||||
// Although it is technically possible to remove the short-circuit conditions
|
||||
// from the external function, that would require every read to obtain a lock
|
||||
// even if the data was not present, leading to potential slowdowns.
|
||||
package state
|
||||
package stateV0
|
||||
@@ -1,4 +1,4 @@
|
||||
package state
|
||||
package stateV0
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package state
|
||||
package stateV0
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
@@ -1,4 +1,4 @@
|
||||
package state
|
||||
package stateV0
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package state
|
||||
package stateV0
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user