mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-07 20:43:57 -05:00
* updating the goethereum dependency * fixing dependencies * reverting workspace * more fixes, work in progress * trying with upgraded geth version * fixing deprecated functions except for the time related ones on eth1 distance due to time issues * fixing time issues * gaz * fixing test and upgrading some dependencies and reverting others * Disable cgo in hid, delete old vendored usb library * changelog * rolling back dependencies * fixing go mod tidy * Geth v1.13.6 * fix tests * Add ping interval, set to 500ms for tests. This didnt work * Update to v1.14.8 * Spread it out to different bootnodes * Fix it * Remove Memsize * Update all out of date dependencies * Fix geth body change * Fix Test * Fix Build * Fix Tests * Fix Tests Again * Fix Tests Again * Fix Tests * Fix Test * Copy USB Package for HID * Push it up * Finally fix all tests with felix's changes * updating geth dependency * Update go-ethereum to v1.14.11 * fixing import * reverting blob change * fixing Implicit memory aliasing in for loop. * WIP changes * wip getting a little further on e2e runs * getting a little further * getting a little further * setting everything to capella * more partial fixes * more fixes but still WIP * fixing access list transactions" * some cleanup * making configs dynamic * reverting time * skip lower bound in builder * updating to geth v1.14.12 * fixing verify blob to pointer * go mod tidy * fixing linting * missed removing another terminal difficulty item * another missed update * updating more dependencies to fix cicd * fixing holiman dependency update * downgrading geth to 1.14.11 due to p2p loop issue * reverting builder middleware caused by downgrade * fixing more rollback issues * upgrading back to 1.14.12 after discussing with preston * mod tidy * gofmt * partial review feedback * trying to start e2e from bellatrix instead * reverting some changes --------- Co-authored-by: Preston Van Loon <preston@pvl.dev> Co-authored-by: nisdas <nishdas93@gmail.com>
138 lines
5.1 KiB
Go
138 lines
5.1 KiB
Go
package evaluators
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v5/config/params"
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
|
"github.com/prysmaticlabs/prysm/v5/encoding/ssz"
|
|
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/endtoend/policies"
|
|
e2etypes "github.com/prysmaticlabs/prysm/v5/testing/endtoend/types"
|
|
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
|
)
|
|
|
|
// BuilderIsActive checks that the builder is indeed producing the respective payloads
|
|
var BuilderIsActive = e2etypes.Evaluator{
|
|
Name: "builder_is_active_at_epoch_%d",
|
|
Policy: func(e primitives.Epoch) bool {
|
|
fEpoch := params.BeaconConfig().BellatrixForkEpoch
|
|
return policies.OnwardsNthEpoch(fEpoch)(e)
|
|
},
|
|
Evaluation: builderActive,
|
|
}
|
|
|
|
func builderActive(_ *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) error {
|
|
conn := conns[0]
|
|
client := ethpb.NewNodeClient(conn)
|
|
beaconClient := ethpb.NewBeaconChainClient(conn)
|
|
genesis, err := client.GetGenesis(context.Background(), &emptypb.Empty{})
|
|
if err != nil {
|
|
return errors.Wrap(err, "failed to get genesis data")
|
|
}
|
|
currSlot := slots.CurrentSlot(uint64(genesis.GenesisTime.AsTime().Unix()))
|
|
currEpoch := slots.ToEpoch(currSlot)
|
|
lowestBound := primitives.Epoch(0)
|
|
if currEpoch >= 1 {
|
|
lowestBound = currEpoch - 1
|
|
}
|
|
|
|
if lowestBound < params.BeaconConfig().BellatrixForkEpoch {
|
|
lowestBound = params.BeaconConfig().BellatrixForkEpoch
|
|
}
|
|
emptyRt, err := ssz.TransactionsRoot([][]byte{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
blockCtrs, err := beaconClient.ListBeaconBlocks(context.Background(), ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: lowestBound}})
|
|
if err != nil {
|
|
return errors.Wrap(err, "failed to get beacon blocks")
|
|
}
|
|
for _, ctr := range blockCtrs.BlockContainers {
|
|
b, err := syncCompatibleBlockFromCtr(ctr)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "block type doesn't exist for block at epoch %d", lowestBound)
|
|
}
|
|
|
|
if b.IsNil() {
|
|
return errors.New("nil block provided")
|
|
}
|
|
forkStartSlot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if forkStartSlot == b.Block().Slot() || forkStartSlot+1 == b.Block().Slot() || lowestBound <= 1 {
|
|
// Skip fork slot and the next one, as we don't send FCUs yet.
|
|
continue
|
|
}
|
|
execPayload, err := b.Block().Body().Execution()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
txRoot, err := execPayload.TransactionsRoot()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if [32]byte(txRoot) == emptyRt && string(execPayload.ExtraData()) != "prysm-builder" {
|
|
// If a local payload is built with 0 transactions, builder cannot build a payload with more transactions
|
|
// since they both utilize the same EL.
|
|
continue
|
|
}
|
|
if string(execPayload.ExtraData()) != "prysm-builder" {
|
|
return errors.Errorf("%s block with slot %d was not built by the builder. It has an extra data of %s and txRoot of %s", version.String(b.Version()), b.Block().Slot(), string(execPayload.ExtraData()), hexutil.Encode(txRoot))
|
|
}
|
|
if execPayload.GasLimit() == 0 {
|
|
return errors.Errorf("%s block with slot %d has a gas limit of 0, when it should be in the 30M range", version.String(b.Version()), b.Block().Slot())
|
|
}
|
|
}
|
|
if lowestBound == currEpoch {
|
|
return nil
|
|
}
|
|
blockCtrs, err = beaconClient.ListBeaconBlocks(context.Background(), ðpb.ListBlocksRequest{QueryFilter: ðpb.ListBlocksRequest_Epoch{Epoch: currEpoch}})
|
|
if err != nil {
|
|
return errors.Wrap(err, "failed to get validator participation")
|
|
}
|
|
for _, ctr := range blockCtrs.BlockContainers {
|
|
b, err := syncCompatibleBlockFromCtr(ctr)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "block type doesn't exist for block at epoch %d", lowestBound)
|
|
}
|
|
if b.IsNil() {
|
|
return errors.New("nil block provided")
|
|
}
|
|
forkStartSlot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if forkStartSlot == b.Block().Slot() || forkStartSlot+1 == b.Block().Slot() || lowestBound <= 1 {
|
|
// Skip fork slot and the next one, as we don't send FCUs yet.
|
|
continue
|
|
}
|
|
execPayload, err := b.Block().Body().Execution()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
txRoot, err := execPayload.TransactionsRoot()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if [32]byte(txRoot) == emptyRt && string(execPayload.ExtraData()) != "prysm-builder" {
|
|
// If a local payload is built with 0 transactions, builder cannot build a payload with more transactions
|
|
// since they both utilize the same EL.
|
|
continue
|
|
}
|
|
if string(execPayload.ExtraData()) != "prysm-builder" {
|
|
return errors.Errorf("%s block with slot %d was not built by the builder. It has an extra data of %s and txRoot of %s", version.String(b.Version()), b.Block().Slot(), string(execPayload.ExtraData()), hexutil.Encode(txRoot))
|
|
}
|
|
if execPayload.GasLimit() == 0 {
|
|
return errors.Errorf("%s block with slot %d has a gas limit of 0, when it should be in the 30M range", version.String(b.Version()), b.Block().Slot())
|
|
}
|
|
}
|
|
return nil
|
|
}
|