chaintopology: always start 100 blocks back.

Since we panic when we see our root reorg out, even if we're not doing
anything yet, restoring the 100 block margin is the simplest fix.

Unfortunately this means adding a 100-block spacer in the tests, so things
don't get confused.

Fixes: #511
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-01-05 13:08:15 +10:30 committed by Christian Decker
parent 822a2cf030
commit fb81e6c14b
2 changed files with 12 additions and 0 deletions

View File

@ -468,6 +468,13 @@ static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
if (blockcount < topo->first_blocknum)
topo->first_blocknum = blockcount;
/* FIXME: Because we don't handle our root disappearing, we go
* 100 blocks back */
if (topo->first_blocknum < 100)
topo->first_blocknum = 0;
else
topo->first_blocknum -= 100;
/* Get up to speed with topology. */
bitcoind_getblockhash(bitcoind, topo->first_blocknum,
get_init_block, topo);

View File

@ -224,6 +224,11 @@ class BaseLightningDTests(unittest.TestCase):
if not ok:
raise Exception("At least one lightning exited with unexpected non-zero return code")
@classmethod
def tearDownClass(cls):
"""We need 100 blocks between runs, since otherwise they might see the txs from a previous run, and get very confused!"""
bitcoind.generate_block(100)
class LightningDTests(BaseLightningDTests):
def connect(self):
l1 = self.node_factory.get_node()