Check for manifest CID while loading bundle
This commit is contained in:
+18
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user