lntest+routing: update best height after graph pruning
It seems #5246 introduced a subtle bug that lead to the error "out of order block: expecting height=1, got height=XXX" some times during startup. Apparently it can happen that during pruning of the graph tip some blocks can come in before we start our chain view and the new block subscription. By querying the chain backend for the best height before syncing with the graph we ensure that we never miss a block.
This commit is contained in:
parent
8147b270d4
commit
6c37cae639
@ -177,9 +177,16 @@ func (n *NetworkHarness) SetUp(testCase string, lndArgs []string) error {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First, make a connection between the two nodes. This will wait until
|
||||||
|
// both nodes are fully started since the Connect RPC is guarded behind
|
||||||
|
// the server.Started() flag that waits for all subsystems to be ready.
|
||||||
|
ctxb := context.Background()
|
||||||
|
if err := n.ConnectNodes(ctxb, n.Alice, n.Bob); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Load up the wallets of the seeder nodes with 10 outputs of 1 BTC
|
// Load up the wallets of the seeder nodes with 10 outputs of 1 BTC
|
||||||
// each.
|
// each.
|
||||||
ctxb := context.Background()
|
|
||||||
addrReq := &lnrpc.NewAddressRequest{
|
addrReq := &lnrpc.NewAddressRequest{
|
||||||
Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH,
|
Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH,
|
||||||
}
|
}
|
||||||
@ -216,8 +223,13 @@ func (n *NetworkHarness) SetUp(testCase string, lndArgs []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, make a connection between both of the nodes.
|
// Now we want to wait for the nodes to catch up.
|
||||||
if err := n.ConnectNodes(ctxb, n.Alice, n.Bob); err != nil {
|
ctxt, cancel := context.WithTimeout(ctxb, DefaultTimeout)
|
||||||
|
defer cancel()
|
||||||
|
if err := n.Alice.WaitForBlockchainSync(ctxt); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := n.Bob.WaitForBlockchainSync(ctxt); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,6 +563,14 @@ func (r *ChannelRouter) Start() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The graph pruning might have taken a while and there could be
|
||||||
|
// new blocks available.
|
||||||
|
bestHash, bestHeight, err = r.cfg.Chain.GetBestBlock()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
r.bestHeight = uint32(bestHeight)
|
||||||
|
|
||||||
// Before we begin normal operation of the router, we first need
|
// Before we begin normal operation of the router, we first need
|
||||||
// to synchronize the channel graph to the latest state of the
|
// to synchronize the channel graph to the latest state of the
|
||||||
// UTXO set.
|
// UTXO set.
|
||||||
|
Loading…
Reference in New Issue
Block a user