mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
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:
@@ -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 := ðpb.ListBlocksRequest{QueryFilter: ðpb.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)
|
||||
|
||||
Reference in New Issue
Block a user