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

fix: use default angelfood bootnodes if network is selected #1463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

njgheorghita
Copy link
Collaborator

@njgheorghita njgheorghita commented Sep 18, 2024

What was wrong?

fixes #1460

How was it fixed?

Added angelfood bootnodes and logic to handle the correct bootnodes depending on what network's selected.

To-Do

Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit: I think it is weird to be able to use mainnet bootnodes on angelfood or the inverse. But I definitely think this PR is an big improvement on what we currently have.

@morph-dev
Copy link
Collaborator

I also don't like that there is "angelfood" as an option. Somebody can just call --bootnodes=angelfood and since mainnet is default network, this would not really work in practice.

In my opinion, "default" bootnodes would depend on the Network.
The way it would work is that instead of having impl From<Bootnodes> for Vec<Enr>, we would have:

impl Bootnodes {
    pub fn to_enrs(&self, network: Network) -> Vec<Enr> {
        let bootnodes: &Vec<Bootnode> = match (self, network) {
            (Bootnodes::Default, Network::Mainnet) => &DEFAULT_BOOTNODES,
            (Bootnodes::Default, Network::Angelfood) => &ANGELFOOD_BOOTNODES,
            (Bootnodes::None, _) => &vec![],
            (Bootnodes::Custom(bootnodes), _) => &bootnodes,
        };
        bootnodes.iter().map(|bn| bn.enr.clone()).collect()
    }
}

This breaks the PortalnetConfig, which doesn't have access the the network. To solve that problem, we can either:

  • change PortalnetConfig.bootnodes to be Vec<Enr>, as all uses that I found are like:
    let bootnode_enrs: Vec<Enr> = portal_config.bootnodes.into();
  • add network field to PortalnetConfig

I personally might have slight preference towards the first one.

If I missed something and it's not so simple, feel free to merge it as it is now.

@KolbyML
Copy link
Member

KolbyML commented Sep 19, 2024

I also don't like that there is "angelfood" as an option. Somebody can just call --bootnodes=angelfood and since mainnet is default network, this would not really work in practice.

In my opinion, "default" bootnodes would depend on the Network. The way it would work is that instead of having impl From<Bootnodes> for Vec<Enr>, we would have:

impl Bootnodes {
    pub fn to_enrs(&self, network: Network) -> Vec<Enr> {
        let bootnodes: &Vec<Bootnode> = match (self, network) {
            (Bootnodes::Default, Network::Mainnet) => &DEFAULT_BOOTNODES,
            (Bootnodes::Default, Network::Angelfood) => &ANGELFOOD_BOOTNODES,
            (Bootnodes::None, _) => &vec![],
            (Bootnodes::Custom(bootnodes), _) => &bootnodes,
        };
        bootnodes.iter().map(|bn| bn.enr.clone()).collect()
    }
}

This breaks the PortalnetConfig, which doesn't have access the the network. To solve that problem, we can either:

  • change PortalnetConfig.bootnodes to be Vec<Enr>, as all uses that I found are like:
    let bootnode_enrs: Vec<Enr> = portal_config.bootnodes.into();
  • add network field to PortalnetConfig

I personally might have slight preference towards the first one.

If I missed something and it's not so simple, feel free to merge it as it is now.

I really like this direction

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.

Properly handle Bootnodes for Mainnet and Angelfood networks
3 participants