Merge pull request #8732 from filecoin-project/gstuart/check-actor-cid
feat: build: Check for manifest CID while loading bundle
This commit is contained in:
commit
a081f8d92d
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
)
|
||||
|
||||
@ -52,6 +53,8 @@ var UpgradeChocolateHeight = abi.ChainEpoch(-17)
|
||||
var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(-19)
|
||||
|
||||
var ActorsCIDs = map[actors.Version]cid.Cid{}
|
||||
|
||||
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||
0: DrandMainnet,
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -48,6 +49,8 @@ const UpgradeOhSnapHeight = 240
|
||||
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)
|
||||
|
||||
var ActorsCIDs = map[actors.Version]cid.Cid{}
|
||||
|
||||
func init() {
|
||||
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2 << 30))
|
||||
policy.SetSupportedProofTypes(
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -61,6 +62,8 @@ const UpgradeOhSnapHeight = 682006
|
||||
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)
|
||||
|
||||
var ActorsCIDs = map[actors.Version]cid.Cid{}
|
||||
|
||||
func init() {
|
||||
policy.SetConsensusMinerMinPower(abi.NewStoragePower(32 << 30))
|
||||
policy.SetSupportedProofTypes(
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
@ -51,6 +53,10 @@ var UpgradeChocolateHeight = abi.ChainEpoch(-17)
|
||||
var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(100)
|
||||
|
||||
var ActorsCIDs = map[actors.Version]cid.Cid{
|
||||
actors.Version8: MustParseCid("bafy2bzaceadr77tamp35bbb3rtio4ver4pnk2cbxqif3nn3mrmxra2nlvwoce"),
|
||||
}
|
||||
|
||||
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||
0: DrandMainnet,
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//go:build !debug && !2k && !testground && !calibnet && !nerpanet && !butterflynet && !interopnet
|
||||
// +build !debug,!2k,!testground,!calibnet,!nerpanet,!butterflynet,!interopnet
|
||||
//go:build !debug && !2k && !testground && !calibnet && !butterflynet && !interopnet
|
||||
// +build !debug,!2k,!testground,!calibnet,!butterflynet,!interopnet
|
||||
|
||||
package build
|
||||
|
||||
@ -7,6 +7,9 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
@ -74,6 +77,8 @@ var UpgradeOhSnapHeight = abi.ChainEpoch(1594680)
|
||||
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)
|
||||
|
||||
var ActorsCIDs = map[actors.Version]cid.Cid{}
|
||||
|
||||
func init() {
|
||||
if os.Getenv("LOTUS_USE_TEST_ADDRESSES") != "1" {
|
||||
SetAddressNetwork(address.Mainnet)
|
||||
|
@ -1,87 +0,0 @@
|
||||
//go:build nerpanet
|
||||
// +build nerpanet
|
||||
|
||||
package build
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
)
|
||||
|
||||
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||
0: DrandMainnet,
|
||||
}
|
||||
|
||||
const GenesisNetworkVersion = network.Version0
|
||||
|
||||
const BootstrappersFile = "nerpanet.pi"
|
||||
const GenesisFile = "nerpanet.car"
|
||||
|
||||
const UpgradeBreezeHeight = -1
|
||||
const BreezeGasTampingDuration = 0
|
||||
|
||||
const UpgradeSmokeHeight = -1
|
||||
|
||||
const UpgradeIgnitionHeight = -2
|
||||
const UpgradeRefuelHeight = -3
|
||||
|
||||
const UpgradeLiftoffHeight = -5
|
||||
|
||||
const UpgradeAssemblyHeight = 30 // critical: the network can bootstrap from v1 only
|
||||
const UpgradeTapeHeight = 60
|
||||
|
||||
const UpgradeKumquatHeight = 90
|
||||
|
||||
const UpgradeCalicoHeight = 100
|
||||
const UpgradePersianHeight = UpgradeCalicoHeight + (builtin2.EpochsInHour * 1)
|
||||
|
||||
const UpgradeClausHeight = 250
|
||||
|
||||
const UpgradeOrangeHeight = 300
|
||||
|
||||
const UpgradeTrustHeight = 600
|
||||
const UpgradeNorwegianHeight = 201000
|
||||
const UpgradeTurboHeight = 203000
|
||||
const UpgradeHyperdriveHeight = 379178
|
||||
|
||||
const UpgradeChocolateHeight = 999999999
|
||||
|
||||
func init() {
|
||||
// Minimum block production power is set to 4 TiB
|
||||
// Rationale is to discourage small-scale miners from trying to take over the network
|
||||
// One needs to invest in ~2.3x the compute to break consensus, making it not worth it
|
||||
//
|
||||
// DOWNSIDE: the fake-seals need to be kept alive/protected, otherwise network will seize
|
||||
//
|
||||
policy.SetConsensusMinerMinPower(abi.NewStoragePower(4 << 40))
|
||||
|
||||
policy.SetSupportedProofTypes(
|
||||
abi.RegisteredSealProof_StackedDrg512MiBV1,
|
||||
abi.RegisteredSealProof_StackedDrg32GiBV1,
|
||||
abi.RegisteredSealProof_StackedDrg64GiBV1,
|
||||
)
|
||||
|
||||
// Lower the most time-consuming parts of PoRep
|
||||
policy.SetPreCommitChallengeDelay(10)
|
||||
|
||||
// TODO - make this a variable
|
||||
//miner.WPoStChallengeLookback = abi.ChainEpoch(2)
|
||||
|
||||
Devnet = false
|
||||
|
||||
BuildType = BuildNerpanet
|
||||
|
||||
}
|
||||
|
||||
const BlockDelaySecs = uint64(builtin2.EpochDurationSeconds)
|
||||
|
||||
const PropagationDelaySecs = uint64(6)
|
||||
|
||||
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
|
||||
const BootstrapPeerThreshold = 4
|
||||
|
||||
var WhitelistedBlock = cid.Undef
|
@ -17,6 +17,7 @@ import (
|
||||
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
)
|
||||
|
||||
@ -121,3 +122,5 @@ var (
|
||||
)
|
||||
|
||||
const BootstrapPeerThreshold = 1
|
||||
|
||||
var ActorsCIDs = map[actors.Version]cid.Cid{}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package actors
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -10,12 +9,9 @@ import (
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
car "github.com/ipld/go-car"
|
||||
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var manifestCids map[Version]cid.Cid
|
||||
@ -144,19 +140,3 @@ func CanonicalName(name string) string {
|
||||
|
||||
return name
|
||||
}
|
||||
|
||||
func LoadBundle(ctx context.Context, bs blockstore.Blockstore, av Version, data []byte) error {
|
||||
blobr := bytes.NewReader(data)
|
||||
|
||||
hdr, err := car.LoadCar(ctx, bs, blobr)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error loading builtin actors v%d bundle: %w", av, err)
|
||||
}
|
||||
|
||||
// TODO: check that this only has one root?
|
||||
|
||||
manifestCid := hdr.Roots[0]
|
||||
AddManifest(av, manifestCid)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -1370,7 +1370,7 @@ func upgradeActorsV8Common(
|
||||
buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync())
|
||||
store := store.ActorStore(ctx, buf)
|
||||
|
||||
// ensure that the manifet is loaded in the blockstore
|
||||
// ensure that the manifest is loaded in the blockstore
|
||||
if err := bundle.FetchAndLoadBundles(ctx, buf, map[actors.Version]build.Bundle{
|
||||
actors.Version8: build.BuiltinActorReleases[actors.Version8],
|
||||
}); err != nil {
|
||||
@ -1395,6 +1395,12 @@ func upgradeActorsV8Common(
|
||||
return cid.Undef, xerrors.Errorf("no manifest CID for v8 upgrade")
|
||||
}
|
||||
|
||||
if val, ok := build.ActorsCIDs[actors.Version8]; ok {
|
||||
if val != manifest {
|
||||
return cid.Undef, xerrors.Errorf("actors V8 manifest CID %s did not match CID given in params file: %s", manifest, val)
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the migration
|
||||
newHamtRoot, err := nv16.MigrateStateTree(ctx, store, manifest, stateRoot.Actors, epoch, config, migrationLogger{}, cache)
|
||||
if err != nil {
|
||||
|
@ -1,9 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/ipld/go-car"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -17,6 +24,7 @@ var cidCmd = &cli.Command{
|
||||
Usage: "Cid command",
|
||||
Subcommands: cli.Commands{
|
||||
cidIdCmd,
|
||||
cidFromCarCmd,
|
||||
},
|
||||
}
|
||||
|
||||
@ -83,3 +91,41 @@ var cidIdCmd = &cli.Command{
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var cidFromCarCmd = &cli.Command{
|
||||
Name: "manifest-cid-from-car",
|
||||
Usage: "Get the manifest CID from a car file",
|
||||
ArgsUsage: "[path]",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
ctx := context.TODO()
|
||||
|
||||
cf := cctx.Args().Get(0)
|
||||
f, err := os.OpenFile(cf, os.O_RDONLY, 0664)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("opening the car file: %w", err)
|
||||
}
|
||||
|
||||
bs := blockstore.NewMemory()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error reading car file: %w", err)
|
||||
}
|
||||
|
||||
blobr := bytes.NewReader(data)
|
||||
|
||||
hdr, err := car.LoadCar(ctx, bs, blobr)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error loading car file: %w", err)
|
||||
}
|
||||
|
||||
manifestCid := hdr.Roots[0]
|
||||
|
||||
fmt.Printf("Manifest CID: %s\n", manifestCid.String())
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -48,6 +48,11 @@ func LoadBuiltinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedRe
|
||||
|
||||
if has {
|
||||
// it's there, no need to reload the bundle to the blockstore; just add it to the manifest list.
|
||||
if val, ok := build.ActorsCIDs[av]; ok {
|
||||
if val != mfCid {
|
||||
return result, xerrors.Errorf("actors V%d manifest CID %s did not match CID given in params file: %s", av, mfCid, val)
|
||||
}
|
||||
}
|
||||
actors.AddManifest(av, mfCid)
|
||||
continue
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user