Skip to content

2 hour stale block check should not hang up regtest networks #11004

Description

@ZZiigguurraatt

At

// If the timestamp on the best header is more than 2 hours in the
// past, then we're not yet synced.
minus24Hours := time.Now().Add(-2 * time.Hour)
if blockHeader.Timestamp.Before(minus24Hours) {
return false, bestTimestamp, nil
}

we check that a block has been mined within 2 hours in order to ensure synced_to_chain (

lnd/lnrpc/lightning.proto

Lines 1959 to 1962 in 02f4116

// Whether the wallet's view is synced to the main chain
bool synced_to_chain = 9;
) is set to true.

When running in regtest, we are required to manually mine blocks, and we may mine them at arbitrary frequencies. Typically, when we are not testing, we sit idle and don't mine blocks until we are ready to test again.

Also, if we backup and restore a regtest network, if the backup is from some distant time in the past, we have the same thing happen.

We may just be testing off chain stuff and don't want to mine any blocks if we aren't doing any channel open or closure activity.

I feel like on regtest networks, we should not cause LND to trigger not synced after 2 hours if we don't mine any blocks. That can trip up other RPC calls and I don't know that we always necessarily want to do that when testing in regtest mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions