-
Notifications
You must be signed in to change notification settings - Fork 132
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
feat: add support for configuring network protocol_id's #1093
Conversation
69b8891
to
9b07c0c
Compare
8976003
to
ea72788
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.
I appreciate the pr & work towards this direction. But imo we shouldn't merge any testnet implementation until ethereum/portal-network-specs#258 is approved by all client teams & merged
@njgheorghita By what is said between you and piper this PR and us even doing a testnet is in a deadlock now. This PR more has to do with configuring protocol ID's and I don't see how that a PR formalizing protocol_ids for a testnet blocks a pr allowing the option to configure protocol ID's. Being able to configure network parameters is a standard feature in all L1 clients. I can comprehend how we wouldn't want to formalize the testnet protocol_ids in our code, but that is 15 lines of 200. This code could have been reviewed and we could have just removed the 15 line testnet part instead of a blanket ignore because the word testnet was mentioned. Shouldn't by the same logic we should have blocked TraceGossip till it was merged into the spec and reviewed by all client teams? I don't see why 95% (configure protocol id's) of this PR is being blocked for 5% (15 lines of testnet parameters) I have removed the code relating to "testnet" from the PR so hopefully the code can be reviewed now |
31fab5d
to
2a37f22
Compare
I wouldn't categorize my opinion as "strong". Only that since we haven't done "testnet" yet my intuition is that actually doing the implementation will likely uncovers somes "unknown unknown" types of learning... but feel free to proceed however you guys feel is best. I think the only thing I have a "strong" opinion on is that we should not write the spec and then blindly implement the clients to follow the spec. Lets make sure that client implementation learnings are actively used to influence the specification because things don't always unfold the way we expect them to. |
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 kurtosis could be useful in testing this.
Something like...
- Spin up 3 trin nodes running testnet
- Spin up 3 trin nodes running mainnet
- Send a ping between the testnet & mainnet clients
- Spin up a bridge gossiping testnet data (eg epoch # 1)
- Spin up a bridge gossiping mainnet data (eg epoch # 2)
Test that the mainnet nodes only store epoch # 2 data, and testnet nodes only have epoch # 1 data.
We can test it with that and also add a test for it in peer tests. If you try to ping a testnet history node to a mainnet history node the ping will fail because the networks have different Discv5 TalkReq ids which is what we use to route messages with Assuming we use this proposal for running testnets* So the test could look like in peertests
|
55967aa
to
e34e9b6
Compare
e34e9b6
to
0a25f79
Compare
@njgheorghita @ogenev ready for a review I added the small peertest I talked about in the call and comment 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.
Looks pretty good, just a few comments on fn naming. But, I'd also like to hold off on merging this until after the db update is deployed, since this will require some changes to the cluster repo, and it'd be better to do the 2 somewhat significant changes in separate goes to isolate their effects/bugs from each other
ethportal-api/src/types/cli.rs
Outdated
match network_string { | ||
"mainnet" => Ok(MAINNET.clone()), | ||
"testnet" => Ok(TESTNET.clone()), | ||
_ => Err(format!("Not a valid network: {network_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.
"Not a valid network: {network_string}, must be 'testnet' or 'mainnet'"
let mut portal_networks = BiHashMap::new(); | ||
portal_networks.insert(ProtocolId::State, "0x501A".to_string()); | ||
portal_networks.insert(ProtocolId::History, "0x501B".to_string()); | ||
portal_networks.insert(ProtocolId::TransactionGossip, "0x501C".to_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.
I don't see any reason to include TransactionGossip
& CanonicalIndices
?
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 it is included in our mainnet code
} | ||
|
||
#[test] | ||
fn protocol_id_encoding() { | ||
let hex = "0x500A"; | ||
let protocol_id = ProtocolId::from_str(hex).unwrap(); | ||
let expected_hex = hex_encode_upper(Vec::try_from(protocol_id).unwrap()); | ||
let protocol_id = MAINNET.portal_networks.get_by_right(hex).unwrap(); |
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'm not a huge fan of using the native BiHashMap
api. It's not obvious (without looking up the map &/or BiHashMap
source code), what these functions do (aka left vs. right)... Could you impl
something more intuitive, like get_protocol_id
/ get_protocol_id_hex
(or whatever fn name makes the most sense here)?
portalnet/src/events.rs
Outdated
let protocol_id = self | ||
.network_spec | ||
.portal_networks | ||
.get_by_right(&hex_encode_upper(request.protocol())); |
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.
Same here. Some custom impl
that has a more intuitive name would be better
@@ -100,7 +111,11 @@ pub async fn run_trin( | |||
beacon_event_tx, | |||
beacon_jsonrpc_tx, | |||
beacon_event_stream, | |||
) = if trin_config.networks.iter().any(|val| val == BEACON_NETWORK) { | |||
) = if trin_config | |||
.portal_subnetworks |
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.
Think we could also do a custom trin_config.portal_subnetwork.contains()
or something similar
tests/self_peertest.rs
Outdated
@@ -206,13 +206,22 @@ async fn peertest_state_offer_contract_bytecode() { | |||
#[tokio::test(flavor = "multi_thread")] | |||
#[serial] | |||
async fn peertest_state_recursive_gossip() { | |||
let (peertest, target, handle) = setup_peertest().await; | |||
let (peertest, target, handle) = setup_peertest(None).await; |
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 it would be a bit better to get rid of the Option
and just use "mainnet"
as the arg here
This PR requires 0 changes to the cluster repo, to my knowledge? Would it be possible to provide an explanation on how that conclusion was achieved? Maybe I am misunderstanding something. |
ready for another look |
Well, it's not a major change, but we'll need to update the |
What was wrong?
We aren't able to configure protocol_id in the case we want to support different networks like a testnet
How was it fixed?
This is basically the same thing we already did except we use a bidirectional map instead of trait conversions acting as a bidirectional map.
For storing mainnet/future network data we will use a folder structure I seen L1 clients use
trin/mainnet/...
trin/futurenetworkname/...
Now we can easily configure future networks