namecoin / electrum-nmc

Namecoin port of Electrum Bitcoin client.
https://www.namecoin.org/
MIT License
29 stars 24 forks source link

Regtest functional tests: Lightning funding transaction not mined #191

Closed JeremyRand closed 4 years ago

JeremyRand commented 4 years ago

The Regtest functional tests are hanging, apparently because a Lightning funding transaction isn't being mined.

Here's a log of the error (I've enabled logging in Namecoin Core, ElectrumX, and Electrum-NMC):

https://travis-ci.org/namecoin/electrum-nmc/jobs/610211982?utm_medium=notification&utm_source=github_status

And here's a log of the auxpow branch, which doesn't have the error:

https://travis-ci.org/namecoin/electrum-nmc/jobs/610224116?utm_medium=notification&utm_source=github_status

Note that the auxpow log contains the following:

2019-11-11T08:29:17Z CreateNewBlock(): block weight: 1505 txs: 1 fees: 27540 sigops 401

Whereas the corresponding line in the master log is:

2019-11-11T07:50:46Z CreateNewBlock(): block weight: 868 txs: 0 fees: 0 sigops 400

I'm not sure if this is because Namecoin Core is maybe rejecting the Lightning funding transaction due to relay policy, or if there's some other thing wrong.

JeremyRand commented 4 years ago

@domob1812 Any ideas on this? Is there any extra debug output I could add that would maybe reveal something?

domob1812 commented 4 years ago

Interesting! I don't have any ideas right now. To enable all log info, add just -debug if you haven't already. Perhaps you could also try to look at the mempool if the tx made it into that, so that you can see if the issue is mempool acceptance or block construction (and then debug further from there, e.g. by inserting log statements into the code).

JeremyRand commented 4 years ago

Perhaps you could also try to look at the mempool if the tx made it into that, so that you can see if the issue is mempool acceptance or block construction

The mempool in both master and auxpow branches seems to contain 1 transaction as expected, see the following logs:

master: https://travis-ci.org/namecoin/electrum-nmc/jobs/611865119#L574 auxpow: https://travis-ci.org/namecoin/electrum-nmc/jobs/611866679#L651

I'll look into adding more debug output from Namecoin Core.

domob1812 commented 4 years ago

Ok, so the issue is with block creation. I've seen similar behaviour (tx is in mempool but not mined) in the past when I was using bech32 addresses but segwit was not yet activated; but since segwit is now active from block height zero (rather than 432 as it used to be for some time) on regtest, that's presumably not the issue you have.

JeremyRand commented 4 years ago

I've seen similar behaviour (tx is in mempool but not mined) in the past when I was using bech32 addresses but segwit was not yet activated; but since segwit is now active from block height zero (rather than 432 as it used to be for some time) on regtest, that's presumably not the issue you have.

@domob1812 That might actually be relevant. The Electrum-NMC Travis job is using Namecoin Core 0.18.0 binaries. I just checked the nc0.18.0 source code, and it looks like BIP16Height is set to 432 for Regtest in that tag of Namecoin Core. If that's the issue, am I correct in guessing that I can either mine a bunch of additional blocks prior to running the tests, or upgrade to a more recent Namecoin Core tag?

domob1812 commented 4 years ago

@JeremyRand Ah yes - in this case, both options you suggest should fix the issue.

JeremyRand commented 4 years ago

The block subsidy decrease caused by advancing the blockchain to height 432 is breaking some of the tests via "Insufficient funds" errors. I'll try to correct those manually in order to confirm the diagnosis, but I'd much rather upgrade to a newer Namecoin Core for the actual fix.

domob1812 commented 4 years ago

Yes definitely. Would it be hard to simply try a run with nc0.19.0?

JeremyRand commented 4 years ago

The Electrum-NMC tests just download a Namecoin Core binary from Namecoin.org; they don't actually build Core from source. So I guess this is a good excuse for me to do a Gitian build of nc0.19.0.

JeremyRand commented 4 years ago

Actually, looks like using Namecoin Core 0.19.0 causes the same "Insufficient funds" issue, so it's not related to the block subsidy. So maybe that issue is happening specifically because Segwit is activated. Maybe related to the deserialization bug in current stable ElectrumX that happens because SegWit is disabled in Namecoin there. My patch to ElectrumX isn't merged by Neil yet; trying to evaluate whether I want to patch ElectrumX in Travis, or just wait for Neil to get around to merging it....