diff --git a/.golangci.yml b/.golangci.yml index 6ebbce1979..abbcc5c634 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -49,5 +49,9 @@ run: skip-dirs: - pkg/constants$ - pkg/util/test$ + - venus-shared/actors/adt$ + - venus-shared/actors/aerrors$ + - venus-shared/actors/builtin$ + - venus-shared/actors/policy$ skip-files: - ".*_gen\\.go$" # skip auto generated go files diff --git a/app/submodule/chain/chaininfo_api.go b/app/submodule/chain/chaininfo_api.go index 50b4dadb17..238b0f6b11 100644 --- a/app/submodule/chain/chaininfo_api.go +++ b/app/submodule/chain/chaininfo_api.go @@ -9,6 +9,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" acrypto "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/network" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" @@ -669,7 +670,7 @@ func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.Netw // StateActorCodeCIDs returns the CIDs of all the builtin actors for the given network version func (cia *chainInfoAPI) StateActorCodeCIDs(ctx context.Context, nv network.Version) (map[string]cid.Cid, error) { - actorVersion, err := actors.VersionForNetwork(nv) + actorVersion, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, fmt.Errorf("invalid network version") } @@ -707,7 +708,7 @@ func (cia *chainInfoAPI) ChainGetGenesis(ctx context.Context) (*types.TipSet, er // StateActorManifestCID returns the CID of the builtin actors manifest for the given network version func (cia *chainInfoAPI) StateActorManifestCID(ctx context.Context, nv network.Version) (cid.Cid, error) { - actorVersion, err := actors.VersionForNetwork(nv) + actorVersion, err := actorstypes.VersionForNetwork(nv) if err != nil { return cid.Undef, fmt.Errorf("invalid network version") } diff --git a/app/submodule/chain/miner_api.go b/app/submodule/chain/miner_api.go index 6495c9bce3..479192e5a8 100644 --- a/app/submodule/chain/miner_api.go +++ b/app/submodule/chain/miner_api.go @@ -20,7 +20,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" cbg "github.com/whyrusleeping/cbor-gen" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" "github.com/filecoin-project/venus/pkg/state/tree" @@ -458,16 +458,20 @@ func (msa *minerStateAPI) StateMinerPreCommitDepositForPower(ctx context.Context store := msa.ChainReader.Store(ctx) var sectorWeight abi.StoragePower - if act, found, err := sTree.GetActor(ctx, market.Address); err != nil || !found { - return big.Int{}, fmt.Errorf("loading market actor %s: %v", maddr, err) - } else if s, err := market.Load(store, act); err != nil { - return big.Int{}, fmt.Errorf("loading market actor state %s: %v", maddr, err) - } else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil { - return big.Int{}, fmt.Errorf("verifying deals for activation: %v", err) + if msa.Fork.GetNetworkVersion(ctx, ts.Height()) <= network.Version16 { + if act, found, err := sTree.GetActor(ctx, market.Address); err != nil || !found { + return big.Int{}, fmt.Errorf("loading market actor %s: %v", maddr, err) + } else if s, err := market.Load(store, act); err != nil { + return big.Int{}, fmt.Errorf("loading market actor state %s: %v", maddr, err) + } else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil { + return big.Int{}, fmt.Errorf("verifying deals for activation: %v", err) + } else { + // NB: not exactly accurate, but should always lead us to *over* estimate, not under + duration := pci.Expiration - ts.Height() + sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw) + } } else { - // NB: not exactly accurate, but should always lead us to *over* estimate, not under - duration := pci.Expiration - ts.Height() - sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw) + sectorWeight = miner.QAPowerMax(ssize) } var powerSmoothed builtin.FilterEstimate diff --git a/app/submodule/chain/v0api/chaininfo_v0api.go b/app/submodule/chain/v0api/chaininfo_v0api.go index 9b07c0414f..adcbc97472 100644 --- a/app/submodule/chain/v0api/chaininfo_v0api.go +++ b/app/submodule/chain/v0api/chaininfo_v0api.go @@ -9,7 +9,7 @@ import ( v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/ipfs/go-cid" diff --git a/app/submodule/multisig/multisig_api.go b/app/submodule/multisig/multisig_api.go index 99e2c99632..0326302c2d 100644 --- a/app/submodule/multisig/multisig_api.go +++ b/app/submodule/multisig/multisig_api.go @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" @@ -39,7 +40,7 @@ func (a *multiSig) messageBuilder(ctx context.Context, from address.Address) (mu if err != nil { return nil, err } - aver, err := actors.VersionForNetwork(nver) + aver, err := actorstypes.VersionForNetwork(nver) if err != nil { return nil, err } @@ -48,7 +49,7 @@ func (a *multiSig) messageBuilder(ctx context.Context, from address.Address) (mu // MsigCreate creates a multisig wallet // It takes the following params: , , -//, , +// , , func (a *multiSig) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (*types.MessagePrototype, error) { mb, err := a.messageBuilder(ctx, src) diff --git a/cmd/miner.go b/cmd/miner.go index dfe34cfd30..bed6bde4e2 100644 --- a/cmd/miner.go +++ b/cmd/miner.go @@ -23,7 +23,6 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/builtin/miner" "github.com/filecoin-project/venus/venus-shared/actors/builtin/power" - "github.com/filecoin-project/venus/venus-shared/actors/policy" "github.com/filecoin-project/venus/venus-shared/types" "github.com/filecoin-project/venus/venus-shared/types/params" ) @@ -54,7 +53,7 @@ var newMinerCmd = &cmds.Command{ cmds.BoolOption("create-worker-key", "Create separate worker key"), cmds.StringOption("from", "Select which address to send actor creation message from"), cmds.StringOption("gas-premium", "Set gas premium for initialization messages in AttoFIL").WithDefault("0"), - cmds.StringOption("sector-size", "specify sector size to use").WithDefault(units.BytesSize(float64(policy.GetDefaultSectorSize()))), + cmds.StringOption("sector-size", "specify sector size to use"), }, Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { ctx := req.Context @@ -64,10 +63,18 @@ var newMinerCmd = &cmds.Command{ return err } - sectorSize, _ := req.Options["sector-size"].(string) - ssize, err := units.RAMInBytes(sectorSize) + ssize, err := abi.RegisteredSealProof_StackedDrg32GiBV1.SectorSize() if err != nil { - return fmt.Errorf("failed to parse sector size: %v", err) + return fmt.Errorf("failed to calculate default sector size: %w", err) + } + + sectorSize, ok := req.Options["sector-size"].(string) + if ok { + sectorSizeInt, err := units.RAMInBytes(sectorSize) + if err != nil { + return err + } + ssize = abi.SectorSize(sectorSizeInt) } gp, _ := req.Options["gas-premium"].(string) @@ -128,7 +135,7 @@ var newMinerCmd = &cmds.Command{ return fmt.Errorf("getting network version: %v", err) } - spt, err := miner.SealProofTypeFromSectorSize(abi.SectorSize(ssize), nv) + spt, err := miner.SealProofTypeFromSectorSize(ssize, nv) if err != nil { return fmt.Errorf("getting seal proof type: %v", err) } diff --git a/cmd/multisig.go b/cmd/multisig.go index 37f7914760..6e874aaf72 100644 --- a/cmd/multisig.go +++ b/cmd/multisig.go @@ -290,7 +290,7 @@ var msigInspectCmd = &cmds.Command{ } paramStr = string(b) } - 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), method.Name, tx.Method, paramStr) + 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), method.Num, tx.Method, paramStr) } } if err := w.Flush(); err != nil { diff --git a/cmd/state.go b/cmd/state.go index 3c351617dd..b40bb1d335 100644 --- a/cmd/state.go +++ b/cmd/state.go @@ -15,6 +15,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" "github.com/ipfs/go-cid" @@ -23,7 +24,6 @@ import ( "github.com/filecoin-project/venus/app/node" "github.com/filecoin-project/venus/pkg/constants" - "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/builtin" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -631,7 +631,7 @@ var stateSysActorCIDsCmd = &cmds.Command{ buf := new(bytes.Buffer) buf.WriteString(fmt.Sprintf("Network Version: %d\n", nv)) - actorVersion, err := actors.VersionForNetwork(nv) + actorVersion, err := actorstypes.VersionForNetwork(nv) if err != nil { return err } diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 32afd6e1f1..c70caaf14f 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 32afd6e1f1419b6bb7d0f4b3944287fde593ca64 +Subproject commit c70caaf14f8ff5b15eb5166093d9e57055e571f8 diff --git a/fixtures/networks/butterfly.go b/fixtures/networks/butterfly.go index c97106cafb..04c3cb50a9 100644 --- a/fixtures/networks/butterfly.go +++ b/fixtures/networks/butterfly.go @@ -21,7 +21,7 @@ func ButterflySnapNet() *NetworkConf { Network: config.NetworkParamsConfig{ DevNet: true, NetworkType: types.NetworkButterfly, - GenesisNetworkVersion: network.Version15, + GenesisNetworkVersion: network.Version16, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1, @@ -32,27 +32,27 @@ func ButterflySnapNet() *NetworkConf { MinVerifiedDealSize: 1 << 20, PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ - UpgradeBreezeHeight: -1, - UpgradeSmokeHeight: -2, - UpgradeIgnitionHeight: -3, - UpgradeRefuelHeight: -4, - UpgradeAssemblyHeight: -5, - UpgradeTapeHeight: -6, - UpgradeLiftoffHeight: -7, - UpgradeKumquatHeight: -8, - UpgradeCalicoHeight: -9, - UpgradePersianHeight: -10, - UpgradeOrangeHeight: -12, - UpgradeTrustHeight: -13, - UpgradeNorwegianHeight: -14, - UpgradeTurboHeight: -15, - UpgradeHyperdriveHeight: -16, - UpgradeChocolateHeight: -17, - UpgradeOhSnapHeight: -18, - UpgradeSkyrHeight: 50, - BreezeGasTampingDuration: 120, - UpgradeClausHeight: -11, + UpgradeBreezeHeight: -1, + UpgradeSmokeHeight: -2, + UpgradeIgnitionHeight: -3, + UpgradeRefuelHeight: -4, + UpgradeAssemblyHeight: -5, + UpgradeTapeHeight: -6, + UpgradeLiftoffHeight: -7, + UpgradeKumquatHeight: -8, + UpgradeCalicoHeight: -9, + UpgradePersianHeight: -10, + UpgradeOrangeHeight: -11, + UpgradeClausHeight: -12, + UpgradeTrustHeight: -13, + UpgradeNorwegianHeight: -14, + UpgradeTurboHeight: -15, + UpgradeHyperdriveHeight: -16, + UpgradeChocolateHeight: -17, + UpgradeOhSnapHeight: -18, + UpgradeSkyrHeight: -19, + UpgradeV17Height: 99999999999999, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, diff --git a/fixtures/networks/calibration.go b/fixtures/networks/calibration.go index 9cf0cc8c34..c83be5cbd9 100644 --- a/fixtures/networks/calibration.go +++ b/fixtures/networks/calibration.go @@ -38,27 +38,27 @@ func Calibration() *NetworkConf { MinVerifiedDealSize: 1 << 20, PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ - UpgradeBreezeHeight: -1, - UpgradeSmokeHeight: -2, - UpgradeIgnitionHeight: -3, - UpgradeRefuelHeight: -4, - UpgradeAssemblyHeight: 30, - UpgradeTapeHeight: 60, - UpgradeLiftoffHeight: -5, - UpgradeKumquatHeight: 90, - UpgradeCalicoHeight: 120, - UpgradePersianHeight: 100 + (120 * 1), - UpgradeOrangeHeight: 300, - UpgradeTrustHeight: 330, - UpgradeNorwegianHeight: 360, - UpgradeTurboHeight: 390, - UpgradeHyperdriveHeight: 420, - UpgradeSkyrHeight: 1044660, // 2022-06-16T17:30:00Z - BreezeGasTampingDuration: 120, + UpgradeBreezeHeight: -1, + UpgradeSmokeHeight: -2, + UpgradeIgnitionHeight: -3, + UpgradeRefuelHeight: -4, + UpgradeAssemblyHeight: 30, + UpgradeTapeHeight: 60, + UpgradeLiftoffHeight: -5, + UpgradeKumquatHeight: 90, + UpgradeCalicoHeight: 120, + UpgradePersianHeight: 100 + (120 * 1), UpgradeClausHeight: 270, + UpgradeOrangeHeight: 300, + UpgradeTrustHeight: 330, + UpgradeNorwegianHeight: 360, + UpgradeTurboHeight: 390, + UpgradeHyperdriveHeight: 420, UpgradeChocolateHeight: 312746, - UpgradeOhSnapHeight: 682006, // 2022-02-10T19:23:00Z + UpgradeOhSnapHeight: 682006, // 2022-02-10T19:23:00Z + UpgradeSkyrHeight: 1044660, // 2022-06-16T17:30:00Z + UpgradeV17Height: 99999999999999, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, diff --git a/fixtures/networks/forcenet.go b/fixtures/networks/forcenet.go index ac074c0051..e49c564aca 100644 --- a/fixtures/networks/forcenet.go +++ b/fixtures/networks/forcenet.go @@ -54,6 +54,7 @@ func ForceNet() *NetworkConf { UpgradeChocolateHeight: -17, UpgradeOhSnapHeight: -18, UpgradeSkyrHeight: -19, + UpgradeV17Height: 99999999999999, }, 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 d5cf478466..98b59fd10f 100644 --- a/fixtures/networks/integrationtestnet.go +++ b/fixtures/networks/integrationtestnet.go @@ -28,27 +28,27 @@ func IntegrationNet() *NetworkConf { MinVerifiedDealSize: 1 << 20, PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ - UpgradeBreezeHeight: 41280, - UpgradeSmokeHeight: 51000, - UpgradeIgnitionHeight: 94000, - UpgradeRefuelHeight: 130800, - UpgradeAssemblyHeight: 138720, - UpgradeTapeHeight: 140760, - UpgradeLiftoffHeight: 148888, - UpgradeKumquatHeight: 170000, - UpgradeCalicoHeight: 265200, - UpgradePersianHeight: 265200 + (120 * 60), - UpgradeOrangeHeight: 336458, - UpgradeTrustHeight: 550321, - UpgradeNorwegianHeight: 665280, - UpgradeTurboHeight: 712320, - UpgradeHyperdriveHeight: 892800, - UpgradeChocolateHeight: 1231620, - UpgradeOhSnapHeight: 1594680, - UpgradeSkyrHeight: 99999999999999, - BreezeGasTampingDuration: 120, + UpgradeBreezeHeight: 41280, + UpgradeSmokeHeight: 51000, + UpgradeIgnitionHeight: 94000, + UpgradeRefuelHeight: 130800, + UpgradeAssemblyHeight: 138720, + UpgradeTapeHeight: 140760, + UpgradeLiftoffHeight: 148888, + UpgradeKumquatHeight: 170000, + UpgradeCalicoHeight: 265200, + UpgradePersianHeight: 265200 + (120 * 60), + UpgradeOrangeHeight: 336458, UpgradeClausHeight: 343200, + UpgradeTrustHeight: 550321, + UpgradeNorwegianHeight: 665280, + UpgradeTurboHeight: 712320, + UpgradeHyperdriveHeight: 892800, + UpgradeChocolateHeight: 1231620, + UpgradeOhSnapHeight: 1594680, + UpgradeSkyrHeight: 1960320, + UpgradeV17Height: 99999999999999, }, 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 d1c0c55c8f..1e24443cd0 100644 --- a/fixtures/networks/interopnet.go +++ b/fixtures/networks/interopnet.go @@ -21,7 +21,7 @@ func InteropNet() *NetworkConf { Network: config.NetworkParamsConfig{ DevNet: true, NetworkType: types.NetworkInterop, - GenesisNetworkVersion: network.Version15, + GenesisNetworkVersion: network.Version16, ReplaceProofTypes: []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg2KiBV1, abi.RegisteredSealProof_StackedDrg8MiBV1, @@ -32,27 +32,27 @@ func InteropNet() *NetworkConf { MinVerifiedDealSize: 256, PreCommitChallengeDelay: abi.ChainEpoch(10), ForkUpgradeParam: &config.ForkUpgradeConfig{ - UpgradeBreezeHeight: -1, - UpgradeSmokeHeight: -2, - UpgradeIgnitionHeight: -3, - UpgradeRefuelHeight: -4, - UpgradeAssemblyHeight: -5, - UpgradeTapeHeight: -6, - UpgradeLiftoffHeight: -7, - UpgradeKumquatHeight: -8, - UpgradeCalicoHeight: -9, - UpgradePersianHeight: -10, - UpgradeOrangeHeight: -11, - UpgradeTrustHeight: -13, - UpgradeNorwegianHeight: -14, - UpgradeTurboHeight: -15, - UpgradeHyperdriveHeight: -16, - UpgradeChocolateHeight: -17, - UpgradeOhSnapHeight: -18, - UpgradeSkyrHeight: 100, - BreezeGasTampingDuration: 0, - UpgradeClausHeight: -11, + UpgradeBreezeHeight: -1, + UpgradeSmokeHeight: -2, + UpgradeIgnitionHeight: -3, + UpgradeRefuelHeight: -4, + UpgradeAssemblyHeight: -5, + UpgradeTapeHeight: -6, + UpgradeLiftoffHeight: -7, + UpgradeKumquatHeight: -8, + UpgradeCalicoHeight: -9, + UpgradePersianHeight: -10, + UpgradeOrangeHeight: -11, + UpgradeClausHeight: -12, + UpgradeTrustHeight: -13, + UpgradeNorwegianHeight: -14, + UpgradeTurboHeight: -15, + UpgradeHyperdriveHeight: -16, + UpgradeChocolateHeight: -17, + UpgradeOhSnapHeight: -18, + UpgradeSkyrHeight: -19, + UpgradeV17Height: 99999999999999, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, diff --git a/fixtures/networks/mainnet.go b/fixtures/networks/mainnet.go index 605487f06f..e902581087 100644 --- a/fixtures/networks/mainnet.go +++ b/fixtures/networks/mainnet.go @@ -46,13 +46,14 @@ func Mainnet() *NetworkConf { MinVerifiedDealSize: 1 << 20, PreCommitChallengeDelay: abi.ChainEpoch(150), ForkUpgradeParam: &config.ForkUpgradeConfig{ - UpgradeBreezeHeight: 41280, - UpgradeSmokeHeight: 51000, - UpgradeIgnitionHeight: 94000, - UpgradeRefuelHeight: 130800, - UpgradeAssemblyHeight: 138720, - UpgradeTapeHeight: 140760, - UpgradeLiftoffHeight: 148888, + BreezeGasTampingDuration: 120, + UpgradeBreezeHeight: 41280, + UpgradeSmokeHeight: 51000, + UpgradeIgnitionHeight: 94000, + UpgradeRefuelHeight: 130800, + UpgradeAssemblyHeight: 138720, + UpgradeTapeHeight: 140760, + UpgradeLiftoffHeight: 148888, // This signals our tentative epoch for mainnet launch. Can make it later, but not earlier. // Miners, clients, developers, custodians all need time to prepare. // We still have upgrades and state changes to do, but can happen after signaling timing here. @@ -60,6 +61,7 @@ func Mainnet() *NetworkConf { UpgradeCalicoHeight: 265200, UpgradePersianHeight: 265200 + (builtin2.EpochsInHour * 60), UpgradeOrangeHeight: 336458, + UpgradeClausHeight: 343200, // 2020-12-22T02:00:00Z UpgradeTrustHeight: 550321, // 2021-03-04T00:00:30Z UpgradeNorwegianHeight: 665280, // 2021-04-12T22:00:00Z UpgradeTurboHeight: 712320, // 2021-04-29T06:00:00Z @@ -67,9 +69,7 @@ func Mainnet() *NetworkConf { UpgradeChocolateHeight: 1231620, UpgradeOhSnapHeight: 1594680, // 2022-03-01T15:00:00Z UpgradeSkyrHeight: 1960320, // 2022-07-06T14:00:00Z - - BreezeGasTampingDuration: 120, - UpgradeClausHeight: 343200, // 2020-12-22T02:00:00Z + UpgradeV17Height: 99999999999999, }, 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 b4bb004c55..d50f42da38 100644 --- a/fixtures/networks/net_2k.go +++ b/fixtures/networks/net_2k.go @@ -27,27 +27,27 @@ func Net2k() *NetworkConf { MinVerifiedDealSize: 256, PreCommitChallengeDelay: abi.ChainEpoch(10), ForkUpgradeParam: &config.ForkUpgradeConfig{ - UpgradeBreezeHeight: -1, - UpgradeSmokeHeight: -2, - UpgradeIgnitionHeight: -3, - UpgradeRefuelHeight: -4, - UpgradeTapeHeight: -5, - UpgradeAssemblyHeight: -6, - UpgradeLiftoffHeight: -7, - UpgradeKumquatHeight: -8, - UpgradeCalicoHeight: -9, - UpgradePersianHeight: -10, - UpgradeOrangeHeight: -11, - UpgradeTrustHeight: -13, - UpgradeNorwegianHeight: -14, - UpgradeTurboHeight: -15, - UpgradeHyperdriveHeight: -16, - UpgradeChocolateHeight: -17, - UpgradeOhSnapHeight: -18, - UpgradeSkyrHeight: -19, - BreezeGasTampingDuration: 0, - UpgradeClausHeight: -11, + UpgradeBreezeHeight: -1, + UpgradeSmokeHeight: -2, + UpgradeIgnitionHeight: -3, + UpgradeRefuelHeight: -4, + UpgradeTapeHeight: -5, + UpgradeAssemblyHeight: -6, + UpgradeLiftoffHeight: -7, + UpgradeKumquatHeight: -8, + UpgradeCalicoHeight: -9, + UpgradePersianHeight: -10, + UpgradeOrangeHeight: -11, + UpgradeClausHeight: -12, + UpgradeTrustHeight: -13, + UpgradeNorwegianHeight: -14, + UpgradeTurboHeight: -15, + UpgradeHyperdriveHeight: -16, + UpgradeChocolateHeight: -17, + UpgradeOhSnapHeight: -18, + UpgradeSkyrHeight: -19, + UpgradeV17Height: 99999999999999, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1}, AddressNetwork: address.Testnet, diff --git a/go.mod b/go.mod index 431bda04b8..66287b8b0e 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/filecoin-project/go-fil-markets v1.24.0 github.com/filecoin-project/go-jsonrpc v0.1.5 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.1.10 + github.com/filecoin-project/go-state-types v0.1.12-beta 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 @@ -139,6 +139,7 @@ require ( github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349 // indirect github.com/filecoin-project/go-amt-ipld/v3 v3.1.0 // indirect github.com/filecoin-project/go-amt-ipld/v4 v4.0.0 // indirect + github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 // indirect github.com/filecoin-project/go-ds-versioning v0.1.1 // indirect github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index b583853924..52801fb973 100644 --- a/go.sum +++ b/go.sum @@ -351,6 +351,8 @@ github.com/filecoin-project/go-cbor-util v0.0.1 h1:E1LYZYTtjfAQwCReho0VXvbu8t3CY github.com/filecoin-project/go-cbor-util v0.0.1/go.mod h1:pqTiPHobNkOVM5thSRsHYjyQfq7O5QSCMhvuu9JoDlg= github.com/filecoin-project/go-commp-utils v0.1.3 h1:rTxbkNXZU7FLgdkBk8RsQIEOuPONHykEoX3xGk41Fkw= github.com/filecoin-project/go-commp-utils v0.1.3/go.mod h1:3ENlD1pZySaUout0p9ANQrY3fDFoXdqyX04J+dWpK30= +github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 h1:4cITW0pwgvqLs86Q9bWQa34+jBfR1V687bDkmv2DgnA= +github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837/go.mod h1:e2YBjSblNVoBckkbv3PPqsq71q98oFkFqL7s1etViGo= github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= github.com/filecoin-project/go-crypto v0.0.1 h1:AcvpSGGCgjaY8y1az6AMfKQWreF/pWO2JJGLl6gCq6o= github.com/filecoin-project/go-crypto v0.0.1/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= @@ -392,8 +394,9 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4 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/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-state-types v0.1.12-beta h1:QZE00g75shqwhPn0/bZL38sFxVAqnXC7zjmYltRdhxI= +github.com/filecoin-project/go-state-types v0.1.12-beta/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI= 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= diff --git a/pkg/config/config.go b/pkg/config/config.go index 990277022e..d0d86d8ddf 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -286,6 +286,7 @@ type ForkUpgradeConfig struct { UpgradeChocolateHeight abi.ChainEpoch `json:"upgradeChocolateHeight"` UpgradeOhSnapHeight abi.ChainEpoch `json:"upgradeOhSnapHeight"` UpgradeSkyrHeight abi.ChainEpoch `json:"upgradeSkyrHeight"` + UpgradeV17Height abi.ChainEpoch `json:"upgradeV17Height"` } func IsNearUpgrade(epoch, upgradeEpoch abi.ChainEpoch) bool { @@ -313,6 +314,7 @@ var DefaultForkUpgradeParam = &ForkUpgradeConfig{ UpgradeChocolateHeight: 1231620, UpgradeOhSnapHeight: 1594680, UpgradeSkyrHeight: 1960320, + UpgradeV17Height: 99999999999999, } func newDefaultNetworkParamsConfig() *NetworkParamsConfig { diff --git a/pkg/constants/shared_vals.go b/pkg/constants/shared_vals.go index 6f75503939..75e2893878 100644 --- a/pkg/constants/shared_vals.go +++ b/pkg/constants/shared_vals.go @@ -21,7 +21,7 @@ const NewestNetworkVersion = network.Version{{.latestNetworkVersion}} /* inline-gen start */ -const NewestNetworkVersion = network.Version16 +const NewestNetworkVersion = network.Version17 /* inline-gen end */ diff --git a/pkg/fork/fork.go b/pkg/fork/fork.go index 9ad11c9ffa..78f1386f2f 100644 --- a/pkg/fork/fork.go +++ b/pkg/fork/fork.go @@ -16,6 +16,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/go-state-types/network" @@ -30,6 +31,7 @@ import ( cbg "github.com/whyrusleeping/cbor-gen" "go.opencensus.io/trace" + nv17 "github.com/filecoin-project/go-state-types/builtin/v9/migration" "github.com/filecoin-project/specs-actors/actors/migration/nv3" "github.com/filecoin-project/specs-actors/v2/actors/migration/nv4" "github.com/filecoin-project/specs-actors/v2/actors/migration/nv7" @@ -296,6 +298,17 @@ func DefaultUpgradeSchedule(cf *ChainFork, upgradeHeight *config.ForkUpgradeConf StopWithin: 5, }}, Expensive: true, + }, { + Height: upgradeHeight.UpgradeV17Height, + Network: network.Version17, + Migration: cf.UpgradeActorsV9, + PreMigrations: []PreMigration{{ + PreMigration: cf.PreUpgradeActorsV9, + StartWithin: 180, + DontStartWithin: 60, + StopWithin: 5, + }}, + Expensive: true, }, } @@ -2081,7 +2094,7 @@ func (c *ChainFork) upgradeActorsV8Common( store := chain.ActorStore(ctx, buf) // ensure that the manifest is loaded in the blockstore - if err := actors.LoadBundles(ctx, buf, actors.Version8); err != nil { + if err := actors.LoadBundles(ctx, buf, actorstypes.Version8); err != nil { return cid.Undef, fmt.Errorf("failed to load manifest bundle: %w", err) } @@ -2098,7 +2111,7 @@ func (c *ChainFork) upgradeActorsV8Common( ) } - manifest, ok := actors.GetManifest(actors.Version8) + manifest, ok := actors.GetManifest(actorstypes.Version8) if !ok { return cid.Undef, fmt.Errorf("no manifest CID for v8 upgrade") } @@ -2133,6 +2146,120 @@ func (c *ChainFork) upgradeActorsV8Common( return newRoot, nil } +func (c *ChainFork) UpgradeActorsV9(ctx context.Context, cache MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) { + // Use all the CPUs except 3. + workerCount := runtime.NumCPU() - 3 + if workerCount <= 0 { + workerCount = 1 + } + + config := nv17.Config{ + MaxWorkers: uint(workerCount), + JobQueueSize: 1000, + ResultQueueSize: 100, + ProgressLogPeriod: 10 * time.Second, + } + + newRoot, err := c.upgradeActorsV9Common(ctx, cache, root, epoch, ts, config) + if err != nil { + return cid.Undef, fmt.Errorf("migrating actors v8 state: %w", err) + } + + fmt.Print(fvmLiftoffBanner) + + return newRoot, nil +} + +func (c *ChainFork) PreUpgradeActorsV9(ctx context.Context, + cache MigrationCache, + root cid.Cid, + epoch abi.ChainEpoch, + ts *types.TipSet, +) error { + // Use half the CPUs for pre-migration, but leave at least 3. + workerCount := runtime.NumCPU() + if workerCount <= 4 { + workerCount = 1 + } else { + workerCount /= 2 + } + + ver := c.GetNetworkVersion(ctx, epoch) + lbts, lbRoot, err := c.cr.GetLookbackTipSetForRound(ctx, ts, epoch, ver) + if err != nil { + return fmt.Errorf("error getting lookback ts for premigration: %w", err) + } + + config := nv17.Config{ + MaxWorkers: uint(workerCount), + ProgressLogPeriod: time.Minute * 5, + } + + _, err = c.upgradeActorsV9Common(ctx, cache, lbRoot, epoch, lbts, config) + return err +} + +func (c *ChainFork) upgradeActorsV9Common(ctx context.Context, + cache MigrationCache, + root cid.Cid, + epoch abi.ChainEpoch, + ts *types.TipSet, + config nv17.Config, +) (cid.Cid, error) { + buf := blockstoreutil.NewTieredBstore(c.bs, blockstoreutil.NewTemporarySync()) + store := chain.ActorStore(ctx, buf) + + // ensure that the manifest is loaded in the blockstore + if err := actors.LoadBundles(ctx, buf, actorstypes.Version9); err != nil { + return cid.Undef, fmt.Errorf("failed to load manifest bundle: %w", err) + } + + // 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 != vmstate.StateTreeVersion4 { + return cid.Undef, fmt.Errorf("expected state root version 4 for actors v9 upgrade, got %d", stateRoot.Version) + } + + manifest, ok := actors.GetManifest(actorstypes.Version9) + if !ok { + return cid.Undef, fmt.Errorf("no manifest CID for v9 upgrade") + } + + // Perform the migration + newHamtRoot, err := nv17.MigrateStateTree(ctx, store, manifest, stateRoot.Actors, epoch, config, + migrationLogger{}, cache) + if err != nil { + return cid.Undef, fmt.Errorf("upgrading to actors v9: %w", err) + } + + // Persist the result. + newRoot, err := store.Put(ctx, &vmstate.StateRoot{ + Version: vmstate.StateTreeVersion4, + Actors: newHamtRoot, + Info: stateRoot.Info, + }) + if err != nil { + return cid.Undef, fmt.Errorf("failed to persist new state root: %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 (c *ChainFork) GetForkUpgrade() *config.ForkUpgradeConfig { return c.forkUpgrade } @@ -2165,7 +2292,7 @@ func (c *ChainFork) GetForkUpgrade() *config.ForkUpgradeConfig { // 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) { +func LiteMigration(ctx context.Context, bstore blockstoreutil.Blockstore, newActorsManifestCid cid.Cid, root cid.Cid, av actorstypes.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) diff --git a/pkg/fvm/cbor_gen.go b/pkg/fvm/cbor_gen.go index 1d71d36bc6..0d2dbd2026 100644 --- a/pkg/fvm/cbor_gen.go +++ b/pkg/fvm/cbor_gen.go @@ -19,7 +19,7 @@ var _ = cid.Undef var _ = math.E var _ = sort.Sort -var lengthBufFvmExecutionTrace = []byte{132} +var lengthBufFvmExecutionTrace = []byte{133} func (t *FvmExecutionTrace) MarshalCBOR(w io.Writer) error { if t == nil { @@ -55,8 +55,22 @@ func (t *FvmExecutionTrace) MarshalCBOR(w io.Writer) error { return err } + // t.GasCharges ([]fvm.FvmGasCharge) (slice) + if len(t.GasCharges) > 1000000000 { + return xerrors.Errorf("Slice value in field t.GasCharges was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.GasCharges))); err != nil { + return err + } + for _, v := range t.GasCharges { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + } + // t.Subcalls ([]fvm.FvmExecutionTrace) (slice) - if len(t.Subcalls) > cbg.MaxLength { + if len(t.Subcalls) > 1000000000 { return xerrors.Errorf("Slice value in field t.Subcalls was too long") } @@ -90,7 +104,7 @@ func (t *FvmExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { return fmt.Errorf("cbor input should be of type array") } - if extra != 4 { + if extra != 5 { return fmt.Errorf("cbor input had wrong number of fields") } @@ -142,6 +156,35 @@ func (t *FvmExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { t.Error = string(sval) } + // t.GasCharges ([]fvm.FvmGasCharge) (slice) + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 1000000000 { + return fmt.Errorf("t.GasCharges: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.GasCharges = make([]FvmGasCharge, extra) + } + + for i := 0; i < int(extra); i++ { + + var v FvmGasCharge + if err := v.UnmarshalCBOR(cr); err != nil { + return err + } + + t.GasCharges[i] = v + } + // t.Subcalls ([]fvm.FvmExecutionTrace) (slice) maj, extra, err = cr.ReadHeader() @@ -149,7 +192,7 @@ func (t *FvmExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { return err } - if extra > cbg.MaxLength { + if extra > 1000000000 { return fmt.Errorf("t.Subcalls: array too large (%d)", extra) } @@ -173,3 +216,175 @@ func (t *FvmExecutionTrace) UnmarshalCBOR(r io.Reader) (err error) { return nil } + +var lengthBufFvmGasCharge = []byte{132} + +func (t *FvmGasCharge) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write(lengthBufFvmGasCharge); err != nil { + return err + } + + // t.Name (string) (string) + if len(t.Name) > cbg.MaxLength { + return xerrors.Errorf("Value in field t.Name was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { + return err + } + if _, err := io.WriteString(w, string(t.Name)); err != nil { + return err + } + + // t.TotalGas (int64) (int64) + if t.TotalGas >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.TotalGas)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.TotalGas-1)); err != nil { + return err + } + } + + // t.ComputeGas (int64) (int64) + if t.ComputeGas >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.ComputeGas)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.ComputeGas-1)); err != nil { + return err + } + } + + // t.StorageGas (int64) (int64) + if t.StorageGas >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.StorageGas)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.StorageGas-1)); err != nil { + return err + } + } + return nil +} + +func (t *FvmGasCharge) UnmarshalCBOR(r io.Reader) (err error) { + *t = FvmGasCharge{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajArray { + return fmt.Errorf("cbor input should be of type array") + } + + if extra != 4 { + return fmt.Errorf("cbor input had wrong number of fields") + } + + // t.Name (string) (string) + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.Name = string(sval) + } + // t.TotalGas (int64) (int64) + { + maj, extra, err := cr.ReadHeader() + var extraI int64 + if err != nil { + return err + } + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative oveflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.TotalGas = int64(extraI) + } + // t.ComputeGas (int64) (int64) + { + maj, extra, err := cr.ReadHeader() + var extraI int64 + if err != nil { + return err + } + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative oveflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.ComputeGas = int64(extraI) + } + // t.StorageGas (int64) (int64) + { + maj, extra, err := cr.ReadHeader() + var extraI int64 + if err != nil { + return err + } + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative oveflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + + t.StorageGas = int64(extraI) + } + return nil +} diff --git a/pkg/fvm/fvm.go b/pkg/fvm/fvm.go index 8f5d9b30d5..5dc4bab103 100644 --- a/pkg/fvm/fvm.go +++ b/pkg/fvm/fvm.go @@ -16,6 +16,7 @@ import ( ffi_cgo "github.com/filecoin-project/filecoin-ffi/cgo" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/venus/pkg/constants" @@ -58,13 +59,21 @@ type FvmExtern struct { // nolint gasPriceSchedule *gas.PricesSchedule } +type FvmGasCharge struct { // nolint + Name string + TotalGas int64 + ComputeGas int64 + StorageGas int64 +} + // This may eventually become identical to ExecutionTrace, but we can make incremental progress towards that type FvmExecutionTrace struct { // nolint Msg *types.Message MsgRct *types.MessageReceipt Error string - Subcalls []FvmExecutionTrace + GasCharges []FvmGasCharge `cborgen:"maxlen=1000000000"` + Subcalls []FvmExecutionTrace `cborgen:"maxlen=1000000000"` } func (t *FvmExecutionTrace) ToExecutionTrace() types.ExecutionTrace { @@ -81,6 +90,18 @@ func (t *FvmExecutionTrace) ToExecutionTrace() types.ExecutionTrace { Subcalls: nil, // Should be nil when there are no subcalls for backwards compatibility } + if len(t.GasCharges) > 0 { + ret.GasCharges = make([]*types.GasTrace, len(t.GasCharges)) + for i, v := range t.GasCharges { + ret.GasCharges[i] = &types.GasTrace{ + Name: v.Name, + TotalGas: v.TotalGas, + ComputeGas: v.ComputeGas, + StorageGas: v.StorageGas, + } + } + } + if len(t.Subcalls) > 0 { ret.Subcalls = make([]types.ExecutionTrace, len(t.Subcalls)) @@ -327,7 +348,7 @@ func NewFVM(ctx context.Context, opts *vm.VmOption) (*FVM, error) { return nil, fmt.Errorf("creating fvm opts: %w", err) } if os.Getenv("VENUS_USE_FVM_CUSTOM_BUNDLE") == "1" { - av, err := actors.VersionForNetwork(opts.NetworkVersion) + av, err := actorstypes.VersionForNetwork(opts.NetworkVersion) if err != nil { return nil, fmt.Errorf("mapping network version to actors version: %w", err) } @@ -395,7 +416,7 @@ func NewDebugFVM(ctx context.Context, opts *vm.VmOption) (*FVM, error) { return fmt.Errorf("loading debug manifest: %w", err) } - av, err := actors.VersionForNetwork(opts.NetworkVersion) + av, err := actorstypes.VersionForNetwork(opts.NetworkVersion) if err != nil { return fmt.Errorf("getting actors version: %w", err) } @@ -429,13 +450,13 @@ func NewDebugFVM(ctx context.Context, opts *vm.VmOption) (*FVM, error) { return nil } - av, err := actors.VersionForNetwork(opts.NetworkVersion) + av, err := actorstypes.VersionForNetwork(opts.NetworkVersion) if err != nil { return nil, fmt.Errorf("error determining actors version for network version %d: %w", opts.NetworkVersion, err) } switch av { - case actors.Version8: + case actorstypes.Version8: if debugBundleV8path != "" { if err := createMapping(debugBundleV8path); err != nil { fvmLog.Errorf("failed to create v8 debug mapping") diff --git a/pkg/gen/genesis/f00_system.go b/pkg/gen/genesis/f00_system.go index 5e9f5d3613..f104cb7fbd 100644 --- a/pkg/gen/genesis/f00_system.go +++ b/pkg/gen/genesis/f00_system.go @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/go-state-types/big" + actorstypes "github.com/filecoin-project/go-state-types/actors" systemtypes "github.com/filecoin-project/go-state-types/builtin/v8/system" "github.com/filecoin-project/go-state-types/manifest" @@ -21,7 +22,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" ) -func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { var st system.State cst := cbor.NewCborStore(bs) @@ -31,7 +32,7 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi return nil, err } - if av >= actors.Version8 { + if av >= actorstypes.Version8 { mfCid, ok := actors.GetManifest(av) if !ok { return nil, fmt.Errorf("missing manifest for actors version %d", av) diff --git a/pkg/gen/genesis/f01_init.go b/pkg/gen/genesis/f01_init.go index 562d0be8ef..cad47d784e 100644 --- a/pkg/gen/genesis/f01_init.go +++ b/pkg/gen/genesis/f01_init.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -21,7 +22,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" ) -func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, initialActors []Actor, rootVerifier Actor, remainder Actor, av actors.Version) (int64, *types.Actor, map[address.Address]address.Address, error) { +func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, initialActors []Actor, rootVerifier Actor, remainder Actor, av actorstypes.Version) (int64, *types.Actor, map[address.Address]address.Address, error) { if len(initialActors) > MaxAccounts { return 0, nil, nil, errors.New("too many initial actors") } diff --git a/pkg/gen/genesis/f02_reward.go b/pkg/gen/genesis/f02_reward.go index c765ccfaea..3f2fe36808 100644 --- a/pkg/gen/genesis/f02_reward.go +++ b/pkg/gen/genesis/f02_reward.go @@ -10,14 +10,14 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/builtin/reward" "github.com/filecoin-project/venus/venus-shared/types" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" - cbor "github.com/ipfs/go-ipld-cbor" bstore "github.com/filecoin-project/venus/pkg/util/blockstoreutil" ) -func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actors.Version) (*types.Actor, error) { +func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) rst, err := reward.MakeState(adt.WrapStore(ctx, cst), av, qaPower) if err != nil { diff --git a/pkg/gen/genesis/f03_cron.go b/pkg/gen/genesis/f03_cron.go index 0e01f4b9dd..3a699dfd2e 100644 --- a/pkg/gen/genesis/f03_cron.go +++ b/pkg/gen/genesis/f03_cron.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" cbor "github.com/ipfs/go-ipld-cbor" @@ -15,7 +16,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" ) -func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) st, err := cron.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) if err != nil { diff --git a/pkg/gen/genesis/f04_power.go b/pkg/gen/genesis/f04_power.go index d9fbb39ee0..d24c411ee8 100644 --- a/pkg/gen/genesis/f04_power.go +++ b/pkg/gen/genesis/f04_power.go @@ -7,6 +7,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/builtin/power" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -16,7 +17,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" ) -func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) pst, err := power.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) diff --git a/pkg/gen/genesis/f05_market.go b/pkg/gen/genesis/f05_market.go index 04706c6b6c..68d087357d 100644 --- a/pkg/gen/genesis/f05_market.go +++ b/pkg/gen/genesis/f05_market.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" cbor "github.com/ipfs/go-ipld-cbor" @@ -15,7 +16,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/types" ) -func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) mst, err := market.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) if err != nil { diff --git a/pkg/gen/genesis/f06_vreg.go b/pkg/gen/genesis/f06_vreg.go index bd6e776b2d..849b10fdcf 100644 --- a/pkg/gen/genesis/f06_vreg.go +++ b/pkg/gen/genesis/f06_vreg.go @@ -10,6 +10,7 @@ import ( "github.com/filecoin-project/go-address" cbor "github.com/ipfs/go-ipld-cbor" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -30,7 +31,7 @@ func init() { RootVerifierID = idk } -func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) vst, err := verifreg.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av, RootVerifierID) if err != nil { diff --git a/pkg/gen/genesis/genesis.go b/pkg/gen/genesis/genesis.go index 6c1c74cdd6..55836393bd 100644 --- a/pkg/gen/genesis/genesis.go +++ b/pkg/gen/genesis/genesis.go @@ -24,6 +24,7 @@ import ( verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/venus/venus-shared/actors" @@ -155,7 +156,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template Te return nil, nil, fmt.Errorf("making new state tree: %w", err) } - av, err := actors.VersionForNetwork(template.NetworkVersion) + av, err := actorstypes.VersionForNetwork(template.NetworkVersion) if err != nil { return nil, nil, fmt.Errorf("get actor version: %w", err) } @@ -373,7 +374,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template Te return state, keyIDs, nil } -func makeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version, addr address.Address, bal types.BigInt) (*types.Actor, error) { +func makeAccountActor(ctx context.Context, cst cbor.IpldStore, av actorstypes.Version, addr address.Address, bal types.BigInt) (*types.Actor, error) { ast, err := account.MakeState(adt.WrapStore(ctx, cst), av, addr) if err != nil { return nil, err @@ -398,7 +399,7 @@ func makeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version return act, nil } -func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *tree.State, info Actor, keyIDs map[address.Address]address.Address, av actors.Version) error { +func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *tree.State, info Actor, keyIDs map[address.Address]address.Address, av actorstypes.Version) error { var ainfo AccountMeta if err := json.Unmarshal(info.Meta, &ainfo); err != nil { return fmt.Errorf("unmarshaling account meta: %w", err) @@ -421,7 +422,7 @@ func createAccountActor(ctx context.Context, cst cbor.IpldStore, state *tree.Sta return nil } -func createMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *tree.State, ida address.Address, info Actor, keyIDs map[address.Address]address.Address, av actors.Version) error { +func createMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *tree.State, ida address.Address, info Actor, keyIDs map[address.Address]address.Address, av actorstypes.Version) error { if info.Type != TMultisig { return fmt.Errorf("can only call createMultisigAccount with multisig Actor info") } diff --git a/pkg/gen/genesis/miners.go b/pkg/gen/genesis/miners.go index d324351583..7060178c03 100644 --- a/pkg/gen/genesis/miners.go +++ b/pkg/gen/genesis/miners.go @@ -9,8 +9,6 @@ import ( cborutil "github.com/filecoin-project/go-cbor-util" - smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing" - reward2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward" power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power" @@ -18,19 +16,18 @@ import ( reward4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/reward" - market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + smoothing9 "github.com/filecoin-project/go-state-types/builtin/v9/util/smoothing" - "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/builtin" "github.com/filecoin-project/venus/venus-shared/actors/policy" "github.com/filecoin-project/venus/venus-shared/actors/adt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" - builtintypes "github.com/filecoin-project/go-state-types/builtin" markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" @@ -95,7 +92,7 @@ func mkFakedSigSyscalls(sys vmcontext.SyscallsImpl) vmcontext.SyscallsImpl { // Note: Much of this is brittle, if the methodNum / param / return changes, it will break things func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, miners []Miner, nv network.Version, para *config.ForkUpgradeConfig) (cid.Cid, error) { cst := cbor.NewCborStore(cs.Blockstore()) - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return cid.Undef, fmt.Errorf("get actor version: %w", err) } @@ -138,10 +135,12 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min presealExp abi.ChainEpoch - dealIDs []abi.DealID + dealIDs []abi.DealID + sectorWeight []abi.StoragePower }, len(miners)) maxPeriods := policy.GetMaxSectorExpirationExtension() / minertypes.WPoStProvingPeriod + rawPow, qaPow := big.NewInt(0), big.NewInt(0) for i, m := range miners { // Create miner through power actor i := i @@ -219,7 +218,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min } } - // Publish preseal deals + // Publish preseal deals, and calculate the QAPower { publish := func(params *markettypes.PublishStorageDealsParams) error { @@ -255,7 +254,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, } - if av >= actors.Version8 { + if av >= actorstypes.Version8 { buf, err := cborutil.Dump(&preseal.Deal) if err != nil { return cid.Undef, fmt.Errorf("failed to marshal proposal: %w", err) @@ -282,6 +281,11 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min params = &markettypes.PublishStorageDealsParams{} } + + rawPow = big.Add(rawPow, big.NewInt(int64(m.SectorSize))) + sectorWeight := builtin.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, big.Zero(), markettypes.DealWeight(&preseal.Deal)) + minerInfos[i].sectorWeight = append(minerInfos[i].sectorWeight, sectorWeight) + qaPow = big.Add(qaPow, sectorWeight) } if len(params.Deals) > 0 { @@ -292,24 +296,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min } } - // adjust total network power for equal pledge per sector - rawPow, qaPow := big.NewInt(0), big.NewInt(0) { - for i, m := range miners { - for pi := range m.Sectors { - rawPow = types.BigAdd(rawPow, types.NewInt(uint64(m.SectorSize))) - - dweight, vdweight, err := dealWeight(ctx, genesisVM, minerInfos[i].maddr, []abi.DealID{minerInfos[i].dealIDs[pi]}, 0, minerInfos[i].presealExp, av) - if err != nil { - return cid.Undef, fmt.Errorf("getting deal weight: %w", err) - } - - sectorWeight := builtin.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight, vdweight) - - qaPow = types.BigAdd(qaPow, sectorWeight) - } - } - nh, err := genesisVM.Flush(ctx) if err != nil { return cid.Undef, fmt.Errorf("flushing vm: %w", err) @@ -364,7 +351,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min return cid.Undef, fmt.Errorf("setting power state: %w", err) } - ver, err := actors.VersionForNetwork(nv) + ver, err := actorstypes.VersionForNetwork(nv) if err != nil { return cid.Undef, fmt.Errorf("get actor version: %w", err) } @@ -402,12 +389,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally! } - dweight, vdweight, err := dealWeight(ctx, genesisVM, minerInfos[i].maddr, params.DealIDs, 0, minerInfos[i].presealExp, av) - if err != nil { - return cid.Undef, fmt.Errorf("getting deal weight: %w", err) - } - - sectorWeight := builtin.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight, vdweight) + sectorWeight := minerInfos[i].sectorWeight[pi] // we've added fake power for this sector above, remove it now @@ -479,14 +461,13 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min return cid.Undef, fmt.Errorf("getting current total power: %w", err) } - pcd := miner0.PreCommitDepositForPower((*smoothing0.FilterEstimate)(&rewardSmoothed), tpow.QualityAdjPowerSmoothed, sectorWeight) + pcd := miner9.PreCommitDepositForPower(smoothing9.FilterEstimate(rewardSmoothed), smoothing9.FilterEstimate(*tpow.QualityAdjPowerSmoothed), miner9.QAPowerMax(m.SectorSize)) - pledge := miner0.InitialPledgeForPower( + pledge := miner9.InitialPledgeForPower( sectorWeight, baselinePower, - tpow.PledgeCollateral, - (*smoothing0.FilterEstimate)(&rewardSmoothed), - tpow.QualityAdjPowerSmoothed, + smoothing9.FilterEstimate(rewardSmoothed), + smoothing9.FilterEstimate(*tpow.QualityAdjPowerSmoothed), big.Zero(), ) @@ -501,7 +482,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min // Commit one-by-one, otherwise pledge math tends to explode var paramBytes []byte - if av >= actors.Version6 { + if av >= actorstypes.Version6 { // TODO: fixup confirmParams := &builtin6.ConfirmSectorProofsParams{ Sectors: []abi.SectorNumber{preseal.SectorID}, @@ -521,7 +502,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min return cid.Undef, fmt.Errorf("failed to confirm presealed sectors: %w", err) } - if av > actors.Version2 { + if av > actorstypes.Version2 { // post v2, we need to explicitly Claim this power since ConfirmSectorProofsValid doesn't do it anymore claimParams := &power4.UpdateClaimedPowerParams{ RawByteDelta: types.NewInt(uint64(m.SectorSize)), @@ -660,56 +641,7 @@ func currentTotalPower(ctx context.Context, vmi vm.Interface, maddr address.Addr return &pwr, nil } -func dealWeight(ctx context.Context, vmi vm.Interface, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch, av actors.Version) (abi.DealWeight, abi.DealWeight, error) { - // TODO: This hack should move to market actor wrapper - if av <= actors.Version2 { - params := &market0.VerifyDealsForActivationParams{ - DealIDs: dealIDs, - SectorStart: sectorStart, - SectorExpiry: sectorExpiry, - } - - var dealWeights market0.VerifyDealsForActivationReturn - ret, err := doExecValue(ctx, vmi, - market.Address, - maddr, - abi.NewTokenAmount(0), - builtin0.MethodsMarket.VerifyDealsForActivation, - mustEnc(params), - ) - if err != nil { - return big.Zero(), big.Zero(), err - } - if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil { - return big.Zero(), big.Zero(), err - } - - return dealWeights.DealWeight, dealWeights.VerifiedDealWeight, nil - } - params := &market4.VerifyDealsForActivationParams{Sectors: []market4.SectorDeals{{ - SectorExpiry: sectorExpiry, - DealIDs: dealIDs, - }}} - - var dealWeights market4.VerifyDealsForActivationReturn - ret, err := doExecValue(ctx, vmi, - market.Address, - maddr, - abi.NewTokenAmount(0), - market.Methods.VerifyDealsForActivation, - mustEnc(params), - ) - if err != nil { - return big.Zero(), big.Zero(), err - } - if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil { - return big.Zero(), big.Zero(), err - } - - return dealWeights.Sectors[0].DealWeight, dealWeights.Sectors[0].VerifiedDealWeight, nil -} - -func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address.Address, av actors.Version) (abi.StoragePower, builtin.FilterEstimate, error) { +func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address.Address, av actorstypes.Version) (abi.StoragePower, builtin.FilterEstimate, error) { rwret, err := doExecValue(ctx, vm, reward.Address, maddr, big.Zero(), reward.Methods.ThisEpochReward, nil) if err != nil { return big.Zero(), builtin.FilterEstimate{}, err @@ -717,7 +649,7 @@ func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address // TODO: This hack should move to reward actor wrapper switch av { - case actors.Version0: + case actorstypes.Version0: var epochReward reward0.ThisEpochRewardReturn if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil { @@ -725,7 +657,7 @@ func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address } return epochReward.ThisEpochBaselinePower, builtin.FilterEstimate(*epochReward.ThisEpochRewardSmoothed), nil - case actors.Version2: + case actorstypes.Version2: var epochReward reward2.ThisEpochRewardReturn if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil { diff --git a/pkg/migration/migrate.go b/pkg/migration/migrate.go index af7b098144..7260990e6b 100644 --- a/pkg/migration/migrate.go +++ b/pkg/migration/migrate.go @@ -31,6 +31,7 @@ var versionMap = []versionInfo{ {version: 6, upgrade: Version6Upgrade}, {version: 7, upgrade: Version7Upgrade}, {version: 8, upgrade: Version8Upgrade}, + {version: 9, upgrade: Version9Upgrade}, } // TryToMigrate used to migrate data(db,config,file,etc) in local repo @@ -121,7 +122,7 @@ func Version4Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 4) } -//Version5Upgrade +// Version5Upgrade func Version5Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 4); err != nil { @@ -159,7 +160,7 @@ func Version5Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 5) } -//Version6Upgrade +// Version6Upgrade func Version6Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 5); err != nil { @@ -197,7 +198,7 @@ func Version6Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 6) } -//Version7Upgrade +// Version7Upgrade func Version7Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 6); err != nil { @@ -259,7 +260,7 @@ func Version7Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 7) } -//Version8Upgrade +// Version8Upgrade func Version8Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 7); err != nil { @@ -281,10 +282,10 @@ func Version8Upgrade(repoPath string) (err error) { cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 case types.NetworkInterop: cfg.NetworkParams.GenesisNetworkVersion = network.Version15 - cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 100 + cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 case types.NetworkButterfly: cfg.NetworkParams.GenesisNetworkVersion = network.Version15 - cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 50 + cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 default: return fsrRepo.Close() } @@ -299,3 +300,44 @@ func Version8Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 8) } + +// Version9Upgrade +func Version9Upgrade(repoPath string) (err error) { + var fsrRepo repo.Repo + if fsrRepo, err = repo.OpenFSRepo(repoPath, 8); err != nil { + return + } + cfg := fsrRepo.Config() + switch cfg.NetworkParams.NetworkType { + case types.NetworkMainnet: + cfg.NetworkParams.GenesisNetworkVersion = network.Version0 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.Network2k: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkCalibnet: + cfg.NetworkParams.GenesisNetworkVersion = network.Version0 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkForce: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkInterop: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkButterfly: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + default: + return fsrRepo.Close() + } + + if err = fsrRepo.ReplaceConfig(cfg); err != nil { + return + } + + if err = fsrRepo.Close(); err != nil { + return + } + + return repo.WriteVersion(repoPath, 9) +} diff --git a/pkg/migration/migrate_test.go b/pkg/migration/migrate_test.go index 1dd430c8e0..c9192ad7d5 100644 --- a/pkg/migration/migrate_test.go +++ b/pkg/migration/migrate_test.go @@ -22,6 +22,7 @@ func TestMigration(t *testing.T) { types.NetworkButterfly: &networks.ButterflySnapNet().Network, types.NetworkCalibnet: &networks.Calibration().Network, types.NetworkMainnet: &networks.Mainnet().Network, + types.Integrationnet: &networks.IntegrationNet().Network, } for nt, paramsCfg := range cfgs { diff --git a/pkg/paychmgr/paych.go b/pkg/paychmgr/paych.go index a6af3c067a..c4acd8bc4b 100644 --- a/pkg/paychmgr/paych.go +++ b/pkg/paychmgr/paych.go @@ -11,8 +11,8 @@ import ( "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/venus/pkg/crypto" - "github.com/filecoin-project/venus/venus-shared/actors" lpaych "github.com/filecoin-project/venus/venus-shared/actors/builtin/paych" "github.com/filecoin-project/venus/venus-shared/types" pchTypes "github.com/filecoin-project/venus/venus-shared/types/market" @@ -88,7 +88,7 @@ func (ca *channelAccessor) messageBuilder(ctx context.Context, from address.Addr return nil, err } - ver, err := actors.VersionForNetwork(nwVersion) + ver, err := actorstypes.VersionForNetwork(nwVersion) if err != nil { return nil, err } diff --git a/pkg/repo/fsrepo.go b/pkg/repo/fsrepo.go index 59a030477d..6cc54def94 100644 --- a/pkg/repo/fsrepo.go +++ b/pkg/repo/fsrepo.go @@ -26,7 +26,7 @@ import ( ) // Version is the version of repo schema that this code understands. -const LatestVersion uint = 8 +const LatestVersion uint = 9 const ( // apiFile is the filename containing the filecoin node's api address. @@ -247,9 +247,6 @@ func (r *FSRepo) loadFromDisk() error { return errors.Wrap(err, "failed to open paych datastore") } - /*if err := r.openMarketDataStore(); err != nil { - return errors.Wrap(err, "failed to open market datastore") - }*/ return nil } @@ -474,14 +471,6 @@ func (r *FSRepo) openPaychDataStore() error { return nil } -/*func (r *FSRepo) openMarketDataStore() error { - var err error - r.marketDs, err = badgerds.NewDatastore(filepath.Join(r.path, marketDatastoreProfix), badgerOptions()) - if err != nil { - return err - } - return nil -}*/ func (r *FSRepo) openWalletDatastore() error { // TODO: read wallet datastore info from config, use that to open it up ds, err := badgerds.NewDatastore(filepath.Join(r.path, walletDatastorePrefix), badgerOptions()) diff --git a/pkg/state/tree/state.go b/pkg/state/tree/state.go index 0c914fa046..fae83c61d9 100644 --- a/pkg/state/tree/state.go +++ b/pkg/state/tree/state.go @@ -143,7 +143,7 @@ func VersionForNetwork(ver network.Version) (StateTreeVersion, error) { case{{range .networkVersions}} {{if (ge . 13.)}} network.Version{{.}}{{if (lt . $lastNv)}},{{end}}{{end}}{{end}}: /* inline-gen start */ - case network.Version13, network.Version14, network.Version15, network.Version16: + case network.Version13, network.Version14, network.Version15, network.Version16, network.Version17: /* inline-gen end */ return StateTreeVersion4, nil diff --git a/pkg/state/view.go b/pkg/state/view.go index 38bbb6a4c6..4ebc1b0cfd 100644 --- a/pkg/state/view.go +++ b/pkg/state/view.go @@ -17,7 +17,7 @@ import ( addr "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/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" vmstate "github.com/filecoin-project/venus/pkg/state/tree" "github.com/filecoin-project/venus/pkg/util/ffiwrapper" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -141,7 +141,7 @@ func (v *View) MinerSectorInfo(ctx context.Context, maddr addr.Address, sectorNu return info, nil } -//GetSectorsForWinningPoSt return sector of winning post challenge result +// GetSectorsForWinningPoSt return sector of winning post challenge result func (v *View) GetSectorsForWinningPoSt(ctx context.Context, nv network.Version, pv ffiwrapper.Verifier, maddr addr.Address, rand abi.PoStRandomness) ([]builtin.ExtendedSectorInfo, error) { mas, err := v.LoadMinerState(ctx, maddr) if err != nil { @@ -487,7 +487,7 @@ func (v *View) MinerClaimedPower(ctx context.Context, miner addr.Address) (raw, return p.RawBytePower, p.QualityAdjPower, nil } -//MinerNominalPowerMeetsConsensusMinimum return whether miner meet consensus minmum power +// MinerNominalPowerMeetsConsensusMinimum return whether miner meet consensus minmum power func (v *View) MinerNominalPowerMeetsConsensusMinimum(ctx context.Context, addr addr.Address) (bool, error) { st, err := v.LoadPowerActor(ctx) if err != nil { @@ -669,7 +669,7 @@ func (v *View) StateMinerActiveSectors(ctx context.Context, maddr addr.Address, return mas.LoadSectors(&activeSectors) } -//GetFilLocked return all locked fil amount +// GetFilLocked return all locked fil amount func (v *View) GetFilLocked(ctx context.Context, st vmstate.Tree) (abi.TokenAmount, error) { filMarketLocked, err := getFilMarketLocked(ctx, v.ipldStore, st) if err != nil { @@ -689,7 +689,7 @@ func (v *View) GetFilLocked(ctx context.Context, st vmstate.Tree) (abi.TokenAmou return big.Add(filMarketLocked, filPowerLocked), nil } -//LoadActor load actor from tree +// LoadActor load actor from tree func (v *View) LoadActor(ctx context.Context, address addr.Address) (*types.Actor, error) { return v.loadActor(ctx, address) } @@ -723,12 +723,12 @@ func (v *View) LoadInitState(ctx context.Context) (notinit.State, error) { return notinit.Load(adt.WrapStore(ctx, v.ipldStore), actr) } -//LoadPaychState get pay channel state for actor +// LoadPaychState get pay channel state for actor func (v *View) LoadPaychState(ctx context.Context, actor *types.Actor) (paychActor.State, error) { return paychActor.Load(adt.WrapStore(context.TODO(), v.ipldStore), actor) } -//LoadMinerState return miner state +// LoadMinerState return miner state func (v *View) LoadMinerState(ctx context.Context, maddr addr.Address) (lminer.State, error) { resolvedAddr, err := v.InitResolveAddress(ctx, maddr) if err != nil { @@ -803,7 +803,7 @@ func (v *View) LoadAccountState(ctx context.Context, a addr.Address) (account.St return account.Load(adt.WrapStore(context.TODO(), v.ipldStore), actr) } -//loadActor load actor of address in db +// loadActor load actor of address in db func (v *View) loadActor(ctx context.Context, address addr.Address) (*types.Actor, error) { tree, err := vmstate.LoadState(ctx, v.ipldStore, v.root) if err != nil { diff --git a/pkg/vm/dispatch/loader.go b/pkg/vm/dispatch/loader.go index 2e1d6eda94..48106eeb31 100644 --- a/pkg/vm/dispatch/loader.go +++ b/pkg/vm/dispatch/loader.go @@ -3,6 +3,7 @@ package dispatch import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/exitcode" rtt "github.com/filecoin-project/go-state-types/rt" rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime" @@ -18,7 +19,7 @@ type CodeLoader struct { actors map[cid.Cid]ActorInfo } -//ActorInfo vm contract actor +// ActorInfo vm contract actor type ActorInfo struct { vmActor rtt.VMActor // TODO: consider making this a network version range? @@ -70,7 +71,7 @@ func NewBuilder() *CodeLoaderBuilder { } // Add lets you add an actor dispatch table for a given version. -func (b *CodeLoaderBuilder) Add(av actors.Version, predict ActorPredicate, actor Actor) *CodeLoaderBuilder { +func (b *CodeLoaderBuilder) Add(av actorstypes.Version, predict ActorPredicate, actor Actor) *CodeLoaderBuilder { if predict == nil { predict = func(vmr.Runtime, rtt.VMActor) error { return nil } } @@ -85,7 +86,7 @@ func (b *CodeLoaderBuilder) Add(av actors.Version, predict ActorPredicate, actor // necessary to make stuff work var realCode cid.Cid - if av >= actors.Version8 { + if av >= actorstypes.Version8 { name := actors.CanonicalName(builtin.ActorNameByCode(ac)) var ok bool @@ -99,7 +100,7 @@ func (b *CodeLoaderBuilder) Add(av actors.Version, predict ActorPredicate, actor } // Add lets you add an actor dispatch table for a given version. -func (b *CodeLoaderBuilder) AddMany(av actors.Version, predict ActorPredicate, actors ...rt5.VMActor) *CodeLoaderBuilder { +func (b *CodeLoaderBuilder) AddMany(av actorstypes.Version, predict ActorPredicate, actors ...rt5.VMActor) *CodeLoaderBuilder { for _, actor := range actors { b.Add(av, predict, actor) } @@ -114,10 +115,10 @@ func (b *CodeLoaderBuilder) Build() CodeLoader { // An ActorPredicate returns an error if the given actor is not valid for the given runtime environment (e.g., chain height, version, etc.). type ActorPredicate func(vmr.Runtime, rtt.VMActor) error -//ActorsVersionPredicate get actor predicate base on actor version and network version -func ActorsVersionPredicate(ver actors.Version) ActorPredicate { +// ActorsVersionPredicate get actor predicate base on actor version and network version +func ActorsVersionPredicate(ver actorstypes.Version) ActorPredicate { return func(rt vmr.Runtime, v rtt.VMActor) error { - nver, err := actors.VersionForNetwork(rt.NetworkVersion()) + nver, err := actorstypes.VersionForNetwork(rt.NetworkVersion()) if err != nil { return fmt.Errorf("version for network %w", err) } diff --git a/pkg/vm/register/default.go b/pkg/vm/register/default.go index 1c09dcddb1..0005b7ae5c 100644 --- a/pkg/vm/register/default.go +++ b/pkg/vm/register/default.go @@ -5,11 +5,7 @@ import ( "fmt" "sync" - /* inline-gen template - {{range .actorVersions}} - exported{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/exported"{{end}} - /* inline-gen start */ - + actorstypes "github.com/filecoin-project/go-state-types/actors" 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" @@ -17,12 +13,7 @@ import ( 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 */ - "github.com/filecoin-project/venus/pkg/vm/dispatch" - "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/builtin" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -36,21 +27,15 @@ var defaultActors dispatch.CodeLoader 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 */ - + DefaultActorBuilder.AddMany(actorstypes.Version0, dispatch.ActorsVersionPredicate(actorstypes.Version0), exported0.BuiltinActors()...) + DefaultActorBuilder.AddMany(actorstypes.Version2, dispatch.ActorsVersionPredicate(actorstypes.Version2), exported2.BuiltinActors()...) + DefaultActorBuilder.AddMany(actorstypes.Version3, dispatch.ActorsVersionPredicate(actorstypes.Version3), exported3.BuiltinActors()...) + DefaultActorBuilder.AddMany(actorstypes.Version4, dispatch.ActorsVersionPredicate(actorstypes.Version4), exported4.BuiltinActors()...) + DefaultActorBuilder.AddMany(actorstypes.Version5, dispatch.ActorsVersionPredicate(actorstypes.Version5), exported5.BuiltinActors()...) + DefaultActorBuilder.AddMany(actorstypes.Version6, dispatch.ActorsVersionPredicate(actorstypes.Version6), exported6.BuiltinActors()...) + DefaultActorBuilder.AddMany(actorstypes.Version7, dispatch.ActorsVersionPredicate(actorstypes.Version7), exported7.BuiltinActors()...) + DefaultActorBuilder.AddMany(actorstypes.Version8, dispatch.ActorsVersionPredicate(actorstypes.Version8), builtin.MakeRegistry(actorstypes.Version8)...) + DefaultActorBuilder.AddMany(actorstypes.Version9, dispatch.ActorsVersionPredicate(actorstypes.Version9), builtin.MakeRegistry(actorstypes.Version9)...) defaultActors = DefaultActorBuilder.Build() }) diff --git a/pkg/vm/vmcontext/invocation_context.go b/pkg/vm/vmcontext/invocation_context.go index 1ff19cf528..4e8de356a2 100644 --- a/pkg/vm/vmcontext/invocation_context.go +++ b/pkg/vm/vmcontext/invocation_context.go @@ -16,6 +16,7 @@ import ( "github.com/ipfs/go-cid" ipfscbor "github.com/ipfs/go-ipld-cbor" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/venus/pkg/vm/dispatch" "github.com/filecoin-project/venus/pkg/vm/gas" "github.com/filecoin-project/venus/pkg/vm/runtime" @@ -323,7 +324,7 @@ func (ctx *invocationContext) resolveTarget(target address.Address) (*types.Acto // Don't implicitly create an account actor for an address without an associated key. runtime.Abort(exitcode.SysErrInvalidReceiver) } - ver, err := actors.VersionForNetwork(ctx.vm.NetworkVersion()) + ver, err := actorstypes.VersionForNetwork(ctx.vm.NetworkVersion()) if err != nil { panic(err) } @@ -400,9 +401,7 @@ func (ctx *invocationContext) resolveToKeyAddr(addr address.Address) (address.Ad return aast.PubkeyAddress() } -// // implement runtime.InvocationContext for invocationContext -// var _ runtime.InvocationContext = (*invocationContext)(nil) // Runtime implements runtime.InvocationContext. @@ -468,7 +467,7 @@ func (ctx *invocationContext) Send(toAddr address.Address, methodNum abi.MethodN return code } -/// Balance implements runtime.InvocationContext. +// / Balance implements runtime.InvocationContext. func (ctx *invocationContext) Balance() abi.TokenAmount { toActor, found, err := ctx.vm.State.GetActor(ctx.vm.context, ctx.originMsg.To) if err != nil { @@ -480,9 +479,7 @@ func (ctx *invocationContext) Balance() abi.TokenAmount { return toActor.Balance } -// // implement runtime.InvocationContext for invocationContext -// var _ runtime.ExtendedInvocationContext = (*invocationContext)(nil) // NextActorAddress predicts the address of the next actor created by this address. diff --git a/pkg/vm/vmcontext/syscalls.go b/pkg/vm/vmcontext/syscalls.go index db4c30b774..37882a13c9 100644 --- a/pkg/vm/vmcontext/syscalls.go +++ b/pkg/vm/vmcontext/syscalls.go @@ -13,12 +13,6 @@ import ( proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" "github.com/ipfs/go-cid" - /* inline-gen template - {{range .actorVersions}} - rt{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/runtime"{{end}} - - /* inline-gen start */ - rt0 "github.com/filecoin-project/specs-actors/actors/runtime" rt2 "github.com/filecoin-project/specs-actors/v2/actors/runtime" rt3 "github.com/filecoin-project/specs-actors/v3/actors/runtime" @@ -26,9 +20,6 @@ import ( rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime" rt6 "github.com/filecoin-project/specs-actors/v6/actors/runtime" rt7 "github.com/filecoin-project/specs-actors/v7/actors/runtime" - rt8 "github.com/filecoin-project/specs-actors/v8/actors/runtime" - - /* inline-gen end */ "github.com/filecoin-project/venus/pkg/crypto" vmState "github.com/filecoin-project/venus/pkg/state/tree" @@ -67,11 +58,6 @@ type syscalls struct { stateView SyscallsStateView } -/* inline-gen template -{{range .actorVersions}} -var _ rt{{.}}.Syscalls = (*syscalls)(nil){{end}} -/* inline-gen start */ - var _ rt0.Syscalls = (*syscalls)(nil) var _ rt2.Syscalls = (*syscalls)(nil) var _ rt3.Syscalls = (*syscalls)(nil) @@ -79,9 +65,6 @@ var _ rt4.Syscalls = (*syscalls)(nil) var _ rt5.Syscalls = (*syscalls)(nil) var _ rt6.Syscalls = (*syscalls)(nil) var _ rt7.Syscalls = (*syscalls)(nil) -var _ rt8.Syscalls = (*syscalls)(nil) - -/* inline-gen end */ func (sys syscalls) VerifySignature(signature crypto.Signature, signer address.Address, plaintext []byte) error { charge, err := sys.pricelist.OnVerifySignature(signature.Type, len(plaintext)) diff --git a/tools/conformance/driver.go b/tools/conformance/driver.go index 0d2a9d3a62..28aa97e78c 100644 --- a/tools/conformance/driver.go +++ b/tools/conformance/driver.go @@ -5,8 +5,6 @@ import ( gobig "math/big" "os" - "github.com/filecoin-project/venus/venus-shared/actors" - "github.com/filecoin-project/venus/pkg/consensus" "github.com/filecoin-project/venus/pkg/util/blockstoreutil" "github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl" @@ -28,6 +26,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/network" @@ -232,7 +231,7 @@ func (d *Driver) ExecuteMessage(bs blockstoreutil.Blockstore, params ExecuteMess actorBuilder := register.DefaultActorBuilder // register the chaos actor if required by the vector. if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" { - av, _ := actors.VersionForNetwork(params.NetworkVersion) + av, _ := actorstypes.VersionForNetwork(params.NetworkVersion) chaosActor := chaos.Actor{} actorBuilder.Add(av, nil, chaosActor) } diff --git a/venus-devtool/cborgen/main.go b/venus-devtool/cborgen/main.go index b112308b75..c5ab2b204e 100644 --- a/venus-devtool/cborgen/main.go +++ b/venus-devtool/cborgen/main.go @@ -118,6 +118,7 @@ func main() { dir: "../pkg/fvm", types: []interface{}{ fvm.FvmExecutionTrace{}, + fvm.FvmGasCharge{}, }, }, } diff --git a/venus-devtool/compatible/actors/render.go b/venus-devtool/compatible/actors/render.go index 30b593d683..236ad675c8 100644 --- a/venus-devtool/compatible/actors/render.go +++ b/venus-devtool/compatible/actors/render.go @@ -91,8 +91,9 @@ func renderSeparated(t *template.Template, dir string) error { buf.Reset() err := t.Execute(&buf, map[string]interface{}{ - "v": v, - "import": importPath(v), + "v": v, + "import": importPath(v), + "latestVersion": actors.LatestVersion, }) if err != nil { diff --git a/venus-devtool/go.mod b/venus-devtool/go.mod index 93aee33d1f..f48de34803 100644 --- a/venus-devtool/go.mod +++ b/venus-devtool/go.mod @@ -7,9 +7,9 @@ require ( github.com/filecoin-project/go-bitfield v0.2.4 github.com/filecoin-project/go-data-transfer v1.15.2 github.com/filecoin-project/go-fil-markets v1.24.0 - github.com/filecoin-project/go-jsonrpc v0.1.5 - github.com/filecoin-project/go-state-types v0.1.10 - github.com/filecoin-project/lotus v1.17.0-rc3 + github.com/filecoin-project/go-jsonrpc v0.1.7 + github.com/filecoin-project/go-state-types v0.1.12-beta + github.com/filecoin-project/lotus v1.17.2-0.20220920163159-fd0fec07d8fc 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.2.0 @@ -19,7 +19,7 @@ require ( github.com/libp2p/go-libp2p-pubsub v0.8.0 github.com/multiformats/go-multiaddr v0.6.0 github.com/urfave/cli/v2 v2.8.1 - github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799 + github.com/whyrusleeping/cbor-gen v0.0.0-20220514204315-f29c37e9c44c golang.org/x/tools v0.1.12 ) @@ -58,6 +58,8 @@ require ( github.com/filecoin-project/go-amt-ipld/v3 v3.1.0 // indirect github.com/filecoin-project/go-amt-ipld/v4 v4.0.0 // indirect github.com/filecoin-project/go-cbor-util v0.0.1 // indirect + github.com/filecoin-project/go-commp-utils v0.1.3 // indirect + github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 // indirect github.com/filecoin-project/go-fil-commcid v0.1.0 // indirect github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect @@ -135,7 +137,7 @@ require ( github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect github.com/libp2p/go-libp2p-core v0.20.0 // indirect github.com/libp2p/go-libp2p-kad-dht v0.18.0 // indirect - github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect + github.com/libp2p/go-libp2p-kbucket v0.5.0 // indirect github.com/libp2p/go-libp2p-record v0.2.0 // indirect github.com/libp2p/go-msgio v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.0 // indirect diff --git a/venus-devtool/go.sum b/venus-devtool/go.sum index 2dfe6055ca..0361c1e104 100644 --- a/venus-devtool/go.sum +++ b/venus-devtool/go.sum @@ -372,6 +372,8 @@ github.com/filecoin-project/go-cbor-util v0.0.1 h1:E1LYZYTtjfAQwCReho0VXvbu8t3CY github.com/filecoin-project/go-cbor-util v0.0.1/go.mod h1:pqTiPHobNkOVM5thSRsHYjyQfq7O5QSCMhvuu9JoDlg= github.com/filecoin-project/go-commp-utils v0.1.3 h1:rTxbkNXZU7FLgdkBk8RsQIEOuPONHykEoX3xGk41Fkw= github.com/filecoin-project/go-commp-utils v0.1.3/go.mod h1:3ENlD1pZySaUout0p9ANQrY3fDFoXdqyX04J+dWpK30= +github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 h1:4cITW0pwgvqLs86Q9bWQa34+jBfR1V687bDkmv2DgnA= +github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837/go.mod h1:e2YBjSblNVoBckkbv3PPqsq71q98oFkFqL7s1etViGo= github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= github.com/filecoin-project/go-crypto v0.0.1 h1:AcvpSGGCgjaY8y1az6AMfKQWreF/pWO2JJGLl6gCq6o= github.com/filecoin-project/go-crypto v0.0.1/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= @@ -387,7 +389,6 @@ 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.23.1/go.mod h1:V+1vFO34RZmpdECdikKGiyWhSNJK81Q89Kn0egA9iAk= github.com/filecoin-project/go-fil-markets v1.24.0 h1:SgZ9JU3vp7YubyTitEQK8hwEMm1l2Pko01jejviOKMA= github.com/filecoin-project/go-fil-markets v1.24.0/go.mod h1:ZOPAjEUia7H60F7p0kEupi0FR7Hy4Zfz90BpR1TMBwI= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= @@ -413,8 +414,9 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4 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/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-state-types v0.1.12-beta h1:QZE00g75shqwhPn0/bZL38sFxVAqnXC7zjmYltRdhxI= +github.com/filecoin-project/go-state-types v0.1.12-beta/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI= 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= @@ -425,8 +427,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.8.1 h1:ggoBWvMSWR91HZQCWfv8SZjoTGNyJBwNMLuN9bJZrbU= github.com/filecoin-project/index-provider v0.8.1/go.mod h1:c/Ym5HtWPp9NQgNc9dgSBMpSNsZ/DE9FEi9qVubl5RM= -github.com/filecoin-project/lotus v1.17.0-rc3 h1:bcO573XtvjXvH0O37xbtwgVncgoVMmg4Px5dE+s2WBM= -github.com/filecoin-project/lotus v1.17.0-rc3/go.mod h1:hZ5L7E4uKWwp8E/8Bw3pBaai4wV7Utq/ZSbl9hIoFnU= +github.com/filecoin-project/lotus v1.17.2-0.20220920163159-fd0fec07d8fc h1:GmnYJOdjmuWZv9wIfwntkit/fI84sUt9lTSnDRwRfXo= +github.com/filecoin-project/lotus v1.17.2-0.20220920163159-fd0fec07d8fc/go.mod h1:DMSDCLtqobi1a8tLSSyNksvaHcEUDQkUaPLDZiQYVoI= github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM= 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= @@ -1216,7 +1218,6 @@ github.com/libp2p/go-libp2p v0.18.0/go.mod h1:+veaZ9z1SZQhmc5PW78jvnnxZ89Mgvmh4c github.com/libp2p/go-libp2p v0.19.4/go.mod h1:MIt8y481VDhUe4ErWi1a4bvt/CjjFfOq6kZTothWIXY= github.com/libp2p/go-libp2p v0.20.0/go.mod h1:g0C5Fu+aXXbCXkusCzLycuBowEih3ElmDqtbo61Em7k= github.com/libp2p/go-libp2p v0.20.1/go.mod h1:XgJHsOhEBVBXp/2Sj9bm/yEyD94uunAaP6oaegdcKks= -github.com/libp2p/go-libp2p v0.20.3/go.mod h1:I+vndVanE/p/SjFbnA+BEmmfAUEpWxrdXZeyQ1Dus5c= github.com/libp2p/go-libp2p v0.21.0/go.mod h1:zvcA6/C4mr5/XQarRICh+L1SN9dAHHlSWDq4x5VYxg4= github.com/libp2p/go-libp2p v0.22.0 h1:2Tce0kHOp5zASFKJbNzRElvh0iZwdtG5uZheNW8chIw= github.com/libp2p/go-libp2p v0.22.0/go.mod h1:UDolmweypBSjQb2f7xutPnwZ/fxioLbMBxSjRksxxU4= @@ -1321,8 +1322,9 @@ github.com/libp2p/go-libp2p-kad-dht v0.18.0 h1:akqO3gPMwixR7qFSFq70ezRun97g5hrA/ github.com/libp2p/go-libp2p-kad-dht v0.18.0/go.mod h1:Gb92MYIPm3K2pJLGn8wl0m8wiKDvHrYpg+rOd0GzzPA= github.com/libp2p/go-libp2p-kbucket v0.2.1/go.mod h1:/Rtu8tqbJ4WQ2KTCOMJhggMukOLNLNPY1EtEWWLxUvc= github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio= -github.com/libp2p/go-libp2p-kbucket v0.4.7 h1:spZAcgxifvFZHBD8tErvppbnNiKA5uokDu3CV7axu70= github.com/libp2p/go-libp2p-kbucket v0.4.7/go.mod h1:XyVo99AfQH0foSf176k4jY1xUJ2+jUJIZCSDm7r2YKk= +github.com/libp2p/go-libp2p-kbucket v0.5.0 h1:g/7tVm8ACHDxH29BGrpsQlnNeu+6OF1A9bno/4/U1oA= +github.com/libp2p/go-libp2p-kbucket v0.5.0/go.mod h1:zGzGCpQd78b5BNTDGHNDLaTt9aDK/A02xeZp9QeFC4U= github.com/libp2p/go-libp2p-loggables v0.0.1/go.mod h1:lDipDlBNYbpyqyPX/KcoO+eq0sJYEVR2JgOexcivchg= github.com/libp2p/go-libp2p-loggables v0.1.0/go.mod h1:EyumB2Y6PrYjr55Q3/tiJ/o3xoDasoRYM7nOzEpoa90= github.com/libp2p/go-libp2p-metrics v0.0.1/go.mod h1:jQJ95SXXA/K1VZi13h52WZMa9ja78zjyy5rspMsC/08= @@ -1367,7 +1369,6 @@ github.com/libp2p/go-libp2p-peerstore v0.4.0/go.mod h1:rDJUFyzEWPpXpEwywkcTYYzDH github.com/libp2p/go-libp2p-peerstore v0.6.0/go.mod h1:DGEmKdXrcYpK9Jha3sS7MhqYdInxJy84bIPtSu65bKc= github.com/libp2p/go-libp2p-peerstore v0.7.0/go.mod h1:cdUWTHro83vpg6unCpGUr8qJoX3e93Vy8o97u5ppIM0= github.com/libp2p/go-libp2p-peerstore v0.7.1/go.mod h1:cdUWTHro83vpg6unCpGUr8qJoX3e93Vy8o97u5ppIM0= -github.com/libp2p/go-libp2p-peerstore v0.8.0 h1:bzTG693TA1Ju/zKmUCQzDLSqiJnyRFVwPpuloZ/OZtI= github.com/libp2p/go-libp2p-peerstore v0.8.0/go.mod h1:9geHWmNA3YDlQBjL/uPEJD6vpDK12aDNlUNHJ6kio/s= github.com/libp2p/go-libp2p-pnet v0.2.0/go.mod h1:Qqvq6JH/oMZGwqs3N1Fqhv8NVhrdYcO0BW4wssv21LA= github.com/libp2p/go-libp2p-protocol v0.0.1/go.mod h1:Af9n4PiruirSDjHycM1QuiMi/1VZNHYcK8cLgFJLZ4s= @@ -1375,7 +1376,6 @@ github.com/libp2p/go-libp2p-protocol v0.1.0/go.mod h1:KQPHpAabB57XQxGrXCNvbL6UEX github.com/libp2p/go-libp2p-pubsub v0.1.1/go.mod h1:ZwlKzRSe1eGvSIdU5bD7+8RZN/Uzw0t1Bp9R1znpR/Q= github.com/libp2p/go-libp2p-pubsub v0.6.0/go.mod h1:nJv87QM2cU0w45KPR1rZicq+FmFIOD16zmT+ep1nOmg= github.com/libp2p/go-libp2p-pubsub v0.7.0/go.mod h1:EuyBJFtF8qF67IEA98biwK8Xnw5MNJpJ/Z+8iWCMFwc= -github.com/libp2p/go-libp2p-pubsub v0.7.1/go.mod h1:EuyBJFtF8qF67IEA98biwK8Xnw5MNJpJ/Z+8iWCMFwc= github.com/libp2p/go-libp2p-pubsub v0.8.0 h1:KygfDpaa9AeUPGCVcpVenpXNFauDn+5kBYu3EjcL3Tg= github.com/libp2p/go-libp2p-pubsub v0.8.0/go.mod h1:e4kT+DYjzPUYGZeWk4I+oxCSYTXizzXii5LDRRhjKSw= github.com/libp2p/go-libp2p-pubsub-router v0.5.0/go.mod h1:TRJKskSem3C0aSb3CmRgPwq6IleVFzds6hS09fmZbGM= @@ -1422,7 +1422,6 @@ github.com/libp2p/go-libp2p-swarm v0.8.0/go.mod h1:sOMp6dPuqco0r0GHTzfVheVBh6UEL github.com/libp2p/go-libp2p-swarm v0.9.0/go.mod h1:2f8d8uxTJmpeqHF/1ujjdXZp+98nNIbujVOMEZxCbZ8= github.com/libp2p/go-libp2p-swarm v0.10.0/go.mod h1:71ceMcV6Rg/0rIQ97rsZWMzto1l9LnNquef+efcRbmA= github.com/libp2p/go-libp2p-swarm v0.10.2/go.mod h1:Pdkq0QU5a+qu+oyqIV3bknMsnzk9lnNyKvB9acJ5aZs= -github.com/libp2p/go-libp2p-swarm v0.11.0/go.mod h1:sumjVYrC84gPSZOFKL8hNcnN6HZvJSwJ8ymaXeko4Lk= github.com/libp2p/go-libp2p-testing v0.0.1/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= @@ -2158,8 +2157,9 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20210118024343-169e9d70c0c2/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210303213153-67a261a1d291/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799 h1:DOOT2B85S0tHoLGTzV+FakaSSihgRCVwZkjqKQP5L/w= github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.0.0-20220514204315-f29c37e9c44c h1:6VPKXBDRt7mDUyiHx9X8ROnPYFDf3L7OfEuKCI5dZDI= +github.com/whyrusleeping/cbor-gen v0.0.0-20220514204315-f29c37e9c44c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-ctrlnet v0.0.0-20180313164037-f564fbbdaa95/go.mod h1:SJqKCCPXRfBFCwXjfNT/skfsceF7+MBFLI2OrvuRA7g= @@ -2372,7 +2372,6 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20210615023648-acb5c1269671/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc= golang.org/x/exp v0.0.0-20210714144626-1041f73d31d8/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc= -golang.org/x/exp v0.0.0-20210715201039-d37aa40e8013/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc= golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= diff --git a/venus-devtool/inline-gen/inlinegen-data.json b/venus-devtool/inline-gen/inlinegen-data.json index d2823090eb..a55b82c483 100644 --- a/venus-devtool/inline-gen/inlinegen-data.json +++ b/venus-devtool/inline-gen/inlinegen-data.json @@ -1,7 +1,7 @@ { - "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8], - "latestActorsVersion": 8, + "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9], + "latestActorsVersion": 9, - "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - "latestNetworkVersion": 16 + "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], + "latestNetworkVersion": 17 } \ No newline at end of file diff --git a/venus-shared/actors/actor_cids.go b/venus-shared/actors/actor_cids.go index 878e813e84..1f5d6ed776 100644 --- a/venus-shared/actors/actor_cids.go +++ b/venus-shared/actors/actor_cids.go @@ -1,5 +1,3 @@ -// FETCHED FROM LOTUS: actor_cids.go - package actors import ( @@ -7,6 +5,7 @@ import ( "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" @@ -17,10 +16,10 @@ import ( ) // GetActorCodeID looks up a builtin actor's code CID by actor version and canonical actor name. -func GetActorCodeID(av Version, name string) (cid.Cid, bool) { +func GetActorCodeID(av actorstypes.Version, name string) (cid.Cid, bool) { // Actors V8 and above - if av >= Version8 { + if av >= actorstypes.Version8 { if cids, ok := GetActorCodeIDsFromManifest(av); ok { c, ok := cids[name] return c, ok @@ -33,275 +32,275 @@ func GetActorCodeID(av Version, name string) (cid.Cid, bool) { case AccountKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.AccountActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.AccountActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.AccountActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.AccountActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.AccountActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.AccountActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.AccountActorCodeID, true } case CronKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.CronActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.CronActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.CronActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.CronActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.CronActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.CronActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.CronActorCodeID, true } case InitKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.InitActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.InitActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.InitActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.InitActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.InitActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.InitActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.InitActorCodeID, true } case MarketKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.StorageMarketActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.StorageMarketActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.StorageMarketActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.StorageMarketActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.StorageMarketActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.StorageMarketActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.StorageMarketActorCodeID, true } case MinerKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.StorageMinerActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.StorageMinerActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.StorageMinerActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.StorageMinerActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.StorageMinerActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.StorageMinerActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.StorageMinerActorCodeID, true } case MultisigKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.MultisigActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.MultisigActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.MultisigActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.MultisigActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.MultisigActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.MultisigActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.MultisigActorCodeID, true } case PaychKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.PaymentChannelActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.PaymentChannelActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.PaymentChannelActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.PaymentChannelActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.PaymentChannelActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.PaymentChannelActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.PaymentChannelActorCodeID, true } case PowerKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.StoragePowerActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.StoragePowerActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.StoragePowerActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.StoragePowerActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.StoragePowerActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.StoragePowerActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.StoragePowerActorCodeID, true } case RewardKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.RewardActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.RewardActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.RewardActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.RewardActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.RewardActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.RewardActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.RewardActorCodeID, true } case SystemKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.SystemActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.SystemActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.SystemActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.SystemActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.SystemActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.SystemActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.SystemActorCodeID, true } case VerifregKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.VerifiedRegistryActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.VerifiedRegistryActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.VerifiedRegistryActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.VerifiedRegistryActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.VerifiedRegistryActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.VerifiedRegistryActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.VerifiedRegistryActorCodeID, true } } @@ -310,7 +309,7 @@ func GetActorCodeID(av Version, name string) (cid.Cid, bool) { } // GetActorCodeIDs looks up all builtin actor's code CIDs by actor version. -func GetActorCodeIDs(av Version) (map[string]cid.Cid, error) { +func GetActorCodeIDs(av actorstypes.Version) (map[string]cid.Cid, error) { cids, ok := GetActorCodeIDsFromManifest(av) if ok { return cids, nil diff --git a/venus-shared/actors/builtin-actors-code/v9.tar.zst b/venus-shared/actors/builtin-actors-code/v9.tar.zst new file mode 100644 index 0000000000..db85bc587b Binary files /dev/null and b/venus-shared/actors/builtin-actors-code/v9.tar.zst differ diff --git a/venus-shared/actors/builtin/account/actor.go b/venus-shared/actors/builtin/account/actor.go index ab320219e7..b6ec5b9619 100644 --- a/venus-shared/actors/builtin/account/actor.go +++ b/venus-shared/actors/builtin/account/actor.go @@ -5,6 +5,7 @@ package account import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/go-address" @@ -27,10 +28,10 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) -var Methods = builtin8.MethodsAccount +var Methods = builtin9.MethodsAccount func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { @@ -40,9 +41,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -74,33 +78,36 @@ 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, addr address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, addr) - case actors.Version2: + case actorstypes.Version2: return make2(store, addr) - case actors.Version3: + case actorstypes.Version3: return make3(store, addr) - case actors.Version4: + case actorstypes.Version4: return make4(store, addr) - case actors.Version5: + case actorstypes.Version5: return make5(store, addr) - case actors.Version6: + case actorstypes.Version6: return make6(store, addr) - case actors.Version7: + case actorstypes.Version7: return make7(store, addr) - case actors.Version8: + case actorstypes.Version8: return make8(store, addr) + case actorstypes.Version9: + return make9(store, addr) + } return nil, fmt.Errorf("unknown actor version %d", av) } diff --git a/venus-shared/actors/builtin/account/actor.go.template b/venus-shared/actors/builtin/account/actor.go.template index 865da9d25f..04cbe1e4ce 100644 --- a/venus-shared/actors/builtin/account/actor.go.template +++ b/venus-shared/actors/builtin/account/actor.go.template @@ -3,6 +3,7 @@ package account import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/venus/venus-shared/actors" "fmt" @@ -11,13 +12,13 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors/adt" types "github.com/filecoin-project/venus/venus-shared/internal" + {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var Methods = builtin{{.latestVersion}}.MethodsAccount @@ -31,7 +32,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -50,10 +51,10 @@ 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, addr address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, addr) {{end}} } diff --git a/venus-shared/actors/builtin/account/state.v9.go b/venus-shared/actors/builtin/account/state.v9.go new file mode 100644 index 0000000000..f62aa8640a --- /dev/null +++ b/venus-shared/actors/builtin/account/state.v9.go @@ -0,0 +1,42 @@ +// FETCHED FROM LOTUS: builtin/account/state.go.template + +package account + +import ( + "github.com/filecoin-project/go-address" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + account9 "github.com/filecoin-project/go-state-types/builtin/v9/account" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, addr address.Address) (State, error) { + out := state9{store: store} + out.State = account9.State{Address: addr} + return &out, nil +} + +type state9 struct { + account9.State + store adt.Store +} + +func (s *state9) PubkeyAddress() (address.Address, error) { + return s.Address, nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/venus-shared/actors/builtin/builtin.go b/venus-shared/actors/builtin/builtin.go index 9425f9d746..4efea24de4 100644 --- a/venus-shared/actors/builtin/builtin.go +++ b/venus-shared/actors/builtin/builtin.go @@ -22,16 +22,14 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin" - "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/venus/venus-shared/actors" - miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" ) var SystemActorAddr = builtin.SystemActorAddr @@ -64,7 +62,7 @@ type PoStProof = proof.PoStProof type FilterEstimate = smoothingtypes.FilterEstimate func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower { - return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) + return minertypes.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) } func ActorNameByCode(c cid.Cid) string { @@ -95,9 +93,6 @@ func ActorNameByCode(c cid.Cid) string { case builtin7.IsBuiltinActor(c): return builtin7.ActorNameByCode(c) - case builtin8.IsBuiltinActor(c): - return builtin8.ActorNameByCode(c) - default: return "" } diff --git a/venus-shared/actors/builtin/builtin.go.template b/venus-shared/actors/builtin/builtin.go.template index e3b60e615d..69c3e584df 100644 --- a/venus-shared/actors/builtin/builtin.go.template +++ b/venus-shared/actors/builtin/builtin.go.template @@ -9,7 +9,9 @@ import ( "github.com/ipfs/go-cid" {{range .versions}} + {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{end}} {{end}} "github.com/filecoin-project/go-state-types/abi" @@ -18,7 +20,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/actors" - miner{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" ) @@ -52,7 +54,7 @@ type PoStProof = proof.PoStProof type FilterEstimate = smoothingtypes.FilterEstimate func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower { - return miner{{.latestVersion}}.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) + return minertypes.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) } func ActorNameByCode(c cid.Cid) string { @@ -62,8 +64,10 @@ func ActorNameByCode(c cid.Cid) string { switch { {{range .versions}} + {{if (le . 7)}} case builtin{{.}}.IsBuiltinActor(c): return builtin{{.}}.ActorNameByCode(c) + {{end}} {{end}} default: return "" diff --git a/venus-shared/actors/builtin/cron/actor.go b/venus-shared/actors/builtin/cron/actor.go index 74131e28d2..a12ac348f0 100644 --- a/venus-shared/actors/builtin/cron/actor.go +++ b/venus-shared/actors/builtin/cron/actor.go @@ -5,6 +5,7 @@ package cron import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "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" @@ -23,7 +24,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -34,9 +35,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -68,40 +72,43 @@ 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 actorstypes.Version) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store) + case actorstypes.Version9: + return make9(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } var ( - Address = builtin8.CronActorAddr - Methods = builtin8.MethodsCron + Address = builtin9.CronActorAddr + Methods = builtin9.MethodsCron ) type State interface { diff --git a/venus-shared/actors/builtin/cron/actor.go.template b/venus-shared/actors/builtin/cron/actor.go.template index b14526167a..5a9fcdead6 100644 --- a/venus-shared/actors/builtin/cron/actor.go.template +++ b/venus-shared/actors/builtin/cron/actor.go.template @@ -3,6 +3,7 @@ package cron import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" "fmt" @@ -11,10 +12,9 @@ import ( {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -26,7 +26,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -45,10 +45,10 @@ 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 actorstypes.Version) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store) {{end}} } diff --git a/venus-shared/actors/builtin/cron/state.v9.go b/venus-shared/actors/builtin/cron/state.v9.go new file mode 100644 index 0000000000..cb340945e3 --- /dev/null +++ b/venus-shared/actors/builtin/cron/state.v9.go @@ -0,0 +1,37 @@ +// FETCHED FROM LOTUS: builtin/cron/state.go.template + +package cron + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + cron9 "github.com/filecoin-project/go-state-types/builtin/v9/cron" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + out.State = *cron9.ConstructState(cron9.BuiltInEntries()) + return &out, nil +} + +type state9 struct { + cron9.State + store adt.Store +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/venus-shared/actors/builtin/init/actor.go b/venus-shared/actors/builtin/init/actor.go index d1fb69b57c..7bf73d25e9 100644 --- a/venus-shared/actors/builtin/init/actor.go +++ b/venus-shared/actors/builtin/init/actor.go @@ -5,6 +5,7 @@ package init import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/go-address" @@ -29,12 +30,12 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin8.InitActorAddr - Methods = builtin8.MethodsInit + Address = builtin9.InitActorAddr + Methods = builtin9.MethodsInit ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -45,9 +46,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -79,33 +83,36 @@ 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, networkName string) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, networkName string) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, networkName) - case actors.Version2: + case actorstypes.Version2: return make2(store, networkName) - case actors.Version3: + case actorstypes.Version3: return make3(store, networkName) - case actors.Version4: + case actorstypes.Version4: return make4(store, networkName) - case actors.Version5: + case actorstypes.Version5: return make5(store, networkName) - case actors.Version6: + case actorstypes.Version6: return make6(store, networkName) - case actors.Version7: + case actorstypes.Version7: return make7(store, networkName) - case actors.Version8: + case actorstypes.Version8: return make8(store, networkName) + case actorstypes.Version9: + return make9(store, networkName) + } return nil, fmt.Errorf("unknown actor version %d", av) } diff --git a/venus-shared/actors/builtin/init/actor.go.template b/venus-shared/actors/builtin/init/actor.go.template index fa4961cb87..0bbfe0c24d 100644 --- a/venus-shared/actors/builtin/init/actor.go.template +++ b/venus-shared/actors/builtin/init/actor.go.template @@ -3,6 +3,7 @@ package init import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/venus/venus-shared/actors" "fmt" @@ -17,10 +18,9 @@ import ( {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var ( @@ -37,7 +37,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -56,10 +56,10 @@ 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, networkName string) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, networkName string) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, networkName) {{end}} } diff --git a/venus-shared/actors/builtin/init/state.v9.go b/venus-shared/actors/builtin/init/state.v9.go new file mode 100644 index 0000000000..7de9d41845 --- /dev/null +++ b/venus-shared/actors/builtin/init/state.v9.go @@ -0,0 +1,115 @@ +// FETCHED FROM LOTUS: builtin/init/state.go.template + +package init + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, networkName string) (State, error) { + out := state9{store: store} + + s, err := init9.ConstructState(store, networkName) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + init9.State + store adt.Store +} + +func (s *state9) ResolveAddress(address address.Address) (address.Address, bool, error) { + return s.State.ResolveAddress(s.store, address) +} + +func (s *state9) MapAddressToNewID(address address.Address) (address.Address, error) { + return s.State.MapAddressToNewID(s.store, address) +} + +func (s *state9) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error { + addrs, err := adt9.AsMap(s.store, s.State.AddressMap, builtin9.DefaultHamtBitwidth) + if err != nil { + return err + } + var actorID cbg.CborInt + return addrs.ForEach(&actorID, func(key string) error { + addr, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(abi.ActorID(actorID), addr) + }) +} + +func (s *state9) NetworkName() (string, error) { + return string(s.State.NetworkName), nil +} + +func (s *state9) SetNetworkName(name string) error { + s.State.NetworkName = name + return nil +} + +func (s *state9) SetNextID(id abi.ActorID) error { + s.State.NextID = id + return nil +} + +func (s *state9) Remove(addrs ...address.Address) (err error) { + m, err := adt9.AsMap(s.store, s.State.AddressMap, builtin9.DefaultHamtBitwidth) + if err != nil { + return err + } + for _, addr := range addrs { + if err = m.Delete(abi.AddrKey(addr)); err != nil { + return fmt.Errorf("failed to delete entry for address: %s; err: %w", addr, err) + } + } + amr, err := m.Root() + if err != nil { + return fmt.Errorf("failed to get address map root: %w", err) + } + s.State.AddressMap = amr + return nil +} + +func (s *state9) SetAddressMap(mcid cid.Cid) error { + s.State.AddressMap = mcid + return nil +} + +func (s *state9) AddressMap() (adt.Map, error) { + return adt9.AsMap(s.store, s.State.AddressMap, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/venus-shared/actors/builtin/market/actor.go b/venus-shared/actors/builtin/market/actor.go index cacf1c50c3..2dcf1e1d85 100644 --- a/venus-shared/actors/builtin/market/actor.go +++ b/venus-shared/actors/builtin/market/actor.go @@ -5,6 +5,8 @@ package market import ( "unicode/utf8" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "fmt" "github.com/filecoin-project/go-state-types/network" @@ -15,7 +17,7 @@ import ( "github.com/filecoin-project/go-state-types/cbor" cbg "github.com/whyrusleeping/cbor-gen" - market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -31,7 +33,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -39,8 +41,8 @@ import ( ) var ( - Address = builtin8.StorageMarketActorAddr - Methods = builtin8.MethodsMarket + Address = builtintypes.StorageMarketActorAddr + Methods = builtintypes.MethodsMarket ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -51,9 +53,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -85,33 +90,36 @@ 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 actorstypes.Version) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store) + case actorstypes.Version9: + return make9(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -147,11 +155,11 @@ type DealStates interface { } type DealProposals interface { - ForEach(cb func(id abi.DealID, dp market8.DealProposal) error) error - Get(id abi.DealID) (*market8.DealProposal, bool, error) + ForEach(cb func(id abi.DealID, dp markettypes.DealProposal) error) error + Get(id abi.DealID) (*markettypes.DealProposal, bool, error) array() adt.Array - decode(*cbg.Deferred) (*market8.DealProposal, error) + decode(*cbg.Deferred) (*markettypes.DealProposal, error) } type PublishStorageDealsReturn interface { @@ -161,44 +169,48 @@ type PublishStorageDealsReturn interface { } func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) { - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, err } switch av { - case actors.Version0: + case actorstypes.Version0: return decodePublishStorageDealsReturn0(b) - case actors.Version2: + case actorstypes.Version2: return decodePublishStorageDealsReturn2(b) - case actors.Version3: + case actorstypes.Version3: return decodePublishStorageDealsReturn3(b) - case actors.Version4: + case actorstypes.Version4: return decodePublishStorageDealsReturn4(b) - case actors.Version5: + case actorstypes.Version5: return decodePublishStorageDealsReturn5(b) - case actors.Version6: + case actorstypes.Version6: return decodePublishStorageDealsReturn6(b) - case actors.Version7: + case actorstypes.Version7: return decodePublishStorageDealsReturn7(b) - case actors.Version8: + case actorstypes.Version8: return decodePublishStorageDealsReturn8(b) + case actorstypes.Version9: + return decodePublishStorageDealsReturn9(b) + } return nil, fmt.Errorf("unknown actor version %d", av) } -type DealProposal = market8.DealProposal +type DealProposal = markettypes.DealProposal +type DealLabel = markettypes.DealLabel -type DealState = market8.DealState +type DealState = markettypes.DealState type DealStateChanges struct { Added []DealIDState @@ -225,7 +237,7 @@ type DealProposalChanges struct { type ProposalIDState struct { ID abi.DealID - Proposal market8.DealProposal + Proposal markettypes.DealProposal } func EmptyDealState() *DealState { @@ -237,7 +249,7 @@ func EmptyDealState() *DealState { } // returns the earned fees and pending fees for a given deal -func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { +func GetDealFees(deal markettypes.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch))) ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch))) @@ -252,10 +264,14 @@ func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmo return ef, big.Sub(tf, ef) } -func labelFromGoString(s string) (market8.DealLabel, error) { +func IsDealActive(state markettypes.DealState) bool { + return state.SectorStartEpoch > -1 && state.SlashEpoch == -1 +} + +func labelFromGoString(s string) (markettypes.DealLabel, error) { if utf8.ValidString(s) { - return market8.NewLabelFromString(s) + return markettypes.NewLabelFromString(s) } else { - return market8.NewLabelFromBytes([]byte(s)) + return markettypes.NewLabelFromBytes([]byte(s)) } } diff --git a/venus-shared/actors/builtin/market/actor.go.template b/venus-shared/actors/builtin/market/actor.go.template index a2476b1b7c..aec631c364 100644 --- a/venus-shared/actors/builtin/market/actor.go.template +++ b/venus-shared/actors/builtin/market/actor.go.template @@ -3,7 +3,8 @@ package market import ( - "unicode/utf8" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "unicode/utf8" "github.com/filecoin-project/go-state-types/network" "fmt" @@ -14,23 +15,23 @@ import ( "github.com/filecoin-project/go-state-types/cbor" cbg "github.com/whyrusleeping/cbor-gen" - market{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}market" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtintypes "github.com/filecoin-project/go-state-types/builtin" + "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" ) var ( - Address = builtin{{.latestVersion}}.StorageMarketActorAddr - Methods = builtin{{.latestVersion}}.MethodsMarket + Address = builtintypes.StorageMarketActorAddr + Methods = builtintypes.MethodsMarket ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -42,7 +43,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -61,10 +62,10 @@ 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 actorstypes.Version) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store) {{end}} } @@ -102,11 +103,11 @@ type DealStates interface { } type DealProposals interface { - ForEach(cb func(id abi.DealID, dp market{{.latestVersion}}.DealProposal) error) error - Get(id abi.DealID) (*market{{.latestVersion}}.DealProposal, bool, error) + ForEach(cb func(id abi.DealID, dp markettypes.DealProposal) error) error + Get(id abi.DealID) (*markettypes.DealProposal, bool, error) array() adt.Array - decode(*cbg.Deferred) (*market{{.latestVersion}}.DealProposal, error) + decode(*cbg.Deferred) (*markettypes.DealProposal, error) } @@ -117,23 +118,24 @@ type PublishStorageDealsReturn interface { } func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) { - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, err } switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return decodePublishStorageDealsReturn{{.}}(b) {{end}} } return nil, fmt.Errorf("unknown actor version %d", av) } -type DealProposal = market{{.latestVersion}}.DealProposal +type DealProposal = markettypes.DealProposal +type DealLabel = markettypes.DealLabel -type DealState = market{{.latestVersion}}.DealState +type DealState = markettypes.DealState type DealStateChanges struct { Added []DealIDState @@ -160,7 +162,7 @@ type DealProposalChanges struct { type ProposalIDState struct { ID abi.DealID - Proposal market{{.latestVersion}}.DealProposal + Proposal markettypes.DealProposal } func EmptyDealState() *DealState { @@ -172,7 +174,7 @@ func EmptyDealState() *DealState { } // returns the earned fees and pending fees for a given deal -func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { +func GetDealFees(deal markettypes.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch))) ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch))) @@ -187,10 +189,14 @@ func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpo return ef, big.Sub(tf, ef) } -func labelFromGoString(s string) (market{{.latestVersion}}.DealLabel, error) { +func IsDealActive(state markettypes.DealState) bool { + return state.SectorStartEpoch > -1 && state.SlashEpoch == -1 +} + +func labelFromGoString(s string) (markettypes.DealLabel, error) { if utf8.ValidString(s) { - return market{{.latestVersion}}.NewLabelFromString(s) + return markettypes.NewLabelFromString(s) } else { - return market{{.latestVersion}}.NewLabelFromBytes([]byte(s)) + return markettypes.NewLabelFromBytes([]byte(s)) } } diff --git a/venus-shared/actors/builtin/market/state.sep.go.template b/venus-shared/actors/builtin/market/state.sep.go.template index e23898f4eb..d2492352e8 100644 --- a/venus-shared/actors/builtin/market/state.sep.go.template +++ b/venus-shared/actors/builtin/market/state.sep.go.template @@ -24,7 +24,8 @@ import ( adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" {{else}} market{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}market" - adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" {{end}} ) @@ -260,12 +261,12 @@ func (s *dealProposals{{.v}}) array() adt.Array { func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, error) { {{if (le .v 7)}} label, err := labelFromGoString(v{{.v}}.Label) - if err != nil { - return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) - } {{else}} - label := v{{.v}}.Label + label, err := fromV{{.v}}Label(v{{.v}}.Label) {{end}} + if err != nil { + return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) + } return DealProposal{ PieceCID: v{{.v}}.PieceCID, @@ -285,6 +286,25 @@ func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, e }, nil } +{{if (ge .v 8)}} + func fromV{{.v}}Label(v{{.v}} market{{.v}}.DealLabel) (DealLabel, error) { + if v{{.v}}.IsString() { + str, err := v{{.v}}.ToString() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v{{.v}}.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) + } +{{end}} + + func (s *state{{.v}}) GetState() interface{} { return &s.State diff --git a/venus-shared/actors/builtin/market/state.v0.go b/venus-shared/actors/builtin/market/state.v0.go index 12ea6fea8b..b3ddbbe4d2 100644 --- a/venus-shared/actors/builtin/market/state.v0.go +++ b/venus-shared/actors/builtin/market/state.v0.go @@ -244,6 +244,7 @@ func (s *dealProposals0) array() adt.Array { func fromV0DealProposal(v0 market0.DealProposal) (DealProposal, error) { label, err := labelFromGoString(v0.Label) + if err != nil { return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) } diff --git a/venus-shared/actors/builtin/market/state.v2.go b/venus-shared/actors/builtin/market/state.v2.go index b3d7c48455..06630ba249 100644 --- a/venus-shared/actors/builtin/market/state.v2.go +++ b/venus-shared/actors/builtin/market/state.v2.go @@ -244,6 +244,7 @@ func (s *dealProposals2) array() adt.Array { func fromV2DealProposal(v2 market2.DealProposal) (DealProposal, error) { label, err := labelFromGoString(v2.Label) + if err != nil { return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) } diff --git a/venus-shared/actors/builtin/market/state.v3.go b/venus-shared/actors/builtin/market/state.v3.go index 3bd5eddc86..b46f3069d7 100644 --- a/venus-shared/actors/builtin/market/state.v3.go +++ b/venus-shared/actors/builtin/market/state.v3.go @@ -239,6 +239,7 @@ func (s *dealProposals3) array() adt.Array { func fromV3DealProposal(v3 market3.DealProposal) (DealProposal, error) { label, err := labelFromGoString(v3.Label) + if err != nil { return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) } diff --git a/venus-shared/actors/builtin/market/state.v4.go b/venus-shared/actors/builtin/market/state.v4.go index 0c35d6f27f..88225a6d84 100644 --- a/venus-shared/actors/builtin/market/state.v4.go +++ b/venus-shared/actors/builtin/market/state.v4.go @@ -239,6 +239,7 @@ func (s *dealProposals4) array() adt.Array { func fromV4DealProposal(v4 market4.DealProposal) (DealProposal, error) { label, err := labelFromGoString(v4.Label) + if err != nil { return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) } diff --git a/venus-shared/actors/builtin/market/state.v5.go b/venus-shared/actors/builtin/market/state.v5.go index 29bbb596ed..0c20925266 100644 --- a/venus-shared/actors/builtin/market/state.v5.go +++ b/venus-shared/actors/builtin/market/state.v5.go @@ -239,6 +239,7 @@ func (s *dealProposals5) array() adt.Array { func fromV5DealProposal(v5 market5.DealProposal) (DealProposal, error) { label, err := labelFromGoString(v5.Label) + if err != nil { return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) } diff --git a/venus-shared/actors/builtin/market/state.v6.go b/venus-shared/actors/builtin/market/state.v6.go index 435348ae12..cd85d9e1fd 100644 --- a/venus-shared/actors/builtin/market/state.v6.go +++ b/venus-shared/actors/builtin/market/state.v6.go @@ -242,6 +242,7 @@ func (s *dealProposals6) array() adt.Array { func fromV6DealProposal(v6 market6.DealProposal) (DealProposal, error) { label, err := labelFromGoString(v6.Label) + if err != nil { return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) } diff --git a/venus-shared/actors/builtin/market/state.v7.go b/venus-shared/actors/builtin/market/state.v7.go index da7269a88e..4c3e23860d 100644 --- a/venus-shared/actors/builtin/market/state.v7.go +++ b/venus-shared/actors/builtin/market/state.v7.go @@ -242,6 +242,7 @@ func (s *dealProposals7) array() adt.Array { func fromV7DealProposal(v7 market7.DealProposal) (DealProposal, error) { label, err := labelFromGoString(v7.Label) + if err != nil { return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) } diff --git a/venus-shared/actors/builtin/market/state.v8.go b/venus-shared/actors/builtin/market/state.v8.go index 235ba81c9a..8995bdc36f 100644 --- a/venus-shared/actors/builtin/market/state.v8.go +++ b/venus-shared/actors/builtin/market/state.v8.go @@ -19,6 +19,7 @@ import ( types "github.com/filecoin-project/venus/venus-shared/internal" market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" ) @@ -241,7 +242,11 @@ func (s *dealProposals8) array() adt.Array { func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) { - label := v8.Label + label, err := fromV8Label(v8.Label) + + if err != nil { + return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) + } return DealProposal{ PieceCID: v8.PieceCID, @@ -261,6 +266,22 @@ func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) { }, nil } +func fromV8Label(v8 market8.DealLabel) (DealLabel, error) { + if v8.IsString() { + str, err := v8.ToString() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v8.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} + func (s *state8) GetState() interface{} { return &s.State } diff --git a/venus-shared/actors/builtin/market/state.v9.go b/venus-shared/actors/builtin/market/state.v9.go new file mode 100644 index 0000000000..bc66a7f2e5 --- /dev/null +++ b/venus-shared/actors/builtin/market/state.v9.go @@ -0,0 +1,329 @@ +// FETCHED FROM LOTUS: builtin/market/state.go.template + +package market + +import ( + "bytes" + + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/go-bitfield" + rlepluslazy "github.com/filecoin-project/go-bitfield/rle" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + types "github.com/filecoin-project/venus/venus-shared/internal" + + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + market9 "github.com/filecoin-project/go-state-types/builtin/v9/market" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + + s, err := market9.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + market9.State + store adt.Store +} + +func (s *state9) TotalLocked() (abi.TokenAmount, error) { + fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral) + fml = types.BigAdd(fml, s.TotalClientStorageFee) + return fml, nil +} + +func (s *state9) BalancesChanged(otherState State) (bool, error) { + otherState9, ok := otherState.(*state9) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.EscrowTable.Equals(otherState9.State.EscrowTable) || !s.State.LockedTable.Equals(otherState9.State.LockedTable), nil +} + +func (s *state9) StatesChanged(otherState State) (bool, error) { + otherState9, ok := otherState.(*state9) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.States.Equals(otherState9.State.States), nil +} + +func (s *state9) States() (DealStates, error) { + stateArray, err := adt9.AsArray(s.store, s.State.States, market9.StatesAmtBitwidth) + if err != nil { + return nil, err + } + return &dealStates9{stateArray}, nil +} + +func (s *state9) ProposalsChanged(otherState State) (bool, error) { + otherState9, ok := otherState.(*state9) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.Proposals.Equals(otherState9.State.Proposals), nil +} + +func (s *state9) Proposals() (DealProposals, error) { + proposalArray, err := adt9.AsArray(s.store, s.State.Proposals, market9.ProposalsAmtBitwidth) + if err != nil { + return nil, err + } + return &dealProposals9{proposalArray}, nil +} + +func (s *state9) EscrowTable() (BalanceTable, error) { + bt, err := adt9.AsBalanceTable(s.store, s.State.EscrowTable) + if err != nil { + return nil, err + } + return &balanceTable9{bt}, nil +} + +func (s *state9) LockedTable() (BalanceTable, error) { + bt, err := adt9.AsBalanceTable(s.store, s.State.LockedTable) + if err != nil { + return nil, err + } + return &balanceTable9{bt}, nil +} + +func (s *state9) VerifyDealsForActivation( + minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, +) (weight, verifiedWeight abi.DealWeight, err error) { + w, vw, _, err := market9.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch) + return w, vw, err +} + +func (s *state9) NextID() (abi.DealID, error) { + return s.State.NextID, nil +} + +type balanceTable9 struct { + *adt9.BalanceTable +} + +func (bt *balanceTable9) ForEach(cb func(address.Address, abi.TokenAmount) error) error { + asMap := (*adt9.Map)(bt.BalanceTable) + var ta abi.TokenAmount + return asMap.ForEach(&ta, func(key string) error { + a, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(a, ta) + }) +} + +type dealStates9 struct { + adt.Array +} + +func (s *dealStates9) Get(dealID abi.DealID) (*DealState, bool, error) { + var deal9 market9.DealState + found, err := s.Array.Get(uint64(dealID), &deal9) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + deal := fromV9DealState(deal9) + return &deal, true, nil +} + +func (s *dealStates9) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { + var ds9 market9.DealState + return s.Array.ForEach(&ds9, func(idx int64) error { + return cb(abi.DealID(idx), fromV9DealState(ds9)) + }) +} + +func (s *dealStates9) decode(val *cbg.Deferred) (*DealState, error) { + var ds9 market9.DealState + if err := ds9.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + ds := fromV9DealState(ds9) + return &ds, nil +} + +func (s *dealStates9) array() adt.Array { + return s.Array +} + +func fromV9DealState(v9 market9.DealState) DealState { + return (DealState)(v9) +} + +type dealProposals9 struct { + adt.Array +} + +func (s *dealProposals9) Get(dealID abi.DealID) (*DealProposal, bool, error) { + var proposal9 market9.DealProposal + found, err := s.Array.Get(uint64(dealID), &proposal9) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + + proposal, err := fromV9DealProposal(proposal9) + if err != nil { + return nil, true, fmt.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil +} + +func (s *dealProposals9) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { + var dp9 market9.DealProposal + return s.Array.ForEach(&dp9, func(idx int64) error { + dp, err := fromV9DealProposal(dp9) + if err != nil { + return fmt.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) + }) +} + +func (s *dealProposals9) decode(val *cbg.Deferred) (*DealProposal, error) { + var dp9 market9.DealProposal + if err := dp9.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + + dp, err := fromV9DealProposal(dp9) + if err != nil { + return nil, err + } + + return &dp, nil +} + +func (s *dealProposals9) array() adt.Array { + return s.Array +} + +func fromV9DealProposal(v9 market9.DealProposal) (DealProposal, error) { + + label, err := fromV9Label(v9.Label) + + if err != nil { + return DealProposal{}, fmt.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v9.PieceCID, + PieceSize: v9.PieceSize, + VerifiedDeal: v9.VerifiedDeal, + Client: v9.Client, + Provider: v9.Provider, + + Label: label, + + StartEpoch: v9.StartEpoch, + EndEpoch: v9.EndEpoch, + StoragePricePerEpoch: v9.StoragePricePerEpoch, + + ProviderCollateral: v9.ProviderCollateral, + ClientCollateral: v9.ClientCollateral, + }, nil +} + +func fromV9Label(v9 market9.DealLabel) (DealLabel, error) { + if v9.IsString() { + str, err := v9.ToString() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v9.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, fmt.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +var _ PublishStorageDealsReturn = (*publishStorageDealsReturn9)(nil) + +func decodePublishStorageDealsReturn9(b []byte) (PublishStorageDealsReturn, error) { + var retval market9.PublishStorageDealsReturn + if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil { + return nil, fmt.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err) + } + + return &publishStorageDealsReturn9{retval}, nil +} + +type publishStorageDealsReturn9 struct { + market9.PublishStorageDealsReturn +} + +func (r *publishStorageDealsReturn9) IsDealValid(index uint64) (bool, int, error) { + + set, err := r.ValidDeals.IsSet(index) + if err != nil || !set { + return false, -1, err + } + maskBf, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{ + Runs: []rlepluslazy.Run{rlepluslazy.Run{Val: true, Len: index}}}) + if err != nil { + return false, -1, err + } + before, err := bitfield.IntersectBitField(maskBf, r.ValidDeals) + if err != nil { + return false, -1, err + } + outIdx, err := before.Count() + if err != nil { + return false, -1, err + } + return set, int(outIdx), nil + +} + +func (r *publishStorageDealsReturn9) DealIDs() ([]abi.DealID, error) { + return r.IDs, nil +} diff --git a/venus-shared/actors/builtin/miner/actor.go b/venus-shared/actors/builtin/miner/actor.go index 3df7e041d7..bb7e4d2300 100644 --- a/venus-shared/actors/builtin/miner/actor.go +++ b/venus-shared/actors/builtin/miner/actor.go @@ -5,6 +5,7 @@ package miner import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/venus/venus-shared/actors" @@ -16,7 +17,7 @@ import ( "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/proof" - miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -43,9 +44,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -104,6 +108,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version8: return make8(store) + case actors.Version9: + return make9(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -122,8 +129,8 @@ type State interface { GetSector(abi.SectorNumber) (*SectorOnChainInfo, error) FindSector(abi.SectorNumber) (*SectorLocation, error) GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error) - GetPrecommittedSector(abi.SectorNumber) (*miner8.SectorPreCommitOnChainInfo, error) - ForEachPrecommittedSector(func(miner8.SectorPreCommitOnChainInfo) error) error + GetPrecommittedSector(abi.SectorNumber) (*miner9.SectorPreCommitOnChainInfo, error) + ForEachPrecommittedSector(func(miner9.SectorPreCommitOnChainInfo) error) error LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error) NumLiveSectors() (uint64, error) IsAllocated(abi.SectorNumber) (bool, error) @@ -152,7 +159,7 @@ type State interface { sectors() (adt.Array, error) decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) precommits() (adt.Map, error) - decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner8.SectorPreCommitOnChainInfo, error) + decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner9.SectorPreCommitOnChainInfo, error) GetState() interface{} } @@ -190,7 +197,7 @@ type Partition interface { UnprovenSectors() (bitfield.BitField, error) } -type SectorOnChainInfo = miner8.SectorOnChainInfo +type SectorOnChainInfo = miner9.SectorOnChainInfo func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) { // We added support for the new proofs in network version 7, and removed support for the old @@ -245,8 +252,9 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi } } -type MinerInfo = miner8.MinerInfo -type WorkerKeyChange = miner8.WorkerKeyChange +type MinerInfo = miner9.MinerInfo +type WorkerKeyChange = miner9.WorkerKeyChange +type SectorPreCommitOnChainInfo = miner9.SectorPreCommitOnChainInfo type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo type SectorExpiration struct { @@ -274,8 +282,8 @@ type SectorExtensions struct { } type PreCommitChanges struct { - Added []miner8.SectorPreCommitOnChainInfo - Removed []miner8.SectorPreCommitOnChainInfo + Added []miner9.SectorPreCommitOnChainInfo + Removed []miner9.SectorPreCommitOnChainInfo } type LockedFunds struct { diff --git a/venus-shared/actors/builtin/miner/actor.go.template b/venus-shared/actors/builtin/miner/actor.go.template index d6cc6ec1b2..0d84d17fb3 100644 --- a/venus-shared/actors/builtin/miner/actor.go.template +++ b/venus-shared/actors/builtin/miner/actor.go.template @@ -3,6 +3,7 @@ package miner import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/venus/venus-shared/actors" @@ -35,7 +36,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -203,6 +204,7 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi type MinerInfo = miner{{.latestVersion}}.MinerInfo type WorkerKeyChange = miner{{.latestVersion}}.WorkerKeyChange +type SectorPreCommitOnChainInfo = miner{{.latestVersion}}.SectorPreCommitOnChainInfo type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo type SectorExpiration struct { diff --git a/venus-shared/actors/builtin/miner/state.sep.go.template b/venus-shared/actors/builtin/miner/state.sep.go.template index 604f43979c..f43d4098b6 100644 --- a/venus-shared/actors/builtin/miner/state.sep.go.template +++ b/venus-shared/actors/builtin/miner/state.sep.go.template @@ -17,7 +17,7 @@ import ( "fmt" "github.com/filecoin-project/venus/venus-shared/actors/adt" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/miner" {{if (le .v 7)}} {{if (ge .v 3)}} @@ -583,11 +583,17 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v{{.v}}.Info), + Info: minertypes.SectorPreCommitInfo{ + SealProof: v{{.v}}.Info.SealProof, + SectorNumber: v{{.v}}.Info.SectorNumber, + SealedCID: v{{.v}}.Info.SealedCID, + SealRandEpoch: v{{.v}}.Info.SealRandEpoch, + DealIDs: v{{.v}}.Info.DealIDs, + Expiration: v{{.v}}.Info.Expiration, + UnsealedCid: nil, + }, PreCommitDeposit: v{{.v}}.PreCommitDeposit, PreCommitEpoch: v{{.v}}.PreCommitEpoch, - DealWeight: v{{.v}}.DealWeight, - VerifiedDealWeight: v{{.v}}.VerifiedDealWeight, } } diff --git a/venus-shared/actors/builtin/miner/state.v0.go b/venus-shared/actors/builtin/miner/state.v0.go index 02db7ee143..c2a380bcd9 100644 --- a/venus-shared/actors/builtin/miner/state.v0.go +++ b/venus-shared/actors/builtin/miner/state.v0.go @@ -17,7 +17,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" @@ -515,11 +515,17 @@ func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo { func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v0.Info), - PreCommitDeposit: v0.PreCommitDeposit, - PreCommitEpoch: v0.PreCommitEpoch, - DealWeight: v0.DealWeight, - VerifiedDealWeight: v0.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v0.Info.SealProof, + SectorNumber: v0.Info.SectorNumber, + SealedCID: v0.Info.SealedCID, + SealRandEpoch: v0.Info.SealRandEpoch, + DealIDs: v0.Info.DealIDs, + Expiration: v0.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v0.PreCommitDeposit, + PreCommitEpoch: v0.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v2.go b/venus-shared/actors/builtin/miner/state.v2.go index c5a2e513fc..124817ce99 100644 --- a/venus-shared/actors/builtin/miner/state.v2.go +++ b/venus-shared/actors/builtin/miner/state.v2.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" @@ -545,11 +545,17 @@ func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo { func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v2.Info), - PreCommitDeposit: v2.PreCommitDeposit, - PreCommitEpoch: v2.PreCommitEpoch, - DealWeight: v2.DealWeight, - VerifiedDealWeight: v2.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v2.Info.SealProof, + SectorNumber: v2.Info.SectorNumber, + SealedCID: v2.Info.SealedCID, + SealRandEpoch: v2.Info.SealRandEpoch, + DealIDs: v2.Info.DealIDs, + Expiration: v2.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v2.PreCommitDeposit, + PreCommitEpoch: v2.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v3.go b/venus-shared/actors/builtin/miner/state.v3.go index 21847b7e7b..9728adaede 100644 --- a/venus-shared/actors/builtin/miner/state.v3.go +++ b/venus-shared/actors/builtin/miner/state.v3.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" @@ -546,11 +546,17 @@ func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo { func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v3.Info), - PreCommitDeposit: v3.PreCommitDeposit, - PreCommitEpoch: v3.PreCommitEpoch, - DealWeight: v3.DealWeight, - VerifiedDealWeight: v3.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v3.Info.SealProof, + SectorNumber: v3.Info.SectorNumber, + SealedCID: v3.Info.SealedCID, + SealRandEpoch: v3.Info.SealRandEpoch, + DealIDs: v3.Info.DealIDs, + Expiration: v3.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v3.PreCommitDeposit, + PreCommitEpoch: v3.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v4.go b/venus-shared/actors/builtin/miner/state.v4.go index ce377c783d..d83ebc194b 100644 --- a/venus-shared/actors/builtin/miner/state.v4.go +++ b/venus-shared/actors/builtin/miner/state.v4.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" @@ -546,11 +546,17 @@ func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo { func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v4.Info), - PreCommitDeposit: v4.PreCommitDeposit, - PreCommitEpoch: v4.PreCommitEpoch, - DealWeight: v4.DealWeight, - VerifiedDealWeight: v4.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v4.Info.SealProof, + SectorNumber: v4.Info.SectorNumber, + SealedCID: v4.Info.SealedCID, + SealRandEpoch: v4.Info.SealRandEpoch, + DealIDs: v4.Info.DealIDs, + Expiration: v4.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v4.PreCommitDeposit, + PreCommitEpoch: v4.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v5.go b/venus-shared/actors/builtin/miner/state.v5.go index faddc30df6..0dd3f59df5 100644 --- a/venus-shared/actors/builtin/miner/state.v5.go +++ b/venus-shared/actors/builtin/miner/state.v5.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" @@ -546,11 +546,17 @@ func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo { func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v5.Info), - PreCommitDeposit: v5.PreCommitDeposit, - PreCommitEpoch: v5.PreCommitEpoch, - DealWeight: v5.DealWeight, - VerifiedDealWeight: v5.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v5.Info.SealProof, + SectorNumber: v5.Info.SectorNumber, + SealedCID: v5.Info.SealedCID, + SealRandEpoch: v5.Info.SealRandEpoch, + DealIDs: v5.Info.DealIDs, + Expiration: v5.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v5.PreCommitDeposit, + PreCommitEpoch: v5.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v6.go b/venus-shared/actors/builtin/miner/state.v6.go index 4ac230a8bd..bae344a9bb 100644 --- a/venus-shared/actors/builtin/miner/state.v6.go +++ b/venus-shared/actors/builtin/miner/state.v6.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" @@ -546,11 +546,17 @@ func fromV6SectorOnChainInfo(v6 miner6.SectorOnChainInfo) SectorOnChainInfo { func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v6.Info), - PreCommitDeposit: v6.PreCommitDeposit, - PreCommitEpoch: v6.PreCommitEpoch, - DealWeight: v6.DealWeight, - VerifiedDealWeight: v6.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v6.Info.SealProof, + SectorNumber: v6.Info.SectorNumber, + SealedCID: v6.Info.SealedCID, + SealRandEpoch: v6.Info.SealRandEpoch, + DealIDs: v6.Info.DealIDs, + Expiration: v6.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v6.PreCommitDeposit, + PreCommitEpoch: v6.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v7.go b/venus-shared/actors/builtin/miner/state.v7.go index cc21fe427b..117145f5a3 100644 --- a/venus-shared/actors/builtin/miner/state.v7.go +++ b/venus-shared/actors/builtin/miner/state.v7.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" @@ -547,11 +547,17 @@ func fromV7SectorOnChainInfo(v7 miner7.SectorOnChainInfo) SectorOnChainInfo { func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v7.Info), - PreCommitDeposit: v7.PreCommitDeposit, - PreCommitEpoch: v7.PreCommitEpoch, - DealWeight: v7.DealWeight, - VerifiedDealWeight: v7.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v7.Info.SealProof, + SectorNumber: v7.Info.SectorNumber, + SealedCID: v7.Info.SealedCID, + SealRandEpoch: v7.Info.SealRandEpoch, + DealIDs: v7.Info.DealIDs, + Expiration: v7.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v7.PreCommitDeposit, + PreCommitEpoch: v7.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v8.go b/venus-shared/actors/builtin/miner/state.v8.go index 84c3b2b9e2..8dfebb363d 100644 --- a/venus-shared/actors/builtin/miner/state.v8.go +++ b/venus-shared/actors/builtin/miner/state.v8.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors/adt" builtin8 "github.com/filecoin-project/go-state-types/builtin" @@ -546,11 +546,17 @@ func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo { func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v8.Info), - PreCommitDeposit: v8.PreCommitDeposit, - PreCommitEpoch: v8.PreCommitEpoch, - DealWeight: v8.DealWeight, - VerifiedDealWeight: v8.VerifiedDealWeight, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v8.Info.SealProof, + SectorNumber: v8.Info.SectorNumber, + SealedCID: v8.Info.SealedCID, + SealRandEpoch: v8.Info.SealRandEpoch, + DealIDs: v8.Info.DealIDs, + Expiration: v8.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v8.PreCommitDeposit, + PreCommitEpoch: v8.PreCommitEpoch, } } diff --git a/venus-shared/actors/builtin/miner/state.v9.go b/venus-shared/actors/builtin/miner/state.v9.go new file mode 100644 index 0000000000..251a4e0fcb --- /dev/null +++ b/venus-shared/actors/builtin/miner/state.v9.go @@ -0,0 +1,565 @@ +// FETCHED FROM LOTUS: builtin/miner/state.go.template + +package miner + +import ( + "bytes" + "errors" + + "fmt" + + "github.com/filecoin-project/go-bitfield" + rle "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/dline" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + out.State = miner9.State{} + return &out, nil +} + +type state9 struct { + miner9.State + store adt.Store +} + +type deadline9 struct { + miner9.Deadline + store adt.Store +} + +type partition9 struct { + miner9.Partition + store adt.Store +} + +func (s *state9) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("failed to get available balance: %w", r) + available = abi.NewTokenAmount(0) + } + }() + // this panics if the miner doesnt have enough funds to cover their locked pledge + available, err = s.GetAvailableBalance(bal) + return available, err +} + +func (s *state9) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.CheckVestedFunds(s.store, epoch) +} + +func (s *state9) LockedFunds() (LockedFunds, error) { + return LockedFunds{ + VestingFunds: s.State.LockedFunds, + InitialPledgeRequirement: s.State.InitialPledge, + PreCommitDeposits: s.State.PreCommitDeposits, + }, nil +} + +func (s *state9) FeeDebt() (abi.TokenAmount, error) { + return s.State.FeeDebt, nil +} + +func (s *state9) InitialPledge() (abi.TokenAmount, error) { + return s.State.InitialPledge, nil +} + +func (s *state9) PreCommitDeposits() (abi.TokenAmount, error) { + return s.State.PreCommitDeposits, nil +} + +func (s *state9) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { + info, ok, err := s.State.GetSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV9SectorOnChainInfo(*info) + return &ret, nil +} + +func (s *state9) FindSector(num abi.SectorNumber) (*SectorLocation, error) { + dlIdx, partIdx, err := s.State.FindSector(s.store, num) + if err != nil { + return nil, err + } + return &SectorLocation{ + Deadline: dlIdx, + Partition: partIdx, + }, nil +} + +func (s *state9) NumLiveSectors() (uint64, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return 0, err + } + var total uint64 + if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner9.Deadline) error { + total += dl.LiveSectors + return nil + }); err != nil { + return 0, err + } + return total, nil +} + +// GetSectorExpiration returns the effective expiration of the given sector. +// +// If the sector does not expire early, the Early expiration field is 0. +func (s *state9) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + // NOTE: this can be optimized significantly. + // 1. If the sector is non-faulty, it will expire on-time (can be + // learned from the sector info). + // 2. If it's faulty, it will expire early within the first 42 entries + // of the expiration queue. + + stopErr := errors.New("stop") + out := SectorExpiration{} + err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner9.Deadline) error { + partitions, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + quant := s.State.QuantSpecForDeadline(dlIdx) + var part miner9.Partition + return partitions.ForEach(&part, func(partIdx int64) error { + if found, err := part.Sectors.IsSet(uint64(num)); err != nil { + return err + } else if !found { + return nil + } + if found, err := part.Terminated.IsSet(uint64(num)); err != nil { + return err + } else if found { + // already terminated + return stopErr + } + + q, err := miner9.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner9.PartitionExpirationAmtBitwidth) + if err != nil { + return err + } + var exp miner9.ExpirationSet + return q.ForEach(&exp, func(epoch int64) error { + if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil { + return err + } else if early { + out.Early = abi.ChainEpoch(epoch) + return nil + } + if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil { + return err + } else if onTime { + out.OnTime = abi.ChainEpoch(epoch) + return stopErr + } + return nil + }) + }) + }) + if err == stopErr { + err = nil + } + if err != nil { + return nil, err + } + if out.Early == 0 && out.OnTime == 0 { + return nil, fmt.Errorf("failed to find sector %d", num) + } + return &out, nil +} + +func (s *state9) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { + info, ok, err := s.State.GetPrecommittedSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV9SectorPreCommitOnChainInfo(*info) + + return &ret, nil +} + +func (s *state9) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { + precommitted, err := adt9.AsMap(s.store, s.State.PreCommittedSectors, builtin9.DefaultHamtBitwidth) + if err != nil { + return err + } + + var info miner9.SectorPreCommitOnChainInfo + if err := precommitted.ForEach(&info, func(_ string) error { + return cb(fromV9SectorPreCommitOnChainInfo(info)) + }); err != nil { + return err + } + + return nil +} + +func (s *state9) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) { + sectors, err := miner9.LoadSectors(s.store, s.State.Sectors) + if err != nil { + return nil, err + } + + // If no sector numbers are specified, load all. + if snos == nil { + infos := make([]*SectorOnChainInfo, 0, sectors.Length()) + var info9 miner9.SectorOnChainInfo + if err := sectors.ForEach(&info9, func(_ int64) error { + info := fromV9SectorOnChainInfo(info9) + infos = append(infos, &info) + return nil + }); err != nil { + return nil, err + } + return infos, nil + } + + // Otherwise, load selected. + infos9, err := sectors.Load(*snos) + if err != nil { + return nil, err + } + infos := make([]*SectorOnChainInfo, len(infos9)) + for i, info9 := range infos9 { + info := fromV9SectorOnChainInfo(*info9) + infos[i] = &info + } + return infos, nil +} + +func (s *state9) loadAllocatedSectorNumbers() (bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors) + return allocatedSectors, err +} + +func (s *state9) IsAllocated(num abi.SectorNumber) (bool, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return false, err + } + + return allocatedSectors.IsSet(uint64(num)) +} + +func (s *state9) GetProvingPeriodStart() (abi.ChainEpoch, error) { + return s.State.ProvingPeriodStart, nil +} + +func (s *state9) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return nil, err + } + + allocatedRuns, err := allocatedSectors.RunIterator() + if err != nil { + return nil, err + } + + unallocatedRuns, err := rle.Subtract( + &rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}}, + allocatedRuns, + ) + if err != nil { + return nil, err + } + + iter, err := rle.BitsFromRuns(unallocatedRuns) + if err != nil { + return nil, err + } + + sectors := make([]abi.SectorNumber, 0, count) + for iter.HasNext() && len(sectors) < count { + nextNo, err := iter.Next() + if err != nil { + return nil, err + } + sectors = append(sectors, abi.SectorNumber(nextNo)) + } + + return sectors, nil +} + +func (s *state9) GetAllocatedSectors() (*bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil { + return nil, err + } + + return &allocatedSectors, nil +} + +func (s *state9) LoadDeadline(idx uint64) (Deadline, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + dl, err := dls.LoadDeadline(s.store, idx) + if err != nil { + return nil, err + } + return &deadline9{*dl, s.store}, nil +} + +func (s *state9) ForEachDeadline(cb func(uint64, Deadline) error) error { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + return dls.ForEach(s.store, func(i uint64, dl *miner9.Deadline) error { + return cb(i, &deadline9{*dl, s.store}) + }) +} + +func (s *state9) NumDeadlines() (uint64, error) { + return miner9.WPoStPeriodDeadlines, nil +} + +func (s *state9) DeadlinesChanged(other State) (bool, error) { + other9, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !s.State.Deadlines.Equals(other9.Deadlines), nil +} + +func (s *state9) MinerInfoChanged(other State) (bool, error) { + other0, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Info.Equals(other0.State.Info), nil +} + +func (s *state9) Info() (MinerInfo, error) { + info, err := s.State.GetInfo(s.store) + if err != nil { + return MinerInfo{}, err + } + + mi := MinerInfo{ + Owner: info.Owner, + Worker: info.Worker, + ControlAddresses: info.ControlAddresses, + + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), + + PeerId: info.PeerId, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: info.WindowPoStProofType, + SectorSize: info.SectorSize, + WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, + ConsensusFaultElapsed: info.ConsensusFaultElapsed, + } + + return mi, nil +} + +func (s *state9) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) { + return s.State.RecordedDeadlineInfo(epoch), nil +} + +func (s *state9) DeadlineCronActive() (bool, error) { + return s.State.DeadlineCronActive, nil +} + +func (s *state9) sectors() (adt.Array, error) { + return adt9.AsArray(s.store, s.Sectors, miner9.SectorsAmtBitwidth) +} + +func (s *state9) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { + var si miner9.SectorOnChainInfo + err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV9SectorOnChainInfo(si), nil +} + +func (s *state9) precommits() (adt.Map, error) { + return adt9.AsMap(s.store, s.PreCommittedSectors, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { + var sp miner9.SectorPreCommitOnChainInfo + err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return minertypes.SectorPreCommitOnChainInfo{}, err + } + + return fromV9SectorPreCommitOnChainInfo(sp), nil +} + +func (s *state9) EraseAllUnproven() error { + + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + + err = dls.ForEach(s.store, func(dindx uint64, dl *miner9.Deadline) error { + ps, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + + var part miner9.Partition + err = ps.ForEach(&part, func(pindx int64) error { + _ = part.ActivateUnproven() + err = ps.Set(uint64(pindx), &part) + return nil + }) + + if err != nil { + return err + } + + dl.Partitions, err = ps.Root() + if err != nil { + return err + } + + return dls.UpdateDeadline(s.store, dindx, dl) + }) + if err != nil { + return err + } + + return s.State.SaveDeadlines(s.store, dls) + +} + +func (d *deadline9) LoadPartition(idx uint64) (Partition, error) { + p, err := d.Deadline.LoadPartition(d.store, idx) + if err != nil { + return nil, err + } + return &partition9{*p, d.store}, nil +} + +func (d *deadline9) ForEachPartition(cb func(uint64, Partition) error) error { + ps, err := d.Deadline.PartitionsArray(d.store) + if err != nil { + return err + } + var part miner9.Partition + return ps.ForEach(&part, func(i int64) error { + return cb(uint64(i), &partition9{part, d.store}) + }) +} + +func (d *deadline9) PartitionsChanged(other Deadline) (bool, error) { + other9, ok := other.(*deadline9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !d.Deadline.Partitions.Equals(other9.Deadline.Partitions), nil +} + +func (d *deadline9) PartitionsPoSted() (bitfield.BitField, error) { + return d.Deadline.PartitionsPoSted, nil +} + +func (d *deadline9) DisputableProofCount() (uint64, error) { + + ops, err := d.OptimisticProofsSnapshotArray(d.store) + if err != nil { + return 0, err + } + + return ops.Length(), nil + +} + +func (p *partition9) AllSectors() (bitfield.BitField, error) { + return p.Partition.Sectors, nil +} + +func (p *partition9) FaultySectors() (bitfield.BitField, error) { + return p.Partition.Faults, nil +} + +func (p *partition9) RecoveringSectors() (bitfield.BitField, error) { + return p.Partition.Recoveries, nil +} + +func (p *partition9) UnprovenSectors() (bitfield.BitField, error) { + return p.Partition.Unproven, nil +} + +func fromV9SectorOnChainInfo(v9 miner9.SectorOnChainInfo) SectorOnChainInfo { + info := SectorOnChainInfo{ + SectorNumber: v9.SectorNumber, + SealProof: v9.SealProof, + SealedCID: v9.SealedCID, + DealIDs: v9.DealIDs, + Activation: v9.Activation, + Expiration: v9.Expiration, + DealWeight: v9.DealWeight, + VerifiedDealWeight: v9.VerifiedDealWeight, + InitialPledge: v9.InitialPledge, + ExpectedDayReward: v9.ExpectedDayReward, + ExpectedStoragePledge: v9.ExpectedStoragePledge, + + SectorKeyCID: v9.SectorKeyCID, + } + return info +} + +func fromV9SectorPreCommitOnChainInfo(v9 miner9.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: minertypes.SectorPreCommitInfo{ + SealProof: v9.Info.SealProof, + SectorNumber: v9.Info.SectorNumber, + SealedCID: v9.Info.SealedCID, + SealRandEpoch: v9.Info.SealRandEpoch, + DealIDs: v9.Info.DealIDs, + Expiration: v9.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v9.PreCommitDeposit, + PreCommitEpoch: v9.PreCommitEpoch, + } +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/venus-shared/actors/builtin/multisig/actor.go b/venus-shared/actors/builtin/multisig/actor.go index 5b796af884..fe779be592 100644 --- a/venus-shared/actors/builtin/multisig/actor.go +++ b/venus-shared/actors/builtin/multisig/actor.go @@ -5,6 +5,8 @@ package multisig import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/minio/blake2b-simd" cbg "github.com/whyrusleeping/cbor-gen" @@ -12,7 +14,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/cbor" - msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -28,7 +30,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -43,9 +45,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -77,33 +82,36 @@ 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, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version2: + case actorstypes.Version2: return make2(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version3: + case actorstypes.Version3: return make3(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version4: + case actorstypes.Version4: return make4(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version5: + case actorstypes.Version5: return make5(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version6: + case actorstypes.Version6: return make6(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version7: + case actorstypes.Version7: return make7(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version8: + case actorstypes.Version8: return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + case actorstypes.Version9: + return make9(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -126,36 +134,39 @@ type State interface { GetState() interface{} } -type Transaction = msig8.Transaction +type Transaction = msig9.Transaction -var Methods = builtin8.MethodsMultisig +var Methods = builtintypes.MethodsMultisig -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { - case actors.Version0: + case actorstypes.Version0: return message0{from} - case actors.Version2: + case actorstypes.Version2: return message2{message0{from}} - case actors.Version3: + case actorstypes.Version3: return message3{message0{from}} - case actors.Version4: + case actorstypes.Version4: return message4{message0{from}} - case actors.Version5: + case actorstypes.Version5: return message5{message0{from}} - case actors.Version6: + case actorstypes.Version6: return message6{message0{from}} - case actors.Version7: + case actorstypes.Version7: return message7{message0{from}} - case actors.Version8: + case actorstypes.Version8: return message8{message0{from}} + + case actorstypes.Version9: + return message9{message0{from}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -179,13 +190,13 @@ type MessageBuilder interface { } // this type is the same between v0 and v2 -type ProposalHashData = msig8.ProposalHashData -type ProposeReturn = msig8.ProposeReturn -type ProposeParams = msig8.ProposeParams -type ApproveReturn = msig8.ApproveReturn +type ProposalHashData = msig9.ProposalHashData +type ProposeReturn = msig9.ProposeReturn +type ProposeParams = msig9.ProposeParams +type ApproveReturn = msig9.ApproveReturn func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { - params := msig8.TxnIDParams{ID: msig8.TxnID(id)} + params := msig9.TxnIDParams{ID: msig9.TxnID(id)} if data != nil { if data.Requester.Protocol() != address.ID { return nil, fmt.Errorf("proposer address must be an ID address, was %s", data.Requester) diff --git a/venus-shared/actors/builtin/multisig/actor.go.template b/venus-shared/actors/builtin/multisig/actor.go.template index d48440a53d..a73b4e55c9 100644 --- a/venus-shared/actors/builtin/multisig/actor.go.template +++ b/venus-shared/actors/builtin/multisig/actor.go.template @@ -3,6 +3,7 @@ package multisig import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "fmt" "github.com/minio/blake2b-simd" @@ -16,11 +17,11 @@ import ( {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtintypes "github.com/filecoin-project/go-state-types/builtin" + "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" @@ -35,7 +36,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -54,10 +55,10 @@ 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, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, signers, threshold, startEpoch, unlockDuration, initialBalance) {{end}} } @@ -84,12 +85,12 @@ type State interface { type Transaction = msig{{.latestVersion}}.Transaction -var Methods = builtin{{.latestVersion}}.MethodsMultisig +var Methods = builtintypes.MethodsMultisig -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return message{{.}}{{"{"}}{{if (ge . 2)}}message0{from}{{else}}from{{end}}} {{end}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) diff --git a/venus-shared/actors/builtin/multisig/message.sep.go.template b/venus-shared/actors/builtin/multisig/message.sep.go.template index 55e6901634..c709234b01 100644 --- a/venus-shared/actors/builtin/multisig/message.sep.go.template +++ b/venus-shared/actors/builtin/multisig/message.sep.go.template @@ -13,12 +13,12 @@ import ( init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init" multisig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig" {{else}} - builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" - multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/multisig" - init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init" + actorstypes "github.com/filecoin-project/go-state-types/actors" + multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}multisig" + init{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/init" {{end}} - + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -70,13 +70,13 @@ func (m message{{.v}}) Create( ConstructorParams: enc, } {{else}} - code, ok := actors.GetActorCodeID(actors.Version{{.v}}, actors.MultisigKey) + code, ok := actors.GetActorCodeID(actorstypes.Version{{.v}}, actors.MultisigKey) if !ok { return nil, fmt.Errorf("failed to get multisig code ID") } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init8.ExecParams{ + execParams := &init{{.latestVersion}}.ExecParams{ CodeCID: code, ConstructorParams: enc, } @@ -90,7 +90,7 @@ func (m message{{.v}}) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin{{.v}}.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v0.go b/venus-shared/actors/builtin/multisig/message.v0.go index 520582a236..bff3932c93 100644 --- a/venus-shared/actors/builtin/multisig/message.v0.go +++ b/venus-shared/actors/builtin/multisig/message.v0.go @@ -12,6 +12,7 @@ import ( init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -69,7 +70,7 @@ func (m message0) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin0.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v2.go b/venus-shared/actors/builtin/multisig/message.v2.go index 6398e67229..0bbec6fc15 100644 --- a/venus-shared/actors/builtin/multisig/message.v2.go +++ b/venus-shared/actors/builtin/multisig/message.v2.go @@ -12,6 +12,7 @@ import ( init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -66,7 +67,7 @@ func (m message2) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin2.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v3.go b/venus-shared/actors/builtin/multisig/message.v3.go index 6354087e51..301b7d8cdb 100644 --- a/venus-shared/actors/builtin/multisig/message.v3.go +++ b/venus-shared/actors/builtin/multisig/message.v3.go @@ -12,6 +12,7 @@ import ( init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" multisig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -66,7 +67,7 @@ func (m message3) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin3.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v4.go b/venus-shared/actors/builtin/multisig/message.v4.go index c712e7c040..f63fc4c021 100644 --- a/venus-shared/actors/builtin/multisig/message.v4.go +++ b/venus-shared/actors/builtin/multisig/message.v4.go @@ -12,6 +12,7 @@ import ( init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init" multisig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -66,7 +67,7 @@ func (m message4) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin4.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v5.go b/venus-shared/actors/builtin/multisig/message.v5.go index 77fa796c23..cc5eedb3e0 100644 --- a/venus-shared/actors/builtin/multisig/message.v5.go +++ b/venus-shared/actors/builtin/multisig/message.v5.go @@ -12,6 +12,7 @@ import ( init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init" multisig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -66,7 +67,7 @@ func (m message5) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin5.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v6.go b/venus-shared/actors/builtin/multisig/message.v6.go index f319a7111e..e98c5c0ea7 100644 --- a/venus-shared/actors/builtin/multisig/message.v6.go +++ b/venus-shared/actors/builtin/multisig/message.v6.go @@ -12,6 +12,7 @@ import ( init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init" multisig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -66,7 +67,7 @@ func (m message6) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin6.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v7.go b/venus-shared/actors/builtin/multisig/message.v7.go index 0c4c9b0f46..749b54c0b1 100644 --- a/venus-shared/actors/builtin/multisig/message.v7.go +++ b/venus-shared/actors/builtin/multisig/message.v7.go @@ -12,6 +12,7 @@ import ( init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init" multisig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -66,7 +67,7 @@ func (m message7) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin7.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v8.go b/venus-shared/actors/builtin/multisig/message.v8.go index 3c573f1b0a..659447be9f 100644 --- a/venus-shared/actors/builtin/multisig/message.v8.go +++ b/venus-shared/actors/builtin/multisig/message.v8.go @@ -8,10 +8,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin8 "github.com/filecoin-project/go-state-types/builtin" - init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" + actorstypes "github.com/filecoin-project/go-state-types/actors" multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" types "github.com/filecoin-project/venus/venus-shared/internal" @@ -52,13 +53,13 @@ func (m message8) Create( return nil, actErr } - code, ok := actors.GetActorCodeID(actors.Version8, actors.MultisigKey) + code, ok := actors.GetActorCodeID(actorstypes.Version8, actors.MultisigKey) if !ok { return nil, fmt.Errorf("failed to get multisig code ID") } // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init8.ExecParams{ + execParams := &init9.ExecParams{ CodeCID: code, ConstructorParams: enc, } @@ -71,7 +72,7 @@ func (m message8) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin8.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/venus-shared/actors/builtin/multisig/message.v9.go b/venus-shared/actors/builtin/multisig/message.v9.go new file mode 100644 index 0000000000..35e8873998 --- /dev/null +++ b/venus-shared/actors/builtin/multisig/message.v9.go @@ -0,0 +1,79 @@ +// FETCHED FROM LOTUS: builtin/multisig/message.go.template + +package multisig + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" + + builtintypes "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/venus/venus-shared/actors" + init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" + types "github.com/filecoin-project/venus/venus-shared/internal" +) + +type message9 struct{ message0 } + +func (m message9) Create( + signers []address.Address, threshold uint64, + unlockStart, unlockDuration abi.ChainEpoch, + initialAmount abi.TokenAmount, +) (*types.Message, error) { + + lenAddrs := uint64(len(signers)) + + if lenAddrs < threshold { + return nil, fmt.Errorf("cannot require signing of more addresses than provided for multisig") + } + + if threshold == 0 { + threshold = lenAddrs + } + + if m.from == address.Undef { + return nil, fmt.Errorf("must provide source address") + } + + // Set up constructor parameters for multisig + msigParams := &multisig9.ConstructorParams{ + Signers: signers, + NumApprovalsThreshold: threshold, + UnlockDuration: unlockDuration, + StartEpoch: unlockStart, + } + + enc, actErr := actors.SerializeParams(msigParams) + if actErr != nil { + return nil, actErr + } + + code, ok := actors.GetActorCodeID(actorstypes.Version9, actors.MultisigKey) + if !ok { + return nil, fmt.Errorf("failed to get multisig code ID") + } + + // new actors are created by invoking 'exec' on the init actor with the constructor params + execParams := &init9.ExecParams{ + CodeCID: code, + ConstructorParams: enc, + } + + enc, actErr = actors.SerializeParams(execParams) + if actErr != nil { + return nil, actErr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Method: builtintypes.MethodsInit.Exec, + Params: enc, + Value: initialAmount, + }, nil +} diff --git a/venus-shared/actors/builtin/multisig/state.v9.go b/venus-shared/actors/builtin/multisig/state.v9.go new file mode 100644 index 0000000000..38ddcd4372 --- /dev/null +++ b/venus-shared/actors/builtin/multisig/state.v9.go @@ -0,0 +1,120 @@ +// FETCHED FROM LOTUS: builtin/multisig/state.go.template + +package multisig + +import ( + "bytes" + "encoding/binary" + + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { + out := state9{store: store} + out.State = msig9.State{} + out.State.Signers = signers + out.State.NumApprovalsThreshold = threshold + out.State.StartEpoch = startEpoch + out.State.UnlockDuration = unlockDuration + out.State.InitialBalance = initialBalance + + em, err := adt9.StoreEmptyMap(store, builtin9.DefaultHamtBitwidth) + if err != nil { + return nil, err + } + + out.State.PendingTxns = em + + return &out, nil +} + +type state9 struct { + msig9.State + store adt.Store +} + +func (s *state9) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil +} + +func (s *state9) StartEpoch() (abi.ChainEpoch, error) { + return s.State.StartEpoch, nil +} + +func (s *state9) UnlockDuration() (abi.ChainEpoch, error) { + return s.State.UnlockDuration, nil +} + +func (s *state9) InitialBalance() (abi.TokenAmount, error) { + return s.State.InitialBalance, nil +} + +func (s *state9) Threshold() (uint64, error) { + return s.State.NumApprovalsThreshold, nil +} + +func (s *state9) Signers() ([]address.Address, error) { + return s.State.Signers, nil +} + +func (s *state9) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error { + arr, err := adt9.AsMap(s.store, s.State.PendingTxns, builtin9.DefaultHamtBitwidth) + if err != nil { + return err + } + var out msig9.Transaction + return arr.ForEach(&out, func(key string) error { + txid, n := binary.Varint([]byte(key)) + if n <= 0 { + return fmt.Errorf("invalid pending transaction key: %v", key) + } + return cb(txid, (Transaction)(out)) //nolint:unconvert + }) +} + +func (s *state9) PendingTxnChanged(other State) (bool, error) { + other9, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.PendingTxns.Equals(other9.PendingTxns), nil +} + +func (s *state9) transactions() (adt.Map, error) { + return adt9.AsMap(s.store, s.PendingTxns, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) decodeTransaction(val *cbg.Deferred) (Transaction, error) { + var tx msig9.Transaction + if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Transaction{}, err + } + return Transaction(tx), nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/venus-shared/actors/builtin/paych/actor.go b/venus-shared/actors/builtin/paych/actor.go index 10468718f1..ba2e16ae80 100644 --- a/venus-shared/actors/builtin/paych/actor.go +++ b/venus-shared/actors/builtin/paych/actor.go @@ -6,6 +6,8 @@ import ( "encoding/base64" "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" @@ -43,9 +45,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -122,33 +127,36 @@ func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) { return &sv, nil } -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { - case actors.Version0: + case actorstypes.Version0: return message0{from} - case actors.Version2: + case actorstypes.Version2: return message2{from} - case actors.Version3: + case actorstypes.Version3: return message3{from} - case actors.Version4: + case actorstypes.Version4: return message4{from} - case actors.Version5: + case actorstypes.Version5: return message5{from} - case actors.Version6: + case actorstypes.Version6: return message6{from} - case actors.Version7: + case actorstypes.Version7: return message7{from} - case actors.Version8: + case actorstypes.Version8: return message8{from} + case actorstypes.Version9: + return message9{from} + default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } diff --git a/venus-shared/actors/builtin/paych/actor.go.template b/venus-shared/actors/builtin/paych/actor.go.template index 6c0d6c3cbb..8d9e98b308 100644 --- a/venus-shared/actors/builtin/paych/actor.go.template +++ b/venus-shared/actors/builtin/paych/actor.go.template @@ -3,6 +3,7 @@ package paych import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "encoding/base64" "fmt" @@ -36,7 +37,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -100,10 +101,10 @@ func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) { return &sv, nil } -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return message{{.}}{from} {{end}} default: diff --git a/venus-shared/actors/builtin/paych/message.sep.go.template b/venus-shared/actors/builtin/paych/message.sep.go.template index 7961912f0d..62ac6108ff 100644 --- a/venus-shared/actors/builtin/paych/message.sep.go.template +++ b/venus-shared/actors/builtin/paych/message.sep.go.template @@ -16,9 +16,10 @@ import ( init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init" paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych" {{else}} + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" - paych{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/paych" - init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init" + paych{{.v}} "github.com/filecoin-project/go-state-types/builtin/v{{.v}}/paych" + init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v{{.v}}/init" {{end}} @@ -33,7 +34,7 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) {{if (le .v 7)}} actorCodeID := builtin{{.v}}.PaymentChannelActorCodeID {{else}} - actorCodeID, ok := actors.GetActorCodeID(actors.Version{{.v}}, "paymentchannel") + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version{{.v}}, "paymentchannel") if !ok { return nil, fmt.Errorf("error getting actor paymentchannel code id for actor version %d", {{.v}}) } @@ -64,8 +65,10 @@ func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVouche params, aerr := actors.SerializeParams(&paych{{.v}}.UpdateChannelStateParams{ {{if (le .v 6)}} Sv: toV0SignedVoucher(*sv), - {{else}} + {{else if (le .v 8)}} Sv: *sv, + {{else}} + Sv: toV{{.v}}SignedVoucher(*sv), {{end}} Secret: secret, }) @@ -82,6 +85,32 @@ func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVouche }, nil } +{{if (ge .v 9)}} + func toV{{.v}}SignedVoucher(sv paychtypes.SignedVoucher) paych{{.v}}.SignedVoucher { + merges := make([]paych{{.v}}.Merge, len(sv.Merges)) + for i := range sv.Merges { + merges[i] = paych{{.v}}.Merge{ + Lane: sv.Merges[i].Lane, + Nonce: sv.Merges[i].Nonce, + } + } + + return paych{{.v}}.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretHash: sv.SecretHash, + Extra: (*paych{{.v}}.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: merges, + Signature: sv.Signature, + } + } +{{end}} + func (m message{{.v}}) Settle(paych address.Address) (*types.Message, error) { return &types.Message{ To: paych, diff --git a/venus-shared/actors/builtin/paych/message.v8.go b/venus-shared/actors/builtin/paych/message.v8.go index cb50a79c3d..146c989c24 100644 --- a/venus-shared/actors/builtin/paych/message.v8.go +++ b/venus-shared/actors/builtin/paych/message.v8.go @@ -10,6 +10,7 @@ import ( paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin8 "github.com/filecoin-project/go-state-types/builtin" init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" @@ -23,7 +24,7 @@ type message8 struct{ from address.Address } func (m message8) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { - actorCodeID, ok := actors.GetActorCodeID(actors.Version8, "paymentchannel") + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version8, "paymentchannel") if !ok { return nil, fmt.Errorf("error getting actor paymentchannel code id for actor version %d", 8) } diff --git a/venus-shared/actors/builtin/paych/message.v9.go b/venus-shared/actors/builtin/paych/message.v9.go new file mode 100644 index 0000000000..a588ea34c8 --- /dev/null +++ b/venus-shared/actors/builtin/paych/message.v9.go @@ -0,0 +1,113 @@ +// FETCHED FROM LOTUS: builtin/paych/message.go.template + +package paych + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin9 "github.com/filecoin-project/go-state-types/builtin" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych" + + "github.com/filecoin-project/venus/venus-shared/actors" + init_ "github.com/filecoin-project/venus/venus-shared/actors/builtin/init" + types "github.com/filecoin-project/venus/venus-shared/internal" +) + +type message9 struct{ from address.Address } + +func (m message9) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version9, "paymentchannel") + if !ok { + return nil, fmt.Errorf("error getting actor paymentchannel code id for actor version %d", 9) + } + + params, aerr := actors.SerializeParams(&paych9.ConstructorParams{From: m.from, To: to}) + if aerr != nil { + return nil, aerr + } + enc, aerr := actors.SerializeParams(&init9.ExecParams{ + CodeCID: actorCodeID, + ConstructorParams: params, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Value: initialAmount, + Method: builtin9.MethodsInit.Exec, + Params: enc, + }, nil +} + +func (m message9) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { + params, aerr := actors.SerializeParams(&paych9.UpdateChannelStateParams{ + + Sv: toV9SignedVoucher(*sv), + + Secret: secret, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin9.MethodsPaych.UpdateChannelState, + Params: params, + }, nil +} + +func toV9SignedVoucher(sv paychtypes.SignedVoucher) paych9.SignedVoucher { + merges := make([]paych9.Merge, len(sv.Merges)) + for i := range sv.Merges { + merges[i] = paych9.Merge{ + Lane: sv.Merges[i].Lane, + Nonce: sv.Merges[i].Nonce, + } + } + + return paych9.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretHash: sv.SecretHash, + Extra: (*paych9.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: merges, + Signature: sv.Signature, + } +} + +func (m message9) Settle(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin9.MethodsPaych.Settle, + }, nil +} + +func (m message9) Collect(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin9.MethodsPaych.Collect, + }, nil +} diff --git a/venus-shared/actors/builtin/paych/state.v9.go b/venus-shared/actors/builtin/paych/state.v9.go new file mode 100644 index 0000000000..b34c7c5022 --- /dev/null +++ b/venus-shared/actors/builtin/paych/state.v9.go @@ -0,0 +1,116 @@ +// FETCHED FROM LOTUS: builtin/paych/state.go.template + +package paych + +import ( + "github.com/ipfs/go-cid" + + "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/venus/venus-shared/actors/adt" + + paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + out.State = paych9.State{} + return &out, nil +} + +type state9 struct { + paych9.State + store adt.Store + lsAmt *adt9.Array +} + +// Channel owner, who has funded the actor +func (s *state9) From() (address.Address, error) { + return s.State.From, nil +} + +// Recipient of payouts from channel +func (s *state9) To() (address.Address, error) { + return s.State.To, nil +} + +// Height at which the channel can be `Collected` +func (s *state9) SettlingAt() (abi.ChainEpoch, error) { + return s.State.SettlingAt, nil +} + +// Amount successfully redeemed through the payment channel, paid out on `Collect()` +func (s *state9) ToSend() (abi.TokenAmount, error) { + return s.State.ToSend, nil +} + +func (s *state9) getOrLoadLsAmt() (*adt9.Array, error) { + if s.lsAmt != nil { + return s.lsAmt, nil + } + + // Get the lane state from the chain + lsamt, err := adt9.AsArray(s.store, s.State.LaneStates, paych9.LaneStatesAmtBitwidth) + if err != nil { + return nil, err + } + + s.lsAmt = lsamt + return lsamt, nil +} + +// Get total number of lanes +func (s *state9) LaneCount() (uint64, error) { + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return 0, err + } + return lsamt.Length(), nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +// Iterate lane states +func (s *state9) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { + // Get the lane state from the chain + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return err + } + + // Note: we use a map instead of an array to store laneStates because the + // client sets the lane ID (the index) and potentially they could use a + // very large index. + var ls paych9.LaneState + return lsamt.ForEach(&ls, func(i int64) error { + return cb(uint64(i), &laneState9{ls}) + }) +} + +type laneState9 struct { + paych9.LaneState +} + +func (ls *laneState9) Redeemed() (big.Int, error) { + return ls.LaneState.Redeemed, nil +} + +func (ls *laneState9) Nonce() (uint64, error) { + return ls.LaneState.Nonce, nil +} diff --git a/venus-shared/actors/builtin/power/actor.go b/venus-shared/actors/builtin/power/actor.go index 58610c4eeb..6608884d59 100644 --- a/venus-shared/actors/builtin/power/actor.go +++ b/venus-shared/actors/builtin/power/actor.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/venus/venus-shared/actors" cbg "github.com/whyrusleeping/cbor-gen" @@ -31,12 +32,12 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin8.StoragePowerActorAddr - Methods = builtin8.MethodsPower + Address = builtin9.StoragePowerActorAddr + Methods = builtin9.MethodsPower ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -47,9 +48,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -81,33 +85,36 @@ 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 actorstypes.Version) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store) + case actorstypes.Version9: + return make9(store) + } return nil, fmt.Errorf("unknown actor version %d", av) } diff --git a/venus-shared/actors/builtin/power/actor.go.template b/venus-shared/actors/builtin/power/actor.go.template index adc719a859..6cbbe997ab 100644 --- a/venus-shared/actors/builtin/power/actor.go.template +++ b/venus-shared/actors/builtin/power/actor.go.template @@ -3,6 +3,7 @@ package power import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/venus/venus-shared/actors" @@ -19,10 +20,9 @@ import ( {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var ( @@ -39,7 +39,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -58,10 +58,10 @@ 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 actorstypes.Version) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store) {{end}} } diff --git a/venus-shared/actors/builtin/power/state.sep.go.template b/venus-shared/actors/builtin/power/state.sep.go.template index 62280e8f53..de95355ff1 100644 --- a/venus-shared/actors/builtin/power/state.sep.go.template +++ b/venus-shared/actors/builtin/power/state.sep.go.template @@ -22,7 +22,7 @@ import ( {{else}} builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" power{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}power" - adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" {{end}} ) diff --git a/venus-shared/actors/builtin/power/state.v9.go b/venus-shared/actors/builtin/power/state.v9.go new file mode 100644 index 0000000000..0701baf0cb --- /dev/null +++ b/venus-shared/actors/builtin/power/state.v9.go @@ -0,0 +1,188 @@ +// FETCHED FROM LOTUS: builtin/power/state.go.template + +package power + +import ( + "bytes" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + "github.com/filecoin-project/venus/venus-shared/actors/builtin" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + power9 "github.com/filecoin-project/go-state-types/builtin/v9/power" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + + s, err := power9.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + power9.State + store adt.Store +} + +func (s *state9) TotalLocked() (abi.TokenAmount, error) { + return s.TotalPledgeCollateral, nil +} + +func (s *state9) TotalPower() (Claim, error) { + return Claim{ + RawBytePower: s.TotalRawBytePower, + QualityAdjPower: s.TotalQualityAdjPower, + }, nil +} + +// Committed power to the network. Includes miners below the minimum threshold. +func (s *state9) TotalCommitted() (Claim, error) { + return Claim{ + RawBytePower: s.TotalBytesCommitted, + QualityAdjPower: s.TotalQABytesCommitted, + }, nil +} + +func (s *state9) MinerPower(addr address.Address) (Claim, bool, error) { + claims, err := s.claims() + if err != nil { + return Claim{}, false, err + } + var claim power9.Claim + ok, err := claims.Get(abi.AddrKey(addr), &claim) + if err != nil { + return Claim{}, false, err + } + return Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }, ok, nil +} + +func (s *state9) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) { + return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a) +} + +func (s *state9) TotalPowerSmoothed() (builtin.FilterEstimate, error) { + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil +} + +func (s *state9) MinerCounts() (uint64, uint64, error) { + return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil +} + +func (s *state9) ListAllMiners() ([]address.Address, error) { + claims, err := s.claims() + if err != nil { + return nil, err + } + + var miners []address.Address + err = claims.ForEach(nil, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + miners = append(miners, a) + return nil + }) + if err != nil { + return nil, err + } + + return miners, nil +} + +func (s *state9) ForEachClaim(cb func(miner address.Address, claim Claim) error) error { + claims, err := s.claims() + if err != nil { + return err + } + + var claim power9.Claim + return claims.ForEach(&claim, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + return cb(a, Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }) + }) +} + +func (s *state9) ClaimsChanged(other State) (bool, error) { + other9, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Claims.Equals(other9.State.Claims), nil +} + +func (s *state9) SetTotalQualityAdjPower(p abi.StoragePower) error { + s.State.TotalQualityAdjPower = p + return nil +} + +func (s *state9) SetTotalRawBytePower(p abi.StoragePower) error { + s.State.TotalRawBytePower = p + return nil +} + +func (s *state9) SetThisEpochQualityAdjPower(p abi.StoragePower) error { + s.State.ThisEpochQualityAdjPower = p + return nil +} + +func (s *state9) SetThisEpochRawBytePower(p abi.StoragePower) error { + s.State.ThisEpochRawBytePower = p + return nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +func (s *state9) claims() (adt.Map, error) { + return adt9.AsMap(s.store, s.Claims, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) decodeClaim(val *cbg.Deferred) (Claim, error) { + var ci power9.Claim + if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Claim{}, err + } + return fromV9Claim(ci), nil +} + +func fromV9Claim(v9 power9.Claim) Claim { + return Claim{ + RawBytePower: v9.RawBytePower, + QualityAdjPower: v9.QualityAdjPower, + } +} diff --git a/venus-shared/actors/builtin/registry.go b/venus-shared/actors/builtin/registry.go new file mode 100644 index 0000000000..8d2126a325 --- /dev/null +++ b/venus-shared/actors/builtin/registry.go @@ -0,0 +1,220 @@ +// FETCHED FROM LOTUS: builtin/registry.go.template + +package builtin + +import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" + + account8 "github.com/filecoin-project/go-state-types/builtin/v8/account" + cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron" + _init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" + power8 "github.com/filecoin-project/go-state-types/builtin/v8/power" + reward8 "github.com/filecoin-project/go-state-types/builtin/v8/reward" + system8 "github.com/filecoin-project/go-state-types/builtin/v8/system" + verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" + + account9 "github.com/filecoin-project/go-state-types/builtin/v9/account" + cron9 "github.com/filecoin-project/go-state-types/builtin/v9/cron" + _init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + market9 "github.com/filecoin-project/go-state-types/builtin/v9/market" + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" + paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych" + power9 "github.com/filecoin-project/go-state-types/builtin/v9/power" + reward9 "github.com/filecoin-project/go-state-types/builtin/v9/reward" + system9 "github.com/filecoin-project/go-state-types/builtin/v9/system" + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + + "github.com/filecoin-project/go-state-types/cbor" + rtt "github.com/filecoin-project/go-state-types/rt" + "github.com/filecoin-project/venus/venus-shared/actors" +) + +var _ rtt.VMActor = (*RegistryEntry)(nil) + +type RegistryEntry struct { + state cbor.Er + code cid.Cid + methods []interface{} +} + +func (r RegistryEntry) State() cbor.Er { + return r.state +} + +func (r RegistryEntry) Exports() []interface{} { + return r.methods +} + +func (r RegistryEntry) Code() cid.Cid { + return r.code +} + +func MakeRegistry(av actorstypes.Version) []rtt.VMActor { + if av < actorstypes.Version8 { + panic("expected version v8 and up only, use specs-actors for v0-7") + } + registry := make([]rtt.VMActor, 0) + + codeIDs, err := actors.GetActorCodeIDs(av) + if err != nil { + panic(err) + } + + switch av { + + case actorstypes.Version8: + for key, codeID := range codeIDs { + switch key { + case actors.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account8.Methods, + state: new(account8.State), + }) + case actors.CronKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: cron8.Methods, + state: new(cron8.State), + }) + case actors.InitKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: _init8.Methods, + state: new(_init8.State), + }) + case actors.MarketKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: market8.Methods, + state: new(market8.State), + }) + case actors.MinerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: miner8.Methods, + state: new(miner8.State), + }) + case actors.MultisigKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: multisig8.Methods, + state: new(multisig8.State), + }) + case actors.PaychKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: paych8.Methods, + state: new(paych8.State), + }) + case actors.PowerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: power8.Methods, + state: new(power8.State), + }) + case actors.RewardKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: reward8.Methods, + state: new(reward8.State), + }) + case actors.SystemKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: system8.Methods, + state: new(system8.State), + }) + case actors.VerifregKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: verifreg8.Methods, + state: new(verifreg8.State), + }) + } + } + + case actorstypes.Version9: + for key, codeID := range codeIDs { + switch key { + case actors.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account9.Methods, + state: new(account9.State), + }) + case actors.CronKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: cron9.Methods, + state: new(cron9.State), + }) + case actors.InitKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: _init9.Methods, + state: new(_init9.State), + }) + case actors.MarketKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: market9.Methods, + state: new(market9.State), + }) + case actors.MinerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: miner9.Methods, + state: new(miner9.State), + }) + case actors.MultisigKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: multisig9.Methods, + state: new(multisig9.State), + }) + case actors.PaychKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: paych9.Methods, + state: new(paych9.State), + }) + case actors.PowerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: power9.Methods, + state: new(power9.State), + }) + case actors.RewardKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: reward9.Methods, + state: new(reward9.State), + }) + case actors.SystemKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: system9.Methods, + state: new(system9.State), + }) + case actors.VerifregKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: verifreg9.Methods, + state: new(verifreg9.State), + }) + } + } + + default: + panic("expected version v8 and up only, use specs-actors for v0-7") + } + + return registry +} diff --git a/venus-shared/actors/builtin/registry.go.template b/venus-shared/actors/builtin/registry.go.template new file mode 100644 index 0000000000..b909d3c4d1 --- /dev/null +++ b/venus-shared/actors/builtin/registry.go.template @@ -0,0 +1,141 @@ +// FETCHED FROM LOTUS: builtin/registry.go.template + +package builtin + +import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" + {{range .versions}} + {{if (ge . 8)}} + account{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/account" + cron{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/cron" + _init{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/init" + multisig{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/multisig" + miner{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/miner" + market{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/market" + reward{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/reward" + paych{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/paych" + power{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/power" + system{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/system" + verifreg{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/verifreg" + {{end}} + {{end}} + "github.com/filecoin-project/go-state-types/cbor" + rtt "github.com/filecoin-project/go-state-types/rt" + "github.com/filecoin-project/venus/venus-shared/actors" +) + +var _ rtt.VMActor = (*RegistryEntry)(nil) + +type RegistryEntry struct { + state cbor.Er + code cid.Cid + methods []interface{} +} + +func (r RegistryEntry) State() cbor.Er { + return r.state +} + +func (r RegistryEntry) Exports() []interface{} { + return r.methods +} + +func (r RegistryEntry) Code() cid.Cid { + return r.code +} + +func MakeRegistry(av actorstypes.Version) []rtt.VMActor { + if av < actorstypes.Version8 { + panic("expected version v8 and up only, use specs-actors for v0-7") + } + registry := make([]rtt.VMActor, 0) + + codeIDs, err := actors.GetActorCodeIDs(av) + if err != nil { + panic(err) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actorstypes.Version{{.}}: + for key, codeID := range codeIDs { + switch key { + case actors.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account{{.}}.Methods, + state: new(account{{.}}.State), + }) + case actors.CronKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: cron{{.}}.Methods, + state: new(cron{{.}}.State), + }) + case actors.InitKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: _init{{.}}.Methods, + state: new(_init{{.}}.State), + }) + case actors.MarketKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: market{{.}}.Methods, + state: new(market{{.}}.State), + }) + case actors.MinerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: miner{{.}}.Methods, + state: new(miner{{.}}.State), + }) + case actors.MultisigKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: multisig{{.}}.Methods, + state: new(multisig{{.}}.State), + }) + case actors.PaychKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: paych{{.}}.Methods, + state: new(paych{{.}}.State), + }) + case actors.PowerKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: power{{.}}.Methods, + state: new(power{{.}}.State), + }) + case actors.RewardKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: reward{{.}}.Methods, + state: new(reward{{.}}.State), + }) + case actors.SystemKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: system{{.}}.Methods, + state: new(system{{.}}.State), + }) + case actors.VerifregKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: verifreg{{.}}.Methods, + state: new(verifreg{{.}}.State), + }) + } + } + {{end}} + {{end}} + + default: + panic("expected version v8 and up only, use specs-actors for v0-7") + } + + return registry +} diff --git a/venus-shared/actors/builtin/reward/actor.go b/venus-shared/actors/builtin/reward/actor.go index 0a471291e8..358c5dbe1a 100644 --- a/venus-shared/actors/builtin/reward/actor.go +++ b/venus-shared/actors/builtin/reward/actor.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" "github.com/filecoin-project/venus/venus-shared/actors" @@ -25,7 +26,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtin9 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/builtin" @@ -33,8 +34,8 @@ import ( ) var ( - Address = builtin8.RewardActorAddr - Methods = builtin8.MethodsReward + Address = builtin9.RewardActorAddr + Methods = builtin9.MethodsReward ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -45,9 +46,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -79,33 +83,36 @@ 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, currRealizedPower abi.StoragePower) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.StoragePower) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, currRealizedPower) - case actors.Version2: + case actorstypes.Version2: return make2(store, currRealizedPower) - case actors.Version3: + case actorstypes.Version3: return make3(store, currRealizedPower) - case actors.Version4: + case actorstypes.Version4: return make4(store, currRealizedPower) - case actors.Version5: + case actorstypes.Version5: return make5(store, currRealizedPower) - case actors.Version6: + case actorstypes.Version6: return make6(store, currRealizedPower) - case actors.Version7: + case actorstypes.Version7: return make7(store, currRealizedPower) - case actors.Version8: + case actorstypes.Version8: return make8(store, currRealizedPower) + case actorstypes.Version9: + return make9(store, currRealizedPower) + } return nil, fmt.Errorf("unknown actor version %d", av) } diff --git a/venus-shared/actors/builtin/reward/actor.go.template b/venus-shared/actors/builtin/reward/actor.go.template index 170a699b8a..62c639d51d 100644 --- a/venus-shared/actors/builtin/reward/actor.go.template +++ b/venus-shared/actors/builtin/reward/actor.go.template @@ -3,6 +3,7 @@ package reward import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/abi" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" "github.com/filecoin-project/venus/venus-shared/actors" @@ -12,10 +13,9 @@ import ( {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors/builtin" @@ -36,7 +36,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -55,10 +55,10 @@ 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, currRealizedPower abi.StoragePower) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.StoragePower) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, currRealizedPower) {{end}} } diff --git a/venus-shared/actors/builtin/reward/state.v9.go b/venus-shared/actors/builtin/reward/state.v9.go new file mode 100644 index 0000000000..31358125cb --- /dev/null +++ b/venus-shared/actors/builtin/reward/state.v9.go @@ -0,0 +1,100 @@ +// FETCHED FROM LOTUS: builtin/reward/state.go.template + +package reward + +import ( + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + "github.com/filecoin-project/venus/venus-shared/actors/builtin" + + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + reward9 "github.com/filecoin-project/go-state-types/builtin/v9/reward" + smoothing9 "github.com/filecoin-project/go-state-types/builtin/v9/util/smoothing" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { + out := state9{store: store} + out.State = *reward9.ConstructState(currRealizedPower) + return &out, nil +} + +type state9 struct { + reward9.State + store adt.Store +} + +func (s *state9) ThisEpochReward() (abi.TokenAmount, error) { + return s.State.ThisEpochReward, nil +} + +func (s *state9) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { + + return builtin.FilterEstimate{ + PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, + VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, + }, nil + +} + +func (s *state9) ThisEpochBaselinePower() (abi.StoragePower, error) { + return s.State.ThisEpochBaselinePower, nil +} + +func (s *state9) TotalStoragePowerReward() (abi.TokenAmount, error) { + return s.State.TotalStoragePowerReward, nil +} + +func (s *state9) EffectiveBaselinePower() (abi.StoragePower, error) { + return s.State.EffectiveBaselinePower, nil +} + +func (s *state9) EffectiveNetworkTime() (abi.ChainEpoch, error) { + return s.State.EffectiveNetworkTime, nil +} + +func (s *state9) CumsumBaseline() (reward9.Spacetime, error) { + return s.State.CumsumBaseline, nil +} + +func (s *state9) CumsumRealized() (reward9.Spacetime, error) { + return s.State.CumsumRealized, nil +} + +func (s *state9) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) { + return miner9.InitialPledgeForPower( + qaPower, + s.State.ThisEpochBaselinePower, + s.State.ThisEpochRewardSmoothed, + smoothing9.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + circSupply, + ), nil +} + +func (s *state9) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) { + return miner9.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed, + smoothing9.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + sectorWeight), nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/venus-shared/actors/builtin/system/actor.go b/venus-shared/actors/builtin/system/actor.go index f741a577cd..9c2b8c7ccb 100644 --- a/venus-shared/actors/builtin/system/actor.go +++ b/venus-shared/actors/builtin/system/actor.go @@ -3,6 +3,7 @@ package system import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "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" @@ -24,11 +25,11 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin8.SystemActorAddr + Address = builtin9.SystemActorAddr ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -39,9 +40,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -73,33 +77,36 @@ 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, builtinActors cid.Cid) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store, builtinActors) + case actorstypes.Version9: + return make9(store, builtinActors) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -107,4 +114,5 @@ func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State type State interface { GetState() interface{} GetBuiltinActors() cid.Cid + SetBuiltinActors(cid.Cid) error } diff --git a/venus-shared/actors/builtin/system/actor.go.template b/venus-shared/actors/builtin/system/actor.go.template index 85a8b28632..d9c0675058 100644 --- a/venus-shared/actors/builtin/system/actor.go.template +++ b/venus-shared/actors/builtin/system/actor.go.template @@ -3,6 +3,7 @@ package system import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "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" @@ -13,10 +14,9 @@ import ( {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var ( @@ -32,7 +32,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -51,10 +51,10 @@ 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, builtinActors cid.Cid) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store{{if (ge . 8)}}, builtinActors{{end}}) {{end}} } @@ -64,4 +64,5 @@ func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State type State interface { GetState() interface{} GetBuiltinActors() cid.Cid + SetBuiltinActors(cid.Cid) error } diff --git a/venus-shared/actors/builtin/system/state.sep.go.template b/venus-shared/actors/builtin/system/state.sep.go.template index d8c00bcc97..72e82666c0 100644 --- a/venus-shared/actors/builtin/system/state.sep.go.template +++ b/venus-shared/actors/builtin/system/state.sep.go.template @@ -9,6 +9,7 @@ import ( {{if (le .v 7)}} system{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/system" + "fmt" {{else}} system{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}system" {{end}} @@ -49,3 +50,12 @@ func (s *state{{.v}}) GetBuiltinActors() cid.Cid { return s.State.BuiltinActors {{end}} } + +func (s *state{{.v}}) SetBuiltinActors(c cid.Cid) error { +{{if (le .v 7)}} + return xerrors.New("cannot set manifest cid before v8") +{{else}} + s.State.BuiltinActors = c + return nil +{{end}} +} diff --git a/venus-shared/actors/builtin/system/state.v0.go b/venus-shared/actors/builtin/system/state.v0.go index 4ed3ec11e3..ff6dc110bc 100644 --- a/venus-shared/actors/builtin/system/state.v0.go +++ b/venus-shared/actors/builtin/system/state.v0.go @@ -4,6 +4,7 @@ package system import ( "github.com/ipfs/go-cid" + "golang.org/x/xerrors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -41,3 +42,9 @@ func (s *state0) GetBuiltinActors() cid.Cid { return cid.Undef } + +func (s *state0) SetBuiltinActors(c cid.Cid) error { + + return xerrors.New("cannot set manifest cid before v8") + +} diff --git a/venus-shared/actors/builtin/system/state.v2.go b/venus-shared/actors/builtin/system/state.v2.go index fae8a959df..376195b254 100644 --- a/venus-shared/actors/builtin/system/state.v2.go +++ b/venus-shared/actors/builtin/system/state.v2.go @@ -4,6 +4,7 @@ package system import ( "github.com/ipfs/go-cid" + "golang.org/x/xerrors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -41,3 +42,9 @@ func (s *state2) GetBuiltinActors() cid.Cid { return cid.Undef } + +func (s *state2) SetBuiltinActors(c cid.Cid) error { + + return xerrors.New("cannot set manifest cid before v8") + +} diff --git a/venus-shared/actors/builtin/system/state.v3.go b/venus-shared/actors/builtin/system/state.v3.go index 159f329d0d..eeb00d03cb 100644 --- a/venus-shared/actors/builtin/system/state.v3.go +++ b/venus-shared/actors/builtin/system/state.v3.go @@ -4,6 +4,7 @@ package system import ( "github.com/ipfs/go-cid" + "golang.org/x/xerrors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -41,3 +42,9 @@ func (s *state3) GetBuiltinActors() cid.Cid { return cid.Undef } + +func (s *state3) SetBuiltinActors(c cid.Cid) error { + + return xerrors.New("cannot set manifest cid before v8") + +} diff --git a/venus-shared/actors/builtin/system/state.v4.go b/venus-shared/actors/builtin/system/state.v4.go index f4d97ce9d5..7498d996a1 100644 --- a/venus-shared/actors/builtin/system/state.v4.go +++ b/venus-shared/actors/builtin/system/state.v4.go @@ -4,6 +4,7 @@ package system import ( "github.com/ipfs/go-cid" + "golang.org/x/xerrors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -41,3 +42,9 @@ func (s *state4) GetBuiltinActors() cid.Cid { return cid.Undef } + +func (s *state4) SetBuiltinActors(c cid.Cid) error { + + return xerrors.New("cannot set manifest cid before v8") + +} diff --git a/venus-shared/actors/builtin/system/state.v5.go b/venus-shared/actors/builtin/system/state.v5.go index 4045c1e67e..fcf197bf1a 100644 --- a/venus-shared/actors/builtin/system/state.v5.go +++ b/venus-shared/actors/builtin/system/state.v5.go @@ -4,6 +4,7 @@ package system import ( "github.com/ipfs/go-cid" + "golang.org/x/xerrors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -41,3 +42,9 @@ func (s *state5) GetBuiltinActors() cid.Cid { return cid.Undef } + +func (s *state5) SetBuiltinActors(c cid.Cid) error { + + return xerrors.New("cannot set manifest cid before v8") + +} diff --git a/venus-shared/actors/builtin/system/state.v6.go b/venus-shared/actors/builtin/system/state.v6.go index 21488b278e..dc1e1ca1fc 100644 --- a/venus-shared/actors/builtin/system/state.v6.go +++ b/venus-shared/actors/builtin/system/state.v6.go @@ -4,6 +4,7 @@ package system import ( "github.com/ipfs/go-cid" + "golang.org/x/xerrors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -41,3 +42,9 @@ func (s *state6) GetBuiltinActors() cid.Cid { return cid.Undef } + +func (s *state6) SetBuiltinActors(c cid.Cid) error { + + return xerrors.New("cannot set manifest cid before v8") + +} diff --git a/venus-shared/actors/builtin/system/state.v7.go b/venus-shared/actors/builtin/system/state.v7.go index 84142089c9..c56156d1a7 100644 --- a/venus-shared/actors/builtin/system/state.v7.go +++ b/venus-shared/actors/builtin/system/state.v7.go @@ -4,6 +4,7 @@ package system import ( "github.com/ipfs/go-cid" + "golang.org/x/xerrors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -41,3 +42,9 @@ func (s *state7) GetBuiltinActors() cid.Cid { return cid.Undef } + +func (s *state7) SetBuiltinActors(c cid.Cid) error { + + return xerrors.New("cannot set manifest cid before v8") + +} diff --git a/venus-shared/actors/builtin/system/state.v8.go b/venus-shared/actors/builtin/system/state.v8.go index 08f6abd6e9..c1e49f2d8e 100644 --- a/venus-shared/actors/builtin/system/state.v8.go +++ b/venus-shared/actors/builtin/system/state.v8.go @@ -43,3 +43,10 @@ func (s *state8) GetBuiltinActors() cid.Cid { return s.State.BuiltinActors } + +func (s *state8) SetBuiltinActors(c cid.Cid) error { + + s.State.BuiltinActors = c + return nil + +} diff --git a/venus-shared/actors/builtin/system/state.v9.go b/venus-shared/actors/builtin/system/state.v9.go new file mode 100644 index 0000000000..cd38110f1f --- /dev/null +++ b/venus-shared/actors/builtin/system/state.v9.go @@ -0,0 +1,52 @@ +// FETCHED FROM LOTUS: builtin/system/state.go.template + +package system + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + system9 "github.com/filecoin-project/go-state-types/builtin/v9/system" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, builtinActors cid.Cid) (State, error) { + out := state9{store: store} + out.State = system9.State{ + BuiltinActors: builtinActors, + } + return &out, nil +} + +type state9 struct { + system9.State + store adt.Store +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +func (s *state9) GetBuiltinActors() cid.Cid { + + return s.State.BuiltinActors + +} + +func (s *state9) SetBuiltinActors(c cid.Cid) error { + + s.State.BuiltinActors = c + return nil + +} diff --git a/venus-shared/actors/builtin/verifreg/actor.go b/venus-shared/actors/builtin/verifreg/actor.go index f1bcf16089..8da58d8693 100644 --- a/venus-shared/actors/builtin/verifreg/actor.go +++ b/venus-shared/actors/builtin/verifreg/actor.go @@ -5,6 +5,8 @@ package verifreg import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" @@ -24,7 +26,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin8 "github.com/filecoin-project/go-state-types/builtin" + builtin9 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/actors/adt" @@ -32,8 +34,8 @@ import ( ) var ( - Address = builtin8.VerifiedRegistryActorAddr - Methods = builtin8.MethodsVerifiedRegistry + Address = builtin9.VerifiedRegistryActorAddr + Methods = builtin9.MethodsVerifiedRegistry ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -44,9 +46,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -78,33 +83,36 @@ 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, rootKeyAddress address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.Address) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, rootKeyAddress) - case actors.Version2: + case actorstypes.Version2: return make2(store, rootKeyAddress) - case actors.Version3: + case actorstypes.Version3: return make3(store, rootKeyAddress) - case actors.Version4: + case actorstypes.Version4: return make4(store, rootKeyAddress) - case actors.Version5: + case actorstypes.Version5: return make5(store, rootKeyAddress) - case actors.Version6: + case actorstypes.Version6: return make6(store, rootKeyAddress) - case actors.Version7: + case actorstypes.Version7: return make7(store, rootKeyAddress) - case actors.Version8: + case actorstypes.Version8: return make8(store, rootKeyAddress) + case actorstypes.Version9: + return make9(store, rootKeyAddress) + } return nil, fmt.Errorf("unknown actor version %d", av) } diff --git a/venus-shared/actors/builtin/verifreg/actor.go.template b/venus-shared/actors/builtin/verifreg/actor.go.template index e7a751d2f9..fee636c120 100644 --- a/venus-shared/actors/builtin/verifreg/actor.go.template +++ b/venus-shared/actors/builtin/verifreg/actor.go.template @@ -3,6 +3,7 @@ package verifreg import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "fmt" "github.com/filecoin-project/go-address" @@ -12,10 +13,9 @@ import ( {{range .versions}} {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - {{else}} - builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" {{end}} {{end}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/venus/venus-shared/actors/adt" "github.com/filecoin-project/venus/venus-shared/actors" @@ -36,7 +36,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -55,10 +55,10 @@ 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, rootKeyAddress address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.Address) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, rootKeyAddress) {{end}} } diff --git a/venus-shared/actors/builtin/verifreg/state.v9.go b/venus-shared/actors/builtin/verifreg/state.v9.go new file mode 100644 index 0000000000..2abe362a03 --- /dev/null +++ b/venus-shared/actors/builtin/verifreg/state.v9.go @@ -0,0 +1,85 @@ +// FETCHED FROM LOTUS: builtin/verifreg/state.go.template + +package verifreg + +import ( + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/venus/venus-shared/actors" + "github.com/filecoin-project/venus/venus-shared/actors/adt" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, rootKeyAddress address.Address) (State, error) { + out := state9{store: store} + + s, err := verifreg9.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + verifreg9.State + store adt.Store +} + +func (s *state9) RootKey() (address.Address, error) { + return s.State.RootKey, nil +} + +func (s *state9) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version9, s.verifiedClients, addr) +} + +func (s *state9) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version9, s.verifiers, addr) +} + +func (s *state9) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) { + return getRemoveDataCapProposalID(s.store, actors.Version9, s.removeDataCapProposalIDs, verifier, client) +} + +func (s *state9) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version9, s.verifiers, cb) +} + +func (s *state9) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version9, s.verifiedClients, cb) +} + +func (s *state9) verifiedClients() (adt.Map, error) { + return adt9.AsMap(s.store, s.VerifiedClients, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) verifiers() (adt.Map, error) { + return adt9.AsMap(s.store, s.Verifiers, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) removeDataCapProposalIDs() (adt.Map, error) { + return adt9.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/venus-shared/actors/builtin_actors.go b/venus-shared/actors/builtin_actors.go index 948ae842de..490cf1f44a 100644 --- a/venus-shared/actors/builtin_actors.go +++ b/venus-shared/actors/builtin_actors.go @@ -13,6 +13,7 @@ import ( "strings" "github.com/DataDog/zstd" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" "github.com/ipld/go-car" @@ -25,13 +26,13 @@ import ( var embeddedBuiltinActorReleases embed.FS // NOTE: DO NOT change this unless you REALLY know what you're doing. This is consensus critical. -var BundleOverrides map[Version]string +var BundleOverrides map[actorstypes.Version]string var NetworkBundle = "mainnet" func init() { if BundleOverrides == nil { - BundleOverrides = make(map[Version]string) + BundleOverrides = make(map[actorstypes.Version]string) } for _, av := range Versions { @@ -39,7 +40,7 @@ func init() { if path == "" { continue } - BundleOverrides[Version(av)] = path + BundleOverrides[actorstypes.Version(av)] = path } if err := loadManifests(NetworkBundle); err != nil { panic(err) @@ -88,7 +89,7 @@ func UseNetworkBundle(netw string) error { } func loadManifests(netw string) error { - overridden := make(map[Version]struct{}) + overridden := make(map[actorstypes.Version]struct{}) var newMetadata []*BuiltinActorsMetadata // First, prefer overrides. for av, path := range BundleOverrides { @@ -127,7 +128,7 @@ func loadManifests(netw string) error { type BuiltinActorsMetadata struct { // nolint Network string - Version Version + Version actorstypes.Version ManifestCid cid.Cid Actors map[string]cid.Cid } @@ -215,7 +216,7 @@ func readEmbeddedBuiltinActorsMetadata(bundle string) ([]*BuiltinActorsMetadata, } bundles = append(bundles, &BuiltinActorsMetadata{ Network: name, - Version: Version(version), + Version: actorstypes.Version(version), ManifestCid: root, Actors: actorCids, }) @@ -262,7 +263,7 @@ func readBundleManifest(r io.Reader) (cid.Cid, map[string]cid.Cid, error) { } // GetEmbeddedBuiltinActorsBundle returns the builtin-actors bundle for the given actors version. -func GetEmbeddedBuiltinActorsBundle(version Version) ([]byte, bool) { +func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version) ([]byte, bool) { fi, err := embeddedBuiltinActorReleases.Open(fmt.Sprintf("builtin-actors-code/v%d.tar.zst", version)) if err != nil { return nil, false diff --git a/venus-shared/actors/builtin_actors_bundle.go b/venus-shared/actors/builtin_actors_bundle.go index e4311f4914..3ccee1d1ed 100644 --- a/venus-shared/actors/builtin_actors_bundle.go +++ b/venus-shared/actors/builtin_actors_bundle.go @@ -7,6 +7,7 @@ import ( "io" "os" + actorstypes "github.com/filecoin-project/go-state-types/actors" blockstore "github.com/filecoin-project/venus/pkg/util/blockstoreutil" cid "github.com/ipfs/go-cid" "github.com/ipld/go-car" @@ -36,10 +37,10 @@ func LoadBundle(ctx context.Context, bs blockstore.Blockstore, r io.Reader) (cid // LoadBundles loads the bundles for the specified actor versions into the passed blockstore, if and // only if the bundle's manifest is not already present in the blockstore. -func LoadBundles(ctx context.Context, bs blockstore.Blockstore, versions ...Version) error { +func LoadBundles(ctx context.Context, bs blockstore.Blockstore, versions ...actorstypes.Version) error { for _, av := range versions { // No bundles before version 8. - if av < Version8 { + if av < actorstypes.Version8 { continue } diff --git a/venus-shared/actors/builtin_actors_gen.go b/venus-shared/actors/builtin_actors_gen.go index f07c37616c..7406ef9684 100644 --- a/venus-shared/actors/builtin_actors_gen.go +++ b/venus-shared/actors/builtin_actors_gen.go @@ -22,6 +22,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacec6xctjxybp7r3kkhase56o6jsaiua7ure5ttu2xfuojt4jhlsoa6"), "verifiedregistry": mustParseCid("bafk2bzacec2hcqlqcfacylfcrhhliwkisvh4y3adwt47xkf2gdvodwu6ccepc"), }, +}, { + Network: "butterflynet", + Version: 9, + ManifestCid: mustParseCid("bafy2bzacebor5miojgkvov7gtiirg7hqxgm54x3hxytbho3qloqryg2r67qaq"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacecd7kgfzbyu4sylskgf7wjqabo43y3d7xqgvz7r67pzr3ovn3sj7y"), + "cron": mustParseCid("bafk2bzacea6dc2a6skmp7saa43dcofp7zvtklvya75bai2k4k6qnkpcfzklug"), + "init": mustParseCid("bafk2bzacean5v7lbsspxmdkcwhac44sk332uwyfteibtxyhgoeabwbzbh736c"), + "multisig": mustParseCid("bafk2bzacea43lypvbof5kwnk2flzrwdrqqvzypom5xyheeuaab6dmuiafngae"), + "paymentchannel": mustParseCid("bafk2bzacecsdimcgztl4tfodnqc35jojoy4mzaqqidubialqmqaa3zpv4h3rw"), + "reward": mustParseCid("bafk2bzacedy3utj67mewe7rpieaex3sf7qxfkgiwtlgg4wlqyl74la65njbn2"), + "storagemarket": mustParseCid("bafk2bzacec4xpazf3l2p5qkknjsku2sd3skqevk7gxryumbelwhfbs7mgjnpa"), + "storageminer": mustParseCid("bafk2bzaceb5scwcdcou56vyhxq3c7vcefjau44v2h6nvsus45wqopt3hadzae"), + "storagepower": mustParseCid("bafk2bzacebxl4ssugntkckifkq6sydczcas463bmonwi2m5hddurzzcukdzyg"), + "system": mustParseCid("bafk2bzacedtw2ebtl3uccbqfcm6jd7teinlpktcglopuaxa6ev334jhs46hso"), + "verifiedregistry": mustParseCid("bafk2bzaceds62ys6rpbtjjsemohalxnkr3jtqhflifabn3xlhpi45mvi757po"), + }, }, { Network: "calibrationnet", Version: 8, @@ -39,6 +56,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzaceaqrkllksxv2jsfgjvmuewx5vbzrammw5mdscod6gkdr3ijih2q64"), "verifiedregistry": mustParseCid("bafk2bzaceaihibfu625lbtzdp3tcftscshrmbgghgrc7kzqhxn4455pycpdkm"), }, +}, { + Network: "calibrationnet", + Version: 9, + ManifestCid: mustParseCid("bafy2bzacectdlm3f5m252s6ken3ncnndvwj4a7hqyev2m7iba4lubkt72r2rm"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzaceag3pkyy5youg2i4qyrhqms2jobycddkhd4eebtlkeqj4wu4sw7ji"), + "cron": mustParseCid("bafk2bzaceaii7ryi4sjqqrrwyqaxulzqgiigkjqfa3f3ghhisleaqrinyal4o"), + "init": mustParseCid("bafk2bzacebpi37hcleu7cpqgs5zdg4zsw7qpydt5w25jny2dyyscsyidquvcw"), + "multisig": mustParseCid("bafk2bzacebt522zme5n3q25mecukjvomfyyzduxormgnprl73mdb5ekda2ywy"), + "paymentchannel": mustParseCid("bafk2bzacebdxmtmloxfyhxkoj4p4ze5gojqohvqjmdmv2t54xyrgfnjs52p26"), + "reward": mustParseCid("bafk2bzacebt7vup2pdxie67goc5ourij32z4ofejlrbv7styzm47ytvmmxx5a"), + "storagemarket": mustParseCid("bafk2bzacebeohybortft5jiihfvfly5oiygvf2hulnuif7vivklind32hbr3c"), + "storageminer": mustParseCid("bafk2bzaceallhekg5fhibexjurqcwrx6uzacbyq5eofic6jbdiu3vhepq6xsw"), + "storagepower": mustParseCid("bafk2bzaceassqqdljvblivbcrkv62a36gxjwf7dmkgez6ezq2oydx3dv2b3z2"), + "system": mustParseCid("bafk2bzacebxsecqifqvqxavnmsuwigmnc5rcuxoezspmykeqinkbgrkfukmgs"), + "verifiedregistry": mustParseCid("bafk2bzacedrmxfk5qifi7ujcb7mm73mwoy5e7nbndxhbqauuyol6cunf6popm"), + }, }, { Network: "caterpillarnet", Version: 8, @@ -56,6 +90,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacebu47th3xerlngqavlipb6cfu2utljkxxzgadc3totogto2tmx2jc"), "verifiedregistry": mustParseCid("bafk2bzaceci3niq3rmbcmepgn27zvlgci6d5t4dvthx3pbmmx3wcu5elova6i"), }, +}, { + Network: "caterpillarnet", + Version: 9, + ManifestCid: mustParseCid("bafy2bzaceaknnblpmv3qqeqlgdycpps2vkgbgkflugbqz47k6zwrqte54hqy2"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzaceckajm6tcdpvfsrvagduv6cuefuo3modkpfupum6ibspulgvporrw"), + "cron": mustParseCid("bafk2bzacea74zhlldpihms2ohp3wvefojifvudbblmeju3izwrpcpxemp43fo"), + "init": mustParseCid("bafk2bzacea5nqh4l76vm4ys6vgrqyt77tquk66il3w5ho3zxugka22fipdkdw"), + "multisig": mustParseCid("bafk2bzacea3ftmx2roav4psh63r5n2sol6x3kwpmfwe473pexhj6lg7pruu2k"), + "paymentchannel": mustParseCid("bafk2bzacea2gqhnycejjfuinywoz4j7pmsvxn3i2y5epdx5vqpo23phx6jeac"), + "reward": mustParseCid("bafk2bzaceamdxogvus7zawqtju3vesmj6ffpf3ta6dlwvvstyfbf23sow2tes"), + "storagemarket": mustParseCid("bafk2bzacecvh6qhfe3ityehpibxmmw43l7recwtru3l4n3yrdj5bmnv4efnrc"), + "storageminer": mustParseCid("bafk2bzaced6ya5wlvplkvnvmhuc2uh5zq7oft6pyyoouwouuoreuk6grn6vsw"), + "storagepower": mustParseCid("bafk2bzacedbfoblr65vbqwx37cym6v3zhbgrau46vma4c2lbh6toz6q5dyrtc"), + "system": mustParseCid("bafk2bzaced7z2lu5hp4qpsesbmubq3chrad3sl6kgveldafksh4w252ijjaw2"), + "verifiedregistry": mustParseCid("bafk2bzacec6fdlcvlnaiktdptogae3bgofhzo24lhn4hs6rsa2zbnknfpsct6"), + }, }, { Network: "devnet", Version: 8, @@ -73,6 +124,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacecf7eta2stfd3cnuxzervd33imbvlaqq6b5tsho7pxmhifrybreru"), "verifiedregistry": mustParseCid("bafk2bzaceaajgtglewgitshgdi2nzrvq7eihjtyqj5yiamesqun2hujl3xev2"), }, +}, { + Network: "devnet", + Version: 9, + ManifestCid: mustParseCid("bafy2bzacecogd7hb3dap7d4abyikdgt6b2zs46s4qyilsgxk4rsienbvvstp4"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacecrgqcwn2j6c44tnfx32om4upg56b7gdwslfgeuyfsm6iwkiuhm2w"), + "cron": mustParseCid("bafk2bzaceblepwha5i5cpac37arpcxjcebm5k7p4e5ed7bwcq7ie6fryxgno4"), + "init": mustParseCid("bafk2bzacebjr3xwsdzfie47rtffibt3irr7a5qqstt7fsbwnolzz3z6oy5frw"), + "multisig": mustParseCid("bafk2bzacec66uf5u7o7q3u3pufrtufya6ntwrreysrwwlzqdjbtj36ajuamz4"), + "paymentchannel": mustParseCid("bafk2bzacebouukxeahifxfoymmvibngg6abftd7luiq5x2c7zxulvqyerwoeg"), + "reward": mustParseCid("bafk2bzacecj4pry2xb6w4kd4xxvs3dqd2endfynnwrkf66zakmt376tafy6ym"), + "storagemarket": mustParseCid("bafk2bzacecmij6fgaasgu7zm354fltmvhwmepzwadhl4euxhb64yg4pgfkxgw"), + "storageminer": mustParseCid("bafk2bzaceb5qyhchlvqvcq5cvrc5tuyjrrz6qkgbbxx4vr4wxhtoa4bfp56bg"), + "storagepower": mustParseCid("bafk2bzaced377v52henedhmudi2isuxe73mp2lrv2zyyxfp4r4uppz3sy2ipw"), + "system": mustParseCid("bafk2bzacebb3gdmg2fqexijivo7dkxj6g6gu7ou2jsw6opszr5gfmwt4fvorw"), + "verifiedregistry": mustParseCid("bafk2bzacec5xfb3a56mlclymhvs2br3qzx7sagqda4dvl4xz3fgiymkkbz5tk"), + }, }, { Network: "mainnet", Version: 8, @@ -90,6 +158,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzacedwq5uppsw7vp55zpj7jdieizirmldceehu6wvombw3ixq2tcq57w"), "verifiedregistry": mustParseCid("bafk2bzaceb3zbkjz3auizmoln2unmxep7dyfcmsre64vnqfhdyh7rkqfoxlw4"), }, +}, { + Network: "mainnet", + Version: 9, + ManifestCid: mustParseCid("bafy2bzaceb7nrn4icde3yt7s2kpllliodblq2i3iuslh3l6swgjqyusual72u"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacedchhykcbvptlrnts62xa2h7fewsyvb4imktudll7tbogkwj4ccpy"), + "cron": mustParseCid("bafk2bzaced2e2ivtglevf5tnqay6eqdl3m5ilx4az766ojbhmy2kbxmkogbni"), + "init": mustParseCid("bafk2bzaceapzqn6e3cfpf4ntln4dkyrqe5egygmjczefduy7fuabxh2npqq6o"), + "multisig": mustParseCid("bafk2bzacebxihi4x4lzelmmdtxiz5gub3cjgthrgxuj5mxl2ihxaz6qhp5qbu"), + "paymentchannel": mustParseCid("bafk2bzacecv34ahs6k552won2vj4r62gur5i7inqnycg7y4dg27ktlq76stlk"), + "reward": mustParseCid("bafk2bzacea4er76nlnzz3muuvdxs4dbygejztezanpafi42idj57n75sumu7o"), + "storagemarket": mustParseCid("bafk2bzacedd3pjxcwgxfli4a5udw3ebbo4gom43epizbldvto7ovduqk6udj6"), + "storageminer": mustParseCid("bafk2bzacebtuopxp2464fxulzfyr4iw7bj4pelfxlatudaf6q5qtahokeo3lo"), + "storagepower": mustParseCid("bafk2bzacec3dmcwtizgy6qhxg6fgb4ykc2pamxxh2n5oyeqvebjf3ikzd2sui"), + "system": mustParseCid("bafk2bzacecrm36gf2gusruvhfc6ukf36qflsr5pdbquvfyysprdyudsatoufm"), + "verifiedregistry": mustParseCid("bafk2bzaceah3mwu6tb4jmffohpoz6nyoxpgno2hmxz455rycw4o2hrat3yg3u"), + }, }, { Network: "testing", Version: 8, @@ -107,6 +192,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"), "verifiedregistry": mustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"), }, +}, { + Network: "testing", + Version: 9, + ManifestCid: mustParseCid("bafy2bzaceas5fka4rtyvnqwvvwdi2qqhbnu7hnyz37chhpflh4rdbwnoupols"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacecsmbmd42fsg33wd3u5vxyp4n4a4mac423fduauishjhiyv2bqz7w"), + "cron": mustParseCid("bafk2bzacedajlwnkefucjxzasudkfojrz3bnhnnirebvacxrtly5y2kfb7qiu"), + "init": mustParseCid("bafk2bzaceat7cvf7s2vnmqoldzafkpjygi6wv3sfnclenfbahk4htsgu4aqsa"), + "multisig": mustParseCid("bafk2bzacebh7pwb7eoyigwgjs2r32ebtxwbwgxqd4cvou4katq4axmhd7lxsq"), + "paymentchannel": mustParseCid("bafk2bzaceb6nbmyo2girdpnwywby7yzelx7g6s4snbq3kb3mmd2pp33qefkww"), + "reward": mustParseCid("bafk2bzacedttgmuddtlrp2ie4i2vzuueury455knof5muqtqlslscxrk7ucl6"), + "storagemarket": mustParseCid("bafk2bzacebjtz7fg5n2sm4wg464fyg5vcvux5hqrsdwki675hsquhh3rpe5rg"), + "storageminer": mustParseCid("bafk2bzacea2c2genvtsktr3f6yjlny57gwqyt5dbqrfws56wn5ssyl2tevjjg"), + "storagepower": mustParseCid("bafk2bzaceasmr5xc3c7jgihqcb5pdv557kfor72wlmzmh4syvedknelebhsve"), + "system": mustParseCid("bafk2bzaceabj3whuno364pjqn7sphwquiqpl2w5le6aa6quwytgyxshvelcwq"), + "verifiedregistry": mustParseCid("bafk2bzaceamn6gzihkytyqym4dqs7wqmo2fz6kpge4tphumvutsp2ys4bwaha"), + }, }, { Network: "testing-fake-proofs", Version: 8, @@ -124,6 +226,23 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet "system": mustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"), "verifiedregistry": mustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"), }, +}, { + Network: "testing-fake-proofs", + Version: 9, + ManifestCid: mustParseCid("bafy2bzacebr7bo4shotwq4cct3ablt6hlcozg4h2e52av2q3md5di7sibrqj2"), + Actors: map[string]cid.Cid{ + "account": mustParseCid("bafk2bzacecsmbmd42fsg33wd3u5vxyp4n4a4mac423fduauishjhiyv2bqz7w"), + "cron": mustParseCid("bafk2bzacedajlwnkefucjxzasudkfojrz3bnhnnirebvacxrtly5y2kfb7qiu"), + "init": mustParseCid("bafk2bzaceat7cvf7s2vnmqoldzafkpjygi6wv3sfnclenfbahk4htsgu4aqsa"), + "multisig": mustParseCid("bafk2bzacebh7pwb7eoyigwgjs2r32ebtxwbwgxqd4cvou4katq4axmhd7lxsq"), + "paymentchannel": mustParseCid("bafk2bzaceb6nbmyo2girdpnwywby7yzelx7g6s4snbq3kb3mmd2pp33qefkww"), + "reward": mustParseCid("bafk2bzacedttgmuddtlrp2ie4i2vzuueury455knof5muqtqlslscxrk7ucl6"), + "storagemarket": mustParseCid("bafk2bzacebjtz7fg5n2sm4wg464fyg5vcvux5hqrsdwki675hsquhh3rpe5rg"), + "storageminer": mustParseCid("bafk2bzacedaxvye4reegpy2fecjuzwt4nly2myhplnvkzhssquo2jjw7vfmuy"), + "storagepower": mustParseCid("bafk2bzaceaoteuuvld3bzy3t3kzjp5iabgkvxjc5cxq2ziwankpxqqixkqqjw"), + "system": mustParseCid("bafk2bzaceabj3whuno364pjqn7sphwquiqpl2w5le6aa6quwytgyxshvelcwq"), + "verifiedregistry": mustParseCid("bafk2bzaceamn6gzihkytyqym4dqs7wqmo2fz6kpge4tphumvutsp2ys4bwaha"), + }, }} func mustParseCid(c string) cid.Cid { diff --git a/venus-shared/actors/builtin_actors_test.go b/venus-shared/actors/builtin_actors_test.go index 89d666258c..782ec676c0 100644 --- a/venus-shared/actors/builtin_actors_test.go +++ b/venus-shared/actors/builtin_actors_test.go @@ -3,6 +3,7 @@ package actors import ( "testing" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/stretchr/testify/require" ) @@ -16,16 +17,16 @@ func TestEmbeddedMetadata(t *testing.T) { // Test that we're registering the manifest correctly. func TestRegistration(t *testing.T) { - manifestCid, found := GetManifest(Version8) + manifestCid, found := GetManifest(actorstypes.Version8) require.True(t, found) require.True(t, manifestCid.Defined()) for _, key := range GetBuiltinActorsKeys() { - actorCid, found := GetActorCodeID(Version8, key) + actorCid, found := GetActorCodeID(actorstypes.Version8, key) require.True(t, found) name, version, found := GetActorMetaByCode(actorCid) require.True(t, found) - require.Equal(t, Version8, version) + require.Equal(t, actorstypes.Version8, version) require.Equal(t, key, name) } } diff --git a/venus-shared/actors/manifest.go b/venus-shared/actors/manifest.go index 1754594922..de69f774e3 100644 --- a/venus-shared/actors/manifest.go +++ b/venus-shared/actors/manifest.go @@ -8,14 +8,15 @@ import ( "strings" "sync" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/venus/venus-shared/actors/adt" cid "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" ) -var manifestCids map[Version]cid.Cid = make(map[Version]cid.Cid) -var manifests map[Version]map[string]cid.Cid = make(map[Version]map[string]cid.Cid) +var manifestCids map[actorstypes.Version]cid.Cid = make(map[actorstypes.Version]cid.Cid) +var manifests map[actorstypes.Version]map[string]cid.Cid = make(map[actorstypes.Version]map[string]cid.Cid) var actorMeta map[cid.Cid]actorEntry = make(map[cid.Cid]actorEntry) const ( @@ -54,7 +55,7 @@ var ( type actorEntry struct { name string - version Version + version actorstypes.Version } // ClearManifest clears all known manifests. This is usually used in tests that need to switch networks. @@ -62,13 +63,13 @@ func ClearManifests() { manifestMx.Lock() defer manifestMx.Unlock() - manifestCids = make(map[Version]cid.Cid) - manifests = make(map[Version]map[string]cid.Cid) + manifestCids = make(map[actorstypes.Version]cid.Cid) + manifests = make(map[actorstypes.Version]map[string]cid.Cid) actorMeta = make(map[cid.Cid]actorEntry) } // RegisterManifest registers an actors manifest with lotus. -func RegisterManifest(av Version, manifestCid cid.Cid, entries map[string]cid.Cid) { +func RegisterManifest(av actorstypes.Version, manifestCid cid.Cid, entries map[string]cid.Cid) { manifestMx.Lock() defer manifestMx.Unlock() @@ -81,7 +82,7 @@ func RegisterManifest(av Version, manifestCid cid.Cid, entries map[string]cid.Ci } // GetManifest gets a loaded manifest. -func GetManifest(av Version) (cid.Cid, bool) { +func GetManifest(av actorstypes.Version) (cid.Cid, bool) { manifestMx.RLock() defer manifestMx.RUnlock() @@ -114,7 +115,7 @@ func ReadManifest(ctx context.Context, store cbor.IpldStore, mfCid cid.Cid) (map } // GetActorCodeIDsFromManifest looks up all builtin actor's code CIDs by actor version for versions that have a manifest. -func GetActorCodeIDsFromManifest(av Version) (map[string]cid.Cid, bool) { +func GetActorCodeIDsFromManifest(av actorstypes.Version) (map[string]cid.Cid, bool) { manifestMx.RLock() defer manifestMx.RUnlock() @@ -137,7 +138,7 @@ func LoadManifest(ctx context.Context, mfCid cid.Cid, adtStore adt.Store) (*mani return &mf, nil } -func GetActorMetaByCode(c cid.Cid) (string, Version, bool) { +func GetActorMetaByCode(c cid.Cid) (string, actorstypes.Version, bool) { manifestMx.RLock() defer manifestMx.RUnlock() diff --git a/venus-shared/actors/policy/policy.go b/venus-shared/actors/policy/policy.go index 54bfbb3834..940dd4069a 100644 --- a/venus-shared/actors/policy/policy.go +++ b/venus-shared/actors/policy/policy.go @@ -3,7 +3,7 @@ package policy import ( - "sort" + actorstypes "github.com/filecoin-project/go-state-types/actors" "fmt" @@ -11,7 +11,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/venus/venus-shared/actors" market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" @@ -60,14 +59,19 @@ import ( miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" - paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin9 "github.com/filecoin-project/go-state-types/builtin" + market9 "github.com/filecoin-project/go-state-types/builtin/v9/market" + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + + paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych" ) const ( - ChainFinality = miner8.ChainFinality + ChainFinality = miner9.ChainFinality SealRandomnessLookback = ChainFinality - PaychSettleDelay = paych8.SettleDelay - MaxPreCommitRandomnessLookback = builtin8.EpochsInDay + SealRandomnessLookback + PaychSettleDelay = paych9.SettleDelay + MaxPreCommitRandomnessLookback = builtin9.EpochsInDay + SealRandomnessLookback ) // SetSupportedProofTypes sets supported proof types, across all actor versions. @@ -94,8 +98,6 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) { miner7.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - miner8.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - AddSupportedProofTypes(types...) } @@ -152,15 +154,6 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { miner7.WindowPoStProofTypes[wpp] = struct{}{} - miner8.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - wpp, err = t.RegisteredWindowPoStProof() - if err != nil { - // Fine to panic, this is a test-only method - panic(err) - } - - miner8.WindowPoStProofTypes[wpp] = struct{}{} - } } @@ -185,11 +178,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) { miner8.PreCommitChallengeDelay = delay + miner9.PreCommitChallengeDelay = delay + } // TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay. func GetPreCommitChallengeDelay() abi.ChainEpoch { - return miner8.PreCommitChallengeDelay + return miner9.PreCommitChallengeDelay } // SetConsensusMinerMinPower sets the minimum power of an individual miner must @@ -227,6 +222,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) { policy.ConsensusMinerMinPower = p } + for _, policy := range builtin9.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + } // SetMinVerifiedDealSize sets the minimum size of a verified deal. This should @@ -249,43 +248,49 @@ func SetMinVerifiedDealSize(size abi.StoragePower) { verifreg8.MinVerifiedDealSize = size + verifreg9.MinVerifiedDealSize = size + } -func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { +func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { switch ver { - case actors.Version0: + case actorstypes.Version0: return miner0.MaxSealDuration[t], nil - case actors.Version2: + case actorstypes.Version2: return miner2.MaxProveCommitDuration[t], nil - case actors.Version3: + case actorstypes.Version3: return miner3.MaxProveCommitDuration[t], nil - case actors.Version4: + case actorstypes.Version4: return miner4.MaxProveCommitDuration[t], nil - case actors.Version5: + case actorstypes.Version5: return miner5.MaxProveCommitDuration[t], nil - case actors.Version6: + case actorstypes.Version6: return miner6.MaxProveCommitDuration[t], nil - case actors.Version7: + case actorstypes.Version7: return miner7.MaxProveCommitDuration[t], nil - case actors.Version8: + case actorstypes.Version8: return miner8.MaxProveCommitDuration[t], nil + case actorstypes.Version9: + + return miner9.MaxProveCommitDuration[t], nil + default: return 0, fmt.Errorf("unsupported actors version") } @@ -331,6 +336,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) { Denominator: denom, } + market9.ProviderCollateralSupplyTarget = builtin9.BigFrac{ + Numerator: num, + Denominator: denom, + } + } func DealProviderCollateralBounds( @@ -338,59 +348,64 @@ func DealProviderCollateralBounds( rawBytePower, qaPower, baselinePower abi.StoragePower, circulatingFil abi.TokenAmount, nwVer network.Version, ) (min, max abi.TokenAmount, err error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), big.Zero(), err } switch v { - case actors.Version0: + case actorstypes.Version0: min, max := market0.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) return min, max, nil - case actors.Version2: + case actorstypes.Version2: min, max := market2.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version3: + case actorstypes.Version3: min, max := market3.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version4: + case actorstypes.Version4: min, max := market4.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version5: + case actorstypes.Version5: min, max := market5.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version6: + case actorstypes.Version6: min, max := market6.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version7: + case actorstypes.Version7: min, max := market7.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version8: + case actorstypes.Version8: min, max := market8.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil + case actorstypes.Version9: + + min, max := market9.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + default: return big.Zero(), big.Zero(), fmt.Errorf("unsupported actors version") } } func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) { - return market8.DealDurationBounds(pieceSize) + return market9.DealDurationBounds(pieceSize) } // Sets the challenge window and scales the proving period to match (such that @@ -445,6 +460,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) { // scale it if we're scaling the challenge period. miner8.WPoStDisputeWindow = period * 30 + miner9.WPoStChallengeWindow = period + miner9.WPoStProvingPeriod = period * abi.ChainEpoch(miner9.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner9.WPoStDisputeWindow = period * 30 + } func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { @@ -457,15 +479,15 @@ func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { } func GetMaxSectorExpirationExtension() abi.ChainEpoch { - return miner8.MaxSectorExpirationExtension + return miner9.MaxSectorExpirationExtension } func GetMinSectorExpiration() abi.ChainEpoch { - return miner8.MinSectorExpiration + return miner9.MinSectorExpiration } func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) { - sectorsPerPart, err := builtin8.PoStProofWindowPoStPartitionSectors(p) + sectorsPerPart, err := builtin9.PoStProofWindowPoStPartitionSectors(p) if err != nil { return 0, err } @@ -476,25 +498,6 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e return int(uint64(maxSectors) / sectorsPerPart), nil } -func GetDefaultSectorSize() abi.SectorSize { - // supported sector sizes are the same across versions. - szs := make([]abi.SectorSize, 0, len(miner8.PreCommitSealProofTypesV8)) - for spt := range miner8.PreCommitSealProofTypesV8 { - ss, err := spt.SectorSize() - if err != nil { - panic(err) - } - - szs = append(szs, ss) - } - - sort.Slice(szs, func(i, j int) bool { - return szs[i] < szs[j] - }) - - return szs[0] -} - func GetDefaultAggregationProof() abi.RegisteredAggregationProof { return abi.RegisteredAggregationProof_SnarkPackV1 } @@ -504,173 +507,188 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime } - return builtin8.SealProofPoliciesV11[proof].SectorMaxLifetime + return builtin9.SealProofPoliciesV11[proof].SectorMaxLifetime } func GetAddressedSectorsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { - case actors.Version0: + case actorstypes.Version0: return miner0.AddressedSectorsMax, nil - case actors.Version2: + case actorstypes.Version2: return miner2.AddressedSectorsMax, nil - case actors.Version3: + case actorstypes.Version3: return miner3.AddressedSectorsMax, nil - case actors.Version4: + case actorstypes.Version4: return miner4.AddressedSectorsMax, nil - case actors.Version5: + case actorstypes.Version5: return miner5.AddressedSectorsMax, nil - case actors.Version6: + case actorstypes.Version6: return miner6.AddressedSectorsMax, nil - case actors.Version7: + case actorstypes.Version7: return miner7.AddressedSectorsMax, nil - case actors.Version8: + case actorstypes.Version8: return miner8.AddressedSectorsMax, nil + case actorstypes.Version9: + return miner9.AddressedSectorsMax, nil + default: return 0, fmt.Errorf("unsupported network version") } } func GetDeclarationsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { - case actors.Version0: + case actorstypes.Version0: // TODO: Should we instead error here since the concept doesn't exist yet? return miner0.AddressedPartitionsMax, nil - case actors.Version2: + case actorstypes.Version2: return miner2.DeclarationsMax, nil - case actors.Version3: + case actorstypes.Version3: return miner3.DeclarationsMax, nil - case actors.Version4: + case actorstypes.Version4: return miner4.DeclarationsMax, nil - case actors.Version5: + case actorstypes.Version5: return miner5.DeclarationsMax, nil - case actors.Version6: + case actorstypes.Version6: return miner6.DeclarationsMax, nil - case actors.Version7: + case actorstypes.Version7: return miner7.DeclarationsMax, nil - case actors.Version8: + case actorstypes.Version8: return miner8.DeclarationsMax, nil + case actorstypes.Version9: + + return miner9.DeclarationsMax, nil + default: return 0, fmt.Errorf("unsupported network version") } } func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { - case actors.Version0: + case actorstypes.Version0: return big.Zero(), nil - case actors.Version2: + case actorstypes.Version2: return big.Zero(), nil - case actors.Version3: + case actorstypes.Version3: return big.Zero(), nil - case actors.Version4: + case actorstypes.Version4: return big.Zero(), nil - case actors.Version5: + case actorstypes.Version5: return miner5.AggregateNetworkFee(aggregateSize, baseFee), nil - case actors.Version6: + case actorstypes.Version6: return miner6.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version7: + case actorstypes.Version7: return miner7.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version8: + case actorstypes.Version8: return miner8.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version9: + + return miner9.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), fmt.Errorf("unsupported network version") } } func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { - case actors.Version0: + case actorstypes.Version0: return big.Zero(), nil - case actors.Version2: + case actorstypes.Version2: return big.Zero(), nil - case actors.Version3: + case actorstypes.Version3: return big.Zero(), nil - case actors.Version4: + case actorstypes.Version4: return big.Zero(), nil - case actors.Version5: + case actorstypes.Version5: return big.Zero(), nil - case actors.Version6: + case actorstypes.Version6: return miner6.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version7: + case actorstypes.Version7: return miner7.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version8: + case actorstypes.Version8: return miner8.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version9: + + return miner9.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), fmt.Errorf("unsupported network version") } diff --git a/venus-shared/actors/policy/policy.go.template b/venus-shared/actors/policy/policy.go.template index bb3b932f0d..47d5498d74 100644 --- a/venus-shared/actors/policy/policy.go.template +++ b/venus-shared/actors/policy/policy.go.template @@ -3,14 +3,13 @@ package policy import ( - "sort" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "fmt" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/venus/venus-shared/actors" {{range .versions}} {{if (ge . 8)}} @@ -52,7 +51,7 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) { miner{{.}}.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) miner{{.}}.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) miner{{.}}.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - {{else}} + {{else if (le . 7)}} miner{{.}}.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) {{end}} {{end}} @@ -86,7 +85,7 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { } miner{{.}}.WindowPoStProofTypes[wpp] = struct{}{} - {{else}} + {{else if (le . 7)}} miner{{.}}.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} wpp, err = t.RegisteredWindowPoStProof() if err != nil { @@ -141,10 +140,10 @@ func SetMinVerifiedDealSize(size abi.StoragePower) { {{end}} } -func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { +func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { switch ver { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (eq . 0)}} return miner{{.}}.MaxSealDuration[t], nil {{else}} @@ -175,13 +174,13 @@ func DealProviderCollateralBounds( rawBytePower, qaPower, baselinePower abi.StoragePower, circulatingFil abi.TokenAmount, nwVer network.Version, ) (min, max abi.TokenAmount, err error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), big.Zero(), err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (eq . 0)}} min, max := market{{.}}.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) return min, max, nil @@ -242,25 +241,6 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e return int(uint64(maxSectors) / sectorsPerPart), nil } -func GetDefaultSectorSize() abi.SectorSize { - // supported sector sizes are the same across versions. - szs := make([]abi.SectorSize, 0, len(miner{{.latestVersion}}.PreCommitSealProofTypesV8)) - for spt := range miner{{.latestVersion}}.PreCommitSealProofTypesV8 { - ss, err := spt.SectorSize() - if err != nil { - panic(err) - } - - szs = append(szs, ss) - } - - sort.Slice(szs, func(i, j int) bool { - return szs[i] < szs[j] - }) - - return szs[0] -} - func GetDefaultAggregationProof() abi.RegisteredAggregationProof { return abi.RegisteredAggregationProof_SnarkPackV1 } @@ -274,13 +254,13 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) } func GetAddressedSectorsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return miner{{.}}.AddressedSectorsMax, nil {{end}} default: @@ -289,13 +269,13 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { } func GetDeclarationsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (eq . 0)}} // TODO: Should we instead error here since the concept doesn't exist yet? return miner{{.}}.AddressedPartitionsMax, nil @@ -309,13 +289,13 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { } func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (ge . 6)}} return miner{{.}}.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil {{else if (eq . 5)}} @@ -330,13 +310,13 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba } func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (ge . 6)}} return miner{{.}}.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil {{else}} diff --git a/venus-shared/actors/version.go b/venus-shared/actors/version.go index 05afe84f4f..414c962102 100644 --- a/venus-shared/actors/version.go +++ b/venus-shared/actors/version.go @@ -2,12 +2,6 @@ package actors -import ( - "fmt" - - "github.com/filecoin-project/go-state-types/network" -) - type Version int /* inline-gen template @@ -22,9 +16,9 @@ const ({{range .actorVersions}} /* inline-gen start */ -var LatestVersion = 8 +var LatestVersion = 9 -var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8} +var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9} const ( Version0 Version = 0 @@ -35,30 +29,7 @@ const ( Version6 Version = 6 Version7 Version = 7 Version8 Version = 8 + Version9 Version = 9 ) /* inline-gen end */ - -// Converts a network version into an actors adt version. -func VersionForNetwork(version network.Version) (Version, error) { - switch version { - case network.Version0, network.Version1, network.Version2, network.Version3: - return Version0, nil - case network.Version4, network.Version5, network.Version6, network.Version7, network.Version8, network.Version9: - return Version2, nil - case network.Version10, network.Version11: - return Version3, nil - case network.Version12: - return Version4, nil - case network.Version13: - return Version5, nil - case network.Version14: - return Version6, nil - case network.Version15: - return Version7, nil - case network.Version16: - return Version8, nil - default: - return -1, fmt.Errorf("unsupported network version %d", version) - } -} diff --git a/venus-shared/api/chain/v0/chain.go b/venus-shared/api/chain/v0/chain.go index f79cd1b0f1..0a00b19c1a 100644 --- a/venus-shared/api/chain/v0/chain.go +++ b/venus-shared/api/chain/v0/chain.go @@ -13,7 +13,7 @@ import ( "github.com/filecoin-project/go-state-types/network" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" lminer "github.com/filecoin-project/venus/venus-shared/actors/builtin/miner" "github.com/filecoin-project/venus/venus-shared/types" ) diff --git a/venus-shared/api/chain/v0/method.md b/venus-shared/api/chain/v0/method.md index 3910eba23c..4ef8596fc2 100644 --- a/venus-shared/api/chain/v0/method.md +++ b/venus-shared/api/chain/v0/method.md @@ -1301,7 +1301,7 @@ Perms: read Inputs: ```json [ - 16 + 17 ] ``` @@ -1316,7 +1316,7 @@ Perms: read Inputs: ```json [ - 16 + 17 ] ``` @@ -1597,7 +1597,7 @@ Inputs: ] ``` -Response: `16` +Response: `17` ### StateSearchMsg @@ -3157,10 +3157,7 @@ Inputs: 5432 ], "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 + "UnsealedCid": null }, [ { @@ -3279,10 +3276,7 @@ Inputs: 5432 ], "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 + "UnsealedCid": null }, [ { @@ -3646,15 +3640,10 @@ Response: 5432 ], "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 + "UnsealedCid": null }, "PreCommitDeposit": "0", - "PreCommitEpoch": 10101, - "DealWeight": "0", - "VerifiedDealWeight": "0" + "PreCommitEpoch": 10101 } ``` diff --git a/venus-shared/api/chain/v0/mock/mock_fullnode.go b/venus-shared/api/chain/v0/mock/mock_fullnode.go index 1107f43e15..bc350a58e0 100644 --- a/venus-shared/api/chain/v0/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v0/mock/mock_fullnode.go @@ -13,8 +13,8 @@ import ( bitfield "github.com/filecoin-project/go-bitfield" abi "github.com/filecoin-project/go-state-types/abi" big "github.com/filecoin-project/go-state-types/big" - miner "github.com/filecoin-project/go-state-types/builtin/v8/miner" paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" + miner "github.com/filecoin-project/go-state-types/builtin/v9/miner" crypto "github.com/filecoin-project/go-state-types/crypto" dline "github.com/filecoin-project/go-state-types/dline" network "github.com/filecoin-project/go-state-types/network" diff --git a/venus-shared/api/chain/v0/proxy_gen.go b/venus-shared/api/chain/v0/proxy_gen.go index af42818341..9d2be132d3 100644 --- a/venus-shared/api/chain/v0/proxy_gen.go +++ b/venus-shared/api/chain/v0/proxy_gen.go @@ -9,7 +9,7 @@ import ( bitfield "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" diff --git a/venus-shared/api/chain/v1/chain.go b/venus-shared/api/chain/v1/chain.go index 09099b9984..7cf8a72add 100644 --- a/venus-shared/api/chain/v1/chain.go +++ b/venus-shared/api/chain/v1/chain.go @@ -14,7 +14,7 @@ import ( "github.com/filecoin-project/go-state-types/network" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" lminer "github.com/filecoin-project/venus/venus-shared/actors/builtin/miner" "github.com/filecoin-project/venus/venus-shared/types" ) diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index 534dd05927..ed1a36f4db 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -1270,7 +1270,7 @@ Perms: read Inputs: ```json [ - 16 + 17 ] ``` @@ -1285,7 +1285,7 @@ Perms: read Inputs: ```json [ - 16 + 17 ] ``` @@ -1606,7 +1606,7 @@ Inputs: ] ``` -Response: `16` +Response: `17` ### StateSearchMsg StateSearchMsg looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed @@ -3485,10 +3485,7 @@ Inputs: 5432 ], "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 + "UnsealedCid": null }, [ { @@ -3607,10 +3604,7 @@ Inputs: 5432 ], "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 + "UnsealedCid": null }, [ { @@ -4011,15 +4005,10 @@ Response: 5432 ], "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 + "UnsealedCid": null }, "PreCommitDeposit": "0", - "PreCommitEpoch": 10101, - "DealWeight": "0", - "VerifiedDealWeight": "0" + "PreCommitEpoch": 10101 } ``` diff --git a/venus-shared/api/chain/v1/mock/mock_fullnode.go b/venus-shared/api/chain/v1/mock/mock_fullnode.go index 849512d2df..91a7656992 100644 --- a/venus-shared/api/chain/v1/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v1/mock/mock_fullnode.go @@ -14,8 +14,8 @@ import ( bitfield "github.com/filecoin-project/go-bitfield" abi "github.com/filecoin-project/go-state-types/abi" big "github.com/filecoin-project/go-state-types/big" - miner "github.com/filecoin-project/go-state-types/builtin/v8/miner" paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" + miner "github.com/filecoin-project/go-state-types/builtin/v9/miner" crypto "github.com/filecoin-project/go-state-types/crypto" dline "github.com/filecoin-project/go-state-types/dline" network "github.com/filecoin-project/go-state-types/network" diff --git a/venus-shared/api/chain/v1/proxy_gen.go b/venus-shared/api/chain/v1/proxy_gen.go index b23ef6ce29..f9bbff1ae3 100644 --- a/venus-shared/api/chain/v1/proxy_gen.go +++ b/venus-shared/api/chain/v1/proxy_gen.go @@ -10,7 +10,7 @@ import ( bitfield "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" diff --git a/venus-shared/api/gateway/v1/method.md b/venus-shared/api/gateway/v1/method.md index 2028774e2f..74692ab605 100644 --- a/venus-shared/api/gateway/v1/method.md +++ b/venus-shared/api/gateway/v1/method.md @@ -197,7 +197,7 @@ Inputs: ], "Bw==", 10101, - 16 + 17 ] ``` diff --git a/venus-shared/compatible-checks/actor-sources.txt b/venus-shared/compatible-checks/actor-sources.txt index f2b05786ed..4aa53bb5d7 100644 --- a/venus-shared/compatible-checks/actor-sources.txt +++ b/venus-shared/compatible-checks/actor-sources.txt @@ -17,6 +17,7 @@ SOURCES IN chain/actors: builtin/account/v6.go builtin/account/v7.go builtin/account/v8.go + builtin/account/v9.go builtin/builtin.go builtin/cron/cron.go builtin/cron/v0.go @@ -27,6 +28,7 @@ SOURCES IN chain/actors: builtin/cron/v6.go builtin/cron/v7.go builtin/cron/v8.go + builtin/cron/v9.go builtin/init/diff.go builtin/init/init.go builtin/init/v0.go @@ -37,6 +39,7 @@ SOURCES IN chain/actors: builtin/init/v6.go builtin/init/v7.go builtin/init/v8.go + builtin/init/v9.go builtin/market/diff.go builtin/market/market.go builtin/market/v0.go @@ -47,6 +50,7 @@ SOURCES IN chain/actors: builtin/market/v6.go builtin/market/v7.go builtin/market/v8.go + builtin/market/v9.go builtin/miner/diff.go builtin/miner/diff_deadlines.go builtin/miner/miner.go @@ -59,6 +63,7 @@ SOURCES IN chain/actors: builtin/miner/v6.go builtin/miner/v7.go builtin/miner/v8.go + builtin/miner/v9.go builtin/multisig/diff.go builtin/multisig/message0.go builtin/multisig/message2.go @@ -68,6 +73,7 @@ SOURCES IN chain/actors: builtin/multisig/message6.go builtin/multisig/message7.go builtin/multisig/message8.go + builtin/multisig/message9.go builtin/multisig/multisig.go builtin/multisig/v0.go builtin/multisig/v2.go @@ -77,6 +83,7 @@ SOURCES IN chain/actors: builtin/multisig/v6.go builtin/multisig/v7.go builtin/multisig/v8.go + builtin/multisig/v9.go builtin/paych/message0.go builtin/paych/message2.go builtin/paych/message3.go @@ -85,6 +92,7 @@ SOURCES IN chain/actors: builtin/paych/message6.go builtin/paych/message7.go builtin/paych/message8.go + builtin/paych/message9.go builtin/paych/mock/mock.go builtin/paych/paych.go builtin/paych/v0.go @@ -95,6 +103,7 @@ SOURCES IN chain/actors: builtin/paych/v6.go builtin/paych/v7.go builtin/paych/v8.go + builtin/paych/v9.go builtin/power/diff.go builtin/power/power.go builtin/power/v0.go @@ -105,6 +114,8 @@ SOURCES IN chain/actors: builtin/power/v6.go builtin/power/v7.go builtin/power/v8.go + builtin/power/v9.go + builtin/registry.go builtin/reward/reward.go builtin/reward/v0.go builtin/reward/v2.go @@ -114,6 +125,7 @@ SOURCES IN chain/actors: builtin/reward/v6.go builtin/reward/v7.go builtin/reward/v8.go + builtin/reward/v9.go builtin/system/system.go builtin/system/v0.go builtin/system/v2.go @@ -123,6 +135,7 @@ SOURCES IN chain/actors: builtin/system/v6.go builtin/system/v7.go builtin/system/v8.go + builtin/system/v9.go builtin/verifreg/util.go builtin/verifreg/v0.go builtin/verifreg/v2.go @@ -132,6 +145,7 @@ SOURCES IN chain/actors: builtin/verifreg/v6.go builtin/verifreg/v7.go builtin/verifreg/v8.go + builtin/verifreg/v9.go builtin/verifreg/verifreg.go manifest.go params.go diff --git a/venus-shared/compatible-checks/actor-templates.txt b/venus-shared/compatible-checks/actor-templates.txt index bb2193324d..5aa537eb3e 100644 --- a/venus-shared/compatible-checks/actor-templates.txt +++ b/venus-shared/compatible-checks/actor-templates.txt @@ -18,6 +18,7 @@ TEMPLATES IN chain/actors: builtin/paych/state.go.template builtin/power/actor.go.template builtin/power/state.go.template + builtin/registry.go.template builtin/reward/actor.go.template builtin/reward/state.go.template builtin/system/actor.go.template diff --git a/venus-shared/compatible-checks/api-checksum.txt b/venus-shared/compatible-checks/api-checksum.txt index fec33ddb25..371038bda0 100644 --- a/venus-shared/compatible-checks/api-checksum.txt +++ b/venus-shared/compatible-checks/api-checksum.txt @@ -142,6 +142,7 @@ v0api.FullNode: Shutdown: In=1, Out=1, CheckSum=c39be30cc5a8826024fcf4d23e7017d6 StateAccountKey: In=3, Out=2, CheckSum=9b6f9fdaea5bb22c60772266c418d98f StateActorCodeCIDs: In=2, Out=2, CheckSum=d52881195cc100121739e6c85c45dd9f + StateActorManifestCID: In=2, Out=2, CheckSum=e04ec685bb3d32a892d45c5215586589 StateAllMinerFaults: In=3, Out=2, CheckSum=a17e05b21e1ecc8da867e2f76df6c46c StateCall: In=3, Out=2, CheckSum=b33ab6c7df31d805c256c8ab6691b085 StateChangedActors: In=3, Out=2, CheckSum=cbc0cd36e495552a6672caab9f839468 @@ -162,20 +163,20 @@ v0api.FullNode: StateMarketDeals: In=2, Out=2, CheckSum=46b5eef922e8252939bf00e1e80ae89e StateMarketParticipants: In=2, Out=2, CheckSum=acc9019d0b6e389743c6f992350f407c StateMarketStorageDeal: In=3, Out=2, CheckSum=94af302d39beba9f0ce7648f4118b6aa - StateMinerActiveSectors: In=3, Out=2, CheckSum=10a984fbf3118e0dab152af36aa64424 + StateMinerActiveSectors: In=3, Out=2, CheckSum=a6cc03c30ff0302d5dcd3002e55585b7 StateMinerAvailableBalance: In=3, Out=2, CheckSum=a05010da3c73edfba49c3b5d28a216cd StateMinerDeadlines: In=3, Out=2, CheckSum=5b128c75ba4953740906520cca96b962 StateMinerFaults: In=3, Out=2, CheckSum=9d26d848f93597964f751b43edd3d476 StateMinerInfo: In=3, Out=2, CheckSum=4ba684a8519aa97d4df405cee3496e7c - StateMinerInitialPledgeCollateral: In=4, Out=2, CheckSum=d2a137a064199d4c8bfd685d21e991f4 + StateMinerInitialPledgeCollateral: In=4, Out=2, CheckSum=b456dc2029fe2ac176ade895bda96dd5 StateMinerPartitions: In=4, Out=2, CheckSum=b3cba1da3bd87c433cb8f9df7f7edc09 StateMinerPower: In=3, Out=2, CheckSum=0e70a6360616c25624118181f764d7df - StateMinerPreCommitDepositForPower: In=4, Out=2, CheckSum=d2a137a064199d4c8bfd685d21e991f4 + StateMinerPreCommitDepositForPower: In=4, Out=2, CheckSum=b456dc2029fe2ac176ade895bda96dd5 StateMinerProvingDeadline: In=3, Out=2, CheckSum=8c6037a054ad720ecfb3d0c3f4f90fe6 StateMinerRecoveries: In=3, Out=2, CheckSum=9d26d848f93597964f751b43edd3d476 StateMinerSectorAllocated: In=4, Out=2, CheckSum=2accd56a9e9196fa1ca85a1d60e19fc2 StateMinerSectorCount: In=3, Out=2, CheckSum=573483cbcf3ccdd38063b9ce16453dc2 - StateMinerSectors: In=4, Out=2, CheckSum=067ee5993041463c27212b948a59e1e5 + StateMinerSectors: In=4, Out=2, CheckSum=532dd2620e4430f0ae9113b75104e12f StateNetworkName: In=1, Out=2, CheckSum=afb82130640a26dcd9d7010f31c69572 StateNetworkVersion: In=2, Out=2, CheckSum=47de92e3b59793ade53abd96c347bace StateReadState: In=3, Out=2, CheckSum=f53f39943eea93d5f3dd64f1389e4c64 @@ -183,9 +184,9 @@ v0api.FullNode: StateSearchMsg: In=2, Out=2, CheckSum=e4186ab56a9d2e3c99174110e3f697dc StateSearchMsgLimited: In=3, Out=2, CheckSum=8990ed018d033c44ebb38c0d077bc6d0 StateSectorExpiration: In=4, Out=2, CheckSum=bb669c8b66b6f74c681b4345c9e4cc8f - StateSectorGetInfo: In=4, Out=2, CheckSum=1fb47cbbd06b1a50e47a087a28998016 + StateSectorGetInfo: In=4, Out=2, CheckSum=8d176fd8a2054079b0017f795f9a4d56 StateSectorPartition: In=4, Out=2, CheckSum=e3743df55a360243a32ac64ce1282c53 - StateSectorPreCommitInfo: In=4, Out=2, CheckSum=04d3c9135dc061d98706f61158224288 + StateSectorPreCommitInfo: In=4, Out=2, CheckSum=f0961d63ab3679dafcf6563a83126d56 StateVMCirculatingSupplyInternal: In=2, Out=2, CheckSum=05c2114e08be095cece55db19e214d2c StateVerifiedClientStatus: In=3, Out=2, CheckSum=e33ae4cd2315832f2d6f2aa74b68c34e StateVerifiedRegistryRootKey: In=2, Out=2, CheckSum=5ad3a497ee24e321c780a69b8d2f0936 @@ -238,6 +239,7 @@ api.FullNode: ChainHasObj: In=2, Out=2, CheckSum=7fe71bcffa1b110db106e0104e98a32f ChainHead: In=1, Out=2, CheckSum=6d1e4c4d8184dc8d645a56278f14cfad ChainNotify: In=1, Out=2, CheckSum=9525148e93a5b83600ebfbde4d24f3e9 + ChainPrune: In=2, Out=1, CheckSum=af574df2ee0daa338f8d54b5f5da15a3 ChainPutObj: In=2, Out=1, CheckSum=8f14a26d66dd2a48d50d58af2ff7d722 ChainReadObj: In=2, Out=2, CheckSum=6fd9244d87bf5d14fb5e79b0dbc0940d ChainSetHead: In=2, Out=1, CheckSum=cdfe593ac791e823186abb77bfad49a0 @@ -367,6 +369,7 @@ api.FullNode: Shutdown: In=1, Out=1, CheckSum=c39be30cc5a8826024fcf4d23e7017d6 StateAccountKey: In=3, Out=2, CheckSum=9b6f9fdaea5bb22c60772266c418d98f StateActorCodeCIDs: In=2, Out=2, CheckSum=d52881195cc100121739e6c85c45dd9f + StateActorManifestCID: In=2, Out=2, CheckSum=e04ec685bb3d32a892d45c5215586589 StateAllMinerFaults: In=3, Out=2, CheckSum=a17e05b21e1ecc8da867e2f76df6c46c StateCall: In=3, Out=2, CheckSum=b33ab6c7df31d805c256c8ab6691b085 StateChangedActors: In=3, Out=2, CheckSum=cbc0cd36e495552a6672caab9f839468 @@ -390,29 +393,30 @@ api.FullNode: StateMarketDeals: In=2, Out=2, CheckSum=46b5eef922e8252939bf00e1e80ae89e StateMarketParticipants: In=2, Out=2, CheckSum=acc9019d0b6e389743c6f992350f407c StateMarketStorageDeal: In=3, Out=2, CheckSum=94af302d39beba9f0ce7648f4118b6aa - StateMinerActiveSectors: In=3, Out=2, CheckSum=10a984fbf3118e0dab152af36aa64424 + StateMinerActiveSectors: In=3, Out=2, CheckSum=a6cc03c30ff0302d5dcd3002e55585b7 + StateMinerAllocated: In=3, Out=2, CheckSum=808e4357d56c3d08769a9d7a249ea7c0 StateMinerAvailableBalance: In=3, Out=2, CheckSum=a05010da3c73edfba49c3b5d28a216cd StateMinerDeadlines: In=3, Out=2, CheckSum=5b128c75ba4953740906520cca96b962 StateMinerFaults: In=3, Out=2, CheckSum=9d26d848f93597964f751b43edd3d476 StateMinerInfo: In=3, Out=2, CheckSum=4ba684a8519aa97d4df405cee3496e7c - StateMinerInitialPledgeCollateral: In=4, Out=2, CheckSum=d2a137a064199d4c8bfd685d21e991f4 + StateMinerInitialPledgeCollateral: In=4, Out=2, CheckSum=b456dc2029fe2ac176ade895bda96dd5 StateMinerPartitions: In=4, Out=2, CheckSum=b3cba1da3bd87c433cb8f9df7f7edc09 StateMinerPower: In=3, Out=2, CheckSum=0e70a6360616c25624118181f764d7df - StateMinerPreCommitDepositForPower: In=4, Out=2, CheckSum=d2a137a064199d4c8bfd685d21e991f4 + StateMinerPreCommitDepositForPower: In=4, Out=2, CheckSum=b456dc2029fe2ac176ade895bda96dd5 StateMinerProvingDeadline: In=3, Out=2, CheckSum=8c6037a054ad720ecfb3d0c3f4f90fe6 StateMinerRecoveries: In=3, Out=2, CheckSum=9d26d848f93597964f751b43edd3d476 StateMinerSectorAllocated: In=4, Out=2, CheckSum=2accd56a9e9196fa1ca85a1d60e19fc2 StateMinerSectorCount: In=3, Out=2, CheckSum=573483cbcf3ccdd38063b9ce16453dc2 - StateMinerSectors: In=4, Out=2, CheckSum=067ee5993041463c27212b948a59e1e5 + StateMinerSectors: In=4, Out=2, CheckSum=532dd2620e4430f0ae9113b75104e12f StateNetworkName: In=1, Out=2, CheckSum=afb82130640a26dcd9d7010f31c69572 StateNetworkVersion: In=2, Out=2, CheckSum=47de92e3b59793ade53abd96c347bace StateReadState: In=3, Out=2, CheckSum=f53f39943eea93d5f3dd64f1389e4c64 StateReplay: In=3, Out=2, CheckSum=ec89143eb01290212c3ce0032f62c5fc StateSearchMsg: In=5, Out=2, CheckSum=05ad20588933ea6ffa941f47b826708a StateSectorExpiration: In=4, Out=2, CheckSum=bb669c8b66b6f74c681b4345c9e4cc8f - StateSectorGetInfo: In=4, Out=2, CheckSum=1fb47cbbd06b1a50e47a087a28998016 + StateSectorGetInfo: In=4, Out=2, CheckSum=8d176fd8a2054079b0017f795f9a4d56 StateSectorPartition: In=4, Out=2, CheckSum=e3743df55a360243a32ac64ce1282c53 - StateSectorPreCommitInfo: In=4, Out=2, CheckSum=699963129f096b031a79fbd0e8c11b1c + StateSectorPreCommitInfo: In=4, Out=2, CheckSum=80eabb64c62e90a2cf0e497107b774ff StateVMCirculatingSupplyInternal: In=2, Out=2, CheckSum=05c2114e08be095cece55db19e214d2c StateVerifiedClientStatus: In=3, Out=2, CheckSum=e33ae4cd2315832f2d6f2aa74b68c34e StateVerifiedRegistryRootKey: In=2, Out=2, CheckSum=5ad3a497ee24e321c780a69b8d2f0936 diff --git a/venus-shared/compatible-checks/api-diff.txt b/venus-shared/compatible-checks/api-diff.txt index 8d4f102cca..70e9d0d81a 100644 --- a/venus-shared/compatible-checks/api-diff.txt +++ b/venus-shared/compatible-checks/api-diff.txt @@ -38,7 +38,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c - CreateBackup - Discover + GasBatchEstimateMessageGas - > GasEstimateMessageGas {[func(context.Context, *internal.Message, *types.MessageSendSpec, types.TipSetKey) (*internal.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 1; nested=nil}}}} + > GasEstimateMessageGas {[func(context.Context, *internal.Message, *types.MessageSendSpec, types.TipSetKey) (*internal.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + GetActor + GetEntry + GetFullBlock @@ -55,11 +55,11 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c - MarketReserveFunds - MarketWithdraw + MessageWait - > MpoolBatchPushMessage {[func(context.Context, []*internal.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 1; nested=nil}}}} + > MpoolBatchPushMessage {[func(context.Context, []*internal.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + MpoolDeleteByAdress + MpoolPublishByAddr + MpoolPublishMessage - > MpoolPushMessage {[func(context.Context, *internal.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 1; nested=nil}}}} + > MpoolPushMessage {[func(context.Context, *internal.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + MpoolSelects > MsigCancel {[func(context.Context, address.Address, uint64, address.Address) (cid.Cid, error) <> func(context.Context, address.Address, uint64, address.Address, big.Int, address.Address, uint64, []uint8) (cid.Cid, error)] base=func in num: 4 != 8; nested=nil} + MsigCancelTxnHash @@ -80,7 +80,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c + SetConcurrent + SetPassword - Shutdown - + StateActorManifestCID - StateAllMinerFaults - StateChangedActors - StateCompute @@ -89,6 +88,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c - StateGetRandomnessFromBeacon - StateGetRandomnessFromTickets - StateListMessages + > StateMinerInfo {[func(context.Context, address.Address, types.TipSetKey) (types.MinerInfo, error) <> func(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)] base=func out type: #0 input; nested={[types.MinerInfo <> api.MinerInfo] base=struct field; nested={[types.MinerInfo <> api.MinerInfo] base=exported fields count: 11 != 14; nested=nil}}} + StateMinerSectorSize + StateMinerWorkerAddress - StateReadState @@ -124,6 +124,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c - ChainGetNode + ChainGetReceipts + ChainList + - ChainPrune + ChainSyncHandleNewTipSet - ClientCalcCommP - ClientCancelDataTransfer @@ -158,7 +159,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c - CreateBackup - Discover + GasBatchEstimateMessageGas - > GasEstimateMessageGas {[func(context.Context, *internal.Message, *types.MessageSendSpec, types.TipSetKey) (*internal.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 1; nested=nil}}}} + > GasEstimateMessageGas {[func(context.Context, *internal.Message, *types.MessageSendSpec, types.TipSetKey) (*internal.Message, error) <> func(context.Context, *types.Message, *api.MessageSendSpec, types.TipSetKey) (*types.Message, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + GetActor + GetEntry + GetFullBlock @@ -175,11 +176,11 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c - MarketReserveFunds - MarketWithdraw + MessageWait - > MpoolBatchPushMessage {[func(context.Context, []*internal.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 1; nested=nil}}}} + > MpoolBatchPushMessage {[func(context.Context, []*internal.Message, *types.MessageSendSpec) ([]*types.SignedMessage, error) <> func(context.Context, []*types.Message, *api.MessageSendSpec) ([]*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + MpoolDeleteByAdress + MpoolPublishByAddr + MpoolPublishMessage - > MpoolPushMessage {[func(context.Context, *internal.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 1; nested=nil}}}} + > MpoolPushMessage {[func(context.Context, *internal.Message, *types.MessageSendSpec) (*types.SignedMessage, error) <> func(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)] base=func in type: #2 input; nested={[*types.MessageSendSpec <> *api.MessageSendSpec] base=pointed type; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=struct field; nested={[types.MessageSendSpec <> api.MessageSendSpec] base=exported fields count: 3 != 2; nested=nil}}}} + MpoolSelects - MsigGetAvailableBalance - MsigGetPending @@ -199,10 +200,9 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c + SetConcurrent + SetPassword - Shutdown - + StateActorManifestCID - StateCompute > StateGetNetworkParams {[func(context.Context) (*types.NetworkParams, error) <> func(context.Context) (*api.NetworkParams, error)] base=func out type: #0 input; nested={[*types.NetworkParams <> *api.NetworkParams] base=pointed type; nested={[types.NetworkParams <> api.NetworkParams] base=struct field; nested={[types.NetworkParams <> api.NetworkParams] base=exported field type: #5 field named ForkUpgradeParams; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=struct field; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=exported field name: #8 field, BreezeGasTampingDuration != UpgradePriceListOopsHeight; nested=nil}}}}}} - + StateMinerAllocated + > StateMinerInfo {[func(context.Context, address.Address, types.TipSetKey) (types.MinerInfo, error) <> func(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)] base=func out type: #0 input; nested={[types.MinerInfo <> api.MinerInfo] base=struct field; nested={[types.MinerInfo <> api.MinerInfo] base=exported fields count: 11 != 14; nested=nil}}} + StateMinerSectorSize + StateMinerWorkerAddress - StateReplay diff --git a/venus-shared/compatible-checks/api-perm.txt b/venus-shared/compatible-checks/api-perm.txt index 8a683d73e5..4c9ae87448 100644 --- a/venus-shared/compatible-checks/api-perm.txt +++ b/venus-shared/compatible-checks/api-perm.txt @@ -11,7 +11,6 @@ v0: github.com/filecoin-project/venus/venus-shared/api/chain/v0 <> github.com/fi - IChainInfo.MessageWait - IChainInfo.ProtocolParameters - IChainInfo.ResolveToKeyAddr - - IChainInfo.StateActorManifestCID - IChainInfo.VerifyEntry - IMinerState.StateMinerSectorSize - IMinerState.StateMinerWorkerAddress @@ -66,9 +65,7 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi - IChainInfo.MessageWait - IChainInfo.ProtocolParameters - IChainInfo.ResolveToKeyAddr - - IChainInfo.StateActorManifestCID - IChainInfo.VerifyEntry - - IMinerState.StateMinerAllocated - IMinerState.StateMinerSectorSize - IMinerState.StateMinerWorkerAddress - IMessagePool.GasBatchEstimateMessageGas diff --git a/venus-shared/utils/method_map.go b/venus-shared/utils/method_map.go index a1da9a2801..0188a73c58 100644 --- a/venus-shared/utils/method_map.go +++ b/venus-shared/utils/method_map.go @@ -2,19 +2,11 @@ package utils import ( "reflect" - "runtime" - "strings" + "strconv" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "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" @@ -22,16 +14,13 @@ import ( 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" + "github.com/ipfs/go-cid" ) type MethodMeta struct { - Name string + Num string Params reflect.Type Ret reflect.Type @@ -43,7 +32,7 @@ type MethodMeta struct { var MethodsMap = map[cid.Cid]map[abi.MethodNum]MethodMeta{} type actorsWithVersion struct { - av _actors.Version + av actorstypes.Version actors []rt.VMActor } @@ -60,27 +49,22 @@ 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 */ + actors = append(actors, actorsWithVersion{av: actorstypes.Version0, actors: exported0.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version2, actors: exported2.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version3, actors: exported3.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version4, actors: exported4.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version5, actors: exported5.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version6, actors: exported6.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version7, actors: exported7.BuiltinActors()}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version8, actors: builtin.MakeRegistry(actorstypes.Version8)}) + actors = append(actors, actorsWithVersion{av: actorstypes.Version9, actors: builtin.MakeRegistry(actorstypes.Version9)}) 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 { + if awv.av >= actorstypes.Version8 { name := _actors.CanonicalName(builtin.ActorNameByCode(ac)) realCode, _ = _actors.GetActorCodeID(awv.av, name) @@ -91,7 +75,7 @@ func loadMethodsMap() { // Explicitly add send, it's special. methods[builtin.MethodSend] = MethodMeta{ - Name: "Send", + Num: "0", Params: reflect.TypeOf(new(abi.EmptyValue)), Ret: reflect.TypeOf(new(abi.EmptyValue)), } @@ -106,24 +90,8 @@ func loadMethodsMap() { 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, + Num: strconv.Itoa(number), Params: et.In(1), Ret: et.Out(0), } diff --git a/venus-shared/utils/msg_parser/parser_test.go b/venus-shared/utils/msg_parser/parser_test.go index 66da289015..b64a792783 100644 --- a/venus-shared/utils/msg_parser/parser_test.go +++ b/venus-shared/utils/msg_parser/parser_test.go @@ -15,7 +15,7 @@ import ( "github.com/filecoin-project/go-address" cbor "github.com/filecoin-project/go-cbor-util" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/specs-actors/v8/actors/builtin" + "github.com/filecoin-project/specs-actors/v7/actors/builtin" "github.com/filecoin-project/venus/venus-shared/types" "github.com/stretchr/testify/require" )