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

GetBlobSidecars API update #8278

Merged
merged 9 commits into from
May 5, 2024

Conversation

gfukushima
Copy link
Contributor

@gfukushima gfukushima commented May 1, 2024

PR Description

This PR adds the metadata fields to the result of the endpoint /eth/v1/beacon/blob_sidecars/{block_id} (GetBlobSidecars) updated here: ethereum/beacon-APIs#441

Fixed Issue(s)

Fixes #8191

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

Copy link
Contributor

@StefanBratanov StefanBratanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall with couple of comments.

.name("GetBlobSidecarsResponse")
.withField("data", listOf(blobSidecarType), Function.identity())
.withOptionalField("version", MILESTONE_TYPE, (b) -> Optional.of(b.getMilestone()))
Copy link
Contributor

@StefanBratanov StefanBratanov May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the OptionalField here for version, execution_optimistic and finalized. Can make it similar to GetBlock. The SerializableTypeDefinition is only used for serializing our fields which we know that are always present in our implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OpenAPI spec has defined them as optional. So I believe we need to use withOptionalField() to ensure we are compliant, don't we?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if we want to deserialize as well. Otherwise, not needed, since we always add them, but not fuzzed about it. Probably defining them as optional makes it more clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking from the perspective of the open api spec that we generate. If we want to match the "official" spec, we would need the optional field so we would generate the open api schema spec as optional as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense.

blobSidecars.isEmpty()
? Optional.empty()
: addMetaData(
//TODO we don't care about metadata here...need to find a way to get around the lack of a block root?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we use slotSelectorForAll only in our internal /teku/v1/beacon/blob_sidecars/{slot} which doesn't have any of the metadata fields, so I would just add a comment why we don't care about the block root and just default it to ZERO as you do.

@StefanBratanov
Copy link
Contributor

I think also worth adding to CHANGELOG we provide those fields now in the eth/v1/beacon/blob_sidecars/{block_id} endpoint

@gfukushima gfukushima marked this pull request as ready for review May 2, 2024 23:52
@lucassaldanha
Copy link
Member

The changes look good for me. The only thing missing is some tests around the metadata logic in BlobSidecarSelectorFactory (could probably re-use some of the test cases on BlobSidecarSelectorFactoryTest).

@gfukushima
Copy link
Contributor Author

Changelog and tests added

@gfukushima gfukushima changed the title GetBlobSideCars API update GetBlobSidecars API update May 3, 2024
@gfukushima gfukushima enabled auto-merge (squash) May 4, 2024 08:39
Copy link
Member

@lucassaldanha lucassaldanha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just added a few NITs.

blobSidecarSelectorFactory.headSelector().getBlobSidecars(indices).get();
assertThat(result).hasValue(blobSidecars);
assertThat(Optional.of(result.get().getData())).hasValue(blobSidecars);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I don't understand why we need to wrap it into an Optional for this assertion. Can't we do it like:

assertThat(result.get().getData()).isEqualTo(blobSidecars);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies to other assertions in this class as well but I won't add a comment on each one :)


assertThat(result).isNotEmpty();
final BlobSidecarsAndMetaData blobSidecarsAndMetaData = result.get();
assertThat(blobSidecarsAndMetaData.isFinalized()).isEqualTo(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: you can use .isTrue() instead of .isEqualTo(true).


assertThat(result).isNotEmpty();
final BlobSidecarsAndMetaData blobSidecarsAndMetaData = result.get();
assertThat(blobSidecarsAndMetaData.isFinalized()).isEqualTo(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: can use .isFalse() :)

gfukushima and others added 9 commits May 6, 2024 10:08
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
@lucassaldanha lucassaldanha force-pushed the getBlobSideCar-api-update branch from 0bf4b76 to ffdfc9d Compare May 5, 2024 22:12
@gfukushima gfukushima merged commit 85da208 into Consensys:master May 5, 2024
15 of 16 checks passed
@gfukushima gfukushima deleted the getBlobSideCar-api-update branch May 7, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[beacon-api] add more context to getBlobSidecars
3 participants