fix: chain: make failure to load the chain state fatal (#11426)

Otherwise, we get strange panics later.
This commit is contained in:
Steven Allen 2023-11-29 16:01:26 +04:00 committed by GitHub
parent 3d5bebc2dd
commit afa95681af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,12 +82,12 @@ func ChainStore(lc fx.Lifecycle,
basebs dtypes.BaseBlockstore, basebs dtypes.BaseBlockstore,
weight store.WeightFunc, weight store.WeightFunc,
us stmgr.UpgradeSchedule, us stmgr.UpgradeSchedule,
j journal.Journal) *store.ChainStore { j journal.Journal) (*store.ChainStore, error) {
chain := store.NewChainStore(cbs, sbs, ds, weight, j) chain := store.NewChainStore(cbs, sbs, ds, weight, j)
if err := chain.Load(helpers.LifecycleCtx(mctx, lc)); err != nil { if err := chain.Load(helpers.LifecycleCtx(mctx, lc)); err != nil {
log.Warnf("loading chain state from disk: %s", err) return nil, xerrors.Errorf("loading chain state from disk: %w", err)
} }
var startHook func(context.Context) error var startHook func(context.Context) error
@ -108,7 +108,7 @@ func ChainStore(lc fx.Lifecycle,
}, },
}) })
return chain return chain, nil
} }
func NetworkName(mctx helpers.MetricsCtx, func NetworkName(mctx helpers.MetricsCtx,