@@ -21,6 +21,8 @@ import (
2121var (
2222 ErrUnknownNetwork = errors .New ("unknown network" )
2323 ErrEmptyPayload = errors .New ("empty payload" )
24+ ErrEmptyPayloadHeader = errors .New ("empty payload header" )
25+ ErrEmptyPayloadMessage = errors .New ("empty payload message" )
2426 ErrVersionNotSupported = errors .New ("version is not supported" )
2527
2628 EthNetworkHolesky = "holesky"
@@ -418,6 +420,15 @@ type BlockSubmissionInfo struct {
418420 ExcessBlobGas uint64
419421}
420422
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+
421432// VersionedSubmitHeaderOptimistic is a versioned signed header to construct the builder bid.
422433type VersionedSubmitHeaderOptimistic struct {
423434 Version spec.DataVersion
@@ -467,6 +478,12 @@ func (h *VersionedSubmitHeaderOptimistic) UnmarshalJSON(data []byte) error {
467478func (h * VersionedSubmitHeaderOptimistic ) BidTrace () (* builderApiV1.BidTrace , error ) {
468479 switch h .Version { //nolint:exhaustive
469480 case spec .DataVersionDeneb :
481+ if h .Deneb == nil {
482+ return nil , ErrEmptyPayload
483+ }
484+ if h .Deneb .Message == nil {
485+ return nil , ErrEmptyPayloadMessage
486+ }
470487 return h .Deneb .Message , nil
471488 default :
472489 return nil , fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
@@ -476,6 +493,12 @@ func (h *VersionedSubmitHeaderOptimistic) BidTrace() (*builderApiV1.BidTrace, er
476493func (h * VersionedSubmitHeaderOptimistic ) ExecutionPayloadBlockHash () (phase0.Hash32 , error ) {
477494 switch h .Version { //nolint:exhaustive
478495 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+ }
479502 return h .Deneb .ExecutionPayloadHeader .BlockHash , nil
480503 default :
481504 return phase0.Hash32 {}, fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
@@ -485,12 +508,75 @@ func (h *VersionedSubmitHeaderOptimistic) ExecutionPayloadBlockHash() (phase0.Ha
485508func (h * VersionedSubmitHeaderOptimistic ) Signature () (phase0.BLSSignature , error ) {
486509 switch h .Version { //nolint:exhaustive
487510 case spec .DataVersionDeneb :
511+ if h .Deneb == nil {
512+ return phase0.BLSSignature {}, ErrEmptyPayload
513+ }
488514 return h .Deneb .Signature , nil
489515 default :
490516 return phase0.BLSSignature {}, fmt .Errorf ("%w: %s" , ErrVersionNotSupported , h .Version )
491517 }
492518}
493519
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+
494580/*
495581DenebSubmitHeaderOptimistic is request from the builder to submit a Deneb header. At minimum
496582without blobs, it is 956 bytes. With the current maximum of 6 blobs this adds another 288
0 commit comments