-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add versioned block requests #67
Add versioned block requests #67
Conversation
758c6b3
to
ab38c7f
Compare
Sorry for the delay on this, I've been considering how best to handle this. I'm not sure that versioning on the way in is a particularly suitable way to go with the expansion in types. Given that we now have blocks, blinded blocks, block contents and blinded block contents, I'm wondering if we should have a simplified API that allows submission. Something like This would result in a slightly tidier API long-term, and stops the world of ever-growing structs. If it works nicely we could also consider carrying over something similar to other areas where we're currently carting around versioned structs. Thoughts? |
df50c0f
to
987f97d
Compare
987f97d
to
c934f6e
Compare
my concern here is the json marshalling / unmarshalling that is not uniform across the endpoints (e.g. some endpoints have additional metadata such as |
All endpoints in the beacon API have a The versioning would need to continue, but only at the stage where the JSON is being unmarshalled. My comment was more focused on providing an easier interface for users and moving some of the difficulty into the codebase. Something like: proposal := &deneb.SignedBlockContents{}
err := client.SubmitSignedProposal(ctx, proposal) rather than the current: proposal := &spec.VersionedSignedBeaconBlock{
Version: spec.DataVersionDeneb,
Deneb: &deneb.SignedBlockContents{},
}
err := client.SubmitBeaconBlock(ctx, proposal) And then Basically: I'm fine with the API returning |
I have spent some time thinking about this, and tying it in with a couple of other areas I'd like to improve. I am now considering making this even more generic and reducing it to a single // Submit submits data to the beacon node.
func (s *Service) Submit(ctx context.Context,
data any,
opts map[string]any,
) (
*consensusclient.SubmitResults,
error,
) {
switch data.(type) {
case *phase0.Attestation:
return s.Submit(ctx, []*phase0.Attestation{data.(*phase0.Attestation)}, opts)
case []*phase0.Attestation:
return s.submitAttestations(ctx, data.([]*phase0.Attestation))
case *phase0.SignedBeaconBlock:
return s.submitBeaconBlock(ctx, &spec.VersionedSignedBeaconBlock{
Version: spec.DataVersionPhase0,
Phase0: data.(*phase0.SignedBeaconBlock),
})
case *altair.SignedBeaconBlock:
return s.submitBeaconBlock(ctx, &spec.VersionedSignedBeaconBlock{
Version: spec.DataVersionAltair,
Altair: data.(*altair.SignedBeaconBlock),
})
case *bellatrix.SignedBeaconBlock:
return s.submitBeaconBlock(ctx, &spec.VersionedSignedBeaconBlock{
Version: spec.DataVersionBellatrix,
Bellatrix: data.(*bellatrix.SignedBeaconBlock),
})
case *capella.SignedBeaconBlock:
return s.submitBeaconBlock(ctx, &spec.VersionedSignedBeaconBlock{
Version: spec.DataVersionCapella,
Capella: data.(*capella.SignedBeaconBlock),
})
case *deneb.SignedBeaconBlock:
return , s.submitBeaconBlock(ctx, &spec.VersionedSignedBeaconBlock{
Version: spec.DataVersionDeneb,
Deneb: data.(*deneb.SignedBeaconBlock),
})
...
} (the implementation would be different, but this shows the basic idea). The benefits of this would be:
Not sure if there would be an equivalent Interested in your thoughts on the above design. |
What would the |
I'm going to merge this as-is, with the caveat that many of the function signatures are going to change in the next major release of this module so structs and signatures may be moved around at that point. |
The publishBlindedBlockV2 and publishBlockV2 uses
BlockContents
for Deneb as request bodies.This adds a versioned struct to support the new endpoints. Open to moving the structs to a more suitable name / location e.g. under a /v2 folder.