Implement proposal 275: don't put "published" times in md consensus

When a new consensus method is negotiated, these values will all get
replaced with "2038-01-01 00:00:00".

This change should be safe because:

  * As of 0.2.9.11 / 0.3.0.7 / 0.3.1.1-alpha, Tor takes no action
    about published_on times in the future.

  * The only remaining parties relying on published_on values are (we
    believe) relays running 0.3.5.x, which rely on the values in a NS
    consensus to see whether their descriptors are out of date.  But
    this patch only changes microdesc consensuses.

  * The latest Tor no longer looks at this field in consensuses.

Why make this change?  In experiments, replacing these values with a
fixed value made the size of compressed consensus diffs much much
smaller.  (Like, by over 50%!)

Implements proposal 275; Implements #40130.
This commit is contained in:
Nick Mathewson 2021-11-09 13:43:48 -05:00
parent 1d2c918dfd
commit 96f1e69f24
4 changed files with 35 additions and 3 deletions

12
changes/prop275 Normal file
View File

@ -0,0 +1,12 @@
o Minor features (directory authority):
- Add a new consensus method in which the "published" times on router
entries in a microdesc consensus are all set to a meaningless fixed
date. Doing this will make the download size for compressed microdesc
consensus diffs much smaller.
Part of ticket 40130; implements proposal 275.
o Minor features (network documents):
- Clients and relays no longer track the "published on" time declared
for relays in any consensus documents. When reporting this time on
the control port, they instead report a fixed date in the future.
Part of ticket 40130.

View File

@ -2048,7 +2048,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
memcpy(rs_out.descriptor_digest, rs->status.descriptor_digest,
DIGEST_LEN);
tor_addr_copy(&rs_out.ipv4_addr, &rs->status.ipv4_addr);
time_t published_on = rs->published_on;
rs_out.ipv4_dirport = rs->status.ipv4_dirport;
rs_out.ipv4_orport = rs->status.ipv4_orport;
tor_addr_copy(&rs_out.ipv6_addr, &alt_orport.addr);
@ -2056,6 +2055,21 @@ networkstatus_compute_consensus(smartlist_t *votes,
rs_out.has_bandwidth = 0;
rs_out.has_exitsummary = 0;
time_t published_on = rs->published_on;
/* Starting with this consensus method, we no longer include a
meaningful published_on time for microdescriptor consensuses. This
makes their diffs smaller and more compressible.
We need to keep including a meaningful published_on time for NS
consensuses, however, until 035 relays are all obsolete. (They use
it for a purpose similar to the current StaleDesc flag.)
*/
if (consensus_method >= MIN_METHOD_TO_SUPPRESS_MD_PUBLISHED &&
flavor == FLAV_MICRODESC) {
published_on = -1;
}
if (chosen_name && !naming_conflict) {
strlcpy(rs_out.nickname, chosen_name, sizeof(rs_out.nickname));
} else {

View File

@ -53,7 +53,7 @@
#define MIN_SUPPORTED_CONSENSUS_METHOD 28
/** The highest consensus method that we currently support. */
#define MAX_SUPPORTED_CONSENSUS_METHOD 32
#define MAX_SUPPORTED_CONSENSUS_METHOD 33
/**
* Lowest consensus method where microdescriptor lines are put in canonical
@ -74,6 +74,12 @@
*/
#define MIN_METHOD_FOR_MIDDLEONLY 32
/**
* Lowest consensus method for which we suppress the published time in
* microdescriptor consensuses.
*/
#define MIN_METHOD_TO_SUPPRESS_MD_PUBLISHED 33
/** Default bandwidth to clip unmeasured bandwidths to using method >=
* MIN_METHOD_TO_CLIP_UNMEASURED_BW. (This is not a consensus method; do not
* get confused with the above macros.) */

View File

@ -58,7 +58,7 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
char digest64[BASE64_DIGEST_LEN+1];
smartlist_t *chunks = smartlist_new();
if (declared_publish_time != -1) {
if (declared_publish_time >= 0) {
format_iso_time(published, declared_publish_time);
} else if (vrs) {
format_iso_time(published, vrs->published_on);