-
Notifications
You must be signed in to change notification settings - Fork 109
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
Conversation
Go version update
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
0dff8c2
to
5aca171
Compare
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set version?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 !)
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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_public.go
Outdated
response := chain.NewChainInfo(d.group).ToProto() | ||
response.Metadata = metadata | ||
response.Metadata.NodeVersion = d.version.ToProto() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then beacon_ID
?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 ?
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
b4ed1dc
to
a8153bc
Compare
No description provided.