diff --git a/.golangci.yml b/.golangci.yml index c7199509..e461ee1b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -60,9 +60,6 @@ linters-settings: disable: - fieldalignment - shadow - gomoddirectives: - replace-allow-list: - - github.com/attestantio/go-builder-client output: print-issued-lines: true diff --git a/go.mod b/go.mod index 74777e16..ee3bfe42 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( require ( github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect - github.com/attestantio/go-builder-client v0.3.2-0.20230626105718-423f7ec4ad24 + github.com/attestantio/go-builder-client v0.3.2-0.20230809093013-1fa02af241e1 github.com/attestantio/go-eth2-client v0.18.1-0.20230728160410-bc2888aaf7d7 github.com/btcsuite/btcd v0.22.0-beta // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect @@ -82,5 +82,3 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/attestantio/go-builder-client => github.com/avalonche/go-builder-client v0.0.0-20230727154356-9a77badf0423 diff --git a/go.sum b/go.sum index 6f3a1109..547aa4c1 100644 --- a/go.sum +++ b/go.sum @@ -16,12 +16,10 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/attestantio/go-builder-client v0.3.2-0.20230809093013-1fa02af241e1 h1:c6Jmkd6mryaFuWv2/Pa4aLqi+2QOv3gEN+Krj0Nmiq4= +github.com/attestantio/go-builder-client v0.3.2-0.20230809093013-1fa02af241e1/go.mod h1:8NZx9L/rC7nLhSMbbVR6PXr37tC28wTE4u65n+Pa3BQ= github.com/attestantio/go-eth2-client v0.18.1-0.20230728160410-bc2888aaf7d7 h1:7CCFg+rn8EppcURkhMLdNv0rl0lwFcAxkwV7kKOSF14= github.com/attestantio/go-eth2-client v0.18.1-0.20230728160410-bc2888aaf7d7/go.mod h1:KSVlZSW1A3jUg5H8O89DLtqxgJprRfTtI7k89fLdhu0= -github.com/avalonche/go-builder-client v0.0.0-20230727154356-9a77badf0423 h1:JWWVNPwWVThSmcfzKBjRbglwe4c6eEYquALAISClK0U= -github.com/avalonche/go-builder-client v0.0.0-20230727154356-9a77badf0423/go.mod h1:8NZx9L/rC7nLhSMbbVR6PXr37tC28wTE4u65n+Pa3BQ= -github.com/avalonche/go-eth2-client v0.0.0-20230727154722-91c9a241729e h1:4bLKeIfXtiYOuEJyZuXeWWdRwfArYRd7UP4PBJZUVOo= -github.com/avalonche/go-eth2-client v0.0.0-20230727154722-91c9a241729e/go.mod h1:KSVlZSW1A3jUg5H8O89DLtqxgJprRfTtI7k89fLdhu0= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/server/service.go b/server/service.go index 543cefa1..fb2f9197 100644 --- a/server/service.go +++ b/server/service.go @@ -21,6 +21,7 @@ import ( apiv1bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix" "github.com/attestantio/go-eth2-client/api/v1/capella" "github.com/attestantio/go-eth2-client/api/v1/deneb" + denebutil "github.com/attestantio/go-eth2-client/util/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/flashbots/go-boost-utils/ssz" "github.com/flashbots/go-boost-utils/types" @@ -774,14 +775,48 @@ func (m *BoostService) processDenebPayload(w http.ResponseWriter, req *http.Requ } // Ensure that blobs are valid and matches the request - if len(blindedBlobs) != len(blobs.Blobs) { + if len(blindedBlobs) != len(blobs.Blobs) || len(blindedBlobs) != len(blobs.Commitments) || len(blindedBlobs) != len(blobs.Proofs) { log.WithFields(logrus.Fields{ - "requestBlobs": len(blindedBlobs), - "responseBlobs": len(blobs.Blobs), + "requestBlobs": len(blindedBlobs), }).Error("requestBlobs length does not equal responseBlobs length") return } + for i, blindedBlob := range blindedBlobs { + if blindedBlob.Message.KzgCommitment != blobs.Commitments[i] { + log.WithFields(logrus.Fields{ + "requestBlobCommitment": blindedBlob.Message.KzgCommitment.String(), + "responseBlobCommiment": blobs.Commitments[i].String(), + "index": blindedBlob.Message.Index, + }).Error("requestBlobCommitment does not equal responseBlobCommiment") + return + } + + if blindedBlob.Message.KzgProof != blobs.Proofs[i] { + log.WithFields(logrus.Fields{ + "requestBlobProof": blindedBlob.Message.KzgProof.String(), + "responseBlobProof": blobs.Proofs[i].String(), + "index": blindedBlob.Message.Index, + }).Error("requestBlobProof does not equal responseBlobProof") + return + } + + blobHelper := denebutil.BeaconBlockBlob{Blob: blobs.Blobs[i]} + blobRoot, err := blobHelper.HashTreeRoot() + if err != nil { + log.WithError(err).Error("error calculating blobRoot") + return + } + if blindedBlob.Message.BlobRoot != blobRoot { + log.WithFields(logrus.Fields{ + "requestBlobRoot": blindedBlob.Message.BlobRoot.String(), + "responseBlobRoot": fmt.Sprintf("%#x", blobRoot), + "index": blindedBlob.Message.Index, + }).Error("requestBlobRoot does not equal responseBlobRoot") + return + } + } + // Lock before accessing the shared payload mu.Lock() defer mu.Unlock()