lnd: [bug]: RegisterBlockEpochNtfn is sending the same event twice

Background

RegisterBlockEpochNtfn is sending 2 events (same data) for block updates

Your environment

  • version of lnd: 0.16.2-beta
  • operating system: Linux
  • version of bitcoind: v24.0.1

Steps to reproduce

use code provided here https://lightning.engineering/api-docs/api/lnd/chain-notifier/register-block-epoch-ntfn or use Alex Library https://github.com/alexbosworth/ln-service#subscribetoblocks

Expected behaviour

Send only 1 event per block

Actual behaviour

Send 2 events per block (same data)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Closing this as I’m pretty sure this is an issue of the specific fork/build of bitcoind and not lnd.

@dolcalmi I looked at the Dockerfile for lncm/bitcoind and it looks like the ZMQ parameters are supplied as command line arguments: https://github.com/lncm/docker-bitcoind/blob/master/24.0/Dockerfile#L256 Maybe adding the same values in the config file actually creates two ZMQ endpoints under the same address which ends up pushing the events twice? No idea how ZMQ works under the hood, but if that is the case then you should be fine with just removing those two lines from your bitcoin.conf and things should work normally.

Thank you for the test project. I now took a look at it and can say with a large degree of certainty that the multiple notifications happen because lnd thinks there is a re-org (the log lines I posted above).

I changed to another bitcoind docker image and the problem was gone:

  bitcoind:
    image: ruimarinho/bitcoin-core:23
    ports:
      - "18443:18443"
    environment:
      - HOME=/home/bitcoin
    volumes:
      - ${PWD}/dev/bitcoind/bitcoin.conf:/home/bitcoin/.bitcoin/bitcoin.conf

So I’m pretty sure something in how ZMQ works is broken or different in your lncm variant of the bitcoind docker image.

I just took a quick look at the log file in your test and see this:

Possible reorg at block: height=188, hash=1596dbacc5e72da3ce0a38f1fbd47e4258bb49206bc034481690f5563a516560
...
Disconnecting block: height=188, hash=1596dbacc5e72da3ce0a38f1fbd47e4258bb49206bc034481690f5563a516560

So it looks like your test is doing a re-org, in which case it would be expected to be notified about a block multiple times. So I’d say something is up with the test logic itself.