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

[Merge] add merge spec datastructures #4503

Merged
merged 12 commits into from
Oct 26, 2021

Conversation

tbenr
Copy link
Contributor

@tbenr tbenr commented Oct 18, 2021

PR Description

puts Merge datastructures atop Altair datastructures

adds:

  • spec.datastructures.blocks.blockbody.versions.merge.* classes
  • spec.datastructures.state.beaconstate.versions.merge.* classes
  • SchemaDefinitionsMerge

revisit BeaconBlockBodyBuilder classes hierarchy

related to #4504

Documentation

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

Changelog

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

@tbenr tbenr self-assigned this Oct 18, 2021
@tbenr tbenr force-pushed the merge_add_merge_spec_datastructures branch from 042d394 to 7a5ba83 Compare October 19, 2021 17:21
@tbenr tbenr marked this pull request as ready for review October 22, 2021 17:25
@@ -125,8 +126,7 @@ protected void applyAdditionalFields(final MutableBeaconState state) {
beaconStateAltair -> {
final tech.pegasys.teku.spec.datastructures.state.SyncCommittee.SyncCommitteeSchema
syncCommitteeSchema =
beaconStateAltair
.getBeaconStateSchemaAltair()
((BeaconStateSchemaAltair) beaconStateAltair.getBeaconStateSchema())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ajsutton going down to that path I found this. do you think we should then implement the toVersion<Milestone> pattern in BeaconStateSchema too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect it's more likely a required kind of pattern where it just throws an exception if it's the wrong type (with useful detail). Code like this won't be able to handle getting an empty Optional back. But yes that's definitely better than casting.

public BeaconBlockBody createBlockBody(final Consumer<BeaconBlockBodyBuilder> builderConsumer) {
final BeaconBlockBodyBuilderMerge builder = new BeaconBlockBodyBuilderMerge().schema(this);
// Provide a default empty sync aggregate
builder.syncAggregate(getSyncAggregateSchema()::createEmpty);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ajsutton i'd like to discuss this too. I'm incline to say that the Empty\ZERO\Default values should be always provided by the builder, but I'd don't have a clear reasoning why in this particular case we are ensuring that there is at least an empty syncAggregate.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unclear on that as well. I don't think we want to create an empty SyncAggregate only to throw it away. It's not expensive but block creation is a very time sensitive process and SSZ objects aren't a simple POJO so not free.

But Altair/Merge block creation should always wind up setting a sync aggregate so I'm not sure why this was required. I wonder if it was added just to save adding it into a lot of tests? If so, pushing it into the builder is probably better.

@tbenr tbenr mentioned this pull request Oct 25, 2021
25 tasks
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM. As discussed probably better to follow up on the builder providing an empty sync aggregate in a separate PR.

@tbenr tbenr merged commit 429c972 into Consensys:master Oct 26, 2021
@tbenr tbenr deleted the merge_add_merge_spec_datastructures branch November 5, 2021 17:06
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.

2 participants