-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(discv5): get fork_id from Enr for all network stacks
#18988
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
Conversation
mattsse
left a comment
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
pending @emhane
|
@mablr could you pls find out if op-geth adheres to specs and sets the fork id key as 'opel' or if it still sets 'eth'? otherwise it may have trouble to connect to the bootnodes. possibly we can just assume not every node will set it correctly and relax the passing criteria as |
|
@emhane That's right, op-geth still sets the fork id key to "eth". On the side on reth I see you created a reth/crates/net/discv5/src/config.rs Lines 246 to 247 in 169a1fb
so according to what I understand the rest of keys are accepted. Tested locally by spawning a op-geth and reth instances : ./build/bin/geth --discv5 --port 30305 --discovery.port 9202 |
|
thanks @mablr ! ETH is EL and ETH2 is CL. ok so based on op-geth behaviour, let's do this reth/crates/net/discv5/src/lib.rs Lines 387 to 391 in 856ad08
we want to do smthg like this let Some(key) = self.fork_key else { return Err(Error::NetworkStackIdNotConfigured) };
let fork_id = enr
.get_decodable::<EnrForkIdEntry>(key)
.ok_or(enr
.get_decodable::<EnrForkIdEntry>(NetworkStackId::ETH)
.ok_or(Error::ForkMissing(key)?
)?
.map(Into::into)?;the syntax in my example is a bit off but I think you get the point? would you mind implementing it? would be good if we had a trace log for the case when the configured key isn't found. we will also need to change the error message for |
- added some tracing on fork id retrieval failure - updated `ForkMissing` error message
|
Thank you very much @emhane for the pointers. The metrics are incremented based on peer's Enr, I guess this is ok: reth/crates/net/discv5/src/metrics.rs Lines 125 to 137 in 169a1fb
|
emhane
left a comment
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.
nice! nitpicks remaining
Co-authored-by: emhane <elsaemiliaevahane@gmail.com>
crates/net/discv5/src/lib.rs
Outdated
| "fork id not found for '{key}' network stack id, trying 'eth'", | ||
| key = String::from_utf8_lossy(key), | ||
| ); | ||
| trace!(target: "net::discv5", "Fork id not found for key, trying 'eth'..."); |
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.
| trace!(target: "net::discv5", "Fork id not found for key, trying 'eth'..."); | |
| trace!(target: "net::discv5", | |
| key = String::from_utf8_lossy(key), | |
| "Fork id not found for key, trying 'eth'..." | |
| ); |
excuse me if wasn't clear, we want to keep the key kv-pair like it was!
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.
no problem, I reverted it. Assuming decoding here is useful.
…mxyz#18988) Co-authored-by: emhane <elsaemiliaevahane@gmail.com> Co-authored-by: Emilia Hane <emiliaha95@gmail.com>
…mxyz#18988) Co-authored-by: emhane <elsaemiliaevahane@gmail.com> Co-authored-by: Emilia Hane <emiliaha95@gmail.com>


Fix #18924