update Announcement "timestamp": sequence number? #1767
Labels
No Label
0.2.0
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0
0.6.1
0.7.0
0.8.0
0.9.0
1.0.0
1.1.0
1.10.0
1.10.1
1.10.2
1.10a2
1.11.0
1.12.0
1.12.1
1.13.0
1.14.0
1.15.0
1.15.1
1.2.0
1.3.0
1.4.1
1.5.0
1.6.0
1.6.1
1.7.0
1.7.1
1.7β
1.8.0
1.8.1
1.8.2
1.8.3
1.8β
1.9.0
1.9.0-s3branch
1.9.0a1
1.9.0a2
1.9.0b1
1.9.1
1.9.2
1.9.2a1
LeastAuthority.com automation
blocker
cannot reproduce
cloud-branch
code
code-dirnodes
code-encoding
code-frontend
code-frontend-cli
code-frontend-ftp-sftp
code-frontend-magic-folder
code-frontend-web
code-mutable
code-network
code-nodeadmin
code-peerselection
code-storage
contrib
critical
defect
dev-infrastructure
documentation
duplicate
enhancement
fixed
invalid
major
minor
n/a
normal
operational
packaging
somebody else's problem
supercritical
task
trivial
unknown
was already fixed
website
wontfix
worksforme
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#1767
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
One proposal that came out of #1765 was to change the current
Announcement's "timestamp"-like field to be a sequence number
instead of an actual clock value. This field is used by both the
Introducer (server) and the IntroducerClient to decide when to
replace a previous announcement with the same (pubkey, servicename)
index, so it needs to be orderable and mostly
monotonically-increasing. (it's ok if a publisher briefly uses a
lower value than it did previously, as long as it's also ok for
other subscribers to ignore that message, which generally means the
publisher needs to periodically update their messages).
A timestamp (plus periodic updates) is a simple, cheap way to
achieve this property. The only rollback would be for a timequake
(when the publisher's clock has been adjusted backwards, maybe by
NTP being turned on for the first time), and that will eventually
be resolved when the new-time increases beyond the old-time of the
last update (so rolling the clock back by one hour means one hour
of stale announcements).
#1765 specifically discourages comparing this "timestamp" against
anybody else's clock (since clocks are never really synchronized).
So it really doesn't need to be a clock: it could just be a
sequence number. The advantage of a seqnum would be that it would
reveal less information about the client (which might help a
de-anonymyzing attacker correlate the tahoe node's behavior with
other externally-visible things).
The disadvantage is that we'd have to manage the counter ourselves,
and tolerate node restarts which don't maintain the saved counter
state. We want to make sure folks can back up their nodes by just
recording some static private keys, and don't need to constantly be
saving their updated counters.
The proposal is to do the following:
IntroducerClient.publish
is calledto one greater than the received value, and re-publish
message body is different, do the same: set the counter to one
greater than the received value, and re-publish
identical), do nothing
In conjunction with the gossip protocol from #1765, that ought to
converge. Nodes that are restored from backup (and thus experience
a "counterquake") will send stale announcements for a little while
(which everyone else will ignore) until they hear back their own
earlier (higher-seqnum) announcements, at which point they'll
advance their counters enough to become fresh again.
One requirement this imposes on clients is that anyone who
publishes a record for service-name=X must also subscribe to
service-name=X. Otherwise they won't know to update their counters
after a counterquake. Alternatively, we could require that anyone
else who receives message they recognize as stale must immediately
send back the fresh version, even if the publisher wasn't
subscribed to hear about them. This would require some changes to
the APIs, as publishers and subscribers are quite distinct right
now.
It might be easier if we only had one counter for the whole node,
instead of separate counters for each service-name. Then receipt of
any message with a higher counter would trigger the updates.
(when gossip-introduction happens, all nodes will subscribe to
"grid-control", so we don't need to require specific loopback
rules). My concern is that we might announce (counter=0,
service-name=storage, data=X) and (counter=0,
service-name=grid-control, data=Y), then have a quake, then some
small thing changes about the storage server but not about
grid-control. When the node comes back, it will announce
(counter=0, storage, data=Z) but still (counter=0, grid-control,
data=Y). If we aren't subscribed to "storage", we'll see the
grid-control loopback and conclude that we've converged, and not
replace the stale storage/data=X announcement. Maybe requiring a
nonce be added to grid-control messages would avoid this.
I want to get this change into 1.10, even though the #68/#1765
gossip-introducer won't happen until later, so that old 1.10
clients can continue to correctly update themselves in a gossipy
world. Also, since the current implementation uses a clock, I'd
like to switch to smaller integers as quickly as possible, so there
are fewer nodes which have ever used a (large) time.time() and will
thus have problems updating those announcements.
+1
The current code (in revision changeset:15c95c2e) uses
time.time()
, so this proposed change has not yet been implemented.fixed some typos in the description.
Two other thoughts:
The one-counter-per-node variant seems simplest.
I wanted to make sure this makes it into 1.10, as it makes forward-compatibility easier.
Let's open a separate ticket for subscribing to announcements about your own types of services, noticing an announcement about yourself, and updating your counter to be newer than the counter in that announcement.
I didn't understand the weird issue about having a single counter per-node rather than one counter per service, and how this could lead to some subtle failure when one service has changed and another hasn't. Therefore, I concluded that having a counter per service is simpler. ☺
Brian wrote:
Ah, for "one-counter-per-node", I was thinking that the counter would be incremented whenever we encode a service announcement. So we would announce (counter=0, service-name=storage, data=X) then (counter=1, service-name=grid-control, data=Y), and the above situation couldn't occur.
Okay, I'm +½ on one-counter-per-node, with davidsarah's variant (increment the counter once per service), and I'm +½ on one-counter-per-service.
Hm. If we increment the counter with each announcement, we could still get into the same trap:
Also I think we'd need to store (at least in RAM) a separate counter for each service, so we could recognize when announcements are newer than anything we've ever created. Ideally we want the very first message from our previous life to trigger re-encodings of everything we might publish.
I'm +1 on one-counter-per-node. I think I'm +1 on using the same counter value for all announcements (i.e. every time we update any service, we increment the counter, write it to disk, then publish a full set of announcements for all services, all using the same counter value). Then if we hear back any announcement with a higher counter value, or an equal counter but different contents, we trigger new announcements with the next higher counter. I think that will let any single message-from-the-future trigger an update, and will also correctly ignore echoes of any current message. I'm also +1 on adding a nonce to each announcement (created when we encode the message, stored in RAM only, not persistent), so we can distinguish messages from two different reboots that happen to otherwise contain the same contents.
I thought of a better example. Suppose we have 4 services A/B/C/D, and we've been publishing them for a while:
Also, I'm thinking the nonce is important, and should basically be part of the counter. So every time you increment the counter, you also make a new nonce, and the announcement's seqnum= field is a two-element list of
(counter, nonce)
. The comparison rule says that recipients ignore announcements with counters that are lower than or equal than what they currently know about. They also ignore announcements which are identical to what they're currently heard. In the future, when a recipient sees a lower-or-equal counter in a non-identical announcement, they can send back a copy of their current copy, to let the sender know that they need to update their counter. The nonce distinguishes reuses of the same counter value (just without any sense of ordering).seqnum+nonce is the same trick I used in Foolscap during reconnections, to tell whether you're talking to the same peer that you were just connected to, or to a newly rebooted instance of that peer. I think we use similar rules over there.
Replying to warner:
AmmonRs: yeah, good point. I don't think there's much we could do about it.. even without sequence numbers, they could just keep re-publishing a bad address until the server admin gave up (sort of a manual version of the same attack).
I landed changeset:3e26c78e a few hours ago to close this. I've opened #1933 to cover the future-todo items listed above.