Open softminus opened 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 }]"
]
}
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
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 }]
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).
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)
We have DNS serving working!
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
Banned
/Ignore
logic, use heuristics to prioritize what look like valid zcash peers for polling: we can simply look atpeer_derived_data
-- if that's notNone
it means we were able to negotiate a connection which means that it's probably better than nothingserde
Serving
Providing perfect per-peer polling
RetryConnection
ulimit -n
to a big numberulimit -n
set -- maybe don't start the fast walker? or actually we probably can use a semaphore (withulimit -n
's value minus like 256 or something like that) to limit in-flight connections in the fast walker? or we could just ignore this and just retry connections like mad until they succeed (or fail because of the network or the remote node)Interval/scheduling/timing stuff
PeerStats
structure for each peer and determines whether we should poll it or not, and filter the list of all known nodes with this function each time we iterate.Crawling
Unknown
classificationActual connection stuff
zebra-network
errorsEMFILE
errors)Extra credit
zcash
chain. this lets us robustly exclude chain forks like ZelCash/flux even if they didn't change the network magicpeer_derived_data
toNone
after a bunch of connections have failed (we could use the EWMAs for this -- if it's not been reachable for a long while it's no longer worth keeping that info around)? not sureCode cleanup
Observability
User interface