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

Use the CandidateSet and AddressBook to connect to initial seed peers #2325

Closed
2 of 5 tasks
Tracked by #3247
teor2345 opened this issue Jun 16, 2021 · 1 comment
Closed
2 of 5 tasks
Tracked by #3247
Labels
A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup

Comments

@teor2345
Copy link
Contributor

teor2345 commented Jun 16, 2021

Motivation

Zebra has custom code that connects to all its initial seed peers on startup.

But we could use the AddressBook and CandidateSet to connect to these peers.

This would make the code simpler and more reliable. But we would need to maintain some existing security and reliability features of Zebra.

Specifications

When started for the first time, programs don’t know the IP addresses of any active full nodes. In order to discover some IP addresses, they query one or more DNS names (called DNS seeds) hardcoded into Bitcoin

https://developer.bitcoin.org/devguide/p2p_network.html#peer-discovery

Solution

Type Refactor

  • Add MetaAddrChange::NewSeed and PeerAddrState::NeverAttemptedSeed variants
    • these variants only have a SocketAddr
    • security: these variants must not be assigned the current time - having a None time makes sure Zebra checks their addresses before gossiping them (existing behaviour)

Function Refactor

  • In add_initial_peers, send the peers to the AddressBook
  • Make sure that the first connected peer gets an immediate Addrs request
    • reliability: on small networks and with small seed sets, Zebra must get more addresses from this peer to reliably connect to other nodes (existing behaviour)

Testing

  • Test Zebra with a single seed peer
    • add an acceptance test that launches a Zebra node with the default initial peers config
    • also launch a Zebra node with only that peer's inbound listener in its initial peers config
    • check they both sync genesis and connect to multiple other peers
  • Test Zebra launch reliability using the existing acceptance tests

Alternatives

We could implement the initial peers rate-limit by waiting for a short time between each initial peer connection, see #2326.

But the rest of this change is a refactor and cleanup.

@teor2345 teor2345 added A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup S-needs-triage Status: A bug report needs triage P-Low A-network Area: Network protocol updates or fixes labels Jun 16, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Jun 21, 2021
@teor2345
Copy link
Contributor Author

teor2345 commented Mar 1, 2022

This would be a useful simplification, but it's not required.

@teor2345 teor2345 closed this as completed Mar 1, 2022
@teor2345 teor2345 reopened this Jul 2, 2023
@teor2345 teor2345 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup
Projects
None yet
Development

No branches or pull requests

2 participants