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

Bug: cannot add relays #2293

Open
alltheseas opened this issue Jun 12, 2024 · 9 comments
Open

Bug: cannot add relays #2293

alltheseas opened this issue Jun 12, 2024 · 9 comments
Labels
bug Something is not working, or not working as intended Needs recreation Issues requires concrete steps for recreation relay workaround

Comments

@alltheseas
Copy link
Collaborator

alltheseas commented Jun 12, 2024

What happens
When I remove all relays but one, and I try to add I cannot successfully add a relay.

What I expect to happen
I expect to be able to add relays.

** Versions **
Damus version: 1.9 (7)

Steps to reproduce the behavior:

  1. Open Damus
  2. Add new relay (relay.zap.store)
  3. Remove all other relays
  4. Attempt to add relay
@alltheseas alltheseas added bug Something is not working, or not working as intended Needs recreation Issues requires concrete steps for recreation relay labels Jun 12, 2024
@alltheseas
Copy link
Collaborator Author

@danieldaquino I seem to remember this was an issue previously - where relays could not be added. Is this a regression?

@alltheseas
Copy link
Collaborator Author

Would first aid help here with restoring working relays?

@danieldaquino
Copy link
Contributor

Would first aid help here with restoring working relays?

Please do not use First Aid (yet), or you will lose your follow list.

I will try to repro your issue and see if I can find any workarounds to get your account working again.

@danieldaquino
Copy link
Contributor

Reproduced. Finding a workaround

@danieldaquino
Copy link
Contributor

@alltheseas one workaround that worked for me was to delete and reinstall Damus. This is probably the fastest workaround.

You would lose bookmarks if you did this, though.

If you don't want to lose bookmarks, I can prioritize creating a new first aid option (or a full fix if time permits).

Are you ok with reinstalling or do you prefer to wait a bit more for the first-aid/fix?

@alltheseas
Copy link
Collaborator Author

Works now, thanks.

what was the cause?

@danieldaquino
Copy link
Contributor

what was the cause?

  1. It fails to add a relay because it requires a contact list to be loaded on the app, but in this scenario it fails to load.
  2. The contact list fails to load for 2 reasons:
    1. The newly added relay does not have the contact list event
    2. In this particular scenario, damus_state.settings.latest_contact_event_id_hex is nil, meaning it could not load from NostrDB
  3. damus_state.settings.latest_contact_event_id_hex is nil for two reasons
    1. Under this scenario, the account was created before we introduced the changes from Confirm contact list creation during account creation #2057
    2. The ContactsDelegate protocol function latest_contact_event_changed (which is responsible for setting this value each time a new contact list is detected) should have been called at some point, but it seems like it hasn't been in this scenario. The reason why it wasn't is still unclear to me 🤔 it will require more investigation

@danieldaquino
Copy link
Contributor

Found it

    /// This loads the latest contact event we have on file from NostrDB. This should be called as soon as we get the new DamusState
    /// Loading the latest contact list event into our `Contacts` instance from storage is important to avoid getting into weird states when the network is unreliable or when relays delete such information
    func load_latest_contact_event_from_damus_state() {
        guard let latest_contact_event_id_hex = damus_state.settings.latest_contact_event_id_hex else { return }
        guard let latest_contact_event_id = NoteId(hex: latest_contact_event_id_hex) else { return }
        guard let latest_contact_event: NdbNote = damus_state.ndb.lookup_note( latest_contact_event_id)?.unsafeUnownedValue?.to_owned() else { return }
        process_contact_event(state: damus_state, ev: latest_contact_event)
        damus_state.contacts.delegate = self // Here
    }

Unless the user signs up after #2057 changes, this delegate will never be set, which means latest_contact_event_changed will never get called. This line needs to be moved up probably

@jb55
Copy link
Collaborator

jb55 commented Jun 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working, or not working as intended Needs recreation Issues requires concrete steps for recreation relay workaround
Projects
Status: In Progress
Development

No branches or pull requests

3 participants