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]: itest: regtest difficulty retarget for backend=bitcoind #7241

Closed
morehouse opened this issue Dec 7, 2022 · 3 comments · Fixed by #7881
Closed

[bug]: itest: regtest difficulty retarget for backend=bitcoind #7241

morehouse opened this issue Dec 7, 2022 · 3 comments · Fixed by #7881
Labels
backend Related to the node backend software/interface (e.g. btcd, bitcoin-core) btcd bug Unintended code behaviour

Comments

@morehouse
Copy link
Collaborator

Background

bitcoind disables difficulty retargeting on regtest, while btcd does not. When we run itests with backend=bitcoind, the btcd miner generates blocks and sends them to the bitcoind backend. If btcd modifies the difficulty target, its mined blocks get rejected by bitcoind.

So far, we seem to have avoided this issue because our itests generate fewer than 4032 blocks in aggregate (the first retarget at block 2016 doesn't modify difficulty). But #7228 adds a test that pushes us over 4032 blocks, so the new itests are failing in CI.

Steps to reproduce

See #7228 CI. Look at the new itests with backend=bitcoind.

How to fix

There are multiple ways to fix this. Some ideas:

  • Make btcd regtest behavior match bitcoind (or add an option for this).
  • Restart miner when it gets close to the retarget height.
  • Use bitcoind to mine blocks instead of btcd.
@morehouse morehouse added bug Unintended code behaviour needs triage labels Dec 7, 2022
@Roasbeef
Copy link
Member

Roasbeef commented Dec 7, 2022

Related issues: lightninglabs/neutrino#255 btcsuite/btcd#1819

@yyforyongyu
Copy link
Member

Restart miner when it gets close to the retarget height.

I thought about this too. Not relating to retargeting but in general it should make our itest faster.

morehouse added a commit to morehouse/lnd that referenced this issue Dec 12, 2022
Ensure active nodes are synced to the latest block mined.

There are two scenarios where they might not be synced to the correct
block even when SyncedToChain is true:
  1. The backend may have rejected a newly mined block (e.g., see
     lightningnetwork#7241).
  2. The backend might not have fully processed the new blocks yet.

In either case SyncedToChain will (correctly) be true since the node is
indeed fully synced to the backend. This commit makes sure we detect
case 1 above, while making sure we continue to wait in case 2.
@saubyk saubyk added btcd backend Related to the node backend software/interface (e.g. btcd, bitcoin-core) and removed needs triage labels Dec 12, 2022
@guggero
Copy link
Collaborator

guggero commented Jun 22, 2023

Fixed for btcd in btcsuite/btcd#1985 and for Neutrino in lightninglabs/neutrino#281.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to the node backend software/interface (e.g. btcd, bitcoin-core) btcd bug Unintended code behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants