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

Add Beacon ID support #832

Merged
merged 43 commits into from
Oct 20, 2021
Merged

Add Beacon ID support #832

merged 43 commits into from
Oct 20, 2021

Conversation

emmanuelm41
Copy link
Contributor

No description provided.

core/drand_control.go Outdated Show resolved Hide resolved
client/client.go Outdated
@@ -248,6 +250,14 @@ func WithSchemeID(schID string) Option {
}
}

// WithBeaconID indicates the id for the randomness generation process which will be queried
func WithBeaconID(beaconID string) Option {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to think of the long term idea here:

  • What does this mean to give this ID for the client specifically ?
  • For example, what happens if the ID is not one of the protocols the endpoint is running ?
  • What happens if we don't provide one ? What is considered "default" ?
    • I think we need have the feature of fetching the ID remotely from the endpoint. Currently since there is stil only one ID it's simple.
  • Why is it not in the chain info ? It'd be simpler to unite all informations there, that's what it is made for. As well the SCHEME ID (not sure if it's there or not anymore). In that way, we dont need this additional information since there is already a WithChainInfo method and client can already fetch it automatically, it's already coded.

Copy link
Member

Choose a reason for hiding this comment

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

I think we are still saying that a given beacon is not going to change it's group info / key over it's lifetime. As such, i agree that the root of trust at this point remains the public key / hash of key that is currently the pinned point of reference.

That means that the beacon ID as a piece of metadata used in calculating hashes and identifying the chain acts a lot like the genesis time of the chain. It should be learned from the info endpoint, rather than manually exposed to the client.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep - so we should remove this option and just let the client knows it via the chain info, do we agree ?

cmd/client/lib/cli.go Outdated Show resolved Hide resolved
core/drand.go Outdated Show resolved Hide resolved
core/drand_control.go Outdated Show resolved Hide resolved
protobuf/drand/common.proto Outdated Show resolved Hide resolved
chain/beacon/cache.go Outdated Show resolved Hide resolved
chain/beacon/node_test.go Outdated Show resolved Hide resolved
last, err := s.store.Last()
if err != nil {
return false
}

beaconID := s.info.ID
metadata := common.NewMetadata(utils.Version{Major: 0, Minor: 0, Patch: 0}.ToProto()) // FIXME We should set node version here
Copy link
Member

Choose a reason for hiding this comment

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

set version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left the comment to fix this in another PR, as you don't want me to mix topics in PRs. I will fix that one on another PR after merging this one!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you open an issue here so we dont forget and track this please ? (maybe you already done it - just making sure !)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, of course we can!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here! #833

chain/convert.go Outdated
}, nil
}

// ToProto returns the protobuf description of the chain info
func (c *Info) ToProto() *drand.ChainInfoPacket {
buff, _ := c.PublicKey.MarshalBinary()

metadata := common.Metadata{BeaconID: c.ID} // FIXME Add node version here too
Copy link
Member

Choose a reason for hiding this comment

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

version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left the comment to fix this in another PR, as you don't want me to mix topics in PRs. I will fix that one on another PR after merging this one!

client/client.go Outdated
@@ -248,6 +250,14 @@ func WithSchemeID(schID string) Option {
}
}

// WithBeaconID indicates the id for the randomness generation process which will be queried
func WithBeaconID(beaconID string) Option {
Copy link
Member

Choose a reason for hiding this comment

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

I think we are still saying that a given beacon is not going to change it's group info / key over it's lifetime. As such, i agree that the root of trust at this point remains the public key / hash of key that is currently the pinned point of reference.

That means that the beacon ID as a piece of metadata used in calculating hashes and identifying the chain acts a lot like the genesis time of the chain. It should be learned from the info endpoint, rather than manually exposed to the client.

core/drand.go Outdated Show resolved Hide resolved
@@ -374,7 +391,7 @@ func (d *Drand) setupAutomaticDKG(_ context.Context, in *drand.InitDKGPacket) (*
if err != nil {
return nil, err
}
return finalGroup.ToProto(), nil
return finalGroup.ToProto(d.version), nil
Copy link
Member

Choose a reason for hiding this comment

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

this is a different change? is this a bug fix from the versioning before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is not a change related to beacon id feature. If you want, I will leave a FIXME comment and change it on another PR. It is so an small change I thought we can include it here.

core/drand_control.go Show resolved Hide resolved
response := chain.NewChainInfo(d.group).ToProto()
response.Metadata = metadata
response.Metadata.NodeVersion = d.version.ToProto()
Copy link
Member

Choose a reason for hiding this comment

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

this ideally would be separated out into a follow-up on the node versioning PR.
Can you add a test to show that this is now passing version information on chain info requests as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a bug fix from node versioning PR. I change the way we set metadata here so we can handle beacon id too.

@@ -15,4 +15,5 @@ message NodeVersion {

message Metadata {
NodeVersion node_version = 1;
string beaconID = 2;
Copy link
Member

Choose a reason for hiding this comment

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

beacon_id to use consistent casing with node_version above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I use beacon_id as name, Protocol will set the name as BeaconId and linter will complain. We had the same issue with schemeID.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then beacon_ID ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nop. If I set so, the filed name would be Beacon_ID. I just tested it.

Copy link
Collaborator

@nikkolasg nikkolasg left a comment

Choose a reason for hiding this comment

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

A few comments but i think after that we're good to merge !

last, err := s.store.Last()
if err != nil {
return false
}

beaconID := s.info.ID
metadata := common.NewMetadata(utils.Version{Major: 0, Minor: 0, Patch: 0}.ToProto()) // FIXME We should set node version here
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you open an issue here so we dont forget and track this please ? (maybe you already done it - just making sure !)

client/client.go Outdated
@@ -248,6 +250,14 @@ func WithSchemeID(schID string) Option {
}
}

// WithBeaconID indicates the id for the randomness generation process which will be queried
func WithBeaconID(beaconID string) Option {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep - so we should remove this option and just let the client knows it via the chain info, do we agree ?

core/drand_control.go Show resolved Hide resolved
if err != nil {
return fmt.Errorf("invalid hash info hex: %v", err)
}
if !bytes.Equal(info.Hash(), hash) {
return errors.New("invalid chain info hash")
}
if beaconID != info.ID {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be nice to test as well - if realistically possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if this would be change in the future, or not. StartFollowChain fetch chain info from other nodes without any specific value. If we have more than one chain info (on multi beacon), we need to be able to choose among them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean you're right to check this here we need to do this even more in the case of multi beacons - so maybe it's enough to test this in your multi beacon PR

key/group.go Show resolved Hide resolved
@willscott willscott merged commit f2ee959 into drand:master Oct 20, 2021
@emmanuelm41 emmanuelm41 deleted the beacon-id branch October 20, 2021 23:57
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.

None yet

3 participants