Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix complains and bad test #11555

Merged
merged 3 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/process_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2206,7 +2206,7 @@ type newForkChoicer func() forkchoice.ForkChoicer
// 2 (and the merge block in this sequence). Block 18 justifies it and Block 19 returns
// INVALID from NewPayload, with LVH block 12. No head is viable. We check that
// the node can reboot from this state
func noViableHead_Reboot(t *testing.T) {
func TestNoViableHead_Reboot(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@potuz please look

params.SetupTestConfigCleanup(t)
config := params.BeaconConfig()
config.SlotsPerEpoch = 6
Expand Down
41 changes: 0 additions & 41 deletions beacon-chain/state/testing/getters_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,6 @@ func VerifyBeaconStateLatestBlockHeader(

type getStateWithLBlockRoots func([][]byte) (state.BeaconState, error)

func VerifyBeaconStateBlockRoots(
t *testing.T,
factory getState,
factoryBR getStateWithLBlockRoots,
) {
s, err := factory()
require.NoError(t, err)
got := s.BlockRoots()
require.DeepEqual(t, ([][]byte)(nil), got)

want := [][]byte{{'a'}}
s, err = factoryBR(want)
require.NoError(t, err)
got = s.BlockRoots()
require.DeepEqual(t, want, got)

// Test copy does not mutate.
got[0][0] = 'b'
require.DeepNotEqual(t, want, got)
}

func VerifyBeaconStateBlockRootsNative(
t *testing.T,
factory getState,
Expand Down Expand Up @@ -89,26 +68,6 @@ func VerifyBeaconStateBlockRootsNative(
require.DeepNotEqual(t, want, got)
}

func VerifyBeaconStateBlockRootAtIndex(
t *testing.T,
factory getState,
factoryBR getStateWithLBlockRoots,
) {
s, err := factory()
require.NoError(t, err)
got, err := s.BlockRootAtIndex(0)
require.NoError(t, err)
require.DeepEqual(t, ([]byte)(nil), got)

r := [][]byte{{'a'}}
s, err = factoryBR(r)
require.NoError(t, err)
got, err = s.BlockRootAtIndex(0)
require.NoError(t, err)
want := bytesutil.PadTo([]byte{'a'}, fieldparams.RootLength)
require.DeepSSZEqual(t, want, got)
}

func VerifyBeaconStateBlockRootAtIndexNative(
t *testing.T,
factory getState,
Expand Down
5 changes: 4 additions & 1 deletion crypto/ecdsa/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
)

func ConvertFromInterfacePrivKey(privkey crypto.PrivKey) (*ecdsa.PrivateKey, error) {
secpKey := (privkey.(*crypto.Secp256k1PrivateKey))
secpKey, ok := privkey.(*crypto.Secp256k1PrivateKey)
if !ok {
return nil, errors.New("could not cast to Secp256k1PrivateKey")
}
rawKey, err := secpKey.Raw()
if err != nil {
return nil, err
Expand Down
15 changes: 0 additions & 15 deletions proto/prysm/v1alpha1/cloners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,21 +697,6 @@ func genSignedBeaconBlockBellatrix() *v1alpha1.SignedBeaconBlockBellatrix {
}
}

func genBlindedBeaconBlockBodyBellatrix() *v1alpha1.BlindedBeaconBlockBodyBellatrix {
return &v1alpha1.BlindedBeaconBlockBodyBellatrix{
RandaoReveal: bytes(32),
Eth1Data: genEth1Data(),
Graffiti: bytes(32),
ProposerSlashings: genProposerSlashings(5),
AttesterSlashings: genAttesterSlashings(5),
Attestations: genAttestations(10),
Deposits: genDeposits(5),
VoluntaryExits: genSignedVoluntaryExits(12),
SyncAggregate: genSyncAggregate(),
ExecutionPayloadHeader: genPayloadHeader(),
}
}

func genSyncCommitteeMessage() *v1alpha1.SyncCommitteeMessage {
return &v1alpha1.SyncCommitteeMessage{
Slot: 424555,
Expand Down
44 changes: 0 additions & 44 deletions testing/endtoend/evaluators/execution_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,26 @@ package evaluators

import (
"context"
"math"
"strconv"

"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v3/config/params"
ctypes "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
mathutil "github.com/prysmaticlabs/prysm/v3/math"
"github.com/prysmaticlabs/prysm/v3/proto/eth/service"
v2 "github.com/prysmaticlabs/prysm/v3/proto/eth/v2"
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v3/testing/endtoend/helpers"
e2e "github.com/prysmaticlabs/prysm/v3/testing/endtoend/params"
"github.com/prysmaticlabs/prysm/v3/testing/endtoend/policies"
"github.com/prysmaticlabs/prysm/v3/testing/endtoend/types"
"github.com/prysmaticlabs/prysm/v3/time/slots"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
)

// TransactionsPresent is an evaluator to make sure transactions send to the execution engine
// appear in consensus client blocks' execution payload.
var TransactionsPresent = types.Evaluator{
Name: "transactions_present_at_epoch_%d",
Policy: policies.AfterNthEpoch(helpers.BellatrixE2EForkEpoch),
Evaluation: transactionsPresent,
}

// OptimisticSyncEnabled checks that the node is in an optimistic state.
var OptimisticSyncEnabled = types.Evaluator{
Name: "optimistic_sync_at_epoch_%d",
Policy: policies.AllEpochs,
Evaluation: optimisticSyncEnabled,
}

func transactionsPresent(conns ...*grpc.ClientConn) error {
conn := conns[0]
client := ethpb.NewBeaconChainClient(conn)
chainHead, err := client.GetChainHead(context.Background(), &emptypb.Empty{})
if err != nil {
return errors.Wrap(err, "failed to get chain head")
}
req := &ethpb.ListBlocksRequest{QueryFilter: &ethpb.ListBlocksRequest_Epoch{Epoch: chainHead.HeadEpoch.Sub(1)}}
blks, err := client.ListBeaconBlocks(context.Background(), req)
if err != nil {
return errors.Wrap(err, "failed to get blocks from beacon-chain")
}
expectedTxNum := int(math.Round(float64(params.E2ETestConfig().SlotsPerEpoch) * float64(e2e.NumOfExecEngineTxs) * e2e.ExpectedExecEngineTxsThreshold))
var numberOfTxs int
for _, ctr := range blks.BlockContainers {
switch ctr.Block.(type) {
case *ethpb.BeaconBlockContainer_BellatrixBlock:
numberOfTxs += len(ctr.GetBellatrixBlock().Block.Body.ExecutionPayload.Transactions)
}
}
if numberOfTxs < expectedTxNum {
return errors.Errorf(
"not enough transactions in execution payload, expected=%d vs actual=%d",
expectedTxNum,
numberOfTxs,
)
}
return nil
}

func optimisticSyncEnabled(conns ...*grpc.ClientConn) error {
for _, conn := range conns {
client := service.NewBeaconChainClient(conn)
Expand Down
2 changes: 1 addition & 1 deletion validator/accounts/cli_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func WithMnemonic25thWord(mnemonic25thWord string) Option {
}
}

// WithMnemonic25thWord specifies the password for backups.
// WithNumAccounts specifies the number of accounts.
func WithNumAccounts(numAccounts int) Option {
return func(acc *AccountsCLIManager) error {
acc.numAccounts = numAccounts
Expand Down
2 changes: 1 addition & 1 deletion validator/accounts/testing/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (_ MockValidator) CheckDoppelGanger(_ context.Context) error {
panic("implement me")
}

// PushProposerSettings for mocking
// HasProposerSettings for mocking
func (MockValidator) HasProposerSettings() bool {
panic("implement me")
}
Expand Down
2 changes: 1 addition & 1 deletion validator/rpc/standard_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ func TestServer_SetGasLimit(t *testing.T) {
newGasLimit: 7777,
// proposerSettings is not set - we need to create proposerSettings and set gaslimit properly
w: []want{
want{
{
pubkey: pubkey1,
gaslimit: 7777,
},
Expand Down