Fix duplicated imports (#9304)

* Fix duplicated imports

* Fix metrics test
This commit is contained in:
terence tsao
2021-07-29 14:45:17 -07:00
committed by GitHub
parent fcd4938ec0
commit 012d279663
130 changed files with 644 additions and 723 deletions

View File

@@ -11,7 +11,6 @@ import (
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -60,7 +59,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(), &statepb.StateSummary{Slot: 1, Root: newRoot[:]}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &ethpb.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 +104,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(), &statepb.StateSummary{Slot: 1, Root: newRoot[:]}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &ethpb.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 +126,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(), &statepb.StateSummary{Root: r[:]}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(context.Background(), &ethpb.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")

View File

@@ -5,7 +5,6 @@ import (
"testing"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
@@ -25,7 +24,7 @@ func TestReportEpochMetrics_BadAttestation(t *testing.T) {
require.NoError(t, err)
h, err := testutil.NewBeaconState()
require.NoError(t, err)
require.NoError(t, h.AppendCurrentEpochAttestations(&statepb.PendingAttestation{InclusionDelay: 0}))
require.NoError(t, h.AppendCurrentEpochAttestations(&eth.PendingAttestation{InclusionDelay: 0}))
err = reportEpochMetrics(context.Background(), s, h)
require.ErrorContains(t, "attestation with inclusion delay of 0", err)
}
@@ -36,7 +35,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(&statepb.PendingAttestation{InclusionDelay: 1, Data: testutil.HydrateAttestationData(&eth.AttestationData{})}))
require.NoError(t, h.AppendCurrentEpochAttestations(&eth.PendingAttestation{InclusionDelay: 1, Data: testutil.HydrateAttestationData(&eth.AttestationData{})}))
err = reportEpochMetrics(context.Background(), h, h)
require.ErrorContains(t, "slot 0 out of bounds", err)
}

View File

@@ -11,7 +11,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/protoarray"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -61,7 +60,7 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) {
require.NoError(t, err)
s, err = testutil.NewBeaconState()
require.NoError(t, err)
err = s.SetFork(&statepb.Fork{
err = s.SetFork(&ethpb.Fork{
Epoch: 0,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
@@ -186,7 +185,7 @@ func TestStore_SaveCheckpointState(t *testing.T) {
r = bytesutil.ToBytes32([]byte{'A'})
cp1 := &ethpb.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, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Root: bytesutil.PadTo([]byte{'A'}, 32)}))
s1, err := service.getAttPreState(ctx, cp1)
require.NoError(t, err)
@@ -194,7 +193,7 @@ func TestStore_SaveCheckpointState(t *testing.T) {
cp2 := &ethpb.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, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'B'}, 32)}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.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 +217,7 @@ func TestStore_SaveCheckpointState(t *testing.T) {
service.prevFinalizedCheckpt = &ethpb.Checkpoint{Root: r[:]}
cp3 := &ethpb.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, &statepb.StateSummary{Root: bytesutil.PadTo([]byte{'C'}, 32)}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.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")

View File

@@ -13,7 +13,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/bls"
@@ -279,7 +278,7 @@ func (s *Service) handleBlockAfterBatchVerify(ctx context.Context, signed block.
if err := s.insertBlockToForkChoiceStore(ctx, b, blockRoot, fCheckpoint, jCheckpoint); err != nil {
return err
}
if err := s.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{
if err := s.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{
Slot: signed.Block().Slot(),
Root: blockRoot[:],
}); err != nil {

View File

@@ -21,7 +21,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
@@ -60,10 +59,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, &statepb.StateSummary{Slot: st.Slot(), Root: randomParentRoot[:]}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.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, &statepb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: st.Slot(), Root: randomParentRoot2}))
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, st.Copy(), bytesutil.ToBytes32(randomParentRoot2)))
tests := []struct {
@@ -256,7 +255,7 @@ func TestCachedPreState_CanGetFromStateSummary(t *testing.T) {
service, err := NewService(ctx, cfg)
require.NoError(t, err)
s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
s, err := v1.InitializeFromProto(&ethpb.BeaconState{Slot: 1, GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:]})
require.NoError(t, err)
genesisStateRoot := [32]byte{}
@@ -273,7 +272,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, &statepb.StateSummary{Slot: 1, Root: gRoot[:]}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.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 +307,9 @@ func TestCachedPreState_CanGetFromDB(t *testing.T) {
assert.ErrorContains(t, wanted, err)
b.Block.ParentRoot = gRoot[:]
s, err := v1.InitializeFromProto(&statepb.BeaconState{Slot: 1})
s, err := v1.InitializeFromProto(&ethpb.BeaconState{Slot: 1})
require.NoError(t, err)
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: gRoot[:]}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.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 +762,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, &statepb.StateSummary{Root: bytesutil.PadTo(test.want.Root, 32)}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.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 +877,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, &statepb.StateSummary{Root: gRoot[:]}))
require.NoError(t, service.cfg.BeaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Root: gRoot[:]}))
beaconState, _ := testutil.DeterministicGenesisState(t, 32)
require.NoError(t, service.cfg.BeaconDB.SaveState(ctx, beaconState, gRoot))
service.genesisRoot = gRoot

View File

@@ -24,8 +24,6 @@ import (
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
@@ -74,20 +72,20 @@ func setupBeaconChain(t *testing.T, beaconDB db.Database) *Service {
bState, _ := testutil.DeterministicGenesisState(t, 10)
pbState, err := v1.ProtobufBeaconState(bState.InnerStateUnsafe())
require.NoError(t, err)
err = beaconDB.SavePowchainData(ctx, &protodb.ETH1ChainData{
err = beaconDB.SavePowchainData(ctx, &ethpb.ETH1ChainData{
BeaconState: pbState,
Trie: &protodb.SparseMerkleTrie{},
CurrentEth1Data: &protodb.LatestETH1Data{
Trie: &ethpb.SparseMerkleTrie{},
CurrentEth1Data: &ethpb.LatestETH1Data{
BlockHash: make([]byte, 32),
},
ChainstartData: &protodb.ChainStartData{
ChainstartData: &ethpb.ChainStartData{
Eth1Data: &ethpb.Eth1Data{
DepositRoot: make([]byte, 32),
DepositCount: 0,
BlockHash: make([]byte, 32),
},
},
DepositContainers: []*protodb.DepositContainer{},
DepositContainers: []*ethpb.DepositContainer{},
})
require.NoError(t, err)
web3Service, err = powchain.NewService(ctx, &powchain.Web3ServiceConfig{
@@ -507,7 +505,7 @@ func BenchmarkHasBlockForkChoiceStore(b *testing.B) {
block := &ethpb.SignedBeaconBlock{Block: &ethpb.BeaconBlock{Body: &ethpb.BeaconBlockBody{}}}
r, err := block.Block.HashTreeRoot()
require.NoError(b, err)
bs := &statepb.BeaconState{FinalizedCheckpoint: &ethpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: &ethpb.Checkpoint{Root: make([]byte, 32)}}
bs := &ethpb.BeaconState{FinalizedCheckpoint: &ethpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: &ethpb.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))

View File

@@ -7,7 +7,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -19,7 +18,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
cache := NewCheckpointStateCache()
cp1 := &ethpb.Checkpoint{Epoch: 1, Root: bytesutil.PadTo([]byte{'A'}, 32)}
st, err := v1.InitializeFromProto(&statepb.BeaconState{
st, err := v1.InitializeFromProto(&ethpb.BeaconState{
GenesisValidatorsRoot: params.BeaconConfig().ZeroHash[:],
Slot: 64,
})
@@ -43,7 +42,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
}
cp2 := &ethpb.Checkpoint{Epoch: 2, Root: bytesutil.PadTo([]byte{'B'}, 32)}
st2, err := v1.InitializeFromProto(&statepb.BeaconState{
st2, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 128,
})
require.NoError(t, err)
@@ -60,7 +59,7 @@ func TestCheckpointStateCache_StateByCheckpoint(t *testing.T) {
func TestCheckpointStateCache_MaxSize(t *testing.T) {
c := NewCheckpointStateCache()
st, err := v1.InitializeFromProto(&statepb.BeaconState{
st, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 0,
})
require.NoError(t, err)

View File

@@ -7,7 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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))
s, err = v1.InitializeFromProto(&statepb.BeaconState{
s, err = v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 10,
})
require.NoError(t, err)

View File

@@ -8,7 +8,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -30,11 +29,11 @@ func TestProcessDeposits_SameValidatorMultipleDepositsSameBlock(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{
beaconState, err := stateAltair.InitializeFromProto(&ethpb.BeaconStateAltair{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},
@@ -63,7 +62,7 @@ func TestProcessDeposits_MerkleBranchFailsVerification(t *testing.T) {
require.NoError(t, err, "Could not generate proof")
deposit.Proof = proof
beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{
beaconState, err := stateAltair.InitializeFromProto(&ethpb.BeaconStateAltair{
Eth1Data: &ethpb.Eth1Data{
DepositRoot: []byte{0},
BlockHash: []byte{1},
@@ -88,11 +87,11 @@ func TestProcessDeposits_AddsNewValidatorDeposit(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{
beaconState, err := stateAltair.InitializeFromProto(&ethpb.BeaconStateAltair{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},
@@ -145,7 +144,7 @@ func TestProcessDeposits_RepeatedDeposit_IncreasesValidatorBalance(t *testing.T)
}
balances := []uint64{0, 50}
root := depositTrie.Root()
beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{
beaconState, err := stateAltair.InitializeFromProto(&ethpb.BeaconStateAltair{
Validators: registry,
Balances: balances,
Eth1Data: &ethpb.Eth1Data{
@@ -173,11 +172,11 @@ func TestProcessDeposit_AddsNewValidatorDeposit(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{
beaconState, err := stateAltair.InitializeFromProto(&ethpb.BeaconStateAltair{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},
@@ -215,11 +214,11 @@ func TestProcessDeposit_SkipsInvalidDeposit(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := stateAltair.InitializeFromProto(&statepb.BeaconStateAltair{
beaconState, err := stateAltair.InitializeFromProto(&ethpb.BeaconStateAltair{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},

View File

@@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/bls"
@@ -205,7 +204,7 @@ func ProcessAttestationNoVerifySignature(
if err != nil {
return nil, err
}
pendingAtt := &statepb.PendingAttestation{
pendingAtt := &ethpb.PendingAttestation{
Data: data,
AggregationBits: att.AggregationBits,
InclusionDelay: beaconState.Slot() - s,

View File

@@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -33,7 +32,7 @@ func TestProcessAttestationNoVerifySignature_BeaconFuzzIssue78(t *testing.T) {
if err != nil {
t.Fatal(err)
}
spb := &statepb.BeaconState{}
spb := &ethpb.BeaconState{}
if err := spb.UnmarshalSSZ(stateData); err != nil {
t.Fatal(err)
}
@@ -73,7 +72,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
err = blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att)
assert.NotEqual(t, nil, err)

View File

@@ -11,7 +11,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/aggregation"
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
@@ -69,7 +68,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendPreviousEpochAttestations(&ethpb.PendingAttestation{}))
want := fmt.Sprintf(
"expected target epoch (%d) to be the previous epoch (%d) or the current epoch (%d)",
@@ -102,7 +101,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
want := "source check point not equal to current justified checkpoint"
_, err := blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b))
@@ -140,7 +139,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendPreviousEpochAttestations(&ethpb.PendingAttestation{}))
want := "source check point not equal to previous justified checkpoint"
_, err = blocks.ProcessAttestations(context.Background(), beaconState, wrapper.WrappedPhase0SignedBeaconBlock(b))
@@ -176,7 +175,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.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 +200,7 @@ func TestProcessAttestations_OK(t *testing.T) {
cfc := beaconState.CurrentJustifiedCheckpoint()
cfc.Root = mockRoot[:]
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
committee, err := helpers.BeaconCommitteeFromState(beaconState, att.Data.Slot, att.Data.CommitteeIndex)
require.NoError(t, err)
@@ -243,7 +242,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex)
require.NoError(t, err)
@@ -306,7 +305,7 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) {
cfc := beaconState.CurrentJustifiedCheckpoint()
cfc.Root = mockRoot[:]
require.NoError(t, beaconState.SetCurrentJustifiedCheckpoint(cfc))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex)
require.NoError(t, err)
@@ -396,7 +395,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
_, err = blocks.ProcessAttestationNoVerifySignature(context.TODO(), beaconState, att)
assert.NoError(t, err)
@@ -427,7 +426,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
err = blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att)
assert.NoError(t, err)
@@ -453,7 +452,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(&statepb.PendingAttestation{}))
require.NoError(t, beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{}))
err := blocks.VerifyAttestationNoVerifySignature(context.TODO(), beaconState, att)
require.ErrorContains(t, "committee index 100 >= committee count 1", err)
}
@@ -467,7 +466,7 @@ func TestConvertToIndexed_OK(t *testing.T) {
}
}
state, err := v1.InitializeFromProto(&statepb.BeaconState{
state, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 5,
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
@@ -525,10 +524,10 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
}
}
state, err := v1.InitializeFromProto(&statepb.BeaconState{
state, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 5,
Validators: validators,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
Epoch: 0,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
@@ -676,7 +675,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(&statepb.Fork{
require.NoError(t, st.SetFork(&ethpb.Fork{
Epoch: 1,
CurrentVersion: []byte{0, 1, 2, 3},
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
@@ -803,7 +802,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(&statepb.Fork{Epoch: 1, CurrentVersion: []byte{0, 1, 2, 3}, PreviousVersion: []byte{0, 1, 1, 1}}))
require.NoError(t, st.SetFork(&ethpb.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)

View File

@@ -10,7 +10,6 @@ import (
v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -47,7 +46,7 @@ func TestProcessAttesterSlashings_DataNotSlashable(t *testing.T) {
var registry []*ethpb.Validator
currentSlot := types.Slot(0)
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Slot: currentSlot,
})
@@ -66,7 +65,7 @@ func TestProcessAttesterSlashings_IndexedAttestationFailedToVerify(t *testing.T)
var registry []*ethpb.Validator
currentSlot := types.Slot(0)
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Slot: currentSlot,
})

View File

@@ -10,7 +10,6 @@ import (
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@@ -19,7 +18,7 @@ import (
func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
ctx := context.Background()
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
att := &eth.Attestation{}
for i := 0; i < 10000; i++ {
@@ -34,7 +33,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
func TestFuzzProcessBlockHeader_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
block := &eth.SignedBeaconBlock{}
for i := 0; i < 10000; i++ {
@@ -106,7 +105,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) {
for i := 0; i < 100000; i++ {
fuzzer.Fuzz(eth1data)
fuzzer.Fuzz(&stateVotes)
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
Eth1DataVotes: stateVotes,
})
require.NoError(t, err)
@@ -118,7 +117,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) {
func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
block := &eth.BeaconBlock{}
for i := 0; i < 10000; i++ {
@@ -133,7 +132,7 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) {
func TestFuzzProcessRandao_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
b := &eth.SignedBeaconBlock{}
for i := 0; i < 10000; i++ {
@@ -150,7 +149,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) {
func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
blockBody := &eth.BeaconBlockBody{}
for i := 0; i < 10000; i++ {
@@ -167,7 +166,7 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) {
func TestFuzzProcessProposerSlashings_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
p := &eth.ProposerSlashing{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -184,7 +183,7 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) {
func TestFuzzVerifyProposerSlashing_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
proposerSlashing := &eth.ProposerSlashing{}
for i := 0; i < 10000; i++ {
fuzzer.Fuzz(state)
@@ -198,7 +197,7 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) {
func TestFuzzProcessAttesterSlashings_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
a := &eth.AttesterSlashing{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -215,7 +214,7 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) {
func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
attesterSlashing := &eth.AttesterSlashing{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -252,7 +251,7 @@ func TestFuzzslashableAttesterIndices_10000(t *testing.T) {
func TestFuzzProcessAttestations_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
b := &eth.SignedBeaconBlock{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -269,7 +268,7 @@ func TestFuzzProcessAttestations_10000(t *testing.T) {
func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
b := &eth.SignedBeaconBlock{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -286,7 +285,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) {
func TestFuzzProcessAttestation_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
attestation := &eth.Attestation{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -303,7 +302,7 @@ func TestFuzzProcessAttestation_10000(t *testing.T) {
func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
idxAttestation := &eth.IndexedAttestation{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -318,7 +317,7 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) {
func TestFuzzVerifyAttestation_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
attestation := &eth.Attestation{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -333,7 +332,7 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) {
func TestFuzzProcessDeposits_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
deposits := make([]*eth.Deposit, 100)
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -352,7 +351,7 @@ func TestFuzzProcessDeposits_10000(t *testing.T) {
func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
deposit := &eth.Deposit{}
ctx := context.Background()
@@ -370,7 +369,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) {
func TestFuzzProcessDeposit_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
deposit := &eth.Deposit{}
for i := 0; i < 10000; i++ {
@@ -387,7 +386,7 @@ func TestFuzzProcessDeposit_10000(t *testing.T) {
func TestFuzzverifyDeposit_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
deposit := &eth.Deposit{}
for i := 0; i < 10000; i++ {
fuzzer.Fuzz(state)
@@ -401,7 +400,7 @@ func TestFuzzverifyDeposit_10000(t *testing.T) {
func TestFuzzProcessVoluntaryExits_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
e := &eth.SignedVoluntaryExit{}
ctx := context.Background()
for i := 0; i < 10000; i++ {
@@ -418,7 +417,7 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) {
func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
e := &eth.SignedVoluntaryExit{}
for i := 0; i < 10000; i++ {
fuzzer.Fuzz(state)
@@ -437,7 +436,7 @@ func TestFuzzVerifyExit_10000(t *testing.T) {
ve := &eth.SignedVoluntaryExit{}
val, err := v1.NewValidator(&ethpb.Validator{})
_ = err
fork := &statepb.Fork{}
fork := &ethpb.Fork{}
var slot types.Slot
for i := 0; i < 10000; i++ {

View File

@@ -8,7 +8,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/depositutil"
@@ -258,7 +257,7 @@ func verifyDepositDataWithDomain(ctx context.Context, deps []*ethpb.Deposit, dom
}
pks[i] = dpk
sigs[i] = dep.Data.Signature
depositMessage := &statepb.DepositMessage{
depositMessage := &ethpb.DepositMessage{
PublicKey: dep.Data.PublicKey,
WithdrawalCredentials: dep.Data.WithdrawalCredentials,
Amount: dep.Data.Amount,

View File

@@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -40,11 +39,11 @@ func TestProcessDeposits_SameValidatorMultipleDepositsSameBlock(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},
@@ -80,7 +79,7 @@ func TestProcessDeposits_MerkleBranchFailsVerification(t *testing.T) {
Deposits: []*ethpb.Deposit{deposit},
},
}
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Eth1Data: &ethpb.Eth1Data{
DepositRoot: []byte{0},
BlockHash: []byte{1},
@@ -111,11 +110,11 @@ func TestProcessDeposits_AddsNewValidatorDeposit(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},
@@ -174,7 +173,7 @@ func TestProcessDeposits_RepeatedDeposit_IncreasesValidatorBalance(t *testing.T)
}
balances := []uint64{0, 50}
root := depositTrie.Root()
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Balances: balances,
Eth1Data: &ethpb.Eth1Data{
@@ -202,11 +201,11 @@ func TestProcessDeposit_AddsNewValidatorDeposit(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},
@@ -244,11 +243,11 @@ func TestProcessDeposit_SkipsInvalidDeposit(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},
@@ -299,11 +298,11 @@ func TestPreGenesisDeposits_SkipInvalidDeposit(t *testing.T) {
},
}
balances := []uint64{0}
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Balances: balances,
Eth1Data: eth1Data,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
},

View File

@@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/copyutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -71,7 +70,7 @@ func TestEth1DataHasEnoughSupport(t *testing.T) {
c.EpochsPerEth1VotingPeriod = tt.votingPeriodLength
params.OverrideBeaconConfig(c)
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
Eth1DataVotes: tt.stateVotes,
})
require.NoError(t, err)
@@ -161,7 +160,7 @@ func TestAreEth1DataEqual(t *testing.T) {
}
func TestProcessEth1Data_SetsCorrectly(t *testing.T) {
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Eth1DataVotes: []*ethpb.Eth1Data{},
})
require.NoError(t, err)

View File

@@ -10,7 +10,6 @@ import (
v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -90,7 +89,7 @@ func ProcessVoluntaryExits(
func VerifyExitAndSignature(
validator state.ReadOnlyValidator,
currentSlot types.Slot,
fork *statepb.Fork,
fork *ethpb.Fork,
signed *ethpb.SignedVoluntaryExit,
genesisRoot []byte,
) error {

View File

@@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
@@ -31,7 +30,7 @@ func TestProcessVoluntaryExits_NotActiveLongEnoughToExit(t *testing.T) {
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
},
}
state, err := v1.InitializeFromProto(&statepb.BeaconState{
state, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Slot: 10,
})
@@ -61,7 +60,7 @@ func TestProcessVoluntaryExits_ExitAlreadySubmitted(t *testing.T) {
ExitEpoch: 10,
},
}
state, err := v1.InitializeFromProto(&statepb.BeaconState{
state, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Slot: 0,
})
@@ -93,9 +92,9 @@ func TestProcessVoluntaryExits_AppliesCorrectStatus(t *testing.T) {
ActivationEpoch: 0,
},
}
state, err := v1.InitializeFromProto(&statepb.BeaconState{
state, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
},

View File

@@ -7,7 +7,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
@@ -19,7 +18,7 @@ import (
func TestVerifyProposerSlashing_BeaconFuzzIssue91(t *testing.T) {
file, err := ioutil.ReadFile("testdata/beaconfuzz_91_beacon.ssz")
require.NoError(t, err)
rawState := &statepb.BeaconState{}
rawState := &ethpb.BeaconState{}
err = rawState.UnmarshalSSZ(file)
require.NoError(t, err)

View File

@@ -12,7 +12,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -118,7 +117,7 @@ func TestProcessProposerSlashings_ValidatorNotSlashable(t *testing.T) {
},
}
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: registry,
Slot: currentSlot,
})

View File

@@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
@@ -27,7 +26,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 := (&statepb.SigningData{ObjectRoot: buf, Domain: domain}).HashTreeRoot()
root, err := (&ethpb.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[:])

View File

@@ -14,7 +14,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/copyutil"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
@@ -56,7 +55,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 state.ReadOnlyBeaconState, atts []*statepb.PendingAttestation) (uint64, error) {
func AttestingBalance(state state.ReadOnlyBeaconState, atts []*ethpb.PendingAttestation) (uint64, error) {
indices, err := UnslashedAttestingIndices(state, atts)
if err != nil {
return 0, errors.Wrap(err, "could not get attesting indices")
@@ -378,7 +377,7 @@ func ProcessHistoricalRootsUpdate(state state.BeaconState) (state.BeaconState, e
// Set historical root accumulator.
epochsPerHistoricalRoot := params.BeaconConfig().SlotsPerHistoricalRoot.DivSlot(params.BeaconConfig().SlotsPerEpoch)
if nextEpoch.Mod(uint64(epochsPerHistoricalRoot)) == 0 {
historicalBatch := &statepb.HistoricalBatch{
historicalBatch := &ethpb.HistoricalBatch{
BlockRoots: state.BlockRoots(),
StateRoots: state.StateRoots(),
}
@@ -461,7 +460,7 @@ func ProcessFinalUpdates(state state.BeaconState) (state.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 state.ReadOnlyBeaconState, atts []*statepb.PendingAttestation) ([]types.ValidatorIndex, error) {
func UnslashedAttestingIndices(state state.ReadOnlyBeaconState, atts []*ethpb.PendingAttestation) ([]types.ValidatorIndex, error) {
var setIndices []types.ValidatorIndex
seen := make(map[uint64]bool)

View File

@@ -5,13 +5,13 @@ import (
fuzz "github.com/google/gofuzz"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestFuzzFinalUpdates_10000(t *testing.T) {
fuzzer := fuzz.NewWithSeed(0)
base := &statepb.BeaconState{}
base := &ethpb.BeaconState{}
for i := 0; i < 10000; i++ {
fuzzer.Fuzz(base)

View File

@@ -11,7 +11,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -21,9 +20,9 @@ import (
func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
// Generate 2 attestations.
atts := make([]*statepb.PendingAttestation, 2)
atts := make([]*ethpb.PendingAttestation, 2)
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
Target: &ethpb.Checkpoint{Epoch: 0, Root: make([]byte, 32)},
},
@@ -39,7 +38,7 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
}
}
base := &statepb.BeaconState{
base := &ethpb.BeaconState{
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}
@@ -68,9 +67,9 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
// Generate 5 of the same attestations.
atts := make([]*statepb.PendingAttestation, 5)
atts := make([]*ethpb.PendingAttestation, 5)
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
Target: &ethpb.Checkpoint{Epoch: 0}},
AggregationBits: bitfield.Bitlist{0x00, 0xFF, 0xFF, 0xFF},
@@ -85,7 +84,7 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
ExitEpoch: params.BeaconConfig().FarFutureEpoch,
}
}
base := &statepb.BeaconState{
base := &ethpb.BeaconState{
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}
@@ -105,9 +104,9 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
func TestAttestingBalance_CorrectBalance(t *testing.T) {
helpers.ClearCache()
// Generate 2 attestations.
atts := make([]*statepb.PendingAttestation, 2)
atts := make([]*ethpb.PendingAttestation, 2)
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{
Target: &ethpb.Checkpoint{Root: make([]byte, 32)},
Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
@@ -128,7 +127,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) {
}
balances[i] = params.BeaconConfig().MaxEffectiveBalance
}
base := &statepb.BeaconState{
base := &ethpb.BeaconState{
Slot: 2,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
@@ -145,7 +144,7 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) {
}
func TestProcessSlashings_NotSlashed(t *testing.T) {
base := &statepb.BeaconState{
base := &ethpb.BeaconState{
Slot: 0,
Validators: []*ethpb.Validator{{Slashed: true}},
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
@@ -161,11 +160,11 @@ func TestProcessSlashings_NotSlashed(t *testing.T) {
func TestProcessSlashings_SlashedLess(t *testing.T) {
tests := []struct {
state *statepb.BeaconState
state *ethpb.BeaconState
want uint64
}{
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
@@ -179,7 +178,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
@@ -195,7 +194,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
want: uint64(32000000000), // 32 * 1e9 - 500000000
},
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
@@ -211,7 +210,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
@@ -231,6 +230,7 @@ func TestProcessSlashings_SlashedLess(t *testing.T) {
original := proto.Clone(tt.state)
s, err := v1.InitializeFromProto(tt.state)
require.NoError(t, err)
helpers.ClearCache()
newState, err := epoch.ProcessSlashings(s)
require.NoError(t, err)
assert.Equal(t, tt.want, newState.Balances()[0], "ProcessSlashings({%v}) = newState; newState.Balances[0] = %d", original, newState.Balances()[0])
@@ -277,7 +277,7 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) {
}
func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
base := &statepb.BeaconState{
base := &ethpb.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 := &statepb.BeaconState{
base := &ethpb.BeaconState{
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
FinalizedCheckpoint: &ethpb.Checkpoint{Epoch: 6, Root: make([]byte, 32)},
}
@@ -331,7 +331,7 @@ func TestProcessRegistryUpdates_EligibleToActivate(t *testing.T) {
}
func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
base := &statepb.BeaconState{
base := &ethpb.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 := &statepb.BeaconState{
base := &ethpb.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 := &statepb.BeaconState{
base := &ethpb.BeaconState{
Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(e)),
Validators: []*ethpb.Validator{
{

View File

@@ -8,7 +8,7 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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 state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, bool, error) {
func AttestedCurrentEpoch(s state.ReadOnlyBeaconState, a *ethpb.PendingAttestation) (bool, bool, error) {
currentEpoch := helpers.CurrentEpoch(s)
var votedCurrentEpoch, votedTarget bool
// Did validator vote current epoch.
@@ -87,7 +87,7 @@ func AttestedCurrentEpoch(s state.ReadOnlyBeaconState, a *statepb.PendingAttesta
}
// AttestedPrevEpoch returns true if attestation `a` attested once in previous epoch and epoch boundary block and/or the same head.
func AttestedPrevEpoch(s state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, bool, bool, error) {
func AttestedPrevEpoch(s state.ReadOnlyBeaconState, a *ethpb.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 state.ReadOnlyBeaconState, a *statepb.PendingAttestatio
}
// SameTarget returns true if attestation `a` attested to the same target block in state.
func SameTarget(state state.ReadOnlyBeaconState, a *statepb.PendingAttestation, e types.Epoch) (bool, error) {
func SameTarget(state state.ReadOnlyBeaconState, a *ethpb.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 state.ReadOnlyBeaconState, a *statepb.PendingAttestation,
}
// SameHead returns true if attestation `a` attested to the same block by attestation slot in state.
func SameHead(state state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (bool, error) {
func SameHead(state state.ReadOnlyBeaconState, a *ethpb.PendingAttestation) (bool, error) {
r, err := helpers.BlockRootAtSlot(state, a.Data.Slot)
if err != nil {
return false, err
@@ -139,7 +139,7 @@ func SameHead(state state.ReadOnlyBeaconState, a *statepb.PendingAttestation) (b
}
// UpdateValidator updates pre computed validator store.
func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *statepb.PendingAttestation, aSlot types.Slot) []*Validator {
func UpdateValidator(vp []*Validator, record *Validator, indices []uint64, a *ethpb.PendingAttestation, aSlot types.Slot) []*Validator {
inclusionSlot := aSlot + a.InclusionDelay
for _, i := range indices {

View File

@@ -8,7 +8,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
@@ -21,7 +20,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 := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
a := &ethpb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
// Indices 1 3 and 5 attested
vp = precompute.UpdateValidator(vp, record, []uint64{1, 3, 5}, a, 100)
@@ -37,7 +36,7 @@ func TestUpdateValidator_InclusionOnlyCountsPrevEpoch(t *testing.T) {
e := params.BeaconConfig().FarFutureSlot
vp := []*precompute.Validator{{InclusionSlot: e}}
record := &precompute.Validator{IsCurrentEpochAttester: true, IsCurrentEpochTargetAttester: true}
a := &statepb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
a := &ethpb.PendingAttestation{InclusionDelay: 1, ProposerIndex: 2}
// Verify inclusion info doesnt get updated.
vp = precompute.UpdateValidator(vp, record, []uint64{0}, a, 100)
@@ -80,12 +79,12 @@ func TestSameHead(t *testing.T) {
br[0] = r[:]
require.NoError(t, beaconState.SetBlockRoots(br))
att.Data.BeaconBlockRoot = r[:]
same, err := precompute.SameHead(beaconState, &statepb.PendingAttestation{Data: att.Data})
same, err := precompute.SameHead(beaconState, &ethpb.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, &statepb.PendingAttestation{Data: att.Data})
same, err = precompute.SameHead(beaconState, &ethpb.PendingAttestation{Data: att.Data})
require.NoError(t, err)
assert.Equal(t, false, same, "Head in state matches head in attestation")
}
@@ -100,12 +99,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, &statepb.PendingAttestation{Data: att.Data}, 0)
same, err := precompute.SameTarget(beaconState, &ethpb.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, &statepb.PendingAttestation{Data: att.Data}, 0)
same, err = precompute.SameTarget(beaconState, &ethpb.PendingAttestation{Data: att.Data}, 0)
require.NoError(t, err)
assert.Equal(t, false, same, "Head in state matches head in attestation")
}
@@ -121,7 +120,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, &statepb.PendingAttestation{Data: att.Data})
votedEpoch, votedTarget, votedHead, err := precompute.AttestedPrevEpoch(beaconState, &ethpb.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 +139,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, &statepb.PendingAttestation{Data: att.Data})
votedEpoch, votedTarget, err := precompute.AttestedCurrentEpoch(beaconState, &ethpb.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 +169,9 @@ func TestProcessAttestations(t *testing.T) {
require.NoError(t, beaconState.SetBlockRoots(br))
att2.Data.Target.Root = newRt[:]
att2.Data.BeaconBlockRoot = newRt[:]
err := beaconState.AppendPreviousEpochAttestations(&statepb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1})
err := beaconState.AppendPreviousEpochAttestations(&ethpb.PendingAttestation{Data: att1.Data, AggregationBits: bf, InclusionDelay: 1})
require.NoError(t, err)
err = beaconState.AppendCurrentEpochAttestations(&statepb.PendingAttestation{Data: att2.Data, AggregationBits: bf, InclusionDelay: 1})
err = beaconState.AppendCurrentEpochAttestations(&ethpb.PendingAttestation{Data: att2.Data, AggregationBits: bf, InclusionDelay: 1})
require.NoError(t, err)
pVals := make([]*precompute.Validator, validators)

View File

@@ -8,7 +8,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@@ -21,7 +20,7 @@ func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *test
for i := 0; i < len(blockRoots); i++ {
blockRoots[i] = []byte{byte(i)}
}
base := &statepb.BeaconState{
base := &ethpb.BeaconState{
Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1,
PreviousJustifiedCheckpoint: &ethpb.Checkpoint{
Epoch: 0,
@@ -58,7 +57,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyCurrentEpoch(t *te
for i := 0; i < len(blockRoots); i++ {
blockRoots[i] = []byte{byte(i)}
}
base := &statepb.BeaconState{
base := &ethpb.BeaconState{
Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1,
PreviousJustifiedCheckpoint: &ethpb.Checkpoint{
Epoch: 0,
@@ -95,7 +94,7 @@ func TestProcessJustificationAndFinalizationPreCompute_JustifyPrevEpoch(t *testi
for i := 0; i < len(blockRoots); i++ {
blockRoots[i] = []byte{byte(i)}
}
base := &statepb.BeaconState{
base := &ethpb.BeaconState{
Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1,
PreviousJustifiedCheckpoint: &ethpb.Checkpoint{
Epoch: 0,

View File

@@ -7,7 +7,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@@ -15,7 +14,7 @@ import (
func TestNew(t *testing.T) {
ffe := params.BeaconConfig().FarFutureEpoch
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: params.BeaconConfig().SlotsPerEpoch,
// Validator 0 is slashed
// Validator 1 is withdrawable

View File

@@ -12,7 +12,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/mathutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -23,9 +22,9 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) {
e := params.BeaconConfig().SlotsPerEpoch
validatorCount := uint64(2048)
base := buildState(e+3, validatorCount)
atts := make([]*statepb.PendingAttestation, 3)
atts := make([]*ethpb.PendingAttestation, 3)
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{
Target: &ethpb.Checkpoint{Root: make([]byte, 32)},
Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
@@ -62,10 +61,10 @@ func TestAttestationDeltaPrecompute(t *testing.T) {
e := params.BeaconConfig().SlotsPerEpoch
validatorCount := uint64(2048)
base := buildState(e+2, validatorCount)
atts := make([]*statepb.PendingAttestation, 3)
atts := make([]*ethpb.PendingAttestation, 3)
var emptyRoot [32]byte
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{
Target: &ethpb.Checkpoint{
Root: emptyRoot[:],
@@ -146,10 +145,10 @@ func TestAttestationDeltas_ZeroEpoch(t *testing.T) {
e := params.BeaconConfig().SlotsPerEpoch
validatorCount := uint64(2048)
base := buildState(e+2, validatorCount)
atts := make([]*statepb.PendingAttestation, 3)
atts := make([]*ethpb.PendingAttestation, 3)
var emptyRoot [32]byte
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{
Target: &ethpb.Checkpoint{
Root: emptyRoot[:],
@@ -182,10 +181,10 @@ func TestAttestationDeltas_ZeroInclusionDelay(t *testing.T) {
e := params.BeaconConfig().SlotsPerEpoch
validatorCount := uint64(2048)
base := buildState(e+2, validatorCount)
atts := make([]*statepb.PendingAttestation, 3)
atts := make([]*ethpb.PendingAttestation, 3)
var emptyRoot [32]byte
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{
Target: &ethpb.Checkpoint{
Root: emptyRoot[:],
@@ -215,9 +214,9 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing.
e := params.BeaconConfig().SlotsPerEpoch
validatorCount := uint64(2048)
base := buildState(e+3, validatorCount)
atts := make([]*statepb.PendingAttestation, 3)
atts := make([]*ethpb.PendingAttestation, 3)
for i := 0; i < len(atts); i++ {
atts[i] = &statepb.PendingAttestation{
atts[i] = &ethpb.PendingAttestation{
Data: &ethpb.AttestationData{
Target: &ethpb.Checkpoint{Root: make([]byte, 32)},
Source: &ethpb.Checkpoint{Root: make([]byte, 32)},
@@ -259,7 +258,7 @@ func TestProcessRewardsAndPenaltiesPrecompute_SlashedInactivePenalty(t *testing.
}
}
func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState {
func buildState(slot types.Slot, validatorCount uint64) *ethpb.BeaconState {
validators := make([]*ethpb.Validator, validatorCount)
for i := 0; i < len(validators); i++ {
validators[i] = &ethpb.Validator{
@@ -285,7 +284,7 @@ func buildState(slot types.Slot, validatorCount uint64) *statepb.BeaconState {
for i := 0; i < len(latestRandaoMixes); i++ {
latestRandaoMixes[i] = params.BeaconConfig().ZeroHash[:]
}
return &statepb.BeaconState{
return &ethpb.BeaconState{
Slot: slot,
Balances: validatorBalances,
Validators: validators,

View File

@@ -7,7 +7,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@@ -15,7 +14,7 @@ import (
)
func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) {
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 0,
Validators: []*ethpb.Validator{{Slashed: true}},
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
@@ -30,7 +29,7 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedTrue(t *testing.T) {
}
func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) {
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 0,
Validators: []*ethpb.Validator{{}},
Balances: []uint64{params.BeaconConfig().MaxEffectiveBalance},
@@ -46,11 +45,11 @@ func TestProcessSlashingsPrecompute_NotSlashedWithSlashedFalse(t *testing.T) {
func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
tests := []struct {
state *statepb.BeaconState
state *ethpb.BeaconState
want uint64
}{
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
@@ -64,7 +63,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
@@ -80,7 +79,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
want: uint64(32000000000), // 32 * 1e9 - 500000000
},
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,
@@ -96,7 +95,7 @@ func TestProcessSlashingsPrecompute_SlashedLess(t *testing.T) {
want: uint64(31000000000), // 32 * 1e9 - 1000000000
},
{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{Slashed: true,
WithdrawableEpoch: params.BeaconConfig().EpochsPerSlashingsVector / 2,

View File

@@ -9,7 +9,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -98,7 +97,7 @@ func TestAttestation_ComputeSubnetForAttestation(t *testing.T) {
}
}
state, err := v1.InitializeFromProto(&statepb.BeaconState{
state, err := v1.InitializeFromProto(&ethpb.BeaconState{
Validators: validators,
Slot: 200,
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),

View File

@@ -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"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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 := &statepb.BeaconState{
s := &ethpb.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 := &statepb.BeaconState{
state := &ethpb.BeaconState{
BlockRoots: blockRoots,
}

View File

@@ -6,7 +6,7 @@ import (
types "github.com/prysmaticlabs/eth2-types"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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(&statepb.BeaconState{RandaoMixes: randaoMixes})
state, err := v1.InitializeFromProto(&ethpb.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(&statepb.BeaconState{RandaoMixes: randaoMixes})
state, err := v1.InitializeFromProto(&ethpb.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(&statepb.BeaconState{
state, err := v1.InitializeFromProto(&ethpb.BeaconState{
RandaoMixes: randaoMixes,
Slot: slot,
})

View File

@@ -6,7 +6,6 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -57,7 +56,7 @@ func signingData(rootFunc func() ([32]byte, error), domain []byte) ([32]byte, er
if err != nil {
return [32]byte{}, err
}
container := &statepb.SigningData{
container := &ethpb.SigningData{
ObjectRoot: objRoot[:],
Domain: domain,
}
@@ -210,7 +209,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 := (&statepb.ForkData{
r, err := (&ethpb.ForkData{
CurrentVersion: version,
GenesisValidatorsRoot: root,
}).HashTreeRoot()

View File

@@ -8,7 +8,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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 := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
pubkey := [48]byte{}
sig := [96]byte{}
domain := [4]byte{}

View File

@@ -7,7 +7,7 @@ import (
types "github.com/prysmaticlabs/eth2-types"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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(&statepb.BeaconState{Slot: tt.slot})
state, err := v1.InitializeFromProto(&ethpb.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(&statepb.BeaconState{Slot: tt.slot})
state, err := v1.InitializeFromProto(&ethpb.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(&statepb.BeaconState{Slot: tt.slot})
state, err := v1.InitializeFromProto(&ethpb.BeaconState{Slot: tt.slot})
require.NoError(t, err)
assert.Equal(t, tt.epoch, NextEpoch(state), "NextEpoch(%d)", state.Slot())
}

View File

@@ -7,7 +7,6 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/hashutil"
@@ -285,7 +284,7 @@ func ComputeProposerIndex(bState state.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 *statepb.Fork, epoch types.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error) {
func Domain(fork *ethpb.Fork, epoch types.Epoch, domainType [bls.DomainByteLength]byte, genesisRoot []byte) ([]byte, error) {
if fork == nil {
return []byte{}, errors.New("nil fork or domain type")
}

View File

@@ -8,7 +8,7 @@ import (
coreState "github.com/prysmaticlabs/prysm/beacon-chain/core/state"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/benchutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -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, &statepb.BeaconState{}))
require.NoError(b, proto.Unmarshal(protoObject, &ethpb.BeaconState{}))
}
})
@@ -154,7 +154,7 @@ func BenchmarkUnmarshalState_FullState(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
sszState := &statepb.BeaconState{}
sszState := &ethpb.BeaconState{}
require.NoError(b, sszState.UnmarshalSSZ(sszObject))
}
})

View File

@@ -12,7 +12,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -114,13 +113,13 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState state.BeaconState,
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
}
state := &statepb.BeaconState{
state := &ethpb.BeaconState{
// Misc fields.
Slot: 0,
GenesisTime: genesisTime,
GenesisValidatorsRoot: genesisValidatorsRoot[:],
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
Epoch: 0,
@@ -152,8 +151,8 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState state.BeaconState,
BlockRoots: blockRoots,
StateRoots: stateRoots,
Slashings: slashings,
CurrentEpochAttestations: []*statepb.PendingAttestation{},
PreviousEpochAttestations: []*statepb.PendingAttestation{},
CurrentEpochAttestations: []*ethpb.PendingAttestation{},
PreviousEpochAttestations: []*ethpb.PendingAttestation{},
// Eth1 data.
Eth1Data: eth1Data,
@@ -184,10 +183,10 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState state.BeaconState,
// EmptyGenesisState returns an empty beacon state object.
func EmptyGenesisState() (state.BeaconState, error) {
state := &statepb.BeaconState{
state := &ethpb.BeaconState{
// Misc fields.
Slot: 0,
Fork: &statepb.Fork{
Fork: &ethpb.Fork{
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
Epoch: 0,
@@ -198,8 +197,8 @@ func EmptyGenesisState() (state.BeaconState, error) {
JustificationBits: []byte{0},
HistoricalRoots: [][]byte{},
CurrentEpochAttestations: []*statepb.PendingAttestation{},
PreviousEpochAttestations: []*statepb.PendingAttestation{},
CurrentEpochAttestations: []*ethpb.PendingAttestation{},
PreviousEpochAttestations: []*ethpb.PendingAttestation{},
// Eth1 data.
Eth1Data: &ethpb.Eth1Data{},

View File

@@ -7,14 +7,13 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/stateutils"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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 := &statepb.BeaconState{
base := &ethpb.BeaconState{
Validators: []*ethpb.Validator{
{
PublicKey: []byte("zero"),

View File

@@ -13,7 +13,7 @@ import (
slashertypes "github.com/prysmaticlabs/prysm/beacon-chain/slasher/types"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/shared/backuputil"
@@ -36,7 +36,7 @@ type ReadOnlyDatabase interface {
State(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error)
GenesisState(ctx context.Context) (state.BeaconState, error)
HasState(ctx context.Context, blockRoot [32]byte) bool
StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error)
StateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error)
HasStateSummary(ctx context.Context, blockRoot [32]byte) bool
HighestSlotStatesBelow(ctx context.Context, slot types.Slot) ([]state.ReadOnlyBeaconState, error)
// Slashing operations.
@@ -73,8 +73,8 @@ type NoHeadAccessDatabase interface {
SaveStates(ctx context.Context, states []state.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 *statepb.StateSummary) error
SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error
SaveStateSummary(ctx context.Context, summary *ethpb.StateSummary) error
SaveStateSummaries(ctx context.Context, summaries []*ethpb.StateSummary) error
// Slashing operations.
SaveProposerSlashing(ctx context.Context, slashing *eth.ProposerSlashing) error
SaveAttesterSlashing(ctx context.Context, slashing *eth.AttesterSlashing) error

View File

@@ -9,7 +9,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/db/filters"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
v2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
)
@@ -70,7 +70,7 @@ func (e Exporter) State(ctx context.Context, blockRoot [32]byte) (state.BeaconSt
}
// StateSummary -- passthrough.
func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) {
func (e Exporter) StateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) {
return e.db.StateSummary(ctx, blockRoot)
}
@@ -145,12 +145,12 @@ func (e Exporter) SaveState(ctx context.Context, st state.ReadOnlyBeaconState, b
}
// SaveStateSummary -- passthrough.
func (e Exporter) SaveStateSummary(ctx context.Context, summary *statepb.StateSummary) error {
func (e Exporter) SaveStateSummary(ctx context.Context, summary *ethpb.StateSummary) error {
return e.db.SaveStateSummary(ctx, summary)
}
// SaveStateSummaries -- passthrough.
func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error {
func (e Exporter) SaveStateSummaries(ctx context.Context, summaries []*ethpb.StateSummary) error {
return e.db.SaveStateSummaries(ctx, summaries)
}

View File

@@ -8,7 +8,6 @@ import (
fastssz "github.com/ferranbt/fastssz"
"github.com/golang/snappy"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"go.opencensus.io/trace"
"google.golang.org/protobuf/proto"
)
@@ -53,7 +52,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 *statepb.BeaconState:
case *ethpb.BeaconState:
return true
case *ethpb.SignedBeaconBlock:
return true

View File

@@ -12,7 +12,7 @@ import (
dbIface "github.com/prysmaticlabs/prysm/beacon-chain/db/iface"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
statev1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -34,7 +34,7 @@ func (s *Store) SaveGenesisData(ctx context.Context, genesisState state.BeaconSt
if err := s.SaveState(ctx, genesisState, genesisBlkRoot); err != nil {
return errors.Wrap(err, "could not save genesis state")
}
if err := s.SaveStateSummary(ctx, &statepb.StateSummary{
if err := s.SaveStateSummary(ctx, &ethpb.StateSummary{
Slot: 0,
Root: genesisBlkRoot[:],
}); err != nil {
@@ -47,7 +47,6 @@ func (s *Store) SaveGenesisData(ctx context.Context, genesisState state.BeaconSt
if err := s.SaveGenesisBlockRoot(ctx, genesisBlkRoot); err != nil {
return errors.Wrap(err, "could not save genesis block root")
}
return nil
}
@@ -57,7 +56,7 @@ func (s *Store) LoadGenesis(ctx context.Context, r io.Reader) error {
if err != nil {
return err
}
st := &statepb.BeaconState{}
st := &ethpb.BeaconState{}
if err := st.UnmarshalSSZ(b); err != nil {
return err
}
@@ -90,7 +89,6 @@ func (s *Store) LoadGenesis(ctx context.Context, r io.Reader) error {
return fmt.Errorf("loaded genesis fork version (%#x) does not match config genesis "+
"fork version (%#x)", gs.Fork().CurrentVersion, params.BeaconConfig().GenesisForkVersion)
}
return s.SaveGenesisData(ctx, gs)
}

View File

@@ -5,7 +5,7 @@ import (
"context"
"github.com/golang/snappy"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/hashutil"
@@ -63,7 +63,7 @@ func migrateStateValidators(tx *bolt.Tx) error {
ctx := context.Background()
c := stateBkt.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
state := &statepb.BeaconState{}
state := &ethpb.BeaconState{}
if decodeErr := decode(ctx, v, state); decodeErr != nil {
return decodeErr
}

View File

@@ -3,22 +3,22 @@ package kv
import (
"context"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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 *statepb.StateSummary) error {
func (s *Store) SaveStateSummary(ctx context.Context, summary *ethpb.StateSummary) error {
ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummary")
defer span.End()
return s.SaveStateSummaries(ctx, []*statepb.StateSummary{summary})
return s.SaveStateSummaries(ctx, []*ethpb.StateSummary{summary})
}
// SaveStateSummaries saves state summary objects to the DB.
func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*statepb.StateSummary) error {
func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*ethpb.StateSummary) error {
ctx, span := trace.StartSpan(ctx, "BeaconDB.SaveStateSummaries")
defer span.End()
@@ -38,7 +38,7 @@ func (s *Store) SaveStateSummaries(ctx context.Context, summaries []*statepb.Sta
}
// StateSummary returns the state summary object from the db using input block root.
func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) {
func (s *Store) StateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.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) (*statepb.
if len(enc) == 0 {
return nil, nil
}
summary := &statepb.StateSummary{}
summary := &ethpb.StateSummary{}
if err := decode(ctx, enc, summary); err != nil {
return nil, err
}

View File

@@ -3,26 +3,26 @@ package kv
import (
"sync"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
const stateSummaryCachePruneCount = 128
// stateSummaryCache caches state summary object.
type stateSummaryCache struct {
initSyncStateSummaries map[[32]byte]*statepb.StateSummary
initSyncStateSummaries map[[32]byte]*ethpb.StateSummary
initSyncStateSummariesLock sync.RWMutex
}
// newStateSummaryCache creates a new state summary cache.
func newStateSummaryCache() *stateSummaryCache {
return &stateSummaryCache{
initSyncStateSummaries: make(map[[32]byte]*statepb.StateSummary),
initSyncStateSummaries: make(map[[32]byte]*ethpb.StateSummary),
}
}
// put saves a state summary to the initial sync state summaries cache.
func (c *stateSummaryCache) put(r [32]byte, b *statepb.StateSummary) {
func (c *stateSummaryCache) put(r [32]byte, b *ethpb.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) *statepb.StateSummary {
func (c *stateSummaryCache) get(r [32]byte) *ethpb.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() []*statepb.StateSummary {
func (c *stateSummaryCache) getAll() []*ethpb.StateSummary {
c.initSyncStateSummariesLock.RLock()
defer c.initSyncStateSummariesLock.RUnlock()
summaries := make([]*statepb.StateSummary, 0, len(c.initSyncStateSummaries))
summaries := make([]*ethpb.StateSummary, 0, len(c.initSyncStateSummaries))
for _, b := range c.initSyncStateSummaries {
summaries = append(summaries, b)
}
@@ -70,5 +70,5 @@ func (c *stateSummaryCache) getAll() []*statepb.StateSummary {
func (c *stateSummaryCache) clear() {
c.initSyncStateSummariesLock.Lock()
defer c.initSyncStateSummariesLock.Unlock()
c.initSyncStateSummaries = make(map[[32]byte]*statepb.StateSummary)
c.initSyncStateSummaries = make(map[[32]byte]*ethpb.StateSummary)
}

View File

@@ -5,7 +5,7 @@ import (
"testing"
types "github.com/prysmaticlabs/eth2-types"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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 := &statepb.StateSummary{Slot: 1, Root: r1[:]}
s1 := &ethpb.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 := &statepb.StateSummary{Slot: 2, Root: r2[:]}
s2 := &ethpb.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([]*statepb.StateSummary, stateSummaryCachePruneCount-1)
summaries := make([]*ethpb.StateSummary, stateSummaryCachePruneCount-1)
for i := range summaries {
summaries[i] = &statepb.StateSummary{Slot: types.Slot(i), Root: bytesutil.PadTo(bytesutil.Uint64ToBytesLittleEndian(uint64(i)), 32)}
summaries[i] = &ethpb.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(), &statepb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}}))
require.NoError(t, db.SaveStateSummary(context.Background(), &ethpb.StateSummary{Slot: 1000, Root: []byte{'a', 'b'}}))
require.Equal(t, db.stateSummaryCache.len(), stateSummaryCachePruneCount)
require.NoError(t, db.SaveStateSummary(context.Background(), &statepb.StateSummary{Slot: 1001, Root: []byte{'c', 'd'}}))
require.NoError(t, db.SaveStateSummary(context.Background(), &ethpb.StateSummary{Slot: 1001, Root: []byte{'c', 'd'}}))
require.Equal(t, db.stateSummaryCache.len(), 1)
for i := range summaries {

View File

@@ -16,7 +16,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/shared/interop"
"github.com/prysmaticlabs/prysm/shared/slotutil"
@@ -62,7 +61,7 @@ func NewService(ctx context.Context, cfg *Config) *Service {
if err != nil {
log.Fatalf("Could not read pre-loaded state: %v", err)
}
genesisState := &statepb.BeaconState{}
genesisState := &ethpb.BeaconState{}
if err := genesisState.UnmarshalSSZ(data); err != nil {
log.Fatalf("Could not unmarshal pre-loaded state: %v", err)
}

View File

@@ -8,7 +8,6 @@ import (
types "github.com/prysmaticlabs/eth2-types"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"google.golang.org/protobuf/proto"
@@ -270,7 +269,7 @@ func TestPool_InsertVoluntaryExit(t *testing.T) {
p := &Pool{
pending: tt.fields.pending,
}
s, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{Validators: validators})
s, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{Validators: validators})
require.NoError(t, err)
p.InsertVoluntaryExit(ctx, s, tt.args.exit)
if len(p.pending) != len(tt.want) {
@@ -521,7 +520,7 @@ func TestPool_PendingExits(t *testing.T) {
p := &Pool{
pending: tt.fields.pending,
}
s, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{Validators: []*ethpb.Validator{{ExitEpoch: params.BeaconConfig().FarFutureEpoch}}})
s, err := v1.InitializeFromProtoUnsafe(&ethpb.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)

View File

@@ -7,7 +7,6 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -26,7 +25,7 @@ func TestCorrect_ActiveValidatorsCount(t *testing.T) {
ctx: context.Background(),
cfg: &Config{DB: db},
}
bState, err := testutil.NewBeaconState(func(state *statepb.BeaconState) error {
bState, err := testutil.NewBeaconState(func(state *ethpb.BeaconState) error {
validators := make([]*ethpb.Validator, params.BeaconConfig().MinGenesisActiveValidatorCount)
for i := 0; i < len(validators); i++ {
validators[i] = &ethpb.Validator{

View File

@@ -6,7 +6,7 @@ import (
"testing"
"time"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"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 := &statepb.Fork{
msg := &ethpb.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(statepb.Fork)
RPCTopicMappings[topic] = new(ethpb.Fork)
defer func() {
delete(RPCTopicMappings, topic)
}()
p2.SetStreamHandler(topic+"/ssz_snappy", func(stream network.Stream) {
rcvd := &statepb.Fork{}
rcvd := &ethpb.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 := &statepb.Fork{}
rcvd := &ethpb.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)

View File

@@ -20,7 +20,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
@@ -40,7 +39,7 @@ func TestServer_ListAttestations_NoResults(t *testing.T) {
db := dbTest.SetupDB(t)
ctx := context.Background()
st, err := v1.InitializeFromProto(&statepb.BeaconState{
st, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 0,
})
require.NoError(t, err)
@@ -68,7 +67,7 @@ func TestServer_ListAttestations_Genesis(t *testing.T) {
db := dbTest.SetupDB(t)
ctx := context.Background()
st, err := v1.InitializeFromProto(&statepb.BeaconState{
st, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 0,
})
require.NoError(t, err)
@@ -564,13 +563,13 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
HeadFetcher: &chainMock.ChainService{State: state},
StateGen: stategen.New(db),
}
err := db.SaveStateSummary(ctx, &statepb.StateSummary{
err := db.SaveStateSummary(ctx, &ethpb.StateSummary{
Root: targetRoot1[:],
Slot: 1,
})
require.NoError(t, err)
err = db.SaveStateSummary(ctx, &statepb.StateSummary{
err = db.SaveStateSummary(ctx, &ethpb.StateSummary{
Root: targetRoot2[:],
Slot: 2,
})
@@ -664,7 +663,7 @@ func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) {
},
StateGen: stategen.New(db),
}
err = db.SaveStateSummary(ctx, &statepb.StateSummary{
err = db.SaveStateSummary(ctx, &ethpb.StateSummary{
Root: blockRoot[:],
Slot: params.BeaconConfig().SlotsPerEpoch.Mul(uint64(epoch)),
})

View File

@@ -12,7 +12,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
@@ -162,7 +161,7 @@ func TestRetrieveCommitteesForRoot(t *testing.T) {
require.NoError(t, err)
require.NoError(t, db.SaveGenesisBlockRoot(ctx, gRoot))
require.NoError(t, db.SaveState(ctx, headState, gRoot))
stateSummary := &statepb.StateSummary{
stateSummary := &ethpb.StateSummary{
Slot: 0,
Root: gRoot[:],
}

View File

@@ -15,7 +15,6 @@ import (
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
attaggregation "github.com/prysmaticlabs/prysm/shared/aggregation/attestations"
"github.com/prysmaticlabs/prysm/shared/attestationutil"
"github.com/prysmaticlabs/prysm/shared/bls"
@@ -45,7 +44,7 @@ func TestSubmitAggregateAndProof_Syncing(t *testing.T) {
func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) {
ctx := context.Background()
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
})
require.NoError(t, err)
@@ -67,7 +66,7 @@ func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) {
func TestSubmitAggregateAndProof_IsAggregatorAndNoAtts(t *testing.T) {
ctx := context.Background()
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
Validators: []*ethpb.Validator{
{PublicKey: pubKey(0)},

View File

@@ -15,7 +15,6 @@ import (
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/event"
@@ -52,7 +51,7 @@ func TestValidatorIndex_OK(t *testing.T) {
func TestWaitForActivation_ContextClosed(t *testing.T) {
ctx := context.Background()
beaconState, err := v1.InitializeFromProto(&statepb.BeaconState{
beaconState, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 0,
Validators: []*ethpb.Validator{},
})
@@ -70,7 +69,7 @@ func TestWaitForActivation_ContextClosed(t *testing.T) {
ChainStartFetcher: &mockPOW.POWChain{},
BlockFetcher: &mockPOW.POWChain{},
Eth1InfoFetcher: &mockPOW.POWChain{},
CanonicalStateChan: make(chan *statepb.BeaconState, 1),
CanonicalStateChan: make(chan *ethpb.BeaconState, 1),
DepositFetcher: depositCache,
HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]},
}
@@ -108,7 +107,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) {
pubKey1 := priv1.PublicKey().Marshal()
pubKey2 := priv2.PublicKey().Marshal()
beaconState := &statepb.BeaconState{
beaconState := &ethpb.BeaconState{
Slot: 4000,
Validators: []*ethpb.Validator{
{
@@ -146,7 +145,7 @@ func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) {
require.NoError(t, err)
vs := &Server{
Ctx: context.Background(),
CanonicalStateChan: make(chan *statepb.BeaconState, 1),
CanonicalStateChan: make(chan *ethpb.BeaconState, 1),
ChainStartFetcher: &mockPOW.POWChain{},
BlockFetcher: &mockPOW.POWChain{},
Eth1InfoFetcher: &mockPOW.POWChain{},
@@ -197,7 +196,7 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) {
pubKey2 := priv2.PublicKey().Marshal()
pubKey3 := priv3.PublicKey().Marshal()
beaconState := &statepb.BeaconState{
beaconState := &ethpb.BeaconState{
Slot: 4000,
Validators: []*ethpb.Validator{
{
@@ -226,7 +225,7 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) {
require.NoError(t, err)
vs := &Server{
Ctx: context.Background(),
CanonicalStateChan: make(chan *statepb.BeaconState, 1),
CanonicalStateChan: make(chan *ethpb.BeaconState, 1),
ChainStartFetcher: &mockPOW.POWChain{},
HeadFetcher: &mockChain.ChainService{State: trie, Root: genesisRoot[:]},
}

View File

@@ -16,7 +16,6 @@ import (
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -45,7 +44,7 @@ func TestValidatorStatus_DepositedEth1(t *testing.T) {
0: uint64(height),
},
}
stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{})
stateObj, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{})
require.NoError(t, err)
vs := &Server{
DepositFetcher: depositCache,
@@ -88,7 +87,7 @@ func TestValidatorStatus_Deposited(t *testing.T) {
0: uint64(height),
},
}
stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{
stateObj, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{
Validators: []*ethpb.Validator{
{
PublicKey: pubKey1,
@@ -138,7 +137,7 @@ func TestValidatorStatus_PartiallyDeposited(t *testing.T) {
0: uint64(height),
},
}
stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{
stateObj, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{
Validators: []*ethpb.Validator{
{
PublicKey: pubKey1,
@@ -253,7 +252,7 @@ func TestValidatorStatus_Active(t *testing.T) {
genesisRoot, err := block.Block.HashTreeRoot()
require.NoError(t, err, "Could not get signing root")
state := &statepb.BeaconState{
state := &ethpb.BeaconState{
GenesisTime: uint64(time.Unix(0, 0).Unix()),
Slot: 10000,
Validators: []*ethpb.Validator{{
@@ -307,7 +306,7 @@ func TestValidatorStatus_Exiting(t *testing.T) {
genesisRoot, err := block.Block.HashTreeRoot()
require.NoError(t, err, "Could not get signing root")
state := &statepb.BeaconState{
state := &ethpb.BeaconState{
Slot: slot,
Validators: []*ethpb.Validator{{
PublicKey: pubKey,
@@ -365,7 +364,7 @@ func TestValidatorStatus_Slashing(t *testing.T) {
genesisRoot, err := block.Block.HashTreeRoot()
require.NoError(t, err, "Could not get signing root")
state := &statepb.BeaconState{
state := &ethpb.BeaconState{
Slot: slot,
Validators: []*ethpb.Validator{{
Slashed: true,
@@ -473,7 +472,7 @@ func TestValidatorStatus_UnknownStatus(t *testing.T) {
depositCache, err := depositcache.New()
require.NoError(t, err)
stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{
stateObj, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{
Slot: 0,
})
require.NoError(t, err)
@@ -498,7 +497,7 @@ func TestActivationStatus_OK(t *testing.T) {
deposits, _, err := testutil.DeterministicDepositsAndKeys(4)
require.NoError(t, err)
pubKeys := [][]byte{deposits[0].Data.PublicKey, deposits[1].Data.PublicKey, deposits[2].Data.PublicKey, deposits[3].Data.PublicKey}
stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{
stateObj, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{
Slot: 4000,
Validators: []*ethpb.Validator{
{
@@ -537,7 +536,7 @@ func TestActivationStatus_OK(t *testing.T) {
vs := &Server{
Ctx: context.Background(),
CanonicalStateChan: make(chan *statepb.BeaconState, 1),
CanonicalStateChan: make(chan *ethpb.BeaconState, 1),
ChainStartFetcher: &mockPOW.POWChain{},
BlockFetcher: &mockPOW.POWChain{},
Eth1InfoFetcher: &mockPOW.POWChain{},
@@ -692,7 +691,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) {
deposits[4].Data.PublicKey,
deposits[5].Data.PublicKey,
}
stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{
stateObj, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{
Slot: 4000,
Validators: []*ethpb.Validator{
{
@@ -741,7 +740,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) {
vs := &Server{
Ctx: context.Background(),
CanonicalStateChan: make(chan *statepb.BeaconState, 1),
CanonicalStateChan: make(chan *ethpb.BeaconState, 1),
ChainStartFetcher: &mockPOW.POWChain{},
BlockFetcher: &mockPOW.POWChain{},
Eth1InfoFetcher: &mockPOW.POWChain{},
@@ -792,7 +791,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) {
slot := types.Slot(10000)
epoch := helpers.SlotToEpoch(slot)
pubKeys := [][]byte{pubKey(1), pubKey(2), pubKey(3), pubKey(4), pubKey(5), pubKey(6), pubKey(7)}
beaconState := &statepb.BeaconState{
beaconState := &ethpb.BeaconState{
Slot: 4000,
Validators: []*ethpb.Validator{
{
@@ -837,7 +836,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) {
vs := &Server{
Ctx: context.Background(),
CanonicalStateChan: make(chan *statepb.BeaconState, 1),
CanonicalStateChan: make(chan *ethpb.BeaconState, 1),
ChainStartFetcher: &mockPOW.POWChain{},
BlockFetcher: &mockPOW.POWChain{},
Eth1InfoFetcher: &mockPOW.POWChain{},
@@ -903,7 +902,7 @@ func TestValidatorStatus_Invalid(t *testing.T) {
0: uint64(height),
},
}
stateObj, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{})
stateObj, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{})
require.NoError(t, err)
vs := &Server{
DepositFetcher: depositCache,

View File

@@ -5,7 +5,7 @@ import (
"github.com/golang/snappy"
state "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -27,7 +27,7 @@ func State(name string) (*state.BeaconState, error) {
// load a compressed ssz state file into a beacon state struct.
func load(b []byte) (*state.BeaconState, error) {
st := &statepb.BeaconState{}
st := &ethpb.BeaconState{}
b, err := snappy.Decode(nil /*dst*/, b)
if err != nil {
return nil, err

View File

@@ -10,7 +10,6 @@ import (
"github.com/prysmaticlabs/go-bitfield"
v1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// BeaconState has read and write access to beacon state methods.
@@ -39,7 +38,7 @@ type ReadOnlyBeaconState interface {
GenesisTime() uint64
GenesisValidatorRoot() []byte
Slot() types.Slot
Fork() *statepb.Fork
Fork() *ethpb.Fork
LatestBlockHeader() *ethpb.BeaconBlockHeader
HistoricalRoots() [][]byte
Slashings() []uint64
@@ -61,7 +60,7 @@ type WriteOnlyBeaconState interface {
SetGenesisTime(val uint64) error
SetGenesisValidatorRoot(val []byte) error
SetSlot(val types.Slot) error
SetFork(val *statepb.Fork) error
SetFork(val *ethpb.Fork) error
SetLatestBlockHeader(val *ethpb.BeaconBlockHeader) error
SetHistoricalRoots(val [][]byte) error
SetSlashings(val []uint64) error
@@ -139,8 +138,8 @@ type ReadOnlyEth1Data interface {
// ReadOnlyAttestations defines a struct which only has read access to attestations methods.
type ReadOnlyAttestations interface {
PreviousEpochAttestations() ([]*statepb.PendingAttestation, error)
CurrentEpochAttestations() ([]*statepb.PendingAttestation, error)
PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error)
CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error)
}
// WriteOnlyBlockRoots defines a struct which only has write access to block roots methods.
@@ -194,8 +193,8 @@ type WriteOnlyCheckpoint interface {
// WriteOnlyAttestations defines a struct which only has write access to attestations methods.
type WriteOnlyAttestations interface {
AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error
AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error
AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error
AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error
RotateAttestations() error
}
@@ -209,10 +208,10 @@ type FutureForkStub interface {
PreviousEpochParticipation() ([]byte, error)
InactivityScores() ([]uint64, error)
SetInactivityScores(val []uint64) error
CurrentSyncCommittee() (*statepb.SyncCommittee, error)
SetCurrentSyncCommittee(val *statepb.SyncCommittee) error
CurrentSyncCommittee() (*ethpb.SyncCommittee, error)
SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error
SetPreviousParticipationBits(val []byte) error
SetCurrentParticipationBits(val []byte) error
NextSyncCommittee() (*statepb.SyncCommittee, error)
SetNextSyncCommittee(val *statepb.SyncCommittee) error
NextSyncCommittee() (*ethpb.SyncCommittee, error)
SetNextSyncCommittee(val *ethpb.SyncCommittee) error
}

View File

@@ -6,7 +6,7 @@ import (
"github.com/pkg/errors"
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"go.opencensus.io/trace"
@@ -111,8 +111,8 @@ func (s *State) StateBySlot(ctx context.Context, slot types.Slot) (state.BeaconS
// This returns the state summary object of a given block root, it first checks the cache
// then checks the DB. An error is returned if state summary object is nil.
func (s *State) stateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) {
var summary *statepb.StateSummary
func (s *State) stateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) {
var summary *ethpb.StateSummary
var err error
summary, err = s.beaconDB.StateSummary(ctx, blockRoot)
@@ -127,13 +127,13 @@ func (s *State) stateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.
}
// RecoverStateSummary recovers state summary object of a given block root by using the saved block in DB.
func (s *State) RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error) {
func (s *State) RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error) {
if s.beaconDB.HasBlock(ctx, blockRoot) {
b, err := s.beaconDB.Block(ctx, blockRoot)
if err != nil {
return nil, err
}
summary := &statepb.StateSummary{Slot: b.Block().Slot(), Root: blockRoot[:]}
summary := &ethpb.StateSummary{Slot: b.Block().Slot(), Root: blockRoot[:]}
if err := s.beaconDB.SaveStateSummary(ctx, summary); err != nil {
return nil, err
}

View File

@@ -7,7 +7,7 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -50,7 +50,7 @@ func TestStateByRoot_HotStateUsingEpochBoundaryCacheNoReplay(t *testing.T) {
blk := testutil.NewBeaconBlock()
blkRoot, err := blk.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: blkRoot[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Root: blkRoot[:]}))
require.NoError(t, service.epochBoundaryStateCache.put(blkRoot, beaconState))
loadedState, err := service.StateByRoot(ctx, blkRoot)
require.NoError(t, err)
@@ -76,7 +76,7 @@ func TestStateByRoot_HotStateUsingEpochBoundaryCacheWithReplay(t *testing.T) {
require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(targetBlock)))
targetRoot, err := targetBlock.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: targetSlot, Root: targetRoot[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: targetSlot, Root: targetRoot[:]}))
loadedState, err := service.StateByRoot(ctx, targetRoot)
require.NoError(t, err)
assert.Equal(t, targetSlot, loadedState.Slot(), "Did not correctly load state")
@@ -90,7 +90,7 @@ func TestStateByRoot_HotStateCached(t *testing.T) {
beaconState, _ := testutil.DeterministicGenesisState(t, 32)
r := [32]byte{'A'}
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: r[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Root: r[:]}))
service.hotStateCache.put(r, beaconState)
loadedState, err := service.StateByRoot(ctx, r)
@@ -124,7 +124,7 @@ func TestStateByRootInitialSync_UseCache(t *testing.T) {
beaconState, _ := testutil.DeterministicGenesisState(t, 32)
r := [32]byte{'A'}
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Root: r[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Root: r[:]}))
service.hotStateCache.put(r, beaconState)
loadedState, err := service.StateByRootInitialSync(ctx, r)
@@ -152,7 +152,7 @@ func TestStateByRootInitialSync_CanProcessUpTo(t *testing.T) {
targetRoot, err := targetBlk.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(targetBlk)))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: targetSlot, Root: targetRoot[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: targetSlot, Root: targetRoot[:]}))
loadedState, err := service.StateByRootInitialSync(ctx, targetRoot)
require.NoError(t, err)
@@ -186,7 +186,7 @@ func TestStateBySlot_ColdState(t *testing.T) {
require.NoError(t, beaconDB.SaveGenesisBlockRoot(ctx, bRoot))
r := [32]byte{}
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: service.slotsPerArchivedPoint, Root: r[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: service.slotsPerArchivedPoint, Root: r[:]}))
slot := types.Slot(20)
loadedState, err := service.StateBySlot(ctx, slot)
@@ -243,7 +243,7 @@ func TestLoadeStateByRoot_FinalizedState(t *testing.T) {
assert.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(genesis)))
gRoot, err := genesis.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 0, Root: gRoot[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: 0, Root: gRoot[:]}))
service.finalizedInfo.state = beaconState
service.finalizedInfo.slot = beaconState.Slot()
@@ -273,7 +273,7 @@ func TestLoadeStateByRoot_EpochBoundaryStateCanProcess(t *testing.T) {
require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk)))
blkRoot, err := blk.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 10, Root: blkRoot[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: 10, Root: blkRoot[:]}))
// This tests where hot state was not cached and needs processing.
loadedState, err := service.loadStateByRoot(ctx, blkRoot)
@@ -299,7 +299,7 @@ func TestLoadeStateByRoot_FromDBBoundaryCase(t *testing.T) {
require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(blk)))
blkRoot, err := blk.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 10, Root: blkRoot[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: 10, Root: blkRoot[:]}))
// This tests where hot state was not cached and needs processing.
loadedState, err := service.loadStateByRoot(ctx, blkRoot)
@@ -345,7 +345,7 @@ func TestLoadeStateBySlot_CanReplayBlock(t *testing.T) {
require.NoError(t, beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1)))
r1, err := b1.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: r1[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: 1, Root: r1[:]}))
service.hotStateCache.put(bytesutil.ToBytes32(b1.Block.ParentRoot), genesis)
loadedState, err := service.loadStateBySlot(ctx, 2)

View File

@@ -5,7 +5,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
@@ -17,7 +17,7 @@ func TestHotStateCache_RoundTrip(t *testing.T) {
assert.Equal(t, state.BeaconState(nil), s)
assert.Equal(t, false, c.has(root), "Empty cache has an object")
s, err := v1.InitializeFromProto(&statepb.BeaconState{
s, err := v1.InitializeFromProto(&ethpb.BeaconState{
Slot: 10,
})
require.NoError(t, err)

View File

@@ -7,7 +7,7 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -84,14 +84,14 @@ func TestMigrateToCold_RegeneratePath(t *testing.T) {
r1, err := b1.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b1)))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 1, Root: r1[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: 1, Root: r1[:]}))
b4, err := testutil.GenerateFullBlock(beaconState, pks, testutil.DefaultBlockGenConfig(), 4)
require.NoError(t, err)
r4, err := b4.Block.HashTreeRoot()
require.NoError(t, err)
require.NoError(t, service.beaconDB.SaveBlock(ctx, wrapper.WrappedPhase0SignedBeaconBlock(b4)))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{Slot: 4, Root: r4[:]}))
require.NoError(t, service.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{Slot: 4, Root: r4[:]}))
service.finalizedInfo = &finalizedInfo{
slot: 0,
root: genesisStateRoot,

View File

@@ -11,7 +11,7 @@ import (
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -33,7 +33,7 @@ type StateManager interface {
StateByRoot(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error)
StateByRootInitialSync(ctx context.Context, blockRoot [32]byte) (state.BeaconState, error)
StateBySlot(ctx context.Context, slot types.Slot) (state.BeaconState, error)
RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*statepb.StateSummary, error)
RecoverStateSummary(ctx context.Context, blockRoot [32]byte) (*ethpb.StateSummary, error)
SaveState(ctx context.Context, root [32]byte, st state.BeaconState) error
ForceCheckpoint(ctx context.Context, root []byte) error
EnableSaveHotStateToDB(_ context.Context)

View File

@@ -6,7 +6,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
@@ -80,7 +80,7 @@ func (s *State) saveStateByRoot(ctx context.Context, blockRoot [32]byte, st stat
}
// On an intermediate slots, save state summary.
if err := s.beaconDB.SaveStateSummary(ctx, &statepb.StateSummary{
if err := s.beaconDB.SaveStateSummary(ctx, &ethpb.StateSummary{
Slot: st.Slot(),
Root: blockRoot[:],
}); err != nil {

View File

@@ -5,7 +5,6 @@ import (
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/htrutils"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -13,7 +12,7 @@ import (
// PendingAttRootWithHasher describes a method from which the hash tree root
// of a pending attestation is returned.
func PendingAttRootWithHasher(hasher htrutils.HashFn, att *statepb.PendingAttestation) ([32]byte, error) {
func PendingAttRootWithHasher(hasher htrutils.HashFn, att *ethpb.PendingAttestation) ([32]byte, error) {
var fieldRoots [][32]byte
// Bitfield.
@@ -43,7 +42,7 @@ func PendingAttRootWithHasher(hasher htrutils.HashFn, att *statepb.PendingAttest
// PendingAttEncKey returns the encoded key in bytes of input `pendingAttestation`,
// the returned key bytes can be used for caching purposes.
func PendingAttEncKey(att *statepb.PendingAttestation) []byte {
func PendingAttEncKey(att *ethpb.PendingAttestation) []byte {
enc := make([]byte, 2192)
if att != nil {

View File

@@ -7,7 +7,6 @@ import (
"testing"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/interop"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -16,7 +15,7 @@ import (
func TestState_FieldCount(t *testing.T) {
count := params.BeaconConfig().BeaconStateFieldCount
typ := reflect.TypeOf(statepb.BeaconState{})
typ := reflect.TypeOf(ethpb.BeaconState{})
numFields := 0
for i := 0; i < typ.NumField(); i++ {
if typ.Field(i).Name == "state" ||
@@ -59,7 +58,7 @@ func BenchmarkHashTreeRoot_Generic_300000(b *testing.B) {
}
}
func setupGenesisState(tb testing.TB, count uint64) *statepb.BeaconState {
func setupGenesisState(tb testing.TB, count uint64) *ethpb.BeaconState {
genesisState, _, err := interop.GenerateGenesisState(context.Background(), 0, 1)
require.NoError(tb, err, "Could not generate genesis beacon state")
for i := uint64(1); i < count; i++ {

View File

@@ -8,7 +8,7 @@ import (
"github.com/dgraph-io/ristretto"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/hashutil"
@@ -49,14 +49,14 @@ type stateRootHasher struct {
// computeFieldRoots returns the hash tree root computations of every field in
// the beacon state as a list of 32 byte roots.
func computeFieldRoots(ctx context.Context, state *statepb.BeaconState) ([][]byte, error) {
func computeFieldRoots(ctx context.Context, state *ethpb.BeaconState) ([][]byte, error) {
if featureconfig.Get().EnableSSZCache {
return cachedHasher.computeFieldRootsWithHasher(ctx, state)
}
return nocachedHasher.computeFieldRootsWithHasher(ctx, state)
}
func (h *stateRootHasher) computeFieldRootsWithHasher(ctx context.Context, state *statepb.BeaconState) ([][]byte, error) {
func (h *stateRootHasher) computeFieldRootsWithHasher(ctx context.Context, state *ethpb.BeaconState) ([][]byte, error) {
ctx, span := trace.StartSpan(ctx, "beaconState.computeFieldRootsWithHasher")
defer span.End()

View File

@@ -7,7 +7,6 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/hashutil"
)
@@ -53,10 +52,10 @@ func fieldConverters(field fieldIndex, indices []uint64, elements interface{}, c
}
return stateutil.HandleValidatorSlice(val, indices, convertAll)
case previousEpochAttestations, currentEpochAttestations:
val, ok := elements.([]*statepb.PendingAttestation)
val, ok := elements.([]*ethpb.PendingAttestation)
if !ok {
return nil, errors.Errorf("Wanted type of %v but got %v",
reflect.TypeOf([]*statepb.PendingAttestation{}).Name(), reflect.TypeOf(elements).Name())
reflect.TypeOf([]*ethpb.PendingAttestation{}).Name(), reflect.TypeOf(elements).Name())
}
return handlePendingAttestation(val, indices, convertAll)
default:
@@ -103,14 +102,14 @@ func HandleEth1DataSlice(val []*ethpb.Eth1Data, indices []uint64, convertAll boo
return roots, nil
}
func handlePendingAttestation(val []*statepb.PendingAttestation, indices []uint64, convertAll bool) ([][32]byte, error) {
func handlePendingAttestation(val []*ethpb.PendingAttestation, indices []uint64, convertAll bool) ([][32]byte, error) {
length := len(indices)
if convertAll {
length = len(val)
}
roots := make([][32]byte, 0, length)
hasher := hashutil.CustomSHA256Hasher()
rootCreator := func(input *statepb.PendingAttestation) error {
rootCreator := func(input *ethpb.PendingAttestation) error {
newRoot, err := stateutil.PendingAttRootWithHasher(hasher, input)
if err != nil {
return err

View File

@@ -7,14 +7,14 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/htrutils"
"github.com/prysmaticlabs/prysm/shared/params"
)
// PreviousEpochAttestations corresponding to blocks on the beacon chain.
func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) {
func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) {
if !b.hasInnerState() {
return nil, nil
}
@@ -30,7 +30,7 @@ func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation
// previousEpochAttestations corresponding to blocks on the beacon chain.
// This assumes that a lock is already held on BeaconState.
func (b *BeaconState) previousEpochAttestations() []*statepb.PendingAttestation {
func (b *BeaconState) previousEpochAttestations() []*ethpb.PendingAttestation {
if !b.hasInnerState() {
return nil
}
@@ -39,7 +39,7 @@ func (b *BeaconState) previousEpochAttestations() []*statepb.PendingAttestation
}
// CurrentEpochAttestations corresponding to blocks on the beacon chain.
func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) {
func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) {
if !b.hasInnerState() {
return nil, nil
}
@@ -55,7 +55,7 @@ func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation,
// currentEpochAttestations corresponding to blocks on the beacon chain.
// This assumes that a lock is already held on BeaconState.
func (b *BeaconState) currentEpochAttestations() []*statepb.PendingAttestation {
func (b *BeaconState) currentEpochAttestations() []*ethpb.PendingAttestation {
if !b.hasInnerState() {
return nil
}
@@ -63,7 +63,7 @@ func (b *BeaconState) currentEpochAttestations() []*statepb.PendingAttestation {
return b.safeCopyPendingAttestationSlice(b.state.CurrentEpochAttestations)
}
func (h *stateRootHasher) epochAttestationsRoot(atts []*statepb.PendingAttestation) ([32]byte, error) {
func (h *stateRootHasher) epochAttestationsRoot(atts []*ethpb.PendingAttestation) ([32]byte, error) {
max := uint64(params.BeaconConfig().SlotsPerEpoch) * params.BeaconConfig().MaxAttestations
if uint64(len(atts)) > max {
return [32]byte{}, fmt.Errorf("epoch attestation exceeds max length %d", max)
@@ -99,7 +99,7 @@ func (h *stateRootHasher) epochAttestationsRoot(atts []*statepb.PendingAttestati
return res, nil
}
func (h *stateRootHasher) pendingAttestationRoot(hasher htrutils.HashFn, att *statepb.PendingAttestation) ([32]byte, error) {
func (h *stateRootHasher) pendingAttestationRoot(hasher htrutils.HashFn, att *ethpb.PendingAttestation) ([32]byte, error) {
if att == nil {
return [32]byte{}, errors.New("nil pending attestation")
}

View File

@@ -3,19 +3,19 @@ package v1
import (
"testing"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestBeaconState_PreviousEpochAttestations(t *testing.T) {
s, err := InitializeFromProto(&statepb.BeaconState{})
s, err := InitializeFromProto(&ethpb.BeaconState{})
require.NoError(t, err)
atts, err := s.PreviousEpochAttestations()
require.NoError(t, err)
require.DeepEqual(t, []*statepb.PendingAttestation(nil), atts)
require.DeepEqual(t, []*ethpb.PendingAttestation(nil), atts)
want := []*statepb.PendingAttestation{{ProposerIndex: 100}}
s, err = InitializeFromProto(&statepb.BeaconState{PreviousEpochAttestations: want})
want := []*ethpb.PendingAttestation{{ProposerIndex: 100}}
s, err = InitializeFromProto(&ethpb.BeaconState{PreviousEpochAttestations: want})
require.NoError(t, err)
got, err := s.PreviousEpochAttestations()
require.NoError(t, err)
@@ -27,14 +27,14 @@ func TestBeaconState_PreviousEpochAttestations(t *testing.T) {
}
func TestBeaconState_CurrentEpochAttestations(t *testing.T) {
s, err := InitializeFromProto(&statepb.BeaconState{})
s, err := InitializeFromProto(&ethpb.BeaconState{})
require.NoError(t, err)
atts, err := s.CurrentEpochAttestations()
require.NoError(t, err)
require.DeepEqual(t, []*statepb.PendingAttestation(nil), atts)
require.DeepEqual(t, []*ethpb.PendingAttestation(nil), atts)
want := []*statepb.PendingAttestation{{ProposerIndex: 101}}
s, err = InitializeFromProto(&statepb.BeaconState{CurrentEpochAttestations: want})
want := []*ethpb.PendingAttestation{{ProposerIndex: 101}}
s, err = InitializeFromProto(&ethpb.BeaconState{CurrentEpochAttestations: want})
require.NoError(t, err)
got, err := s.CurrentEpochAttestations()
require.NoError(t, err)

View File

@@ -3,20 +3,20 @@ package v1
import (
"testing"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
v1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestBeaconState_LatestBlockHeader(t *testing.T) {
s, err := InitializeFromProto(&statepb.BeaconState{})
s, err := InitializeFromProto(&ethpb.BeaconState{})
require.NoError(t, err)
got := s.LatestBlockHeader()
require.DeepEqual(t, (*v1alpha1.BeaconBlockHeader)(nil), got)
want := &v1alpha1.BeaconBlockHeader{Slot: 100}
s, err = InitializeFromProto(&statepb.BeaconState{LatestBlockHeader: want})
s, err = InitializeFromProto(&ethpb.BeaconState{LatestBlockHeader: want})
require.NoError(t, err)
got = s.LatestBlockHeader()
require.DeepEqual(t, want, got)
@@ -27,13 +27,13 @@ func TestBeaconState_LatestBlockHeader(t *testing.T) {
}
func TestBeaconState_BlockRoots(t *testing.T) {
s, err := InitializeFromProto(&statepb.BeaconState{})
s, err := InitializeFromProto(&ethpb.BeaconState{})
require.NoError(t, err)
got := s.BlockRoots()
require.DeepEqual(t, ([][]byte)(nil), got)
want := [][]byte{{'a'}}
s, err = InitializeFromProto(&statepb.BeaconState{BlockRoots: want})
s, err = InitializeFromProto(&ethpb.BeaconState{BlockRoots: want})
require.NoError(t, err)
got = s.BlockRoots()
require.DeepEqual(t, want, got)
@@ -44,14 +44,14 @@ func TestBeaconState_BlockRoots(t *testing.T) {
}
func TestBeaconState_BlockRootAtIndex(t *testing.T) {
s, err := InitializeFromProto(&statepb.BeaconState{})
s, err := InitializeFromProto(&ethpb.BeaconState{})
require.NoError(t, err)
got, err := s.BlockRootAtIndex(0)
require.NoError(t, err)
require.DeepEqual(t, ([]byte)(nil), got)
r := [][]byte{{'a'}}
s, err = InitializeFromProto(&statepb.BeaconState{BlockRoots: r})
s, err = InitializeFromProto(&ethpb.BeaconState{BlockRoots: r})
require.NoError(t, err)
got, err = s.BlockRootAtIndex(0)
require.NoError(t, err)

View File

@@ -4,7 +4,7 @@ import (
"github.com/pkg/errors"
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/htrutils"
@@ -92,7 +92,7 @@ func (b *BeaconState) slot() types.Slot {
}
// Fork version of the beacon chain.
func (b *BeaconState) Fork() *statepb.Fork {
func (b *BeaconState) Fork() *ethpb.Fork {
if !b.hasInnerState() {
return nil
}
@@ -108,7 +108,7 @@ func (b *BeaconState) Fork() *statepb.Fork {
// fork version of the beacon chain.
// This assumes that a lock is already held on BeaconState.
func (b *BeaconState) fork() *statepb.Fork {
func (b *BeaconState) fork() *ethpb.Fork {
if !b.hasInnerState() {
return nil
}
@@ -120,7 +120,7 @@ func (b *BeaconState) fork() *statepb.Fork {
copy(prevVersion, b.state.Fork.PreviousVersion)
currVersion := make([]byte, len(b.state.Fork.CurrentVersion))
copy(currVersion, b.state.Fork.CurrentVersion)
return &statepb.Fork{
return &ethpb.Fork{
PreviousVersion: prevVersion,
CurrentVersion: currVersion,
Epoch: b.state.Fork.Epoch,

View File

@@ -7,7 +7,6 @@ import (
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// InnerStateUnsafe returns the pointer value of the underlying
@@ -27,7 +26,7 @@ func (b *BeaconState) CloneInnerState() interface{} {
b.lock.RLock()
defer b.lock.RUnlock()
return &statepb.BeaconState{
return &ethpb.BeaconState{
GenesisTime: b.genesisTime(),
GenesisValidatorsRoot: b.genesisValidatorRoot(),
Slot: b.slot(),
@@ -118,10 +117,10 @@ func (b *BeaconState) MarshalSSZ() ([]byte, error) {
// ProtobufBeaconState transforms an input into beacon state in the form of protobuf.
// Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconState(s interface{}) (*statepb.BeaconState, error) {
pbState, ok := s.(*statepb.BeaconState)
func ProtobufBeaconState(s interface{}) (*ethpb.BeaconState, error) {
pbState, ok := s.(*ethpb.BeaconState)
if !ok {
return nil, errors.New("input is not type statepb.BeaconState")
return nil, errors.New("input is not type ethpb.BeaconState")
}
return pbState, nil
}
@@ -153,12 +152,12 @@ func (b *BeaconState) safeCopyBytesAtIndex(input [][]byte, idx uint64) ([]byte,
return root, nil
}
func (b *BeaconState) safeCopyPendingAttestationSlice(input []*statepb.PendingAttestation) []*statepb.PendingAttestation {
func (b *BeaconState) safeCopyPendingAttestationSlice(input []*ethpb.PendingAttestation) []*ethpb.PendingAttestation {
if input == nil {
return nil
}
res := make([]*statepb.PendingAttestation, len(input))
res := make([]*ethpb.PendingAttestation, len(input))
for i := 0; i < len(res); i++ {
res[i] = copyutil.CopyPendingAttestation(input[i])
}

View File

@@ -7,13 +7,13 @@ import (
types "github.com/prysmaticlabs/eth2-types"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestBeaconState_SlotDataRace(t *testing.T) {
headState, err := InitializeFromProto(&statepb.BeaconState{Slot: 1})
headState, err := InitializeFromProto(&ethpb.BeaconState{Slot: 1})
require.NoError(t, err)
wg := sync.WaitGroup{}
@@ -81,7 +81,7 @@ func TestNilState_NoPanic(t *testing.T) {
func TestBeaconState_MatchCurrentJustifiedCheckpt(t *testing.T) {
c1 := &eth.Checkpoint{Epoch: 1}
c2 := &eth.Checkpoint{Epoch: 2}
beaconState, err := InitializeFromProto(&statepb.BeaconState{CurrentJustifiedCheckpoint: c1})
beaconState, err := InitializeFromProto(&ethpb.BeaconState{CurrentJustifiedCheckpoint: c1})
require.NoError(t, err)
require.Equal(t, true, beaconState.MatchCurrentJustifiedCheckpoint(c1))
require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c2))
@@ -94,7 +94,7 @@ func TestBeaconState_MatchCurrentJustifiedCheckpt(t *testing.T) {
func TestBeaconState_MatchPreviousJustifiedCheckpt(t *testing.T) {
c1 := &eth.Checkpoint{Epoch: 1}
c2 := &eth.Checkpoint{Epoch: 2}
beaconState, err := InitializeFromProto(&statepb.BeaconState{PreviousJustifiedCheckpoint: c1})
beaconState, err := InitializeFromProto(&ethpb.BeaconState{PreviousJustifiedCheckpoint: c1})
require.NoError(t, err)
require.NoError(t, err)
require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c1))
@@ -106,7 +106,7 @@ func TestBeaconState_MatchPreviousJustifiedCheckpt(t *testing.T) {
}
func TestBeaconState_MarshalSSZ_NilState(t *testing.T) {
s, err := InitializeFromProto(&statepb.BeaconState{})
s, err := InitializeFromProto(&ethpb.BeaconState{})
require.NoError(t, err)
s.state = nil
_, err = s.MarshalSSZ()
@@ -204,7 +204,7 @@ func TestBeaconState_ValidatorByPubkey(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, err := InitializeFromProto(&statepb.BeaconState{})
s, err := InitializeFromProto(&ethpb.BeaconState{})
require.NoError(t, err)
nKey := keyCreator([]byte{'A'})
tt.modifyFunc(s, nKey)

View File

@@ -4,13 +4,13 @@ import (
"testing"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestBeaconState_ValidatorAtIndexReadOnly_HandlesNilSlice(t *testing.T) {
st, err := v1.InitializeFromProtoUnsafe(&statepb.BeaconState{
st, err := v1.InitializeFromProtoUnsafe(&ethpb.BeaconState{
Validators: nil,
})
require.NoError(t, err)

View File

@@ -4,12 +4,11 @@ import (
"testing"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
func Test_handlePendingAttestation_OutOfRange(t *testing.T) {
items := make([]*statepb.PendingAttestation, 1)
items := make([]*ethpb.PendingAttestation, 1)
indices := []uint64{3}
_, err := handlePendingAttestation(items, indices, false)
assert.ErrorContains(t, "index 3 greater than number of pending attestations 1", err)

View File

@@ -11,7 +11,6 @@ import (
"github.com/prysmaticlabs/go-bitfield"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@@ -20,7 +19,7 @@ import (
func TestStateReferenceSharing_Finalizer(t *testing.T) {
// This test showcases the logic on a the RandaoMixes field with the GC finalizer.
a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{RandaoMixes: [][]byte{[]byte("foo")}})
a, err := InitializeFromProtoUnsafe(&ethpb.BeaconState{RandaoMixes: [][]byte{[]byte("foo")}})
require.NoError(t, err)
assert.Equal(t, uint(1), a.sharedFieldReferences[randaoMixes].Refs(), "Expected a single reference for RANDAO mixes")
@@ -46,7 +45,7 @@ func TestStateReferenceSharing_Finalizer(t *testing.T) {
func TestStateReferenceCopy_NoUnexpectedRootsMutation(t *testing.T) {
root1, root2 := bytesutil.ToBytes32([]byte("foo")), bytesutil.ToBytes32([]byte("bar"))
a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{
a, err := InitializeFromProtoUnsafe(&ethpb.BeaconState{
BlockRoots: [][]byte{
root1[:],
},
@@ -117,7 +116,7 @@ func TestStateReferenceCopy_NoUnexpectedRootsMutation(t *testing.T) {
func TestStateReferenceCopy_NoUnexpectedRandaoMutation(t *testing.T) {
val1, val2 := []byte("foo"), []byte("bar")
a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{
a, err := InitializeFromProtoUnsafe(&ethpb.BeaconState{
RandaoMixes: [][]byte{
val1,
},
@@ -164,7 +163,7 @@ func TestStateReferenceCopy_NoUnexpectedRandaoMutation(t *testing.T) {
}
func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) {
assertAttFound := func(vals []*statepb.PendingAttestation, val uint64) {
assertAttFound := func(vals []*ethpb.PendingAttestation, val uint64) {
for i := range vals {
if reflect.DeepEqual(vals[i].AggregationBits, bitfield.NewBitlist(val)) {
return
@@ -173,7 +172,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) {
t.Log(string(debug.Stack()))
t.Fatalf("Expected attestation not found (%v), want: %v", vals, val)
}
assertAttNotFound := func(vals []*statepb.PendingAttestation, val uint64) {
assertAttNotFound := func(vals []*ethpb.PendingAttestation, val uint64) {
for i := range vals {
if reflect.DeepEqual(vals[i].AggregationBits, bitfield.NewBitlist(val)) {
t.Log(string(debug.Stack()))
@@ -183,13 +182,13 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) {
}
}
a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{})
a, err := InitializeFromProtoUnsafe(&ethpb.BeaconState{})
require.NoError(t, err)
assertRefCount(t, a, previousEpochAttestations, 1)
assertRefCount(t, a, currentEpochAttestations, 1)
// Update initial state.
atts := []*statepb.PendingAttestation{
atts := []*ethpb.PendingAttestation{
{AggregationBits: bitfield.NewBitlist(1)},
{AggregationBits: bitfield.NewBitlist(2)},
}
@@ -248,9 +247,9 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) {
assertAttNotFound(b.state.GetPreviousEpochAttestations(), 2)
// Mutator should only affect calling state: a.
applyToEveryAttestation := func(state *statepb.BeaconState) {
applyToEveryAttestation := func(state *ethpb.BeaconState) {
// One MUST copy on write.
atts = make([]*statepb.PendingAttestation, len(state.CurrentEpochAttestations))
atts = make([]*ethpb.PendingAttestation, len(state.CurrentEpochAttestations))
copy(atts, state.CurrentEpochAttestations)
state.CurrentEpochAttestations = atts
for i := range state.GetCurrentEpochAttestations() {
@@ -259,7 +258,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) {
state.CurrentEpochAttestations[i] = att
}
atts = make([]*statepb.PendingAttestation, len(state.PreviousEpochAttestations))
atts = make([]*ethpb.PendingAttestation, len(state.PreviousEpochAttestations))
copy(atts, state.PreviousEpochAttestations)
state.PreviousEpochAttestations = atts
for i := range state.GetPreviousEpochAttestations() {
@@ -293,7 +292,7 @@ func TestStateReferenceCopy_NoUnexpectedAttestationsMutation(t *testing.T) {
}
func TestValidatorReferences_RemainsConsistent(t *testing.T) {
a, err := InitializeFromProtoUnsafe(&statepb.BeaconState{
a, err := InitializeFromProtoUnsafe(&ethpb.BeaconState{
Validators: []*ethpb.Validator{
{PublicKey: []byte{'A'}},
{PublicKey: []byte{'B'}},

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -18,11 +18,11 @@ func (b *BeaconState) RotateAttestations() error {
defer b.lock.Unlock()
b.setPreviousEpochAttestations(b.currentEpochAttestations())
b.setCurrentEpochAttestations([]*statepb.PendingAttestation{})
b.setCurrentEpochAttestations([]*ethpb.PendingAttestation{})
return nil
}
func (b *BeaconState) setPreviousEpochAttestations(val []*statepb.PendingAttestation) {
func (b *BeaconState) setPreviousEpochAttestations(val []*ethpb.PendingAttestation) {
b.sharedFieldReferences[previousEpochAttestations].MinusRef()
b.sharedFieldReferences[previousEpochAttestations] = stateutil.NewRef(1)
@@ -31,7 +31,7 @@ func (b *BeaconState) setPreviousEpochAttestations(val []*statepb.PendingAttesta
b.rebuildTrie[previousEpochAttestations] = true
}
func (b *BeaconState) setCurrentEpochAttestations(val []*statepb.PendingAttestation) {
func (b *BeaconState) setCurrentEpochAttestations(val []*ethpb.PendingAttestation) {
b.sharedFieldReferences[currentEpochAttestations].MinusRef()
b.sharedFieldReferences[currentEpochAttestations] = stateutil.NewRef(1)
@@ -42,7 +42,7 @@ func (b *BeaconState) setCurrentEpochAttestations(val []*statepb.PendingAttestat
// AppendCurrentEpochAttestations for the beacon state. Appends the new value
// to the the end of list.
func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error {
func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error {
if !b.hasInnerState() {
return ErrNilInnerState
}
@@ -57,7 +57,7 @@ func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttesta
if b.sharedFieldReferences[currentEpochAttestations].Refs() > 1 {
// Copy elements in underlying array by reference.
atts = make([]*statepb.PendingAttestation, len(b.state.CurrentEpochAttestations))
atts = make([]*ethpb.PendingAttestation, len(b.state.CurrentEpochAttestations))
copy(atts, b.state.CurrentEpochAttestations)
b.sharedFieldReferences[currentEpochAttestations].MinusRef()
b.sharedFieldReferences[currentEpochAttestations] = stateutil.NewRef(1)
@@ -71,7 +71,7 @@ func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttesta
// AppendPreviousEpochAttestations for the beacon state. Appends the new value
// to the the end of list.
func (b *BeaconState) AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error {
func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error {
if !b.hasInnerState() {
return ErrNilInnerState
}
@@ -85,7 +85,7 @@ func (b *BeaconState) AppendPreviousEpochAttestations(val *statepb.PendingAttest
}
if b.sharedFieldReferences[previousEpochAttestations].Refs() > 1 {
atts = make([]*statepb.PendingAttestation, len(b.state.PreviousEpochAttestations))
atts = make([]*ethpb.PendingAttestation, len(b.state.PreviousEpochAttestations))
copy(atts, b.state.PreviousEpochAttestations)
b.sharedFieldReferences[previousEpochAttestations].MinusRef()
b.sharedFieldReferences[previousEpochAttestations] = stateutil.NewRef(1)

View File

@@ -6,17 +6,17 @@ import (
types "github.com/prysmaticlabs/eth2-types"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestBeaconState_RotateAttestations(t *testing.T) {
st, err := InitializeFromProto(&statepb.BeaconState{
st, err := InitializeFromProto(&ethpb.BeaconState{
Slot: 1,
CurrentEpochAttestations: []*statepb.PendingAttestation{{Data: &eth.AttestationData{Slot: 456}}},
PreviousEpochAttestations: []*statepb.PendingAttestation{{Data: &eth.AttestationData{Slot: 123}}},
CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: &eth.AttestationData{Slot: 456}}},
PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: &eth.AttestationData{Slot: 123}}},
})
require.NoError(t, err)
@@ -40,10 +40,10 @@ func TestAppendBeyondIndicesLimit(t *testing.T) {
for i := 0; i < len(mockrandaoMixes); i++ {
mockrandaoMixes[i] = zeroHash[:]
}
st, err := InitializeFromProto(&statepb.BeaconState{
st, err := InitializeFromProto(&ethpb.BeaconState{
Slot: 1,
CurrentEpochAttestations: []*statepb.PendingAttestation{{Data: &eth.AttestationData{Slot: 456}}},
PreviousEpochAttestations: []*statepb.PendingAttestation{{Data: &eth.AttestationData{Slot: 123}}},
CurrentEpochAttestations: []*ethpb.PendingAttestation{{Data: &eth.AttestationData{Slot: 456}}},
PreviousEpochAttestations: []*ethpb.PendingAttestation{{Data: &eth.AttestationData{Slot: 123}}},
Validators: []*eth.Validator{},
Eth1Data: &eth.Eth1Data{},
BlockRoots: mockblockRoots,

View File

@@ -4,7 +4,7 @@ import (
"github.com/pkg/errors"
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"google.golang.org/protobuf/proto"
)
@@ -71,14 +71,14 @@ func (b *BeaconState) SetSlot(val types.Slot) error {
}
// SetFork version for the beacon chain.
func (b *BeaconState) SetFork(val *statepb.Fork) error {
func (b *BeaconState) SetFork(val *ethpb.Fork) error {
if !b.hasInnerState() {
return ErrNilInnerState
}
b.lock.Lock()
defer b.lock.Unlock()
fk, ok := proto.Clone(val).(*statepb.Fork)
fk, ok := proto.Clone(val).(*ethpb.Fork)
if !ok {
return errors.New("proto.Clone did not return a fork proto")
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -60,7 +59,7 @@ func TestBeaconState_NoDeadlock(t *testing.T) {
WithdrawableEpoch: 1,
})
}
st, err := InitializeFromProtoUnsafe(&statepb.BeaconState{
st, err := InitializeFromProtoUnsafe(&ethpb.BeaconState{
Validators: vals,
})
assert.NoError(t, err)
@@ -102,6 +101,6 @@ func TestStateTrie_IsNil(t *testing.T) {
emptyProto := &BeaconState{state: nil}
assert.Equal(t, true, emptyProto.IsNil())
nonNilState := &BeaconState{state: &statepb.BeaconState{}}
nonNilState := &BeaconState{state: &ethpb.BeaconState{}}
assert.Equal(t, false, nonNilState.IsNil())
}

View File

@@ -12,7 +12,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
v1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/htrutils"
@@ -30,13 +30,13 @@ var (
)
// InitializeFromProto the beacon state from a protobuf representation.
func InitializeFromProto(st *statepb.BeaconState) (*BeaconState, error) {
return InitializeFromProtoUnsafe(proto.Clone(st).(*statepb.BeaconState))
func InitializeFromProto(st *ethpb.BeaconState) (*BeaconState, error) {
return InitializeFromProtoUnsafe(proto.Clone(st).(*ethpb.BeaconState))
}
// InitializeFromProtoUnsafe directly uses the beacon state protobuf pointer
// and sets it as the inner state of the BeaconState type.
func InitializeFromProtoUnsafe(st *statepb.BeaconState) (*BeaconState, error) {
func InitializeFromProtoUnsafe(st *ethpb.BeaconState) (*BeaconState, error) {
if st == nil {
return nil, errors.New("received nil state")
}
@@ -89,7 +89,7 @@ func (b *BeaconState) Copy() state.BeaconState {
defer b.lock.RUnlock()
fieldCount := params.BeaconConfig().BeaconStateFieldCount
dst := &BeaconState{
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
// Primitive types, safe to copy.
GenesisTime: b.state.GenesisTime,
Slot: b.state.Slot,

View File

@@ -10,7 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
@@ -24,7 +24,7 @@ func TestInitializeFromProto(t *testing.T) {
require.NoError(t, err)
type test struct {
name string
state *statepb.BeaconState
state *ethpb.BeaconState
error string
}
initTests := []test{
@@ -35,14 +35,14 @@ func TestInitializeFromProto(t *testing.T) {
},
{
name: "nil validators",
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Slot: 4,
Validators: nil,
},
},
{
name: "empty state",
state: &statepb.BeaconState{},
state: &ethpb.BeaconState{},
},
{
name: "full state",
@@ -67,7 +67,7 @@ func TestInitializeFromProtoUnsafe(t *testing.T) {
require.NoError(t, err)
type test struct {
name string
state *statepb.BeaconState
state *ethpb.BeaconState
error string
}
initTests := []test{
@@ -78,14 +78,14 @@ func TestInitializeFromProtoUnsafe(t *testing.T) {
},
{
name: "nil validators",
state: &statepb.BeaconState{
state: &ethpb.BeaconState{
Slot: 4,
Validators: nil,
},
},
{
name: "empty state",
state: &statepb.BeaconState{},
state: &ethpb.BeaconState{},
},
{
name: "full state",
@@ -256,11 +256,11 @@ func TestBeaconState_AppendValidator_DoesntMutateCopy(t *testing.T) {
}
func TestBeaconState_ToProto(t *testing.T) {
source, err := testutil.NewBeaconState(testutil.FillRootsNaturalOpt, func(state *statepb.BeaconState) error {
source, err := testutil.NewBeaconState(testutil.FillRootsNaturalOpt, func(state *ethpb.BeaconState) error {
state.GenesisTime = 1
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorroot"), 32)
state.Slot = 2
state.Fork = &statepb.Fork{
state.Fork = &ethpb.Fork{
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
Epoch: 3,
@@ -299,7 +299,7 @@ func TestBeaconState_ToProto(t *testing.T) {
state.Balances = []uint64{14}
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
state.Slashings = []uint64{15}
state.PreviousEpochAttestations = []*statepb.PendingAttestation{{
state.PreviousEpochAttestations = []*ethpb.PendingAttestation{{
AggregationBits: bitfield.Bitlist{16},
Data: &eth.AttestationData{
Slot: 17,
@@ -317,7 +317,7 @@ func TestBeaconState_ToProto(t *testing.T) {
InclusionDelay: 21,
ProposerIndex: 22,
}}
state.CurrentEpochAttestations = []*statepb.PendingAttestation{{
state.CurrentEpochAttestations = []*ethpb.PendingAttestation{{
AggregationBits: bitfield.Bitlist{23},
Data: &eth.AttestationData{
Slot: 24,

View File

@@ -6,7 +6,7 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -79,7 +79,7 @@ var ErrNilInnerState = errors.New("nil inner state")
// BeaconState defines a struct containing utilities for the Ethereum Beacon Chain state, defining
// getters and setters for its respective values and helpful functions such as HashTreeRoot().
type BeaconState struct {
state *statepb.BeaconState
state *ethpb.BeaconState
lock sync.RWMutex
dirtyFields map[fieldIndex]bool
dirtyIndices map[fieldIndex][]uint64

View File

@@ -8,7 +8,6 @@ import (
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/interop"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -24,8 +23,8 @@ func TestBeaconState_ProtoBeaconStateCompatibility(t *testing.T) {
genesis := setupGenesisState(t, 64)
customState, err := v1.InitializeFromProto(genesis)
require.NoError(t, err)
cloned, ok := proto.Clone(genesis).(*statepb.BeaconState)
assert.Equal(t, true, ok, "Object is not of type *statepb.BeaconState")
cloned, ok := proto.Clone(genesis).(*ethpb.BeaconState)
assert.Equal(t, true, ok, "Object is not of type *ethpb.BeaconState")
custom := customState.CloneInnerState()
assert.DeepSSZEqual(t, cloned, custom)
@@ -51,7 +50,7 @@ func TestBeaconState_ProtoBeaconStateCompatibility(t *testing.T) {
assert.Equal(t, r1, r2, "Mismatched roots")
}
func setupGenesisState(tb testing.TB, count uint64) *statepb.BeaconState {
func setupGenesisState(tb testing.TB, count uint64) *ethpb.BeaconState {
genesisState, _, err := interop.GenerateGenesisState(context.Background(), 0, count)
require.NoError(tb, err, "Could not generate genesis beacon state")
for i := uint64(1); i < count; i++ {
@@ -126,8 +125,8 @@ func BenchmarkStateClone_Proto(b *testing.B) {
genesis := setupGenesisState(b, 64)
b.StartTimer()
for i := 0; i < b.N; i++ {
_, ok := proto.Clone(genesis).(*statepb.BeaconState)
assert.Equal(b, true, ok, "Entity is not of type *statepb.BeaconState")
_, ok := proto.Clone(genesis).(*ethpb.BeaconState)
assert.Equal(b, true, ok, "Entity is not of type *ethpb.BeaconState")
}
}
@@ -214,7 +213,7 @@ func TestForkManualCopy_OK(t *testing.T) {
genesis := setupGenesisState(t, 64)
a, err := v1.InitializeFromProto(genesis)
require.NoError(t, err)
wantedFork := &statepb.Fork{
wantedFork := &ethpb.Fork{
PreviousVersion: []byte{'a', 'b', 'c'},
CurrentVersion: []byte{'d', 'e', 'f'},
Epoch: 0,

View File

@@ -2,7 +2,7 @@ package v1
import (
"github.com/pkg/errors"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// CurrentEpochParticipation is not supported for phase 0 beacon state.
@@ -21,11 +21,11 @@ func (b *BeaconState) InactivityScores() ([]uint64, error) {
}
// CurrentSyncCommittee is not supported for phase 0 beacon state.
func (b *BeaconState) CurrentSyncCommittee() (*statepb.SyncCommittee, error) {
func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) {
return nil, errors.New("CurrentSyncCommittee is not supported for phase 0 beacon state")
}
// NextSyncCommittee is not supported for phase 0 beacon state.
func (b *BeaconState) NextSyncCommittee() (*statepb.SyncCommittee, error) {
func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) {
return nil, errors.New("NextSyncCommittee is not supported for phase 0 beacon state")
}

View File

@@ -2,7 +2,7 @@ package v1
import (
"github.com/pkg/errors"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// AppendCurrentParticipationBits is not supported for phase 0 beacon state.
@@ -21,12 +21,12 @@ func (b *BeaconState) AppendInactivityScore(s uint64) error {
}
// SetCurrentSyncCommittee is not supported for phase 0 beacon state.
func (b *BeaconState) SetCurrentSyncCommittee(val *statepb.SyncCommittee) error {
func (b *BeaconState) SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error {
return errors.New("SetCurrentSyncCommittee is not supported for phase 0 beacon state")
}
// SetNextSyncCommittee is not supported for phase 0 beacon state.
func (b *BeaconState) SetNextSyncCommittee(val *statepb.SyncCommittee) error {
func (b *BeaconState) SetNextSyncCommittee(val *ethpb.SyncCommittee) error {
return errors.New("SetNextSyncCommittee is not supported for phase 0 beacon state")
}

View File

@@ -2,15 +2,15 @@ package v2
import (
"github.com/pkg/errors"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// PreviousEpochAttestations is not supported for HF1 beacon state.
func (b *BeaconState) PreviousEpochAttestations() ([]*statepb.PendingAttestation, error) {
func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) {
return nil, errors.New("PreviousEpochAttestations is not supported for hard fork 1 beacon state")
}
// CurrentEpochAttestations is not supported for HF1 beacon state.
func (b *BeaconState) CurrentEpochAttestations() ([]*statepb.PendingAttestation, error) {
func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) {
return nil, errors.New("CurrentEpochAttestations is not supported for hard fork 1 beacon state")
}

View File

@@ -3,26 +3,26 @@ package v2
import (
"github.com/pkg/errors"
v1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// SetPreviousEpochAttestations is not supported for HF1 beacon state.
func (b *BeaconState) SetPreviousEpochAttestations(val []*statepb.PendingAttestation) error {
func (b *BeaconState) SetPreviousEpochAttestations(val []*ethpb.PendingAttestation) error {
return errors.New("SetPreviousEpochAttestations is not supported for hard fork 1 beacon state")
}
// SetCurrentEpochAttestations is not supported for HF1 beacon state.
func (b *BeaconState) SetCurrentEpochAttestations(val []*statepb.PendingAttestation) error {
func (b *BeaconState) SetCurrentEpochAttestations(val []*ethpb.PendingAttestation) error {
return errors.New("SetCurrentEpochAttestations is not supported for hard fork 1 beacon state")
}
// AppendCurrentEpochAttestations is not supported for HF1 beacon state.
func (b *BeaconState) AppendCurrentEpochAttestations(val *statepb.PendingAttestation) error {
func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error {
return errors.New("AppendCurrentEpochAttestations is not supported for hard fork 1 beacon state")
}
// AppendPreviousEpochAttestations is not supported for HF1 beacon state.
func (b *BeaconState) AppendPreviousEpochAttestations(val *statepb.PendingAttestation) error {
func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error {
return errors.New("AppendPreviousEpochAttestations is not supported for hard fork 1 beacon state")
}

View File

@@ -1,7 +1,7 @@
package v2
import (
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/htrutils"
)
@@ -9,7 +9,7 @@ import (
// syncCommitteeRoot computes the HashTreeRoot Merkleization of a commitee root.
// a SyncCommitteeRoot struct according to the eth2
// Simple Serialize specification.
func syncCommitteeRoot(committee *statepb.SyncCommittee) ([32]byte, error) {
func syncCommitteeRoot(committee *ethpb.SyncCommittee) ([32]byte, error) {
hasher := hashutil.CustomSHA256Hasher()
var fieldRoots [][32]byte
if committee == nil {

View File

@@ -7,7 +7,7 @@ import (
"github.com/dgraph-io/ristretto"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"github.com/prysmaticlabs/prysm/shared/hashutil"
@@ -47,14 +47,14 @@ type stateRootHasher struct {
// computeFieldRoots returns the hash tree root computations of every field in
// the beacon state as a list of 32 byte roots.
func computeFieldRoots(state *statepb.BeaconStateAltair) ([][]byte, error) {
func computeFieldRoots(state *ethpb.BeaconStateAltair) ([][]byte, error) {
if featureconfig.Get().EnableSSZCache {
return cachedHasher.computeFieldRootsWithHasher(state)
}
return nocachedHasher.computeFieldRootsWithHasher(state)
}
func (h *stateRootHasher) computeFieldRootsWithHasher(state *statepb.BeaconStateAltair) ([][]byte, error) {
func (h *stateRootHasher) computeFieldRootsWithHasher(state *ethpb.BeaconStateAltair) ([][]byte, error) {
if state == nil {
return nil, errors.New("nil state")
}

View File

@@ -11,7 +11,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/copyutil"
"github.com/prysmaticlabs/prysm/shared/params"
@@ -35,7 +34,7 @@ func (b *BeaconState) CloneInnerState() interface{} {
b.lock.RLock()
defer b.lock.RUnlock()
return &statepb.BeaconStateAltair{
return &ethpb.BeaconStateAltair{
GenesisTime: b.genesisTime(),
GenesisValidatorsRoot: b.genesisValidatorRoot(),
Slot: b.slot(),
@@ -166,7 +165,7 @@ func (b *BeaconState) slot() types.Slot {
}
// Fork version of the beacon chain.
func (b *BeaconState) Fork() *statepb.Fork {
func (b *BeaconState) Fork() *ethpb.Fork {
if !b.hasInnerState() {
return nil
}
@@ -182,7 +181,7 @@ func (b *BeaconState) Fork() *statepb.Fork {
// fork version of the beacon chain.
// This assumes that a lock is already held on BeaconState.
func (b *BeaconState) fork() *statepb.Fork {
func (b *BeaconState) fork() *ethpb.Fork {
if !b.hasInnerState() {
return nil
}
@@ -194,7 +193,7 @@ func (b *BeaconState) fork() *statepb.Fork {
copy(prevVersion, b.state.Fork.PreviousVersion)
currVersion := make([]byte, len(b.state.Fork.CurrentVersion))
copy(currVersion, b.state.Fork.CurrentVersion)
return &statepb.Fork{
return &ethpb.Fork{
PreviousVersion: prevVersion,
CurrentVersion: currVersion,
Epoch: b.state.Fork.Epoch,
@@ -979,7 +978,7 @@ func (b *BeaconState) FinalizedCheckpointEpoch() types.Epoch {
// currentSyncCommittee of the current sync committee in beacon chain state.
// This assumes that a lock is already held on BeaconState.
func (b *BeaconState) currentSyncCommittee() *statepb.SyncCommittee {
func (b *BeaconState) currentSyncCommittee() *ethpb.SyncCommittee {
if !b.hasInnerState() {
return nil
}
@@ -989,7 +988,7 @@ func (b *BeaconState) currentSyncCommittee() *statepb.SyncCommittee {
// nextSyncCommittee of the next sync committee in beacon chain state.
// This assumes that a lock is already held on BeaconState.
func (b *BeaconState) nextSyncCommittee() *statepb.SyncCommittee {
func (b *BeaconState) nextSyncCommittee() *ethpb.SyncCommittee {
if !b.hasInnerState() {
return nil
}
@@ -998,7 +997,7 @@ func (b *BeaconState) nextSyncCommittee() *statepb.SyncCommittee {
}
// CurrentSyncCommittee of the current sync committee in beacon chain state.
func (b *BeaconState) CurrentSyncCommittee() (*statepb.SyncCommittee, error) {
func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) {
if !b.hasInnerState() {
return nil, nil
}
@@ -1014,7 +1013,7 @@ func (b *BeaconState) CurrentSyncCommittee() (*statepb.SyncCommittee, error) {
}
// NextSyncCommittee of the next sync committee in beacon chain state.
func (b *BeaconState) NextSyncCommittee() (*statepb.SyncCommittee, error) {
func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) {
if !b.hasInnerState() {
return nil, nil
}
@@ -1156,8 +1155,8 @@ func (b *BeaconState) MarshalSSZ() ([]byte, error) {
// ProtobufBeaconState transforms an input into beacon state hard fork 1 in the form of protobuf.
// Error is returned if the input is not type protobuf beacon state.
func ProtobufBeaconState(s interface{}) (*statepb.BeaconStateAltair, error) {
pbState, ok := s.(*statepb.BeaconStateAltair)
func ProtobufBeaconState(s interface{}) (*ethpb.BeaconStateAltair, error) {
pbState, ok := s.(*ethpb.BeaconStateAltair)
if !ok {
return nil, errors.New("input is not type pb.BeaconStateAltair")
}
@@ -1170,11 +1169,11 @@ func (b *BeaconState) Version() int {
}
// CopySyncCommittee copies the provided sync committee object.
func CopySyncCommittee(data *statepb.SyncCommittee) *statepb.SyncCommittee {
func CopySyncCommittee(data *ethpb.SyncCommittee) *ethpb.SyncCommittee {
if data == nil {
return nil
}
return &statepb.SyncCommittee{
return &ethpb.SyncCommittee{
Pubkeys: bytesutil.Copy2dBytes(data.Pubkeys),
AggregatePubkey: bytesutil.SafeCopyBytes(data.AggregatePubkey),
}

View File

@@ -5,12 +5,12 @@ import (
"sync"
"testing"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestBeaconState_SlotDataRace(t *testing.T) {
headState, err := InitializeFromProto(&statepb.BeaconStateAltair{Slot: 1})
headState, err := InitializeFromProto(&ethpb.BeaconStateAltair{Slot: 1})
require.NoError(t, err)
wg := sync.WaitGroup{}

View File

@@ -8,7 +8,6 @@ import (
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/copyutil"
"github.com/prysmaticlabs/prysm/shared/hashutil"
@@ -69,14 +68,14 @@ func (b *BeaconState) SetSlot(val types.Slot) error {
}
// SetFork version for the beacon chain.
func (b *BeaconState) SetFork(val *statepb.Fork) error {
func (b *BeaconState) SetFork(val *ethpb.Fork) error {
if !b.hasInnerState() {
return ErrNilInnerState
}
b.lock.Lock()
defer b.lock.Unlock()
fk, ok := proto.Clone(val).(*statepb.Fork)
fk, ok := proto.Clone(val).(*ethpb.Fork)
if !ok {
return errors.New("proto.Clone did not return a fork proto")
}
@@ -704,7 +703,7 @@ func (b *BeaconState) SetFinalizedCheckpoint(val *ethpb.Checkpoint) error {
}
// SetCurrentSyncCommittee for the beacon state.
func (b *BeaconState) SetCurrentSyncCommittee(val *statepb.SyncCommittee) error {
func (b *BeaconState) SetCurrentSyncCommittee(val *ethpb.SyncCommittee) error {
if !b.hasInnerState() {
return ErrNilInnerState
}
@@ -717,7 +716,7 @@ func (b *BeaconState) SetCurrentSyncCommittee(val *statepb.SyncCommittee) error
}
// SetNextSyncCommittee for the beacon state.
func (b *BeaconState) SetNextSyncCommittee(val *statepb.SyncCommittee) error {
func (b *BeaconState) SetNextSyncCommittee(val *ethpb.SyncCommittee) error {
if !b.hasInnerState() {
return ErrNilInnerState
}

View File

@@ -9,7 +9,7 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/htrutils"
@@ -20,13 +20,13 @@ import (
)
// InitializeFromProto the beacon state from a protobuf representation.
func InitializeFromProto(st *statepb.BeaconStateAltair) (*BeaconState, error) {
return InitializeFromProtoUnsafe(proto.Clone(st).(*statepb.BeaconStateAltair))
func InitializeFromProto(st *ethpb.BeaconStateAltair) (*BeaconState, error) {
return InitializeFromProtoUnsafe(proto.Clone(st).(*ethpb.BeaconStateAltair))
}
// InitializeFromProtoUnsafe directly uses the beacon state protobuf pointer
// and sets it as the inner state of the BeaconState type.
func InitializeFromProtoUnsafe(st *statepb.BeaconStateAltair) (*BeaconState, error) {
func InitializeFromProtoUnsafe(st *ethpb.BeaconStateAltair) (*BeaconState, error) {
if st == nil {
return nil, errors.New("received nil state")
}
@@ -80,7 +80,7 @@ func (b *BeaconState) Copy() state.BeaconState {
fieldCount := params.BeaconConfig().BeaconStateAltairFieldCount
dst := &BeaconState{
state: &statepb.BeaconStateAltair{
state: &ethpb.BeaconStateAltair{
// Primitive types, safe to copy.
GenesisTime: b.state.GenesisTime,
Slot: b.state.Slot,
@@ -355,7 +355,6 @@ func (b *BeaconState) recomputeFieldTrie(index fieldIndex, elements interface{})
if err != nil {
return [32]byte{}, err
}
b.dirtyIndices[index] = []uint64{}
return root, nil
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
@@ -45,7 +44,7 @@ func TestValidatorMap_DistinctCopy(t *testing.T) {
func TestInitializeFromProto(t *testing.T) {
type test struct {
name string
state *statepb.BeaconStateAltair
state *ethpb.BeaconStateAltair
error string
}
initTests := []test{
@@ -56,14 +55,14 @@ func TestInitializeFromProto(t *testing.T) {
},
{
name: "nil validators",
state: &statepb.BeaconStateAltair{
state: &ethpb.BeaconStateAltair{
Slot: 4,
Validators: nil,
},
},
{
name: "empty state",
state: &statepb.BeaconStateAltair{},
state: &ethpb.BeaconStateAltair{},
},
// TODO: Add full state. Blocked by testutil migration.
}
@@ -98,7 +97,7 @@ func TestBeaconState_NoDeadlock(t *testing.T) {
WithdrawableEpoch: 1,
})
}
st, err := InitializeFromProtoUnsafe(&statepb.BeaconStateAltair{
st, err := InitializeFromProtoUnsafe(&ethpb.BeaconStateAltair{
Validators: vals,
})
assert.NoError(t, err)
@@ -136,7 +135,7 @@ func TestBeaconState_NoDeadlock(t *testing.T) {
func TestInitializeFromProtoUnsafe(t *testing.T) {
type test struct {
name string
state *statepb.BeaconStateAltair
state *ethpb.BeaconStateAltair
error string
}
initTests := []test{
@@ -147,14 +146,14 @@ func TestInitializeFromProtoUnsafe(t *testing.T) {
},
{
name: "nil validators",
state: &statepb.BeaconStateAltair{
state: &ethpb.BeaconStateAltair{
Slot: 4,
Validators: nil,
},
},
{
name: "empty state",
state: &statepb.BeaconStateAltair{},
state: &ethpb.BeaconStateAltair{},
},
// TODO: Add full state. Blocked by testutil migration.
}

View File

@@ -5,7 +5,7 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
)
@@ -76,7 +76,7 @@ var ErrNilInnerState = errors.New("nil inner state")
// BeaconState defines a struct containing utilities for the eth2 chain state, defining
// getters and setters for its respective values and helpful functions such as HashTreeRoot().
type BeaconState struct {
state *statepb.BeaconStateAltair
state *ethpb.BeaconStateAltair
lock sync.RWMutex
dirtyFields map[fieldIndex]interface{}
dirtyIndices map[fieldIndex][]uint64

View File

@@ -12,7 +12,7 @@ import (
prysmP2P "github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
@@ -58,7 +58,7 @@ func TestRegisterRPC_ReceivesValidMessage(t *testing.T) {
wg.Add(1)
topic := "/testing/foobar/1"
handler := func(ctx context.Context, msg interface{}, stream libp2pcore.Stream) error {
m, ok := msg.(*statepb.Fork)
m, ok := msg.(*ethpb.Fork)
if !ok {
t.Error("Object is not of type *pb.TestSimpleMessage")
}
@@ -67,14 +67,14 @@ func TestRegisterRPC_ReceivesValidMessage(t *testing.T) {
return nil
}
prysmP2P.RPCTopicMappings[topic] = new(statepb.Fork)
prysmP2P.RPCTopicMappings[topic] = new(ethpb.Fork)
// Cleanup Topic mappings
defer func() {
delete(prysmP2P.RPCTopicMappings, topic)
}()
r.registerRPC(topic, handler)
p2p.ReceiveRPC(topic, &statepb.Fork{CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr")})
p2p.ReceiveRPC(topic, &ethpb.Fork{CurrentVersion: []byte("fooo"), PreviousVersion: []byte("barr")})
if testutil.WaitTimeout(&wg, time.Second) {
t.Fatal("Did not receive RPC in 1 second")

Some files were not shown because too many files have changed in this diff Show More