introduce a marker type for builtin actor loading to make DI work

This commit is contained in:
vyzo 2022-04-04 20:06:49 +03:00
parent f26d19ed7d
commit 5e3112fa95
4 changed files with 11 additions and 5 deletions

View File

@ -57,7 +57,7 @@ var ChainNode = Options(
// Consensus settings
Override(new(dtypes.DrandSchedule), modules.BuiltinDrandConfig),
Override(new(stmgr.UpgradeSchedule), filcns.DefaultUpgradeSchedule()),
Override(new(stmgr.UpgradeSchedule), modules.UpgradeSchedule),
Override(new(dtypes.NetworkName), modules.NetworkName),
Override(new(modules.Genesis), modules.ErrorGenesis),
Override(new(dtypes.AfterGenesisSet), modules.SetGenesis),

View File

@ -15,7 +15,7 @@ import (
car "github.com/ipld/go-car"
)
func LoadBultinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.UniversalBlockstore) error {
func LoadBultinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.UniversalBlockstore) (result dtypes.BuiltinActorsLoaded, err error) {
ctx := helpers.LifecycleCtx(mctx, lc)
// TODO eventually we want this to start with bundle/manifest CIDs and fetch them from IPFS if
@ -25,7 +25,7 @@ func LoadBultinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.Univer
blobr := bytes.NewReader(build.BuiltinActorsV8Bundle())
hdr, err := car.LoadCar(ctx, bs, blobr)
if err != nil {
return xerrors.Errorf("error loading builtin actors v8 bundle: %w", err)
return result, xerrors.Errorf("error loading builtin actors v8 bundle: %w", err)
}
manifestCid := hdr.Roots[0]
@ -33,8 +33,8 @@ func LoadBultinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.Univer
cborStore := cbor.NewCborStore(bs)
if err := actors.LoadManifests(ctx, cborStore); err != nil {
return xerrors.Errorf("error loading actor manifests: %w", err)
return result, xerrors.Errorf("error loading actor manifests: %w", err)
}
return nil
return result, nil
}

View File

@ -18,6 +18,7 @@ import (
"github.com/filecoin-project/lotus/chain"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/consensus"
"github.com/filecoin-project/lotus/chain/consensus/filcns"
"github.com/filecoin-project/lotus/chain/exchange"
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
"github.com/filecoin-project/lotus/chain/messagepool"
@ -176,3 +177,7 @@ func NewSyncer(params SyncerParams) (*chain.Syncer, error) {
func NewSlashFilter(ds dtypes.MetadataDS) *slashfilter.SlashFilter {
return slashfilter.New(ds)
}
func UpgradeSchedule(_ dtypes.BuiltinActorsLoaded) stmgr.UpgradeSchedule {
return filcns.DefaultUpgradeSchedule()
}

View File

@ -2,3 +2,4 @@ package dtypes
type NetworkName string
type AfterGenesisSet struct{}
type BuiltinActorsLoaded struct{}