Skip to content

tor-guardmgr: Persist the vanguard sets if running in full vanguard mode

gabi-250 requested to merge gabi-250/arti:vanguard-set-persistence into main

VanguardMgr now supports running in "full" vanguard mode:

  • I replaced VanguardSet::new with VanguardSet::default: VanguardSet::new() took a set of VanguardParams (from which it derived the target size of the set), but the VanguardSets are supposed to be initialized on startup, when we don't have a VanguardParams (we don't have the params until we obtain a NetDir). Moreover, it doesn't make sense to even set the target size of the VanguardSet before obtaining a NetDir, because we can't actually populate the set without a NetDir (we can't select relays).
  • VanguardMgr no longer has direct access to its VanguardSets. It now holds a VanguardSets (not to be confused with VanguardSet) which is an abstraction over the L2 and L3 vanguard sets. Storing the two sets in VanguardSets makes them easier to serialize and deserialize. It also enables us to track vanguard changes more easily (via VanguardSetsTrackedMut)
  • VanguardSets can't be directly mutated by VanguardMgr. Instead, they are mutated through a VanguardSetsTrackedMut handle, which enables us to track the VanguardSets was actually mutated. This is useful because we only want to flush the VanguardSets to storage if we added or removed some relays
  • I moved some of the vanguard management logic to VanguardSets. I think this makes the code easier to follow.

Closes #1273 (closed)

Merge request reports