From e1419d1787ae551999dd8c4e123115c0b62a4a06 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 12 Dec 2022 13:03:41 -0700 Subject: [PATCH] contact-store: no-op if adding old contact %contact-store is responsible for sending updates about contacts, eg profile color. When it hears an update, it fans that out to its subsribers, unless that update is stale. If you reguarly fan out stale updates, then they reverberate across the network indefinitely -- we call this "echoing". To cut off this echoing, all edits have a timestamp, and we consider any updates from before this timestamp to be stale. Additions are separate from edits, and for them we instead do a value comparison on the contact -- if it didn't change, we consider the update stale. The problem with this scheme is that if an addition and edit happen one after the other in quick succession, you might have the following sequence: - add comes in with timestamp T1 - edit comes in with timestamp T2 after T1 - we hear an echo of the add, and that errantly applies because it passes our "did the contact actually change" check - we hear an echo of the edit, which applies because T2 is after T1 - GOTO 3 Each time we apply the stale update, we fan that out to our subscribers, and if any two hosts subscribe to each other, this will loop. This may even loop unconditionally because the ship that made the profile changes seems like it might not recognize that those changes didn't come from itself, so it sends them to all the groups it's in. If so, that's an important issue to fix. Fixes tloncorp/landscape-issues#1442 --- bin/multi-brass.pill | 4 ++-- pkg/landscape/app/contact-store.hoon | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/multi-brass.pill b/bin/multi-brass.pill index e1229bb75..d95c40bd6 100644 --- a/bin/multi-brass.pill +++ b/bin/multi-brass.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3306a5b916caa838c67cb079410c6e5bb158054520129ffb9f9bdb144ab1b691 -size 7418493 +oid sha256:ea8626444e4f0213e39c21ded20607145ee85a947afc592f182f46e7f598ef30 +size 7748671 diff --git a/pkg/landscape/app/contact-store.hoon b/pkg/landscape/app/contact-store.hoon index e3f750715..bac7cd9ec 100644 --- a/pkg/landscape/app/contact-store.hoon +++ b/pkg/landscape/app/contact-store.hoon @@ -123,7 +123,15 @@ :: ensure difference =/ old=(unit contact:store) (~(get by rolodex) ship) ?. ?| ?=(~ old) - !=(contact(last-updated *@da) u.old(last-updated *@da)) + :: if new contact is before existing contact, no-op + :: + :: NB: last-updated.contact is often *@da, so this + :: effectively stops add from applying if we already have + :: a contact for them + :: + ?& (gth last-updated.contact last-updated.u.old) + !=(contact(last-updated *@da) u.old(last-updated *@da)) + == == [~ state] ~| "cannot add a data url to cover!"