diff --git a/beacon-chain/blockchain/process_block_test.go b/beacon-chain/blockchain/process_block_test.go index f226930e59..7bd6431d04 100644 --- a/beacon-chain/blockchain/process_block_test.go +++ b/beacon-chain/blockchain/process_block_test.go @@ -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 diff --git a/beacon-chain/cache/depositsnapshot/merkle_tree.go b/beacon-chain/cache/depositsnapshot/merkle_tree.go index 5d2efa5b7d..e9b5c1e5f5 100644 --- a/beacon-chain/cache/depositsnapshot/merkle_tree.go +++ b/beacon-chain/cache/depositsnapshot/merkle_tree.go @@ -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. diff --git a/beacon-chain/core/signing/signing_root.go b/beacon-chain/core/signing/signing_root.go index b8369f3830..4d1a91f404 100644 --- a/beacon-chain/core/signing/signing_root.go +++ b/beacon-chain/core/signing/signing_root.go @@ -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() diff --git a/beacon-chain/core/transition/state-bellatrix.go b/beacon-chain/core/transition/state-bellatrix.go index bf6ac61562..0e5710097d 100644 --- a/beacon-chain/core/transition/state-bellatrix.go +++ b/beacon-chain/core/transition/state-bellatrix.go @@ -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. diff --git a/beacon-chain/execution/engine_client_test.go b/beacon-chain/execution/engine_client_test.go index e997a15343..dc1732f0af 100644 --- a/beacon-chain/execution/engine_client_test.go +++ b/beacon-chain/execution/engine_client_test.go @@ -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) } diff --git a/beacon-chain/state/state-native/setters_withdrawal.go b/beacon-chain/state/state-native/setters_withdrawal.go index 53be0e7ae5..34cdf73497 100644 --- a/beacon-chain/state/state-native/setters_withdrawal.go +++ b/beacon-chain/state/state-native/setters_withdrawal.go @@ -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 { diff --git a/beacon-chain/state/stategen/mock/replayer.go b/beacon-chain/state/stategen/mock/replayer.go index 3b030b15b1..f347cab3d7 100644 --- a/beacon-chain/state/stategen/mock/replayer.go +++ b/beacon-chain/state/stategen/mock/replayer.go @@ -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 } diff --git a/beacon-chain/state/testing/BUILD.bazel b/beacon-chain/state/testing/BUILD.bazel index ecfb159756..71425e8ea0 100644 --- a/beacon-chain/state/testing/BUILD.bazel +++ b/beacon-chain/state/testing/BUILD.bazel @@ -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__"], diff --git a/beacon-chain/state/testing/getters.go b/beacon-chain/state/testing/getters.go index 729001ca03..3f5655c663 100644 --- a/beacon-chain/state/testing/getters.go +++ b/beacon-chain/state/testing/getters.go @@ -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 diff --git a/beacon-chain/state/testing/setters_participation.go b/beacon-chain/state/testing/setters_participation.go deleted file mode 100644 index 0725420b5a..0000000000 --- a/beacon-chain/state/testing/setters_participation.go +++ /dev/null @@ -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) -} diff --git a/validator/client/beacon-api/attestation_data_test.go b/validator/client/beacon-api/attestation_data_test.go index d55e7a8359..84da676f34 100644 --- a/validator/client/beacon-api/attestation_data_test.go +++ b/validator/client/beacon-api/attestation_data_test.go @@ -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) diff --git a/validator/client/beacon-api/beacon_api_validator_client.go b/validator/client/beacon-api/beacon_api_validator_client.go index d62a05054b..44a47e87a0 100644 --- a/validator/client/beacon-api/beacon_api_validator_client.go +++ b/validator/client/beacon-api/beacon_api_validator_client.go @@ -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}, diff --git a/validator/client/beacon-api/beacon_api_validator_client_test.go b/validator/client/beacon-api/beacon_api_validator_client_test.go index 4858b518d0..3937622624 100644 --- a/validator/client/beacon-api/beacon_api_validator_client_test.go +++ b/validator/client/beacon-api/beacon_api_validator_client_test.go @@ -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() diff --git a/validator/client/beacon-api/domain_data_test.go b/validator/client/beacon-api/domain_data_test.go index 1ce5dbbfa8..baa579647e 100644 --- a/validator/client/beacon-api/domain_data_test.go +++ b/validator/client/beacon-api/domain_data_test.go @@ -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