diff --git a/http/beaconstate.go b/http/beaconstate.go index ab3e6e34..7c46978e 100644 --- a/http/beaconstate.go +++ b/http/beaconstate.go @@ -137,7 +137,12 @@ func (s *Service) beaconStateFromSSZ(ctx context.Context, res *httpResponse) (*a } case spec.DataVersionElectra: response.Data.Electra = &electra.BeaconState{} - if err := response.Data.Electra.UnmarshalSSZ(res.body); err != nil { + if s.customSpecSupport { + err = dynSSZ.UnmarshalSSZ(response.Data.Electra, res.body) + } else { + err = response.Data.Electra.UnmarshalSSZ(res.body) + } + if err != nil { return nil, errors.Join(errors.New("failed to decode electra beacon state"), err) } default: diff --git a/http/proposal.go b/http/proposal.go index 80f08d56..ccab2683 100644 --- a/http/proposal.go +++ b/http/proposal.go @@ -221,10 +221,18 @@ func (s *Service) beaconBlockProposalFromSSZ(ctx context.Context, case spec.DataVersionElectra: if response.Data.Blinded { response.Data.ElectraBlinded = &apiv1electra.BlindedBeaconBlock{} - err = response.Data.ElectraBlinded.UnmarshalSSZ(res.body) + if s.customSpecSupport { + err = dynSSZ.UnmarshalSSZ(response.Data.ElectraBlinded, res.body) + } else { + err = response.Data.ElectraBlinded.UnmarshalSSZ(res.body) + } } else { response.Data.Electra = &apiv1electra.BlockContents{} - err = response.Data.Electra.UnmarshalSSZ(res.body) + if s.customSpecSupport { + err = dynSSZ.UnmarshalSSZ(response.Data.Electra, res.body) + } else { + err = response.Data.Electra.UnmarshalSSZ(res.body) + } } default: return nil, fmt.Errorf("unhandled block proposal version %s", res.consensusVersion) diff --git a/http/signedbeaconblock.go b/http/signedbeaconblock.go index e231004d..45b9d06f 100644 --- a/http/signedbeaconblock.go +++ b/http/signedbeaconblock.go @@ -145,8 +145,13 @@ func (s *Service) signedBeaconBlockFromSSZ(ctx context.Context, } case spec.DataVersionElectra: response.Data.Electra = &electra.SignedBeaconBlock{} - if err := response.Data.Electra.UnmarshalSSZ(res.body); err != nil { - return nil, errors.Join(errors.New("failed to decode electra signed block contents"), err) + if s.customSpecSupport { + err = dynSSZ.UnmarshalSSZ(response.Data.Electra, res.body) + } else { + err = response.Data.Electra.UnmarshalSSZ(res.body) + } + if err != nil { + return nil, errors.Join(errors.New("failed to decode deneb signed block contents"), err) } default: return nil, fmt.Errorf("unhandled block version %s", res.consensusVersion) diff --git a/spec/versionedbeaconblock.go b/spec/versionedbeaconblock.go index f878ec9b..a390121c 100644 --- a/spec/versionedbeaconblock.go +++ b/spec/versionedbeaconblock.go @@ -675,6 +675,30 @@ func (v *VersionedBeaconBlock) ProposerSlashings() ([]*phase0.ProposerSlashing, } } +// Consolidations returns the consolidations of the beacon block. +func (v *VersionedBeaconBlock) Consolidations() ([]*electra.SignedConsolidation, error) { + switch v.Version { + case DataVersionPhase0: + return nil, errors.New("consolidations not available in phase0 block") + case DataVersionAltair: + return nil, errors.New("consolidations not available in altair block") + case DataVersionBellatrix: + return nil, errors.New("consolidations not available in bellatrix block") + case DataVersionCapella: + return nil, errors.New("consolidations not available in capella block") + case DataVersionDeneb: + return nil, errors.New("consolidations not available in deneb block") + case DataVersionElectra: + if v.Electra == nil || v.Electra.Body == nil { + return nil, errors.New("no electra block") + } + + return v.Electra.Body.Consolidations, nil + default: + return nil, errors.New("unknown version") + } +} + // String returns a string version of the structure. func (v *VersionedBeaconBlock) String() string { switch v.Version {