diff --git a/mev-boost/server/mock_relay.go b/mev-boost/server/mock_relay.go index cdde64fad..f286b1107 100644 --- a/mev-boost/server/mock_relay.go +++ b/mev-boost/server/mock_relay.go @@ -411,7 +411,7 @@ func (m *mockRelay) defaultHandleGetHeaderWithProofs(w http.ResponseWriter) { "0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7", "0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7", "0x8a1d7b8dd64e0aafe7ea7b6c95065c9364cf99d38470c12ee807d55f7de1529ad29ce2c422e0b65e3d5a05c02caca249", - spec.DataVersionCapella, + spec.DataVersionDeneb, nil, ) diff --git a/mev-boost/server/proofs.go b/mev-boost/server/proofs.go index dd6315932..5ba5f40ba 100644 --- a/mev-boost/server/proofs.go +++ b/mev-boost/server/proofs.go @@ -69,6 +69,69 @@ func (v *VersionedSignedBuilderBidWithProofs) MarshalJSON() ([]byte, error) { return nil, fmt.Errorf("unknown data version %d", v.Version) } +func (v *VersionedSignedBuilderBidWithProofs) UnmarshalJSON(data []byte) error { + var err error + + // Try Deneb + var deneb struct { + Message *builderApiDeneb.BuilderBid `json:"message"` + Signature phase0.BLSSignature `json:"signature"` + Proofs *InclusionProof `json:"proofs"` + } + err = json.Unmarshal(data, &deneb) + if err == nil && deneb.Message != nil { + v.Proofs = deneb.Proofs + + v.VersionedSignedBuilderBid = &builderSpec.VersionedSignedBuilderBid{} + v.Deneb = &builderApiDeneb.SignedBuilderBid{ + Message: deneb.Message, + Signature: deneb.Signature, + } + v.Version = consensusSpec.DataVersionDeneb + return nil + } + + // Try Capella + var capella struct { + Message *builderApiCapella.BuilderBid `json:"message"` + Signature phase0.BLSSignature `json:"signature"` + Proofs *InclusionProof `json:"proofs"` + } + err = json.Unmarshal(data, &capella) + if err == nil && capella.Message != nil { + v.Proofs = capella.Proofs + + v.VersionedSignedBuilderBid = &builderSpec.VersionedSignedBuilderBid{} + v.Capella = &builderApiCapella.SignedBuilderBid{ + Message: capella.Message, + Signature: capella.Signature, + } + v.Version = consensusSpec.DataVersionCapella + return nil + } + + // Try Bellatrix + var bellatrix struct { + Message *builderApiBellatrix.BuilderBid `json:"message"` + Signature phase0.BLSSignature `json:"signature"` + Proofs *InclusionProof `json:"proofs"` + } + err = json.Unmarshal(data, &bellatrix) + if err == nil && bellatrix.Message != nil { + v.Proofs = bellatrix.Proofs + + v.VersionedSignedBuilderBid = &builderSpec.VersionedSignedBuilderBid{} + v.Bellatrix = &builderApiBellatrix.SignedBuilderBid{ + Message: bellatrix.Message, + Signature: bellatrix.Signature, + } + v.Version = consensusSpec.DataVersionBellatrix + return nil + } + + return fmt.Errorf("failed to unmarshal VersionedSignedBuilderBidWithProofs: %v", err) +} + func (v *VersionedSignedBuilderBidWithProofs) String() string { return JSONStringify(v) }