contractcourt: catch error when no historical bucket exists

For older nodes, this bucket was never created, so we'll get an error if
we try and query it. In this commit, we catch this error like we do when
a given channel doesn't have the information (but the bucket actually
exists).

Fixes #6155
This commit is contained in:
Olaoluwa Osuntokun 2022-01-13 15:05:48 -08:00
parent 2682ca3e22
commit 91f32ad270
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306
3 changed files with 9 additions and 3 deletions

View File

@ -329,6 +329,7 @@ var dbTopLevelBuckets = [][]byte{
metaBucket,
closeSummaryBucket,
outpointBucket,
historicalChannelBucket,
}
// Wipe completely deletes all saved state within all used buckets within the

View File

@ -717,10 +717,11 @@ func TestFetchHistoricalChannel(t *testing.T) {
// Create a an open channel in the database.
channel := createTestChannel(t, cdb, openChannelOption())
// First, try to lookup a channel when the bucket does not
// exist.
// First, try to lookup a channel when nothing is in the bucket. As the
// bucket is auto-created (on start up), we'll get a channel not found
// error.
_, err = cdb.FetchHistoricalChannel(&channel.FundingOutpoint)
if err != ErrNoHistoricalBucket {
if err != ErrChannelNotFound {
t.Fatalf("expected no bucket, got: %v", err)
}

View File

@ -618,6 +618,8 @@ func (c *ChannelArbitrator) relaunchResolvers(commitSet *CommitSet,
// If we don't find this channel, then it may be the case that it
// was closed before we started to retain the final state
// information for open channels.
case err == channeldb.ErrNoHistoricalBucket:
fallthrough
case err == channeldb.ErrChannelNotFound:
log.Warnf("ChannelArbitrator(%v): unable to fetch historical "+
"state", c.cfg.ChanPoint)
@ -1947,6 +1949,8 @@ func (c *ChannelArbitrator) prepContractResolutions(
// If we don't find this channel, then it may be the case that it
// was closed before we started to retain the final state
// information for open channels.
case err == channeldb.ErrNoHistoricalBucket:
fallthrough
case err == channeldb.ErrChannelNotFound:
log.Warnf("ChannelArbitrator(%v): unable to fetch historical "+
"state", c.cfg.ChanPoint)