diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 50f94ec070..0000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/Makefile b/Makefile index 936cd1581d..f6e88d94b5 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ test: go build -o gengen ./tools/gengen ./gengen --keypath ./fixtures/live --out-car ./fixtures/live/genesis.car --out-json ./fixtures/live/gen.json --config ./fixtures/setup.json ./gengen --keypath ./fixtures/test --out-car ./fixtures/test/genesis.car --out-json ./fixtures/test/gen.json --config ./fixtures/setup.json - go test -v ./... -integration=true -unit=false + go test -v ./... -integration=true -unit=false lint: $(BUILD_DEPS) staticcheck ./... diff --git a/app/node/builder.go b/app/node/builder.go index 140e35abc2..90af1893e1 100644 --- a/app/node/builder.go +++ b/app/node/builder.go @@ -31,7 +31,6 @@ import ( "github.com/filecoin-project/venus/pkg/repo" "github.com/filecoin-project/venus/pkg/util/ffiwrapper" "github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl" - builtin_actors "github.com/filecoin-project/venus/venus-shared/builtin-actors" "github.com/filecoin-project/venus/venus-shared/types" "github.com/ipfs-force-community/metrics/ratelimit" ) @@ -102,10 +101,6 @@ func (b *Builder) build(ctx context.Context) (*Node, error) { chainClock: b.chainClock, } - if err := builtin_actors.SetNetworkBundle(b.repo.Config().NetworkParams.NetworkType); err != nil { - return nil, err - } - //modules nd.circulatiingSupplyCalculator = chain2.NewCirculatingSupplyCalculator(b.repo.Datastore(), b.genBlk.ParentStateRoot, b.repo.Config().NetworkParams.ForkUpgradeParam) diff --git a/app/submodule/blockstore/blockstore_api.go b/app/submodule/blockstore/blockstore_api.go index f3654699f2..09ce9a5175 100644 --- a/app/submodule/blockstore/blockstore_api.go +++ b/app/submodule/blockstore/blockstore_api.go @@ -7,6 +7,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-blockservice" "github.com/ipfs/go-cid" offline "github.com/ipfs/go-ipfs-exchange-offline" @@ -86,3 +87,11 @@ func (blockstoreAPI *blockstoreAPI) ChainStatObj(ctx context.Context, obj cid.Ci return stats, nil } + +func (blockstoreAPI *blockstoreAPI) ChainPutObj(ctx context.Context, blk blocks.Block) error { + return blockstoreAPI.blockstore.Blockstore.Put(ctx, blk) +} + +func (blockstoreAPI *blockstoreAPI) PutMany(ctx context.Context, blocks []blocks.Block) error { + return blockstoreAPI.blockstore.Blockstore.PutMany(ctx, blocks) +} diff --git a/cmd/daemon.go b/cmd/daemon.go index 12df52c177..b9b177ca2e 100644 --- a/cmd/daemon.go +++ b/cmd/daemon.go @@ -6,6 +6,8 @@ import ( "github.com/filecoin-project/venus/fixtures/assets" "github.com/filecoin-project/venus/fixtures/networks" + builtinactors "github.com/filecoin-project/venus/venus-shared/builtin-actors" + "github.com/filecoin-project/venus/venus-shared/utils" "github.com/filecoin-project/venus/pkg/constants" "github.com/filecoin-project/venus/pkg/util/ulimit" @@ -24,7 +26,6 @@ import ( "github.com/filecoin-project/venus/pkg/journal" "github.com/filecoin-project/venus/pkg/migration" "github.com/filecoin-project/venus/pkg/repo" - builtin_actors "github.com/filecoin-project/venus/venus-shared/builtin-actors" ) var log = logging.Logger("daemon") @@ -140,10 +141,6 @@ func initRun(req *cmds.Request) error { } node.SetNetParams(cfg.NetworkParams) - // load builtin actors - if err := builtin_actors.SetNetworkBundle(cfg.NetworkParams.NetworkType); err != nil { - return err - } genesisFunc = genesis.MakeGenesis(req.Context, rep, mkGen, preTp.(string), cfg.NetworkParams.ForkUpgradeParam) } else { genesisFileSource, _ := req.Options[GenesisFile].(string) @@ -178,6 +175,11 @@ func daemonRun(req *cmds.Request, re cmds.ResponseEmitter) error { config := rep.Config() + if err := builtinactors.SetNetworkBundle(config.NetworkParams.NetworkType); err != nil { + return err + } + utils.ReloadMethodsMap() + // second highest precedence is env vars. if envAPI := os.Getenv("VENUS_API"); envAPI != "" { config.API.APIAddress = envAPI diff --git a/cmd/message.go b/cmd/message.go index 8e7d852fd0..c7d0fe383e 100644 --- a/cmd/message.go +++ b/cmd/message.go @@ -17,10 +17,10 @@ import ( cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/venus/app/node" - "github.com/filecoin-project/venus/pkg/chain" "github.com/filecoin-project/venus/pkg/vm" "github.com/filecoin-project/venus/venus-shared/actors/builtin" "github.com/filecoin-project/venus/venus-shared/types" + "github.com/filecoin-project/venus/venus-shared/utils" ) var feecapOption = cmds.StringOption("gas-feecap", "Price (FIL e.g. 0.00013) to pay for each GasUnit consumed mining this message") @@ -121,6 +121,10 @@ var msgSendCmd = &cmds.Command{ return err } + if err := utils.LoadBuiltinActors(req.Context, env.(*node.Env).ChainAPI); err != nil { + return err + } + var params []byte rawPJ := req.Options["params-json"] if rawPJ != nil { @@ -191,7 +195,7 @@ func decodeTypedParams(ctx context.Context, fapi *node.Env, to address.Address, return nil, err } - methodMeta, found := chain.MethodsMap[act.Code][method] + methodMeta, found := utils.MethodsMap[act.Code][method] if !found { return nil, fmt.Errorf("method %d not found on actor %s", method, act.Code) } diff --git a/cmd/multisig.go b/cmd/multisig.go index c067f95f2b..e79ffc88a3 100644 --- a/cmd/multisig.go +++ b/cmd/multisig.go @@ -19,13 +19,13 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/venus/app/node" sbchain "github.com/filecoin-project/venus/app/submodule/chain" - "github.com/filecoin-project/venus/pkg/chain" "github.com/filecoin-project/venus/pkg/constants" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/builtin" "github.com/filecoin-project/venus/venus-shared/actors/builtin/multisig" "github.com/filecoin-project/venus/venus-shared/types" + "github.com/filecoin-project/venus/venus-shared/utils" "github.com/ipfs/go-cid" cmds "github.com/ipfs/go-ipfs-cmds" cbor "github.com/ipfs/go-ipld-cbor" @@ -164,6 +164,11 @@ var msigInspectCmd = &cmds.Command{ if err != nil { return err } + + if err := utils.LoadBuiltinActors(ctx, env.(*node.Env).ChainAPI); err != nil { + return err + } + head, err := env.(*node.Env).ChainAPI.ChainHead(req.Context) if err != nil { return err @@ -271,7 +276,7 @@ var msigInspectCmd = &cmds.Command{ fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), "new account, unknown method", tx.Method, paramStr) } } else { - method := chain.MethodsMap[targAct.Code][tx.Method] + method := utils.MethodsMap[targAct.Code][tx.Method] if decParams && tx.Method != 0 { ptyp := reflect.New(method.Params.Elem()).Interface().(cbg.CBORUnmarshaler) diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index acda280d74..943e33574d 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit acda280d74047ee7b247ffb8463cf29f1f108560 +Subproject commit 943e33574dcacd940edff0cf414c82e656bdaeb3 diff --git a/fixtures/assets/genesis-car/butterflynet.car b/fixtures/assets/genesis-car/butterflynet.car index 6ef5243beb..2a23ff147b 100644 Binary files a/fixtures/assets/genesis-car/butterflynet.car and b/fixtures/assets/genesis-car/butterflynet.car differ diff --git a/fixtures/networks/butterfly.go b/fixtures/networks/butterfly.go index 7d92f4a353..c97106cafb 100644 --- a/fixtures/networks/butterfly.go +++ b/fixtures/networks/butterfly.go @@ -12,23 +12,25 @@ func ButterflySnapNet() *NetworkConf { return &NetworkConf{ Bootstrap: config.BootstrapConfig{ Addresses: []string{ - "/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWFHDtFx7CVTy4xoCDutVo1cScvSnQjDeaM8UzwVS1qwkh", - "/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWKt8cwpkiumkT8x32c3YFxsPRwhV5J8hCYPn9mhUmcAXt", + "/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWSUZhAY3eyoPUboJ1ZWe4dNPFWTr1EPoDjbTDSAN15uhY", + "/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWDfvNrSRVGWAGbn3sm9C8z98W2x25qCZjaXGHXmGiH24e", }, MinPeerThreshold: 0, Period: "30s", }, Network: config.NetworkParamsConfig{ - DevNet: true, + DevNet: true, + NetworkType: types.NetworkButterfly, + GenesisNetworkVersion: network.Version15, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1, abi.RegisteredSealProof_StackedDrg64GiBV1, }, - NetworkType: types.NetworkButterfly, - GenesisNetworkVersion: network.Version15, - BlockDelay: 30, - ConsensusMinerMinPower: 2 << 30, + BlockDelay: 30, + ConsensusMinerMinPower: 2 << 30, + MinVerifiedDealSize: 1 << 20, + PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ UpgradeBreezeHeight: -1, UpgradeSmokeHeight: -2, diff --git a/fixtures/networks/calibration.go b/fixtures/networks/calibration.go index 3c07ab7275..9cf0cc8c34 100644 --- a/fixtures/networks/calibration.go +++ b/fixtures/networks/calibration.go @@ -26,15 +26,17 @@ func Calibration() *NetworkConf { Period: "30s", }, Network: config.NetworkParamsConfig{ - DevNet: true, - NetworkType: types.NetworkCalibnet, - GenesisNetworkVersion: network.Version0, - BlockDelay: 30, - ConsensusMinerMinPower: 32 << 30, + DevNet: true, + NetworkType: types.NetworkCalibnet, + GenesisNetworkVersion: network.Version0, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, abi.RegisteredSealProof_StackedDrg64GiBV1, }, + BlockDelay: 30, + ConsensusMinerMinPower: 32 << 30, + MinVerifiedDealSize: 1 << 20, + PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ UpgradeBreezeHeight: -1, UpgradeSmokeHeight: -2, @@ -58,9 +60,8 @@ func Calibration() *NetworkConf { UpgradeChocolateHeight: 312746, UpgradeOhSnapHeight: 682006, // 2022-02-10T19:23:00Z }, - DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, - AddressNetwork: address.Testnet, - PreCommitChallengeDelay: abi.ChainEpoch(150), + DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, + AddressNetwork: address.Testnet, }, } } diff --git a/fixtures/networks/forcenet.go b/fixtures/networks/forcenet.go index d5770c6c3c..ac074c0051 100644 --- a/fixtures/networks/forcenet.go +++ b/fixtures/networks/forcenet.go @@ -17,16 +17,18 @@ func ForceNet() *NetworkConf { Period: "30s", }, Network: config.NetworkParamsConfig{ - DevNet: true, + DevNet: true, + NetworkType: types.NetworkForce, + GenesisNetworkVersion: network.Version16, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg8MiBV1, abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1, }, - NetworkType: types.NetworkForce, - GenesisNetworkVersion: network.Version15, - BlockDelay: 30, - ConsensusMinerMinPower: 2048, + BlockDelay: 30, + ConsensusMinerMinPower: 2048, + MinVerifiedDealSize: 256, + PreCommitChallengeDelay: abi.ChainEpoch(10), ForkUpgradeParam: &config.ForkUpgradeConfig{ UpgradeBreezeHeight: -1, BreezeGasTampingDuration: 0, @@ -53,9 +55,8 @@ func ForceNet() *NetworkConf { UpgradeOhSnapHeight: -18, UpgradeSkyrHeight: -19, }, - DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandMainnet}, - AddressNetwork: address.Testnet, - PreCommitChallengeDelay: abi.ChainEpoch(10), + DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandMainnet}, + AddressNetwork: address.Testnet, }, } } diff --git a/fixtures/networks/integrationtestnet.go b/fixtures/networks/integrationtestnet.go index 052b00d817..d5cf478466 100644 --- a/fixtures/networks/integrationtestnet.go +++ b/fixtures/networks/integrationtestnet.go @@ -17,10 +17,16 @@ func IntegrationNet() *NetworkConf { Period: "30s", }, Network: config.NetworkParamsConfig{ - BlockDelay: 30, - ConsensusMinerMinPower: 10 << 40, - NetworkType: types.Integrationnet, - GenesisNetworkVersion: network.Version0, + NetworkType: types.Integrationnet, + GenesisNetworkVersion: network.Version0, + ReplaceProofTypes: []abi.RegisteredSealProof{ + abi.RegisteredSealProof_StackedDrg32GiBV1, + abi.RegisteredSealProof_StackedDrg64GiBV1, + }, + BlockDelay: 30, + ConsensusMinerMinPower: 10 << 40, + MinVerifiedDealSize: 1 << 20, + PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ UpgradeBreezeHeight: 41280, UpgradeSmokeHeight: 51000, @@ -44,9 +50,8 @@ func IntegrationNet() *NetworkConf { BreezeGasTampingDuration: 120, UpgradeClausHeight: 343200, }, - DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1}, - AddressNetwork: address.Testnet, - PreCommitChallengeDelay: abi.ChainEpoch(150), + DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1}, + AddressNetwork: address.Testnet, }, } } diff --git a/fixtures/networks/interopnet.go b/fixtures/networks/interopnet.go index 2f38a7edf0..f43bcc496a 100644 --- a/fixtures/networks/interopnet.go +++ b/fixtures/networks/interopnet.go @@ -19,17 +19,18 @@ func InteropNet() *NetworkConf { Period: "30s", }, Network: config.NetworkParamsConfig{ - DevNet: true, + DevNet: true, + NetworkType: types.NetworkInterop, + GenesisNetworkVersion: network.Version15, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg2KiBV1, abi.RegisteredSealProof_StackedDrg8MiBV1, abi.RegisteredSealProof_StackedDrg512MiBV1, }, - NetworkType: types.NetworkInterop, - GenesisNetworkVersion: network.Version15, - BlockDelay: 30, - ConsensusMinerMinPower: 2048, - MinVerifiedDealSize: 256, + BlockDelay: 30, + ConsensusMinerMinPower: 2048, + MinVerifiedDealSize: 256, + PreCommitChallengeDelay: abi.ChainEpoch(10), ForkUpgradeParam: &config.ForkUpgradeConfig{ UpgradeBreezeHeight: -1, UpgradeSmokeHeight: -2, @@ -53,9 +54,8 @@ func InteropNet() *NetworkConf { BreezeGasTampingDuration: 0, UpgradeClausHeight: -11, }, - DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, - AddressNetwork: address.Testnet, - PreCommitChallengeDelay: abi.ChainEpoch(10), + DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, + AddressNetwork: address.Testnet, }, } } diff --git a/fixtures/networks/mainnet.go b/fixtures/networks/mainnet.go index 9f89e98dcc..9ccf5b4aa0 100644 --- a/fixtures/networks/mainnet.go +++ b/fixtures/networks/mainnet.go @@ -37,7 +37,14 @@ func Mainnet() *NetworkConf { DevNet: false, NetworkType: types.NetworkMainnet, GenesisNetworkVersion: network.Version0, - BlockDelay: 30, + ReplaceProofTypes: []abi.RegisteredSealProof{ + abi.RegisteredSealProof_StackedDrg32GiBV1, + abi.RegisteredSealProof_StackedDrg64GiBV1, + }, + BlockDelay: 30, + ConsensusMinerMinPower: 10 << 40, + MinVerifiedDealSize: 1 << 20, + PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ UpgradeBreezeHeight: 41280, UpgradeSmokeHeight: 51000, @@ -59,14 +66,13 @@ func Mainnet() *NetworkConf { UpgradeHyperdriveHeight: 892800, // 2021-06-30T22:00:00Z UpgradeChocolateHeight: 1231620, UpgradeOhSnapHeight: 1594680, // 2022-03-01T15:00:00Z - UpgradeSkyrHeight: 99999999999999, + UpgradeSkyrHeight: 1960320, // 2022-07-06T14:00:00Z BreezeGasTampingDuration: 120, UpgradeClausHeight: 343200, // 2020-12-22T02:00:00Z }, - DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1}, - AddressNetwork: address.Mainnet, - PreCommitChallengeDelay: abi.ChainEpoch(150), + DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1}, + AddressNetwork: address.Mainnet, }, } } diff --git a/fixtures/networks/net_2k.go b/fixtures/networks/net_2k.go index 15bb47bc48..b4bb004c55 100644 --- a/fixtures/networks/net_2k.go +++ b/fixtures/networks/net_2k.go @@ -16,15 +16,16 @@ func Net2k() *NetworkConf { Period: "30s", }, Network: config.NetworkParamsConfig{ - NetworkType: types.Network2k, - GenesisNetworkVersion: network.Version16, - BlockDelay: 4, - ConsensusMinerMinPower: 2048, - MinVerifiedDealSize: 256, + NetworkType: types.Network2k, + GenesisNetworkVersion: network.Version16, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg2KiBV1, abi.RegisteredSealProof_StackedDrg8MiBV1, }, + BlockDelay: 4, + ConsensusMinerMinPower: 2048, + MinVerifiedDealSize: 256, + PreCommitChallengeDelay: abi.ChainEpoch(10), ForkUpgradeParam: &config.ForkUpgradeConfig{ UpgradeBreezeHeight: -1, UpgradeSmokeHeight: -2, @@ -48,9 +49,8 @@ func Net2k() *NetworkConf { BreezeGasTampingDuration: 0, UpgradeClausHeight: -11, }, - DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, - AddressNetwork: address.Testnet, - PreCommitChallengeDelay: abi.ChainEpoch(10), + DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, + AddressNetwork: address.Testnet, }, } } diff --git a/go.mod b/go.mod index e37ecade7a..ea7c9fda21 100644 --- a/go.mod +++ b/go.mod @@ -25,11 +25,11 @@ require ( github.com/filecoin-project/go-crypto v0.0.1 github.com/filecoin-project/go-data-transfer v1.15.1 github.com/filecoin-project/go-fil-commcid v0.1.0 - github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 + github.com/filecoin-project/go-fil-markets v1.20.1-v16-2 github.com/filecoin-project/go-jsonrpc v0.1.5 github.com/filecoin-project/go-leb128 v0.0.0-20190212224330-8d79a5489543 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.1.8 + github.com/filecoin-project/go-state-types v0.1.10 github.com/filecoin-project/pubsub v1.0.0 github.com/filecoin-project/specs-actors v0.9.15 github.com/filecoin-project/specs-actors/v2 v2.3.6 @@ -38,7 +38,7 @@ require ( github.com/filecoin-project/specs-actors/v5 v5.0.6 github.com/filecoin-project/specs-actors/v6 v6.0.2 github.com/filecoin-project/specs-actors/v7 v7.0.1 - github.com/filecoin-project/specs-actors/v8 v8.0.0 + github.com/filecoin-project/specs-actors/v8 v8.0.1 github.com/filecoin-project/specs-storage v0.4.1 github.com/filecoin-project/test-vectors/schema v0.0.5 github.com/filecoin-project/venus-auth v1.6.0-pre-rc1 diff --git a/go.sum b/go.sum index 2f98053970..770e652da9 100644 --- a/go.sum +++ b/go.sum @@ -334,8 +334,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8= -github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 h1:/eZXwVg2Z7qPwTBUAinA7m6w6rLYBeSvE61XW8MTV5M= -github.com/filecoin-project/go-fil-markets v1.20.1-v16-1/go.mod h1:QHJZVEbQ7TydJ6hjK87q4MxOmRfDNbQkuSkdjxtqBWo= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-2 h1:uZHJav35gTGcm2CwY8B+V6fQO9aB1YeUYid2jkb6jXE= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-2/go.mod h1:JLP8bltMbPVhOULcHxE+QFg3b8/a9J8NbcA6Qf69W0k= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= @@ -361,8 +361,9 @@ github.com/filecoin-project/go-state-types v0.1.3/go.mod h1:ezYnPf0bNkTsDibL/psS github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4IrzznwS98X5XW/irUP3Lhxg= github.com/filecoin-project/go-state-types v0.1.5/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.1.8 h1:mrPnqeOHkBXOUkYZdIee7F1VcjKw7dtpVam8VrTvpuI= github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.10 h1:YrrJWWh2fU4VPhwHyPlDK5I4mB7bqgnRd3HCm9IOwIU= +github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc= @@ -398,8 +399,8 @@ github.com/filecoin-project/specs-actors/v6 v6.0.2/go.mod h1:wnfVvPnYmzPZilNvSqC github.com/filecoin-project/specs-actors/v7 v7.0.0/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= github.com/filecoin-project/specs-actors/v7 v7.0.1 h1:w72xCxijK7xs1qzmJiw+WYJaVt2EPHN8oiwpA1Ay3/4= github.com/filecoin-project/specs-actors/v7 v7.0.1/go.mod h1:tPLEYXoXhcpyLh69Ccq91SOuLXsPWjHiY27CzawjUEk= -github.com/filecoin-project/specs-actors/v8 v8.0.0 h1:c6NztoE4J5j7KvIfGmx9XW9o5aszPl6DU0M4xDqAJVU= -github.com/filecoin-project/specs-actors/v8 v8.0.0/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= +github.com/filecoin-project/specs-actors/v8 v8.0.1 h1:4u0tIRJeT5G7F05lwLRIsDnsrN+bJ5Ixj6h49Q7uE2Y= +github.com/filecoin-project/specs-actors/v8 v8.0.1/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= github.com/filecoin-project/specs-storage v0.4.1 h1:yvLEaLZj8f+uByhNC4mFOtCUyL2wQku+NGBp6hjTe9M= github.com/filecoin-project/specs-storage v0.4.1/go.mod h1:Z2eK6uMwAOSLjek6+sy0jNV2DSsMEENziMUz0GHRFBw= github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q= diff --git a/pkg/chain/randomness.go b/pkg/chain/randomness.go index e406dc25ec..602f9f0b86 100644 --- a/pkg/chain/randomness.go +++ b/pkg/chain/randomness.go @@ -232,7 +232,7 @@ func (c *ChainRandomnessSource) GetBeaconRandomnessV3(ctx context.Context, pers be, err := c.extractBeaconEntryForEpoch(ctx, filecoinEpoch) if err != nil { - log.Errorf("failed to get beacon entry as expected: %w", err) + log.Errorf("failed to get beacon entry as expected: %s", err) return nil, err } diff --git a/pkg/chain/utils.go b/pkg/chain/utils.go index 777426fd31..0daad70fef 100644 --- a/pkg/chain/utils.go +++ b/pkg/chain/utils.go @@ -2,121 +2,14 @@ package chain import ( "context" - "reflect" - "runtime" - "strings" "github.com/filecoin-project/venus/pkg/util/blockstoreutil" "github.com/filecoin-project/venus/venus-shared/types" - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/rt" blockFormat "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" - - exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported" - exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported" - exported3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/exported" - exported4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/exported" - exported5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/exported" - exported6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/exported" - exported7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported" - exported8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/exported" - - _actors "github.com/filecoin-project/venus/venus-shared/actors" - "github.com/filecoin-project/venus/venus-shared/actors/builtin" ) -type MethodMeta struct { - Name string - - Params reflect.Type - Ret reflect.Type -} - -var MethodsMap = map[cid.Cid]map[abi.MethodNum]MethodMeta{} - -type actorsWithVersion struct { - av _actors.Version - actors []rt.VMActor -} - -func init() { - // TODO: combine with the runtime actor registry. - var actors []actorsWithVersion - - actors = append(actors, actorsWithVersion{av: _actors.Version0, actors: exported0.BuiltinActors()}) - actors = append(actors, actorsWithVersion{av: _actors.Version2, actors: exported2.BuiltinActors()}) - actors = append(actors, actorsWithVersion{av: _actors.Version3, actors: exported3.BuiltinActors()}) - actors = append(actors, actorsWithVersion{av: _actors.Version4, actors: exported4.BuiltinActors()}) - actors = append(actors, actorsWithVersion{av: _actors.Version5, actors: exported5.BuiltinActors()}) - actors = append(actors, actorsWithVersion{av: _actors.Version6, actors: exported6.BuiltinActors()}) - actors = append(actors, actorsWithVersion{av: _actors.Version7, actors: exported7.BuiltinActors()}) - actors = append(actors, actorsWithVersion{av: _actors.Version8, actors: exported8.BuiltinActors()}) - - for _, awv := range actors { - for _, actor := range awv.actors { - // necessary to make stuff work - ac := actor.Code() - var realCode cid.Cid - if awv.av >= _actors.Version8 { - name := _actors.CanonicalName(builtin.ActorNameByCode(ac)) - - realCode, _ = _actors.GetActorCodeID(awv.av, name) - } - - exports := actor.Exports() - methods := make(map[abi.MethodNum]MethodMeta, len(exports)) - - // Explicitly add send, it's special. - methods[builtin.MethodSend] = MethodMeta{ - Name: "Send", - Params: reflect.TypeOf(new(abi.EmptyValue)), - Ret: reflect.TypeOf(new(abi.EmptyValue)), - } - - // Iterate over exported methods. Some of these _may_ be nil and - // must be skipped. - for number, export := range exports { - if export == nil { - continue - } - - ev := reflect.ValueOf(export) - et := ev.Type() - - // Extract the method names using reflection. These - // method names always match the field names in the - // `builtin.Method*` structs (tested in the specs-actors - // tests). - fnName := runtime.FuncForPC(ev.Pointer()).Name() - fnName = strings.TrimSuffix(fnName[strings.LastIndexByte(fnName, '.')+1:], "-fm") - - switch abi.MethodNum(number) { - case builtin.MethodSend: - panic("method 0 is reserved for Send") - case builtin.MethodConstructor: - if fnName != "Constructor" { - panic("method 1 is reserved for Constructor") - } - } - - methods[abi.MethodNum(number)] = MethodMeta{ - Name: fnName, - Params: et.In(1), - Ret: et.Out(0), - } - } - - if realCode.Defined() { - MethodsMap[realCode] = methods - } else { - MethodsMap[actor.Code()] = methods - } - } - } -} - type storable interface { ToStorageBlock() (blockFormat.Block, error) } diff --git a/pkg/config/config.go b/pkg/config/config.go index 294b20780a..990277022e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -312,7 +312,7 @@ var DefaultForkUpgradeParam = &ForkUpgradeConfig{ UpgradeHyperdriveHeight: 892800, UpgradeChocolateHeight: 1231620, UpgradeOhSnapHeight: 1594680, - UpgradeSkyrHeight: 99999999999999, + UpgradeSkyrHeight: 1960320, } func newDefaultNetworkParamsConfig() *NetworkParamsConfig { diff --git a/pkg/consensus/processor.go b/pkg/consensus/processor.go index 2999054554..58be61914c 100644 --- a/pkg/consensus/processor.go +++ b/pkg/consensus/processor.go @@ -50,7 +50,7 @@ var _ Processor = (*DefaultProcessor)(nil) // NewDefaultProcessor creates a default processor from the given state tree and vms. func NewDefaultProcessor(syscalls vm.SyscallsImpl, circulatingSupplyCalculator chain.ICirculatingSupplyCalcualtor) *DefaultProcessor { - return NewConfiguredProcessor(vm.DefaultActors, syscalls, circulatingSupplyCalculator) + return NewConfiguredProcessor(*vm.GetDefaultActors(), syscalls, circulatingSupplyCalculator) } // NewConfiguredProcessor creates a default processor with custom validation and rewards. diff --git a/pkg/constants/version.go b/pkg/constants/version.go index 87f92895b3..349fe4c460 100644 --- a/pkg/constants/version.go +++ b/pkg/constants/version.go @@ -5,7 +5,7 @@ import ( ) // BuildVersion is the local build version, set by build system -const BuildVersion = "1.6.0-rc1" +const BuildVersion = "1.6.0-rc2" var CurrentCommit string diff --git a/pkg/fork/FVMLiftoff.txt b/pkg/fork/FVMLiftoff.txt new file mode 100644 index 0000000000..4bff5c25b0 --- /dev/null +++ b/pkg/fork/FVMLiftoff.txt @@ -0,0 +1,57 @@ + . + + . ' ` . + . ' . + + . ' . ' | + . ' . ' | ++ . ' . + +| ` . . ' . ' . +| + . ' . + ++ | . ' . ' | + ` . | . ' . ' | ++ + . ' . + +| ` . . ' . ' +| + . ' ++ | . ' . + ` . | '. ` . + + ` . ` . + ` . ` . ` . --- --- + ` . ` . . + /\__\ ___ /\ \ + ` . + ' | /:/ _/_ /\ \ |::\ \ + ` . | | /:/ /\__\ \:\ \ |:|:\ \ + ` . | . + /:/ /:/ / \:\ \ __|:|\:\ \ + + ' /:/_/:/ / ___ \:\__\ /::::|_\:\__\ + \:\/:/ / /\ \ |:| | \:\~~\ \/__/ + \::/__/ \:\ \|:| | \:\ \ + \:\ \ \:\__|:|__| \:\ \ + \:\__\ \::::/__/ \:\__\ + \/__/ ~~~~ \/__/ + ___ ___ ___ ___ + /\__\ /\ \ /\__\ /\__\ + ___ /:/ _/_ ___ /::\ \ /:/ _/_ /:/ _/_ + /\__\ /:/ /\__\ /\__\ /:/\:\ \ /:/ /\__\ /:/ /\__\ + ___ ___ /:/__/ /:/ /:/ / /:/ / /:/ \:\ \ /:/ /:/ / /:/ /:/ / + /\ \ /\__\ /::\ \ /:/_/:/ / /:/__/ /:/__/ \:\__\ /:/_/:/ / /:/_/:/ / + \:\ \ /:/ / \/\:\ \__ \:\/:/ / /::\ \ \:\ \ /:/ / \:\/:/ / \:\/:/ / + \:\ /:/ / ~~\:\/\__\ \::/__/ /:/\:\ \ \:\ /:/ / \::/__/ \::/__/ . + + \:\/:/ / \::/ / \:\ \ \/__\:\ \ \:\/:/ / \:\ \ \:\ \ . ' ` . + \::/ / /:/ / \:\__\ \:\__\ \::/ / \:\__\ \:\__\ . ' . + + \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ . ' . ' | + . ' . ' | + + . ' . + + | ` . . ' . ' . + | + . ' . + + + | . ' . ' | + ` . | . ' . ' | + + + . ' . + + | ` . . ' . ' + | + . ' + + | . ' . + ` . | '. ` . + + ` . ` . + ` . ` . ` . + ` . ` . . + + ` . + ' | + ` . | | + ` . | . + + + diff --git a/pkg/fork/fork.go b/pkg/fork/fork.go index f77f22ca61..9d4cd0144e 100644 --- a/pkg/fork/fork.go +++ b/pkg/fork/fork.go @@ -3,6 +3,7 @@ package fork import ( "bytes" "context" + _ "embed" "encoding/binary" "errors" "fmt" @@ -16,8 +17,10 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/rt" + gstStore "github.com/filecoin-project/go-state-types/store" ipfsblock "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" blockstore "github.com/ipfs/go-ipfs-blockstore" @@ -53,10 +56,14 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/builtin" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" "github.com/filecoin-project/venus/venus-shared/actors/builtin/multisig" + "github.com/filecoin-project/venus/venus-shared/actors/builtin/system" builtinactors "github.com/filecoin-project/venus/venus-shared/builtin-actors" "github.com/filecoin-project/venus/venus-shared/types" ) +//go:embed FVMLiftoff.txt +var fvmLiftoffBanner string + var log = logging.Logger("fork") var ErrExpensiveFork = errors.New("refusing explicit call due to state fork at epoch") @@ -2037,6 +2044,8 @@ func (c *ChainFork) UpgradeActorsV8(ctx context.Context, cache MigrationCache, r return cid.Undef, fmt.Errorf("migrating actors v8 state: %w", err) } + fmt.Print(fvmLiftoffBanner) + return newRoot, nil } @@ -2128,3 +2137,186 @@ func (c *ChainFork) upgradeActorsV8Common( func (c *ChainFork) GetForkUpgrade() *config.ForkUpgradeConfig { return c.forkUpgrade } + +// Example upgrade function if upgrade requires only code changes +// func (c *ChainFork) upgradeActorsV9Common( +// ctx context.Context, cache MigrationCache, +// root cid.Cid, +// epoch abi.ChainEpoch, +// ts *types.TipSet, +// config nv16.Config, +// ) (cid.Cid, error) { +// buf := blockstoreutil.NewTieredBstore(c.bs, blockstoreutil.NewTemporarySync()) + +// av := actors.Version9 +// // This may change for upgrade +// newStateTreeVersion := vmstate.StateTreeVersion4 + +// // ensure that the manifest is loaded in the blockstore +// if err := builtinactors.LoadBundles(ctx, buf, actors.Version9); err != nil { +// return cid.Undef, fmt.Errorf("failed to load manifest bundle: %w", err) +// } + +// newActorsManifestCid, ok := actors.GetManifest(av) +// if !ok { +// return cid.Undef, fmt.Errorf("no manifest CID for v8 upgrade") +// } + +// bstore := c.bs +// return LiteMigration(ctx, bstore, newActorsManifestCid, root, av, vmstate.StateTreeVersion4, newStateTreeVersion) +// } + +func LiteMigration(ctx context.Context, bstore blockstoreutil.Blockstore, newActorsManifestCid cid.Cid, root cid.Cid, av actors.Version, oldStateTreeVersion vmstate.StateTreeVersion, newStateTreeVersion vmstate.StateTreeVersion) (cid.Cid, error) { + buf := blockstoreutil.NewTieredBstore(bstore, blockstoreutil.NewTemporarySync()) + store := chain.ActorStore(ctx, buf) + adtStore := gstStore.WrapStore(ctx, store) + + // Load the state root. + var stateRoot vmstate.StateRoot + if err := store.Get(ctx, root, &stateRoot); err != nil { + return cid.Undef, fmt.Errorf("failed to decode state root: %w", err) + } + + if stateRoot.Version != oldStateTreeVersion { + return cid.Undef, fmt.Errorf( + "expected state tree version %d for actors code upgrade, got %d", + oldStateTreeVersion, + stateRoot.Version, + ) + } + + st, err := vmstate.LoadState(ctx, store, root) + if err != nil { + return cid.Undef, fmt.Errorf("failed to load state tree: %w", err) + } + + oldManifest, err := getManifest(ctx, st) + if err != nil { + return cid.Undef, fmt.Errorf("error loading old actor manifest: %w", err) + } + oldManifestData := manifest.ManifestData{} + if err := store.Get(ctx, oldManifest.Data, &oldManifestData); err != nil { + return cid.Undef, fmt.Errorf("error loading old manifest data: %w", err) + } + + // load new manifest + newManifest := manifest.Manifest{} + if err := store.Get(ctx, newActorsManifestCid, &newManifest); err != nil { + return cid.Undef, fmt.Errorf("error loading new manifest: %w", err) + } + newManifestData := manifest.ManifestData{} + if err := store.Get(ctx, newManifest.Data, &newManifestData); err != nil { + return cid.Undef, fmt.Errorf("error loading new manifest data: %w", err) + } + + if len(oldManifestData.Entries) != len(actors.GetBuiltinActorsKeys()) { + return cid.Undef, fmt.Errorf("incomplete old manifest with %d code CIDs", len(oldManifestData.Entries)) + } + if len(newManifestData.Entries) != len(actors.GetBuiltinActorsKeys()) { + return cid.Undef, fmt.Errorf("incomplete new manifest with %d code CIDs", len(newManifestData.Entries)) + } + + // Maps prior version code CIDs to migration functions. + migrations := make(map[cid.Cid]cid.Cid) + + for _, entry := range newManifestData.Entries { + oldCodeCid, ok := oldManifest.Get(entry.Name) + if !ok { + return cid.Undef, fmt.Errorf("code cid for %s actor not found in old manifest", entry.Name) + } + migrations[oldCodeCid] = entry.Code + } + + startTime := time.Now() + + // Load output state tree + actorsOut, err := vmstate.NewState(adtStore, newStateTreeVersion) + if err != nil { + return cid.Undef, err + } + + // Insert migrated records in output state tree. + err = st.ForEach(func(addr address.Address, actorIn *types.Actor) error { + newCid, ok := migrations[actorIn.Code] + if !ok { + return fmt.Errorf("new code cid not found in migrations for actor %s", addr) + } + var head cid.Cid + if addr == system.Address { + newSystemState, err := system.MakeState(store, av, newManifest.Data) + if err != nil { + return fmt.Errorf("could not make system actor state: %w", err) + } + head, err = store.Put(ctx, newSystemState) + if err != nil { + return fmt.Errorf("could not set system actor state head: %w", err) + } + } else { + head = actorIn.Head + } + newActor := types.Actor{ + Code: newCid, + Head: head, + Nonce: actorIn.Nonce, + Balance: actorIn.Balance, + } + err = actorsOut.SetActor(ctx, addr, &newActor) + if err != nil { + return fmt.Errorf("could not set actor at address %s: %w", addr, err) + } + + return nil + }) + if err != nil { + return cid.Undef, fmt.Errorf("failed update actor states: %w", err) + } + + elapsed := time.Since(startTime) + log.Infof("All done after %v. Flushing state tree root.", elapsed) + newRoot, err := actorsOut.Flush(ctx) + if err != nil { + return cid.Undef, fmt.Errorf("failed to flush new actors: %w", err) + } + + // Persist the new tree. + { + from := buf + to := buf.Read() + + if err := Copy(ctx, from, to, newRoot); err != nil { + return cid.Undef, fmt.Errorf("copying migrated tree: %w", err) + } + } + + return newRoot, nil +} + +func getManifest(ctx context.Context, st *vmstate.State) (*manifest.Manifest, error) { + wrapStore := gstStore.WrapStore(ctx, st.Store) + + systemActor, found, err := st.GetActor(ctx, system.Address) + if err != nil { + return nil, fmt.Errorf("failed to get system actor: %w", err) + } + if !found { + return nil, fmt.Errorf("not found actor") + } + systemActorState, err := system.Load(wrapStore, systemActor) + if err != nil { + return nil, fmt.Errorf("failed to load system actor state: %w", err) + } + actorsManifestCid := systemActorState.GetBuiltinActors() + + mf := manifest.Manifest{ + Version: 1, + Data: actorsManifestCid, + } + if err := mf.Load(ctx, wrapStore); err != nil { + return nil, fmt.Errorf("failed to load actor manifest: %w", err) + } + manifestData := manifest.ManifestData{} + if err := st.Store.Get(ctx, mf.Data, &manifestData); err != nil { + return nil, fmt.Errorf("failed to load manifest data: %w", err) + } + return &mf, nil +} diff --git a/pkg/fvm/fvm.go b/pkg/fvm/fvm.go index 11de47aa3e..1203bc9e42 100644 --- a/pkg/fvm/fvm.go +++ b/pkg/fvm/fvm.go @@ -376,13 +376,14 @@ func (fvm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*vm.Ret, return nil, fmt.Errorf("failed to unmarshal exectrace: %w", err) } et = fvmEt.ToExecutionTrace() - } else { - et.Msg = vmMsg - et.MsgRct = &receipt - et.Duration = duration - if aerr != nil { - et.Error = aerr.Error() - } + } + + // Set the top-level exectrace info from the message and receipt for backwards compatibility + et.Msg = vmMsg + et.MsgRct = &receipt + et.Duration = duration + if aerr != nil { + et.Error = aerr.Error() } return &vm.Ret{ @@ -494,7 +495,7 @@ func (r wrapperRand) GetBeaconRandomness(ctx context.Context, pers acrypto.Domai return r.ChainGetRandomnessFromBeacon(ctx, pers, round, entropy) } -var experimentalUseFvm = os.Getenv("VENUS_USE_FVM_TO_SYNC_MAINNET_V15") == "1" +var useFvmForMainnetV15 = os.Getenv("VENUS_USE_FVM_TO_SYNC_MAINNET_V15") == "1" func NewVM(ctx context.Context, opts vm.VmOption) (vm.Interface, error) { if opts.NetworkVersion >= network.Version16 { @@ -502,7 +503,7 @@ func NewVM(ctx context.Context, opts vm.VmOption) (vm.Interface, error) { } // Remove after v16 upgrade, this is only to support testing and validation of the FVM - if experimentalUseFvm && opts.NetworkVersion >= network.Version15 { + if useFvmForMainnetV15 && opts.NetworkVersion >= network.Version15 { fvmLog.Info("use fvm") return NewFVM(ctx, &opts) } diff --git a/pkg/gen/genesis/f00_system.go b/pkg/gen/genesis/f00_system.go index 127697e5e4..b63f14c2d6 100644 --- a/pkg/gen/genesis/f00_system.go +++ b/pkg/gen/genesis/f00_system.go @@ -16,6 +16,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/builtin/system" + "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" bstore "github.com/filecoin-project/venus/pkg/util/blockstoreutil" @@ -26,7 +27,8 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi var st system.State cst := cbor.NewCborStore(bs) - st, err := system.MakeState(adt.WrapStore(ctx, cst), av) + // TODO pass in built-in actors cid for V8 and later + st, err := system.MakeState(adt.WrapStore(ctx, cst), av, cid.Undef) if err != nil { return nil, err } diff --git a/pkg/gen/genesis/miners.go b/pkg/gen/genesis/miners.go index 8db8bbc452..fdb6be5ad3 100644 --- a/pkg/gen/genesis/miners.go +++ b/pkg/gen/genesis/miners.go @@ -115,6 +115,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min BaseFee: big.NewInt(0), Epoch: 0, PRoot: base, + NetworkVersion: nv, Bsstore: cs.Blockstore(), SysCallsImpl: mkFakedSigSyscalls(syscalls), GasPriceSchedule: gasPirceSchedule, @@ -262,7 +263,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min var sig *crypto.Signature err = preseal.DealClientKey.UsePrivateKey(func(privateKey []byte) error { var err error - sig, err = crypto2.Sign(privateKey, buf, preseal.DealClientKey.SigType) + sig, err = crypto2.Sign(buf, privateKey, preseal.DealClientKey.SigType) return err }) if err != nil { diff --git a/pkg/migration/migrate.go b/pkg/migration/migrate.go index cbcca4d6f6..af7b098144 100644 --- a/pkg/migration/migrate.go +++ b/pkg/migration/migrate.go @@ -5,7 +5,6 @@ import ( "fmt" "io/ioutil" "math" - "os" "path/filepath" "github.com/filecoin-project/go-state-types/network" @@ -42,9 +41,7 @@ func TryToMigrate(repoPath string) error { } for _, up := range versionMap { - // 实现根据环境变量 `VENUS_DISABLE_SKYR` 来控制是否升级fvm - // todo: 在下一次网络(nv17)升级移除 - if up.version > localVersion || (localVersion == 8 && up.version == 8) { + if up.version > localVersion { err = up.upgrade(repoPath) if err != nil { return err @@ -107,6 +104,8 @@ func Version4Upgrade(repoPath string) (err error) { cfg.NetworkParams.ForkUpgradeParam = networks.ForceNet().Network.ForkUpgradeParam case types.NetworkButterfly: cfg.NetworkParams.ForkUpgradeParam = networks.ButterflySnapNet().Network.ForkUpgradeParam + case types.NetworkInterop: + cfg.NetworkParams.ForkUpgradeParam = networks.InteropNet().Network.ForkUpgradeParam default: return fsrRepo.Close() } @@ -217,7 +216,7 @@ func Version7Upgrade(repoPath string) (err error) { cfg.NetworkParams.ForkUpgradeParam.UpgradeOhSnapHeight = 682006 case types.NetworkButterfly: cfg.NetworkParams.GenesisNetworkVersion = network.Version14 - cfg.NetworkParams.ForkUpgradeParam.UpgradeOhSnapHeight = 240 + cfg.NetworkParams.ForkUpgradeParam.UpgradeOhSnapHeight = -18 case types.NetworkForce: cfg.NetworkParams.GenesisNetworkVersion = network.Version0 cfg.NetworkParams.ForkUpgradeParam.UpgradeOhSnapHeight = -18 @@ -270,25 +269,21 @@ func Version8Upgrade(repoPath string) (err error) { switch cfg.NetworkParams.NetworkType { case types.NetworkMainnet: cfg.NetworkParams.GenesisNetworkVersion = network.Version0 - cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 99999999999999 - // https://github.com/filecoin-project/lotus/pull/8733 - if os.Getenv("VENUS_DISABLE_SKYR") == "1" { - cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 99999999999999 - } + cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 1960320 case types.Network2k: - cfg.NetworkParams.GenesisNetworkVersion = network.Version15 + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 case types.NetworkCalibnet: cfg.NetworkParams.GenesisNetworkVersion = network.Version0 cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 1044660 case types.NetworkForce: - cfg.NetworkParams.GenesisNetworkVersion = network.Version15 + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 case types.NetworkInterop: - cfg.NetworkParams.GenesisNetworkVersion = network.Version14 + cfg.NetworkParams.GenesisNetworkVersion = network.Version15 cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 100 case types.NetworkButterfly: - cfg.NetworkParams.GenesisNetworkVersion = network.Version14 + cfg.NetworkParams.GenesisNetworkVersion = network.Version15 cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 50 default: return fsrRepo.Close() diff --git a/pkg/migration/migrate_test.go b/pkg/migration/migrate_test.go new file mode 100644 index 0000000000..1dd430c8e0 --- /dev/null +++ b/pkg/migration/migrate_test.go @@ -0,0 +1,43 @@ +package migration + +import ( + "os" + "testing" + + "github.com/filecoin-project/venus/fixtures/networks" + "github.com/filecoin-project/venus/pkg/config" + "github.com/filecoin-project/venus/pkg/repo" + tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags" + "github.com/filecoin-project/venus/venus-shared/types" + "github.com/stretchr/testify/assert" +) + +func TestMigration(t *testing.T) { + tf.UnitTest(t) + + cfgs := map[types.NetworkType]*config.NetworkParamsConfig{ + types.Network2k: &networks.Net2k().Network, + types.NetworkForce: &networks.ForceNet().Network, + types.NetworkInterop: &networks.InteropNet().Network, + types.NetworkButterfly: &networks.ButterflySnapNet().Network, + types.NetworkCalibnet: &networks.Calibration().Network, + types.NetworkMainnet: &networks.Mainnet().Network, + } + + for nt, paramsCfg := range cfgs { + cfg := config.NewDefaultConfig() + cfg.NetworkParams.NetworkType = nt + repoPath := t.TempDir() + assert.Nil(t, os.RemoveAll(repoPath)) + t.Log(repoPath) + assert.Nil(t, repo.InitFSRepo(repoPath, 0, cfg)) + + assert.Nil(t, TryToMigrate(repoPath)) + fsRepo, err := repo.OpenFSRepo(repoPath, repo.LatestVersion) + assert.Nil(t, err) + newCfg := fsRepo.Config() + assert.Equal(t, paramsCfg.GenesisNetworkVersion, newCfg.NetworkParams.GenesisNetworkVersion) + assert.EqualValues(t, paramsCfg.ForkUpgradeParam, newCfg.NetworkParams.ForkUpgradeParam) + + } +} diff --git a/pkg/repo/fsrepo.go b/pkg/repo/fsrepo.go index bfb718bdfb..59a030477d 100644 --- a/pkg/repo/fsrepo.go +++ b/pkg/repo/fsrepo.go @@ -216,11 +216,7 @@ func (r *FSRepo) loadFromDisk() error { } if localVersion > r.version { - // 实现根据环境变量 `VENUS_DISABLE_SKYR` 来控制是否升级fvm - // todo: 在下一次网络(nv17)升级移除 - if r.version != 7 { - return fmt.Errorf("binary needs update to handle repo version, got %d expected %d. Update binary to latest release", localVersion, LatestVersion) - } + return fmt.Errorf("binary needs update to handle repo version, got %d expected %d. Update binary to latest release", localVersion, LatestVersion) } if err := r.loadConfig(); err != nil { diff --git a/pkg/util/ulimit/ulimit_freebsd.go b/pkg/util/ulimit/ulimit_freebsd.go index 7e50436f3d..a5ff35707b 100644 --- a/pkg/util/ulimit/ulimit_freebsd.go +++ b/pkg/util/ulimit/ulimit_freebsd.go @@ -1,3 +1,4 @@ +//go:build freebsd // +build freebsd package ulimit diff --git a/pkg/vm/register/default.go b/pkg/vm/register/default.go index 26eaf44e32..8491c2a9f3 100644 --- a/pkg/vm/register/default.go +++ b/pkg/vm/register/default.go @@ -1,10 +1,11 @@ package register import ( + "sync" + /* inline-gen template {{range .actorVersions}} exported{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/exported"{{end}} - /* inline-gen start */ exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported" @@ -22,27 +23,32 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors" ) -// DefaultActors is list of all actors that ship with Filecoin. +// defaultActors is list of all actors that ship with Filecoin. // They are indexed by their CID. // Dragons: add the rest of the actors var DefaultActorBuilder = dispatch.NewBuilder() -var DefaultActors dispatch.CodeLoader +var loadOnce sync.Once +var defaultActors dispatch.CodeLoader -func init() { - /* inline-gen template - {{range .actorVersions}} +func GetDefaultActros() *dispatch.CodeLoader { + loadOnce.Do(func() { + /* inline-gen template + {{range .actorVersions}} DefaultActorBuilder.AddMany(actors.Version{{.}}, dispatch.ActorsVersionPredicate(actors.Version{{.}}), exported{{.}}.BuiltinActors()...){{end}} - /* inline-gen start */ - - DefaultActorBuilder.AddMany(actors.Version0, dispatch.ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...) - DefaultActorBuilder.AddMany(actors.Version2, dispatch.ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...) - DefaultActorBuilder.AddMany(actors.Version3, dispatch.ActorsVersionPredicate(actors.Version3), exported3.BuiltinActors()...) - DefaultActorBuilder.AddMany(actors.Version4, dispatch.ActorsVersionPredicate(actors.Version4), exported4.BuiltinActors()...) - DefaultActorBuilder.AddMany(actors.Version5, dispatch.ActorsVersionPredicate(actors.Version5), exported5.BuiltinActors()...) - DefaultActorBuilder.AddMany(actors.Version6, dispatch.ActorsVersionPredicate(actors.Version6), exported6.BuiltinActors()...) - DefaultActorBuilder.AddMany(actors.Version7, dispatch.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...) - DefaultActorBuilder.AddMany(actors.Version8, dispatch.ActorsVersionPredicate(actors.Version8), exported8.BuiltinActors()...) - /* inline-gen end */ - - DefaultActors = DefaultActorBuilder.Build() + /* inline-gen start */ + + DefaultActorBuilder.AddMany(actors.Version0, dispatch.ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...) + DefaultActorBuilder.AddMany(actors.Version2, dispatch.ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...) + DefaultActorBuilder.AddMany(actors.Version3, dispatch.ActorsVersionPredicate(actors.Version3), exported3.BuiltinActors()...) + DefaultActorBuilder.AddMany(actors.Version4, dispatch.ActorsVersionPredicate(actors.Version4), exported4.BuiltinActors()...) + DefaultActorBuilder.AddMany(actors.Version5, dispatch.ActorsVersionPredicate(actors.Version5), exported5.BuiltinActors()...) + DefaultActorBuilder.AddMany(actors.Version6, dispatch.ActorsVersionPredicate(actors.Version6), exported6.BuiltinActors()...) + DefaultActorBuilder.AddMany(actors.Version7, dispatch.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...) + DefaultActorBuilder.AddMany(actors.Version8, dispatch.ActorsVersionPredicate(actors.Version8), exported8.BuiltinActors()...) + /* inline-gen end */ + + defaultActors = DefaultActorBuilder.Build() + }) + + return &defaultActors } diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 7335cf38a5..4a2ea5afdf 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -30,14 +30,14 @@ type Interface = vmcontext.Interface // nolint // NewLegacyVM creates a new LegacyVM interpreter. func NewLegacyVM(ctx context.Context, option VmOption) (Interpreter, error) { if option.ActorCodeLoader == nil { - option.ActorCodeLoader = &DefaultActors + option.ActorCodeLoader = GetDefaultActors() } return vmcontext.NewLegacyVM(ctx, option.ActorCodeLoader, option) } -// DefaultActors is a code loader with the built-in actors that come with the system. -var DefaultActors = register.DefaultActors +// GetDefaultActors return a code loader with the built-in actors that come with the system. +var GetDefaultActors = register.GetDefaultActros // ActorCodeLoader allows yo to load an actor's code based on its id an epoch. type ActorCodeLoader = dispatch.CodeLoader diff --git a/tools/conformance/driver.go b/tools/conformance/driver.go index 293147abd4..420bc2a339 100644 --- a/tools/conformance/driver.go +++ b/tools/conformance/driver.go @@ -236,6 +236,7 @@ func (d *Driver) ExecuteMessage(bs blockstoreutil.Blockstore, params ExecuteMess actorBuilder.Add(av, nil, chaosActor) } + register.GetDefaultActros() coderLoader := actorBuilder.Build() if params.Rand == nil { diff --git a/venus-devtool/api-gen/example.go b/venus-devtool/api-gen/example.go index b313195be1..7d5ce94c04 100644 --- a/venus-devtool/api-gen/example.go +++ b/venus-devtool/api-gen/example.go @@ -18,6 +18,7 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/venus/venus-shared/types/market" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" "github.com/ipfs/go-graphsync" textselector "github.com/ipld/go-ipld-selector-text-lite" @@ -122,6 +123,8 @@ func init() { if err != nil { panic(err) } + block := blocks.Block(&blocks.BasicBlock{}) + ExampleValues[reflect.TypeOf(&block).Elem()] = block addExample(reqID) addExample(datatransfer.TransferID(3)) addExample(datatransfer.Ongoing) diff --git a/venus-devtool/go.mod b/venus-devtool/go.mod index 1202e5c63d..681c4d306b 100644 --- a/venus-devtool/go.mod +++ b/venus-devtool/go.mod @@ -3,14 +3,15 @@ module github.com/filecoin-project/venus/venus-devtool go 1.17 require ( - github.com/filecoin-project/go-address v0.0.6 + github.com/filecoin-project/go-address v1.0.0 github.com/filecoin-project/go-bitfield v0.2.4 github.com/filecoin-project/go-data-transfer v1.15.1 - github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 + github.com/filecoin-project/go-fil-markets v1.20.1-v16-2 github.com/filecoin-project/go-jsonrpc v0.1.5 - github.com/filecoin-project/go-state-types v0.1.8 - github.com/filecoin-project/lotus v1.16.0-pre-rc.0.20220611005856-f01bd41cc811 + github.com/filecoin-project/go-state-types v0.1.10 + github.com/filecoin-project/lotus v1.16.0-pre-rc.0.20220614091823-016749b60be5 github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000 + github.com/ipfs/go-block-format v0.0.3 github.com/ipfs/go-cid v0.1.0 github.com/ipfs/go-graphsync v0.13.1 github.com/ipld/go-ipld-selector-text-lite v0.0.1 @@ -57,7 +58,7 @@ require ( github.com/filecoin-project/specs-actors/v5 v5.0.6 // indirect github.com/filecoin-project/specs-actors/v6 v6.0.2 // indirect github.com/filecoin-project/specs-actors/v7 v7.0.1 // indirect - github.com/filecoin-project/specs-actors/v8 v8.0.0 // indirect + github.com/filecoin-project/specs-actors/v8 v8.0.1 // indirect github.com/filecoin-project/specs-storage v0.4.1 // indirect github.com/fxamacker/cbor/v2 v2.4.0 // indirect github.com/gbrlsnchs/jwt/v3 v3.0.1 // indirect @@ -77,7 +78,6 @@ require ( github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/icza/backscanner v0.0.0-20210726202459-ac2ffc679f94 // indirect github.com/ipfs/bbloom v0.0.4 // indirect - github.com/ipfs/go-block-format v0.0.3 // indirect github.com/ipfs/go-blockservice v0.2.1 // indirect github.com/ipfs/go-datastore v0.5.1 // indirect github.com/ipfs/go-ipfs-blockstore v1.1.2 // indirect diff --git a/venus-devtool/go.sum b/venus-devtool/go.sum index 3adbda9a7e..b3dd9e5706 100644 --- a/venus-devtool/go.sum +++ b/venus-devtool/go.sum @@ -312,8 +312,9 @@ github.com/filecoin-project/dagstore v0.5.2 h1:Nd6oXdnolbbVhpMpkYT5PJHOjQp4OBSnt github.com/filecoin-project/dagstore v0.5.2/go.mod h1:mdqKzYrRBHf1pRMthYfMv3n37oOw0Tkx7+TxPt240M0= github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= github.com/filecoin-project/go-address v0.0.5/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= -github.com/filecoin-project/go-address v0.0.6 h1:DWQtj38ax+ogHwyH3VULRIoT8E6loyXqsk/p81xoY7M= github.com/filecoin-project/go-address v0.0.6/go.mod h1:7B0/5DA13n6nHkB8bbGx1gWzG/dbTsZ0fgOJVGsM3TE= +github.com/filecoin-project/go-address v1.0.0 h1:IrexI0kpADLaPP+CdmU3CVAUqnW/FQC0KTmz4lVKiFU= +github.com/filecoin-project/go-address v1.0.0/go.mod h1:5t3z6qPmIADZBtuE9EIzi0EwzcRy2nVhpo0I/c1r0OA= github.com/filecoin-project/go-amt-ipld/v2 v2.1.0/go.mod h1:nfFPoGyX0CU9SkXX8EoCcSuHN1XcbN0c6KBh7yvP5fs= github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349 h1:pIuR0dnMD0i+as8wNnjjHyQrnhP5O5bmba/lmgQeRgU= github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349/go.mod h1:vgmwKBkx+ca5OIeEvstiQgzAZnb7R6QaqE1oEDSqa6g= @@ -346,8 +347,9 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8= -github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 h1:/eZXwVg2Z7qPwTBUAinA7m6w6rLYBeSvE61XW8MTV5M= github.com/filecoin-project/go-fil-markets v1.20.1-v16-1/go.mod h1:QHJZVEbQ7TydJ6hjK87q4MxOmRfDNbQkuSkdjxtqBWo= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-2 h1:uZHJav35gTGcm2CwY8B+V6fQO9aB1YeUYid2jkb6jXE= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-2/go.mod h1:JLP8bltMbPVhOULcHxE+QFg3b8/a9J8NbcA6Qf69W0k= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= @@ -372,9 +374,10 @@ github.com/filecoin-project/go-state-types v0.1.3/go.mod h1:ezYnPf0bNkTsDibL/psS github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4IrzznwS98X5XW/irUP3Lhxg= github.com/filecoin-project/go-state-types v0.1.5/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.1.7/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.1.8 h1:mrPnqeOHkBXOUkYZdIee7F1VcjKw7dtpVam8VrTvpuI= github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.9/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.10 h1:YrrJWWh2fU4VPhwHyPlDK5I4mB7bqgnRd3HCm9IOwIU= +github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc= @@ -385,8 +388,8 @@ github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lI github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8= github.com/filecoin-project/index-provider v0.5.0 h1:k2C1RFvOvxmA2i8bhmkb3b4qun7RDRDzzs/y25/TwQg= github.com/filecoin-project/index-provider v0.5.0/go.mod h1:KHVrP2vU3YuScb+fawObwTFoR882up9U07kk0ZrfP0c= -github.com/filecoin-project/lotus v1.16.0-pre-rc.0.20220611005856-f01bd41cc811 h1:Fhxkkyc5r/Bb7AWA2sF2wwxhqu/LLPKk7nzTbasLDUc= -github.com/filecoin-project/lotus v1.16.0-pre-rc.0.20220611005856-f01bd41cc811/go.mod h1:IOKKUPF3YXm9zpB10WxnfB8D26Vz9yEDdtw0/unFAsA= +github.com/filecoin-project/lotus v1.16.0-pre-rc.0.20220614091823-016749b60be5 h1:xPVYrCZNFLiEOfs8LRTCFxADLTzK3SOSb5QtO6vV3ok= +github.com/filecoin-project/lotus v1.16.0-pre-rc.0.20220614091823-016749b60be5/go.mod h1:YrPB+TedOacKPzMf2sxXGMpumGfswz0jXnXdiKdmTj8= github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg= github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= github.com/filecoin-project/specs-actors v0.9.15-0.20220514164640-94e0d5e123bd/go.mod h1:pjGEe3QlWtK20ju/aFRsiArbMX6Cn8rqEhhsiCM9xYE= @@ -412,8 +415,8 @@ github.com/filecoin-project/specs-actors/v6 v6.0.2/go.mod h1:wnfVvPnYmzPZilNvSqC github.com/filecoin-project/specs-actors/v7 v7.0.0/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= github.com/filecoin-project/specs-actors/v7 v7.0.1 h1:w72xCxijK7xs1qzmJiw+WYJaVt2EPHN8oiwpA1Ay3/4= github.com/filecoin-project/specs-actors/v7 v7.0.1/go.mod h1:tPLEYXoXhcpyLh69Ccq91SOuLXsPWjHiY27CzawjUEk= -github.com/filecoin-project/specs-actors/v8 v8.0.0 h1:c6NztoE4J5j7KvIfGmx9XW9o5aszPl6DU0M4xDqAJVU= -github.com/filecoin-project/specs-actors/v8 v8.0.0/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= +github.com/filecoin-project/specs-actors/v8 v8.0.1 h1:4u0tIRJeT5G7F05lwLRIsDnsrN+bJ5Ixj6h49Q7uE2Y= +github.com/filecoin-project/specs-actors/v8 v8.0.1/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= github.com/filecoin-project/specs-storage v0.4.1 h1:yvLEaLZj8f+uByhNC4mFOtCUyL2wQku+NGBp6hjTe9M= github.com/filecoin-project/specs-storage v0.4.1/go.mod h1:Z2eK6uMwAOSLjek6+sy0jNV2DSsMEENziMUz0GHRFBw= github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q= diff --git a/venus-shared/actors/builtin/system/actor.go b/venus-shared/actors/builtin/system/actor.go index 2f6651716b..f741a577cd 100644 --- a/venus-shared/actors/builtin/system/actor.go +++ b/venus-shared/actors/builtin/system/actor.go @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" types "github.com/filecoin-project/venus/venus-shared/internal" + "github.com/ipfs/go-cid" "fmt" @@ -72,7 +73,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, fmt.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State, error) { switch av { case actors.Version0: @@ -97,7 +98,7 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { return make7(store) case actors.Version8: - return make8(store) + return make8(store, builtinActors) } return nil, fmt.Errorf("unknown actor version %d", av) @@ -105,4 +106,5 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { type State interface { GetState() interface{} + GetBuiltinActors() cid.Cid } diff --git a/venus-shared/actors/builtin/system/actor.go.template b/venus-shared/actors/builtin/system/actor.go.template index f5c909d6b5..85a8b28632 100644 --- a/venus-shared/actors/builtin/system/actor.go.template +++ b/venus-shared/actors/builtin/system/actor.go.template @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors" types "github.com/filecoin-project/venus/venus-shared/internal" + "github.com/ipfs/go-cid" "fmt" @@ -50,11 +51,11 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, fmt.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State, error) { switch av { {{range .versions}} case actors.Version{{.}}: - return make{{.}}(store) + return make{{.}}(store{{if (ge . 8)}}, builtinActors{{end}}) {{end}} } return nil, fmt.Errorf("unknown actor version %d", av) @@ -62,4 +63,5 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { type State interface { GetState() interface{} + GetBuiltinActors() cid.Cid } diff --git a/venus-shared/actors/builtin/system/state.sep.go.template b/venus-shared/actors/builtin/system/state.sep.go.template index 71823b3a18..d8c00bcc97 100644 --- a/venus-shared/actors/builtin/system/state.sep.go.template +++ b/venus-shared/actors/builtin/system/state.sep.go.template @@ -25,9 +25,11 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make{{.v}}(store adt.Store) (State, error) { +func make{{.v}}(store adt.Store{{if (ge .v 8)}}, builtinActors cid.Cid{{end}}) (State, error) { out := state{{.v}}{store: store} - out.State = system{{.v}}.State{} + out.State = system{{.v}}.State{ + {{if (ge .v 8)}}BuiltinActors: builtinActors,{{end}} + } return &out, nil } @@ -39,3 +41,11 @@ type state{{.v}} struct { func (s *state{{.v}}) GetState() interface{} { return &s.State } + +func (s *state{{.v}}) GetBuiltinActors() cid.Cid { +{{if (le .v 7)}} + return cid.Undef +{{else}} + return s.State.BuiltinActors +{{end}} +} diff --git a/venus-shared/actors/builtin/system/state.v0.go b/venus-shared/actors/builtin/system/state.v0.go index 9204cd8382..4ed3ec11e3 100644 --- a/venus-shared/actors/builtin/system/state.v0.go +++ b/venus-shared/actors/builtin/system/state.v0.go @@ -35,3 +35,9 @@ type state0 struct { func (s *state0) GetState() interface{} { return &s.State } + +func (s *state0) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/venus-shared/actors/builtin/system/state.v2.go b/venus-shared/actors/builtin/system/state.v2.go index d0c35d89c9..fae8a959df 100644 --- a/venus-shared/actors/builtin/system/state.v2.go +++ b/venus-shared/actors/builtin/system/state.v2.go @@ -35,3 +35,9 @@ type state2 struct { func (s *state2) GetState() interface{} { return &s.State } + +func (s *state2) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/venus-shared/actors/builtin/system/state.v3.go b/venus-shared/actors/builtin/system/state.v3.go index c6382434c1..159f329d0d 100644 --- a/venus-shared/actors/builtin/system/state.v3.go +++ b/venus-shared/actors/builtin/system/state.v3.go @@ -35,3 +35,9 @@ type state3 struct { func (s *state3) GetState() interface{} { return &s.State } + +func (s *state3) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/venus-shared/actors/builtin/system/state.v4.go b/venus-shared/actors/builtin/system/state.v4.go index 63d360a24b..f4d97ce9d5 100644 --- a/venus-shared/actors/builtin/system/state.v4.go +++ b/venus-shared/actors/builtin/system/state.v4.go @@ -35,3 +35,9 @@ type state4 struct { func (s *state4) GetState() interface{} { return &s.State } + +func (s *state4) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/venus-shared/actors/builtin/system/state.v5.go b/venus-shared/actors/builtin/system/state.v5.go index 2ac0c71ae6..4045c1e67e 100644 --- a/venus-shared/actors/builtin/system/state.v5.go +++ b/venus-shared/actors/builtin/system/state.v5.go @@ -35,3 +35,9 @@ type state5 struct { func (s *state5) GetState() interface{} { return &s.State } + +func (s *state5) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/venus-shared/actors/builtin/system/state.v6.go b/venus-shared/actors/builtin/system/state.v6.go index 219dd9619a..21488b278e 100644 --- a/venus-shared/actors/builtin/system/state.v6.go +++ b/venus-shared/actors/builtin/system/state.v6.go @@ -35,3 +35,9 @@ type state6 struct { func (s *state6) GetState() interface{} { return &s.State } + +func (s *state6) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/venus-shared/actors/builtin/system/state.v7.go b/venus-shared/actors/builtin/system/state.v7.go index f4f68fcc78..84142089c9 100644 --- a/venus-shared/actors/builtin/system/state.v7.go +++ b/venus-shared/actors/builtin/system/state.v7.go @@ -35,3 +35,9 @@ type state7 struct { func (s *state7) GetState() interface{} { return &s.State } + +func (s *state7) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/venus-shared/actors/builtin/system/state.v8.go b/venus-shared/actors/builtin/system/state.v8.go index 9d68d0c1df..08f6abd6e9 100644 --- a/venus-shared/actors/builtin/system/state.v8.go +++ b/venus-shared/actors/builtin/system/state.v8.go @@ -21,9 +21,11 @@ func load8(store adt.Store, root cid.Cid) (State, error) { return &out, nil } -func make8(store adt.Store) (State, error) { +func make8(store adt.Store, builtinActors cid.Cid) (State, error) { out := state8{store: store} - out.State = system8.State{} + out.State = system8.State{ + BuiltinActors: builtinActors, + } return &out, nil } @@ -35,3 +37,9 @@ type state8 struct { func (s *state8) GetState() interface{} { return &s.State } + +func (s *state8) GetBuiltinActors() cid.Cid { + + return s.State.BuiltinActors + +} diff --git a/venus-shared/api/chain/v0/blockstore.go b/venus-shared/api/chain/v0/blockstore.go index f8d2768ebf..2590ba52ad 100644 --- a/venus-shared/api/chain/v0/blockstore.go +++ b/venus-shared/api/chain/v0/blockstore.go @@ -4,6 +4,7 @@ import ( "context" "github.com/filecoin-project/venus/venus-shared/types" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" ) @@ -12,4 +13,6 @@ type IBlockStore interface { ChainDeleteObj(ctx context.Context, obj cid.Cid) error //perm:admin ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error) //perm:read ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (types.ObjStat, error) //perm:read + // ChainPutObj puts a given object into the block store + ChainPutObj(context.Context, blocks.Block) error //perm:admin } diff --git a/venus-shared/api/chain/v0/method.md b/venus-shared/api/chain/v0/method.md index 4cda7060e7..db655f51e6 100644 --- a/venus-shared/api/chain/v0/method.md +++ b/venus-shared/api/chain/v0/method.md @@ -10,6 +10,7 @@ * [BlockStore](#BlockStore) * [ChainDeleteObj](#ChainDeleteObj) * [ChainHasObj](#ChainHasObj) + * [ChainPutObj](#ChainPutObj) * [ChainReadObj](#ChainReadObj) * [ChainStatObj](#ChainStatObj) * [ChainInfo](#ChainInfo) @@ -303,6 +304,21 @@ Inputs: Response: `true` +### ChainPutObj +ChainPutObj puts a given object into the block store + + +Perms: admin + +Inputs: +```json +[ + {} +] +``` + +Response: `{}` + ### ChainReadObj diff --git a/venus-shared/api/chain/v0/mock/mock_fullnode.go b/venus-shared/api/chain/v0/mock/mock_fullnode.go index 6e9d017095..274163feb9 100644 --- a/venus-shared/api/chain/v0/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v0/mock/mock_fullnode.go @@ -22,6 +22,7 @@ import ( internal "github.com/filecoin-project/venus/venus-shared/internal" types "github.com/filecoin-project/venus/venus-shared/types" gomock "github.com/golang/mock/gomock" + blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" metrics "github.com/libp2p/go-libp2p-core/metrics" peer "github.com/libp2p/go-libp2p-core/peer" @@ -349,6 +350,20 @@ func (mr *MockFullNodeMockRecorder) ChainNotify(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainNotify", reflect.TypeOf((*MockFullNode)(nil).ChainNotify), arg0) } +// ChainPutObj mocks base method. +func (m *MockFullNode) ChainPutObj(arg0 context.Context, arg1 blocks.Block) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ChainPutObj", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// ChainPutObj indicates an expected call of ChainPutObj. +func (mr *MockFullNodeMockRecorder) ChainPutObj(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutObj", reflect.TypeOf((*MockFullNode)(nil).ChainPutObj), arg0, arg1) +} + // ChainReadObj mocks base method. func (m *MockFullNode) ChainReadObj(arg0 context.Context, arg1 cid.Cid) ([]byte, error) { m.ctrl.T.Helper() diff --git a/venus-shared/api/chain/v0/proxy_gen.go b/venus-shared/api/chain/v0/proxy_gen.go index 4d0ada0ed7..70e1b01f09 100644 --- a/venus-shared/api/chain/v0/proxy_gen.go +++ b/venus-shared/api/chain/v0/proxy_gen.go @@ -13,6 +13,7 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" + blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/metrics" "github.com/libp2p/go-libp2p-core/peer" @@ -26,6 +27,7 @@ type IBlockStoreStruct struct { Internal struct { ChainDeleteObj func(ctx context.Context, obj cid.Cid) error `perm:"admin"` ChainHasObj func(ctx context.Context, obj cid.Cid) (bool, error) `perm:"read"` + ChainPutObj func(context.Context, blocks.Block) error `perm:"admin"` ChainReadObj func(ctx context.Context, cid cid.Cid) ([]byte, error) `perm:"read"` ChainStatObj func(ctx context.Context, obj cid.Cid, base cid.Cid) (types.ObjStat, error) `perm:"read"` } @@ -37,6 +39,9 @@ func (s *IBlockStoreStruct) ChainDeleteObj(p0 context.Context, p1 cid.Cid) error func (s *IBlockStoreStruct) ChainHasObj(p0 context.Context, p1 cid.Cid) (bool, error) { return s.Internal.ChainHasObj(p0, p1) } +func (s *IBlockStoreStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error { + return s.Internal.ChainPutObj(p0, p1) +} func (s *IBlockStoreStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) { return s.Internal.ChainReadObj(p0, p1) } diff --git a/venus-shared/api/chain/v1/blockstore.go b/venus-shared/api/chain/v1/blockstore.go index 3ffc5c88f4..ddb74b74e7 100644 --- a/venus-shared/api/chain/v1/blockstore.go +++ b/venus-shared/api/chain/v1/blockstore.go @@ -4,6 +4,7 @@ import ( "context" "github.com/filecoin-project/venus/venus-shared/types" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" ) @@ -12,4 +13,6 @@ type IBlockStore interface { ChainDeleteObj(ctx context.Context, obj cid.Cid) error //perm:admin ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error) //perm:read ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (types.ObjStat, error) //perm:read + // ChainPutObj puts a given object into the block store + ChainPutObj(context.Context, blocks.Block) error //perm:admin } diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index e1264868a2..199dd1fd7e 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -10,6 +10,7 @@ * [BlockStore](#BlockStore) * [ChainDeleteObj](#ChainDeleteObj) * [ChainHasObj](#ChainHasObj) + * [ChainPutObj](#ChainPutObj) * [ChainReadObj](#ChainReadObj) * [ChainStatObj](#ChainStatObj) * [ChainInfo](#ChainInfo) @@ -310,6 +311,21 @@ Inputs: Response: `true` +### ChainPutObj +ChainPutObj puts a given object into the block store + + +Perms: admin + +Inputs: +```json +[ + {} +] +``` + +Response: `{}` + ### ChainReadObj diff --git a/venus-shared/api/chain/v1/mock/mock_fullnode.go b/venus-shared/api/chain/v1/mock/mock_fullnode.go index 6b665a6dff..45c6d62fc8 100644 --- a/venus-shared/api/chain/v1/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v1/mock/mock_fullnode.go @@ -22,6 +22,7 @@ import ( internal "github.com/filecoin-project/venus/venus-shared/internal" types "github.com/filecoin-project/venus/venus-shared/types" gomock "github.com/golang/mock/gomock" + blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" metrics "github.com/libp2p/go-libp2p-core/metrics" peer "github.com/libp2p/go-libp2p-core/peer" @@ -364,6 +365,20 @@ func (mr *MockFullNodeMockRecorder) ChainNotify(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainNotify", reflect.TypeOf((*MockFullNode)(nil).ChainNotify), arg0) } +// ChainPutObj mocks base method. +func (m *MockFullNode) ChainPutObj(arg0 context.Context, arg1 blocks.Block) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ChainPutObj", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// ChainPutObj indicates an expected call of ChainPutObj. +func (mr *MockFullNodeMockRecorder) ChainPutObj(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutObj", reflect.TypeOf((*MockFullNode)(nil).ChainPutObj), arg0, arg1) +} + // ChainReadObj mocks base method. func (m *MockFullNode) ChainReadObj(arg0 context.Context, arg1 cid.Cid) ([]byte, error) { m.ctrl.T.Helper() diff --git a/venus-shared/api/chain/v1/proxy_gen.go b/venus-shared/api/chain/v1/proxy_gen.go index 92bb08c60c..5b356a9e12 100644 --- a/venus-shared/api/chain/v1/proxy_gen.go +++ b/venus-shared/api/chain/v1/proxy_gen.go @@ -13,6 +13,7 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" + blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/metrics" "github.com/libp2p/go-libp2p-core/peer" @@ -26,6 +27,7 @@ type IBlockStoreStruct struct { Internal struct { ChainDeleteObj func(ctx context.Context, obj cid.Cid) error `perm:"admin"` ChainHasObj func(ctx context.Context, obj cid.Cid) (bool, error) `perm:"read"` + ChainPutObj func(context.Context, blocks.Block) error `perm:"admin"` ChainReadObj func(ctx context.Context, cid cid.Cid) ([]byte, error) `perm:"read"` ChainStatObj func(ctx context.Context, obj cid.Cid, base cid.Cid) (types.ObjStat, error) `perm:"read"` } @@ -37,6 +39,9 @@ func (s *IBlockStoreStruct) ChainDeleteObj(p0 context.Context, p1 cid.Cid) error func (s *IBlockStoreStruct) ChainHasObj(p0 context.Context, p1 cid.Cid) (bool, error) { return s.Internal.ChainHasObj(p0, p1) } +func (s *IBlockStoreStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error { + return s.Internal.ChainPutObj(p0, p1) +} func (s *IBlockStoreStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) { return s.Internal.ChainReadObj(p0, p1) } diff --git a/venus-shared/builtin-actors/actors/README.md b/venus-shared/builtin-actors/actors/README.md index 097959f4fa..981ad726a1 100644 --- a/venus-shared/builtin-actors/actors/README.md +++ b/venus-shared/builtin-actors/actors/README.md @@ -16,3 +16,11 @@ This will: 1. Download the actors bundles and pack them into the appropriate tarfile (`$VERSION.tar.zst`). 2. Run `make bundle-gen` in the top-level directory to regenerate the bundle metadata file for _all_ network versions (all `*.tar.zst` files in this directory). + +## Overriding + +To build a bundle, but specify a different release/tag for a specific network, append `$network=$alternative_release` on the command line. For example: + +```bash +./pack.sh v8 dev/20220602 mainnet=v8.0.0 calibrationnet=v8.0.0-rc.1 +``` diff --git a/venus-shared/builtin-actors/actors/pack.sh b/venus-shared/builtin-actors/actors/pack.sh index 0d958a2d7c..8c6512c8b3 100755 --- a/venus-shared/builtin-actors/actors/pack.sh +++ b/venus-shared/builtin-actors/actors/pack.sh @@ -1,25 +1,43 @@ #!/bin/bash +NETWORKS=(devnet mainnet caterpillarnet butterflynet testing testing-fake-proofs calibrationnet) + set -e -if [[ $# -ne 2 ]]; then - echo "expected two arguments, an actors version (e.g., v8) and an actors release" +if [[ $# -lt 2 ]]; then + echo "Usage: $0 VERSION RELEASE [NETWORK=RELEASE_OVERRIDE]..." >&2 + echo "expected at least two arguments, an actors version (e.g., v8), an actors release, and any number of release overrides." >&2 exit 1 fi VERSION="$1" # actors version RELEASE="$2" # actors release name -NETWORKS=(devnet mainnet caterpillarnet butterflynet testing testing-fake-proofs calibrationnet) +RELEASE_OVERRIDES=("${@:3}") -echo "Downloading bundles for actors version ${VERSION}, release ${RELEASE}" +echo "Downloading bundles for actors version ${VERSION} release ${RELEASE}" +echo "With release overrides ${RELEASE_OVERRIDES[*]}" TARGET_FILE="$(pwd)/${VERSION}.tar.zst" WORKDIR=$(mktemp -d -t "actor-bundles-${VERSION}.XXXXXXXXXX") trap 'rm -rf -- "$WORKDIR"' EXIT +encode_release() { + jq -rn --arg release "$1" '$release | @uri' +} + pushd "${WORKDIR}" encoded_release="$(jq -rn --arg release "$RELEASE" '$release | @uri')" for network in "${NETWORKS[@]}"; do + release="$RELEASE" + # Ideally, we'd use an associative array (map). But that's not supported on macos. + for override in "${RELEASE_OVERRIDES[@]}"; do + if [[ "${network}" = "${override%%=*}" ]]; then + release="${override#*=}" + break + fi + done + encoded_release="$(encode_release "$release")" + echo "Downloading $release for network $network." wget "https://github.com/filecoin-project/builtin-actors/releases/download/${encoded_release}/builtin-actors-${network}"{.car,.sha256} done diff --git a/venus-shared/builtin-actors/actors/v8.tar.zst b/venus-shared/builtin-actors/actors/v8.tar.zst index 9d6c9f7435..c4eb857b9f 100644 Binary files a/venus-shared/builtin-actors/actors/v8.tar.zst and b/venus-shared/builtin-actors/actors/v8.tar.zst differ diff --git a/venus-shared/builtin-actors/builtin_actors_gen.go b/venus-shared/builtin-actors/builtin_actors_gen.go index d689dc8759..ce46905b7d 100644 --- a/venus-shared/builtin-actors/builtin_actors_gen.go +++ b/venus-shared/builtin-actors/builtin_actors_gen.go @@ -9,19 +9,19 @@ import ( var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMetadata{{ Network: "butterflynet", Version: 8, - ManifestCid: types.MustParseCid("bafy2bzaced6uuyvoidi5gmqk6wsx7hlchpjfvzrkqlbnto2p5tvzcnaf6gmey"), + ManifestCid: types.MustParseCid("bafy2bzacedvaarfyh6q3bk4dyzux46ednlace2ckxp5nbyn6mb3da2apqn6sk"), Actors: map[string]cid.Cid{ - "account": types.MustParseCid("bafk2bzaceckohebftaeh3umtazldwcm2yjfsv74tf7qbxledmhm5uiqoslhgy"), - "cron": types.MustParseCid("bafk2bzacebjgaky46lkkwh7dk6vxxcoktem3wvd64pamjlmjiuw4dpw6ip4gs"), - "init": types.MustParseCid("bafk2bzacebjzrzjtrq7fops45chsb5xwr2ljmsbpn6rdhaeofhgazqfnnnvia"), - "multisig": types.MustParseCid("bafk2bzacecumdo2d2vpmkd66vqdkj32zu6m54ddpaqiqcchybq7fljygips6e"), - "paymentchannel": types.MustParseCid("bafk2bzacecmsfeq364zbysebk4xkpmtcxe4bv4lrlfdzidqoudnsdihph4d6u"), - "reward": types.MustParseCid("bafk2bzacecegz7l24oflfaljv2leyt5hm43xtnpiud6onb5cj7rxii64skro4"), - "storagemarket": types.MustParseCid("bafk2bzacedhbgxtzn7njswwj6nddtwvikiawg6v6nfd5j2m4kzwpmzx3hs6za"), - "storageminer": types.MustParseCid("bafk2bzacedesl6liweoc2tbd2tu7srt4gl47s4mkpxuutyhsp5xdgfon7dhde"), - "storagepower": types.MustParseCid("bafk2bzaceaanma6h3fgx6i7z44rq43ztpgsm5p5kv7o67tgx37w2deg22747u"), - "system": types.MustParseCid("bafk2bzaceb7hdtxcgmjyad73fmwqsitaj45tdnf33w4ppr6yviwrng42vrfqk"), - "verifiedregistry": types.MustParseCid("bafk2bzacebevs25cjj2swznkyyauodmwpvcwkgqldbw2x5sd7dwjg7vvntnzu"), + "account": types.MustParseCid("bafk2bzaceavzeu4gqte7o33vr4htiaapiwpfq6p26tgdkqla2baqhmiqswfso"), + "cron": types.MustParseCid("bafk2bzacech35onpqxep4yox36k7sr4mj4bch54s3i4b3yyaustrbo5xwfbfs"), + "init": types.MustParseCid("bafk2bzaceahxin3sf5f6ude5j6we4yeqlg66s5qe4tu7lwp26jcg7yp2ns6hi"), + "multisig": types.MustParseCid("bafk2bzacectfmzjtniypgl4whm42sws5aupihqgfikwsr7p5yoq3bmqaogldi"), + "paymentchannel": types.MustParseCid("bafk2bzacecbwu54ce5mjgp2pqxyj6kpn2vlgiu5wv2lj2byjiegxnn3infd5i"), + "reward": types.MustParseCid("bafk2bzacecskkbhe6c4ud5jt62wg4w7j7shj6xdwoyic74s5y6pgywxxvnw72"), + "storagemarket": types.MustParseCid("bafk2bzacebycxcwwm7hwhuhpasaskil2kxaqb7tins7azdvvm72rorlciuysi"), + "storageminer": types.MustParseCid("bafk2bzacecgx3etor5m6lahpmjdwqnryutqe6naiurfhgsju72rd4nqssutbg"), + "storagepower": types.MustParseCid("bafk2bzaceayvy6xyp5cwtngm457c5hssvihidppgq3o7gy3dlmhgor3yzujoc"), + "system": types.MustParseCid("bafk2bzacec6xctjxybp7r3kkhase56o6jsaiua7ure5ttu2xfuojt4jhlsoa6"), + "verifiedregistry": types.MustParseCid("bafk2bzacec2hcqlqcfacylfcrhhliwkisvh4y3adwt47xkf2gdvodwu6ccepc"), }, }, { Network: "calibrationnet", @@ -43,86 +43,86 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet }, { Network: "caterpillarnet", Version: 8, - ManifestCid: types.MustParseCid("bafy2bzacebitcr6geekzzkiggl35gi7f32zph46ufgz5lxkd7pqccqgzvpqyc"), + ManifestCid: types.MustParseCid("bafy2bzacecsmunz6fzhg53276cixadn6ybhcnzkgbw3la5hf342tfxsdoet26"), Actors: map[string]cid.Cid{ - "account": types.MustParseCid("bafk2bzaceaqeughlonz5okhkep3busavpt6qlaxy3x4lx2go3wsf4oval42go"), - "cron": types.MustParseCid("bafk2bzacedixwc4mo3k2akjstogi3hsu6yzibe6uzs3hke2m74j7umpe7ydwk"), - "init": types.MustParseCid("bafk2bzacedrygc7pawj6rgfy5uawgfkykias2phw7lgjfj7yyxtfpk3wsyj7c"), - "multisig": types.MustParseCid("bafk2bzacececbmijm2t4uemwgrspnnslpgnksozvshrwgf3ozh6zncz7aqr4c"), - "paymentchannel": types.MustParseCid("bafk2bzacedv3lmu3ut7nrl5zpxl22je2qiognakt3m4eibux4x74nwibdegeu"), - "reward": types.MustParseCid("bafk2bzacebaxil4vhggtxaz57s4rdxsmjgiegexoyyol77gdtkaxmzuuk2fts"), - "storagemarket": types.MustParseCid("bafk2bzacecsr53mwcmsdqvg6o45j6skvs56rszpk6qitgctebqmjhntatkhie"), - "storageminer": types.MustParseCid("bafk2bzacecamuvyexrh27koduxutjtmiats7knwgduujhpx2ppbcidnyrsj22"), - "storagepower": types.MustParseCid("bafk2bzaceadhmwub5wksxgcakprhahrnm6rhmcle2unlc5lqcnnkplxcy3tby"), - "system": types.MustParseCid("bafk2bzacebnierpf3g52brlzcs3of4stltmrfw3nhgy3y67e2lndohpuckv72"), - "verifiedregistry": types.MustParseCid("bafk2bzaceckqvl6647so55jgmnoa7jchs3ifbgncdb3qx6e33l2smcnthrkgi"), + "account": types.MustParseCid("bafk2bzaced6yatl4y2nmqmx2h3btk3np6oelyw2yt57elsb2nfmm33fadzt2g"), + "cron": types.MustParseCid("bafk2bzacebrujytq4u7g62jbz52gio5k2s6rhruty7nt4eqq7ygitzxuee5zi"), + "init": types.MustParseCid("bafk2bzacedajw5ptnwfdidv6m4rvd4c2m7dve4lhfbawygl5idkalcxbiiudu"), + "multisig": types.MustParseCid("bafk2bzaceb3kh5hjh6eebb5236xp7crn2owyyo7irap6sy4ns76uc7om6pxuy"), + "paymentchannel": types.MustParseCid("bafk2bzacedl5am53e4mtxpzligcycxvmkolfkhfiuavww2dq3ukgaqwowj7vw"), + "reward": types.MustParseCid("bafk2bzacecbswf242j43cymj3wh7nszawwlofv6z6z4qipb5d32hpxdhxywng"), + "storagemarket": types.MustParseCid("bafk2bzaceca5ersmg3zxf2cztgktq33bmfjuiqjcjlktwj52xyrpujbdsqvek"), + "storageminer": types.MustParseCid("bafk2bzacedg2fqaq5udfp3h6cxhywm27dgagxtselfgkyyyunqq362eaxpdm4"), + "storagepower": types.MustParseCid("bafk2bzaceb3dm2i2q323e6iozo3r6pyded645vvlpf537kga2a3hu5x7abgl4"), + "system": types.MustParseCid("bafk2bzacebu47th3xerlngqavlipb6cfu2utljkxxzgadc3totogto2tmx2jc"), + "verifiedregistry": types.MustParseCid("bafk2bzaceci3niq3rmbcmepgn27zvlgci6d5t4dvthx3pbmmx3wcu5elova6i"), }, }, { Network: "devnet", Version: 8, - ManifestCid: types.MustParseCid("bafy2bzaceajvuce5g5f3lxosfupsizwtlppix6xcwrjphv5rto3rf63j5cdfy"), + ManifestCid: types.MustParseCid("bafy2bzacedq7tuibavyqxzkq4uybjj7ly22eu42mjkoehwn5d47xfunmtjm4k"), Actors: map[string]cid.Cid{ - "account": types.MustParseCid("bafk2bzacedt3rrna27knzqv45rntnzblcpbdyb7abwprqqc3m3sclhhs5rcbm"), - "cron": types.MustParseCid("bafk2bzaceacwupgz6ywehqvepuyo5zmmk5zckeep2unnrh2v4m55zzfmuybnm"), - "init": types.MustParseCid("bafk2bzacedetk52vj6vfpqw3wfd5shnkfigokmyhrfojhtvz43336m43thham"), - "multisig": types.MustParseCid("bafk2bzacebtypmb6dqnhowzttf643kbgtdhf6iclasc4ffxkkq5atriqc42g6"), - "paymentchannel": types.MustParseCid("bafk2bzacedvd4cfhfz7duxkudnu2cxbqkmanodgvpf623jmtz75njif5d5d3a"), - "reward": types.MustParseCid("bafk2bzaceaegqj6sg3dkfb6pcduktclnaqg7lwxfvbmnb75dbwdft7p7ovwh4"), - "storagemarket": types.MustParseCid("bafk2bzacecfzobcdmc3hxivo7e4w66xlvz2ekbx2g24yzom5b2wxfmt775nus"), - "storageminer": types.MustParseCid("bafk2bzacebjmefvh4a3qee4e5pnjdhtpwz3hcvysofuclfxl4v7r3wmjggoja"), - "storagepower": types.MustParseCid("bafk2bzacebxp6iwxv4ofpij2yf4etg42w6spbwt44f7cioyvo6u6rt76mkrvi"), - "system": types.MustParseCid("bafk2bzacec3t66vrvb6ltgjvtga7xmtvy4x2xvfgq262v44gs7nsalbklamzc"), - "verifiedregistry": types.MustParseCid("bafk2bzaceantjiul66lkpcq6jpujmo3gy2nft44w2tud44wzznrodqm5imegk"), + "account": types.MustParseCid("bafk2bzacea4tlgnp7m6tlldpz3termlwxlnyq24nwd4zdzv4r6nsjuaktuuzc"), + "cron": types.MustParseCid("bafk2bzacecgrlf3vg3mufwovddlbgclhpnpp3jftr46stssh3crd3pyljc37w"), + "init": types.MustParseCid("bafk2bzacedarbnovmucppbjkcwsxopludrj5ttmtm7mzfqsugmxdnqevqso7o"), + "multisig": types.MustParseCid("bafk2bzaced4gcxjwy6garxwfw6y5a2k4jewj4t5nzopjy4qwnimhjtnsgo3ss"), + "paymentchannel": types.MustParseCid("bafk2bzaceb3isfguytt6cs4xecyoonbhhekmngfbap2msggbwyde7zch3a6w4"), + "reward": types.MustParseCid("bafk2bzacedn3fkp27ys5dxn4pwqdq2atj2x6cyezxuekdorvjwi7zazirgvgy"), + "storagemarket": types.MustParseCid("bafk2bzacecw57fpkqesfhi5g3nr4csy4oy7oc42wmwjuis6l7ijniolo4rt2k"), + "storageminer": types.MustParseCid("bafk2bzacebze3elvppssc6v5457ukszzy6ndrg6xgaojfsqfbbtg3xfwo4rbs"), + "storagepower": types.MustParseCid("bafk2bzaceb45l6zhgc34n6clz7xnvd7ek55bhw46q25umuje34t6kroix6hh6"), + "system": types.MustParseCid("bafk2bzacecf7eta2stfd3cnuxzervd33imbvlaqq6b5tsho7pxmhifrybreru"), + "verifiedregistry": types.MustParseCid("bafk2bzaceaajgtglewgitshgdi2nzrvq7eihjtyqj5yiamesqun2hujl3xev2"), }, }, { Network: "mainnet", Version: 8, - ManifestCid: types.MustParseCid("bafy2bzaceclwsaafb4h7nofp64v7ctxq5cs75545mylvw3hwaxdign6xk5kka"), + ManifestCid: types.MustParseCid("bafy2bzacebogjbpiemi7npzxchgcjjki3tfxon4ims55obfyfleqntteljsea"), Actors: map[string]cid.Cid{ - "account": types.MustParseCid("bafk2bzaceb2bkfdnv2ohescckcywwtrmhtbn53aenbo2x5ybrvtnjfspkud4g"), - "cron": types.MustParseCid("bafk2bzaceaxoogtk2e4onrx32eykhqy43l3hzcrkz6okhdujjohrfuy6z4ygk"), - "init": types.MustParseCid("bafk2bzacecxkeddlvo5azclqbasrlymu3a2k3y6jsbaeov4lix5pwzdra5bek"), - "multisig": types.MustParseCid("bafk2bzacebqhfu4doyffwknjsw7vjldpkccf253i6sncx6ty7ofm2q3d2ttys"), - "paymentchannel": types.MustParseCid("bafk2bzacebk5kb6ofhksspgv3wp6uwbcrn7x37ego54bgakywseg7bgw4ffdq"), - "reward": types.MustParseCid("bafk2bzaced2lusdnjdfn7o6fb5cqzdccllqgb5i6ofqlfdknvpuaz7wkkq324"), - "storagemarket": types.MustParseCid("bafk2bzacedcpb2vsb6xzz32jzgxc5hh4bmhjggjjitizusr5eucfrziizt7tk"), - "storageminer": types.MustParseCid("bafk2bzacecbnz4cxd3j46taxsfzq3jkzai5sef3zwnxzft77unterfkcukk6w"), - "storagepower": types.MustParseCid("bafk2bzaceaz7dharmmwjghgobsnefiyciz6ogj6uzdoomlyid6h3ye4nzpurs"), - "system": types.MustParseCid("bafk2bzaceckspyzcsqyrigwziyubzj7nv3bfiu2p7mwfltyhmzxg34lwj4dfm"), - "verifiedregistry": types.MustParseCid("bafk2bzacecztqq7o5po5hbbtgi3uc7znxkmjl4qqeyhuy42svo3p3zc6cev2c"), + "account": types.MustParseCid("bafk2bzacedudbf7fc5va57t3tmo63snmt3en4iaidv4vo3qlyacbxaa6hlx6y"), + "cron": types.MustParseCid("bafk2bzacecqb3eolfurehny6yp7tgmapib4ocazo5ilkopjce2c7wc2bcec62"), + "init": types.MustParseCid("bafk2bzaceaipvjhoxmtofsnv3aj6gj5ida4afdrxa4ewku2hfipdlxpaektlw"), + "multisig": types.MustParseCid("bafk2bzacebhldfjuy4o5v7amrhp5p2gzv2qo5275jut4adnbyp56fxkwy5fag"), + "paymentchannel": types.MustParseCid("bafk2bzacebalad3f72wyk7qyilvfjijcwubdspytnyzlrhvn73254gqis44rq"), + "reward": types.MustParseCid("bafk2bzacecwzzxlgjiavnc3545cqqil3cmq4hgpvfp2crguxy2pl5ybusfsbe"), + "storagemarket": types.MustParseCid("bafk2bzacediohrxkp2fbsl4yj4jlupjdkgsiwqb4zuezvinhdo2j5hrxco62q"), + "storageminer": types.MustParseCid("bafk2bzacecgnynvd3tene3bvqoknuspit56canij5bpra6wl4mrq2mxxwriyu"), + "storagepower": types.MustParseCid("bafk2bzacebjvqva6ppvysn5xpmiqcdfelwbbcxmghx5ww6hr37cgred6dyrpm"), + "system": types.MustParseCid("bafk2bzacedwq5uppsw7vp55zpj7jdieizirmldceehu6wvombw3ixq2tcq57w"), + "verifiedregistry": types.MustParseCid("bafk2bzaceb3zbkjz3auizmoln2unmxep7dyfcmsre64vnqfhdyh7rkqfoxlw4"), }, }, { Network: "testing", Version: 8, - ManifestCid: types.MustParseCid("bafy2bzacea33t2faxpcqd47layvl7j6e2rzctc4of4m7nwx5wjagvulwasjzs"), + ManifestCid: types.MustParseCid("bafy2bzacedkjpqx27wgsvfxzuxfvixuxtbpt2y6yo6igcasez6gqiowron776"), Actors: map[string]cid.Cid{ - "account": types.MustParseCid("bafk2bzacearozlorchwfq4gkgkdtmvd43lcjblnge6j3putfetavneycdum4i"), - "cron": types.MustParseCid("bafk2bzacean2fewjae57hwyomnf7ktyiahuenyxhzrpkhsrlwsecyv2lk2hto"), - "init": types.MustParseCid("bafk2bzacecioxkb2gqaze7lnaq7xj2aibiqgapl4jq2qyccjbvuzanzzkwqnc"), - "multisig": types.MustParseCid("bafk2bzacecyeqb2ilsuoxfphqpfxrtwaz7vfbrq3kq67j5uof6sbrw675zbry"), - "paymentchannel": types.MustParseCid("bafk2bzacedsi4nwln57uqf2vhjma3qfsmavjhyjwk6bch2nl3zbwmwln3cgk6"), - "reward": types.MustParseCid("bafk2bzacec3no7avpydxxkqzc7druqiljmfs6antcmdbhjtyytlzfrj3nemlm"), - "storagemarket": types.MustParseCid("bafk2bzacedqlm6c4yhtcw3f3fkhx4bc3cfckyvkk6tfsdnzita47poq4jfv5i"), - "storageminer": types.MustParseCid("bafk2bzacedcxbj6ntcnmupkmxwr42pvfrurqjykbs4mzndmvjgjg63ka2wupo"), - "storagepower": types.MustParseCid("bafk2bzacebg663joio3mq5utzm2k3je6piwmqlyindcklbhnsukku6u26mrus"), - "system": types.MustParseCid("bafk2bzaceaxy3h63qnazdiny57sh2yaq3c3azyt6zgpefpom3hs2lyfsmw3ui"), - "verifiedregistry": types.MustParseCid("bafk2bzacebeauqrzfv4cr644udm2fnltuz6cddoyzo2n7cvpa6l3ktnofu7w2"), + "account": types.MustParseCid("bafk2bzacebmfbtdj5vruje5auacrhhprcjdd6uclhukb7je7t2f6ozfcgqlu2"), + "cron": types.MustParseCid("bafk2bzacea4gwsbeux7z4yxvpkxpco77iyxijoyqaoikofrxdewunwh3unjem"), + "init": types.MustParseCid("bafk2bzacecqk6zlwein7tzy7yrrhtj4pzavrkofgpyxvvw5ktr3w4x4ml4lis"), + "multisig": types.MustParseCid("bafk2bzacea5zp2g6ag5qfuro7zw6kyku2swxs57wjxncaaxbih5iqflqy4ghm"), + "paymentchannel": types.MustParseCid("bafk2bzaced47dbtbygmfwnyfsp5iihzhhdmnkpuyc5nlnfgc4mkkvlsgvj2do"), + "reward": types.MustParseCid("bafk2bzacecmcagk32pzdzfg7piobzqhlgla37x3g7jjzyndlz7mqdno2zulfi"), + "storagemarket": types.MustParseCid("bafk2bzaceballmgd7puoixfwm65f5shi3kzreqdisowtsoufbvduwytydqotw"), + "storageminer": types.MustParseCid("bafk2bzacebucngwdhxtod2gvv52adtdssafyg43znsoy4omtfkkqe2hbhvxeu"), + "storagepower": types.MustParseCid("bafk2bzaceakxw5wx3rtqoarrdbzhmxkufg2kx7n34xotzxzacvvbe5iqggmsa"), + "system": types.MustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"), + "verifiedregistry": types.MustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"), }, }, { Network: "testing-fake-proofs", Version: 8, - ManifestCid: types.MustParseCid("bafy2bzacedsjtsrqey2n54hm7eblf25ygmvv6e73uvqsdiklavtmqmxilcdjc"), + ManifestCid: types.MustParseCid("bafy2bzacecd3lb5v6tzjylnhnrhexslssyaozy6hogzgpkhztoe76exbrgrug"), Actors: map[string]cid.Cid{ - "account": types.MustParseCid("bafk2bzacearozlorchwfq4gkgkdtmvd43lcjblnge6j3putfetavneycdum4i"), - "cron": types.MustParseCid("bafk2bzacean2fewjae57hwyomnf7ktyiahuenyxhzrpkhsrlwsecyv2lk2hto"), - "init": types.MustParseCid("bafk2bzacebwfsgvfuuogwodiq53m23ggae5saavabeqouttmo6s52pdmzmg36"), - "multisig": types.MustParseCid("bafk2bzacecyeqb2ilsuoxfphqpfxrtwaz7vfbrq3kq67j5uof6sbrw675zbry"), - "paymentchannel": types.MustParseCid("bafk2bzacedsi4nwln57uqf2vhjma3qfsmavjhyjwk6bch2nl3zbwmwln3cgk6"), - "reward": types.MustParseCid("bafk2bzacec3no7avpydxxkqzc7druqiljmfs6antcmdbhjtyytlzfrj3nemlm"), - "storagemarket": types.MustParseCid("bafk2bzaceckvmh2knnsuzx2jqcmjnmckccoffznr3uah25p7ndphva6qwhfuc"), - "storageminer": types.MustParseCid("bafk2bzacedngg6mggpxoeyineuiwp26doj7h46yxp6fk6rftfo6suwsd23fku"), - "storagepower": types.MustParseCid("bafk2bzacectbtyzafwpjtsfbsi75wky6i6ufoggrch6nc66bxcskmxie4ho34"), - "system": types.MustParseCid("bafk2bzaceaxy3h63qnazdiny57sh2yaq3c3azyt6zgpefpom3hs2lyfsmw3ui"), - "verifiedregistry": types.MustParseCid("bafk2bzacebeauqrzfv4cr644udm2fnltuz6cddoyzo2n7cvpa6l3ktnofu7w2"), + "account": types.MustParseCid("bafk2bzacebmfbtdj5vruje5auacrhhprcjdd6uclhukb7je7t2f6ozfcgqlu2"), + "cron": types.MustParseCid("bafk2bzacea4gwsbeux7z4yxvpkxpco77iyxijoyqaoikofrxdewunwh3unjem"), + "init": types.MustParseCid("bafk2bzacebwkqd6e7gdphfzw2kdmbokdh2bly6fvzgfopxzy7quq4l67gmkks"), + "multisig": types.MustParseCid("bafk2bzacea5zp2g6ag5qfuro7zw6kyku2swxs57wjxncaaxbih5iqflqy4ghm"), + "paymentchannel": types.MustParseCid("bafk2bzaced47dbtbygmfwnyfsp5iihzhhdmnkpuyc5nlnfgc4mkkvlsgvj2do"), + "reward": types.MustParseCid("bafk2bzacecmcagk32pzdzfg7piobzqhlgla37x3g7jjzyndlz7mqdno2zulfi"), + "storagemarket": types.MustParseCid("bafk2bzacecxqgajcaednamgolc6wc3lzbjc6tz5alfrbwqez2y3c372vts6dg"), + "storageminer": types.MustParseCid("bafk2bzaceaqwxllfycpq6decpsnkqjdeycpysh5acubonjae7u3wciydlkvki"), + "storagepower": types.MustParseCid("bafk2bzaceddmeolsokbxgcr25cuf2skrobtmmoof3dmqfpcfp33lmw63oikvm"), + "system": types.MustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"), + "verifiedregistry": types.MustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"), }, }} diff --git a/venus-shared/compatible-checks/api-checksum.txt b/venus-shared/compatible-checks/api-checksum.txt index 7c1a6958fd..a15dcec6ef 100644 --- a/venus-shared/compatible-checks/api-checksum.txt +++ b/venus-shared/compatible-checks/api-checksum.txt @@ -20,6 +20,7 @@ v0api.FullNode: ChainHasObj: In=2, Out=2, CheckSum=7fe71bcffa1b110db106e0104e98a32f ChainHead: In=1, Out=2, CheckSum=6d1e4c4d8184dc8d645a56278f14cfad ChainNotify: In=1, Out=2, CheckSum=9525148e93a5b83600ebfbde4d24f3e9 + ChainPutObj: In=2, Out=1, CheckSum=8f14a26d66dd2a48d50d58af2ff7d722 ChainReadObj: In=2, Out=2, CheckSum=6fd9244d87bf5d14fb5e79b0dbc0940d ChainSetHead: In=2, Out=1, CheckSum=cdfe593ac791e823186abb77bfad49a0 ChainStatObj: In=3, Out=2, CheckSum=9db2a0d97998daaf9c15e7c3d6ffe82d @@ -236,6 +237,7 @@ api.FullNode: ChainHasObj: In=2, Out=2, CheckSum=7fe71bcffa1b110db106e0104e98a32f ChainHead: In=1, Out=2, CheckSum=6d1e4c4d8184dc8d645a56278f14cfad ChainNotify: In=1, Out=2, CheckSum=9525148e93a5b83600ebfbde4d24f3e9 + ChainPutObj: In=2, Out=1, CheckSum=8f14a26d66dd2a48d50d58af2ff7d722 ChainReadObj: In=2, Out=2, CheckSum=6fd9244d87bf5d14fb5e79b0dbc0940d ChainSetHead: In=2, Out=1, CheckSum=cdfe593ac791e823186abb77bfad49a0 ChainStatObj: In=3, Out=2, CheckSum=9db2a0d97998daaf9c15e7c3d6ffe82d diff --git a/venus-shared/compatible-checks/api-perm.txt b/venus-shared/compatible-checks/api-perm.txt index 05209f02df..af7a5e87f5 100644 --- a/venus-shared/compatible-checks/api-perm.txt +++ b/venus-shared/compatible-checks/api-perm.txt @@ -1,4 +1,5 @@ v0: github.com/filecoin-project/venus/venus-shared/api/chain/v0 <> github.com/filecoin-project/lotus/api/v0api + - IBlockStore.ChainPutObj - IActor.ListActor - IChainInfo.BlockTime - IChainInfo.ChainGetReceipts diff --git a/venus-shared/types/api_types.go b/venus-shared/types/api_types.go index 063996b4dd..37020acc69 100644 --- a/venus-shared/types/api_types.go +++ b/venus-shared/types/api_types.go @@ -60,6 +60,14 @@ type MessageCID struct { type NetworkName string +const ( + NetworkNameMain NetworkName = "mainnet" + NetworkNameCalibration NetworkName = "calibrationnet" + NetworkNameButterfly NetworkName = "butterflynet" + NetworkNameInterop NetworkName = "interopnet" + NetworkNameIntegration NetworkName = "integrationnet" +) + type NetworkType int const ( diff --git a/venus-shared/utils/method_map.go b/venus-shared/utils/method_map.go new file mode 100644 index 0000000000..37a8732648 --- /dev/null +++ b/venus-shared/utils/method_map.go @@ -0,0 +1,139 @@ +package utils + +import ( + "reflect" + "runtime" + "strings" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/rt" + "github.com/ipfs/go-cid" + + /* inline-gen template + {{range .actorVersions}} + exported{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/exported"{{end}} + + /* inline-gen start */ + + exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported" + exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported" + exported3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/exported" + exported4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/exported" + exported5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/exported" + exported6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/exported" + exported7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported" + exported8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/exported" + + /* inline-gen end */ + + _actors "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/builtin" +) + +type MethodMeta struct { + Name string + + Params reflect.Type + Ret reflect.Type +} + +// In the v8 version, different networks will have different actors(venus-shared/builtin-actors/builtin_actors_gen.go). +// Pay attention to the network type when using. +// By default, the actors of the mainnet are loaded. +var MethodsMap = map[cid.Cid]map[abi.MethodNum]MethodMeta{} + +type actorsWithVersion struct { + av _actors.Version + actors []rt.VMActor +} + +func init() { + loadMethodsMap() +} + +func ReloadMethodsMap() { + MethodsMap = make(map[cid.Cid]map[abi.MethodNum]MethodMeta) + loadMethodsMap() +} + +func loadMethodsMap() { + // TODO: combine with the runtime actor registry. + var actors []actorsWithVersion + + /* inline-gen template + {{range .actorVersions}} + actors = append(actors, actorsWithVersion{av: _actors.Version{{.}}, actors: exported{{.}}.BuiltinActors()}){{end}} + /* inline-gen start */ + + actors = append(actors, actorsWithVersion{av: _actors.Version0, actors: exported0.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: _actors.Version2, actors: exported2.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: _actors.Version3, actors: exported3.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: _actors.Version4, actors: exported4.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: _actors.Version5, actors: exported5.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: _actors.Version6, actors: exported6.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: _actors.Version7, actors: exported7.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: _actors.Version8, actors: exported8.BuiltinActors()}) + /* inline-gen end */ + + for _, awv := range actors { + for _, actor := range awv.actors { + // necessary to make stuff work + ac := actor.Code() + var realCode cid.Cid + if awv.av >= _actors.Version8 { + name := _actors.CanonicalName(builtin.ActorNameByCode(ac)) + + realCode, _ = _actors.GetActorCodeID(awv.av, name) + } + + exports := actor.Exports() + methods := make(map[abi.MethodNum]MethodMeta, len(exports)) + + // Explicitly add send, it's special. + methods[builtin.MethodSend] = MethodMeta{ + Name: "Send", + Params: reflect.TypeOf(new(abi.EmptyValue)), + Ret: reflect.TypeOf(new(abi.EmptyValue)), + } + + // Iterate over exported methods. Some of these _may_ be nil and + // must be skipped. + for number, export := range exports { + if export == nil { + continue + } + + ev := reflect.ValueOf(export) + et := ev.Type() + + // Extract the method names using reflection. These + // method names always match the field names in the + // `builtin.Method*` structs (tested in the specs-actors + // tests). + fnName := runtime.FuncForPC(ev.Pointer()).Name() + fnName = strings.TrimSuffix(fnName[strings.LastIndexByte(fnName, '.')+1:], "-fm") + + switch abi.MethodNum(number) { + case builtin.MethodSend: + panic("method 0 is reserved for Send") + case builtin.MethodConstructor: + if fnName != "Constructor" { + panic("method 1 is reserved for Constructor") + } + } + + methods[abi.MethodNum(number)] = MethodMeta{ + Name: fnName, + Params: et.In(1), + Ret: et.Out(0), + } + } + + if realCode.Defined() { + MethodsMap[realCode] = methods + } else { + MethodsMap[actor.Code()] = methods + } + } + } +} diff --git a/venus-shared/utils/method_map_test.go b/venus-shared/utils/method_map_test.go new file mode 100644 index 0000000000..1c98a18171 --- /dev/null +++ b/venus-shared/utils/method_map_test.go @@ -0,0 +1,47 @@ +package utils + +import ( + "testing" + + tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags" + builtinactors "github.com/filecoin-project/venus/venus-shared/builtin-actors" + "github.com/filecoin-project/venus/venus-shared/types" + "github.com/stretchr/testify/assert" +) + +func TestMethodMap(t *testing.T) { + tf.UnitTest(t) + + t.Run("Default to load mainnet v8 actors", func(t *testing.T) { + for _, actorsMetadata := range builtinactors.EmbeddedBuiltinActorsMetadata { + if actorsMetadata.Network == string(types.NetworkNameMain) { + for _, actor := range actorsMetadata.Actors { + _, ok := MethodsMap[actor] + assert.True(t, ok) + } + } + } + }) + + t.Run("ReLoad butterflynet v8 actors", func(t *testing.T) { + for _, actorsMetadata := range builtinactors.EmbeddedBuiltinActorsMetadata { + if actorsMetadata.Network == string(types.NetworkNameButterfly) { + for _, actor := range actorsMetadata.Actors { + _, ok := MethodsMap[actor] + assert.False(t, ok) + } + } + } + + assert.Nil(t, builtinactors.SetNetworkBundle(types.NetworkButterfly)) + ReloadMethodsMap() + for _, actorsMetadata := range builtinactors.EmbeddedBuiltinActorsMetadata { + if actorsMetadata.Network == string(types.NetworkNameButterfly) { + for _, actor := range actorsMetadata.Actors { + _, ok := MethodsMap[actor] + assert.True(t, ok) + } + } + } + }) +} diff --git a/venus-shared/utils/utils.go b/venus-shared/utils/utils.go new file mode 100644 index 0000000000..0fa7116fe4 --- /dev/null +++ b/venus-shared/utils/utils.go @@ -0,0 +1,69 @@ +package utils + +import ( + "context" + "fmt" + + builtinactors "github.com/filecoin-project/venus/venus-shared/builtin-actors" + "github.com/filecoin-project/venus/venus-shared/types" +) + +var NameType = map[types.NetworkName]types.NetworkType{ + types.NetworkNameMain: types.NetworkMainnet, + types.NetworkNameCalibration: types.NetworkCalibnet, + types.NetworkNameButterfly: types.NetworkButterfly, + types.NetworkNameInterop: types.NetworkInterop, + types.NetworkNameIntegration: types.Integrationnet, +} + +var TypeName = func() map[types.NetworkType]types.NetworkName { + typeName := make(map[types.NetworkType]types.NetworkName, len(NameType)) + for nt, nn := range NameType { + typeName[nn] = nt + } + + return typeName +}() + +func NetworkNameToNetworkType(networkName types.NetworkName) (types.NetworkType, error) { + if len(networkName) == 0 { + return types.NetworkDefault, fmt.Errorf("network name is empty") + } + nt, ok := NameType[networkName] + if ok { + return nt, nil + } + // 2k and force networks do not have exact network names + return types.Network2k, nil +} + +func NetworkTypeToNetworkName(networkType types.NetworkType) types.NetworkName { + nn, ok := TypeName[networkType] + if ok { + return nn + } + + // 2k and force networks do not have exact network names + return "" +} + +type networkNameGetter interface { + StateNetworkName(ctx context.Context) (types.NetworkName, error) +} + +func LoadBuiltinActors(ctx context.Context, getter networkNameGetter) error { + networkName, err := getter.StateNetworkName(ctx) + if err != nil { + return err + } + nt, err := NetworkNameToNetworkType(networkName) + if err != nil { + return err + } + if err := builtinactors.SetNetworkBundle(nt); err != nil { + return err + } + ReloadMethodsMap() + + return nil +} diff --git a/venus-shared/utils/utils_test.go b/venus-shared/utils/utils_test.go new file mode 100644 index 0000000000..0ad0171de7 --- /dev/null +++ b/venus-shared/utils/utils_test.go @@ -0,0 +1,64 @@ +package utils + +import ( + "context" + "testing" + + tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags" + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/api/chain/v1/mock" + builtinactors "github.com/filecoin-project/venus/venus-shared/builtin-actors" + "github.com/filecoin-project/venus/venus-shared/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" +) + +func TestNetworkNamtToNetworkType(t *testing.T) { + tf.UnitTest(t) + for nt, nn := range TypeName { + got, err := NetworkNameToNetworkType(nn) + assert.Nil(t, err) + assert.Equal(t, nt, got) + } + + nt, err2 := NetworkNameToNetworkType("2k") + assert.Nil(t, err2) + assert.Equal(t, types.Network2k, nt) +} + +func TestNetworkTypeToNetworkName(t *testing.T) { + tf.UnitTest(t) + for nt, nn := range TypeName { + got := NetworkTypeToNetworkName(nt) + assert.Equal(t, nn, got) + } + assert.Equal(t, types.NetworkName(""), NetworkTypeToNetworkName(types.Network2k)) +} + +func TestLoadBuiltinActors(t *testing.T) { + tf.UnitTest(t) + + ctx := context.Background() + + ctrl := gomock.NewController(t) + full := mock.NewMockFullNode(ctrl) + + for nn := range NameType { + full.EXPECT().StateNetworkName(ctx).Return(nn, nil) + + assert.Nil(t, LoadBuiltinActors(ctx, full)) + + for _, actorsMetadata := range builtinactors.EmbeddedBuiltinActorsMetadata { + if actorsMetadata.Network == string(nn) { + for name, actor := range actorsMetadata.Actors { + res, ok := actors.GetActorCodeID(actorsMetadata.Version, name) + assert.True(t, ok) + assert.Equal(t, actor, res) + + _, ok2 := MethodsMap[actor] + assert.True(t, ok2) + } + } + } + } +}