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

Stubbed implementation of GetLightClientBootstrap #6384

Merged
merged 8 commits into from
Nov 14, 2022

Conversation

robzajac
Copy link
Contributor

@robzajac robzajac commented Nov 5, 2022

PR Description

This PR is a base implementation of GetLightClientBootstrap with return 501;. It is intended to validate the interface.

Fixed Issue(s)

fixes #6287

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.

@CLAassistant
Copy link

CLAassistant commented Nov 5, 2022

CLA assistant check
All committers have signed the CLA.

request.respondError(501, "Not implemented");
}

private static SerializableTypeDefinition<ObjectAndMetaData<LightClientBootstrap>>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure whether to use ObjectAndMetadata here given that this API only requires version and not executionOptimistic or canonical

Copy link
Contributor

Choose a reason for hiding this comment

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

ObjectAndMetadata is generally what's coming out of the ChainDataClient, so using that should be ok, but it's also just an interface you're using if we end up needing to change it so it's not locked in stone...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will still have all fields consumers need, and the two extra that they don't. As long as clients don't have strict response validation (i.e. allowing additive fields) then it should be okay.

@@ -41,6 +42,7 @@ public class SchemaDefinitionsAltair extends AbstractSchemaDefinitions {
private final ContributionAndProofSchema contributionAndProofSchema;
private final SignedContributionAndProofSchema signedContributionAndProofSchema;
private final MetadataMessageSchemaAltair metadataMessageSchema;
private final LightClientBootstrapSchema lightClientBootstrapSchema;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added only for Altair schema definitions. Question whether the schema should be added for all consensus versions (i.e. lift up into SchemaDefinitions) (though there is no change from Altair) or whether it should only be specified in SchemaDefinitionsAltair and used this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to pull it into SchemaDefinitions I think, rather than hard references to Altair, as that creates the altair schema definitions even though maybe only this one is used... @ajsutton may have opinions here so tagging

Copy link
Contributor

Choose a reason for hiding this comment

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

Given the light client types are defined in the spec they will be versioned with hard forks and so need to come from SchemaDefinitions. They will still just wind up being added to SchemaDefinitionsAltair because SchemaDefinitionsBellatrix extends from that and doesn't need to make any changes so will just inherit the Altair definitions.

Since these types are new in Altair I think you've actually got it right that they get added to SchemaDefinitionsAltair - they're then inherited by Bellatrix and they don't need to be in Phase0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not entirely sure that comment made sense... SchemaDefinitions is an interface that only contains the types that are common to all hard forks. For things new in Altair like this you'd call SchemaDefinitions.toVersionAltair() to get a SchemaDefinitionsAltair and then can use these new methods.

And Bellatrix inherits all the Altair types, then just redefines a few, so SchemaDefinitionsBellatrix extends SchemaDefinitionsAltair so these methods will also be available there (and Capella extends Bellatrix).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Admittedly I am still a bit confused. Since SchemaDefinitions contains types for all consensus versions (including phase0), I think we wouldn't lift LightClientBootstrap there. The spec asks only for an Altair.LightClientBootstrap return type on this endpoint. The other endpoint I can see that has a similar treatment is produceSyncCommitteeContribution. This makes me inclined to retrieve the SchemaDefinitionsAltair in the endpoint with SchemaDefinitionsAltair.required(schemaDefinitionCache.getSchemaDefinition(SpecMilestone.ALTAIR)) and from there .getLightClientBootstrapSchema()

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry should have responded to this earlier, but it looks like you worked it out and done the right thing. The new method only gets added to SchemaDefinitionsAltair. We can be a bit sloppy with terminology when saying things should be added to "SchemaDefinitions" - we mean to the schema definitions for the first milestone it's relevant to.

public class LightClientBootstrap
extends Container3<LightClientBootstrap, BeaconBlockHeader, SyncCommittee, SszBytes32Vector> {

// TODO: Lift into SpecConfigAltair
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep I think moving this will be a whole thing...

It's a little involved to create an SSZ object against the schema for the correct milestone, but it's worthwhile in case it ever changes...
Initially a good object to look at would probably be ExecutionPayload which exists from Bellatrix... it's not broken down into versions because there's only 1, although it may start moving very soon because there's changes marked for capella...

It might actually be worth that becoming it's own smallish PR as they're a little involved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rolfyone Can this one be treated like SYNC_COMMITTEE_SIZE from SyncCommittee? Another Altair-specific parameter. The field would move up to SpecConfigAltair, and then I believe it should be read from config, or a static constants file. But I'm having trouble seeing where the config is parsed (for e.g. SYNC_COMMITTEE_SIZE).

I have an example impl on a separate branch but it fails the SpecConfigBuilder validation, making me believe the field is not being successfully read from config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second pass, I got it working (was missing a method in the Builder) robzajac@6b1b6a4

Just awaiting a second opinion on whether we want this in config this way, and then can write it into this branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved constant up to config in the latest push.

@robzajac robzajac force-pushed the light-client-bootstrap-endpoint branch 3 times, most recently from 4603123 to 7525630 Compare November 10, 2022 19:32
@robzajac robzajac marked this pull request as ready for review November 10, 2022 20:39
@robzajac
Copy link
Contributor Author

@rolfyone @ajsutton Addressed comments & outstanding todos, do you mind taking another look?
The acceptance test failure is new. Unable to replicate locally, taking another look.

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.

Looking really good. I think the key thing is just to provide a default so we don't break backwards compatibility with the config endpoint.

@@ -41,6 +42,7 @@ public class SchemaDefinitionsAltair extends AbstractSchemaDefinitions {
private final ContributionAndProofSchema contributionAndProofSchema;
private final SignedContributionAndProofSchema signedContributionAndProofSchema;
private final MetadataMessageSchemaAltair metadataMessageSchema;
private final LightClientBootstrapSchema lightClientBootstrapSchema;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry should have responded to this earlier, but it looks like you worked it out and done the right thing. The new method only gets added to SchemaDefinitionsAltair. We can be a bit sloppy with terminology when saying things should be added to "SchemaDefinitions" - we mean to the schema definitions for the first milestone it's relevant to.

@@ -79,6 +79,7 @@
"SLOTS_PER_EPOCH": "32",
"SLOTS_PER_HISTORICAL_ROOT": "8192",
"SYNC_COMMITTEE_SIZE": "512",
"SYNC_COMMITTEE_BRANCH_LENGTH": "5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Sadly we can't just update these test files (including altairForkSpec.json and mergeForkSpec.json). They're a capture of the actual response the beacon node will give from the /eth/v1/node/config endpoint which the standalone validator client uses to load the spec from the beacon node. It looks like adding this new property as a required field to Altair is breaking backwards compatibility (which is what the SpecConfigLoaderTest.shouldLoadMainnetPreservingBackwardsCompatibilityWithRestApi test is checking for.

We probably need to provide a default value in SpecConfigBuilder instead of requiring the field be set. Could just use the mainnet value as the default which I think would be reasonable. It's not particularly ideal but better than breaking backwards compatibility since people don't always update the VC and BN together. The default probably never gets used anyway since the VC doesn't use it and the built-in presets will provide it for the BN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ajsutton I think that makes sense. I set a default in the builder, similar treatment as updateTimeout. To check my understanding, is there a point at which the validators are updated to receive the new configs? Or will we continue to use the default for some time?

Copy link
Contributor

Choose a reason for hiding this comment

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

The validator client will load the config from the beacon node every time it starts up, so the real value should be picked up quite quickly but it's possible the VC is running against a beacon node that doesn't get updated or against a different client which doesn't yet have light client support and this config item. So we'll probably wind up keeping the default around pretty much forever (or at least until the next hard fork if all clients include it by then since that forces everyone to update). For the vast majority of setups though, they'll start loading the real value very quickly.

@ajsutton
Copy link
Contributor

Oh I think that acceptance test failure is likely related to the config backwards compatibility issue as well. It's running the latest version of the validator client (with these changes) against an old release of the beacon node and it's failing to start, likely because of the incorrect config.

To run locally you'll likely need to run ./gradlew distDocker to build the docker images from the latest code including your changes (otherwise it likely winds up running the latest version from master without your changes). Then you can run the acceptance test in IntelliJ like a normal test.

./gradlew acceptanceTest should automatically build the docker image but it runs all the tests so takes a fair while which is less useful for debugging stuff.

@robzajac robzajac force-pushed the light-client-bootstrap-endpoint branch from 56b631f to 03d27e3 Compare November 11, 2022 14:15
@robzajac
Copy link
Contributor Author

robzajac commented Nov 11, 2022

@ajsutton Recreated locally & pushed up a fix 🙏

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. Thanks for your patience on this and sorry we've been slow with reviews.

@ajsutton ajsutton merged commit 56ed542 into Consensys:master Nov 14, 2022
@robzajac robzajac deleted the light-client-bootstrap-endpoint branch November 14, 2022 14:13
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.

Sync endpoints for light-client
4 participants