softminus / zcash-cotyledon

rust zcash seeder
MIT License
0 stars 0 forks source link

Roadmap towards MVP seeder in Rust #1

Open softminus opened 2 years ago

softminus commented 2 years ago

Let's think step-by-step:

General strategy

If we don't know how to implement it, go with something simpler. If we don't know what to implement, go with what the original zcash seeder or with what the ZF seeder https://github.com/ZcashFoundation/dnsseeder does.

Loops and state

Serving

Providing perfect per-peer polling

Interval/scheduling/timing stuff

Crawling

Actual connection stuff

Extra credit

Code cleanup

Observability

User interface

softminus commented 2 years ago

With d91b3df4ece3bc5b17d78b21ccfdf8b85e01f55c we are serving something over the network that is derived from the live peer set and its statistics! we don't yet do crawling nor keep detailed/granular statistics, so the peer set is hardcoded, and it's not quite machine-parseable but I have learned enough Rust to connect all these moving parts so far!

sasha_work@seasonal-dream zcash-cotyledon % grpcurl -plaintext -import-path ./proto -proto seeds.proto 127.0.0.1:50051 seeder.Seeder/Seed
{
  "IP": [
    "[PeerStats { address: 34.127.5.144:8233, attempts: 8, successes: 7 }, PeerStats { address: 157.245.172.190:8233, attempts: 8, successes: 7 }]"
  ]
}
softminus commented 2 years ago

I have the multi-scale EWMA calculations working! (though to be perfectly honest I do not quite understand the role of the count and weight tracked variables) https://github.com/superbaud/zcash-cotyledon/commit/31fd4c7b9c975844a8c3ee8b435e4e01a5d5877c

softminus commented 2 years ago

Running into something weird with the Peers replies -- I'm not getting multiple peers anymore:

Starting new connection: peer addr is 157.245.172.190:8233
peers response: Peers { peers: 1 }
peers is: [MetaAddr { addr: 157.245.172.190:8233, services: Some(NODE_NETWORK), untrusted_last_seen: Some(DateTime32 { timestamp: 1666049426, calendar: 2022-10-17T23:30:26Z }), last_response: None, last_attempt: None, last_failure: None, last_connection_state: NeverAttemptedGossiped }]
softminus commented 2 years ago

OK, since the getaddr command seems to be rate-limited (by AVG_ADDRESS_BROADCAST_INTERVAL) -- let's not use that to check if the node is live (BlocksByHash isn't rate-limited at all).

softminus commented 2 years ago

i think i want to slightly change how crawling works; by creating a pending work queue (of IPs to query) and having it be separate from the HashMap (which once i have some other stuff working, i'll figure out how to save/restore from disk, undecided yet whether to use serde or learn how to use sqlite) that keeps track of all the nodes about, and so we can add new peers into the work queue as we find them (and also add them into the HashMap) while we are doing crawling vs needing to separate and batch crawling and updating (because we can't modify the HashMap while we're iterating over it)

softminus commented 2 years ago

We have DNS serving working!