-
Notifications
You must be signed in to change notification settings - Fork 12
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
Improve network error handling #148
Improve network error handling #148
Conversation
b41027f
to
3aa2b49
Compare
3aa2b49
to
e33f28b
Compare
anchor/network/src/discovery.rs
Outdated
pub enum DiscoveryError { | ||
#[error("Failed to parse keypair into an ENR key: {0}")] | ||
EnrKey(String), | ||
|
||
#[error("Failed to build ENR: {0}")] | ||
EnrBuild(String), | ||
|
||
#[error("Discv5 initialization error: {0}")] | ||
Discv5Init(String), | ||
|
||
#[error("Discv5 start error: {0}")] | ||
Discv5Start(String), | ||
} |
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.
Do these all need to be String
? Actual error types should be a bit clearer and should not affect the displayed message as the format string uses the Display
impl of the inner type, which is the same thing as the to_string
that you manually call below.
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.
Do you mean the original error? If so, that's the type of the original errors, like in https://github.com/sigp/lighthouse/blob/stable/beacon_node/lighthouse_network/src/discovery/enr_ext.rs#L281
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.
Good catch, thanks. I changed it for EnrBuild
and I'll double-check the others.
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.
Hopefully I covered everything now
bitfield.set(9, true).unwrap(); | ||
|
||
builder.add_value::<Bytes>("subnets", &bitfield.as_ssz_bytes().into()); | ||
builder.add_value::<Bytes>("subnets", &BitVector::<U128>::new().as_ssz_bytes().into()); |
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.
@dknopik This is about what we talked yesterday. Should we create an empty BitVector
at this point?
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, the subnets will be updates as the subnet tracker messages come in: 9e9e485
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.
as always, open for other suggestions though
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.
From what I understand, it makes sense.
423fcbf
to
5b3a009
Compare
0d97c23
to
07455cc
Compare
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.
lgtm
Issue Addressed
closes #75
Proposed Changes
This PR aims to improve network error handling. The key technical changes proposed include:
thiserror
.