Skip to content

Unclear private validator accept connection logic #452

Closed

Description

@corverroos

Bug Report

version: 0.34.27

While diving into the privval package source code as part of an investigation into horcrux we discovered that the "accept connection logic" is unclear.

See source. Writing to the unbuffered channel sl.connectRequestCh after attempting to accept a connection in SignerListenerEndpoint.serviceLoop has no affect. This is because a single goroutine cannot read and write to the same unbuffered channel, it can only do that with buffered channels.

It would therefore be clearer to remove that select statement since it never actually writes to the channel.

If the reasoning behind the serviceLoop is to successfully accept one connection for each connectRequest then one could change connectRequestCh into a buffered channel with length 1 and only write to it when acceptNewConnection errored.

Activity

  1. added
    bug
    needs-triage
    on Mar 3, 2023
  2. corverroos commented on Mar 3, 2023

    @corverroos
    ContributorAuthor

    I raised this with Tendermint but they routed me here: tendermint/tendermint#10009

    I also created a PR in my local fork that I can move here if it looks good: corverroos/tendermint#1

  3. adizere commented on Mar 9, 2023

    @adizere
    Contributor

    Nice find, thanks for reporting!

    We'll need a bit of time to get a deep understanding of this issue since our team is working full capacity to deliver v0.38 this month. Thanks for the patience.

    In the meantime, do I understand correctly that this issue does not translate into an incorrect behavior/defect (such as inability to accept conns), but it's more about code hygiene? If it's a defect, that will encourage us to prioritize it. Also, noticed you added unit tests here, but not sure I understand the logic; maybe there is also a recipe to reproduce the defect using a couple of nodes in practice?

  4. corverroos commented on Mar 10, 2023

    @corverroos
    ContributorAuthor

    Hi @adizere, at first I only thought it was a "code hygiene" issue. But then I realised that it is indeed a logic bug.

    Basically, the serviceloop will not retry sl.acceptNewConnection() if it errors. It will only attempt acceptNewConnection once and if it errors, it will ignore the error and block waiting to another thread to call triggerConnect.

    My understanding is that this can cause a "deadlock" with the node not accepting new connections anymore.

    The problem with testing this "using couple of nodes in practice" is that you need net.Listener.Accept() to error to trigger this bug. In practice net.Listener.Accept() doesn't error. That is why I used a mock listener in the unit test that returns a few initial errors before successfully returning (err==nil).

  5. adizere commented on Mar 10, 2023

    @adizere
    Contributor

    Was suspecting that, thanks for clarifying! Too bad there's no reliable way to reproduce the bug. That would have given us a lot more confidence in the proposed changes. Give us some time to parse this, and we'll ping you re: potentially porting corverroos/tendermint#1 here.

  6. added a commit that references this issue on Jan 16, 2024
    ac06cf0
  7. added this to the 2024-Q1 milestone on Jan 19, 2024
  8. moved this from Todo to Ready for Review in CometBFTon Jan 19, 2024
  9. added a commit that references this issue on Jan 30, 2024
    a8991d6
  10. moved this from Ready for Review to Done in CometBFTon Jan 30, 2024
  11. added 2 commits that reference this issue on Jan 30, 2024
    67d7adb
    f3f41f7
  12. added 2 commits that reference this issue on Aug 30, 2024
    66afad6
    340dfdc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugneeds-triage

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions