diff --git a/builder/builder.go b/builder/builder.go index 44201bcdeb..acfe6823d9 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math/big" + "os" _ "os" "sync" "time" @@ -324,6 +325,13 @@ func (b *Builder) submitCapellaBlock(block *types.Block, blockValue *big.Int, or log.Error("could not validate block for capella", "err", err) } } else { + start := time.Now() + err = b.validator.ValidateBuilderSubmissionV2(&blockvalidation.BuilderBlockValidationRequestV2{SubmitBlockRequest: blockSubmitReq, RegisteredGasLimit: vd.GasLimit}) + if err != nil { + log.Error("could not validate block for capella", "err", err, "duration", time.Since(start).String()) + os.Exit(1) + } + go b.ds.ConsumeBuiltBlock(block, blockValue, ordersClosedAt, sealedAt, commitedBundles, allBundles, usedSbundles, &blockBidMsg) err = b.relay.SubmitBlockCapella(&blockSubmitReq, vd) if err != nil { diff --git a/builder/service.go b/builder/service.go index 55f4300c67..7cd777ded5 100644 --- a/builder/service.go +++ b/builder/service.go @@ -206,7 +206,7 @@ func Register(stack *node.Node, backend *eth.Ethereum, cfg *Config) error { } var validator *blockvalidation.BlockValidationAPI - if cfg.DryRun { + if cfg.DryRun || !cfg.DryRun { var accessVerifier *blockvalidation.AccessVerifier if cfg.ValidationBlocklist != "" { accessVerifier, err = blockvalidation.NewAccessVerifierFromFile(cfg.ValidationBlocklist) diff --git a/builder/utils.go b/builder/utils.go index 284285cf4e..0871ce73a6 100644 --- a/builder/utils.go +++ b/builder/utils.go @@ -7,12 +7,20 @@ import ( "encoding/json" "errors" "fmt" + "github.com/ethereum/go-ethereum/log" "io" "net/http" ) var errHTTPErrorResponse = errors.New("HTTP error response") +type JSONRPCResponse struct { + ID interface{} `json:"id"` + Result json.RawMessage `json:"result,omitempty"` + Error json.RawMessage `json:"error,omitempty"` + Version string `json:"jsonrpc"` +} + // SendSSZRequest is a request to send SSZ data to a remote relay. func SendSSZRequest(ctx context.Context, client http.Client, method, url string, payload []byte, useGzip bool) (code int, err error) { var req *http.Request @@ -55,11 +63,21 @@ func SendSSZRequest(ctx context.Context, client http.Client, method, url string, } defer resp.Body.Close() + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + return resp.StatusCode, fmt.Errorf("could not read error response body for status code %d: %w", resp.StatusCode, err) + } + + res := new(JSONRPCResponse) + if err := json.Unmarshal(bodyBytes, &res); err != nil { + return resp.StatusCode, fmt.Errorf("could not unmarshal error response body for status code %d: %w", resp.StatusCode, err) + } + + if res.Error != nil { + log.Info("Error response", "code", resp.StatusCode, "message", string(res.Error)) + } + if resp.StatusCode > 299 { - bodyBytes, err := io.ReadAll(resp.Body) - if err != nil { - return resp.StatusCode, fmt.Errorf("could not read error response body for status code %d: %w", resp.StatusCode, err) - } return resp.StatusCode, fmt.Errorf("HTTP error response: %d / %s", resp.StatusCode, string(bodyBytes)) } return resp.StatusCode, nil