Derive VanguardMode from VanguardParams and has_onion_svc
From #tor-dev
2024-04-11 11:24:25 * gabi took a detour from vanguard persistence to hack on parts of arti#1272. I feel like we don't actually need a vanguards config at this point. ISTM all the configuration comes from the NetParameters (which can be overriden in the config)
2024-04-11 11:24:26 -- Notice(tor): https://gitlab.torproject.org/tpo/core/arti/-/issues/1272 - Add vanguard configuration options
2024-04-11 12:15:46 +nickm gabi: I think you're likely right wrt configuration.
2024-04-11 12:16:24 gabi ack. I think I'll remove the VanguardConfig for now (right now it's just an empty struct)
2024-04-11 12:16:25 +nickm gabi: Sometimes we might want to provide a more ergonomic way to override consensus parameters, but I don't think this is one of those times
2024-04-11 12:16:32 gabi right
So this ticket is about
- removing the
VanguardConfig
and deriving theVanguardMode
from theVanguardParams
like so/// Get the current [`VanguardMode`]. /// /// If we are not running an onion service, we use the `vanguards_enabled` mode. /// /// If we *are* running an onion service, we use whichever of `vanguards_hs_service` /// and `vanguards_enabled` is higher for all our onion service circuits. fn mode(&self) -> VanguardMode { if self.has_onion_svc { std::cmp::max( self.params.vanguards_enabled(), self.params.vanguards_hs_service(), ) } else { self.params.vanguards_enabled() } }
has_onion_svc
is a boolean value specifying whether arti is running as an onion service or not. For context, see torspec!258 (comment 3011734) - setting
has_onion_svc
in theVanguardMgr
totrue
orfalse
, depending on whether the config enables an onion service or not (this also needs to be handled inreconfigure()
).
This will likely involve rethinking our reconfigure()
APIs. Currently, reconfigure()
takes a &TorClientConfig
, which doesn't contain the onion svc config, so when the VanguardMgr
is reconfigure()
d in response to a config change, we have no way of telling if its has_onion_svc
flag needs to be updated.
Moreover, in !2035 (merged), the vanguards API was designed to purge all HS circuits on vanguard "mode" changes. However, that design assumed the vanguard mode (full/lite/disabled) would be read from the config, which will no longer be true after this ticket is implemented (the vanguard mode will be derived from the consensus params and the onion svc config). The VanguardMgr
will need to be able to notify the HsCircPool
that it needs to retire all circuits whenever the vanguard mode changes (which can be due to a config change or a consensus change).