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

chore(op-service): Add missing fields to blob API types #12602

Merged
merged 4 commits into from
Oct 24, 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
1 change: 1 addition & 0 deletions op-e2e/e2eutils/fakebeacon/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (f *FakeBeacon) Start(addr string) error {
Slot: eth.Uint64String(slot),
},
},
InclusionProof: make([]eth.Bytes32, 0),
}
copy(sidecars[i].Blob[:], bundle.Blobs[ix])
}
Expand Down
9 changes: 5 additions & 4 deletions op-service/eth/blobs_api.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eth

import "github.com/ethereum/go-ethereum/common/hexutil"

type BlobSidecar struct {
Blob Blob `json:"blob"`
Index Uint64String `json:"index"`
Expand All @@ -13,8 +15,7 @@ type APIBlobSidecar struct {
KZGCommitment Bytes48 `json:"kzg_commitment"`
KZGProof Bytes48 `json:"kzg_proof"`
SignedBlockHeader SignedBeaconBlockHeader `json:"signed_block_header"`
// The inclusion-proof of the blob-sidecar into the beacon-block is ignored,
// since we verify blobs by their versioned hashes against the execution-layer block instead.
InclusionProof []Bytes32 `json:"kzg_commitment_inclusion_proof"`
}

func (sc *APIBlobSidecar) BlobSidecar() *BlobSidecar {
Expand All @@ -27,8 +28,8 @@ func (sc *APIBlobSidecar) BlobSidecar() *BlobSidecar {
}

type SignedBeaconBlockHeader struct {
Message BeaconBlockHeader `json:"message"`
// signature is ignored, since we verify blobs against EL versioned-hashes
Message BeaconBlockHeader `json:"message"`
Signature hexutil.Bytes `json:"signature"`
}

type BeaconBlockHeader struct {
Expand Down
6 changes: 4 additions & 2 deletions op-service/eth/blobs_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ func TestAPIGetBlobSidecarsResponse(t *testing.T) {
var resp eth.APIGetBlobSidecarsResponse
require.NoError(json.Unmarshal(jsonStr, &resp))
require.NotEmpty(resp.Data)
require.Equal(5, reflect.TypeOf(*resp.Data[0]).NumField(), "APIBlobSidecar changed, adjust test")
require.Equal(1, reflect.TypeOf(resp.Data[0].SignedBlockHeader).NumField(), "SignedBeaconBlockHeader changed, adjust test")
require.Equal(6, reflect.TypeOf(*resp.Data[0]).NumField(), "APIBlobSidecar changed, adjust test")
require.Equal(2, reflect.TypeOf(resp.Data[0].SignedBlockHeader).NumField(), "SignedBeaconBlockHeader changed, adjust test")
require.Equal(5, reflect.TypeOf(resp.Data[0].SignedBlockHeader.Message).NumField(), "BeaconBlockHeader changed, adjust test")

require.NotZero(resp.Data[0].Blob)
require.NotZero(resp.Data[1].Index)
require.NotZero(resp.Data[0].KZGCommitment)
require.NotZero(resp.Data[0].KZGProof)
require.NotZero(resp.Data[0].InclusionProof)
require.NotZero(resp.Data[0].SignedBlockHeader.Message.Slot)
require.NotZero(resp.Data[0].SignedBlockHeader.Message.ParentRoot)
require.NotZero(resp.Data[0].SignedBlockHeader.Message.BodyRoot)
require.NotZero(resp.Data[0].SignedBlockHeader.Message.ProposerIndex)
require.NotZero(resp.Data[0].SignedBlockHeader.Message.StateRoot)
require.NotZero(resp.Data[0].SignedBlockHeader.Signature)
}