@@ -19,6 +19,7 @@ import (
19
19
"github.com/prysmaticlabs/prysm/v4/monitoring/tracing"
20
20
"github.com/prysmaticlabs/prysm/v4/network"
21
21
"github.com/prysmaticlabs/prysm/v4/network/authorization"
22
+ v1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
22
23
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
23
24
"github.com/prysmaticlabs/prysm/v4/runtime/version"
24
25
log "github.com/sirupsen/logrus"
@@ -86,7 +87,7 @@ type BuilderClient interface {
86
87
NodeURL () string
87
88
GetHeader (ctx context.Context , slot primitives.Slot , parentHash [32 ]byte , pubkey [48 ]byte ) (SignedBid , error )
88
89
RegisterValidator (ctx context.Context , svr []* ethpb.SignedValidatorRegistrationV1 ) error
89
- SubmitBlindedBlock (ctx context.Context , sb interfaces.ReadOnlySignedBeaconBlock ) (interfaces.ExecutionData , error )
90
+ SubmitBlindedBlock (ctx context.Context , sb interfaces.ReadOnlySignedBeaconBlock , blobs [] * ethpb. SignedBlindedBlobSidecar ) (interfaces.ExecutionData , * v1. BlobsBundle , error )
90
91
Status (ctx context.Context ) error
91
92
}
92
93
@@ -220,6 +221,16 @@ func (c *Client) GetHeader(ctx context.Context, slot primitives.Slot, parentHash
220
221
return nil , errors .Wrapf (err , "error unmarshaling the builder GetHeader response, using slot=%d, parentHash=%#x, pubkey=%#x" , slot , parentHash , pubkey )
221
222
}
222
223
switch strings .ToLower (v .Version ) {
224
+ case strings .ToLower (version .String (version .Deneb )):
225
+ hr := & ExecHeaderResponseDeneb {}
226
+ if err := json .Unmarshal (hb , hr ); err != nil {
227
+ return nil , errors .Wrapf (err , "error unmarshaling the builder GetHeader response, using slot=%d, parentHash=%#x, pubkey=%#x" , slot , parentHash , pubkey )
228
+ }
229
+ p , err := hr .ToProto ()
230
+ if err != nil {
231
+ return nil , errors .Wrapf (err , "could not extract proto message from header" )
232
+ }
233
+ return WrappedSignedBuilderBidDeneb (p )
223
234
case strings .ToLower (version .String (version .Capella )):
224
235
hr := & ExecHeaderResponseCapella {}
225
236
if err := json .Unmarshal (hb , hr ); err != nil {
@@ -274,20 +285,20 @@ func (c *Client) RegisterValidator(ctx context.Context, svr []*ethpb.SignedValid
274
285
275
286
// SubmitBlindedBlock calls the builder API endpoint that binds the validator to the builder and submits the block.
276
287
// The response is the full execution payload used to create the blinded block.
277
- func (c * Client ) SubmitBlindedBlock (ctx context.Context , sb interfaces.ReadOnlySignedBeaconBlock ) (interfaces.ExecutionData , error ) {
288
+ func (c * Client ) SubmitBlindedBlock (ctx context.Context , sb interfaces.ReadOnlySignedBeaconBlock , blobs [] * ethpb. SignedBlindedBlobSidecar ) (interfaces.ExecutionData , * v1. BlobsBundle , error ) {
278
289
if ! sb .IsBlinded () {
279
- return nil , errNotBlinded
290
+ return nil , nil , errNotBlinded
280
291
}
281
292
switch sb .Version () {
282
293
case version .Bellatrix :
283
294
psb , err := sb .PbBlindedBellatrixBlock ()
284
295
if err != nil {
285
- return nil , errors .Wrapf (err , "could not get protobuf block" )
296
+ return nil , nil , errors .Wrapf (err , "could not get protobuf block" )
286
297
}
287
298
b := & SignedBlindedBeaconBlockBellatrix {SignedBlindedBeaconBlockBellatrix : psb }
288
299
body , err := json .Marshal (b )
289
300
if err != nil {
290
- return nil , errors .Wrap (err , "error encoding the SignedBlindedBeaconBlockBellatrix value body in SubmitBlindedBlock" )
301
+ return nil , nil , errors .Wrap (err , "error encoding the SignedBlindedBeaconBlockBellatrix value body in SubmitBlindedBlock" )
291
302
}
292
303
293
304
versionOpt := func (r * http.Request ) {
@@ -296,29 +307,33 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
296
307
rb , err := c .do (ctx , http .MethodPost , postBlindedBeaconBlockPath , bytes .NewBuffer (body ), versionOpt )
297
308
298
309
if err != nil {
299
- return nil , errors .Wrap (err , "error posting the SignedBlindedBeaconBlockBellatrix to the builder api" )
310
+ return nil , nil , errors .Wrap (err , "error posting the SignedBlindedBeaconBlockBellatrix to the builder api" )
300
311
}
301
312
ep := & ExecPayloadResponse {}
302
313
if err := json .Unmarshal (rb , ep ); err != nil {
303
- return nil , errors .Wrap (err , "error unmarshaling the builder SubmitBlindedBlock response" )
314
+ return nil , nil , errors .Wrap (err , "error unmarshaling the builder SubmitBlindedBlock response" )
304
315
}
305
316
if strings .ToLower (ep .Version ) != version .String (version .Bellatrix ) {
306
- return nil , errors .New ("not a bellatrix payload" )
317
+ return nil , nil , errors .New ("not a bellatrix payload" )
307
318
}
308
319
p , err := ep .ToProto ()
309
320
if err != nil {
310
- return nil , errors .Wrapf (err , "could not extract proto message from payload" )
321
+ return nil , nil , errors .Wrapf (err , "could not extract proto message from payload" )
311
322
}
312
- return blocks .WrappedExecutionPayload (p )
323
+ payload , err := blocks .WrappedExecutionPayload (p )
324
+ if err != nil {
325
+ return nil , nil , errors .Wrapf (err , "could not wrap execution payload in interface" )
326
+ }
327
+ return payload , nil , nil
313
328
case version .Capella :
314
329
psb , err := sb .PbBlindedCapellaBlock ()
315
330
if err != nil {
316
- return nil , errors .Wrapf (err , "could not get protobuf block" )
331
+ return nil , nil , errors .Wrapf (err , "could not get protobuf block" )
317
332
}
318
333
b := & SignedBlindedBeaconBlockCapella {SignedBlindedBeaconBlockCapella : psb }
319
334
body , err := json .Marshal (b )
320
335
if err != nil {
321
- return nil , errors .Wrap (err , "error encoding the SignedBlindedBeaconBlockCapella value body in SubmitBlindedBlockCapella" )
336
+ return nil , nil , errors .Wrap (err , "error encoding the SignedBlindedBeaconBlockCapella value body in SubmitBlindedBlockCapella" )
322
337
}
323
338
324
339
versionOpt := func (r * http.Request ) {
@@ -327,22 +342,61 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
327
342
rb , err := c .do (ctx , http .MethodPost , postBlindedBeaconBlockPath , bytes .NewBuffer (body ), versionOpt )
328
343
329
344
if err != nil {
330
- return nil , errors .Wrap (err , "error posting the SignedBlindedBeaconBlockCapella to the builder api" )
345
+ return nil , nil , errors .Wrap (err , "error posting the SignedBlindedBeaconBlockCapella to the builder api" )
331
346
}
332
347
ep := & ExecPayloadResponseCapella {}
333
348
if err := json .Unmarshal (rb , ep ); err != nil {
334
- return nil , errors .Wrap (err , "error unmarshaling the builder SubmitBlindedBlockCapella response" )
349
+ return nil , nil , errors .Wrap (err , "error unmarshaling the builder SubmitBlindedBlockCapella response" )
335
350
}
336
351
if strings .ToLower (ep .Version ) != version .String (version .Capella ) {
337
- return nil , errors .New ("not a capella payload" )
352
+ return nil , nil , errors .New ("not a capella payload" )
338
353
}
339
354
p , err := ep .ToProto ()
340
355
if err != nil {
341
- return nil , errors .Wrapf (err , "could not extract proto message from payload" )
356
+ return nil , nil , errors .Wrapf (err , "could not extract proto message from payload" )
357
+ }
358
+ payload , err := blocks .WrappedExecutionPayloadCapella (p , 0 )
359
+ if err != nil {
360
+ return nil , nil , errors .Wrapf (err , "could not wrap execution payload in interface" )
361
+ }
362
+ return payload , nil , nil
363
+ case version .Deneb :
364
+ psb , err := sb .PbBlindedDenebBlock ()
365
+ if err != nil {
366
+ return nil , nil , errors .Wrapf (err , "could not get protobuf block" )
367
+ }
368
+
369
+ b := & ethpb.SignedBlindedBeaconBlockAndBlobsDeneb {Block : psb , Blobs : blobs }
370
+ body , err := json .Marshal (b )
371
+ if err != nil {
372
+ return nil , nil , errors .Wrap (err , "error encoding the SignedBlindedBeaconBlockDeneb value body in SubmitBlindedBlockDeneb" )
373
+ }
374
+
375
+ versionOpt := func (r * http.Request ) {
376
+ r .Header .Add ("Eth-Consensus-Version" , version .String (version .Deneb ))
377
+ }
378
+ rb , err := c .do (ctx , http .MethodPost , postBlindedBeaconBlockPath , bytes .NewBuffer (body ), versionOpt )
379
+ if err != nil {
380
+ return nil , nil , errors .Wrap (err , "error posting the SignedBlindedBeaconBlockDeneb to the builder api" )
381
+ }
382
+ ep := & ExecPayloadResponseDeneb {}
383
+ if err := json .Unmarshal (rb , ep ); err != nil {
384
+ return nil , nil , errors .Wrap (err , "error unmarshaling the builder SubmitBlindedBlockDeneb response" )
385
+ }
386
+ if strings .ToLower (ep .Version ) != version .String (version .Deneb ) {
387
+ return nil , nil , errors .New ("not a deneb payload" )
388
+ }
389
+ p , blobBundle , err := ep .ToProto ()
390
+ if err != nil {
391
+ return nil , nil , errors .Wrapf (err , "could not extract proto message from payload" )
392
+ }
393
+ payload , err := blocks .WrappedExecutionPayloadDeneb (p , 0 )
394
+ if err != nil {
395
+ return nil , nil , errors .Wrapf (err , "could not wrap execution payload in interface" )
342
396
}
343
- return blocks . WrappedExecutionPayloadCapella ( p , 0 )
397
+ return payload , blobBundle , nil
344
398
default :
345
- return nil , fmt .Errorf ("unsupported block version %s" , version .String (sb .Version ()))
399
+ return nil , nil , fmt .Errorf ("unsupported block version %s" , version .String (sb .Version ()))
346
400
}
347
401
}
348
402
0 commit comments