Skip to content

Commit d42e650

Browse files
committed
add unmarshal for block validation request
1 parent 460fbaf commit d42e650

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

eth/block-validation/api.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,27 @@ type BuilderBlockValidationRequestV2 struct {
220220
WithdrawalsRoot common.Hash `json:"withdrawals_root"`
221221
}
222222

223+
func (r *BuilderBlockValidationRequestV2) UnmarshalJSON(data []byte) error {
224+
params := &struct {
225+
RegisteredGasLimit uint64 `json:"registered_gas_limit,string"`
226+
WithdrawalsRoot common.Hash `json:"withdrawals_root"`
227+
}{}
228+
err := json.Unmarshal(data, params)
229+
if err != nil {
230+
return err
231+
}
232+
r.RegisteredGasLimit = params.RegisteredGasLimit
233+
r.WithdrawalsRoot = params.WithdrawalsRoot
234+
235+
blockRequest := new(capellaapi.SubmitBlockRequest)
236+
err = json.Unmarshal(data, &blockRequest)
237+
if err != nil {
238+
return err
239+
}
240+
r.SubmitBlockRequest = *blockRequest
241+
return nil
242+
}
243+
223244
func (api *BlockValidationAPI) ValidateBuilderSubmissionV2(params *BuilderBlockValidationRequestV2) error {
224245
// TODO: fuzztest, make sure the validation is sound
225246
// TODO: handle context!

0 commit comments

Comments
 (0)