Skip to content

tor-guardmgr: Make lite vanguards work

gabi-250 requested to merge gabi-250/arti:vanguard-mgr-sets into main

The VanguardMgr now has a background task that

  • removes vanguards when their lifetime runs out
  • repopulates each VanguardSet with new vanguards when the number of vanguards drops below the target size of the set
  • handles NetDir changes, updating the vanguard set sizes as needed, and discarding any vanguards that are no longer in the consensus

Another major change is that VanguardSet no longer owns the TimeBoundVanguards it contains. Instead, it holds Weak references to the vanguards, which are now owned by the VanguardMgr. VanguardMgr keeps all TimeBoundVanguards, regardless of the Layer they're used in, in a "min"-heap, ordered by expiration timestamp (since we need to periodically remove the expired vanguards, and determine which vanguard will expire next, it was convenient to just put them all in VanguardMgr).

To test this patch, I had to extend TestNetDirProvider with a set_netdir_and_notify function that updates the underlying NetDir and causes DirEvent::NewConsensus event to fire.

Closes #1275 (closed) and #1340 (closed)

Merge request reports