diff --git a/chain/actors/manifest.go b/chain/actors/manifest.go index 4eecab352..23caa184b 100644 --- a/chain/actors/manifest.go +++ b/chain/actors/manifest.go @@ -13,7 +13,7 @@ import ( "github.com/filecoin-project/specs-actors/v8/actors/builtin/manifest" ) -var ManifestCids map[Version]cid.Cid = map[Version]cid.Cid{ +var manifestCids map[Version]cid.Cid = map[Version]cid.Cid{ // TODO fill in manifest CIDs for v8 and upwards once these are fixed } @@ -30,6 +30,21 @@ type actorEntry struct { version Version } +func AddManifest(av Version, manifestCid cid.Cid) { + manifestMx.Lock() + defer manifestMx.Unlock() + + manifestCids[av] = manifestCid +} + +func GetManifest(av Version) (cid.Cid, bool) { + manifestMx.Lock() + defer manifestMx.Unlock() + + c, ok := manifestCids[av] + return c, ok +} + func LoadManifests(ctx context.Context, store cbor.IpldStore) error { // tests may invoke this concurrently, so we wrap it in a sync.Once loadOnce.Do(func() { loadError = loadManifests(ctx, store) }) @@ -42,7 +57,7 @@ func loadManifests(ctx context.Context, store cbor.IpldStore) error { manifests = make(map[Version]*manifest.Manifest) actorMeta = make(map[cid.Cid]actorEntry) - for av, mfCid := range ManifestCids { + for av, mfCid := range manifestCids { mf := &manifest.Manifest{} if err := adtStore.Get(ctx, mfCid, mf); err != nil { return xerrors.Errorf("error reading manifest for network version %d (cid: %s): %w", av, mfCid, err) diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index cced0c0f9..f580c0aeb 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -89,7 +89,7 @@ func legacyPreMigration(f LegacyPreMigrationFunc) stmgr.PreMigrationFunc { func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { var us stmgr.UpgradeSchedule - v8ManifestCid, ok := actors.ManifestCids[actors.Version8] + v8ManifestCid, ok := actors.GetManifest(actors.Version8) if !ok { v8ManifestCid = cid.Undef } diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index 02f5e157e..5b52dd24e 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -265,7 +265,7 @@ func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { return nil, xerrors.Errorf("mapping network version to actors version: %w", err) } - c, ok := actors.ManifestCids[av] + c, ok := actors.GetManifest(av) if !ok { return nil, xerrors.Errorf("no manifest for custom bundle (actors version %d)", av) }