mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Move State Protos Into V2 Namespace (#9257)
* move state protos * regen ssz * edit v1 code * fix imports * building * beacon chain builds * validator and shared builds * fuzz builds * changes * spectest builds * tools build * remove import cycle * generate ssz * pcli * gaz * kafka * gaz
This commit is contained in:
@@ -43,10 +43,10 @@ go_library(
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/eth/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
@@ -107,7 +107,6 @@ go_test(
|
||||
"//beacon-chain/powchain:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
@@ -158,9 +157,9 @@ go_test(
|
||||
"//beacon-chain/db/testing:go_default_library",
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/powchain:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/event:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/copyutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -55,7 +55,7 @@ type HeadFetcher interface {
|
||||
|
||||
// ForkFetcher retrieves the current fork information of the Ethereum beacon chain.
|
||||
type ForkFetcher interface {
|
||||
CurrentFork() *pb.Fork
|
||||
CurrentFork() *statepb.Fork
|
||||
}
|
||||
|
||||
// CanonicalFetcher retrieves the current chain's canonical information.
|
||||
@@ -239,12 +239,12 @@ func (s *Service) GenesisValidatorRoot() [32]byte {
|
||||
}
|
||||
|
||||
// CurrentFork retrieves the latest fork information of the beacon chain.
|
||||
func (s *Service) CurrentFork() *pb.Fork {
|
||||
func (s *Service) CurrentFork() *statepb.Fork {
|
||||
s.headLock.RLock()
|
||||
defer s.headLock.RUnlock()
|
||||
|
||||
if !s.hasHeadState() {
|
||||
return &pb.Fork{
|
||||
return &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -105,7 +105,7 @@ func TestPrevJustifiedCheckpt_GenesisRootOk(t *testing.T) {
|
||||
|
||||
func TestHeadSlot_CanRetrieve(t *testing.T) {
|
||||
c := &Service{}
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{})
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{})
|
||||
require.NoError(t, err)
|
||||
c.head = &head{slot: 100, state: s}
|
||||
assert.Equal(t, types.Slot(100), c.HeadSlot())
|
||||
@@ -127,7 +127,7 @@ func TestHeadRoot_UseDB(t *testing.T) {
|
||||
br, err := b.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveBlock(context.Background(), wrapper.WrappedPhase0SignedBeaconBlock(b)))
|
||||
require.NoError(t, beaconDB.SaveStateSummary(context.Background(), &pb.StateSummary{Root: br[:]}))
|
||||
require.NoError(t, beaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Root: br[:]}))
|
||||
require.NoError(t, beaconDB.SaveHeadBlockRoot(context.Background(), br))
|
||||
r, err := c.HeadRoot(context.Background())
|
||||
require.NoError(t, err)
|
||||
@@ -137,7 +137,7 @@ func TestHeadRoot_UseDB(t *testing.T) {
|
||||
func TestHeadBlock_CanRetrieve(t *testing.T) {
|
||||
b := testutil.NewBeaconBlock()
|
||||
b.Block.Slot = 1
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{})
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{block: wrapper.WrappedPhase0SignedBeaconBlock(b), state: s}
|
||||
@@ -148,7 +148,7 @@ func TestHeadBlock_CanRetrieve(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHeadState_CanRetrieve(t *testing.T) {
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{Slot: 2, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 2, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{state: s}
|
||||
@@ -164,8 +164,8 @@ func TestGenesisTime_CanRetrieve(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCurrentFork_CanRetrieve(t *testing.T) {
|
||||
f := &pb.Fork{Epoch: 999}
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{Fork: f})
|
||||
f := &statepb.Fork{Epoch: 999}
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{Fork: f})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{state: s}
|
||||
@@ -175,7 +175,7 @@ func TestCurrentFork_CanRetrieve(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCurrentFork_NilHeadSTate(t *testing.T) {
|
||||
f := &pb.Fork{
|
||||
f := &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
}
|
||||
@@ -190,7 +190,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 := v1.InitializeFromProto(&pb.BeaconState{GenesisValidatorsRoot: []byte{'a'}})
|
||||
s, err := v1.InitializeFromProto(&statepb.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")
|
||||
@@ -204,7 +204,7 @@ func TestHeadETH1Data_Nil(t *testing.T) {
|
||||
|
||||
func TestHeadETH1Data_CanRetrieve(t *testing.T) {
|
||||
d := ðpb.Eth1Data{DepositCount: 999}
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{Eth1Data: d})
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{Eth1Data: d})
|
||||
require.NoError(t, err)
|
||||
c := &Service{}
|
||||
c.head = &head{state: s}
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -60,7 +60,7 @@ func TestSaveHead_Different(t *testing.T) {
|
||||
headState, err := testutil.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, headState.SetSlot(1))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &pb.StateSummary{Slot: 1, Root: newRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1, Root: newRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(context.Background(), headState, newRoot))
|
||||
require.NoError(t, service.saveHead(context.Background(), newRoot))
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestSaveHead_Different_Reorg(t *testing.T) {
|
||||
headState, err := testutil.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, headState.SetSlot(1))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &pb.StateSummary{Slot: 1, Root: newRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1, Root: newRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(context.Background(), headState, newRoot))
|
||||
require.NoError(t, service.saveHead(context.Background(), newRoot))
|
||||
|
||||
@@ -127,7 +127,7 @@ func TestCacheJustifiedStateBalances_CanCache(t *testing.T) {
|
||||
|
||||
state, _ := testutil.DeterministicGenesisState(t, 100)
|
||||
r := [32]byte{'a'}
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &pb.StateSummary{Root: r[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &statepb.StateSummary{Root: r[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(context.Background(), state, r))
|
||||
require.NoError(t, service.cacheJustifiedStateBalances(context.Background(), r))
|
||||
require.DeepEqual(t, service.getJustifiedBalances(), state.Balances(), "Incorrect justified balances")
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
@@ -25,7 +25,7 @@ func TestReportEpochMetrics_BadAttestation(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
h, err := testutil.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, h.AppendCurrentEpochAttestations(&pb.PendingAttestation{InclusionDelay: 0}))
|
||||
require.NoError(t, h.AppendCurrentEpochAttestations(&statepb.PendingAttestation{InclusionDelay: 0}))
|
||||
err = reportEpochMetrics(context.Background(), s, h)
|
||||
require.ErrorContains(t, "attestation with inclusion delay of 0", err)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func TestReportEpochMetrics_SlashedValidatorOutOfBound(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
v.Slashed = true
|
||||
require.NoError(t, h.UpdateValidatorAtIndex(0, v))
|
||||
require.NoError(t, h.AppendCurrentEpochAttestations(&pb.PendingAttestation{InclusionDelay: 1, Data: testutil.HydrateAttestationData(ð.AttestationData{})}))
|
||||
require.NoError(t, h.AppendCurrentEpochAttestations(&statepb.PendingAttestation{InclusionDelay: 1, Data: testutil.HydrateAttestationData(ð.AttestationData{})}))
|
||||
err = reportEpochMetrics(context.Background(), h, h)
|
||||
require.ErrorContains(t, "slot 0 out of bounds", err)
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -61,7 +61,7 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
s, err = testutil.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
err = s.SetFork(&pb.Fork{
|
||||
err = s.SetFork(&statepb.Fork{
|
||||
Epoch: 0,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
@@ -186,7 +186,7 @@ func TestStore_SaveCheckpointState(t *testing.T) {
|
||||
r = bytesutil.ToBytes32([]byte{'A'})
|
||||
cp1 := ðpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'A'}, 32)}
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, bytesutil.ToBytes32([]byte{'A'})))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)}))
|
||||
|
||||
s1, err := service.getAttPreState(ctx, cp1)
|
||||
require.NoError(t, err)
|
||||
@@ -194,7 +194,7 @@ func TestStore_SaveCheckpointState(t *testing.T) {
|
||||
|
||||
cp2 := ðpb.Checkpoint{Epoch: 2, Root: bytesutil.PadTo([]byte{'B'}, 32)}
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, bytesutil.ToBytes32([]byte{'B'})))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: bytesutil.PadTo([]byte{'B'}, 32)}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'B'}, 32)}))
|
||||
s2, err := service.getAttPreState(ctx, cp2)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 2*params.BeaconConfig().SlotsPerEpoch, s2.Slot(), "Unexpected state slot")
|
||||
@@ -218,7 +218,7 @@ func TestStore_SaveCheckpointState(t *testing.T) {
|
||||
service.prevFinalizedCheckpt = ðpb.Checkpoint{Root: r[:]}
|
||||
cp3 := ðpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'C'}, 32)}
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, s, bytesutil.ToBytes32([]byte{'C'})))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: bytesutil.PadTo([]byte{'C'}, 32)}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'C'}, 32)}))
|
||||
s3, err := service.getAttPreState(ctx, cp3)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, s.Slot(), s3.Slot(), "Unexpected state slot")
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -279,7 +279,7 @@ func (s *Service) handleBlockAfterBatchVerify(ctx context.Context, signed interf
|
||||
if err := s.insertBlockToForkChoiceStore(ctx, b, blockRoot, fCheckpoint, jCheckpoint); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{
|
||||
if err := s.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{
|
||||
Slot: signed.Block().Slot(),
|
||||
Root: blockRoot[:],
|
||||
}); err != nil {
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -60,10 +60,10 @@ func TestStore_OnBlock(t *testing.T) {
|
||||
assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(random)))
|
||||
randomParentRoot, err := random.Block.HashTreeRoot()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: st.Slot(), Root: randomParentRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: st.Slot(), Root: randomParentRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, st.Copy(), randomParentRoot))
|
||||
randomParentRoot2 := roots[1]
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, st.Copy(), bytesutil.ToBytes32(randomParentRoot2)))
|
||||
|
||||
tests := []struct {
|
||||
@@ -256,7 +256,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) {
|
||||
service, err := NewService(ctx, cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
|
||||
require.NoError(t, err)
|
||||
|
||||
genesisStateRoot := [32]byte{}
|
||||
@@ -273,7 +273,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) {
|
||||
b := testutil.NewBeaconBlock()
|
||||
b.Block.Slot = 1
|
||||
b.Block.ParentRoot = gRoot[:]
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Slot: 1, Root: gRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: gRoot[:]}))
|
||||
require.NoError(t, service.cfg.StateGen.SaveState(ctx, gRoot, s))
|
||||
require.NoError(t, service.verifyBlkPreState(ctx, wrapper.WrappedPhase0BeaconBlock(b.Block)))
|
||||
}
|
||||
@@ -308,9 +308,9 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) {
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
|
||||
b.Block.ParentRoot = gRoot[:]
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{Slot: 1})
|
||||
s, err := v1.InitializeFromProto(&statepb.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.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: gRoot[:]}))
|
||||
require.NoError(t, service.cfg.StateGen.SaveState(ctx, gRoot, s))
|
||||
require.NoError(t, service.verifyBlkPreState(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b).Block()))
|
||||
}
|
||||
@@ -763,7 +763,7 @@ func TestFinalizedImpliesNewJustified(t *testing.T) {
|
||||
service, err := NewService(ctx, &Config{BeaconDB: beaconDB, StateGen: stategen.New(beaconDB), ForkChoiceStore: protoarray.New(0, 0, [32]byte{})})
|
||||
require.NoError(t, err)
|
||||
service.justifiedCheckpt = test.args.cachedCheckPoint
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: bytesutil.PadTo(test.want.Root, 32)}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: bytesutil.PadTo(test.want.Root, 32)}))
|
||||
genesisState, err := testutil.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, genesisState, bytesutil.ToBytes32(test.want.Root)))
|
||||
@@ -878,7 +878,7 @@ func TestUpdateJustifiedInitSync(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(gBlk)))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveGenesisBlockRoot(ctx, gRoot))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &pb.StateSummary{Root: gRoot[:]}))
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: gRoot[:]}))
|
||||
beaconState, _ := testutil.DeterministicGenesisState(t, 32)
|
||||
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, beaconState, gRoot))
|
||||
service.genesisRoot = gRoot
|
||||
|
||||
@@ -21,13 +21,13 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
protodb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/event"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -507,7 +507,7 @@ func BenchmarkHasBlockForkChoiceStore(b *testing.B) {
|
||||
block := ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}}
|
||||
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)}}
|
||||
bs := &statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}}
|
||||
beaconState, err := v1.InitializeFromProto(bs)
|
||||
require.NoError(b, err)
|
||||
require.NoError(b, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wrapper.WrappedPhase0SignedBeaconBlock(block).Block(), r, beaconState))
|
||||
|
||||
@@ -20,9 +20,9 @@ go_library(
|
||||
"//beacon-chain/forkchoice/protoarray:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/event:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -19,10 +19,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/event"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -42,7 +42,7 @@ type ChainService struct {
|
||||
Genesis time.Time
|
||||
ValidatorsRoot [32]byte
|
||||
CanonicalRoots map[[32]byte]bool
|
||||
Fork *pb.Fork
|
||||
Fork *statepb.Fork
|
||||
ETH1Data *ethpb.Eth1Data
|
||||
DB db.Database
|
||||
stateNotifier statefeed.Notifier
|
||||
@@ -259,7 +259,7 @@ func (s *ChainService) HeadState(context.Context) (iface.BeaconState, error) {
|
||||
}
|
||||
|
||||
// CurrentFork mocks HeadState method in chain service.
|
||||
func (s *ChainService) CurrentFork() *pb.Fork {
|
||||
func (s *ChainService) CurrentFork() *statepb.Fork {
|
||||
return s.Fork
|
||||
}
|
||||
|
||||
|
||||
2
beacon-chain/cache/BUILD.bazel
vendored
2
beacon-chain/cache/BUILD.bazel
vendored
@@ -63,8 +63,8 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
|
||||
8
beacon-chain/cache/checkpoint_state_test.go
vendored
8
beacon-chain/cache/checkpoint_state_test.go
vendored
@@ -6,8 +6,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
st, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:],
|
||||
Slot: 64,
|
||||
})
|
||||
@@ -43,7 +43,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
|
||||
}
|
||||
|
||||
cp2 := ðpb.Checkpoint{Epoch: 2, Root: bytesutil.PadTo([]byte{'B'}, 32)}
|
||||
st2, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
st2, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
st, err := v1.InitializeFromProto(&statepb.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
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"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 = v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err = v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Slot: 10,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -27,9 +27,9 @@ go_library(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
@@ -76,9 +76,9 @@ go_test(
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/aggregation:go_default_library",
|
||||
"//shared/aggregation/attestations:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -205,7 +205,7 @@ func ProcessAttestationNoVerifySignature(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pendingAtt := &pb.PendingAttestation{
|
||||
pendingAtt := &statepb.PendingAttestation{
|
||||
Data: data,
|
||||
AggregationBits: att.AggregationBits,
|
||||
InclusionDelay: beaconState.Slot() - s,
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -33,7 +33,7 @@ func TestProcessAttestationNoVerifySignature_BeaconFuzzIssue78(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
spb := &pb.BeaconState{}
|
||||
spb := &statepb.BeaconState{}
|
||||
if err := spb.UnmarshalSSZ(stateData); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func TestVerifyAttestationNoVerifySignature_IncorrectSourceEpoch(t *testing.T) {
|
||||
ckp := beaconState.CurrentJustifiedCheckpoint()
|
||||
copy(ckp.Root, "hello-world")
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
err = blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att)
|
||||
assert.NotEqual(t, nil, err)
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/aggregation"
|
||||
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
@@ -69,7 +69,7 @@ func TestProcessAttestations_NeitherCurrentNorPrevEpoch(t *testing.T) {
|
||||
pfc := beaconState.PreviousJustifiedCheckpoint()
|
||||
pfc.Root = []byte("hello-world")
|
||||
require.NoError(t, beaconState.SetPreviousJustifiedCheckpoint(pfc))
|
||||
require.NoError(t, beaconState.AppendPreviousEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
want := fmt.Sprintf(
|
||||
"expected target epoch (%d) to be the previous epoch (%d) or the current epoch (%d)",
|
||||
@@ -102,7 +102,7 @@ func TestProcessAttestations_CurrentEpochFFGDataMismatches(t *testing.T) {
|
||||
cfc := beaconState.CurrentJustifiedCheckpoint()
|
||||
cfc.Root = []byte("hello-world")
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
want := "source check point not equal to current justified checkpoint"
|
||||
_, err := blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b))
|
||||
@@ -140,7 +140,7 @@ func TestProcessAttestations_PrevEpochFFGDataMismatches(t *testing.T) {
|
||||
pfc := beaconState.PreviousJustifiedCheckpoint()
|
||||
pfc.Root = []byte("hello-world")
|
||||
require.NoError(t, beaconState.SetPreviousJustifiedCheckpoint(pfc))
|
||||
require.NoError(t, beaconState.AppendPreviousEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
want := "source check point not equal to previous justified checkpoint"
|
||||
_, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b))
|
||||
@@ -176,7 +176,7 @@ func TestProcessAttestations_InvalidAggregationBitsLength(t *testing.T) {
|
||||
cfc := beaconState.CurrentJustifiedCheckpoint()
|
||||
cfc.Root = []byte("hello-world")
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
expected := "failed to verify aggregation bitfield: wanted participants bitfield length 3, got: 4"
|
||||
_, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b))
|
||||
@@ -201,7 +201,7 @@ func TestProcessAttestations_OK(t *testing.T) {
|
||||
cfc := beaconState.CurrentJustifiedCheckpoint()
|
||||
cfc.Root = mockRoot[:]
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex)
|
||||
require.NoError(t, err)
|
||||
@@ -243,7 +243,7 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) {
|
||||
cfc := beaconState.CurrentJustifiedCheckpoint()
|
||||
cfc.Root = bytesutil.PadTo([]byte("hello-world"), 32)
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex)
|
||||
require.NoError(t, err)
|
||||
@@ -306,7 +306,7 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) {
|
||||
cfc := beaconState.CurrentJustifiedCheckpoint()
|
||||
cfc.Root = mockRoot[:]
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex)
|
||||
require.NoError(t, err)
|
||||
@@ -396,7 +396,7 @@ func TestProcessAttestationsNoVerify_OK(t *testing.T) {
|
||||
ckp := beaconState.CurrentJustifiedCheckpoint()
|
||||
copy(ckp.Root, "hello-world")
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
_, err = blocks.ProcessAttestationNoVerifySignature(context.TODO(), beaconState, att)
|
||||
assert.NoError(t, err)
|
||||
@@ -427,7 +427,7 @@ func TestVerifyAttestationNoVerifySignature_OK(t *testing.T) {
|
||||
ckp := beaconState.CurrentJustifiedCheckpoint()
|
||||
copy(ckp.Root, "hello-world")
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
err = blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att)
|
||||
assert.NoError(t, err)
|
||||
@@ -453,7 +453,7 @@ func TestVerifyAttestationNoVerifySignature_BadAttIdx(t *testing.T) {
|
||||
ckp := beaconState.CurrentJustifiedCheckpoint()
|
||||
copy(ckp.Root, "hello-world")
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(ckp))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
err := blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att)
|
||||
require.ErrorContains(t, "committee index 100 >= committee count 1", err)
|
||||
}
|
||||
@@ -467,7 +467,7 @@ func TestConvertToIndexed_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Slot: 5,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -525,10 +525,10 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Slot: 5,
|
||||
Validators: validators,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
Epoch: 0,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
@@ -676,7 +676,7 @@ func TestVerifyAttestations_HandlesPlannedFork(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, st.SetSlot(35))
|
||||
require.NoError(t, st.SetValidators(validators))
|
||||
require.NoError(t, st.SetFork(&pb.Fork{
|
||||
require.NoError(t, st.SetFork(&statepb.Fork{
|
||||
Epoch: 1,
|
||||
CurrentVersion: []byte{0, 1, 2, 3},
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
@@ -803,7 +803,7 @@ func TestRetrieveAttestationSignatureSet_AcrossFork(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, st.SetSlot(5))
|
||||
require.NoError(t, st.SetValidators(validators))
|
||||
require.NoError(t, st.SetFork(&pb.Fork{Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: []byte{0, 1, 1, 1}}))
|
||||
require.NoError(t, st.SetFork(&statepb.Fork{Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: []byte{0, 1, 1, 1}}))
|
||||
|
||||
comm1, err := helpers.BeaconCommitteeFromState(st, 1 /*slot*/, 0 /*committeeIndex*/)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -47,7 +47,7 @@ func TestProcessAttesterSlashings_DataNotSlashable(t *testing.T) {
|
||||
var registry []*ethpb.Validator
|
||||
currentSlot := types.Slot(0)
|
||||
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: currentSlot,
|
||||
})
|
||||
@@ -66,7 +66,7 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T)
|
||||
var registry []*ethpb.Validator
|
||||
currentSlot := types.Slot(0)
|
||||
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: currentSlot,
|
||||
})
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
ctx := context.Background()
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
att := ð.Attestation{}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -34,7 +34,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessBlockHeader_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
block := ð.SignedBeaconBlock{}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -106,7 +106,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) {
|
||||
for i := 0; i < 100000; i++ {
|
||||
fuzzer.Fuzz(eth1data)
|
||||
fuzzer.Fuzz(&stateVotes)
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Eth1DataVotes: stateVotes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -118,7 +118,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
block := ð.BeaconBlock{}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -133,7 +133,7 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessRandao_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
b := ð.SignedBeaconBlock{}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -150,7 +150,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
blockBody := ð.BeaconBlockBody{}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -167,7 +167,7 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessProposerSlashings_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
p := ð.ProposerSlashing{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -184,7 +184,7 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzVerifyProposerSlashing_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
proposerSlashing := ð.ProposerSlashing{}
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
@@ -198,7 +198,7 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessAttesterSlashings_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
a := ð.AttesterSlashing{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -215,7 +215,7 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
attesterSlashing := ð.AttesterSlashing{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -252,7 +252,7 @@ func TestFuzzslashableAttesterIndices_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessAttestations_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
b := ð.SignedBeaconBlock{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -269,7 +269,7 @@ func TestFuzzProcessAttestations_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
b := ð.SignedBeaconBlock{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -286,7 +286,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessAttestation_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
attestation := ð.Attestation{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -303,7 +303,7 @@ func TestFuzzProcessAttestation_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
idxAttestation := ð.IndexedAttestation{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -318,7 +318,7 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzVerifyAttestation_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
attestation := ð.Attestation{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -333,7 +333,7 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessDeposits_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
deposits := make([]*eth.Deposit, 100)
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -352,7 +352,7 @@ func TestFuzzProcessDeposits_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
deposit := ð.Deposit{}
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -370,7 +370,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessDeposit_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
deposit := ð.Deposit{}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -387,7 +387,7 @@ func TestFuzzProcessDeposit_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzverifyDeposit_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
deposit := ð.Deposit{}
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
@@ -401,7 +401,7 @@ func TestFuzzverifyDeposit_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessVoluntaryExits_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
e := ð.SignedVoluntaryExit{}
|
||||
ctx := context.Background()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -418,7 +418,7 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) {
|
||||
|
||||
func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := &pb.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
e := ð.SignedVoluntaryExit{}
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(state)
|
||||
@@ -437,7 +437,7 @@ func TestFuzzVerifyExit_10000(t *testing.T) {
|
||||
ve := ð.SignedVoluntaryExit{}
|
||||
val, err := v1.NewValidator(ðpb.Validator{})
|
||||
_ = err
|
||||
fork := &pb.Fork{}
|
||||
fork := &statepb.Fork{}
|
||||
var slot types.Slot
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/depositutil"
|
||||
@@ -258,7 +258,7 @@ func verifyDepositDataWithDomain(ctx context.Context, deps []*ethpb.Deposit, dom
|
||||
}
|
||||
pks[i] = dpk
|
||||
sigs[i] = dep.Data.Signature
|
||||
depositMessage := &pb.DepositMessage{
|
||||
depositMessage := &statepb.DepositMessage{
|
||||
PublicKey: dep.Data.PublicKey,
|
||||
WithdrawalCredentials: dep.Data.WithdrawalCredentials,
|
||||
Amount: dep.Data.Amount,
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -40,11 +40,11 @@ func TestProcessDeposits_SameValidatorMultipleDepositsSameBlock(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
},
|
||||
@@ -80,7 +80,7 @@ func TestProcessDeposits_MerkleBranchFailsVerification(t *testing.T) {
|
||||
Deposits: []*ethpb.Deposit{deposit},
|
||||
},
|
||||
}
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
DepositRoot: []byte{0},
|
||||
BlockHash: []byte{1},
|
||||
@@ -111,11 +111,11 @@ func TestProcessDeposits_AddsNewValidatorDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
},
|
||||
@@ -174,7 +174,7 @@ func TestProcessDeposits_RepeatedDeposit_IncreasesValidatorBalance(t *testing.T)
|
||||
}
|
||||
balances := []uint64{0, 50}
|
||||
root := depositTrie.Root()
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: ðpb.Eth1Data{
|
||||
@@ -202,11 +202,11 @@ func TestProcessDeposit_AddsNewValidatorDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
},
|
||||
@@ -244,11 +244,11 @@ func TestProcessDeposit_SkipsInvalidDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
},
|
||||
@@ -299,11 +299,11 @@ func TestPreGenesisDeposits_SkipInvalidDeposit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
balances := []uint64{0}
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Balances: balances,
|
||||
Eth1Data: eth1Data,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
},
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/copyutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -71,7 +71,7 @@ func TestEth1DataHasEnoughSupport(t *testing.T) {
|
||||
c.EpochsPerEth1VotingPeriod = tt.votingPeriodLength
|
||||
params.OverrideBeaconConfig(c)
|
||||
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Eth1DataVotes: tt.stateVotes,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -161,7 +161,7 @@ func TestAreEth1DataEqual(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessEth1Data_SetsCorrectly(t *testing.T) {
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Eth1DataVotes: []*ethpb.Eth1Data{},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ func ProcessVoluntaryExits(
|
||||
func VerifyExitAndSignature(
|
||||
validator iface.ReadOnlyValidator,
|
||||
currentSlot types.Slot,
|
||||
fork *pb.Fork,
|
||||
fork *statepb.Fork,
|
||||
signed *ethpb.SignedVoluntaryExit,
|
||||
genesisRoot []byte,
|
||||
) error {
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -31,7 +31,7 @@ func TestProcessVoluntaryExits_NotActiveLongEnoughToExit(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
},
|
||||
}
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: 10,
|
||||
})
|
||||
@@ -61,7 +61,7 @@ func TestProcessVoluntaryExits_ExitAlreadySubmitted(t *testing.T) {
|
||||
ExitEpoch: 10,
|
||||
},
|
||||
}
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: 0,
|
||||
})
|
||||
@@ -93,9 +93,9 @@ func TestProcessVoluntaryExits_AppliesCorrectStatus(t *testing.T) {
|
||||
ActivationEpoch: 0,
|
||||
},
|
||||
}
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
},
|
||||
|
||||
@@ -6,9 +6,8 @@ import (
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
@@ -20,7 +19,7 @@ import (
|
||||
func TestVerifyProposerSlashing_BeaconFuzzIssue91(t *testing.T) {
|
||||
file, err := ioutil.ReadFile("testdata/beaconfuzz_91_beacon.ssz")
|
||||
require.NoError(t, err)
|
||||
rawState := &pb.BeaconState{}
|
||||
rawState := &statepb.BeaconState{}
|
||||
err = rawState.UnmarshalSSZ(file)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -118,7 +118,7 @@ func TestProcessProposerSlashings_ValidatorNotSlashable(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Slot: currentSlot,
|
||||
})
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -27,7 +27,7 @@ func TestProcessRandao_IncorrectProposerFailsVerification(t *testing.T) {
|
||||
binary.LittleEndian.PutUint64(buf, uint64(epoch))
|
||||
domain, err := helpers.Domain(beaconState.Fork(), epoch, params.BeaconConfig().DomainRandao, beaconState.GenesisValidatorRoot())
|
||||
require.NoError(t, err)
|
||||
root, err := (&pb.SigningData{ObjectRoot: buf, Domain: domain}).HashTreeRoot()
|
||||
root, err := (&statepb.SigningData{ObjectRoot: buf, Domain: domain}).HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
// We make the previous validator's index sign the message instead of the proposer.
|
||||
epochSignature := privKeys[proposerIdx-1].Sign(root[:])
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -21,7 +21,7 @@ func signatureSet(signedData, pub, signature, domain []byte) (*bls.SignatureSet,
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert bytes to public key")
|
||||
}
|
||||
signingData := &pb.SigningData{
|
||||
signingData := &statepb.SigningData{
|
||||
ObjectRoot: signedData,
|
||||
Domain: domain,
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ go_library(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/copyutil:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
@@ -36,8 +36,8 @@ go_test(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/copyutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
@@ -56,7 +56,7 @@ func (s sortableIndices) Less(i, j int) bool {
|
||||
// Note: ``get_total_balance`` returns ``EFFECTIVE_BALANCE_INCREMENT`` Gwei minimum to avoid divisions by zero.
|
||||
// """
|
||||
// return get_total_balance(state, get_unslashed_attesting_indices(state, attestations))
|
||||
func AttestingBalance(state iface.ReadOnlyBeaconState, atts []*pb.PendingAttestation) (uint64, error) {
|
||||
func AttestingBalance(state iface.ReadOnlyBeaconState, atts []*statepb.PendingAttestation) (uint64, error) {
|
||||
indices, err := UnslashedAttestingIndices(state, atts)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "could not get attesting indices")
|
||||
@@ -378,7 +378,7 @@ func ProcessHistoricalRootsUpdate(state iface.BeaconState) (iface.BeaconState, e
|
||||
// Set historical root accumulator.
|
||||
epochsPerHistoricalRoot := params.BeaconConfig().SlotsPerHistoricalRoot.DivSlot(params.BeaconConfig().SlotsPerEpoch)
|
||||
if nextEpoch.Mod(uint64(epochsPerHistoricalRoot)) == 0 {
|
||||
historicalBatch := &pb.HistoricalBatch{
|
||||
historicalBatch := &statepb.HistoricalBatch{
|
||||
BlockRoots: state.BlockRoots(),
|
||||
StateRoots: state.StateRoots(),
|
||||
}
|
||||
@@ -461,7 +461,7 @@ func ProcessFinalUpdates(state iface.BeaconState) (iface.BeaconState, error) {
|
||||
// for a in attestations:
|
||||
// output = output.union(get_attesting_indices(state, a.data, a.aggregation_bits))
|
||||
// return set(filter(lambda index: not state.validators[index].slashed, output))
|
||||
func UnslashedAttestingIndices(state iface.ReadOnlyBeaconState, atts []*pb.PendingAttestation) ([]types.ValidatorIndex, error) {
|
||||
func UnslashedAttestingIndices(state iface.ReadOnlyBeaconState, atts []*statepb.PendingAttestation) ([]types.ValidatorIndex, error) {
|
||||
var setIndices []types.ValidatorIndex
|
||||
seen := make(map[uint64]bool)
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
|
||||
fuzz "github.com/google/gofuzz"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
func TestFuzzFinalUpdates_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
base := ðereum_beacon_p2p_v1.BeaconState{}
|
||||
base := &statepb.BeaconState{}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
fuzzer.Fuzz(base)
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -21,9 +21,9 @@ import (
|
||||
|
||||
func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
|
||||
// Generate 2 attestations.
|
||||
atts := make([]*pb.PendingAttestation, 2)
|
||||
atts := make([]*statepb.PendingAttestation, 2)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{Source: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
Target: ðpb.Checkpoint{Epoch: 0, Root: make([]byte, 32)},
|
||||
},
|
||||
@@ -39,7 +39,7 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
}
|
||||
@@ -68,9 +68,9 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
|
||||
|
||||
func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
|
||||
// Generate 5 of the same attestations.
|
||||
atts := make([]*pb.PendingAttestation, 5)
|
||||
atts := make([]*statepb.PendingAttestation, 5)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{Source: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
Target: ðpb.Checkpoint{Epoch: 0}},
|
||||
AggregationBits: bitfield.Bitlist{0x00, 0xFF, 0xFF, 0xFF},
|
||||
@@ -85,7 +85,7 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
|
||||
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
|
||||
}
|
||||
}
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
}
|
||||
@@ -105,9 +105,9 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
|
||||
func TestAttestingBalance_CorrectBalance(t *testing.T) {
|
||||
helpers.ClearCache()
|
||||
// Generate 2 attestations.
|
||||
atts := make([]*pb.PendingAttestation, 2)
|
||||
atts := make([]*statepb.PendingAttestation, 2)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
Source: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
@@ -128,7 +128,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) {
|
||||
}
|
||||
balances[i] = params.BeaconConfig().MaxEffectiveBalance
|
||||
}
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 2,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
|
||||
@@ -145,7 +145,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessSlashings_NotSlashed(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: []*ethpb.Validator{{Slashed: true}},
|
||||
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
|
||||
@@ -161,11 +161,11 @@ func TestProcessSlashings_NotSlashed(t *testing.T) {
|
||||
|
||||
func TestProcessSlashings_SlashedLess(t *testing.T) {
|
||||
tests := []struct {
|
||||
state *pb.BeaconState
|
||||
state *statepb.BeaconState
|
||||
want uint64
|
||||
}{
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
@@ -179,7 +179,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
|
||||
want: uint64(31000000000), // 32 * 1e9 - 1000000000
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
@@ -195,7 +195,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
|
||||
want: uint64(32000000000), // 32 * 1e9 - 500000000
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
@@ -211,7 +211,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
|
||||
want: uint64(31000000000), // 32 * 1e9 - 1000000000
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
@@ -277,7 +277,7 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
|
||||
Validators: []*ethpb.Validator{
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookahead},
|
||||
@@ -299,7 +299,7 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessRegistryUpdates_EligibleToActivate(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 6, Root: make([]byte, 32)},
|
||||
}
|
||||
@@ -331,7 +331,7 @@ func TestProcessRegistryUpdates_EligibleToActivate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
|
||||
Validators: []*ethpb.Validator{
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookahead,
|
||||
@@ -351,7 +351,7 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessRegistryUpdates_ValidatorsEjected(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -378,7 +378,7 @@ func TestProcessRegistryUpdates_CanExits(t *testing.T) {
|
||||
e := types.Epoch(5)
|
||||
exitEpoch := helpers.ActivationExitEpoch(e)
|
||||
minWithdrawalDelay := params.BeaconConfig().MinValidatorWithdrawabilityDelay
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(e)),
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
|
||||
@@ -18,8 +18,8 @@ go_library(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/mathutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
@@ -45,8 +45,8 @@ go_test(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/mathutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/traceutil"
|
||||
@@ -69,7 +69,7 @@ func ProcessAttestations(
|
||||
}
|
||||
|
||||
// AttestedCurrentEpoch returns true if attestation `a` attested once in current epoch and/or epoch boundary block.
|
||||
func AttestedCurrentEpoch(s iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool, bool, error) {
|
||||
func AttestedCurrentEpoch(s iface.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, bool, error) {
|
||||
currentEpoch := helpers.CurrentEpoch(s)
|
||||
var votedCurrentEpoch, votedTarget bool
|
||||
// Did validator vote current epoch.
|
||||
@@ -87,7 +87,7 @@ func AttestedCurrentEpoch(s iface.ReadOnlyBeaconState, a *pb.PendingAttestation)
|
||||
}
|
||||
|
||||
// AttestedPrevEpoch returns true if attestation `a` attested once in previous epoch and epoch boundary block and/or the same head.
|
||||
func AttestedPrevEpoch(s iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool, bool, bool, error) {
|
||||
func AttestedPrevEpoch(s iface.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, bool, bool, error) {
|
||||
prevEpoch := helpers.PrevEpoch(s)
|
||||
var votedPrevEpoch, votedTarget, votedHead bool
|
||||
// Did validator vote previous epoch.
|
||||
@@ -115,7 +115,7 @@ func AttestedPrevEpoch(s iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (b
|
||||
}
|
||||
|
||||
// SameTarget returns true if attestation `a` attested to the same target block in state.
|
||||
func SameTarget(state iface.ReadOnlyBeaconState, a *pb.PendingAttestation, e types.Epoch) (bool, error) {
|
||||
func SameTarget(state iface.ReadOnlyBeaconState, a *statepb.PendingAttestation, e types.Epoch) (bool, error) {
|
||||
r, err := helpers.BlockRoot(state, e)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -127,7 +127,7 @@ func SameTarget(state iface.ReadOnlyBeaconState, a *pb.PendingAttestation, e typ
|
||||
}
|
||||
|
||||
// SameHead returns true if attestation `a` attested to the same block by attestation slot in state.
|
||||
func SameHead(state iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool, error) {
|
||||
func SameHead(state iface.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, error) {
|
||||
r, err := helpers.BlockRootAtSlot(state, a.Data.Slot)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -139,7 +139,7 @@ func SameHead(state iface.ReadOnlyBeaconState, a *pb.PendingAttestation) (bool,
|
||||
}
|
||||
|
||||
// UpdateValidator updates pre computed validator store.
|
||||
func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *pb.PendingAttestation, aSlot types.Slot) []*Validator {
|
||||
func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *statepb.PendingAttestation, aSlot types.Slot) []*Validator {
|
||||
inclusionSlot := aSlot + a.InclusionDelay
|
||||
|
||||
for _, i := range indices {
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -21,7 +21,7 @@ func TestUpdateValidator_Works(t *testing.T) {
|
||||
vp := []*precompute.Validator{{}, {InclusionSlot: e}, {}, {InclusionSlot: e}, {}, {InclusionSlot: e}}
|
||||
record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true,
|
||||
IsPrevEpochAttester: true, IsPrevEpochTargetAttester: true, IsPrevEpochHeadAttester: true}
|
||||
a := &pb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
|
||||
a := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
|
||||
|
||||
// Indices 1 3 and 5 attested
|
||||
vp = precompute.UpdateValidator(vp, record, []uint64{1, 3, 5}, a, 100)
|
||||
@@ -37,7 +37,7 @@ func TestUpdateValidator_InclusionOnlyCountsPrevEpoch(t *testing.T) {
|
||||
e := params.BeaconConfig().FarFutureSlot
|
||||
vp := []*precompute.Validator{{InclusionSlot: e}}
|
||||
record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true}
|
||||
a := &pb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
|
||||
a := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
|
||||
|
||||
// Verify inclusion info doesnt get updated.
|
||||
vp = precompute.UpdateValidator(vp, record, []uint64{0}, a, 100)
|
||||
@@ -80,12 +80,12 @@ func TestSameHead(t *testing.T) {
|
||||
br[0] = r[:]
|
||||
require.NoError(t, beaconState.SetBlockRoots(br))
|
||||
att.Data.BeaconBlockRoot = r[:]
|
||||
same, err := precompute.SameHead(beaconState, &pb.PendingAttestation{Data: att.Data})
|
||||
same, err := precompute.SameHead(beaconState, &statepb.PendingAttestation{Data: att.Data})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, same, "Head in state does not match head in attestation")
|
||||
newRoot := [32]byte{'B'}
|
||||
att.Data.BeaconBlockRoot = newRoot[:]
|
||||
same, err = precompute.SameHead(beaconState, &pb.PendingAttestation{Data: att.Data})
|
||||
same, err = precompute.SameHead(beaconState, &statepb.PendingAttestation{Data: att.Data})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, false, same, "Head in state matches head in attestation")
|
||||
}
|
||||
@@ -100,12 +100,12 @@ func TestSameTarget(t *testing.T) {
|
||||
br[0] = r[:]
|
||||
require.NoError(t, beaconState.SetBlockRoots(br))
|
||||
att.Data.Target.Root = r[:]
|
||||
same, err := precompute.SameTarget(beaconState, &pb.PendingAttestation{Data: att.Data}, 0)
|
||||
same, err := precompute.SameTarget(beaconState, &statepb.PendingAttestation{Data: att.Data}, 0)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, same, "Head in state does not match head in attestation")
|
||||
newRoot := [32]byte{'B'}
|
||||
att.Data.Target.Root = newRoot[:]
|
||||
same, err = precompute.SameTarget(beaconState, &pb.PendingAttestation{Data: att.Data}, 0)
|
||||
same, err = precompute.SameTarget(beaconState, &statepb.PendingAttestation{Data: att.Data}, 0)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, false, same, "Head in state matches head in attestation")
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func TestAttestedPrevEpoch(t *testing.T) {
|
||||
require.NoError(t, beaconState.SetBlockRoots(br))
|
||||
att.Data.Target.Root = r[:]
|
||||
att.Data.BeaconBlockRoot = r[:]
|
||||
votedEpoch, votedTarget, votedHead, err := precompute.AttestedPrevEpoch(beaconState, &pb.PendingAttestation{Data: att.Data})
|
||||
votedEpoch, votedTarget, votedHead, err := precompute.AttestedPrevEpoch(beaconState, &statepb.PendingAttestation{Data: att.Data})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, votedEpoch, "Did not vote epoch")
|
||||
assert.Equal(t, true, votedTarget, "Did not vote target")
|
||||
@@ -140,7 +140,7 @@ func TestAttestedCurrentEpoch(t *testing.T) {
|
||||
require.NoError(t, beaconState.SetBlockRoots(br))
|
||||
att.Data.Target.Root = r[:]
|
||||
att.Data.BeaconBlockRoot = r[:]
|
||||
votedEpoch, votedTarget, err := precompute.AttestedCurrentEpoch(beaconState, &pb.PendingAttestation{Data: att.Data})
|
||||
votedEpoch, votedTarget, err := precompute.AttestedCurrentEpoch(beaconState, &statepb.PendingAttestation{Data: att.Data})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, true, votedEpoch, "Did not vote epoch")
|
||||
assert.Equal(t, true, votedTarget, "Did not vote target")
|
||||
@@ -170,9 +170,9 @@ func TestProcessAttestations(t *testing.T) {
|
||||
require.NoError(t, beaconState.SetBlockRoots(br))
|
||||
att2.Data.Target.Root = newRt[:]
|
||||
att2.Data.BeaconBlockRoot = newRt[:]
|
||||
err := beaconState.AppendPreviousEpochAttestations(&pb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1})
|
||||
err := beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1})
|
||||
require.NoError(t, err)
|
||||
err = beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{Data: att2.Data, AggregationBits: bf, InclusionDelay: 1})
|
||||
err = beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{Data: att2.Data, AggregationBits: bf, InclusionDelay: 1})
|
||||
require.NoError(t, err)
|
||||
|
||||
pVals := make([]*precompute.Validator, validators)
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -21,7 +21,7 @@ func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *test
|
||||
for i := 0; i < len(blockRoots); i++ {
|
||||
blockRoots[i] = []byte{byte(i)}
|
||||
}
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1,
|
||||
PreviousJustifiedCheckpoint: ðpb.Checkpoint{
|
||||
Epoch: 0,
|
||||
@@ -58,7 +58,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyCurrentEpoch(t *te
|
||||
for i := 0; i < len(blockRoots); i++ {
|
||||
blockRoots[i] = []byte{byte(i)}
|
||||
}
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1,
|
||||
PreviousJustifiedCheckpoint: ðpb.Checkpoint{
|
||||
Epoch: 0,
|
||||
@@ -95,7 +95,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyPrevEpoch(t *testi
|
||||
for i := 0; i < len(blockRoots); i++ {
|
||||
blockRoots[i] = []byte{byte(i)}
|
||||
}
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1,
|
||||
PreviousJustifiedCheckpoint: ðpb.Checkpoint{
|
||||
Epoch: 0,
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
ffe := params.BeaconConfig().FarFutureEpoch
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch,
|
||||
// Validator 0 is slashed
|
||||
// Validator 1 is withdrawable
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -23,9 +23,9 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) {
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(2048)
|
||||
base := buildState(e+3, validatorCount)
|
||||
atts := make([]*pb.PendingAttestation, 3)
|
||||
atts := make([]*statepb.PendingAttestation, 3)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
Source: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
@@ -62,10 +62,10 @@ func TestAttestationDeltaPrecompute(t *testing.T) {
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(2048)
|
||||
base := buildState(e+2, validatorCount)
|
||||
atts := make([]*pb.PendingAttestation, 3)
|
||||
atts := make([]*statepb.PendingAttestation, 3)
|
||||
var emptyRoot [32]byte
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{
|
||||
Root: emptyRoot[:],
|
||||
@@ -146,10 +146,10 @@ func TestAttestationDeltas_ZeroEpoch(t *testing.T) {
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(2048)
|
||||
base := buildState(e+2, validatorCount)
|
||||
atts := make([]*pb.PendingAttestation, 3)
|
||||
atts := make([]*statepb.PendingAttestation, 3)
|
||||
var emptyRoot [32]byte
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{
|
||||
Root: emptyRoot[:],
|
||||
@@ -182,10 +182,10 @@ func TestAttestationDeltas_ZeroInclusionDelay(t *testing.T) {
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(2048)
|
||||
base := buildState(e+2, validatorCount)
|
||||
atts := make([]*pb.PendingAttestation, 3)
|
||||
atts := make([]*statepb.PendingAttestation, 3)
|
||||
var emptyRoot [32]byte
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{
|
||||
Root: emptyRoot[:],
|
||||
@@ -215,9 +215,9 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing.
|
||||
e := params.BeaconConfig().SlotsPerEpoch
|
||||
validatorCount := uint64(2048)
|
||||
base := buildState(e+3, validatorCount)
|
||||
atts := make([]*pb.PendingAttestation, 3)
|
||||
atts := make([]*statepb.PendingAttestation, 3)
|
||||
for i := 0; i < len(atts); i++ {
|
||||
atts[i] = &pb.PendingAttestation{
|
||||
atts[i] = &statepb.PendingAttestation{
|
||||
Data: ðpb.AttestationData{
|
||||
Target: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
Source: ðpb.Checkpoint{Root: make([]byte, 32)},
|
||||
@@ -259,7 +259,7 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing.
|
||||
}
|
||||
}
|
||||
|
||||
func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState {
|
||||
func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState {
|
||||
validators := make([]*ethpb.Validator, validatorCount)
|
||||
for i := 0; i < len(validators); i++ {
|
||||
validators[i] = ðpb.Validator{
|
||||
@@ -285,7 +285,7 @@ func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState {
|
||||
for i := 0; i < len(latestRandaoMixes); i++ {
|
||||
latestRandaoMixes[i] = params.BeaconConfig().ZeroHash[:]
|
||||
}
|
||||
return &pb.BeaconState{
|
||||
return &statepb.BeaconState{
|
||||
Slot: slot,
|
||||
Balances: validatorBalances,
|
||||
Validators: validators,
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) {
|
||||
s, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
s, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: []*ethpb.Validator{{}},
|
||||
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
|
||||
@@ -46,11 +46,11 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) {
|
||||
|
||||
func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
|
||||
tests := []struct {
|
||||
state *pb.BeaconState
|
||||
state *statepb.BeaconState
|
||||
want uint64
|
||||
}{
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
@@ -64,7 +64,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
|
||||
want: uint64(31000000000), // 32 * 1e9 - 1000000000
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
@@ -80,7 +80,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
|
||||
want: uint64(32000000000), // 32 * 1e9 - 500000000
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
@@ -96,7 +96,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
|
||||
want: uint64(31000000000), // 32 * 1e9 - 1000000000
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{Slashed: true,
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
|
||||
|
||||
@@ -36,9 +36,9 @@ go_library(
|
||||
deps = [
|
||||
"//beacon-chain/cache:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/hashutil:go_default_library",
|
||||
@@ -76,8 +76,8 @@ go_test(
|
||||
"//beacon-chain/cache:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/hashutil:go_default_library",
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -98,7 +98,7 @@ func TestAttestation_ComputeSubnetForAttestation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 200,
|
||||
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -20,7 +20,7 @@ func TestBlockRootAtSlot_CorrectBlockRoot(t *testing.T) {
|
||||
for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ {
|
||||
blockRoots = append(blockRoots, []byte{byte(i)})
|
||||
}
|
||||
s := &pb.BeaconState{
|
||||
s := &statepb.BeaconState{
|
||||
BlockRoots: blockRoots,
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func TestBlockRootAtSlot_OutOfBounds(t *testing.T) {
|
||||
for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ {
|
||||
blockRoots = append(blockRoots, []byte{byte(i)})
|
||||
}
|
||||
state := &pb.BeaconState{
|
||||
state := &statepb.BeaconState{
|
||||
BlockRoots: blockRoots,
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -35,7 +35,7 @@ func TestComputeCommittee_WithoutCache(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: activeRoots,
|
||||
})
|
||||
@@ -378,7 +378,7 @@ func TestShuffledIndices_ShuffleRightLength(t *testing.T) {
|
||||
}
|
||||
indices[i] = uint64(i)
|
||||
}
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -411,7 +411,7 @@ func TestUpdateCommitteeCache_CanUpdate(t *testing.T) {
|
||||
}
|
||||
indices[i] = i
|
||||
}
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
@@ -610,7 +610,7 @@ func TestBeaconCommitteeFromState_UpdateCacheForPreviousEpoch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -20,7 +20,7 @@ func TestRandaoMix_OK(t *testing.T) {
|
||||
binary.LittleEndian.PutUint64(intInBytes, uint64(i))
|
||||
randaoMixes[i] = intInBytes
|
||||
}
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{RandaoMixes: randaoMixes})
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{RandaoMixes: randaoMixes})
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
RandaoMixes: randaoMixes,
|
||||
Slot: slot,
|
||||
})
|
||||
|
||||
@@ -5,15 +5,15 @@ import (
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
func TestTotalBalance_OK(t *testing.T) {
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{}})
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{Balances: test.b})
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 4}, {EffectiveBalance: 3}},
|
||||
Balances: test.b,
|
||||
@@ -179,7 +179,7 @@ func TestIsInInactivityLeak(t *testing.T) {
|
||||
assert.Equal(t, false, IsInInactivityLeak(prevEpoch, finalizedEpoch), "Wanted inactivity leak false")
|
||||
}
|
||||
|
||||
func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState {
|
||||
func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState {
|
||||
validators := make([]*ethpb.Validator, validatorCount)
|
||||
for i := 0; i < len(validators); i++ {
|
||||
validators[i] = ðpb.Validator{
|
||||
@@ -205,7 +205,7 @@ func buildState(slot types.Slot, validatorCount uint64) *pb.BeaconState {
|
||||
for i := 0; i < len(latestRandaoMixes); i++ {
|
||||
latestRandaoMixes[i] = params.BeaconConfig().ZeroHash[:]
|
||||
}
|
||||
return &pb.BeaconState{
|
||||
return &statepb.BeaconState{
|
||||
Slot: slot,
|
||||
Balances: validatorBalances,
|
||||
Validators: validators,
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -57,7 +57,7 @@ func signingData(rootFunc func() ([32]byte, error), domain []byte) ([32]byte, er
|
||||
if err != nil {
|
||||
return [32]byte{}, err
|
||||
}
|
||||
container := &pb.SigningData{
|
||||
container := &statepb.SigningData{
|
||||
ObjectRoot: objRoot[:],
|
||||
Domain: domain,
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func domain(domainType [DomainByteLength]byte, forkDataRoot []byte) []byte {
|
||||
// genesis_validators_root=genesis_validators_root,
|
||||
// ))
|
||||
func computeForkDataRoot(version, root []byte) ([32]byte, error) {
|
||||
r, err := (&pb.ForkData{
|
||||
r, err := (&statepb.ForkData{
|
||||
CurrentVersion: version,
|
||||
GenesisValidatorsRoot: root,
|
||||
}).HashTreeRoot()
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
fuzz "github.com/google/gofuzz"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -109,7 +109,7 @@ func TestSigningRoot_ComputeForkDigest(t *testing.T) {
|
||||
|
||||
func TestFuzzverifySigningRoot_10000(t *testing.T) {
|
||||
fuzzer := fuzz.NewWithSeed(0)
|
||||
state := ðereum_beacon_p2p_v1.BeaconState{}
|
||||
state := &statepb.BeaconState{}
|
||||
pubkey := [48]byte{}
|
||||
sig := [96]byte{}
|
||||
domain := [4]byte{}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -42,7 +42,7 @@ func TestCurrentEpoch_OK(t *testing.T) {
|
||||
{slot: 200, epoch: 6},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{Slot: tt.slot})
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: tt.slot})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.epoch, NextEpoch(state), "NextEpoch(%d)", state.Slot())
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
@@ -285,7 +285,7 @@ func ComputeProposerIndex(bState iface.ReadOnlyValidators, activeIndices []types
|
||||
// epoch = get_current_epoch(state) if epoch is None else epoch
|
||||
// fork_version = state.fork.previous_version if epoch < state.fork.epoch else state.fork.current_version
|
||||
// return compute_domain(domain_type, fork_version, state.genesis_validators_root)
|
||||
func Domain(fork *pb.Fork, epoch types.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error) {
|
||||
func Domain(fork *statepb.Fork, epoch types.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error) {
|
||||
if fork == nil {
|
||||
return []byte{}, errors.New("nil fork or domain type")
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
@@ -45,7 +45,7 @@ func TestIsActiveValidatorUsingTrie_OK(t *testing.T) {
|
||||
{a: 64, b: true},
|
||||
}
|
||||
val := ðpb.Validator{ActivationEpoch: 10, ExitEpoch: 100}
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{val}})
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{Validators: []*ethpb.Validator{test.validator}})
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Validators: validators,
|
||||
Slot: 0,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -317,7 +317,7 @@ func TestComputeProposerIndex_Compatibility(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
state, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
state, err := v1.InitializeFromProto(&statepb.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 := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Slot: 0,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -400,7 +400,7 @@ func TestChurnLimit_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
beaconState, err := v1.InitializeFromProto(&pb.BeaconState{
|
||||
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
|
||||
Slot: 1,
|
||||
Validators: validators,
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -415,8 +415,8 @@ func TestChurnLimit_OK(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDomain_OK(t *testing.T) {
|
||||
state := &pb.BeaconState{
|
||||
Fork: &pb.Fork{
|
||||
state := &statepb.BeaconState{
|
||||
Fork: &statepb.Fork{
|
||||
Epoch: 3,
|
||||
PreviousVersion: []byte{0, 0, 0, 2},
|
||||
CurrentVersion: []byte{0, 0, 0, 3},
|
||||
@@ -445,7 +445,7 @@ func TestDomain_OK(t *testing.T) {
|
||||
func TestActiveValidatorIndices(t *testing.T) {
|
||||
farFutureEpoch := params.BeaconConfig().FarFutureEpoch
|
||||
type args struct {
|
||||
state *pb.BeaconState
|
||||
state *statepb.BeaconState
|
||||
epoch types.Epoch
|
||||
}
|
||||
tests := []struct {
|
||||
@@ -457,7 +457,7 @@ func TestActiveValidatorIndices(t *testing.T) {
|
||||
{
|
||||
name: "all_active_epoch_10",
|
||||
args: args{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -481,7 +481,7 @@ func TestActiveValidatorIndices(t *testing.T) {
|
||||
{
|
||||
name: "some_active_epoch_10",
|
||||
args: args{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -505,7 +505,7 @@ func TestActiveValidatorIndices(t *testing.T) {
|
||||
{
|
||||
name: "some_active_with_recent_new_epoch_10",
|
||||
args: args{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -533,7 +533,7 @@ func TestActiveValidatorIndices(t *testing.T) {
|
||||
{
|
||||
name: "some_active_with_recent_new_epoch_10",
|
||||
args: args{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -561,7 +561,7 @@ func TestActiveValidatorIndices(t *testing.T) {
|
||||
{
|
||||
name: "some_active_with_recent_new_epoch_10",
|
||||
args: args{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
@@ -698,7 +698,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}
|
||||
bState := &statepb.BeaconState{Validators: tt.args.validators}
|
||||
stTrie, err := v1.InitializeFromProtoUnsafe(bState)
|
||||
require.NoError(t, err)
|
||||
got, err := ComputeProposerIndex(stTrie, tt.args.indices, tt.args.seed)
|
||||
@@ -739,20 +739,20 @@ func TestIsIsEligibleForActivation(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
validator *ethpb.Validator
|
||||
state *pb.BeaconState
|
||||
state *statepb.BeaconState
|
||||
want bool
|
||||
}{
|
||||
{"Eligible",
|
||||
ðpb.Validator{ActivationEligibilityEpoch: 1, ActivationEpoch: params.BeaconConfig().FarFutureEpoch},
|
||||
&pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}},
|
||||
&statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}},
|
||||
true},
|
||||
{"Not yet finalized",
|
||||
ðpb.Validator{ActivationEligibilityEpoch: 1, ActivationEpoch: params.BeaconConfig().FarFutureEpoch},
|
||||
&pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}},
|
||||
&statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}},
|
||||
false},
|
||||
{"Incorrect activation epoch",
|
||||
ðpb.Validator{ActivationEligibilityEpoch: 1},
|
||||
&pb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}},
|
||||
&statepb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Epoch: 2}},
|
||||
false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
||||
@@ -34,9 +34,9 @@ go_library(
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
@@ -76,9 +76,9 @@ go_test(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
"//shared/benchutil:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
@@ -117,7 +117,7 @@ go_test(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/state:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//shared/benchutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/require:go_default_library",
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/benchutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -146,7 +146,7 @@ func BenchmarkUnmarshalState_FullState(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
require.NoError(b, proto.Unmarshal(protoObject, &pb.BeaconState{}))
|
||||
require.NoError(b, proto.Unmarshal(protoObject, &statepb.BeaconState{}))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -154,7 +154,7 @@ func BenchmarkUnmarshalState_FullState(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
sszState := &pb.BeaconState{}
|
||||
sszState := &statepb.BeaconState{}
|
||||
require.NoError(b, sszState.UnmarshalSSZ(sszObject))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
@@ -114,13 +114,13 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState,
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
|
||||
state := &pb.BeaconState{
|
||||
state := &statepb.BeaconState{
|
||||
// Misc fields.
|
||||
Slot: 0,
|
||||
GenesisTime: genesisTime,
|
||||
GenesisValidatorsRoot: genesisValidatorsRoot[:],
|
||||
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
Epoch: 0,
|
||||
@@ -152,8 +152,8 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState,
|
||||
BlockRoots: blockRoots,
|
||||
StateRoots: stateRoots,
|
||||
Slashings: slashings,
|
||||
CurrentEpochAttestations: []*pb.PendingAttestation{},
|
||||
PreviousEpochAttestations: []*pb.PendingAttestation{},
|
||||
CurrentEpochAttestations: []*statepb.PendingAttestation{},
|
||||
PreviousEpochAttestations: []*statepb.PendingAttestation{},
|
||||
|
||||
// Eth1 data.
|
||||
Eth1Data: eth1Data,
|
||||
@@ -184,10 +184,10 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState iface.BeaconState,
|
||||
|
||||
// EmptyGenesisState returns an empty beacon state object.
|
||||
func EmptyGenesisState() (iface.BeaconState, error) {
|
||||
state := &pb.BeaconState{
|
||||
state := &statepb.BeaconState{
|
||||
// Misc fields.
|
||||
Slot: 0,
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
|
||||
Epoch: 0,
|
||||
@@ -198,8 +198,8 @@ func EmptyGenesisState() (iface.BeaconState, error) {
|
||||
|
||||
JustificationBits: []byte{0},
|
||||
HistoricalRoots: [][]byte{},
|
||||
CurrentEpochAttestations: []*pb.PendingAttestation{},
|
||||
PreviousEpochAttestations: []*pb.PendingAttestation{},
|
||||
CurrentEpochAttestations: []*statepb.PendingAttestation{},
|
||||
PreviousEpochAttestations: []*statepb.PendingAttestation{},
|
||||
|
||||
// Eth1 data.
|
||||
Eth1Data: ðpb.Eth1Data{},
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -42,7 +42,7 @@ func TestGenesisBeaconState_OK(t *testing.T) {
|
||||
|
||||
// Misc fields checks.
|
||||
assert.Equal(t, types.Slot(0), newState.Slot(), "Slot was not correctly initialized")
|
||||
if !proto.Equal(newState.Fork(), &pb.Fork{
|
||||
if !proto.Equal(newState.Fork(), &statepb.Fork{
|
||||
PreviousVersion: genesisForkVersion,
|
||||
CurrentVersion: genesisForkVersion,
|
||||
Epoch: genesisEpoch,
|
||||
@@ -76,10 +76,10 @@ func TestGenesisBeaconState_OK(t *testing.T) {
|
||||
assert.DeepEqual(t, make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), newState.Slashings(), "Slashings was not correctly initialized")
|
||||
currAtt, err := newState.CurrentEpochAttestations()
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, []*pb.PendingAttestation{}, currAtt, "CurrentEpochAttestations was not correctly initialized")
|
||||
assert.DeepSSZEqual(t, []*statepb.PendingAttestation{}, currAtt, "CurrentEpochAttestations was not correctly initialized")
|
||||
prevAtt, err := newState.CurrentEpochAttestations()
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, []*pb.PendingAttestation{}, prevAtt, "PreviousEpochAttestations was not correctly initialized")
|
||||
assert.DeepSSZEqual(t, []*statepb.PendingAttestation{}, prevAtt, "PreviousEpochAttestations was not correctly initialized")
|
||||
|
||||
zeroHash := params.BeaconConfig().ZeroHash[:]
|
||||
// History root checks.
|
||||
|
||||
@@ -22,8 +22,8 @@ go_test(
|
||||
deps = [
|
||||
":go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
"//shared/testutil/require:go_default_library",
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/stateutils"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
func TestValidatorIndexMap_OK(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
PublicKey: []byte("zero"),
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@@ -33,7 +33,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestExecuteStateTransition_IncorrectSlot(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 5,
|
||||
}
|
||||
beaconState, err := v1.InitializeFromProto(base)
|
||||
@@ -243,7 +243,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) {
|
||||
cp := beaconState.CurrentJustifiedCheckpoint()
|
||||
cp.Root = []byte("hello-world")
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
_, err = state.VerifyOperationLengths(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(block))
|
||||
wanted := "number of voluntary exits (17) in block body exceeds allowed threshold of 16"
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
@@ -269,7 +269,7 @@ func createFullBlockWithOperations(t *testing.T) (iface.BeaconState,
|
||||
copy(mockRoot[:], "hello-world")
|
||||
cp.Root = mockRoot[:]
|
||||
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cp))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&pb.PendingAttestation{}))
|
||||
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
|
||||
|
||||
proposerSlashIdx := types.ValidatorIndex(3)
|
||||
slotsPerEpoch := params.BeaconConfig().SlotsPerEpoch
|
||||
@@ -445,9 +445,9 @@ func TestProcessBlock_PassesProcessingConditions(t *testing.T) {
|
||||
func TestProcessEpochPrecompute_CanProcess(t *testing.T) {
|
||||
epoch := types.Epoch(1)
|
||||
|
||||
atts := []*pb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: make([]byte, 32)}}, InclusionDelay: 1}}
|
||||
atts := []*statepb.PendingAttestation{{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: make([]byte, 32)}}, InclusionDelay: 1}}
|
||||
slashing := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch)) + 1,
|
||||
BlockRoots: make([][]byte, 128),
|
||||
Slashings: slashing,
|
||||
@@ -489,7 +489,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) {
|
||||
randaoMixes[i] = params.BeaconConfig().ZeroHash[:]
|
||||
}
|
||||
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Slot: 20,
|
||||
LatestBlockHeader: ðpb.BeaconBlockHeader{},
|
||||
BlockRoots: make([][]byte, 254),
|
||||
@@ -500,7 +500,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) {
|
||||
CurrentJustifiedCheckpoint: ðpb.Checkpoint{
|
||||
Root: []byte("hello-world"),
|
||||
},
|
||||
Fork: &pb.Fork{
|
||||
Fork: &statepb.Fork{
|
||||
PreviousVersion: []byte{0, 0, 0, 0},
|
||||
CurrentVersion: []byte{0, 0, 0, 0},
|
||||
},
|
||||
@@ -567,7 +567,7 @@ func BenchmarkProcessBlk_65536Validators_FullBlock(b *testing.B) {
|
||||
binary.LittleEndian.PutUint64(buf, 0)
|
||||
domain, err := helpers.Domain(s.Fork(), 0, params.BeaconConfig().DomainRandao, s.GenesisValidatorRoot())
|
||||
require.NoError(b, err)
|
||||
ctr := &pb.SigningData{
|
||||
ctr := &statepb.SigningData{
|
||||
ObjectRoot: buf,
|
||||
Domain: domain,
|
||||
}
|
||||
@@ -730,7 +730,7 @@ func TestCanProcessEpoch_TrueOnEpochs(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
b := &pb.BeaconState{Slot: tt.slot}
|
||||
b := &statepb.BeaconState{Slot: tt.slot}
|
||||
s, err := v1.InitializeFromProto(b)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.canProcessEpoch, state.CanProcessEpoch(s), "CanProcessEpoch(%d)", tt.slot)
|
||||
@@ -797,7 +797,7 @@ func TestProcessBlock_OverMaxVoluntaryExits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessBlock_IncorrectDeposits(t *testing.T) {
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Eth1Data: ðpb.Eth1Data{DepositCount: 100},
|
||||
Eth1DepositIndex: 98,
|
||||
}
|
||||
@@ -818,7 +818,7 @@ func TestProcessBlock_IncorrectDeposits(t *testing.T) {
|
||||
|
||||
func TestProcessSlots_SameSlotAsParentState(t *testing.T) {
|
||||
slot := types.Slot(2)
|
||||
parentState, err := v1.InitializeFromProto(&pb.BeaconState{Slot: slot})
|
||||
parentState, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: slot})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = state.ProcessSlots(context.Background(), parentState, slot)
|
||||
@@ -827,7 +827,7 @@ func TestProcessSlots_SameSlotAsParentState(t *testing.T) {
|
||||
|
||||
func TestProcessSlots_LowerSlotAsParentState(t *testing.T) {
|
||||
slot := types.Slot(2)
|
||||
parentState, err := v1.InitializeFromProto(&pb.BeaconState{Slot: slot})
|
||||
parentState, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: slot})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = state.ProcessSlots(context.Background(), parentState, slot-1)
|
||||
|
||||
@@ -26,8 +26,8 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
"//shared/testutil/require:go_default_library",
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -41,7 +41,7 @@ func TestHasVoted_OK(t *testing.T) {
|
||||
|
||||
func TestInitiateValidatorExit_AlreadyExited(t *testing.T) {
|
||||
exitEpoch := types.Epoch(199)
|
||||
base := &pb.BeaconState{Validators: []*ethpb.Validator{{
|
||||
base := &statepb.BeaconState{Validators: []*ethpb.Validator{{
|
||||
ExitEpoch: exitEpoch},
|
||||
}}
|
||||
state, err := v1.InitializeFromProto(base)
|
||||
@@ -56,7 +56,7 @@ func TestInitiateValidatorExit_AlreadyExited(t *testing.T) {
|
||||
func TestInitiateValidatorExit_ProperExit(t *testing.T) {
|
||||
exitedEpoch := types.Epoch(100)
|
||||
idx := types.ValidatorIndex(3)
|
||||
base := &pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
base := &statepb.BeaconState{Validators: []*ethpb.Validator{
|
||||
{ExitEpoch: exitedEpoch},
|
||||
{ExitEpoch: exitedEpoch + 1},
|
||||
{ExitEpoch: exitedEpoch + 2},
|
||||
@@ -74,7 +74,7 @@ func TestInitiateValidatorExit_ProperExit(t *testing.T) {
|
||||
func TestInitiateValidatorExit_ChurnOverflow(t *testing.T) {
|
||||
exitedEpoch := types.Epoch(100)
|
||||
idx := types.ValidatorIndex(4)
|
||||
base := &pb.BeaconState{Validators: []*ethpb.Validator{
|
||||
base := &statepb.BeaconState{Validators: []*ethpb.Validator{
|
||||
{ExitEpoch: exitedEpoch + 2},
|
||||
{ExitEpoch: exitedEpoch + 2},
|
||||
{ExitEpoch: exitedEpoch + 2},
|
||||
@@ -110,7 +110,7 @@ func TestSlashValidator_OK(t *testing.T) {
|
||||
balances = append(balances, params.BeaconConfig().MaxEffectiveBalance)
|
||||
}
|
||||
|
||||
base := &pb.BeaconState{
|
||||
base := &statepb.BeaconState{
|
||||
Validators: registry,
|
||||
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
|
||||
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
|
||||
@@ -153,11 +153,11 @@ func TestSlashValidator_OK(t *testing.T) {
|
||||
|
||||
func TestActivatedValidatorIndices(t *testing.T) {
|
||||
tests := []struct {
|
||||
state *pb.BeaconState
|
||||
state *statepb.BeaconState
|
||||
wanted []types.ValidatorIndex
|
||||
}{
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
ActivationEpoch: 0,
|
||||
@@ -179,7 +179,7 @@ func TestActivatedValidatorIndices(t *testing.T) {
|
||||
wanted: []types.ValidatorIndex{0, 1, 3},
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
ActivationEpoch: helpers.ActivationExitEpoch(10),
|
||||
@@ -189,7 +189,7 @@ func TestActivatedValidatorIndices(t *testing.T) {
|
||||
wanted: []types.ValidatorIndex{},
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
ActivationEpoch: 0,
|
||||
@@ -210,11 +210,11 @@ func TestActivatedValidatorIndices(t *testing.T) {
|
||||
|
||||
func TestSlashedValidatorIndices(t *testing.T) {
|
||||
tests := []struct {
|
||||
state *pb.BeaconState
|
||||
state *statepb.BeaconState
|
||||
wanted []types.ValidatorIndex
|
||||
}{
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector,
|
||||
@@ -233,7 +233,7 @@ func TestSlashedValidatorIndices(t *testing.T) {
|
||||
wanted: []types.ValidatorIndex{0, 2},
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector,
|
||||
@@ -243,7 +243,7 @@ func TestSlashedValidatorIndices(t *testing.T) {
|
||||
wanted: []types.ValidatorIndex{},
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector,
|
||||
@@ -264,11 +264,11 @@ func TestSlashedValidatorIndices(t *testing.T) {
|
||||
|
||||
func TestExitedValidatorIndices(t *testing.T) {
|
||||
tests := []struct {
|
||||
state *pb.BeaconState
|
||||
state *statepb.BeaconState
|
||||
wanted []types.ValidatorIndex
|
||||
}{
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance,
|
||||
@@ -290,7 +290,7 @@ func TestExitedValidatorIndices(t *testing.T) {
|
||||
wanted: []types.ValidatorIndex{0, 2},
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance,
|
||||
@@ -302,7 +302,7 @@ func TestExitedValidatorIndices(t *testing.T) {
|
||||
wanted: []types.ValidatorIndex{},
|
||||
},
|
||||
{
|
||||
state: &pb.BeaconState{
|
||||
state: &statepb.BeaconState{
|
||||
Validators: []*ethpb.Validator{
|
||||
{
|
||||
EffectiveBalance: params.BeaconConfig().MaxEffectiveBalance,
|
||||
|
||||
@@ -13,10 +13,10 @@ go_library(
|
||||
"//beacon-chain/db/filters:go_default_library",
|
||||
"//beacon-chain/slasher/types:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/backuputil:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db/filters"
|
||||
slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
v2 "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/backuputil"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ type ReadOnlyDatabase interface {
|
||||
State(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error)
|
||||
GenesisState(ctx context.Context) (iface.BeaconState, error)
|
||||
HasState(ctx context.Context, blockRoot [32]byte) bool
|
||||
StateSummary(ctx context.Context, blockRoot [32]byte) (*ethereum_beacon_p2p_v1.StateSummary, error)
|
||||
StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error)
|
||||
HasStateSummary(ctx context.Context, blockRoot [32]byte) bool
|
||||
HighestSlotStatesBelow(ctx context.Context, slot types.Slot) ([]iface.ReadOnlyBeaconState, error)
|
||||
// Slashing operations.
|
||||
@@ -73,8 +73,8 @@ type NoHeadAccessDatabase interface {
|
||||
SaveStates(ctx context.Context, states []iface.ReadOnlyBeaconState, blockRoots [][32]byte) error
|
||||
DeleteState(ctx context.Context, blockRoot [32]byte) error
|
||||
DeleteStates(ctx context.Context, blockRoots [][32]byte) error
|
||||
SaveStateSummary(ctx context.Context, summary *ethereum_beacon_p2p_v1.StateSummary) error
|
||||
SaveStateSummaries(ctx context.Context, summaries []*ethereum_beacon_p2p_v1.StateSummary) error
|
||||
SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error
|
||||
SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error
|
||||
// Slashing operations.
|
||||
SaveProposerSlashing(ctx context.Context, slashing *eth.ProposerSlashing) error
|
||||
SaveAttesterSlashing(ctx context.Context, slashing *eth.AttesterSlashing) error
|
||||
|
||||
@@ -14,10 +14,10 @@ go_library(
|
||||
"//beacon-chain/db/filters:go_default_library",
|
||||
"//beacon-chain/db/iface:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/traceutil:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/db/filters"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
v2 "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
)
|
||||
|
||||
// DatabasePath -- passthrough.
|
||||
@@ -70,7 +70,7 @@ func (e Exporter) State(ctx context.Context, blockRoot [32]byte) (iface.BeaconSt
|
||||
}
|
||||
|
||||
// StateSummary -- passthrough.
|
||||
func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*pb.StateSummary, error) {
|
||||
func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) {
|
||||
return e.db.StateSummary(ctx, blockRoot)
|
||||
}
|
||||
|
||||
@@ -145,12 +145,12 @@ func (e Exporter) SaveState(ctx context.Context, st iface.ReadOnlyBeaconState, b
|
||||
}
|
||||
|
||||
// SaveStateSummary -- passthrough.
|
||||
func (e Exporter) SaveStateSummary(ctx context.Context, summary *pb.StateSummary) error {
|
||||
func (e Exporter) SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error {
|
||||
return e.db.SaveStateSummary(ctx, summary)
|
||||
}
|
||||
|
||||
// SaveStateSummaries -- passthrough.
|
||||
func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*pb.StateSummary) error {
|
||||
func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error {
|
||||
return e.db.SaveStateSummaries(ctx, summaries)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ go_library(
|
||||
"//beacon-chain/state/genesis:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/fileutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
@@ -92,11 +92,11 @@ go_test(
|
||||
"//beacon-chain/db/filters:go_default_library",
|
||||
"//beacon-chain/db/iface:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//proto/testing:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
fastssz "github.com/ferranbt/fastssz"
|
||||
"github.com/golang/snappy"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"go.opencensus.io/trace"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -53,7 +53,7 @@ func encode(ctx context.Context, msg proto.Message) ([]byte, error) {
|
||||
// isSSZStorageFormat returns true if the object type should be saved in SSZ encoded format.
|
||||
func isSSZStorageFormat(obj interface{}) bool {
|
||||
switch obj.(type) {
|
||||
case *pb.BeaconState:
|
||||
case *statepb.BeaconState:
|
||||
return true
|
||||
case *ethpb.SignedBeaconBlock:
|
||||
return true
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
dbIface "github.com/prysmaticlabs/prysm/beacon-chain/db/iface"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
state "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ func (s *Store) SaveGenesisData(ctx context.Context, genesisState iface.BeaconSt
|
||||
if err := s.SaveState(ctx, genesisState, genesisBlkRoot); err != nil {
|
||||
return errors.Wrap(err, "could not save genesis state")
|
||||
}
|
||||
if err := s.SaveStateSummary(ctx, &pbp2p.StateSummary{
|
||||
if err := s.SaveStateSummary(ctx, &statepb.StateSummary{
|
||||
Slot: 0,
|
||||
Root: genesisBlkRoot[:],
|
||||
}); err != nil {
|
||||
@@ -57,7 +57,7 @@ func (s *Store) LoadGenesis(ctx context.Context, r io.Reader) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
st := &pbp2p.BeaconState{}
|
||||
st := &statepb.BeaconState{}
|
||||
if err := st.UnmarshalSSZ(b); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/genesis"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/traceutil"
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
func (s *Store) State(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "BeaconDB.State")
|
||||
defer span.End()
|
||||
var st *pb.BeaconState
|
||||
var st *statepb.BeaconState
|
||||
enc, err := s.stateBytes(ctx, blockRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -57,7 +57,7 @@ func (s *Store) GenesisState(ctx context.Context) (iface.BeaconState, error) {
|
||||
return cached, nil
|
||||
}
|
||||
|
||||
var st *pb.BeaconState
|
||||
var st *statepb.BeaconState
|
||||
err = s.db.View(func(tx *bolt.Tx) error {
|
||||
// Retrieve genesis block's signing root from blocks bucket,
|
||||
// to look up what the genesis state is.
|
||||
@@ -198,8 +198,8 @@ func (s *Store) DeleteStates(ctx context.Context, blockRoots [][32]byte) error {
|
||||
}
|
||||
|
||||
// creates state from marshaled proto state bytes.
|
||||
func createState(ctx context.Context, enc []byte) (*pb.BeaconState, error) {
|
||||
protoState := &pb.BeaconState{}
|
||||
func createState(ctx context.Context, enc []byte) (*statepb.BeaconState, error) {
|
||||
protoState := &statepb.BeaconState{}
|
||||
if err := decode(ctx, enc, protoState); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal encoding")
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func slotByBlockRoot(ctx context.Context, tx *bolt.Tx, blockRoot []byte) (types.
|
||||
}
|
||||
return b.Block.Slot, nil
|
||||
}
|
||||
stateSummary := &pb.StateSummary{}
|
||||
stateSummary := &statepb.StateSummary{}
|
||||
if err := decode(ctx, enc, stateSummary); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -3,22 +3,22 @@ package kv
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
bolt "go.etcd.io/bbolt"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
// SaveStateSummary saves a state summary object to the DB.
|
||||
func (s *Store) SaveStateSummary(ctx context.Context, summary *pb.StateSummary) error {
|
||||
func (s *Store) SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error {
|
||||
ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummary")
|
||||
defer span.End()
|
||||
|
||||
return s.SaveStateSummaries(ctx, []*pb.StateSummary{summary})
|
||||
return s.SaveStateSummaries(ctx, []*statepb.StateSummary{summary})
|
||||
}
|
||||
|
||||
// SaveStateSummaries saves state summary objects to the DB.
|
||||
func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*pb.StateSummary) error {
|
||||
func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error {
|
||||
ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummaries")
|
||||
defer span.End()
|
||||
|
||||
@@ -38,7 +38,7 @@ func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*pb.StateSum
|
||||
}
|
||||
|
||||
// StateSummary returns the state summary object from the db using input block root.
|
||||
func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*pb.StateSummary, error) {
|
||||
func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "BeaconDB.StateSummary")
|
||||
defer span.End()
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*pb.State
|
||||
if len(enc) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
summary := &pb.StateSummary{}
|
||||
summary := &statepb.StateSummary{}
|
||||
if err := decode(ctx, enc, summary); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -3,26 +3,26 @@ package kv
|
||||
import (
|
||||
"sync"
|
||||
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
)
|
||||
|
||||
const stateSummaryCachePruneCount = 128
|
||||
|
||||
// stateSummaryCache caches state summary object.
|
||||
type stateSummaryCache struct {
|
||||
initSyncStateSummaries map[[32]byte]*pb.StateSummary
|
||||
initSyncStateSummaries map[[32]byte]*statepb.StateSummary
|
||||
initSyncStateSummariesLock sync.RWMutex
|
||||
}
|
||||
|
||||
// newStateSummaryCache creates a new state summary cache.
|
||||
func newStateSummaryCache() *stateSummaryCache {
|
||||
return &stateSummaryCache{
|
||||
initSyncStateSummaries: make(map[[32]byte]*pb.StateSummary),
|
||||
initSyncStateSummaries: make(map[[32]byte]*statepb.StateSummary),
|
||||
}
|
||||
}
|
||||
|
||||
// put saves a state summary to the initial sync state summaries cache.
|
||||
func (c *stateSummaryCache) put(r [32]byte, b *pb.StateSummary) {
|
||||
func (c *stateSummaryCache) put(r [32]byte, b *statepb.StateSummary) {
|
||||
c.initSyncStateSummariesLock.Lock()
|
||||
defer c.initSyncStateSummariesLock.Unlock()
|
||||
c.initSyncStateSummaries[r] = b
|
||||
@@ -39,7 +39,7 @@ func (c *stateSummaryCache) has(r [32]byte) bool {
|
||||
|
||||
// get retrieves a state summary from the initial sync state summaries cache using the root of
|
||||
// the block.
|
||||
func (c *stateSummaryCache) get(r [32]byte) *pb.StateSummary {
|
||||
func (c *stateSummaryCache) get(r [32]byte) *statepb.StateSummary {
|
||||
c.initSyncStateSummariesLock.RLock()
|
||||
defer c.initSyncStateSummariesLock.RUnlock()
|
||||
b := c.initSyncStateSummaries[r]
|
||||
@@ -55,11 +55,11 @@ func (c *stateSummaryCache) len() int {
|
||||
|
||||
// GetAll retrieves all the beacon state summaries from the initial sync state summaries cache, the returned
|
||||
// state summaries are unordered.
|
||||
func (c *stateSummaryCache) getAll() []*pb.StateSummary {
|
||||
func (c *stateSummaryCache) getAll() []*statepb.StateSummary {
|
||||
c.initSyncStateSummariesLock.RLock()
|
||||
defer c.initSyncStateSummariesLock.RUnlock()
|
||||
|
||||
summaries := make([]*pb.StateSummary, 0, len(c.initSyncStateSummaries))
|
||||
summaries := make([]*statepb.StateSummary, 0, len(c.initSyncStateSummaries))
|
||||
for _, b := range c.initSyncStateSummaries {
|
||||
summaries = append(summaries, b)
|
||||
}
|
||||
@@ -70,5 +70,5 @@ func (c *stateSummaryCache) getAll() []*pb.StateSummary {
|
||||
func (c *stateSummaryCache) clear() {
|
||||
c.initSyncStateSummariesLock.Lock()
|
||||
defer c.initSyncStateSummariesLock.Unlock()
|
||||
c.initSyncStateSummaries = make(map[[32]byte]*pb.StateSummary)
|
||||
c.initSyncStateSummaries = make(map[[32]byte]*statepb.StateSummary)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -16,7 +16,7 @@ func TestStateSummary_CanSaveRretrieve(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
r1 := bytesutil.ToBytes32([]byte{'A'})
|
||||
r2 := bytesutil.ToBytes32([]byte{'B'})
|
||||
s1 := &pb.StateSummary{Slot: 1, Root: r1[:]}
|
||||
s1 := &statepb.StateSummary{Slot: 1, Root: r1[:]}
|
||||
|
||||
// State summary should not exist yet.
|
||||
require.Equal(t, false, db.HasStateSummary(ctx, r1), "State summary should not be saved")
|
||||
@@ -28,7 +28,7 @@ func TestStateSummary_CanSaveRretrieve(t *testing.T) {
|
||||
assert.DeepEqual(t, s1, saved, "State summary does not equal")
|
||||
|
||||
// Save a new state summary.
|
||||
s2 := &pb.StateSummary{Slot: 2, Root: r2[:]}
|
||||
s2 := &statepb.StateSummary{Slot: 2, Root: r2[:]}
|
||||
|
||||
// State summary should not exist yet.
|
||||
require.Equal(t, false, db.HasStateSummary(ctx, r2), "State summary should not be saved")
|
||||
@@ -43,18 +43,18 @@ func TestStateSummary_CanSaveRretrieve(t *testing.T) {
|
||||
func TestStateSummary_CacheToDB(t *testing.T) {
|
||||
db := setupDB(t)
|
||||
|
||||
summaries := make([]*pb.StateSummary, stateSummaryCachePruneCount-1)
|
||||
summaries := make([]*statepb.StateSummary, stateSummaryCachePruneCount-1)
|
||||
for i := range summaries {
|
||||
summaries[i] = &pb.StateSummary{Slot: types.Slot(i), Root: bytesutil.PadTo(bytesutil.Uint64ToBytesLittleEndian(uint64(i)), 32)}
|
||||
summaries[i] = &statepb.StateSummary{Slot: types.Slot(i), Root: bytesutil.PadTo(bytesutil.Uint64ToBytesLittleEndian(uint64(i)), 32)}
|
||||
}
|
||||
|
||||
require.NoError(t, db.SaveStateSummaries(context.Background(), summaries))
|
||||
require.Equal(t, db.stateSummaryCache.len(), stateSummaryCachePruneCount-1)
|
||||
|
||||
require.NoError(t, db.SaveStateSummary(context.Background(), &pb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}}))
|
||||
require.NoError(t, db.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}}))
|
||||
require.Equal(t, db.stateSummaryCache.len(), stateSummaryCachePruneCount)
|
||||
|
||||
require.NoError(t, db.SaveStateSummary(context.Background(), &pb.StateSummary{Slot: 1001, Root: []byte{'c', 'd'}}))
|
||||
require.NoError(t, db.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1001, Root: []byte{'c', 'd'}}))
|
||||
require.Equal(t, db.stateSummaryCache.len(), 1)
|
||||
|
||||
for i := range summaries {
|
||||
|
||||
@@ -14,8 +14,8 @@ go_library(
|
||||
"//beacon-chain/powchain:go_default_library",
|
||||
"//beacon-chain/state/interface:go_default_library",
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared:go_default_library",
|
||||
"//shared/interop:go_default_library",
|
||||
"//shared/slotutil:go_default_library",
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
||||
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared"
|
||||
"github.com/prysmaticlabs/prysm/shared/interop"
|
||||
"github.com/prysmaticlabs/prysm/shared/slotutil"
|
||||
@@ -62,7 +62,7 @@ func NewService(ctx context.Context, cfg *Config) *Service {
|
||||
if err != nil {
|
||||
log.Fatalf("Could not read pre-loaded state: %v", err)
|
||||
}
|
||||
genesisState := &pb.BeaconState{}
|
||||
genesisState := &statepb.BeaconState{}
|
||||
if err := genesisState.UnmarshalSSZ(data); err != nil {
|
||||
log.Fatalf("Could not unmarshal pre-loaded state: %v", err)
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ go_test(
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//beacon-chain/state/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/require:go_default_library",
|
||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||
p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -270,7 +270,7 @@ func TestPool_InsertVoluntaryExit(t *testing.T) {
|
||||
p := &Pool{
|
||||
pending: tt.fields.pending,
|
||||
}
|
||||
s, err := v1.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: validators})
|
||||
s, err := v1.InitializeFromProtoUnsafe(&statepb.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 := v1.InitializeFromProtoUnsafe(&p2ppb.BeaconState{Validators: []*ethpb.Validator{{ExitEpoch: params.BeaconConfig().FarFutureEpoch}}})
|
||||
s, err := v1.InitializeFromProtoUnsafe(&statepb.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)
|
||||
|
||||
@@ -49,11 +49,10 @@ go_library(
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//proto/beacon/p2p:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1/wrapper:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//proto/prysm/v2/wrapper:go_default_library",
|
||||
"//shared:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/fileutil:go_default_library",
|
||||
@@ -135,10 +134,11 @@ go_test(
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//beacon-chain/p2p/testing:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1/wrapper:go_default_library",
|
||||
"//proto/eth/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//proto/prysm/v2/wrapper:go_default_library",
|
||||
"//proto/testing:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/event:go_default_library",
|
||||
|
||||
@@ -17,9 +17,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper"
|
||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper"
|
||||
testpb "github.com/prysmaticlabs/prysm/proto/testing"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -45,7 +46,7 @@ func TestService_Broadcast(t *testing.T) {
|
||||
genesisValidatorsRoot: bytesutil.PadTo([]byte{'A'}, 32),
|
||||
}
|
||||
|
||||
msg := &pb.Fork{
|
||||
msg := &statepb.Fork{
|
||||
Epoch: 55,
|
||||
CurrentVersion: []byte("fooo"),
|
||||
PreviousVersion: []byte("barr"),
|
||||
@@ -76,7 +77,7 @@ func TestService_Broadcast(t *testing.T) {
|
||||
incomingMessage, err := sub.Next(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
result := &pb.Fork{}
|
||||
result := &statepb.Fork{}
|
||||
require.NoError(t, p.Encoding().DecodeGossip(incomingMessage.Data, result))
|
||||
if !proto.Equal(result, msg) {
|
||||
tt.Errorf("Did not receive expected message, got %+v, wanted %+v", result, msg)
|
||||
|
||||
@@ -28,9 +28,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||
testp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/iputils"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
|
||||
@@ -31,7 +31,7 @@ go_test(
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v2/state:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
gogo "github.com/gogo/protobuf/proto"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -26,7 +26,7 @@ func TestSszNetworkEncoder_RoundTrip(t *testing.T) {
|
||||
|
||||
func TestSszNetworkEncoder_FailsSnappyLength(t *testing.T) {
|
||||
e := &encoder.SszNetworkEncoder{}
|
||||
att := &pb.Fork{}
|
||||
att := &statepb.Fork{}
|
||||
data := make([]byte, 32)
|
||||
binary.PutUvarint(data, encoder.MaxGossipSize+32)
|
||||
err := e.DecodeGossip(data, att)
|
||||
@@ -35,14 +35,14 @@ func TestSszNetworkEncoder_FailsSnappyLength(t *testing.T) {
|
||||
|
||||
func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &pb.Fork{
|
||||
msg := &statepb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 9001,
|
||||
}
|
||||
_, err := e.EncodeWithMaxLength(buf, msg)
|
||||
require.NoError(t, err)
|
||||
decoded := &pb.Fork{}
|
||||
decoded := &statepb.Fork{}
|
||||
require.NoError(t, e.DecodeWithMaxLength(buf, decoded))
|
||||
if !proto.Equal(decoded, msg) {
|
||||
t.Logf("decoded=%+v\n", decoded)
|
||||
@@ -52,14 +52,14 @@ func testRoundTripWithLength(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
|
||||
func testRoundTripWithGossip(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &pb.Fork{
|
||||
msg := &statepb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 9001,
|
||||
}
|
||||
_, err := e.EncodeGossip(buf, msg)
|
||||
require.NoError(t, err)
|
||||
decoded := &pb.Fork{}
|
||||
decoded := &statepb.Fork{}
|
||||
require.NoError(t, e.DecodeGossip(buf.Bytes(), decoded))
|
||||
if !proto.Equal(decoded, msg) {
|
||||
t.Logf("decoded=%+v\n", decoded)
|
||||
@@ -69,7 +69,7 @@ func testRoundTripWithGossip(t *testing.T, e *encoder.SszNetworkEncoder) {
|
||||
|
||||
func TestSszNetworkEncoder_EncodeWithMaxLength(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &pb.Fork{
|
||||
msg := &statepb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 9001,
|
||||
@@ -86,7 +86,7 @@ func TestSszNetworkEncoder_EncodeWithMaxLength(t *testing.T) {
|
||||
|
||||
func TestSszNetworkEncoder_DecodeWithMaxLength(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
msg := &pb.Fork{
|
||||
msg := &statepb.Fork{
|
||||
PreviousVersion: []byte("fooo"),
|
||||
CurrentVersion: []byte("barr"),
|
||||
Epoch: 4242,
|
||||
@@ -99,7 +99,7 @@ func TestSszNetworkEncoder_DecodeWithMaxLength(t *testing.T) {
|
||||
params.OverrideBeaconNetworkConfig(c)
|
||||
_, err := e.EncodeGossip(buf, msg)
|
||||
require.NoError(t, err)
|
||||
decoded := &pb.Fork{}
|
||||
decoded := &statepb.Fork{}
|
||||
err = e.DecodeWithMaxLength(buf, decoded)
|
||||
wanted := fmt.Sprintf("goes over the provided max limit of %d", maxChunkSize)
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
@@ -121,7 +121,7 @@ func TestSszNetworkEncoder_DecodeWithMultipleFrames(t *testing.T) {
|
||||
if buf.Len() <= 76490 {
|
||||
t.Errorf("buffer smaller than expected, wanted > %d but got %d", 76490, buf.Len())
|
||||
}
|
||||
decoded := new(pb.BeaconState)
|
||||
decoded := new(statepb.BeaconState)
|
||||
err = e.DecodeWithMaxLength(buf, decoded)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func TestSszNetworkEncoder_MaxInt64(t *testing.T) {
|
||||
func TestSszNetworkEncoder_DecodeWithBadSnappyStream(t *testing.T) {
|
||||
st := newBadSnappyStream()
|
||||
e := &encoder.SszNetworkEncoder{}
|
||||
decoded := new(pb.Fork)
|
||||
decoded := new(statepb.Fork)
|
||||
err := e.DecodeWithMaxLength(st, decoded)
|
||||
assert.ErrorContains(t, io.EOF.Error(), err)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/p2putils"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/p2putils"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
@@ -26,7 +26,7 @@ func TestCorrect_ActiveValidatorsCount(t *testing.T) {
|
||||
ctx: context.Background(),
|
||||
cfg: &Config{DB: db},
|
||||
}
|
||||
bState, err := testutil.NewBeaconState(func(state *pb.BeaconState) error {
|
||||
bState, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error {
|
||||
validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount)
|
||||
for i := 0; i < len(validators); i++ {
|
||||
validators[i] = ðpb.Validator{
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -92,6 +92,6 @@ type PeersProvider interface {
|
||||
|
||||
// MetadataProvider returns the metadata related information for the local peer.
|
||||
type MetadataProvider interface {
|
||||
Metadata() p2p.Metadata
|
||||
Metadata() interfaces.Metadata
|
||||
MetadataSeq() uint64
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ go_library(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/p2p/peers/peerdata:go_default_library",
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//proto/beacon/p2p:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/rand:go_default_library",
|
||||
"//shared/timeutils:go_default_library",
|
||||
@@ -36,9 +36,9 @@ go_test(
|
||||
"//beacon-chain/p2p/peers/peerdata:go_default_library",
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/beacon/p2p/v1/wrapper:go_default_library",
|
||||
"//proto/eth/v1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//proto/prysm/v2/wrapper:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
|
||||
@@ -6,8 +6,7 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata",
|
||||
visibility = ["//beacon-chain:__subpackages__"],
|
||||
deps = [
|
||||
"//proto/beacon/p2p:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
|
||||
@@ -10,10 +10,9 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
pbrpc "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -50,7 +49,7 @@ type PeerData struct {
|
||||
Enr *enr.Record
|
||||
NextValidTime time.Time
|
||||
// Chain related data.
|
||||
MetaData p2p.Metadata
|
||||
MetaData interfaces.Metadata
|
||||
ChainState *pb.Status
|
||||
ChainStateLastUpdated time.Time
|
||||
ChainStateValidationError error
|
||||
@@ -59,7 +58,7 @@ type PeerData struct {
|
||||
ProcessedBlocks uint64
|
||||
BlockProviderUpdated time.Time
|
||||
// Gossip Scoring data.
|
||||
TopicScores map[string]*pbrpc.TopicScoreSnapshot
|
||||
TopicScores map[string]*pb.TopicScoreSnapshot
|
||||
GossipScore float64
|
||||
BehaviourPenalty float64
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ go_library(
|
||||
"//beacon-chain/p2p/peers/peerdata:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/rand:go_default_library",
|
||||
@@ -41,7 +40,6 @@ go_test(
|
||||
"//beacon-chain/p2p/peers/peerdata:go_default_library",
|
||||
"//beacon-chain/p2p/types:go_default_library",
|
||||
"//cmd/beacon-chain/flags:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/rand:go_default_library",
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata"
|
||||
p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||
p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
@@ -38,8 +38,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/rand"
|
||||
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
||||
@@ -230,7 +230,7 @@ func (p *Status) InboundLimit() int {
|
||||
}
|
||||
|
||||
// SetMetadata sets the metadata of the given remote peer.
|
||||
func (p *Status) SetMetadata(pid peer.ID, metaData p2p.Metadata) {
|
||||
func (p *Status) SetMetadata(pid peer.ID, metaData interfaces.Metadata) {
|
||||
p.store.Lock()
|
||||
defer p.store.Unlock()
|
||||
|
||||
@@ -240,7 +240,7 @@ func (p *Status) SetMetadata(pid peer.ID, metaData p2p.Metadata) {
|
||||
|
||||
// Metadata returns a copy of the metadata corresponding to the provided
|
||||
// peer id.
|
||||
func (p *Status) Metadata(pid peer.ID) (p2p.Metadata, error) {
|
||||
func (p *Status) Metadata(pid peer.ID) (interfaces.Metadata, error) {
|
||||
p.store.RLock()
|
||||
defer p.store.RUnlock()
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/peerdata"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
p2ptypes "github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
)
|
||||
|
||||
// SchemaVersionV1 specifies the schema version for our rpc protocol ID.
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/types"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
testp2p "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
|
||||
@@ -26,7 +26,7 @@ func TestService_Send(t *testing.T) {
|
||||
cfg: &Config{},
|
||||
}
|
||||
|
||||
msg := &pb.Fork{
|
||||
msg := &statepb.Fork{
|
||||
CurrentVersion: []byte("fooo"),
|
||||
PreviousVersion: []byte("barr"),
|
||||
Epoch: 55,
|
||||
@@ -36,12 +36,12 @@ func TestService_Send(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
topic := "/testing/1"
|
||||
RPCTopicMappings[topic] = new(pb.Fork)
|
||||
RPCTopicMappings[topic] = new(statepb.Fork)
|
||||
defer func() {
|
||||
delete(RPCTopicMappings, topic)
|
||||
}()
|
||||
p2.SetStreamHandler(topic+"/ssz_snappy", func(stream network.Stream) {
|
||||
rcvd := &pb.Fork{}
|
||||
rcvd := &statepb.Fork{}
|
||||
require.NoError(t, svc.Encoding().DecodeWithMaxLength(stream, rcvd))
|
||||
_, err := svc.Encoding().EncodeWithMaxLength(stream, rcvd)
|
||||
require.NoError(t, err)
|
||||
@@ -54,7 +54,7 @@ func TestService_Send(t *testing.T) {
|
||||
|
||||
testutil.WaitTimeout(&wg, 1*time.Second)
|
||||
|
||||
rcvd := &pb.Fork{}
|
||||
rcvd := &statepb.Fork{}
|
||||
require.NoError(t, svc.Encoding().DecodeWithMaxLength(stream, rcvd))
|
||||
if !proto.Equal(rcvd, msg) {
|
||||
t.Errorf("Expected identical message to be received. got %v want %v", rcvd, msg)
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/shared"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/runutil"
|
||||
@@ -64,7 +64,7 @@ type Service struct {
|
||||
addrFilter *multiaddr.Filters
|
||||
ipLimiter *leakybucket.Collector
|
||||
privKey *ecdsa.PrivateKey
|
||||
metaData p2p.Metadata
|
||||
metaData interfaces.Metadata
|
||||
pubsub *pubsub.PubSub
|
||||
joinedTopics map[string]*pubsub.Topic
|
||||
joinedTopicsLock sync.Mutex
|
||||
@@ -342,7 +342,7 @@ func (s *Service) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) {
|
||||
}
|
||||
|
||||
// Metadata returns a copy of the peer's metadata.
|
||||
func (s *Service) Metadata() p2p.Metadata {
|
||||
func (s *Service) Metadata() interfaces.Metadata {
|
||||
return s.metaData.Copy()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper"
|
||||
"go.opencensus.io/trace"
|
||||
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
|
||||
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1/wrapper"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
|
||||
"github.com/prysmaticlabs/prysm/proto/prysm/v2/wrapper"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
|
||||
@@ -21,9 +21,9 @@ go_library(
|
||||
"//beacon-chain/p2p/encoder:go_default_library",
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//beacon-chain/p2p/peers/scorers:go_default_library",
|
||||
"//proto/beacon/p2p:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/interfaces:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v2:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//crypto:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enode:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||
|
||||
@@ -10,12 +10,11 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"github.com/prysmaticlabs/prysm/proto/beacon/p2p"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
||||
"github.com/prysmaticlabs/prysm/proto/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// FakeP2P stack
|
||||
@@ -75,7 +74,7 @@ func (p *FakeP2P) LeaveTopic(_ string) error {
|
||||
}
|
||||
|
||||
// Metadata -- fake.
|
||||
func (p *FakeP2P) Metadata() p2p.Metadata {
|
||||
func (p *FakeP2P) Metadata() interfaces.Metadata {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user