lnd: [bug]: Fail to chain sync on `testnet3` & `mainnet` errors relating to: script witness item is larger than the max allowed size
Background
Fail to chain sync on testnet3
.
The node does show it is up to the tip of the chain , but remains unsynced due to errors
2022-10-09 18:42:39.886 [ERR] LNWL: Unable to process chain reorg: unable to get block 0000000000000032fcf519b61aad2b966348e3f2d27687b26277933cc9881965: readScript: script witness item is larger than the max allowed size [count 396669, max 11000]
....
2022-10-09 18:46:18.715 [ERR] LNWL: Unable to complete chain rescan: readScript: script witness item is larger than the max allowed size [count 396669, max 11000]
...
2022-10-09 21:36:23.272 [ERR] LNWL: Unable to process chain reorg: unable to get block 0000000000000014820a254fbcdccce582df2194014c1e3b3f5ecd9259fce663: readScript: script witness item is larger than the max allowed size [count 33970, max 11000]
Your environment
0.15.0-beta commit=v0.15.0-beta
Linux ip-10-21-2-70 5.13.0-1031-aws #35~20.04.1-Ubuntu SMP Mon Jun 13 22:30:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
- backend
bitcoind v23.0.0
Steps to reproduce
Unknown
Expected behaviour
“synced_to_chain”: true
Actual behaviour
“synced_to_chain”: false with following errors in logs:
2022-10-09 18:42:39.886 [ERR] LNWL: Unable to process chain reorg: unable to get block 0000000000000032fcf519b61aad2b966348e3f2d27687b26277933cc9881965: readScript: script witness item is larger than the max allowed size [count 396669, max 11000]
....
2022-10-09 18:46:18.715 [ERR] LNWL: Unable to complete chain rescan: readScript: script witness item is larger than the max allowed size [count 396669, max 11000]
...
2022-10-09 21:36:23.272 [ERR] LNWL: Unable to process chain reorg: unable to get block 0000000000000014820a254fbcdccce582df2194014c1e3b3f5ecd9259fce663: readScript: script witness item is larger than the max allowed size [count 33970, max 11000]
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 24 (9 by maintainers)
Links to this issue
Commits related to this issue
- build: update to version of btcd with wire parsing bug fix Fixes https://github.com/lightningnetwork/lnd/issues/7002 — committed to Roasbeef/lnd by Roasbeef 2 years ago
- build: update to version of btcd with wire parsing bug fix Fixes https://github.com/lightningnetwork/lnd/issues/7002 — committed to Roasbeef/lnd by Roasbeef 2 years ago
- build: update to version of btcd with wire parsing bug fix Fixes https://github.com/lightningnetwork/lnd/issues/7002 — committed to Roasbeef/lnd by Roasbeef 2 years ago
- gomod: Update to lnd v0.15.2-beta We need a fast update to the newest lnd version as there was a security issue detected. https://github.com/lightningnetwork/lnd/issues/7002 As the bug was part of t... — committed to nepet/peerswap by nepet 2 years ago
- build: update to version of btcd with wire parsing bug fix Fixes https://github.com/lightningnetwork/lnd/issues/7002 — committed to SachinMeier/lnd by Roasbeef 2 years ago
Hey y’all, thanks for bringing this to our attention. I’ve identified the issue in the
btcd
wire parsing library, which led to this incident.AFAICT, the consensus code wasn’t the issue here, it was instead that the wire parsing library was erroneously still enforcing a prior check to limit witness sizing left over from segwit v0.
btcd is/was using this test vectors. The issue here is that the code the parsed the witnesses for these test vectors isn’t the same code that’s used to read blocks off the wire. When a new block comes in, we fetch the raw block then attempt to decode it, which triggered this issue.
The fix to the btcd wire parsing logic can be found here: https://github.com/btcsuite/btcd/pull/1896
This should be safe to apply to those running btcd nodes, which’ll allow them to resume validating the main chain (the block was accepted as this wasn’t a consensus issue persay).
Once this passes CI and a few more sniff checks, we’ll issue a hotfix release for lnd: 0.15.2. This release will only contain the dependency update to the wire parsing library.
Looks like lnd/btcd has a bug in their taproot implementation. In BIP342:
I am surprised this wasn’t caught by tests. Are they not using the static test vectors?
Having this with LND Version v0.15.1 on mainnet:
Bug is actually in btcd code:
https://github.com/btcsuite/btcd/blob/fc36cb25a4bdc6d989f9161552e7b0fe08b02939/wire/msgtx.go#L105-L109
I also also seeing on mainnet v0.15.0:
Posted about here: https://twitter.com/brqgoo/status/1579216353780957185
See this on v0.15.1/mainnet
Got the same error on mainnet: