Skip to content

Commit

Permalink
Prefill GetTipsetByHeight skiplist cache on lotus startup
Browse files Browse the repository at this point in the history
  • Loading branch information
fridrik01 committed Jun 6, 2023
1 parent fc0df4a commit d3fed20
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions node/modules/ethmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ 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"
Expand Down Expand Up @@ -54,6 +56,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 {
Expand Down

0 comments on commit d3fed20

Please sign in to comment.