Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug24977 final #146

Closed
wants to merge 7 commits into from
Closed

Bug24977 final #146

wants to merge 7 commits into from

Conversation

asn-d6
Copy link
Member

@asn-d6 asn-d6 commented Jun 13, 2018

No description provided.

Here is how this changes the HSv3 client-side and service-side:

For service side we already required live consensus to upload descriptors (see
9e900d1) so we should never get there without
a live consensus.

For the client-side we now require a live consensus to attempt to connect to
HS.  While this changes the client behavior in principle, it doesn't really
change it, because we always required live consensus to set HSDir indices, so
before this patch a client with no live consensus would try to compute
responsible HSDirs without any HSDir indices and bug out. This makes the client
behavior more consistent, by requiring a live consensus (and hence a
semi-synced clock) for the client to connect to an HS entirely.

The alternative would have been to allow setting HSDir indices with a non-live
consensus, but this would cause the various problems outlined by commit
b89d2fa.
We currently only do the check when we are about to use the HSDir indices.
@coveralls
Copy link

coveralls commented Jun 13, 2018

Coverage Status

Coverage increased (+0.03%) to 59.894% when pulling 82bb4f3 on asn-d6:bug24977_final into 1b04dab on torproject:master.

* newer consensus, make sure we recalculate the voting schedule. */
networkstatus_t *consensus = networkstatus_get_live_consensus(approx_time());
if (consensus &&
consensus->valid_after != voting_schedule.live_consensus_valid_after) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to use a else if somehow so we avoid all this code if the first condition was hit which would recalculate the voting schedule in the first place?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Took the goto approach in 82bb4f3 to avoid the extra indentation of else if. Let me know if you hate it, and I will just use else if.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK


/* Also make sure we are not using an outdated voting schedule. If we have a
* newer consensus, make sure we recalculate the voting schedule. */
networkstatus_t *consensus = networkstatus_get_live_consensus(approx_time());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would const that if possible.

Also, approx_time() is used twice in this function so probably a time_t now is desirable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 222c5cf.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

}

if (need_to_recalculate_voting_schedule) {
voting_schedule_recalculate_timing(get_options(), approx_time());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold on a sec. Don't we have a circular loop here? get_voting_schedule() can reach this point and then voting_schedule_recalculate_timing() calls get_voting_schedule() again so we do this whole path over and over again?

I actually wonder if the right approach would be to have a getter for the voting_schedule static object that makes sure it is not out of date. So no where we should use that object directly but rather get the ref through the getter assuring us that it is updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, trying to understand this better: How can get_voting_schedule() reach voting_schedule_get_next_valid_after_time()? They seem disconnected to me.

No?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh oops... my brain failed to parse that voting_schedule_get_start_of_next_interval() (in get_voting_schedule()) != voting_schedule_get_next_valid_after_time() :P...

NVM.


/* We don't even have a recent consensus: this is a NOP */
networkstatus_t *ns = networkstatus_get_live_consensus(approx_time());
if (!ns) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we can't call this without a live consensus. Should we BUG() here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done in aa951c7.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@@ -29,6 +29,7 @@ const node_t *node_get_by_hex_id(const char *identity_digest,
node_t *nodelist_set_routerinfo(routerinfo_t *ri, routerinfo_t **ri_old_out);
node_t *nodelist_add_microdesc(microdesc_t *md);
void nodelist_set_consensus(networkstatus_t *ns);
void ensure_nodelist_freshness(void);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose we namespace this one starting with nodelist_.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done in aa951c7.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@teor2345
Copy link
Contributor

Closed on trac

@teor2345 teor2345 closed this Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants