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
Replace the Seeder #3881
Comments
i'm currently trying to code up a seeder in Rust using zebra's networking crates: https://github.com/superbaud/zcash-cotyledon |
i have it connecting to nodes; though it exits immediately afterward. softminus/zcash-cotyledon@fa66767 |
Per the zebra book, the |
Also ZF has a dns seeder written in Go https://github.com/ZcashFoundation/dnsseeder (putting this down so i dont forget myself) |
Hey @superbaud I'm one of the Zebra engineers, I've done a bit of work on Here are some things that might help, feel free to ping me on the Zcash discord if you have questions!
It looks like you're blocking on the result of That result is a: Future<Output = (
Buffer<BoxService<Request, Response, BoxError>, Request>,
Arc<std::sync::Mutex<AddressBook>>,
)> So the (
Buffer<BoxService<Request, Response, BoxError>, Request>,
Arc<std::sync::Mutex<AddressBook>>,
) https://github.com/superbaud/zcash-cotyledon/blob/main/src/main.rs#L54 The So you'll need some way to access the background tasks:
You can monitor progress via the You can also check for permanent failures via
The default 75 outbound connection limit should be ok. You might want to set it higher if some peers are dropped from the active list, because Zebra has reached the connection limit with stable connections. (Zebra filters peers from We could also implement some kind of peer churn, or add a method with a different time filter. Let us know if we can help here! |
Thank you very much; this gives a good overall view of the features of the codebase that i'm gonna want to hook into! I do have an issue I'm a bit stuck on -- I pushed some new code (basically a version of
and it's a bit confusing because I can see that in Zebra, the result of Obviously I'm going to keep trying to figure this out but if you see something obvious I'd be grateful if you could let me know! |
So if you wrap your inbound service in a let inbound = ServiceBuilder::new().load_shed().buffer(MAX_INBOUND_CONCURRENCY).service(Inbound::new(setup_rx)); As an alternative, you could replace the |
Ohhhhh, I had removed the |
Got it compiling and replying to |
We just wrote up a Zebra startup doc, you might find the peer handling section useful. |
So it doesn't work quite yet for bootstrapping as a "fixed seed node" (by removing
to I do see the If we're going with the plan to use HTTP/gRPC-style seeding we shouldn't actually need to figure this out but I am curious why zcashd isn't able to use the peer IPs it gets from the fixed seed node (or if there's another problem with the way i'm using |
It's possible there is a bug in Zebra's A bug like that could also explain this known Zebra issue: |
Oh interesting, thanks for pointing me at that, I'm going to try and look deeper at what zcashd does on startup when I'm pointing it at a |
Please let us know if you find anything, it could be a really simple fix on our end. |
I had just started hacking on a Rust DNS seeder myself this evening for some downtime relaxation, and then while also trying to figure out
@superbaud I think you are misunderstanding how the current seeders operate: they are not in-band seed nodes. That is, The current DNS seeders work by crawling in-band for peers, and then seeding those peers out-of-band, specifically via DNS. The OP suggests seeding via other more secure avenues, but the actual medium doesn't really matter too much for the purpose of structuring the seeder. I'll specifically describe how
|
Thanks for the detailed writeup about the extant seeder, it does clarify what the code is doing!
That makes sense. I understand that it's not what the https://github.com/zcash/zcash-seeder code does, but I had seen the The crawling you described in the extant
|
Ah, that makes sense. And it doesn't work as an address-only seeder because that field is to hard-code some full nodes in the network that can bootstrap new nodes - they "seed" both addresses and blocks. Any fixed nodes added there need to be nodes that the DNS seeders would have considered "good". It's also equivalent to telling people to connect to the network by adding
The reason for that port filtering is because the seeders can't advertise ports over DNS, so clients need to be able to predict it. It would make sense for a more capable seeder to try and identify good peers that are on any port, and then sub-select only default-port peers for DNS seeding (if configured). The main issue I see with reusing the |
I'm wondering how easy it'd be (without needing to make the seeder a full syncing node by itself) to verify that the good peers are actually synced to the zcash blockchain rather than a different blockchain that's using the same network magic and version strings that look vaguely similar (like
Makes sense; I think this week I'll try and figure out how to implement a more appropriate peer set strategy in rust. |
We could also modify zebra-network so it can be configured to disconnect from peers more rapidly. For example, we could pass a disconnection function on peer set initialisation. Then before each request, we call the disconnection function with the peer address, version, and connection creation time. Then for a seeder, you tell zebra-network to disconnect from peers after 30 seconds. (Or whatever time you want.) |
@superbaud are these zebra-network changes something that would be helpful? (They'd be really quick for us to do.) |
By "before each request" you mean "triggered when there's a message from the peer" or "before each message initiated internally towards the peer"? If it's the latter, how would we make sure that the disconnection function would get called frequently enough? |
The peer set would check all peers, before it routes any request to any peer. (We do our existing peer readiness and version checks this way, and they work well.) Since zebra-network crawls the peer set for new addresses every minute, every peer would get checked at least that often. (You can adjust this interval using We could also add a specific |
I tried to do this, but it seems like I need to rewrite it as a trait, because Rust's function generics are a bit tricky. I'm going to be busy for a few days, but I should be able to get back to it next week. |
I'm not sure, to be honest, I think for the seeder itself it'd be easier to use |
No worries, happy to do whatever is easiest for you. Please let us know if you run into any issues! |
There's some peer metadata which we need access to (from the
I see there's a The place where |
I'll see if I can change |
Also, would it be reasonable to write up a patch to augment |
In Zebra we try to track serialized data, per-connection data, and inbound/outbound connection data separately. The current design is roughly:
So I think we might want to do something like:
Would that work for how you want to use |
I think so (I hadn't seen The reason I suggested |
Just letting you know that I'm starting on this today. Sorry it has taken longer than I thought, we've been tuning up Zebra to deal with the extra transaction load on the network. |
No worries and thanks; let me know if I can help out or give feedback or anything. |
I just opened a draft PR with these changes today: Here's what's in the PR:
Here's what we still have to do:
Once you're happy with the metadata, it should be pretty easy to add it to Sorry this has taken a while, network load and Zcon have been taking up most of my time! |
Oh and if you need any extra |
I'm going to look at that PR today and give feedback, thank you so much for working on it! |
Added my feedback comment on the PR itself: ZcashFoundation/zebra#4870 (comment) |
@softminus just wondering how the DNS seeder is going? The Zebra team might have some time to work on the DNS seeder itself or Would you like some help finishing it off? How much work is left, do you think? I'm happy to chat over Discord or my zfnd.org email if that's easier, I'm teor on both. |
Hey, sorry I didn't get around to replying to this until now; https://github.com/softminus/zcash-cotyledon is the repo I'm working on and it does sort of work but I am in the middle of a refactor to try and make it so the probe/criteria parameters can be adjusted in a config file vs hardcoded. I would definitely be up to working together to finish it off or even just chatting about it, let me know when would work for you. |
Sounds great!
We're still in the planning stages ourselves, we might end up with slightly different ways of scanning the network and putting it all into an application. Because we know We haven't decided on the DNS server we're going to use yet. Here's one possible DNS server, do you know of any others? |
The existing Zcash seeder is written in C (a type- and memory- unsafe language) and would be more expensive to secure to an appropriate standard as-is than it would be to replace it with a more modern equivalent.
Additionally, it does not provide cryptographic authenticity or integrity over the data it provides to clients, and so clients rely on the data not being modified in transit.
We should replace the seeder with one that provides end-to-end cryptographic authenticity and integrity over the data it provides, write it in Rust (a language that provides type and memory safety features, and one that the ECC team has experience with).
The new version should provide data over a web framework instead of DNS, and take advantage of ECC’s CloudFlare distribution in order to cache results to make the system less susceptible to denial-of-service attacks.
Extra data types such as notary data (ticket number #FILL_IN_THIS_TICKET_NUMBER), time data, or future data distribution could be performed using this system quite simply, without requiring protocol additions (as would be the case with a seeder using the DNS protocol).
Without a change to the peer networking protocol between Zcash peers, the system of seeding cannot provide coverage of eclipse and sybil attacks, however to provide such coverage, this ticket will need to be completed, and the resulting system will be compatible with any such peer-to-peer network upgrades.
ECC does not intend to remain the sole authoritative supplier of network nodes for seeding purposes and so another requirement of this work is that it be distributable among other seeder nodes that users could decide to trust via a configuration change.
The text was updated successfully, but these errors were encountered: