Check for manifest CID while loading bundle

This commit is contained in:
Geoff Stuart
2022-05-26 17:30:32 -04:00
parent c159290868
commit 30e7f89662
12 changed files with 102 additions and 113 deletions
+18 -2
View File
@@ -1,11 +1,14 @@
package bundle
import (
"bytes"
"context"
"fmt"
"io"
"os"
"github.com/ipld/go-car"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/blockstore"
@@ -58,10 +61,23 @@ func LoadBundle(ctx context.Context, bs blockstore.Blockstore, path string, av a
return cid.Undef, xerrors.Errorf("error reading bundle for builtin-actors version %d: %w", av, err)
}
if err := actors.LoadBundle(ctx, bs, av, data); err != nil {
return cid.Undef, xerrors.Errorf("error loading bundle for builtin-actors version %d: %w", av, err)
blobr := bytes.NewReader(data)
hdr, err := car.LoadCar(ctx, bs, blobr)
if err != nil {
return cid.Undef, xerrors.Errorf("error loading builtin actors v%d bundle: %w", av, err)
}
// TODO: check that this only has one root?
manifestCid := hdr.Roots[0]
if val, ok := build.ActorsCIDs[av]; ok {
if val != manifestCid {
return cid.Undef, xerrors.Errorf("actors V%d manifest CID %s did not match CID given in params file: %s", av, manifestCid, val)
}
}
actors.AddManifest(av, manifestCid)
mfCid, ok := actors.GetManifest(av)
if !ok {
return cid.Undef, xerrors.Errorf("missing manifest CID for builtin-actors vrsion %d", av)