Merge pull request #10955 from filecoin-project/prefill-skiplist-on-lotus-startup

Prefill GetTipsetByHeight skiplist cache on lotus startup
This commit is contained in:
Friðrik Ásmundsson 2023-06-06 15:29:47 -05:00 committed by GitHub
commit 7fea1795d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,9 +4,12 @@ import (
"context"
"os"
"path/filepath"
"time"
"go.uber.org/fx"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/ethhashlookup"
"github.com/filecoin-project/lotus/chain/events"
"github.com/filecoin-project/lotus/chain/messagepool"
@ -54,6 +57,17 @@ func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRep
}
}
// prefill the whole skiplist cache maintained internally by the GetTipsetByHeight
go func() {
start := time.Now()
log.Infoln("Start prefilling GetTipsetByHeight cache")
_, err := cs.GetTipsetByHeight(mctx, abi.ChainEpoch(0), cs.GetHeaviestTipSet(), false)
if err != nil {
log.Warnf("error when prefilling GetTipsetByHeight cache: %w", err)
}
log.Infof("Prefilling GetTipsetByHeight done in %s", time.Since(start))
}()
ctx := helpers.LifecycleCtx(mctx, lc)
lc.Append(fx.Hook{
OnStart: func(context.Context) error {