Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Debug commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazzymandias committed Aug 9, 2023
1 parent bdc7422 commit c59fe71
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
8 changes: 8 additions & 0 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math/big"
"os"
_ "os"
"sync"
"time"
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion builder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 22 additions & 4 deletions builder/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c59fe71

Please sign in to comment.