Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deneb follow up #608

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,10 @@ func (m *BoostService) processDenebPayload(w http.ResponseWriter, req *http.Requ
// Ensure that blobs are valid and matches the request
if len(commitments) != len(blobs.Blobs) || len(commitments) != len(blobs.Commitments) || len(commitments) != len(blobs.Proofs) {
log.WithFields(logrus.Fields{
"requestBlobs": len(commitments),
"requestBlobCommitments": len(commitments),
"responseBlobs": len(blobs.Blobs),
"responseBlobCommitments": len(blobs.Commitments),
"responseBlobProofs": len(blobs.Proofs),
}).Error("block KZG commitment length does not equal responseBlobs length")
return
}
Expand Down
177 changes: 94 additions & 83 deletions server/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,99 +102,110 @@ func TestWeiBigIntToEthBigFloat(t *testing.T) {
}

func TestGetPayloadResponseIsEmpty(t *testing.T) {
t.Run("Non-empty capella payload response", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionCapella,
Capella: &capella.ExecutionPayload{
BlockHash: phase0.Hash32{0x1},
},
}
require.False(t, getPayloadResponseIsEmpty(payload))
})

t.Run("Non-empty deneb payload response", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
ExecutionPayload: &deneb.ExecutionPayload{
testCases := []struct {
name string
payload *builderApi.VersionedSubmitBlindedBlockResponse
expected bool
}{
{
name: "Non-empty capella payload response",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionCapella,
Capella: &capella.ExecutionPayload{
BlockHash: phase0.Hash32{0x1},
},
BlobsBundle: &builderApiDeneb.BlobsBundle{
Blobs: make([]deneb.Blob, 0),
Commitments: make([]deneb.KZGCommitment, 0),
Proofs: make([]deneb.KZGProof, 0),
},
expected: false,
},
{
name: "Non-empty deneb payload response",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
ExecutionPayload: &deneb.ExecutionPayload{
BlockHash: phase0.Hash32{0x1},
},
BlobsBundle: &builderApiDeneb.BlobsBundle{
Blobs: make([]deneb.Blob, 0),
Commitments: make([]deneb.KZGCommitment, 0),
Proofs: make([]deneb.KZGProof, 0),
},
},
},
}
require.False(t, getPayloadResponseIsEmpty(payload))
})

t.Run("Empty capella payload response", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionCapella,
}
require.True(t, getPayloadResponseIsEmpty(payload))
})

t.Run("Nil block hash for capella payload response", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionCapella,
Capella: &capella.ExecutionPayload{
BlockHash: nilHash,
expected: false,
},
{
name: "Empty capella payload response",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionCapella,
},
}
require.True(t, getPayloadResponseIsEmpty(payload))
})

t.Run("Empty deneb payload response", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
}
require.True(t, getPayloadResponseIsEmpty(payload))
})

t.Run("Empty deneb execution payload", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
BlobsBundle: &builderApiDeneb.BlobsBundle{
Blobs: make([]deneb.Blob, 0),
Commitments: make([]deneb.KZGCommitment, 0),
Proofs: make([]deneb.KZGProof, 0),
expected: true,
},
{
name: "Nil block hash for capella payload response",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionCapella,
Capella: &capella.ExecutionPayload{
BlockHash: nilHash,
},
},
}
require.True(t, getPayloadResponseIsEmpty(payload))
})

t.Run("Empty deneb blobs bundle", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
ExecutionPayload: &deneb.ExecutionPayload{
BlockHash: phase0.Hash32{0x1},
expected: true,
},
{
name: "Empty deneb payload response",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
},
expected: true,
},
{
name: "Empty deneb execution payload",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
BlobsBundle: &builderApiDeneb.BlobsBundle{
Blobs: make([]deneb.Blob, 0),
Commitments: make([]deneb.KZGCommitment, 0),
Proofs: make([]deneb.KZGProof, 0),
},
},
},
}
require.True(t, getPayloadResponseIsEmpty(payload))
})

t.Run("Nil block hash for deneb payload response", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
ExecutionPayload: &deneb.ExecutionPayload{
BlockHash: nilHash,
expected: true,
},
{
name: "Empty deneb blobs bundle",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
ExecutionPayload: &deneb.ExecutionPayload{
BlockHash: phase0.Hash32{0x1},
},
},
},
}
require.True(t, getPayloadResponseIsEmpty(payload))
})
expected: true,
},
{
name: "Nil block hash for deneb payload response",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
ExecutionPayload: &deneb.ExecutionPayload{
BlockHash: nilHash,
},
},
},
expected: true,
},
{
name: "Unsupported payload version",
payload: &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionBellatrix,
},
expected: true,
},
}

t.Run("Unsupported payload version", func(t *testing.T) {
payload := &builderApi.VersionedSubmitBlindedBlockResponse{
Version: spec.DataVersionBellatrix,
}
require.True(t, getPayloadResponseIsEmpty(payload))
})
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.expected, getPayloadResponseIsEmpty(tt.payload))
})
}
}
Loading