@@ -4,8 +4,10 @@ use serde_utils::quoted_u64::Quoted;
44use ssz_derive:: { Decode , Encode } ;
55pub use types:: {
66 superstruct, Address , EthSpec , ExecutionBlockHash , ExecutionPayloadBellatrix ,
7- ExecutionPayloadCapella , ExecutionPayloadDeneb , ExecutionPayloadElectra , MainnetEthSpec ,
8- MinimalEthSpec , PublicKeyBytes , Signature , SignedValidatorRegistrationData , Slot , Uint256 ,
7+ ExecutionPayloadCapella , ExecutionPayloadDeneb , ExecutionPayloadElectra ,
8+ ExecutionPayloadHeaderBellatrix , ExecutionPayloadHeaderCapella , ExecutionPayloadHeaderDeneb ,
9+ ExecutionPayloadHeaderElectra , MainnetEthSpec , MinimalEthSpec , PublicKeyBytes , Signature ,
10+ SignedValidatorRegistrationData , Slot , Uint256 ,
911} ;
1012
1113// Builder API requests
@@ -108,13 +110,96 @@ pub struct GetValidatorRegistrationQueryParams {
108110 pub pubkey : PublicKeyBytes ,
109111}
110112
113+ #[ superstruct(
114+ variants( Bellatrix , Capella , Deneb , Electra ) ,
115+ variant_attributes(
116+ derive( Debug , Clone , Serialize , Deserialize , Encode , Decode ) ,
117+ serde( bound = "E: EthSpec" , deny_unknown_fields) ,
118+ ) ,
119+ map_into( ExecutionPayloadHeader ) ,
120+ map_ref_into( ExecutionPayloadHeader )
121+ ) ]
122+ #[ derive( Debug , Clone , Serialize , Deserialize , Encode , Decode ) ]
123+ #[ serde( bound = "E: EthSpec" , untagged) ]
124+ #[ ssz( enum_behaviour = "transparent" ) ]
125+ pub struct HeaderSubmission < E : EthSpec > {
126+ bid_trace : BidTraceV1 ,
127+ #[ superstruct( flatten) ]
128+ execution_payload_header : ExecutionPayloadHeader < E > ,
129+ #[ superstruct( only( Deneb ) ) ]
130+ blobs_bundle : BlobsBundle < E > ,
131+ }
132+
133+ #[ superstruct(
134+ variants( Bellatrix , Capella , Deneb , Electra ) ,
135+ variant_attributes(
136+ derive( Debug , Clone , Serialize , Deserialize , Encode , Decode ) ,
137+ serde( bound = "E: EthSpec" , deny_unknown_fields) ,
138+ ) ,
139+ map_into( ExecutionPayloadHeader ) ,
140+ map_ref_into( ExecutionPayloadHeader )
141+ ) ]
142+ #[ derive( Debug , Clone , Serialize , Deserialize , Encode , Decode ) ]
143+ #[ serde( bound = "E: EthSpec" , untagged) ]
144+ #[ ssz( enum_behaviour = "transparent" ) ]
145+ pub struct SignedHeaderSubmission < E : EthSpec > {
146+ #[ superstruct( flatten) ]
147+ message : HeaderSubmission < E > ,
148+ signature : Signature ,
149+ }
150+
151+ #[ derive( Debug , Clone , Serialize , Deserialize , Encode , Decode ) ]
152+ pub struct Cancellation {
153+ #[ serde( with = "serde_utils::quoted_u64" ) ]
154+ pub slot : u64 ,
155+ pub parent_hash : ExecutionBlockHash ,
156+ pub proposer_public_key : PublicKeyBytes ,
157+ pub builder_public_key : PublicKeyBytes ,
158+ }
159+
160+ #[ derive( Debug , Clone , Serialize , Deserialize , Encode , Decode ) ]
161+ pub struct SignedCancellation {
162+ pub message : Cancellation ,
163+ pub signature : Signature ,
164+ }
165+
166+ // Websockets types
167+ #[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
168+ pub struct TopBidUpdate {
169+ #[ serde( with = "serde_utils::quoted_u64" ) ]
170+ timestamp : u64 ,
171+ slot : Slot ,
172+ #[ serde( with = "serde_utils::quoted_u64" ) ]
173+ block_number : u64 ,
174+ block_hash : ExecutionBlockHash ,
175+ parent_hash : ExecutionBlockHash ,
176+ builder_pubkey : PublicKeyBytes ,
177+ fee_recipient : Address ,
178+ #[ serde( with = "serde_utils::quoted_u256" ) ]
179+ value : Uint256 ,
180+ }
181+
111182// Builder API responses
183+ #[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
184+ #[ serde( rename_all = "kebab-case" ) ]
185+ pub enum Filtering {
186+ Regional ,
187+ Global ,
188+ }
189+
190+ #[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
191+ pub struct ValidatorPreferences {
192+ filtering : Filtering ,
193+ trusted_builders : Option < Vec < String > > ,
194+ }
195+
112196#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
113197pub struct ValidatorsResponse {
114198 pub slot : Slot ,
115199 #[ serde( with = "serde_utils::quoted_u64" ) ]
116200 pub validator_index : u64 ,
117201 pub entry : SignedValidatorRegistrationData ,
202+ pub preferences : Option < ValidatorPreferences > ,
118203}
119204
120205// Data API responses
@@ -156,15 +241,6 @@ pub struct BidTraceV2WithTimestamp {
156241}
157242
158243// Response types common
159-
160- #[ derive( Debug , PartialEq , Serialize , Deserialize ) ]
161- #[ serde( untagged) ]
162- #[ must_use]
163- pub enum Response < T > {
164- Success ( T ) ,
165- Error ( ErrorResponse ) ,
166- }
167-
168244#[ derive( Clone , Default , Debug , PartialEq , Serialize , Deserialize ) ]
169245pub struct ErrorResponse {
170246 pub code : u16 ,
@@ -173,11 +249,18 @@ pub struct ErrorResponse {
173249 pub stacktraces : Option < Vec < String > > ,
174250}
175251
252+ pub fn custom_internal_err ( message : String ) -> ErrorResponse {
253+ ErrorResponse {
254+ code : 500 ,
255+ message,
256+ stacktraces : None ,
257+ }
258+ }
259+
176260// Builder API response types
177- pub type GetValidatorsResponse = Response < Vec < ValidatorsResponse > > ;
178- pub type SubmitBlockResponse = Response < ( ) > ;
261+ pub type GetValidatorsResponse = Vec < ValidatorsResponse > ;
179262
180263// Data API response types
181- pub type GetDeliveredPayloadsResponse = Response < Vec < BidTraceV2 > > ;
182- pub type GetReceivedBidsResponse = Response < Vec < BidTraceV2WithTimestamp > > ;
183- pub type GetValidatorRegistrationResponse = Response < SignedValidatorRegistrationData > ;
264+ pub type GetDeliveredPayloadsResponse = Vec < BidTraceV2 > ;
265+ pub type GetReceivedBidsResponse = Vec < BidTraceV2WithTimestamp > ;
266+ pub type GetValidatorRegistrationResponse = SignedValidatorRegistrationData ;
0 commit comments