Fix complains and bad test (#11555)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terencechain
2022-10-17 09:20:26 -07:00
committed by GitHub
parent dcba27ffbc
commit e8400a0773
8 changed files with 8 additions and 105 deletions

View File

@@ -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) {
params.SetupTestConfigCleanup(t)
config := params.BeaconConfig()
config.SlotsPerEpoch = 6

View File

@@ -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,
@@ -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,

View File

@@ -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

View File

@@ -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,

View File

@@ -2,33 +2,19 @@ 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",
@@ -36,36 +22,6 @@ var OptimisticSyncEnabled = types.Evaluator{
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)

View File

@@ -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

View File

@@ -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")
}

View File

@@ -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,
},