Enable Deneb For E2E Scenario Tests (#13317)

* fix all cases

* update web3signer

* current progress

* fix it finally

* push it back to capella

* remove hard-coded forks

* fix failing tests

* gaz

* fix dumb bug

* fix bad test setup

* change back
This commit is contained in:
Nishant Das
2023-12-16 19:37:44 +08:00
committed by GitHub
parent c56abfb840
commit b45a6664be
39 changed files with 431 additions and 171 deletions

View File

@@ -427,22 +427,22 @@ func non200Err(response *http.Response) error {
log.WithError(ErrNoContent).Debug(msg)
return ErrNoContent
case http.StatusBadRequest:
log.WithError(ErrBadRequest).Debug(msg)
if jsonErr := json.Unmarshal(bodyBytes, &errMessage); jsonErr != nil {
return errors.Wrap(jsonErr, "unable to read response body")
}
log.WithError(ErrBadRequest).Debug(msg)
return errors.Wrap(ErrBadRequest, errMessage.Message)
case http.StatusNotFound:
log.WithError(ErrNotFound).Debug(msg)
if jsonErr := json.Unmarshal(bodyBytes, &errMessage); jsonErr != nil {
return errors.Wrap(jsonErr, "unable to read response body")
}
log.WithError(ErrNotFound).Debug(msg)
return errors.Wrap(ErrNotFound, errMessage.Message)
case http.StatusInternalServerError:
log.WithError(ErrNotOK).Debug(msg)
if jsonErr := json.Unmarshal(bodyBytes, &errMessage); jsonErr != nil {
return errors.Wrap(jsonErr, "unable to read response body")
}
log.WithError(ErrNotOK).Debug(msg)
return errors.Wrap(ErrNotOK, errMessage.Message)
default:
log.WithError(ErrNotOK).Debug(msg)

View File

@@ -357,6 +357,45 @@ func FromProtoCapella(payload *v1.ExecutionPayloadCapella) (ExecutionPayloadCape
}, nil
}
func FromProtoDeneb(payload *v1.ExecutionPayloadDeneb) (ExecutionPayloadDeneb, error) {
bFee, err := sszBytesToUint256(payload.BaseFeePerGas)
if err != nil {
return ExecutionPayloadDeneb{}, err
}
txs := make([]hexutil.Bytes, len(payload.Transactions))
for i := range payload.Transactions {
txs[i] = bytesutil.SafeCopyBytes(payload.Transactions[i])
}
withdrawals := make([]Withdrawal, len(payload.Withdrawals))
for i, w := range payload.Withdrawals {
withdrawals[i] = Withdrawal{
Index: Uint256{Int: big.NewInt(0).SetUint64(w.Index)},
ValidatorIndex: Uint256{Int: big.NewInt(0).SetUint64(uint64(w.ValidatorIndex))},
Address: bytesutil.SafeCopyBytes(w.Address),
Amount: Uint256{Int: big.NewInt(0).SetUint64(w.Amount)},
}
}
return ExecutionPayloadDeneb{
ParentHash: bytesutil.SafeCopyBytes(payload.ParentHash),
FeeRecipient: bytesutil.SafeCopyBytes(payload.FeeRecipient),
StateRoot: bytesutil.SafeCopyBytes(payload.StateRoot),
ReceiptsRoot: bytesutil.SafeCopyBytes(payload.ReceiptsRoot),
LogsBloom: bytesutil.SafeCopyBytes(payload.LogsBloom),
PrevRandao: bytesutil.SafeCopyBytes(payload.PrevRandao),
BlockNumber: Uint64String(payload.BlockNumber),
GasLimit: Uint64String(payload.GasLimit),
GasUsed: Uint64String(payload.GasUsed),
Timestamp: Uint64String(payload.Timestamp),
ExtraData: bytesutil.SafeCopyBytes(payload.ExtraData),
BaseFeePerGas: bFee,
BlockHash: bytesutil.SafeCopyBytes(payload.BlockHash),
Transactions: txs,
Withdrawals: withdrawals,
BlobGasUsed: Uint64String(payload.BlobGasUsed),
ExcessBlobGas: Uint64String(payload.ExcessBlobGas),
}, nil
}
// ExecHeaderResponseCapella is the response of builder API /eth/v1/builder/header/{slot}/{parent_hash}/{pubkey} for Capella.
type ExecHeaderResponseCapella struct {
Data struct {
@@ -1059,6 +1098,28 @@ func (b BlobsBundle) ToProto() (*v1.BlobsBundle, error) {
}, nil
}
// FromBundleProto converts the proto bundle type to the builder
// type.
func FromBundleProto(bundle *v1.BlobsBundle) *BlobsBundle {
commitments := make([]hexutil.Bytes, len(bundle.KzgCommitments))
for i := range bundle.KzgCommitments {
commitments[i] = bytesutil.SafeCopyBytes(bundle.KzgCommitments[i])
}
proofs := make([]hexutil.Bytes, len(bundle.Proofs))
for i := range bundle.Proofs {
proofs[i] = bytesutil.SafeCopyBytes(bundle.Proofs[i])
}
blobs := make([]hexutil.Bytes, len(bundle.Blobs))
for i := range bundle.Blobs {
blobs[i] = bytesutil.SafeCopyBytes(bundle.Blobs[i])
}
return &BlobsBundle{
Commitments: commitments,
Proofs: proofs,
Blobs: blobs,
}
}
// ToProto returns ExecutionPayloadDeneb Proto and BlobsBundle Proto separately.
func (r *ExecPayloadResponseDeneb) ToProto() (*v1.ExecutionPayloadDeneb, *v1.BlobsBundle, error) {
if r.Data == nil {

View File

@@ -2050,7 +2050,7 @@ func driftGenesisTime(s *Service, slot, delay int64) {
}
func Test_commitmentsToCheck(t *testing.T) {
windowSlots, err := slots.EpochEnd(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest)
windowSlots, err := slots.EpochEnd(params.BeaconConfig().MinEpochsForBlobsSidecarsRequest)
require.NoError(t, err)
commits := [][]byte{
bytesutil.PadTo([]byte("a"), 48),

View File

@@ -60,7 +60,7 @@ func NewBlobStorage(base string, opts ...BlobStorageOption) (*BlobStorage, error
fs := afero.NewBasePathFs(afero.NewOsFs(), base)
b := &BlobStorage{
fs: fs,
retentionEpochs: params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest,
retentionEpochs: params.BeaconConfig().MinEpochsForBlobsSidecarsRequest,
lastPrunedEpoch: firstPruneEpoch,
}
for _, o := range opts {

View File

@@ -18,7 +18,7 @@ func NewEphemeralBlobStorage(_ testing.TB) *BlobStorage {
// in order to interact with it outside the parameters of the BlobStorage api.
func NewEphemeralBlobStorageWithFs(_ testing.TB) (afero.Fs, *BlobStorage, error) {
fs := afero.NewMemMapFs()
retentionEpoch := params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
retentionEpoch := params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
return fs, &BlobStorage{fs: fs, retentionEpochs: retentionEpoch}, nil
}

View File

@@ -205,7 +205,7 @@ func TestStore_BlobSidecars(t *testing.T) {
require.NoError(t, equalBlobSlices(scs, got))
newScs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
newRetentionSlot := primitives.Slot(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
newRetentionSlot := primitives.Slot(params.BeaconConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
for _, sc := range newScs {
sc.Slot = sc.Slot + newRetentionSlot
}
@@ -229,7 +229,7 @@ func TestStore_BlobSidecars(t *testing.T) {
require.NoError(t, equalBlobSlices(scs, got))
scs = generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
newRetentionSlot := primitives.Slot(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
newRetentionSlot := primitives.Slot(params.BeaconConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
for _, sc := range scs {
sc.Slot = sc.Slot + newRetentionSlot
}
@@ -255,7 +255,7 @@ func TestStore_BlobSidecars(t *testing.T) {
require.NoError(t, equalBlobSlices(scs, got))
scs = generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
newRetentionSlot := primitives.Slot(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
newRetentionSlot := primitives.Slot(params.BeaconConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
for _, sc := range scs {
sc.Slot = sc.Slot + newRetentionSlot
}
@@ -281,7 +281,7 @@ func TestStore_BlobSidecars(t *testing.T) {
require.NoError(t, equalBlobSlices(scs, got))
scs = generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
newRetentionSlot := primitives.Slot(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
newRetentionSlot := primitives.Slot(params.BeaconConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
for _, sc := range scs {
sc.Slot = sc.Slot + newRetentionSlot
}

View File

@@ -223,7 +223,7 @@ func NewKVStore(ctx context.Context, dirPath string, opts ...KVStoreOption) (*St
// set a default so that tests don't break
if kv.blobRetentionEpochs == 0 {
kv.blobRetentionEpochs = params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
kv.blobRetentionEpochs = params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
}
return kv, nil
}

View File

@@ -16,7 +16,7 @@ import (
// setupDB instantiates and returns a Store instance.
func setupDB(t testing.TB) *Store {
opt := WithBlobRetentionEpochs(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest)
opt := WithBlobRetentionEpochs(params.BeaconConfig().MinEpochsForBlobsSidecarsRequest)
db, err := NewKVStore(context.Background(), t.TempDir(), opt)
require.NoError(t, err, "Failed to instantiate DB")
t.Cleanup(func() {

View File

@@ -163,7 +163,7 @@ func (b *BlobSidecarsByRootReq) MarshalSSZ() ([]byte, error) {
// BlobSidecarsByRootReq value.
func (b *BlobSidecarsByRootReq) UnmarshalSSZ(buf []byte) error {
bufLen := len(buf)
maxLength := int(params.BeaconNetworkConfig().MaxRequestBlobSidecars) * blobIdSize
maxLength := int(params.BeaconConfig().MaxRequestBlobSidecars) * blobIdSize
if bufLen > maxLength {
return errors.Errorf("expected buffer with length of up to %d but received length %d", maxLength, bufLen)
}

View File

@@ -172,7 +172,7 @@ func TestGetSpec(t *testing.T) {
data, ok := resp.Data.(map[string]interface{})
require.Equal(t, true, ok)
assert.Equal(t, 118, len(data))
assert.Equal(t, 121, len(data))
for k, v := range data {
switch k {
case "CONFIG_NAME":
@@ -428,6 +428,12 @@ func TestGetSpec(t *testing.T) {
assert.Equal(t, "2", v)
case "EPOCHS_PER_SUBNET_SUBSCRIPTION":
assert.Equal(t, "256", v)
case "MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS":
assert.Equal(t, "4096", v)
case "MAX_REQUEST_BLOCKS_DENEB":
assert.Equal(t, "128", v)
case "MAX_REQUEST_BLOB_SIDECARS":
assert.Equal(t, "768", v)
default:
t.Errorf("Incorrect key: %s", k)
}

View File

@@ -173,11 +173,12 @@ func (r *expectedBlobChunk) requireExpected(t *testing.T, s *Service, stream net
func (c *blobsTestCase) setup(t *testing.T) (*Service, []blocks.ROBlob, func()) {
cfg := params.BeaconConfig()
repositionFutureEpochs(cfg)
undo, err := params.SetActiveWithUndo(cfg)
require.NoError(t, err)
copiedCfg := cfg.Copy()
repositionFutureEpochs(copiedCfg)
copiedCfg.InitializeForkSchedule()
params.OverrideBeaconConfig(copiedCfg)
cleanup := func() {
require.NoError(t, undo())
params.OverrideBeaconConfig(cfg)
}
maxBlobs := fieldparams.MaxBlobsPerBlock
chain, clock := defaultMockChain(t)
@@ -217,8 +218,8 @@ func (c *blobsTestCase) setup(t *testing.T) (*Service, []blocks.ROBlob, func())
rateLimiter: newRateLimiter(client),
}
byRootRate := params.BeaconNetworkConfig().MaxRequestBlobSidecars * fieldparams.MaxBlobsPerBlock
byRangeRate := params.BeaconNetworkConfig().MaxRequestBlobSidecars * fieldparams.MaxBlobsPerBlock
byRootRate := params.BeaconConfig().MaxRequestBlobSidecars * fieldparams.MaxBlobsPerBlock
byRangeRate := params.BeaconConfig().MaxRequestBlobSidecars * fieldparams.MaxBlobsPerBlock
s.setRateCollector(p2p.RPCBlobSidecarsByRootTopicV1, leakybucket.NewCollector(0.000001, int64(byRootRate), time.Second, false))
s.setRateCollector(p2p.RPCBlobSidecarsByRangeTopicV1, leakybucket.NewCollector(0.000001, int64(byRangeRate), time.Second, false))
@@ -283,7 +284,7 @@ func defaultMockChain(t *testing.T) (*mock.ChainService, *startup.Clock) {
de := params.BeaconConfig().DenebForkEpoch
df, err := forks.Fork(de)
require.NoError(t, err)
denebBuffer := params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest + 1000
denebBuffer := params.BeaconConfig().MinEpochsForBlobsSidecarsRequest + 1000
ce := de + denebBuffer
fe := ce - 2
cs, err := slots.EpochStart(ce)

View File

@@ -99,7 +99,7 @@ func (s *Service) blobSidecarsByRangeRPCHandler(ctx context.Context, msg interfa
}
var batch blockBatch
wQuota := params.BeaconNetworkConfig().MaxRequestBlobSidecars
wQuota := params.BeaconConfig().MaxRequestBlobSidecars
for batch, ok = batcher.next(ctx, stream); ok; batch, ok = batcher.next(ctx, stream) {
batchStart := time.Now()
wQuota, err = s.streamBlobBatch(ctx, batch, wQuota, stream)
@@ -131,7 +131,7 @@ func BlobsByRangeMinStartSlot(current primitives.Slot) (primitives.Slot, error)
if params.BeaconConfig().DenebForkEpoch == math.MaxUint64 {
return primitives.Slot(math.MaxUint64), nil
}
minReqEpochs := params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
minReqEpochs := params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
currEpoch := slots.ToEpoch(current)
minStart := params.BeaconConfig().DenebForkEpoch
if currEpoch > minReqEpochs && currEpoch-minReqEpochs > minStart {

View File

@@ -15,7 +15,7 @@ import (
func (c *blobsTestCase) defaultOldestSlotByRange(t *testing.T) types.Slot {
currentEpoch := slots.ToEpoch(c.chain.CurrentSlot())
oldestEpoch := currentEpoch - params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
oldestEpoch := currentEpoch - params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
if oldestEpoch < params.BeaconConfig().DenebForkEpoch {
oldestEpoch = params.BeaconConfig().DenebForkEpoch
}
@@ -54,7 +54,7 @@ func (c *blobsTestCase) filterExpectedByRange(t *testing.T, scs []blocks.ROBlob,
if sc.Slot() < rreq.StartSlot || sc.Slot() > rreq.StartSlot+types.Slot(rreq.Count)-1 {
continue
}
if writes == params.BeaconNetworkConfig().MaxRequestBlobSidecars {
if writes == params.BeaconConfig().MaxRequestBlobSidecars {
continue
}
expect = append(expect, &expectedBlobChunk{
@@ -90,15 +90,15 @@ func (c *blobsTestCase) runTestBlobSidecarsByRange(t *testing.T) {
}
func TestBlobByRangeOK(t *testing.T) {
origNC := params.BeaconNetworkConfig()
origNC := params.BeaconConfig()
// restore network config after test completes
defer func() {
params.OverrideBeaconNetworkConfig(origNC)
params.OverrideBeaconConfig(origNC)
}()
// set MaxRequestBlobSidecars to a low-ish value so the test doesn't timeout.
nc := params.BeaconNetworkConfig().Copy()
nc := params.BeaconConfig().Copy()
nc.MaxRequestBlobSidecars = 100
params.OverrideBeaconNetworkConfig(nc)
params.OverrideBeaconConfig(nc)
cases := []*blobsTestCase{
{
@@ -139,14 +139,14 @@ func TestBlobByRangeOK(t *testing.T) {
},
{
name: "when request count > MAX_REQUEST_BLOCKS_DENEB, MAX_REQUEST_BLOBS_SIDECARS sidecars in response",
nblocks: int(params.BeaconNetworkConfig().MaxRequestBlocksDeneb) + 10,
nblocks: int(params.BeaconConfig().MaxRequestBlocksDeneb) + 10,
requestFromSidecars: func(scs []blocks.ROBlob) interface{} {
return &ethpb.BlobSidecarsByRangeRequest{
StartSlot: scs[0].Slot(),
Count: params.BeaconNetworkConfig().MaxRequestBlocksDeneb + 1,
Count: params.BeaconConfig().MaxRequestBlocksDeneb + 1,
}
},
total: func() *int { x := int(params.BeaconNetworkConfig().MaxRequestBlobSidecars); return &x }(),
total: func() *int { x := int(params.BeaconConfig().MaxRequestBlobSidecars); return &x }(),
},
}
for _, c := range cases {
@@ -167,7 +167,7 @@ func TestBlobsByRangeValidation(t *testing.T) {
denebSlot, err := slots.EpochStart(params.BeaconConfig().DenebForkEpoch)
require.NoError(t, err)
minReqEpochs := params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
minReqEpochs := params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
minReqSlots, err := slots.EpochStart(minReqEpochs)
require.NoError(t, err)
// spec criteria for mix,max bound checking

View File

@@ -23,8 +23,8 @@ func blobMinReqEpoch(finalized, current primitives.Epoch) primitives.Epoch {
// max(finalized_epoch, current_epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS, DENEB_FORK_EPOCH)
denebFork := params.BeaconConfig().DenebForkEpoch
var reqWindow primitives.Epoch
if current > params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest {
reqWindow = current - params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
if current > params.BeaconConfig().MinEpochsForBlobsSidecarsRequest {
reqWindow = current - params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
}
if finalized >= reqWindow && finalized > denebFork {
return finalized
@@ -109,7 +109,7 @@ func (s *Service) blobSidecarByRootRPCHandler(ctx context.Context, msg interface
}
func validateBlobByRootRequest(blobIdents types.BlobSidecarsByRootReq) error {
if uint64(len(blobIdents)) > params.BeaconNetworkConfig().MaxRequestBlobSidecars {
if uint64(len(blobIdents)) > params.BeaconConfig().MaxRequestBlobSidecars {
return types.ErrMaxBlobReqExceeded
}
return nil

View File

@@ -39,7 +39,7 @@ func (c *blobsTestCase) filterExpectedByRoot(t *testing.T, scs []blocks.ROBlob,
panic("unexpected request type in filterExpectedByRoot")
}
req := *rp
if uint64(len(req)) > params.BeaconNetworkConfig().MaxRequestBlobSidecars {
if uint64(len(req)) > params.BeaconConfig().MaxRequestBlobSidecars {
return []*expectedBlobChunk{{
code: responseCodeInvalidRequest,
message: p2pTypes.ErrBlobLTMinRequest.Error(),
@@ -169,7 +169,7 @@ func readChunkEncodedBlobsAsStreamReader(t *testing.T, s *Service, expect []*exp
return nil
}
return func(stream network.Stream) {
scs, err := readChunkEncodedBlobs(stream, encoding, ctxMap, vf, params.BeaconNetworkConfig().MaxRequestBlobSidecars)
scs, err := readChunkEncodedBlobs(stream, encoding, ctxMap, vf, params.BeaconConfig().MaxRequestBlobSidecars)
require.NoError(t, err)
require.Equal(t, len(expect), len(scs))
for i, sc := range scs {
@@ -227,7 +227,7 @@ func TestBlobsByRootValidation(t *testing.T) {
},
{
name: "exceeds req max",
nblocks: int(params.BeaconNetworkConfig().MaxRequestBlobSidecars) + 1,
nblocks: int(params.BeaconConfig().MaxRequestBlobSidecars) + 1,
err: p2pTypes.ErrMaxBlobReqExceeded,
},
}
@@ -261,7 +261,7 @@ func TestBlobsByRootOK(t *testing.T) {
}
func TestBlobsByRootMinReqEpoch(t *testing.T) {
winMin := params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
winMin := params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
cases := []struct {
name string
finalized types.Epoch

View File

@@ -163,7 +163,7 @@ func SendBlobsByRangeRequest(ctx context.Context, tor blockchain.TemporalOracle,
}
defer closeStream(stream, log)
max := params.BeaconNetworkConfig().MaxRequestBlobSidecars
max := params.BeaconConfig().MaxRequestBlobSidecars
if max > req.Count*fieldparams.MaxBlobsPerBlock {
max = req.Count * fieldparams.MaxBlobsPerBlock
}
@@ -174,7 +174,7 @@ func SendBlobSidecarByRoot(
ctx context.Context, tor blockchain.TemporalOracle, p2pApi p2p.P2P, pid peer.ID,
ctxMap ContextByteVersions, req *p2ptypes.BlobSidecarsByRootReq,
) ([]blocks.ROBlob, error) {
if uint64(len(*req)) > params.BeaconNetworkConfig().MaxRequestBlobSidecars {
if uint64(len(*req)) > params.BeaconConfig().MaxRequestBlobSidecars {
return nil, errors.Wrapf(p2ptypes.ErrMaxBlobReqExceeded, "length=%d", len(*req))
}
@@ -189,7 +189,7 @@ func SendBlobSidecarByRoot(
}
defer closeStream(stream, log)
max := params.BeaconNetworkConfig().MaxRequestBlobSidecars
max := params.BeaconConfig().MaxRequestBlobSidecars
if max > uint64(len(*req))*fieldparams.MaxBlobsPerBlock {
max = uint64(len(*req)) * fieldparams.MaxBlobsPerBlock
}

View File

@@ -21,7 +21,7 @@ var (
BlobRetentionEpochFlag = &cli.Uint64Flag{
Name: "blob-retention-epochs",
Usage: "Override the default blob retention period (measured in epochs). The node will exit with an error at startup if the value is less than the default of 4096 epochs.",
Value: uint64(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest),
Value: uint64(params.BeaconConfig().MinEpochsForBlobsSidecarsRequest),
Aliases: []string{"extend-blob-retention-epoch"},
}
)
@@ -57,14 +57,14 @@ var errInvalidBlobRetentionEpochs = errors.New("value is smaller than spec minim
// or a user-specified flag overriding this value. If a user-specified override is
// smaller than the spec default, an error will be returned.
func blobRetentionEpoch(cliCtx *cli.Context) (primitives.Epoch, error) {
spec := params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
spec := params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
if !cliCtx.IsSet(BlobRetentionEpochFlag.Name) {
return spec, nil
}
re := primitives.Epoch(cliCtx.Uint64(BlobRetentionEpochFlag.Name))
// Validate the epoch value against the spec default.
if re < params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest {
if re < params.BeaconConfig().MinEpochsForBlobsSidecarsRequest {
return spec, errors.Wrapf(errInvalidBlobRetentionEpochs, "%s=%d, spec=%d", BlobRetentionEpochFlag.Name, re, spec)
}

View File

@@ -35,7 +35,7 @@ func TestBlobStoragePath_FlagSpecified(t *testing.T) {
func TestConfigureBlobRetentionEpoch(t *testing.T) {
params.SetupTestConfigCleanup(t)
specMinEpochs := params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest
specMinEpochs := params.BeaconConfig().MinEpochsForBlobsSidecarsRequest
app := cli.App{}
set := flag.NewFlagSet("test", 0)
cliCtx := cli.NewContext(&app, set, nil)

View File

@@ -224,7 +224,10 @@ type BeaconChainConfig struct {
BlobsidecarSubnetCount uint64 `yaml:"BLOB_SIDECAR_SUBNET_COUNT"` // BlobsidecarSubnetCount is the number of blobsidecar subnets used in the gossipsub protocol.
// Values introduced in Deneb hard fork
MaxPerEpochActivationChurnLimit uint64 `yaml:"MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT" spec:"true"` // MaxPerEpochActivationChurnLimit is the maximum amount of churn allotted for validator activation.
MaxPerEpochActivationChurnLimit uint64 `yaml:"MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT" spec:"true"` // MaxPerEpochActivationChurnLimit is the maximum amount of churn allotted for validator activation.
MinEpochsForBlobsSidecarsRequest primitives.Epoch `yaml:"MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS" spec:"true"` // MinEpochsForBlobsSidecarsRequest is the minimum number of epochs the node will keep the blobs for.
MaxRequestBlobSidecars uint64 `yaml:"MAX_REQUEST_BLOB_SIDECARS" spec:"true"` // MaxRequestBlobSidecars is the maximum number of blobs to request in a single request.
MaxRequestBlocksDeneb uint64 `yaml:"MAX_REQUEST_BLOCKS_DENEB" spec:"true"` // MaxRequestBlocksDeneb is the maximum number of blocks in a single request after the deneb epoch.
// Values related to the new subnet backbone
EpochsPerSubnetSubscription uint64 `yaml:"EPOCHS_PER_SUBNET_SUBSCRIPTION" spec:"true"` // EpochsPerSubnetSubscription specifies the minimum duration a validator is connected to their subnet.
@@ -301,5 +304,5 @@ func DenebEnabled() bool {
// WithinDAPeriod checks if the block epoch is within MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS of the given current epoch.
func WithinDAPeriod(block, current primitives.Epoch) bool {
return block+BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest >= current
return block+BeaconConfig().MinEpochsForBlobsSidecarsRequest >= current
}

View File

@@ -64,7 +64,7 @@ func TestConfig_WithinDAPeriod(t *testing.T) {
{
name: "before",
block: 0,
current: params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest + 1,
current: params.BeaconConfig().MinEpochsForBlobsSidecarsRequest + 1,
within: false,
},
{
@@ -76,13 +76,13 @@ func TestConfig_WithinDAPeriod(t *testing.T) {
{
name: "boundary",
block: 0,
current: params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest,
current: params.BeaconConfig().MinEpochsForBlobsSidecarsRequest,
within: true,
},
{
name: "one less",
block: params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest - 1,
current: params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest,
block: params.BeaconConfig().MinEpochsForBlobsSidecarsRequest - 1,
current: params.BeaconConfig().MinEpochsForBlobsSidecarsRequest,
within: true,
},
}

View File

@@ -207,6 +207,11 @@ func ConfigToYaml(cfg *BeaconChainConfig) []byte {
fmt.Sprintf("TERMINAL_BLOCK_HASH: %#x", cfg.TerminalBlockHash),
fmt.Sprintf("TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: %d", cfg.TerminalBlockHashActivationEpoch),
fmt.Sprintf("DEPOSIT_CONTRACT_ADDRESS: %s", cfg.DepositContractAddress),
fmt.Sprintf("MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: %d", cfg.MaxPerEpochActivationChurnLimit),
fmt.Sprintf("MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: %d", cfg.MinEpochsForBlobsSidecarsRequest),
fmt.Sprintf("MAX_REQUEST_BLOCKS_DENEB: %d", cfg.MaxRequestBlocksDeneb),
fmt.Sprintf("MAX_REQUEST_BLOB_SIDECARS: %d", cfg.MaxRequestBlobSidecars),
fmt.Sprintf("BLOB_SIDECAR_SUBNET_COUNT: %d", cfg.BlobsidecarSubnetCount),
fmt.Sprintf("DENEB_FORK_EPOCH: %d", cfg.DenebForkEpoch),
fmt.Sprintf("DENEB_FORK_VERSION: %#x", cfg.DenebForkVersion),
fmt.Sprintf("EPOCHS_PER_SUBNET_SUBSCRIPTION: %d", cfg.EpochsPerSubnetSubscription),
@@ -236,9 +241,6 @@ func NetworkConfigToYaml(cfg *NetworkConfig) []byte {
fmt.Sprintf("MAXIMUM_GOSSIP_CLOCK_DISPARITY: %d", int(cfg.MaximumGossipClockDisparity.Seconds())),
fmt.Sprintf("MESSAGE_DOMAIN_INVALID_SNAPPY: %#x", cfg.MessageDomainInvalidSnappy),
fmt.Sprintf("MESSAGE_DOMAIN_VALID_SNAPPY: %#x", cfg.MessageDomainValidSnappy),
fmt.Sprintf("MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUEST: %d", cfg.MinEpochsForBlobsSidecarsRequest),
fmt.Sprintf("MAX_REQUEST_BLOB_SIDECARS: %d", cfg.MaxRequestBlobSidecars),
fmt.Sprintf("MAX_REQUEST_BLOCKS_DENEB: %d", cfg.MaxRequestBlocksDeneb),
}
yamlFile := []byte(strings.Join(lines, "\n"))

View File

@@ -33,12 +33,9 @@ var placeholderFields = []string{
"MAXIMUM_GOSSIP_CLOCK_DISPARITY",
"MAX_BLOBS_PER_BLOCK",
"MAX_CHUNK_SIZE",
"MAX_REQUEST_BLOB_SIDECARS",
"MAX_REQUEST_BLOCKS",
"MAX_REQUEST_BLOCKS_DENEB",
"MESSAGE_DOMAIN_INVALID_SNAPPY",
"MESSAGE_DOMAIN_VALID_SNAPPY",
"MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS",
"MIN_EPOCHS_FOR_BLOCK_REQUESTS",
"REORG_HEAD_WEIGHT_THRESHOLD",
"RESP_TIMEOUT",

View File

@@ -27,26 +27,23 @@ const (
)
var mainnetNetworkConfig = &NetworkConfig{
GossipMaxSize: 1 << 20, // 1 MiB
GossipMaxSizeBellatrix: 10 * 1 << 20, // 10 MiB
MaxChunkSize: 1 << 20, // 1 MiB
MaxChunkSizeBellatrix: 10 * 1 << 20, // 10 MiB
AttestationSubnetCount: 64,
AttestationPropagationSlotRange: 32,
MaxRequestBlocks: 1 << 10, // 1024
TtfbTimeout: 5 * time.Second,
RespTimeout: 10 * time.Second,
MaximumGossipClockDisparity: 500 * time.Millisecond,
MessageDomainInvalidSnappy: [4]byte{00, 00, 00, 00},
MessageDomainValidSnappy: [4]byte{01, 00, 00, 00},
ETH2Key: "eth2",
AttSubnetKey: "attnets",
SyncCommsSubnetKey: "syncnets",
MinimumPeersInSubnetSearch: 20,
ContractDeploymentBlock: 11184524, // Note: contract was deployed in block 11052984 but no transactions were sent until 11184524.
MinEpochsForBlobsSidecarsRequest: 4096,
MaxRequestBlobSidecars: 768,
MaxRequestBlocksDeneb: 128,
GossipMaxSize: 1 << 20, // 1 MiB
GossipMaxSizeBellatrix: 10 * 1 << 20, // 10 MiB
MaxChunkSize: 1 << 20, // 1 MiB
MaxChunkSizeBellatrix: 10 * 1 << 20, // 10 MiB
AttestationSubnetCount: 64,
AttestationPropagationSlotRange: 32,
MaxRequestBlocks: 1 << 10, // 1024
TtfbTimeout: 5 * time.Second,
RespTimeout: 10 * time.Second,
MaximumGossipClockDisparity: 500 * time.Millisecond,
MessageDomainInvalidSnappy: [4]byte{00, 00, 00, 00},
MessageDomainValidSnappy: [4]byte{01, 00, 00, 00},
ETH2Key: "eth2",
AttSubnetKey: "attnets",
SyncCommsSubnetKey: "syncnets",
MinimumPeersInSubnetSearch: 20,
ContractDeploymentBlock: 11184524, // Note: contract was deployed in block 11052984 but no transactions were sent until 11184524.
BootstrapNodes: []string{
// Teku team's bootnode
"enr:-KG4QMOEswP62yzDjSwWS4YEjtTZ5PO6r65CPqYBkgTTkrpaedQ8uEUo1uMALtJIvb2w_WWEVmg5yt1UAuK1ftxUU7QDhGV0aDKQu6TalgMAAAD__________4JpZIJ2NIJpcIQEnfA2iXNlY3AyNTZrMaEDfol8oLr6XJ7FsdAYE7lpJhKMls4G_v6qQOGKJUWGb_uDdGNwgiMog3VkcIIjKA",
@@ -273,7 +270,10 @@ var mainnetBeaconConfig = &BeaconChainConfig{
// Subnet value
BlobsidecarSubnetCount: 6,
MaxPerEpochActivationChurnLimit: 8,
MaxPerEpochActivationChurnLimit: 8,
MinEpochsForBlobsSidecarsRequest: 4096,
MaxRequestBlobSidecars: 768,
MaxRequestBlocksDeneb: 128,
// Values related to the new subnet backbone
EpochsPerSubnetSubscription: 256,

View File

@@ -18,7 +18,7 @@ func TestMaxRequestBlock(t *testing.T) {
},
{
epoch: primitives.Epoch(mainnetDenebForkEpoch),
expectedMaxBlock: mainnetNetworkConfig.MaxRequestBlocksDeneb,
expectedMaxBlock: mainnetBeaconConfig.MaxRequestBlocksDeneb,
},
}

View File

@@ -9,21 +9,18 @@ import (
// NetworkConfig defines the spec based network parameters.
type NetworkConfig struct {
GossipMaxSize uint64 `yaml:"GOSSIP_MAX_SIZE"` // GossipMaxSize is the maximum allowed size of uncompressed gossip messages.
GossipMaxSizeBellatrix uint64 `yaml:"GOSSIP_MAX_SIZE_BELLATRIX"` // GossipMaxSizeBellatrix is the maximum allowed size of uncompressed gossip messages after the bellatrix epoch.
MaxChunkSize uint64 `yaml:"MAX_CHUNK_SIZE"` // MaxChunkSize is the maximum allowed size of uncompressed req/resp chunked responses.
MaxChunkSizeBellatrix uint64 `yaml:"MAX_CHUNK_SIZE_BELLATRIX"` // MaxChunkSizeBellatrix is the maximum allowed size of uncompressed req/resp chunked responses after the bellatrix epoch.
AttestationSubnetCount uint64 `yaml:"ATTESTATION_SUBNET_COUNT"` // AttestationSubnetCount is the number of attestation subnets used in the gossipsub protocol.
AttestationPropagationSlotRange primitives.Slot `yaml:"ATTESTATION_PROPAGATION_SLOT_RANGE"` // AttestationPropagationSlotRange is the maximum number of slots during which an attestation can be propagated.
MaxRequestBlocks uint64 `yaml:"MAX_REQUEST_BLOCKS"` // MaxRequestBlocks is the maximum number of blocks in a single request.
TtfbTimeout time.Duration `yaml:"TTFB_TIMEOUT"` // TtfbTimeout is the maximum time to wait for first byte of request response (time-to-first-byte).
RespTimeout time.Duration `yaml:"RESP_TIMEOUT"` // RespTimeout is the maximum time for complete response transfer.
MaximumGossipClockDisparity time.Duration `yaml:"MAXIMUM_GOSSIP_CLOCK_DISPARITY"` // MaximumGossipClockDisparity is the maximum milliseconds of clock disparity assumed between honest nodes.
MessageDomainInvalidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_INVALID_SNAPPY"` // MessageDomainInvalidSnappy is the 4-byte domain for gossip message-id isolation of invalid snappy messages.
MessageDomainValidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_VALID_SNAPPY"` // MessageDomainValidSnappy is the 4-byte domain for gossip message-id isolation of valid snappy messages.
MinEpochsForBlobsSidecarsRequest primitives.Epoch `yaml:"MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUEST"` // MinEpochsForBlobsSidecarsRequest is the minimum number of epochs the node will keep the blobs for.
MaxRequestBlobSidecars uint64 `yaml:"MAX_REQUEST_BLOB_SIDECARS"` // MaxRequestBlobSidecars is the maximum number of blobs to request in a single request.
MaxRequestBlocksDeneb uint64 `yaml:"MAX_REQUEST_BLOCKS_DENEB"` // MaxRequestBlocksDeneb is the maximum number of blocks in a single request after the deneb epoch.
GossipMaxSize uint64 `yaml:"GOSSIP_MAX_SIZE"` // GossipMaxSize is the maximum allowed size of uncompressed gossip messages.
GossipMaxSizeBellatrix uint64 `yaml:"GOSSIP_MAX_SIZE_BELLATRIX"` // GossipMaxSizeBellatrix is the maximum allowed size of uncompressed gossip messages after the bellatrix epoch.
MaxChunkSize uint64 `yaml:"MAX_CHUNK_SIZE"` // MaxChunkSize is the maximum allowed size of uncompressed req/resp chunked responses.
MaxChunkSizeBellatrix uint64 `yaml:"MAX_CHUNK_SIZE_BELLATRIX"` // MaxChunkSizeBellatrix is the maximum allowed size of uncompressed req/resp chunked responses after the bellatrix epoch.
AttestationSubnetCount uint64 `yaml:"ATTESTATION_SUBNET_COUNT"` // AttestationSubnetCount is the number of attestation subnets used in the gossipsub protocol.
AttestationPropagationSlotRange primitives.Slot `yaml:"ATTESTATION_PROPAGATION_SLOT_RANGE"` // AttestationPropagationSlotRange is the maximum number of slots during which an attestation can be propagated.
MaxRequestBlocks uint64 `yaml:"MAX_REQUEST_BLOCKS"` // MaxRequestBlocks is the maximum number of blocks in a single request.
TtfbTimeout time.Duration `yaml:"TTFB_TIMEOUT"` // TtfbTimeout is the maximum time to wait for first byte of request response (time-to-first-byte).
RespTimeout time.Duration `yaml:"RESP_TIMEOUT"` // RespTimeout is the maximum time for complete response transfer.
MaximumGossipClockDisparity time.Duration `yaml:"MAXIMUM_GOSSIP_CLOCK_DISPARITY"` // MaximumGossipClockDisparity is the maximum milliseconds of clock disparity assumed between honest nodes.
MessageDomainInvalidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_INVALID_SNAPPY"` // MessageDomainInvalidSnappy is the 4-byte domain for gossip message-id isolation of invalid snappy messages.
MessageDomainValidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_VALID_SNAPPY"` // MessageDomainValidSnappy is the 4-byte domain for gossip message-id isolation of valid snappy messages.
// DiscoveryV5 Config
ETH2Key string // ETH2Key is the ENR key of the Ethereum consensus object in an enr.
@@ -64,7 +61,7 @@ func (c *NetworkConfig) Copy() *NetworkConfig {
// a special limit defined for Deneb is used.
func MaxRequestBlock(e primitives.Epoch) uint64 {
if e >= BeaconConfig().DenebForkEpoch {
return networkConfig.MaxRequestBlocksDeneb
return BeaconConfig().MaxRequestBlocksDeneb
}
return networkConfig.MaxRequestBlocks
}

View File

@@ -6,10 +6,10 @@ lighthouse_archive_name = "lighthouse-%s-x86_64-unknown-linux-gnu-portable.tar.g
def e2e_deps():
http_archive(
name = "web3signer",
urls = ["https://artifacts.consensys.net/public/web3signer/raw/names/web3signer.tar.gz/versions/23.9.1/web3signer-23.9.1.tar.gz"],
sha256 = "aec9dc745cb25fd8d7b38b06e435e3138972c2cf842dd6f851d50be7bf081629",
urls = ["https://artifacts.consensys.net/public/web3signer/raw/names/web3signer.tar.gz/versions/23.11.0/web3signer-23.11.0.tar.gz"],
sha256 = "e7643a6aa32efd859e96a82cb3ea03a294fd92c22fffeab987e5ec97500867a8",
build_file = "@prysm//testing/endtoend:web3signer.BUILD",
strip_prefix = "web3signer-23.9.1",
strip_prefix = "web3signer-23.11.0",
)
http_archive(

View File

@@ -21,7 +21,6 @@ go_library(
"//config/params:go_default_library",
"//consensus-types/primitives:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//testing/endtoend/helpers:go_default_library",
"//testing/endtoend/params:go_default_library",
"//testing/endtoend/policies:go_default_library",
"//testing/endtoend/types:go_default_library",

View File

@@ -12,7 +12,6 @@ import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers"
)
var requests = map[string]endpoint{
@@ -47,7 +46,7 @@ var requests = map[string]endpoint{
return []string{"head"}
})),
"/beacon/states/{param1}/sync_committees": newMetadata[beacon.GetSyncCommitteeResponse](v1PathTemplate,
withStart(helpers.AltairE2EForkEpoch),
withStart(params.BeaconConfig().AltairForkEpoch),
withParams(func(_ primitives.Epoch) []string {
return []string{"head"}
})),

View File

@@ -12,9 +12,9 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/validator"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/policies"
e2etypes "github.com/prysmaticlabs/prysm/v4/testing/endtoend/types"
"github.com/prysmaticlabs/prysm/v4/time/slots"
@@ -86,7 +86,7 @@ func postEvaluation(requests map[string]endpoint, epoch primitives.Epoch) error
// verify that block SSZ responses have the correct structure
blockData := requests["/beacon/blocks/{param1}"]
blindedBlockData := requests["/beacon/blinded_blocks/{param1}"]
if epoch < helpers.AltairE2EForkEpoch {
if epoch < params.BeaconConfig().AltairForkEpoch {
b := &ethpb.SignedBeaconBlock{}
if err := b.UnmarshalSSZ(blockData.getSszResp()); err != nil {
return errors.Wrap(err, msgSSZUnmarshalFailed)
@@ -95,7 +95,7 @@ func postEvaluation(requests map[string]endpoint, epoch primitives.Epoch) error
if err := bb.UnmarshalSSZ(blindedBlockData.getSszResp()); err != nil {
return errors.Wrap(err, msgSSZUnmarshalFailed)
}
} else if epoch < helpers.BellatrixE2EForkEpoch {
} else if epoch < params.BeaconConfig().BellatrixForkEpoch {
b := &ethpb.SignedBeaconBlockAltair{}
if err := b.UnmarshalSSZ(blockData.getSszResp()); err != nil {
return errors.Wrap(err, msgSSZUnmarshalFailed)
@@ -104,7 +104,7 @@ func postEvaluation(requests map[string]endpoint, epoch primitives.Epoch) error
if err := bb.UnmarshalSSZ(blindedBlockData.getSszResp()); err != nil {
return errors.Wrap(err, msgSSZUnmarshalFailed)
}
} else if epoch < helpers.CapellaE2EForkEpoch {
} else if epoch < params.BeaconConfig().CapellaForkEpoch {
b := &ethpb.SignedBeaconBlockBellatrix{}
if err := b.UnmarshalSSZ(blockData.getSszResp()); err != nil {
return errors.Wrap(err, msgSSZUnmarshalFailed)
@@ -113,7 +113,7 @@ func postEvaluation(requests map[string]endpoint, epoch primitives.Epoch) error
if err := bb.UnmarshalSSZ(blindedBlockData.getSszResp()); err != nil {
return errors.Wrap(err, msgSSZUnmarshalFailed)
}
} else if epoch < helpers.DenebE2EForkEpoch {
} else if epoch < params.BeaconConfig().DenebForkEpoch {
b := &ethpb.SignedBeaconBlockCapella{}
if err := b.UnmarshalSSZ(blockData.getSszResp()); err != nil {
return errors.Wrap(err, msgSSZUnmarshalFailed)

View File

@@ -4,9 +4,9 @@ import (
"context"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/policies"
e2etypes "github.com/prysmaticlabs/prysm/v4/testing/endtoend/types"
"github.com/prysmaticlabs/prysm/v4/time/slots"
@@ -16,8 +16,11 @@ import (
// BuilderIsActive checks that the builder is indeed producing the respective payloads
var BuilderIsActive = e2etypes.Evaluator{
Name: "builder_is_active_at_epoch_%d",
Policy: policies.OnwardsNthEpoch(helpers.BellatrixE2EForkEpoch),
Name: "builder_is_active_at_epoch_%d",
Policy: func(e primitives.Epoch) bool {
fEpoch := params.BeaconConfig().BellatrixForkEpoch
return policies.OnwardsNthEpoch(fEpoch)(e)
},
Evaluation: builderActive,
}
@@ -36,8 +39,8 @@ func builderActive(_ *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) err
lowestBound = currEpoch - 1
}
if lowestBound < helpers.BellatrixE2EForkEpoch {
lowestBound = helpers.BellatrixE2EForkEpoch
if lowestBound < params.BeaconConfig().BellatrixForkEpoch {
lowestBound = params.BeaconConfig().BellatrixForkEpoch
}
blockCtrs, err := beaconClient.ListBeaconBlocks(context.Background(), &ethpb.ListBlocksRequest{QueryFilter: &ethpb.ListBlocksRequest_Epoch{Epoch: lowestBound}})
if err != nil {
@@ -52,7 +55,7 @@ func builderActive(_ *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) err
if b.IsNil() {
return errors.New("nil block provided")
}
forkStartSlot, err := slots.EpochStart(helpers.BellatrixE2EForkEpoch)
forkStartSlot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
if err != nil {
return err
}
@@ -86,7 +89,7 @@ func builderActive(_ *e2etypes.EvaluationContext, conns ...*grpc.ClientConn) err
if b.IsNil() {
return errors.New("nil block provided")
}
forkStartSlot, err := slots.EpochStart(helpers.BellatrixE2EForkEpoch)
forkStartSlot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
if err != nil {
return err
}

View File

@@ -11,10 +11,10 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/runtime/interop"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/components"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers"
e2e "github.com/prysmaticlabs/prysm/v4/testing/endtoend/params"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/policies"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/types"
@@ -24,8 +24,11 @@ import (
)
var FeeRecipientIsPresent = types.Evaluator{
Name: "fee_recipient_is_present_%d",
Policy: policies.AfterNthEpoch(helpers.BellatrixE2EForkEpoch),
Name: "fee_recipient_is_present_%d",
Policy: func(e primitives.Epoch) bool {
fEpoch := params.BeaconConfig().BellatrixForkEpoch
return policies.AfterNthEpoch(fEpoch)(e)
},
Evaluation: feeRecipientIsPresent,
}

View File

@@ -5,11 +5,11 @@ import (
"time"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/runtime/version"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/policies"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/types"
"github.com/prysmaticlabs/prysm/v4/time/slots"
@@ -23,7 +23,7 @@ var startingFork = version.Phase0
var AltairForkTransition = types.Evaluator{
Name: "altair_fork_transition_%d",
Policy: func(e primitives.Epoch) bool {
altair := policies.OnEpoch(helpers.AltairE2EForkEpoch)
altair := policies.OnEpoch(params.BeaconConfig().AltairForkEpoch)
// TODO (11750): modify policies to take an end to end config
if startingFork == version.Phase0 {
return altair(e)
@@ -35,21 +35,30 @@ var AltairForkTransition = types.Evaluator{
// BellatrixForkTransition ensures that the Bellatrix hard fork has occurred successfully.
var BellatrixForkTransition = types.Evaluator{
Name: "bellatrix_fork_transition_%d",
Policy: policies.OnEpoch(helpers.BellatrixE2EForkEpoch),
Name: "bellatrix_fork_transition_%d",
Policy: func(e primitives.Epoch) bool {
fEpoch := params.BeaconConfig().BellatrixForkEpoch
return policies.OnEpoch(fEpoch)(e)
},
Evaluation: bellatrixForkOccurs,
}
// CapellaForkTransition ensures that the Capella hard fork has occurred successfully.
var CapellaForkTransition = types.Evaluator{
Name: "capella_fork_transition_%d",
Policy: policies.OnEpoch(helpers.CapellaE2EForkEpoch),
Name: "capella_fork_transition_%d",
Policy: func(e primitives.Epoch) bool {
fEpoch := params.BeaconConfig().CapellaForkEpoch
return policies.OnEpoch(fEpoch)(e)
},
Evaluation: capellaForkOccurs,
}
var DenebForkTransition = types.Evaluator{
Name: "deneb_fork_transition_%d",
Policy: policies.OnEpoch(helpers.DenebE2EForkEpoch),
Name: "deneb_fork_transition_%d",
Policy: func(e primitives.Epoch) bool {
fEpoch := params.BeaconConfig().DenebForkEpoch
return policies.OnEpoch(fEpoch)(e)
},
Evaluation: denebForkOccurs,
}
@@ -62,7 +71,7 @@ func altairForkOccurs(_ *types.EvaluationContext, conns ...*grpc.ClientConn) err
if err != nil {
return errors.Wrap(err, "failed to get stream")
}
fSlot, err := slots.EpochStart(helpers.AltairE2EForkEpoch)
fSlot, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
if err != nil {
return err
}
@@ -104,7 +113,7 @@ func bellatrixForkOccurs(_ *types.EvaluationContext, conns ...*grpc.ClientConn)
if err != nil {
return errors.Wrap(err, "failed to get stream")
}
fSlot, err := slots.EpochStart(helpers.BellatrixE2EForkEpoch)
fSlot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
if err != nil {
return err
}
@@ -149,7 +158,7 @@ func capellaForkOccurs(_ *types.EvaluationContext, conns ...*grpc.ClientConn) er
if err != nil {
return errors.Wrap(err, "failed to get stream")
}
fSlot, err := slots.EpochStart(helpers.CapellaE2EForkEpoch)
fSlot, err := slots.EpochStart(params.BeaconConfig().CapellaForkEpoch)
if err != nil {
return err
}
@@ -192,7 +201,7 @@ func denebForkOccurs(_ *types.EvaluationContext, conns ...*grpc.ClientConn) erro
if err != nil {
return errors.Wrap(err, "failed to get stream")
}
fSlot, err := slots.EpochStart(helpers.DenebE2EForkEpoch)
fSlot, err := slots.EpochStart(params.BeaconConfig().DenebForkEpoch)
if err != nil {
return err
}

View File

@@ -85,8 +85,11 @@ var ValidatorsHaveExited = e2etypes.Evaluator{
// SubmitWithdrawal sends a withdrawal from a previously exited validator.
var SubmitWithdrawal = e2etypes.Evaluator{
Name: "submit_withdrawal_epoch_%d",
Policy: policies.BetweenEpochs(helpers.CapellaE2EForkEpoch-2, helpers.CapellaE2EForkEpoch+1),
Name: "submit_withdrawal_epoch_%d",
Policy: func(currentEpoch primitives.Epoch) bool {
fEpoch := params.BeaconConfig().CapellaForkEpoch
return policies.BetweenEpochs(fEpoch-2, fEpoch+1)(currentEpoch)
},
Evaluation: submitWithdrawal,
}
@@ -99,7 +102,7 @@ var ValidatorsHaveWithdrawn = e2etypes.Evaluator{
return false
}
// Only run this for minimal setups after capella
validWithdrawnEpoch := primitives.Epoch(helpers.CapellaE2EForkEpoch + 1)
validWithdrawnEpoch := params.BeaconConfig().CapellaForkEpoch + 1
requiredPolicy := policies.OnEpoch(validWithdrawnEpoch)
return requiredPolicy(currentEpoch)

View File

@@ -19,7 +19,6 @@ import (
"github.com/prysmaticlabs/prysm/v4/network/httputil"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/runtime/version"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers"
e2eparams "github.com/prysmaticlabs/prysm/v4/testing/endtoend/params"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/policies"
"github.com/prysmaticlabs/prysm/v4/testing/endtoend/types"
@@ -53,8 +52,11 @@ var ValidatorsParticipatingAtEpoch = func(epoch primitives.Epoch) types.Evaluato
// ValidatorSyncParticipation ensures the expected amount of sync committee participants
// are active.
var ValidatorSyncParticipation = types.Evaluator{
Name: "validator_sync_participation_%d",
Policy: policies.OnwardsNthEpoch(helpers.AltairE2EForkEpoch),
Name: "validator_sync_participation_%d",
Policy: func(e primitives.Epoch) bool {
fEpoch := params.BeaconConfig().AltairForkEpoch
return policies.OnwardsNthEpoch(fEpoch)(e)
},
Evaluation: validatorsSyncParticipation,
}
@@ -125,7 +127,7 @@ func validatorsParticipating(_ *types.EvaluationContext, conns ...*grpc.ClientCo
if e2eparams.TestParams.LighthouseBeaconNodeCount != 0 {
expected = float32(expectedMulticlientParticipation)
}
if participation.Epoch > 0 && participation.Epoch.Sub(1) == helpers.BellatrixE2EForkEpoch {
if participation.Epoch > 0 && participation.Epoch.Sub(1) == params.BeaconConfig().BellatrixForkEpoch {
// Reduce Participation requirement to 95% to account for longer EE calls for
// the merge block. Target and head will likely be missed for a few validators at
// slot 0.
@@ -219,8 +221,8 @@ func validatorsSyncParticipation(_ *types.EvaluationContext, conns ...*grpc.Clie
lowestBound = currEpoch - 1
}
if lowestBound < helpers.AltairE2EForkEpoch {
lowestBound = helpers.AltairE2EForkEpoch
if lowestBound < params.BeaconConfig().AltairForkEpoch {
lowestBound = params.BeaconConfig().AltairForkEpoch
}
blockCtrs, err := altairClient.ListBeaconBlocks(context.Background(), &ethpb.ListBlocksRequest{QueryFilter: &ethpb.ListBlocksRequest_Epoch{Epoch: lowestBound}})
if err != nil {
@@ -235,7 +237,7 @@ func validatorsSyncParticipation(_ *types.EvaluationContext, conns ...*grpc.Clie
if b.IsNil() {
return errors.New("nil block provided")
}
forkStartSlot, err := slots.EpochStart(helpers.AltairE2EForkEpoch)
forkStartSlot, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
if err != nil {
return err
}
@@ -245,7 +247,7 @@ func validatorsSyncParticipation(_ *types.EvaluationContext, conns ...*grpc.Clie
}
expectedParticipation := expectedSyncParticipation
switch slots.ToEpoch(b.Block().Slot()) {
case helpers.AltairE2EForkEpoch:
case params.BeaconConfig().AltairForkEpoch:
// Drop expected sync participation figure.
expectedParticipation = 0.90
default:
@@ -276,11 +278,11 @@ func validatorsSyncParticipation(_ *types.EvaluationContext, conns ...*grpc.Clie
if b.IsNil() {
return errors.New("nil block provided")
}
forkSlot, err := slots.EpochStart(helpers.AltairE2EForkEpoch)
forkSlot, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
if err != nil {
return err
}
nexForkSlot, err := slots.EpochStart(helpers.BellatrixE2EForkEpoch)
nexForkSlot, err := slots.EpochStart(params.BeaconConfig().BellatrixForkEpoch)
if err != nil {
return err
}

View File

@@ -31,16 +31,12 @@ import (
)
const (
maxPollingWaitTime = 60 * time.Second // A minute so timing out doesn't take very long.
filePollingInterval = 500 * time.Millisecond
memoryHeapFileName = "node_heap_%d.pb.gz"
cpuProfileFileName = "node_cpu_profile_%d.pb.gz"
fileBufferSize = 64 * 1024
maxFileBufferSize = 1024 * 1024
AltairE2EForkEpoch = params.AltairE2EForkEpoch
BellatrixE2EForkEpoch = params.BellatrixE2EForkEpoch
CapellaE2EForkEpoch = params.CapellaE2EForkEpoch
DenebE2EForkEpoch = params.DenebE2EForkEpoch
maxPollingWaitTime = 60 * time.Second // A minute so timing out doesn't take very long.
filePollingInterval = 500 * time.Millisecond
memoryHeapFileName = "node_heap_%d.pb.gz"
cpuProfileFileName = "node_cpu_profile_%d.pb.gz"
fileBufferSize = 64 * 1024
maxFileBufferSize = 1024 * 1024
)
// Graffiti is a list of sample graffiti strings.

View File

@@ -10,7 +10,7 @@ import (
// Run mainnet e2e config with the current release validator against latest beacon node.
func TestEndToEnd_MainnetConfig_ValidatorAtCurrentRelease(t *testing.T) {
r := e2eMainnet(t, true, false, types.InitForkCfg(version.Phase0, version.Deneb, params.E2EMainnetTestConfig()))
r := e2eMainnet(t, true, false, types.InitForkCfg(version.Phase0, version.Capella, params.E2EMainnetTestConfig()))
r.run()
}

View File

@@ -9,11 +9,11 @@ import (
)
func TestEndToEnd_MinimalConfig_WithBuilder(t *testing.T) {
r := e2eMinimal(t, types.InitForkCfg(version.Phase0, version.Capella, params.E2ETestConfig()), types.WithCheckpointSync(), types.WithBuilder())
r := e2eMinimal(t, types.InitForkCfg(version.Phase0, version.Deneb, params.E2ETestConfig()), types.WithCheckpointSync(), types.WithBuilder())
r.run()
}
func TestEndToEnd_MinimalConfig_WithBuilder_ValidatorRESTApi(t *testing.T) {
r := e2eMinimal(t, types.InitForkCfg(version.Phase0, version.Capella, params.E2ETestConfig()), types.WithCheckpointSync(), types.WithBuilder(), types.WithValidatorRESTApi())
r := e2eMinimal(t, types.InitForkCfg(version.Phase0, version.Deneb, params.E2ETestConfig()), types.WithCheckpointSync(), types.WithBuilder(), types.WithValidatorRESTApi())
r.run()
}

View File

@@ -17,7 +17,7 @@ func TestEndToEnd_MultiScenarioRun(t *testing.T) {
}
func TestEndToEnd_MinimalConfig_Web3Signer(t *testing.T) {
e2eMinimal(t, types.InitForkCfg(version.Phase0, version.Capella, params.E2ETestConfig()), types.WithRemoteSigner()).run()
e2eMinimal(t, types.InitForkCfg(version.Phase0, version.Deneb, params.E2ETestConfig()), types.WithRemoteSigner()).run()
}
func TestEndToEnd_MinimalConfig_ValidatorRESTApi(t *testing.T) {

View File

@@ -50,10 +50,14 @@ const (
ForkchoiceUpdatedMethod = "engine_forkchoiceUpdatedV1"
// ForkchoiceUpdatedMethodV2 v2 request string for JSON-RPC.
ForkchoiceUpdatedMethodV2 = "engine_forkchoiceUpdatedV2"
// ForkchoiceUpdatedMethodV3 v3 request string for JSON-RPC.
ForkchoiceUpdatedMethodV3 = "engine_forkchoiceUpdatedV3"
// GetPayloadMethod v1 request string for JSON-RPC.
GetPayloadMethod = "engine_getPayloadV1"
// GetPayloadMethodV2 v2 request string for JSON-RPC.
GetPayloadMethodV2 = "engine_getPayloadV2"
// GetPayloadMethodV3 v3 request string for JSON-RPC.
GetPayloadMethodV3 = "engine_getPayloadV3"
)
var (
@@ -93,15 +97,25 @@ type ExecHeaderResponseCapella struct {
} `json:"data"`
}
type ExecHeaderResponseDeneb struct {
Version string `json:"version"`
Data struct {
Signature hexutil.Bytes `json:"signature"`
Message *builderAPI.BuilderBidDeneb `json:"message"`
} `json:"data"`
}
type Builder struct {
cfg *config
address string
execClient *gethRPC.Client
currId *v1.PayloadIDBytes
currPayload interfaces.ExecutionData
mux *gMux.Router
validatorMap map[string]*eth.ValidatorRegistrationV1
srv *http.Server
cfg *config
address string
execClient *gethRPC.Client
currId *v1.PayloadIDBytes
prevBeaconRoot []byte
currPayload interfaces.ExecutionData
blobBundle *v1.BlobsBundle
mux *gMux.Router
validatorMap map[string]*eth.ValidatorRegistrationV1
srv *http.Server
}
// New creates a proxy server forwarding requests from a consensus client to an execution client.
@@ -226,7 +240,7 @@ func (p *Builder) handleEngineCalls(req, resp []byte) {
}
p.cfg.logger.Infof("Received engine call %s", rpcObj.Method)
switch rpcObj.Method {
case ForkchoiceUpdatedMethod, ForkchoiceUpdatedMethodV2:
case ForkchoiceUpdatedMethod, ForkchoiceUpdatedMethodV2, ForkchoiceUpdatedMethodV3:
result := &ForkchoiceUpdatedResponse{}
err = json.Unmarshal(resp, result)
if err != nil {
@@ -234,6 +248,19 @@ func (p *Builder) handleEngineCalls(req, resp []byte) {
return
}
p.currId = result.Result.PayloadId
if rpcObj.Method == ForkchoiceUpdatedMethodV3 {
attr := &v1.PayloadAttributesV3{}
obj, err := json.Marshal(rpcObj.Params[1])
if err != nil {
p.cfg.logger.Errorf("Could not marshal attr: %v", err)
return
}
if err := json.Unmarshal(obj, attr); err != nil {
p.cfg.logger.Errorf("Could not unmarshal attr: %v", err)
return
}
p.prevBeaconRoot = attr.ParentBeaconBlockRoot
}
p.cfg.logger.Infof("Received payload id of %#x", result.Result.PayloadId)
}
}
@@ -279,6 +306,11 @@ func (p *Builder) handleHeaderRequest(w http.ResponseWriter, req *http.Request)
}
ax := types.Slot(slot)
currEpoch := types.Epoch(ax / params.BeaconConfig().SlotsPerEpoch)
if currEpoch >= params.BeaconConfig().DenebForkEpoch {
p.handleHeaderRequestDeneb(w)
return
}
if currEpoch >= params.BeaconConfig().CapellaForkEpoch {
p.handleHeaderRequestCapella(w)
return
@@ -439,6 +471,96 @@ func (p *Builder) handleHeaderRequestCapella(w http.ResponseWriter) {
w.WriteHeader(http.StatusOK)
}
func (p *Builder) handleHeaderRequestDeneb(w http.ResponseWriter) {
b, err := p.retrievePendingBlockDeneb()
if err != nil {
p.cfg.logger.WithError(err).Error("Could not retrieve pending block")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
secKey, err := bls.RandKey()
if err != nil {
p.cfg.logger.WithError(err).Error("Could not retrieve secret key")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
v := big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.Value))
// we set the payload value as twice its actual one so that it always chooses builder payloads vs local payloads
v = v.Mul(v, big.NewInt(2))
// Is used as the helper modifies the big.Int
weiVal := big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.Value))
// we set the payload value as twice its actual one so that it always chooses builder payloads vs local payloads
weiVal = weiVal.Mul(weiVal, big.NewInt(2))
wObj, err := blocks.WrappedExecutionPayloadDeneb(b.Payload, math.WeiToGwei(weiVal))
if err != nil {
p.cfg.logger.WithError(err).Error("Could not wrap execution payload")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
hdr, err := blocks.PayloadToHeaderDeneb(wObj)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not make payload into header")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
val := builderAPI.Uint256{Int: v}
commitments := []hexutil.Bytes{}
for _, c := range b.BlobsBundle.KzgCommitments {
copiedC := c
commitments = append(commitments, copiedC)
}
wrappedHdr := &builderAPI.ExecutionPayloadHeaderDeneb{ExecutionPayloadHeaderDeneb: hdr}
bid := &builderAPI.BuilderBidDeneb{
Header: wrappedHdr,
BlobKzgCommitments: commitments,
Value: val,
Pubkey: secKey.PublicKey().Marshal(),
}
sszBid := &eth.BuilderBidDeneb{
Header: hdr,
BlobKzgCommitments: b.BlobsBundle.KzgCommitments,
Value: val.SSZBytes(),
Pubkey: secKey.PublicKey().Marshal(),
}
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder,
nil, /* fork version */
nil /* genesis val root */)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not compute the domain")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
rt, err := signing.ComputeSigningRoot(sszBid, d)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not compute the signing root")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
sig := secKey.Sign(rt[:])
hdrResp := &ExecHeaderResponseDeneb{
Version: "deneb",
Data: struct {
Signature hexutil.Bytes `json:"signature"`
Message *builderAPI.BuilderBidDeneb `json:"message"`
}{
Signature: sig.Marshal(),
Message: bid,
},
}
err = json.NewEncoder(w).Encode(hdrResp)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not encode response")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
p.currPayload = wObj
p.blobBundle = b.BlobsBundle
w.WriteHeader(http.StatusOK)
}
func (p *Builder) handleBlindedBlock(w http.ResponseWriter, req *http.Request) {
sb := &builderAPI.SignedBlindedBeaconBlockBellatrix{
SignedBlindedBeaconBlockBellatrix: &eth.SignedBlindedBeaconBlockBellatrix{},
@@ -453,6 +575,29 @@ func (p *Builder) handleBlindedBlock(w http.ResponseWriter, req *http.Request) {
http.Error(w, "payload not found", http.StatusInternalServerError)
return
}
if payload, err := p.currPayload.PbDeneb(); err == nil {
convertedPayload, err := builderAPI.FromProtoDeneb(payload)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not convert the payload")
http.Error(w, "payload not found", http.StatusInternalServerError)
return
}
execResp := &builderAPI.ExecPayloadResponseDeneb{
Version: "deneb",
Data: &builderAPI.ExecutionPayloadDenebAndBlobsBundle{
ExecutionPayload: &convertedPayload,
BlobsBundle: builderAPI.FromBundleProto(p.blobBundle),
},
}
err = json.NewEncoder(w).Encode(execResp)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not encode full payload response")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
return
}
if payload, err := p.currPayload.PbCapella(); err == nil {
convertedPayload, err := builderAPI.FromProtoCapella(payload)
if err != nil {
@@ -507,7 +652,7 @@ func (p *Builder) retrievePendingBlock() (*v1.ExecutionPayload, error) {
if err != nil {
return nil, err
}
payloadEnv, err := modifyExecutionPayload(*result, big.NewInt(0))
payloadEnv, err := modifyExecutionPayload(*result, big.NewInt(0), nil)
if err != nil {
return nil, err
}
@@ -531,7 +676,7 @@ func (p *Builder) retrievePendingBlockCapella() (*v1.ExecutionPayloadCapellaWith
if err != nil {
return nil, err
}
payloadEnv, err := modifyExecutionPayload(*result.ExecutionPayload, result.BlockValue)
payloadEnv, err := modifyExecutionPayload(*result.ExecutionPayload, result.BlockValue, nil)
if err != nil {
return nil, err
}
@@ -546,6 +691,34 @@ func (p *Builder) retrievePendingBlockCapella() (*v1.ExecutionPayloadCapellaWith
return capellaPayload, nil
}
func (p *Builder) retrievePendingBlockDeneb() (*v1.ExecutionPayloadDenebWithValueAndBlobsBundle, error) {
result := &engine.ExecutionPayloadEnvelope{}
if p.currId == nil {
return nil, errors.New("no payload id is cached")
}
err := p.execClient.CallContext(context.Background(), result, GetPayloadMethodV3, *p.currId)
if err != nil {
return nil, err
}
if p.prevBeaconRoot == nil {
p.cfg.logger.Errorf("previous root is nil")
}
payloadEnv, err := modifyExecutionPayload(*result.ExecutionPayload, result.BlockValue, p.prevBeaconRoot)
if err != nil {
return nil, err
}
payloadEnv.BlobsBundle = result.BlobsBundle
marshalledOutput, err := payloadEnv.MarshalJSON()
if err != nil {
return nil, err
}
denebPayload := &v1.ExecutionPayloadDenebWithValueAndBlobsBundle{}
if err = json.Unmarshal(marshalledOutput, denebPayload); err != nil {
return nil, err
}
return denebPayload, nil
}
func (p *Builder) sendHttpRequest(req *http.Request, requestBytes []byte) (*http.Response, error) {
proxyReq, err := http.NewRequest(req.Method, p.cfg.destinationUrl.String(), req.Body)
if err != nil {
@@ -608,8 +781,8 @@ func unmarshalRPCObject(b []byte) (*jsonRPCObject, error) {
return r, nil
}
func modifyExecutionPayload(execPayload engine.ExecutableData, fees *big.Int) (*engine.ExecutionPayloadEnvelope, error) {
modifiedBlock, err := executableDataToBlock(execPayload)
func modifyExecutionPayload(execPayload engine.ExecutableData, fees *big.Int, prevBeaconRoot []byte) (*engine.ExecutionPayloadEnvelope, error) {
modifiedBlock, err := executableDataToBlock(execPayload, prevBeaconRoot)
if err != nil {
return &engine.ExecutionPayloadEnvelope{}, err
}
@@ -617,7 +790,7 @@ func modifyExecutionPayload(execPayload engine.ExecutableData, fees *big.Int) (*
}
// This modifies the provided payload to imprint the builder's extra data
func executableDataToBlock(params engine.ExecutableData) (*gethTypes.Block, error) {
func executableDataToBlock(params engine.ExecutableData, prevBeaconRoot []byte) (*gethTypes.Block, error) {
txs, err := decodeTransactions(params.Transactions)
if err != nil {
return nil, err
@@ -647,6 +820,12 @@ func executableDataToBlock(params engine.ExecutableData) (*gethTypes.Block, erro
Extra: []byte("prysm-builder"), // add in extra data
MixDigest: params.Random,
WithdrawalsHash: withdrawalsRoot,
BlobGasUsed: params.BlobGasUsed,
ExcessBlobGas: params.ExcessBlobGas,
}
if prevBeaconRoot != nil {
pRoot := common.Hash(prevBeaconRoot)
header.ParentBeaconRoot = &pRoot
}
block := gethTypes.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */).WithWithdrawals(params.Withdrawals)
return block, nil