mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Clean up unused code (#11900)
* Clean up unused code * More unused Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -22,7 +22,6 @@ import (
|
||||
testDB "github.com/prysmaticlabs/prysm/v3/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/execution"
|
||||
mockExecution "github.com/prysmaticlabs/prysm/v3/beacon-chain/execution/testing"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/forkchoice"
|
||||
doublylinkedtree "github.com/prysmaticlabs/prysm/v3/beacon-chain/forkchoice/doubly-linked-tree"
|
||||
forkchoicetypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/forkchoice/types"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/attestations"
|
||||
@@ -1992,8 +1991,6 @@ func TestStore_NoViableHead_Liveness(t *testing.T) {
|
||||
require.Equal(t, false, optimistic)
|
||||
}
|
||||
|
||||
type newForkChoicer func() forkchoice.ForkChoicer
|
||||
|
||||
// See the description in #10777 and #10782 for the full setup
|
||||
// We sync optimistically a chain of blocks. Block 12 is the first block in Epoch
|
||||
// 2 (and the merge block in this sequence). Block 18 justifies it and Block 19 returns
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package depositsnapshot
|
||||
|
||||
const (
|
||||
DepositContractDepth = 32 // Maximum tree depth as defined by EIP-4881.
|
||||
)
|
||||
|
||||
// MerkleTreeNode is the interface for a Merkle tree.
|
||||
type MerkleTreeNode interface {
|
||||
// GetRoot returns the root of the Merkle tree.
|
||||
|
||||
@@ -76,7 +76,7 @@ func ComputeSigningRoot(object fssz.HashRoot, domain []byte) ([32]byte, error) {
|
||||
return SigningData(object.HashTreeRoot, domain)
|
||||
}
|
||||
|
||||
// Computes the signing data by utilising the provided root function and then
|
||||
// SigningData computes the signing data by utilising the provided root function and then
|
||||
// returning the signing data of the container object.
|
||||
func SigningData(rootFunc func() ([32]byte, error), domain []byte) ([32]byte, error) {
|
||||
objRoot, err := rootFunc()
|
||||
|
||||
@@ -88,7 +88,7 @@ func GenesisBeaconStateBellatrix(ctx context.Context, deposits []*ethpb.Deposit,
|
||||
return OptimizedGenesisBeaconStateBellatrix(genesisTime, st, st.Eth1Data(), ep)
|
||||
}
|
||||
|
||||
// OptimizedGenesisBeaconState is used to create a state that has already processed deposits. This is to efficiently
|
||||
// OptimizedGenesisBeaconStateBellatrix is used to create a state that has already processed deposits. This is to efficiently
|
||||
// create a mainnet state at chainstart.
|
||||
func OptimizedGenesisBeaconStateBellatrix(genesisTime uint64, preState state.BeaconState, eth1Data *ethpb.Eth1Data, ep *enginev1.ExecutionPayload) (state.BeaconState, error) {
|
||||
if eth1Data == nil {
|
||||
@@ -241,7 +241,7 @@ func OptimizedGenesisBeaconStateBellatrix(genesisTime uint64, preState state.Bea
|
||||
return ist, nil
|
||||
}
|
||||
|
||||
// EmptyGenesisState returns an empty beacon state object.
|
||||
// EmptyGenesisStateBellatrix returns an empty beacon state object.
|
||||
func EmptyGenesisStateBellatrix() (state.BeaconState, error) {
|
||||
st := ðpb.BeaconStateBellatrix{
|
||||
// Misc fields.
|
||||
|
||||
@@ -1470,7 +1470,7 @@ func TestHeaderByHash_NotFound(t *testing.T) {
|
||||
srv := &Service{}
|
||||
srv.rpcClient = RPCClientBad{}
|
||||
|
||||
_, err := srv.HeaderByHash(context.Background(), common.Hash([32]byte{}))
|
||||
_, err := srv.HeaderByHash(context.Background(), [32]byte{})
|
||||
assert.Equal(t, ethereum.NotFound, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetLastWithdrawalValidatorIndex sets the index of the validator which is
|
||||
// SetNextWithdrawalValidatorIndex sets the index of the validator which is
|
||||
// next in line for a partial withdrawal.
|
||||
func (b *BeaconState) SetNextWithdrawalValidatorIndex(i types.ValidatorIndex) error {
|
||||
if b.version < version.Capella {
|
||||
|
||||
@@ -24,12 +24,6 @@ func WithMockState(s state.BeaconState) MockReplayerBuilderOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithStateError(s types.Slot, e error) MockReplayerBuilderOption {
|
||||
return func(b *MockReplayerBuilder) {
|
||||
b.SetMockSlotError(s, e)
|
||||
}
|
||||
}
|
||||
|
||||
type MockReplayerBuilder struct {
|
||||
forSlot map[types.Slot]*MockReplayer
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ go_library(
|
||||
"getters_block.go",
|
||||
"getters_checkpoint.go",
|
||||
"getters_validator.go",
|
||||
"setters_participation.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/testing",
|
||||
visibility = ["//beacon-chain/state:__subpackages__"],
|
||||
|
||||
@@ -31,20 +31,6 @@ func VerifyBeaconStateSlotDataRace(t *testing.T, factory getState) {
|
||||
}
|
||||
|
||||
type getStateWithCurrentJustifiedCheckpoint func(*ethpb.Checkpoint) (state.BeaconState, error)
|
||||
type clearInternalState func(state.BeaconState)
|
||||
|
||||
func VerifyBeaconStateMatchCurrentJustifiedCheckpt(t *testing.T, factory getStateWithCurrentJustifiedCheckpoint, clear clearInternalState) {
|
||||
c1 := ðpb.Checkpoint{Epoch: 1}
|
||||
c2 := ðpb.Checkpoint{Epoch: 2}
|
||||
beaconState, err := factory(c1)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, beaconState.MatchCurrentJustifiedCheckpoint(c1))
|
||||
require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c2))
|
||||
require.Equal(t, false, beaconState.MatchPreviousJustifiedCheckpoint(c1))
|
||||
require.Equal(t, false, beaconState.MatchPreviousJustifiedCheckpoint(c2))
|
||||
clear(beaconState)
|
||||
require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c1))
|
||||
}
|
||||
|
||||
func VerifyBeaconStateMatchCurrentJustifiedCheckptNative(t *testing.T, factory getStateWithCurrentJustifiedCheckpoint) {
|
||||
c1 := ðpb.Checkpoint{Epoch: 1}
|
||||
@@ -57,19 +43,6 @@ func VerifyBeaconStateMatchCurrentJustifiedCheckptNative(t *testing.T, factory g
|
||||
require.Equal(t, false, beaconState.MatchPreviousJustifiedCheckpoint(c2))
|
||||
}
|
||||
|
||||
func VerifyBeaconStateMatchPreviousJustifiedCheckpt(t *testing.T, factory getStateWithCurrentJustifiedCheckpoint, clear clearInternalState) {
|
||||
c1 := ðpb.Checkpoint{Epoch: 1}
|
||||
c2 := ðpb.Checkpoint{Epoch: 2}
|
||||
beaconState, err := factory(c1)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c1))
|
||||
require.Equal(t, false, beaconState.MatchCurrentJustifiedCheckpoint(c2))
|
||||
require.Equal(t, true, beaconState.MatchPreviousJustifiedCheckpoint(c1))
|
||||
require.Equal(t, false, beaconState.MatchPreviousJustifiedCheckpoint(c2))
|
||||
clear(beaconState)
|
||||
require.Equal(t, false, beaconState.MatchPreviousJustifiedCheckpoint(c1))
|
||||
}
|
||||
|
||||
func VerifyBeaconStateMatchPreviousJustifiedCheckptNative(t *testing.T, factory getStateWithCurrentJustifiedCheckpoint) {
|
||||
c1 := ðpb.Checkpoint{Epoch: 1}
|
||||
c2 := ðpb.Checkpoint{Epoch: 2}
|
||||
@@ -81,14 +54,6 @@ func VerifyBeaconStateMatchPreviousJustifiedCheckptNative(t *testing.T, factory
|
||||
require.Equal(t, false, beaconState.MatchPreviousJustifiedCheckpoint(c2))
|
||||
}
|
||||
|
||||
func VerifyBeaconStateMarshalSSZNilState(t *testing.T, factory getState, clear clearInternalState) {
|
||||
s, err := factory()
|
||||
require.NoError(t, err)
|
||||
clear(s)
|
||||
_, err = s.MarshalSSZ()
|
||||
require.ErrorContains(t, "nil beacon state", err)
|
||||
}
|
||||
|
||||
func VerifyBeaconStateValidatorByPubkey(t *testing.T, factory getState) {
|
||||
keyCreator := func(input []byte) [fieldparams.BLSPubkeyLength]byte {
|
||||
var nKey [fieldparams.BLSPubkeyLength]byte
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
)
|
||||
|
||||
func VerifyBeaconStateModifyCurrentParticipationField(t *testing.T, factory getState) {
|
||||
st, err := factory()
|
||||
require.NoError(t, err)
|
||||
assert.NoError(t, st.ModifyCurrentParticipationBits(func(val []byte) ([]byte, error) {
|
||||
length := len(val)
|
||||
mid := length / 2
|
||||
|
||||
val[0] = uint8(100)
|
||||
val[len(val)-1] = uint8(200)
|
||||
val[mid] = 150
|
||||
return val, nil
|
||||
}))
|
||||
participation, err := st.CurrentEpochParticipation()
|
||||
assert.NoError(t, err)
|
||||
|
||||
mid := len(participation) / 2
|
||||
assert.Equal(t, participation[0], uint8(100))
|
||||
assert.Equal(t, participation[mid], uint8(150))
|
||||
assert.Equal(t, participation[len(participation)-1], uint8(200))
|
||||
}
|
||||
|
||||
func VerifyBeaconStateModifyCurrentParticipationField_NestedAction(t *testing.T, factory getState) {
|
||||
st, err := factory()
|
||||
require.NoError(t, err)
|
||||
assert.NoError(t, st.ModifyCurrentParticipationBits(func(val []byte) ([]byte, error) {
|
||||
|
||||
length := len(val)
|
||||
mid := length / 2
|
||||
|
||||
val[0] = uint8(100)
|
||||
v1, err := st.ValidatorAtIndex(0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v1.WithdrawableEpoch = 2
|
||||
err = st.UpdateValidatorAtIndex(0, v1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
val[mid] = 150
|
||||
|
||||
v2, err := st.ValidatorAtIndex(types.ValidatorIndex(mid))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v2.WithdrawableEpoch = 10
|
||||
err = st.UpdateValidatorAtIndex(types.ValidatorIndex(mid), v2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
val[len(val)-1] = uint8(200)
|
||||
v3, err := st.ValidatorAtIndex(types.ValidatorIndex(len(val) - 1))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v3.WithdrawableEpoch = 50
|
||||
err = st.UpdateValidatorAtIndex(types.ValidatorIndex(len(val)-1), v3)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return val, nil
|
||||
}))
|
||||
participation, err := st.CurrentEpochParticipation()
|
||||
assert.NoError(t, err)
|
||||
|
||||
mid := len(participation) / 2
|
||||
assert.Equal(t, participation[0], uint8(100))
|
||||
val, err := st.ValidatorAtIndex(types.ValidatorIndex(0))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, types.Epoch(2), val.WithdrawableEpoch)
|
||||
assert.Equal(t, participation[mid], uint8(150))
|
||||
val, err = st.ValidatorAtIndex(types.ValidatorIndex(mid))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, types.Epoch(10), val.WithdrawableEpoch)
|
||||
assert.Equal(t, participation[len(participation)-1], uint8(200))
|
||||
val, err = st.ValidatorAtIndex(types.ValidatorIndex(len(participation) - 1))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, types.Epoch(50), val.WithdrawableEpoch)
|
||||
}
|
||||
|
||||
func VerifyBeaconStateModifyPreviousParticipationField(t *testing.T, factory getState) {
|
||||
st, err := factory()
|
||||
require.NoError(t, err)
|
||||
assert.NoError(t, st.ModifyPreviousParticipationBits(func(val []byte) ([]byte, error) {
|
||||
length := len(val)
|
||||
mid := length / 2
|
||||
|
||||
val[0] = uint8(100)
|
||||
val[len(val)-1] = uint8(200)
|
||||
val[mid] = 150
|
||||
return val, nil
|
||||
}))
|
||||
participation, err := st.PreviousEpochParticipation()
|
||||
assert.NoError(t, err)
|
||||
|
||||
mid := len(participation) / 2
|
||||
assert.Equal(t, participation[0], uint8(100))
|
||||
assert.Equal(t, participation[mid], uint8(150))
|
||||
assert.Equal(t, participation[len(participation)-1], uint8(200))
|
||||
}
|
||||
|
||||
func VerifyBeaconStateModifyPreviousParticipationField_NestedAction(t *testing.T, factory getState) {
|
||||
st, err := factory()
|
||||
require.NoError(t, err)
|
||||
assert.NoError(t, st.ModifyPreviousParticipationBits(func(val []byte) ([]byte, error) {
|
||||
|
||||
length := len(val)
|
||||
mid := length / 2
|
||||
|
||||
val[0] = uint8(100)
|
||||
v1, err := st.ValidatorAtIndex(0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v1.WithdrawableEpoch = 2
|
||||
err = st.UpdateValidatorAtIndex(0, v1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
val[mid] = 150
|
||||
|
||||
v2, err := st.ValidatorAtIndex(types.ValidatorIndex(mid))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v2.WithdrawableEpoch = 10
|
||||
err = st.UpdateValidatorAtIndex(types.ValidatorIndex(mid), v2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
val[len(val)-1] = uint8(200)
|
||||
v3, err := st.ValidatorAtIndex(types.ValidatorIndex(len(val) - 1))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v3.WithdrawableEpoch = 50
|
||||
err = st.UpdateValidatorAtIndex(types.ValidatorIndex(len(val)-1), v3)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return val, nil
|
||||
}))
|
||||
participation, err := st.PreviousEpochParticipation()
|
||||
assert.NoError(t, err)
|
||||
|
||||
mid := len(participation) / 2
|
||||
assert.Equal(t, participation[0], uint8(100))
|
||||
val, err := st.ValidatorAtIndex(types.ValidatorIndex(0))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, types.Epoch(2), val.WithdrawableEpoch)
|
||||
assert.Equal(t, participation[mid], uint8(150))
|
||||
val, err = st.ValidatorAtIndex(types.ValidatorIndex(mid))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, types.Epoch(10), val.WithdrawableEpoch)
|
||||
assert.Equal(t, participation[len(participation)-1], uint8(200))
|
||||
val, err = st.ValidatorAtIndex(types.ValidatorIndex(len(participation) - 1))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, types.Epoch(50), val.WithdrawableEpoch)
|
||||
}
|
||||
@@ -16,8 +16,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/validator/client/beacon-api/mock"
|
||||
)
|
||||
|
||||
const attestationDataEndpoint = "/eth/v1/validator/attestation_data"
|
||||
|
||||
func TestGetAttestationData_ValidAttestation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
expectedSlot := uint64(5)
|
||||
|
||||
@@ -22,10 +22,6 @@ type beaconApiValidatorClient struct {
|
||||
fallbackClient iface.ValidatorClient
|
||||
}
|
||||
|
||||
func NewBeaconApiValidatorClient(host string, timeout time.Duration) iface.ValidatorClient {
|
||||
return NewBeaconApiValidatorClientWithFallback(host, timeout, nil)
|
||||
}
|
||||
|
||||
func NewBeaconApiValidatorClientWithFallback(host string, timeout time.Duration, fallbackClient iface.ValidatorClient) iface.ValidatorClient {
|
||||
jsonRestHandler := beaconApiJsonRestHandler{
|
||||
httpClient: http.Client{Timeout: timeout},
|
||||
|
||||
@@ -167,9 +167,6 @@ func TestBeaconApiValidatorClient_ProposeBeaconBlockValid(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBeaconApiValidatorClient_ProposeBeaconBlockError(t *testing.T) {
|
||||
const slot = types.Slot(1)
|
||||
const committeeIndex = types.CommitteeIndex(2)
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ func TestGetDomainData_ValidDomainData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetDomainData_GenesisError(t *testing.T) {
|
||||
const genesisValidatorRoot = "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
|
||||
epoch := params.BeaconConfig().AltairForkEpoch
|
||||
domainType := params.BeaconConfig().DomainBeaconProposer
|
||||
|
||||
@@ -77,7 +76,6 @@ func TestGetDomainData_GenesisError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetDomainData_InvalidGenesisRoot(t *testing.T) {
|
||||
const genesisValidatorRoot = "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
|
||||
epoch := params.BeaconConfig().AltairForkEpoch
|
||||
domainType := params.BeaconConfig().DomainBeaconProposer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user