@@ -21,6 +21,8 @@ import (
21
21
var (
22
22
ErrUnknownNetwork = errors .New ("unknown network" )
23
23
ErrEmptyPayload = errors .New ("empty payload" )
24
+ ErrEmptyPayloadHeader = errors .New ("empty payload header" )
25
+ ErrEmptyPayloadMessage = errors .New ("empty payload message" )
24
26
ErrVersionNotSupported = errors .New ("version is not supported" )
25
27
26
28
EthNetworkHolesky = "holesky"
@@ -418,6 +420,15 @@ type BlockSubmissionInfo struct {
418
420
ExcessBlobGas uint64
419
421
}
420
422
423
+ type HeaderSubmissionInfo struct {
424
+ BidTrace * builderApiV1.BidTrace
425
+ Signature phase0.BLSSignature
426
+ Timestamp uint64
427
+ PrevRandao phase0.Hash32
428
+ TransactionsRoot phase0.Root
429
+ WithdrawalsRoot phase0.Root
430
+ }
431
+
421
432
// VersionedSubmitHeaderOptimistic is a versioned signed header to construct the builder bid.
422
433
type VersionedSubmitHeaderOptimistic struct {
423
434
Version spec.DataVersion
@@ -467,6 +478,12 @@ func (h *VersionedSubmitHeaderOptimistic) UnmarshalJSON(data []byte) error {
467
478
func (h * VersionedSubmitHeaderOptimistic ) BidTrace () (* builderApiV1.BidTrace , error ) {
468
479
switch h .Version { //nolint:exhaustive
469
480
case spec .DataVersionDeneb :
481
+ if h .Deneb == nil {
482
+ return nil , ErrEmptyPayload
483
+ }
484
+ if h .Deneb .Message == nil {
485
+ return nil , ErrEmptyPayloadMessage
486
+ }
470
487
return h .Deneb .Message , nil
471
488
default :
472
489
return nil , fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
@@ -476,6 +493,12 @@ func (h *VersionedSubmitHeaderOptimistic) BidTrace() (*builderApiV1.BidTrace, er
476
493
func (h * VersionedSubmitHeaderOptimistic ) ExecutionPayloadBlockHash () (phase0.Hash32 , error ) {
477
494
switch h .Version { //nolint:exhaustive
478
495
case spec .DataVersionDeneb :
496
+ if h .Deneb == nil {
497
+ return phase0.Hash32 {}, ErrEmptyPayload
498
+ }
499
+ if h .Deneb .ExecutionPayloadHeader == nil {
500
+ return phase0.Hash32 {}, ErrEmptyPayloadHeader
501
+ }
479
502
return h .Deneb .ExecutionPayloadHeader .BlockHash , nil
480
503
default :
481
504
return phase0.Hash32 {}, fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
@@ -485,12 +508,75 @@ func (h *VersionedSubmitHeaderOptimistic) ExecutionPayloadBlockHash() (phase0.Ha
485
508
func (h * VersionedSubmitHeaderOptimistic ) Signature () (phase0.BLSSignature , error ) {
486
509
switch h .Version { //nolint:exhaustive
487
510
case spec .DataVersionDeneb :
511
+ if h .Deneb == nil {
512
+ return phase0.BLSSignature {}, ErrEmptyPayload
513
+ }
488
514
return h .Deneb .Signature , nil
489
515
default :
490
516
return phase0.BLSSignature {}, fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
491
517
}
492
518
}
493
519
520
+ func (h * VersionedSubmitHeaderOptimistic ) Timestamp () (uint64 , error ) {
521
+ switch h .Version { //nolint:exhaustive
522
+ case spec .DataVersionDeneb :
523
+ if h .Deneb == nil {
524
+ return 0 , ErrEmptyPayload
525
+ }
526
+ if h .Deneb .ExecutionPayloadHeader == nil {
527
+ return 0 , ErrEmptyPayloadHeader
528
+ }
529
+ return h .Deneb .ExecutionPayloadHeader .Timestamp , nil
530
+ default :
531
+ return 0 , fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
532
+ }
533
+ }
534
+
535
+ func (h * VersionedSubmitHeaderOptimistic ) PrevRandao () (phase0.Hash32 , error ) {
536
+ switch h .Version { //nolint:exhaustive
537
+ case spec .DataVersionDeneb :
538
+ if h .Deneb == nil {
539
+ return phase0.Hash32 {}, ErrEmptyPayload
540
+ }
541
+ if h .Deneb .ExecutionPayloadHeader == nil {
542
+ return phase0.Hash32 {}, ErrEmptyPayloadHeader
543
+ }
544
+ return h .Deneb .ExecutionPayloadHeader .PrevRandao , nil
545
+ default :
546
+ return phase0.Hash32 {}, fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
547
+ }
548
+ }
549
+
550
+ func (h * VersionedSubmitHeaderOptimistic ) TransactionsRoot () (phase0.Root , error ) {
551
+ switch h .Version { //nolint:exhaustive
552
+ case spec .DataVersionDeneb :
553
+ if h .Deneb == nil {
554
+ return phase0.Root {}, ErrEmptyPayload
555
+ }
556
+ if h .Deneb .ExecutionPayloadHeader == nil {
557
+ return phase0.Root {}, ErrEmptyPayloadHeader
558
+ }
559
+ return h .Deneb .ExecutionPayloadHeader .TransactionsRoot , nil
560
+ default :
561
+ return phase0.Root {}, fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
562
+ }
563
+ }
564
+
565
+ func (h * VersionedSubmitHeaderOptimistic ) WithdrawalsRoot () (phase0.Root , error ) {
566
+ switch h .Version { //nolint:exhaustive
567
+ case spec .DataVersionDeneb :
568
+ if h .Deneb == nil {
569
+ return phase0.Root {}, ErrEmptyPayload
570
+ }
571
+ if h .Deneb .ExecutionPayloadHeader == nil {
572
+ return phase0.Root {}, ErrEmptyPayloadHeader
573
+ }
574
+ return h .Deneb .ExecutionPayloadHeader .WithdrawalsRoot , nil
575
+ default :
576
+ return phase0.Root {}, fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
577
+ }
578
+ }
579
+
494
580
/*
495
581
DenebSubmitHeaderOptimistic is request from the builder to submit a Deneb header. At minimum
496
582
without blobs, it is 956 bytes. With the current maximum of 6 blobs this adds another 288
0 commit comments