diff --git a/actors/builtin/miner/miner_actor.go b/actors/builtin/miner/miner_actor.go index 5090d7dda..b59dd6255 100644 --- a/actors/builtin/miner/miner_actor.go +++ b/actors/builtin/miner/miner_actor.go @@ -14,7 +14,6 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/go-state-types/network" rtt "github.com/filecoin-project/go-state-types/rt" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" @@ -336,7 +335,6 @@ type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams // Invoked by miner's worker address to submit their fallback post func (a Actor) SubmitWindowedPoSt(rt Runtime, params *SubmitWindowedPoStParams) *abi.EmptyValue { currEpoch := rt.CurrEpoch() - nv := rt.NetworkVersion() store := adt.AsStore(rt) var st State @@ -351,10 +349,8 @@ func (a Actor) SubmitWindowedPoSt(rt Runtime, params *SubmitWindowedPoStParams) } partitionIndexes := bitfield.New() - if nv >= network.Version7 { - for _, partition := range params.Partitions { - partitionIndexes.Set(partition.Index) - } + for _, partition := range params.Partitions { + partitionIndexes.Set(partition.Index) } var postResult *PoStResult @@ -420,14 +416,12 @@ func (a Actor) SubmitWindowedPoSt(rt Runtime, params *SubmitWindowedPoStParams) deadline, err := deadlines.LoadDeadline(store, params.Deadline) builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load deadline %d", params.Deadline) - if nv >= network.Version7 { - alreadyProven, err := bitfield.IntersectBitField(deadline.PostSubmissions, partitionIndexes) - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check proven partitions") - empty, err := alreadyProven.IsEmpty() - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check proven intersection is empty") - if !empty { - rt.Abortf(exitcode.ErrIllegalArgument, "partition already proven: %v", alreadyProven) - } + alreadyProven, err := bitfield.IntersectBitField(deadline.PostSubmissions, partitionIndexes) + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check proven partitions") + empty, err := alreadyProven.IsEmpty() + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check proven intersection is empty") + if !empty { + rt.Abortf(exitcode.ErrIllegalArgument, "partition already proven: %v", alreadyProven) } // Record proven sectors/partitions, returning updates to power and the final set of sectors @@ -567,12 +561,6 @@ func (a Actor) PreCommitSector(rt Runtime, params *PreCommitSectorParams) *abi.E newlyVested := big.Zero() feeToBurn := abi.NewTokenAmount(0) rt.StateTransaction(&st, func() { - // Stop vesting funds as of version 7. Its computationally expensive and unlikely to release any funds. - if rt.NetworkVersion() < network.Version7 { - newlyVested, err = st.UnlockVestedFunds(store, rt.CurrEpoch()) - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to vest funds") - } - // available balance already accounts for fee debt so it is correct to call // this before RepayDebts. We would have to // subtract fee debt explicitly if we called this after. @@ -587,22 +575,16 @@ func (a Actor) PreCommitSector(rt Runtime, params *PreCommitSectorParams) *abi.E rt.Abortf(exitcode.ErrForbidden, "precommit not allowed during active consensus fault") } - if nv < network.Version7 { - if params.SealProof != info.SealProofType { - rt.Abortf(exitcode.ErrIllegalArgument, "sector seal proof %v must match miner seal proof type %d", params.SealProof, info.SealProofType) - } - } else { - // From network version 7, the pre-commit seal type must have the same Window PoSt proof type as the miner's - // recorded seal type has, rather than be exactly the same seal type. - // This permits a transition window from V1 to V1_1 seal types (which share Window PoSt proof type). - minerWPoStProof, err := info.SealProofType.RegisteredWindowPoStProof() - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to lookup Window PoSt proof type for miner seal proof %d", info.SealProofType) - sectorWPoStProof, err := params.SealProof.RegisteredWindowPoStProof() - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "failed to lookup Window PoSt proof type for sector seal proof %d", params.SealProof) - if sectorWPoStProof != minerWPoStProof { - rt.Abortf(exitcode.ErrIllegalArgument, "sector Window PoSt proof type %d must match miner Window PoSt proof type %d (seal proof type %d)", - sectorWPoStProof, minerWPoStProof, params.SealProof) - } + // From network version 7, the pre-commit seal type must have the same Window PoSt proof type as the miner's + // recorded seal type has, rather than be exactly the same seal type. + // This permits a transition window from V1 to V1_1 seal types (which share Window PoSt proof type). + minerWPoStProof, err := info.SealProofType.RegisteredWindowPoStProof() + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to lookup Window PoSt proof type for miner seal proof %d", info.SealProofType) + sectorWPoStProof, err := params.SealProof.RegisteredWindowPoStProof() + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "failed to lookup Window PoSt proof type for sector seal proof %d", params.SealProof) + if sectorWPoStProof != minerWPoStProof { + rt.Abortf(exitcode.ErrIllegalArgument, "sector Window PoSt proof type %d must match miner Window PoSt proof type %d (seal proof type %d)", + sectorWPoStProof, minerWPoStProof, params.SealProof) } dealCountMax := SectorDealsMax(info.SectorSize) @@ -691,16 +673,12 @@ type ProveCommitSectorParams = miner0.ProveCommitSectorParams // If valid, the power actor will call ConfirmSectorProofsValid at the end of the same epoch as this message. func (a Actor) ProveCommitSector(rt Runtime, params *ProveCommitSectorParams) *abi.EmptyValue { rt.ValidateImmediateCallerAcceptAny() - nv := rt.NetworkVersion() if params.SectorNumber > abi.MaxSectorNumber { rt.Abortf(exitcode.ErrIllegalArgument, "sector number greater than maximum") } - maxProofSize := MaxProveCommitSizeV4 - if nv >= network.Version5 { - maxProofSize = MaxProveCommitSizeV5 - } + maxProofSize := MaxProveCommitSize if len(params.Proof) > maxProofSize { rt.Abortf(exitcode.ErrIllegalArgument, "sector prove-commit proof of size %d exceeds max size of %d", len(params.Proof), maxProofSize) @@ -900,14 +878,6 @@ func (a Actor) ConfirmSectorProofsValid(rt Runtime, params *builtin.ConfirmSecto err = st.AssignSectorsToDeadlines(store, rt.CurrEpoch(), newSectors, info.WindowPoStPartitionSectors, info.SectorSize) builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to assign new sectors to deadlines") - // Stop unlocking funds as of version 7. It's computationally expensive and unlikely to actually unlock anything. - if rt.NetworkVersion() < network.Version7 { - newlyVested, err = st.UnlockVestedFunds(store, rt.CurrEpoch()) - if err != nil { - rt.Abortf(exitcode.ErrIllegalState, "failed to vest new funds: %s", err) - } - } - // Unlock deposit for successful proofs, make it available for lock-up as initial pledge. err = st.AddPreCommitDeposit(depositToUnlock.Neg()) builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to add pre-commit deposit %v", depositToUnlock.Neg()) @@ -975,7 +945,6 @@ type ExpirationExtension = miner0.ExpirationExtension // The sector must not be terminated or faulty. // The sector's power is recomputed for the new expiration. func (a Actor) ExtendSectorExpiration(rt Runtime, params *ExtendSectorExpirationParams) *abi.EmptyValue { - nv := rt.NetworkVersion() if uint64(len(params.Extensions)) > DeclarationsMax { rt.Abortf(exitcode.ErrIllegalArgument, "too many declarations %d, max %d", len(params.Extensions), DeclarationsMax) } @@ -1062,7 +1031,7 @@ func (a Actor) ExtendSectorExpiration(rt Runtime, params *ExtendSectorExpiration builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load sectors in deadline %v partition %v", dlIdx, decl.Partition) newSectors := make([]*SectorOnChainInfo, len(oldSectors)) for i, sector := range oldSectors { - if !CanExtendSealProofType(sector.SealProof, nv) { + if !CanExtendSealProofType(sector.SealProof) { rt.Abortf(exitcode.ErrForbidden, "cannot extend expiration for sector %v with unsupported seal type %v", sector.SectorNumber, sector.SealProof) } @@ -1102,12 +1071,10 @@ func (a Actor) ExtendSectorExpiration(rt Runtime, params *ExtendSectorExpiration builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to save deadline %v partition %v", dlIdx, decl.Partition) // Record the new partition expiration epoch for setting outside this loop over declarations. - if nv >= network.Version7 { - prevEpochPartitions, ok := partitionsByNewEpoch[decl.NewExpiration] - partitionsByNewEpoch[decl.NewExpiration] = append(prevEpochPartitions, decl.Partition) - if !ok { - epochsToReschedule = append(epochsToReschedule, decl.NewExpiration) - } + prevEpochPartitions, ok := partitionsByNewEpoch[decl.NewExpiration] + partitionsByNewEpoch[decl.NewExpiration] = append(prevEpochPartitions, decl.Partition) + if !ok { + epochsToReschedule = append(epochsToReschedule, decl.NewExpiration) } } @@ -1115,13 +1082,11 @@ func (a Actor) ExtendSectorExpiration(rt Runtime, params *ExtendSectorExpiration builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to save partitions for deadline %d", dlIdx) // Record partitions in deadline expiration queue - if nv >= network.Version7 { - for _, epoch := range epochsToReschedule { - pIdxs := partitionsByNewEpoch[epoch] - err := deadline.AddExpirationPartitions(store, epoch, pIdxs, quant) - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to add expiration partitions to deadline %v epoch %v: %v", - dlIdx, epoch, pIdxs) - } + for _, epoch := range epochsToReschedule { + pIdxs := partitionsByNewEpoch[epoch] + err := deadline.AddExpirationPartitions(store, epoch, pIdxs, quant) + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to add expiration partitions to deadline %v epoch %v: %v", + dlIdx, epoch, pIdxs) } err = deadlines.UpdateDeadline(store, dlIdx, deadline) @@ -1554,7 +1519,6 @@ func (a Actor) ApplyRewards(rt Runtime, params *builtin.ApplyRewardParams) *abi. if params.Penalty.Sign() < 0 { rt.Abortf(exitcode.ErrIllegalArgument, "cannot penalize a negative amount of funds") } - nv := rt.NetworkVersion() var st State pledgeDeltaTotal := big.Zero() @@ -1564,7 +1528,7 @@ func (a Actor) ApplyRewards(rt Runtime, params *builtin.ApplyRewardParams) *abi. store := adt.AsStore(rt) rt.ValidateImmediateCallerIs(builtin.RewardActorAddr) - rewardToLock, lockedRewardVestingSpec := LockedRewardFromReward(params.Reward, nv) + rewardToLock, lockedRewardVestingSpec := LockedRewardFromReward(params.Reward) // This ensures the miner has sufficient funds to lock up amountToLock. // This should always be true if reward actor sends reward funds with the message. @@ -2024,7 +1988,6 @@ func validateExpiration(rt Runtime, activation, expiration abi.ChainEpoch, sealP } func validateReplaceSector(rt Runtime, st *State, store adt.Store, params *PreCommitSectorParams) { - nv := rt.NetworkVersion() replaceSector, found, err := st.GetSector(store, params.ReplaceSectorNumber) builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load sector %v", params.SectorNumber) if !found { @@ -2034,23 +1997,16 @@ func validateReplaceSector(rt Runtime, st *State, store adt.Store, params *PreCo if len(replaceSector.DealIDs) > 0 { rt.Abortf(exitcode.ErrIllegalArgument, "cannot replace sector %v which has deals", params.ReplaceSectorNumber) } - if nv < network.Version7 { - if params.SealProof != replaceSector.SealProof { - rt.Abortf(exitcode.ErrIllegalArgument, "cannot replace sector %v seal proof %v with seal proof %v", - params.ReplaceSectorNumber, replaceSector.SealProof, params.SealProof) - } - } else { - // From network version 7, the new sector's seal type must have the same Window PoSt proof type as the one - // being replaced, rather than be exactly the same seal type. - // This permits replacing sectors with V1 seal types with V1_1 seal types. - replaceWPoStProof, err := replaceSector.SealProof.RegisteredWindowPoStProof() - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to lookup Window PoSt proof type for sector seal proof %d", replaceSector.SealProof) - newWPoStProof, err := params.SealProof.RegisteredWindowPoStProof() - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "failed to lookup Window PoSt proof type for new seal proof %d", params.SealProof) - if newWPoStProof != replaceWPoStProof { - rt.Abortf(exitcode.ErrIllegalArgument, "new sector window PoSt proof type %d must match replaced proof type %d (seal proof type %d)", - newWPoStProof, replaceWPoStProof, params.SealProof) - } + // From network version 7, the new sector's seal type must have the same Window PoSt proof type as the one + // being replaced, rather than be exactly the same seal type. + // This permits replacing sectors with V1 seal types with V1_1 seal types. + replaceWPoStProof, err := replaceSector.SealProof.RegisteredWindowPoStProof() + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to lookup Window PoSt proof type for sector seal proof %d", replaceSector.SealProof) + newWPoStProof, err := params.SealProof.RegisteredWindowPoStProof() + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "failed to lookup Window PoSt proof type for new seal proof %d", params.SealProof) + if newWPoStProof != replaceWPoStProof { + rt.Abortf(exitcode.ErrIllegalArgument, "new sector window PoSt proof type %d must match replaced proof type %d (seal proof type %d)", + newWPoStProof, replaceWPoStProof, params.SealProof) } if params.Expiration < replaceSector.Expiration { rt.Abortf(exitcode.ErrIllegalArgument, "cannot replace sector %v expiration %v with sooner expiration %v", diff --git a/actors/builtin/miner/miner_test.go b/actors/builtin/miner/miner_test.go index 31809742e..1c4f17b7e 100644 --- a/actors/builtin/miner/miner_test.go +++ b/actors/builtin/miner/miner_test.go @@ -291,42 +291,15 @@ func TestConstruction(t *testing.T) { t.Run("checks seal proof version", func(t *testing.T) { actor := newHarness(t, 0) builder := builderForHarness(actor) - { - // Before version 7, only V1 accepted - rt := builder.Build(t) - rt.SetNetworkVersion(network.Version6) - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1_1) - rt.ExpectAbort(exitcode.ErrIllegalArgument, func() { - actor.constructAndVerify(rt) - }) - rt.Reset() - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1) - actor.constructAndVerify(rt) - } - { - // Version 7 accepts either - rt := builder.Build(t) - rt.SetNetworkVersion(network.Version7) - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1) - actor.constructAndVerify(rt) - - rt = builder.Build(t) - rt.SetNetworkVersion(network.Version7) - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1_1) - actor.constructAndVerify(rt) - } - { - // From version 8, only V1_1 accepted - rt := builder.Build(t) - rt.SetNetworkVersion(network.Version8) - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1) - rt.ExpectAbort(exitcode.ErrIllegalArgument, func() { - actor.constructAndVerify(rt) - }) - rt.Reset() - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1_1) + // From version 8, only V1_1 accepted + rt := builder.Build(t) + actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1) + rt.ExpectAbort(exitcode.ErrIllegalArgument, func() { actor.constructAndVerify(rt) - } + }) + rt.Reset() + actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1_1) + actor.constructAndVerify(rt) }) } @@ -555,16 +528,6 @@ func TestCommitments(t *testing.T) { expectedPledgeDelta abi.TokenAmount sealProofType abi.RegisteredSealProof }{{ - name: "precommit vests funds in version 6", - version: network.Version6, - expectedPledgeDelta: abi.NewTokenAmount(-1000), - sealProofType: abi.RegisteredSealProof_StackedDrg32GiBV1, - }, { - name: "precommit stops vesting funds in version 7", - version: network.Version7, - expectedPledgeDelta: abi.NewTokenAmount(0), - sealProofType: abi.RegisteredSealProof_StackedDrg32GiBV1_1, - }, { name: "precommit does not vest funds in version 8", version: network.Version8, expectedPledgeDelta: abi.NewTokenAmount(0), @@ -862,17 +825,7 @@ func TestCommitments(t *testing.T) { rt.SetBalance(big.Mul(big.NewInt(1000), big.NewInt(1e18))) - // Too big at version 4 proveCommit := makeProveCommit(sectorNo) - proveCommit.Proof = make([]byte, 1920) - rt.SetNetworkVersion(network.Version4) - rt.ExpectAbort(exitcode.ErrIllegalArgument, func() { - actor.proveCommitSectorAndConfirm(rt, precommit, proveCommit, proveCommitConf{}) - }) - rt.Reset() - - // Good proof at version 5 - rt.SetNetworkVersion(network.Version5) actor.proveCommitSectorAndConfirm(rt, precommit, proveCommit, proveCommitConf{}) st := getState(rt) @@ -899,17 +852,7 @@ func TestCommitments(t *testing.T) { vestingPledgeDelta abi.TokenAmount sealProofType abi.RegisteredSealProof }{{ - name: "verify proof vests funds in network version 6", - version: network.Version6, - vestingPledgeDelta: abi.NewTokenAmount(-1000), - sealProofType: abi.RegisteredSealProof_StackedDrg32GiBV1, - }, { - name: "verify proof does not vest starting version 7", - version: network.Version7, - vestingPledgeDelta: abi.NewTokenAmount(0), - sealProofType: abi.RegisteredSealProof_StackedDrg32GiBV1_1, - }, { - name: "verify proof still does not vest at version 7", + name: "verify proof does not vest at version 8", version: network.Version8, vestingPledgeDelta: abi.NewTokenAmount(0), sealProofType: abi.RegisteredSealProof_StackedDrg32GiBV1_1, @@ -1056,28 +999,6 @@ func TestCommitments(t *testing.T) { deadline := actor.deadline(rt) challengeEpoch := precommitEpoch - 1 expiration := deadline.PeriodEnd() + defaultSectorExpiration*miner.WPoStProvingPeriod - - // Before version 7, V1 ok, V1_1 rejected - { - pc := actor.makePreCommit(101, challengeEpoch, expiration, nil) - pc.SealProof = abi.RegisteredSealProof_StackedDrg32GiBV1_1 - rt.ExpectAbort(exitcode.ErrIllegalArgument, func() { - actor.preCommitSector(rt, pc, preCommitConf{}) - }) - rt.Reset() - pc.SealProof = abi.RegisteredSealProof_StackedDrg32GiBV1 - actor.preCommitSector(rt, pc, preCommitConf{}) - } - { - // At version 7, both are accepted - rt.SetNetworkVersion(network.Version7) - pc := actor.makePreCommit(102, challengeEpoch, expiration, nil) - pc.SealProof = abi.RegisteredSealProof_StackedDrg32GiBV1 - actor.preCommitSector(rt, pc, preCommitConf{}) - pc3 := actor.makePreCommit(103, challengeEpoch, expiration, nil) - pc.SealProof = abi.RegisteredSealProof_StackedDrg32GiBV1_1 - actor.preCommitSector(rt, pc3, preCommitConf{}) - } { // After version 7, only V1_1 accepted rt.SetNetworkVersion(network.Version8) @@ -1939,71 +1860,6 @@ func TestCCUpgrade(t *testing.T) { assert.Equal(t, st.InitialPledge, big.Add(newSector1.InitialPledge, newSector2.InitialPledge)) actor.checkState(rt) }) - - t.Run("upgrade seal proof type", func(t *testing.T) { - actor := newHarness(t, periodOffset) - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1) - rt := builderForHarness(actor). - WithBalance(bigBalance, big.Zero()). - Build(t) - rt.SetNetworkVersion(network.Version7) // Version 7 allows both seal proof types - actor.constructAndVerify(rt) - - // Commit and prove first sector with V1 - rt.SetEpoch(periodOffset + miner.WPoStChallengeWindow) - oldSector := actor.commitAndProveSector(rt, 101, defaultSectorExpiration, nil) - assert.Equal(t, abi.RegisteredSealProof_StackedDrg32GiBV1, oldSector.SealProof) - advanceAndSubmitPoSts(rt, actor, oldSector) - - st := getState(rt) - dlIdx, pIdx, err := st.FindSector(rt.AdtStore(), oldSector.SectorNumber) - require.NoError(t, err) - - // Commit and prove upgrade sector with V1_1 - challengeEpoch := rt.Epoch() - 1 - upgradeParams := actor.makePreCommit(102, challengeEpoch, oldSector.Expiration, []abi.DealID{1}) - upgradeParams.SealProof = abi.RegisteredSealProof_StackedDrg32GiBV1_1 - upgradeParams.ReplaceCapacity = true - upgradeParams.ReplaceSectorDeadline = dlIdx - upgradeParams.ReplaceSectorPartition = pIdx - upgradeParams.ReplaceSectorNumber = oldSector.SectorNumber - upgrade := actor.preCommitSector(rt, upgradeParams, preCommitConf{}) - - // Prove new sector - rt.SetEpoch(upgrade.PreCommitEpoch + miner.PreCommitChallengeDelay + 1) - newSector := actor.proveCommitSectorAndConfirm(rt, upgrade, makeProveCommit(upgrade.Info.SectorNumber), proveCommitConf{}) - assert.Equal(t, abi.RegisteredSealProof_StackedDrg32GiBV1_1, newSector.SealProof) - - // Both sectors are present (in the same deadline/partition). - deadline, partition := actor.getDeadlineAndPartition(rt, dlIdx, pIdx) - assert.Equal(t, uint64(2), deadline.TotalSectors) - assert.Equal(t, uint64(2), deadline.LiveSectors) - assertBitfieldEquals(t, partition.Sectors, uint64(newSector.SectorNumber), uint64(oldSector.SectorNumber)) - - // Roll forward to the beginning of the next iteration of this deadline - dlInfo := miner.NewDeadlineInfo(st.ProvingPeriodStart, dlIdx, rt.Epoch()) - advanceToEpochWithCron(rt, actor, dlInfo.NextNotElapsed().Open) - dlInfo = actor.deadline(rt) - - // Submit post for both sectors, new sector gains power. - // Note that this PoSt is over two sectors with different seal proof types (but compatible Window PoSt parameters). - newPower := miner.PowerForSector(actor.sectorSize, newSector) - partitions := []miner.PoStPartition{ - {Index: pIdx, Skipped: bitfield.New()}, - } - actor.submitWindowPoSt(rt, dlInfo, partitions, []*miner.SectorOnChainInfo{oldSector, newSector}, &poStConfig{ - expectedPowerDelta: newPower, - }) - - // At deadline cron, old sector expires. - expectedPowerDelta := miner.PowerForSector(actor.sectorSize, oldSector).Neg() - actor.onDeadlineCron(rt, &cronConfig{ - expiredSectorsPledgeDelta: oldSector.InitialPledge.Neg(), - expiredSectorsPowerDelta: &expectedPowerDelta, - expectedEnrollment: dlInfo.Last() + miner.WPoStChallengeWindow, - }) - actor.checkState(rt) - }) } func TestWindowPost(t *testing.T) { @@ -2095,28 +1951,13 @@ func TestWindowPost(t *testing.T) { expectQueryNetworkInfo(rt, actor) rt.SetCaller(actor.worker, builtin.AccountActorCodeID) - { - // Before version 7, the rejection is a side-effect of there being no active sectors after - // the duplicate is ignored. - rt.SetNetworkVersion(network.Version6) - rt.ExpectValidateCallerAddr(append(actor.controlAddrs, actor.owner, actor.worker)...) - rt.ExpectGetRandomnessTickets(crypto.DomainSeparationTag_PoStChainCommit, dlinfo.Challenge, nil, commitRand) - rt.ExpectAbortContainsMessage(exitcode.ErrIllegalArgument, "no active sectors", func() { - rt.Call(actor.a.SubmitWindowedPoSt, ¶ms) - }) - rt.Reset() - } - - { - // From version 7, a duplicate is explicitly rejected. - rt.SetNetworkVersion(network.Version7) - rt.ExpectValidateCallerAddr(append(actor.controlAddrs, actor.owner, actor.worker)...) - rt.ExpectGetRandomnessTickets(crypto.DomainSeparationTag_PoStChainCommit, dlinfo.Challenge, nil, commitRand) - rt.ExpectAbortContainsMessage(exitcode.ErrIllegalArgument, "partition already proven", func() { - rt.Call(actor.a.SubmitWindowedPoSt, ¶ms) - }) - rt.Reset() - } + // From version 7, a duplicate is explicitly rejected. + rt.ExpectValidateCallerAddr(append(actor.controlAddrs, actor.owner, actor.worker)...) + rt.ExpectGetRandomnessTickets(crypto.DomainSeparationTag_PoStChainCommit, dlinfo.Challenge, nil, commitRand) + rt.ExpectAbortContainsMessage(exitcode.ErrIllegalArgument, "partition already proven", func() { + rt.Call(actor.a.SubmitWindowedPoSt, ¶ms) + }) + rt.Reset() // Advance to end-of-deadline cron to verify no penalties. advanceDeadline(rt, actor, &cronConfig{}) @@ -2167,21 +2008,7 @@ func TestWindowPost(t *testing.T) { sectorsToProve := append(sectors[:actor.partitionSize], lastSector) pwr := miner.PowerForSectors(actor.sectorSize, sectorsToProve) - // Before network version 6, the miner would silently drop the sector infos for the partition already - // proven. This means that the sectors provided for verification would not match the sectors from - // which the proof was constructed by the miner worker, so will be rejected. - rt.SetNetworkVersion(network.Version6) - sectorsSubmitted := []*miner.SectorOnChainInfo{lastSector} // Doesn't match partitions - rt.ExpectAbortContainsMessage(exitcode.ErrIllegalArgument, "invalid PoSt", func() { - actor.submitWindowPoSt(rt, dlinfo, partitions, sectorsSubmitted, &poStConfig{ - expectedPowerDelta: miner.NewPowerPairZero(), - verificationError: fmt.Errorf("wrong sectors"), - }) - }) - rt.Reset() - // From network version 7, the miner outright rejects attempts to prove a partition twice. - rt.SetNetworkVersion(network.Version7) rt.ExpectAbortContainsMessage(exitcode.ErrIllegalArgument, "partition already proven", func() { actor.submitWindowPoSt(rt, dlinfo, partitions, sectorsToProve, &poStConfig{ expectedPowerDelta: pwr, @@ -3074,44 +2901,6 @@ func TestExtendSectorExpiration(t *testing.T) { actor.checkState(rt) }) - t.Run("fails to update deadline expiration queue until nv=7", func(t *testing.T) { - rt := builder.Build(t) - rt.SetNetworkVersion(network.Version6) - // set actor to use proof type valid for nv=6 - proofTypeDefault := actor.sealProofType - actor.sealProofType = abi.RegisteredSealProof_StackedDrg32GiBV1 - defer func() { - actor.sealProofType = proofTypeDefault - }() - oldSector := commitSector(t, rt) - advanceAndSubmitPoSts(rt, actor, oldSector) - - st := getState(rt) - dlIdx, pIdx, err := st.FindSector(rt.AdtStore(), oldSector.SectorNumber) - require.NoError(t, err) - - extension := 42 * miner.WPoStProvingPeriod - newExpiration := oldSector.Expiration + extension - params := &miner.ExtendSectorExpirationParams{ - Extensions: []miner.ExpirationExtension{{ - Deadline: dlIdx, - Partition: pIdx, - Sectors: bf(uint64(oldSector.SectorNumber)), - NewExpiration: newExpiration, - }}, - } - - actor.extendSectors(rt, params) - - // ExtendSectorExpiration fails to update the deadline expiration queue. - st = getState(rt) - _, msgs := miner.CheckStateInvariants(st, rt.AdtStore(), rt.Balance()) - assert.Equal(t, 2, len(msgs.Messages()), strings.Join(msgs.Messages(), "\n")) - for _, msg := range msgs.Messages() { - assert.True(t, strings.Contains(msg, "at epoch 668439")) - } - }) - t.Run("updates many sectors", func(t *testing.T) { rt := builder.Build(t) actor.constructAndVerify(rt) @@ -3509,7 +3298,7 @@ func TestRepayDebts(t *testing.T) { actor.constructAndVerify(rt) rewardAmount := big.Mul(big.NewInt(4), big.NewInt(1e18)) - amountLocked, _ := miner.LockedRewardFromReward(rewardAmount, rt.NetworkVersion()) + amountLocked, _ := miner.LockedRewardFromReward(rewardAmount) rt.SetBalance(amountLocked) actor.applyRewards(rt, rewardAmount, big.Zero()) require.Equal(t, amountLocked, actor.getLockedFunds(rt)) @@ -4383,31 +4172,16 @@ func TestApplyRewards(t *testing.T) { WithBalance(bigBalance, big.Zero()) t.Run("funds are locked", func(t *testing.T) { - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1) - { - rt := builder.Build(t) - rt.SetNetworkVersion(network.Version5) - actor.constructAndVerify(rt) - - rwd := abi.NewTokenAmount(1_000_000) - actor.applyRewards(rt, rwd, big.Zero()) - - assert.Equal(t, rwd, actor.getLockedFunds(rt)) - } - { - rt := builder.Build(t) - rt.SetNetworkVersion(network.Version6) - actor.constructAndVerify(rt) + rt := builder.Build(t) + actor.constructAndVerify(rt) - rwd := abi.NewTokenAmount(1_000_000) - actor.applyRewards(rt, rwd, big.Zero()) + rwd := abi.NewTokenAmount(1_000_000) + actor.applyRewards(rt, rwd, big.Zero()) - expected := abi.NewTokenAmount(750_000) - assert.Equal(t, expected, actor.getLockedFunds(rt)) - } + expected := abi.NewTokenAmount(750_000) + assert.Equal(t, expected, actor.getLockedFunds(rt)) }) - actor.setProofType(abi.RegisteredSealProof_StackedDrg32GiBV1_1) t.Run("funds vest", func(t *testing.T) { rt := builder.Build(t) actor.constructAndVerify(rt) @@ -4446,7 +4220,7 @@ func TestApplyRewards(t *testing.T) { require.EqualValues(t, expectedOffset, int64(vf.Epoch)%int64(miner.RewardVestingSpec.Quantization)) } - lockedAmt, _ := miner.LockedRewardFromReward(amt, rt.NetworkVersion()) + lockedAmt, _ := miner.LockedRewardFromReward(amt) assert.Equal(t, lockedAmt, st.LockedFunds) actor.checkState(rt) }) @@ -4460,7 +4234,7 @@ func TestApplyRewards(t *testing.T) { rt.SetBalance(big.Add(rt.Balance(), rwd)) actor.applyRewards(rt, rwd, penalty) - expectedLockAmt, _ := miner.LockedRewardFromReward(rwd, rt.NetworkVersion()) + expectedLockAmt, _ := miner.LockedRewardFromReward(rwd) expectedLockAmt = big.Sub(expectedLockAmt, penalty) assert.Equal(t, expectedLockAmt, actor.getLockedFunds(rt)) @@ -4530,7 +4304,7 @@ func TestApplyRewards(t *testing.T) { // pledge change is new reward - reward taken for fee debt // 3*LockedRewardFactor*amt - 2*amt = remainingLocked - lockedReward, _ := miner.LockedRewardFromReward(reward, rt.NetworkVersion()) + lockedReward, _ := miner.LockedRewardFromReward(reward) remainingLocked := big.Sub(lockedReward, st.FeeDebt) // note that this would be clamped at 0 if difference above is < 0 pledgeDelta := remainingLocked rt.SetCaller(builtin.RewardActorAddr, builtin.RewardActorCodeID) @@ -5606,7 +5380,7 @@ func (h *actorHarness) applyRewards(rt *mock.Runtime, amt, penalty abi.TokenAmou // We further assume the miner can pay the penalty. If the miner // goes into debt we can't rely on the harness call // TODO unify those cases - lockAmt, _ := miner.LockedRewardFromReward(amt, rt.NetworkVersion()) + lockAmt, _ := miner.LockedRewardFromReward(amt) pledgeDelta := big.Sub(lockAmt, penalty) rt.SetCaller(builtin.RewardActorAddr, builtin.RewardActorCodeID) @@ -5983,7 +5757,7 @@ func makeDeadlineCronEventParams(t testing.TB, epoch abi.ChainEpoch) *power.Enro func makeProveCommit(sectorNo abi.SectorNumber) *miner.ProveCommitSectorParams { return &miner.ProveCommitSectorParams{ SectorNumber: sectorNo, - Proof: []byte("proof"), + Proof: make([]byte, 1920), } } diff --git a/actors/builtin/miner/monies.go b/actors/builtin/miner/monies.go index 42dca847f..dde026dca 100644 --- a/actors/builtin/miner/monies.go +++ b/actors/builtin/miner/monies.go @@ -4,7 +4,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/specs-actors/v3/actors/builtin" "github.com/filecoin-project/specs-actors/v3/actors/util/math" @@ -57,8 +56,8 @@ const TerminationLifetimeCap = 140 // PARAM_SPEC const ConsensusFaultFactor = 5 // Fraction of total reward (block reward + gas reward) to be locked up as of V6 -var LockedRewardFactorNumV6 = big.NewInt(75) -var LockedRewardFactorDenomV6 = big.NewInt(100) +var LockedRewardFactorNum = big.NewInt(75) +var LockedRewardFactorDenom = big.NewInt(100) // The projected block reward a sector would earn over some period. // Also known as "BR(t)". @@ -176,12 +175,8 @@ func ConsensusFaultPenalty(thisEpochReward abi.TokenAmount) abi.TokenAmount { } // Returns the amount of a reward to vest, and the vesting schedule, for a reward amount. -func LockedRewardFromReward(reward abi.TokenAmount, nv network.Version) (abi.TokenAmount, *VestSpec) { - lockAmount := reward - spec := &RewardVestingSpec - if nv >= network.Version6 { - // Locked amount is 75% of award. - lockAmount = big.Div(big.Mul(reward, LockedRewardFactorNumV6), LockedRewardFactorDenomV6) - } - return lockAmount, spec +func LockedRewardFromReward(reward abi.TokenAmount) (abi.TokenAmount, *VestSpec) { + // Locked amount is 75% of award. + lockAmount := big.Div(big.Mul(reward, LockedRewardFactorNum), LockedRewardFactorDenom) + return lockAmount, &RewardVestingSpec } diff --git a/actors/builtin/miner/policy.go b/actors/builtin/miner/policy.go index ba5266649..f626f03e2 100644 --- a/actors/builtin/miner/policy.go +++ b/actors/builtin/miner/policy.go @@ -65,10 +65,8 @@ const ( MaxMultiaddrData = 1024 // PARAM_SPEC ) -// Maximum size of a single prove-commit proof, in bytes. -// The 1024 maximum at network version 4 was an error (the expected size is 1920). -const MaxProveCommitSizeV4 = 1024 -const MaxProveCommitSizeV5 = 10240 +// Maximum size of a single prove-commit proof, in bytes (the expected size is 1920). +const MaxProveCommitSize = 10240 // Maximum number of control addresses a miner may register. const MaxControlAddresses = 10 @@ -123,23 +121,15 @@ func CanPreCommitSealProof(s abi.RegisteredSealProof, nv network.Version) bool { } // List of proof types for which sector lifetime may be extended. -var ExtensibleProofTypesV0 = map[abi.RegisteredSealProof]struct{}{ - abi.RegisteredSealProof_StackedDrg32GiBV1: {}, - abi.RegisteredSealProof_StackedDrg64GiBV1: {}, -} - // From network version 7, sectors sealed with the V1 seal proof types cannot be extended. -var ExtensibleProofTypesV7 = map[abi.RegisteredSealProof]struct{}{ +var ExtensibleProofTypes = map[abi.RegisteredSealProof]struct{}{ abi.RegisteredSealProof_StackedDrg32GiBV1_1: {}, abi.RegisteredSealProof_StackedDrg64GiBV1_1: {}, } // Checks whether a seal proof type is supported for new miners and sectors. -func CanExtendSealProofType(s abi.RegisteredSealProof, nv network.Version) bool { - _, ok := ExtensibleProofTypesV0[s] - if nv >= network.Version7 { - _, ok = ExtensibleProofTypesV7[s] - } +func CanExtendSealProofType(s abi.RegisteredSealProof) bool { + _, ok := ExtensibleProofTypes[s] return ok } diff --git a/actors/builtin/multisig/multisig_actor.go b/actors/builtin/multisig/multisig_actor.go index cc56a4017..a17b963b4 100644 --- a/actors/builtin/multisig/multisig_actor.go +++ b/actors/builtin/multisig/multisig_actor.go @@ -9,7 +9,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/go-state-types/network" multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" @@ -459,8 +458,7 @@ func (a Actor) LockBalance(rt runtime.Runtime, params *LockBalanceParams) *abi.E rt.Abortf(exitcode.ErrIllegalArgument, "unlock duration must be positive") } - nv := rt.NetworkVersion() - if nv >= network.Version7 && params.Amount.LessThan(big.Zero()) { + if params.Amount.LessThan(big.Zero()) { rt.Abortf(exitcode.ErrIllegalArgument, "amount to lock must be positive") } @@ -528,7 +526,6 @@ func executeTransactionIfApproved(rt runtime.Runtime, st State, txnID TxnID, txn var out builtin.CBORBytes var code exitcode.ExitCode applied := false - nv := rt.NetworkVersion() thresholdMet := uint64(len(txn.Approved)) >= st.NumApprovalsThreshold if thresholdMet { @@ -551,19 +548,12 @@ func executeTransactionIfApproved(rt runtime.Runtime, st State, txnID TxnID, txn ptx, err := adt.AsMap(adt.AsStore(rt), st.PendingTxns, builtin.DefaultHamtBitwidth) builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load pending transactions") - // Prior to version 6 we attempt to delete all transactions, even those - // no longer in the pending txns map because they have been purged. - shouldDelete := true // Starting at version 6 we first check if the transaction exists before // deleting. This allows 1 out of n multisig swaps and removes initiated // by the swapped/removed signer to go through without an illegal state error - if nv >= network.Version6 { - txnExists, err := ptx.Has(txnID) - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check existance of transaction %v for cleanup", txnID) - shouldDelete = txnExists - } - - if shouldDelete { + txnExists, err := ptx.Has(txnID) + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check existance of transaction %v for cleanup", txnID) + if txnExists { if err := ptx.Delete(txnID); err != nil { rt.Abortf(exitcode.ErrIllegalState, "failed to delete transaction for cleanup: %v", err) } diff --git a/actors/builtin/multisig/multisig_test.go b/actors/builtin/multisig/multisig_test.go index 1830244b5..09fc93dac 100644 --- a/actors/builtin/multisig/multisig_test.go +++ b/actors/builtin/multisig/multisig_test.go @@ -11,7 +11,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/go-state-types/network" "github.com/minio/blake2b-simd" assert "github.com/stretchr/testify/assert" require "github.com/stretchr/testify/require" @@ -1916,10 +1915,6 @@ func TestLockBalance(t *testing.T) { rt.ExpectAbort(exitcode.ErrIllegalArgument, func() { actor.lockBalance(rt, vestStart, vestDuration, abi.NewTokenAmount(-1)) }) - - // Before version 7, allow negative amount. - rt.SetNetworkVersion(network.Version6) - actor.lockBalance(rt, vestStart, vestDuration, abi.NewTokenAmount(-1)) }) } diff --git a/actors/builtin/power/power_actor.go b/actors/builtin/power/power_actor.go index 0ebe3229b..9cdef0cb1 100644 --- a/actors/builtin/power/power_actor.go +++ b/actors/builtin/power/power_actor.go @@ -8,7 +8,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/go-state-types/network" rtt "github.com/filecoin-project/go-state-types/rt" power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" @@ -137,11 +136,9 @@ func (a Actor) CreateMiner(rt Runtime, params *CreateMinerParams) *CreateMinerRe st.MinerCount += 1 - // starting version 7, call addToClaim to ensure new claim updates all power stats - if rt.NetworkVersion() >= network.Version7 { - err := st.updateStatsForNewMiner(params.SealProofType) - builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed update power stats for new miner %v", addresses.IDAddress) - } + // Ensure new claim updates all power stats + err = st.updateStatsForNewMiner(params.SealProofType) + builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed update power stats for new miner %v", addresses.IDAddress) st.Claims, err = claims.Root() builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to flush claims") @@ -494,10 +491,8 @@ func (a Actor) processDeferredCronEvents(rt Runtime) { continue } - // Starting version 7, decrement miner count to keep stats consistent. - if rt.NetworkVersion() >= network.Version7 { - st.MinerCount-- - } + // Decrement miner count to keep stats consistent. + st.MinerCount-- } st.Claims, err = claims.Root() diff --git a/actors/builtin/power/power_test.go b/actors/builtin/power/power_test.go index 50553cd22..1aa2bca89 100644 --- a/actors/builtin/power/power_test.go +++ b/actors/builtin/power/power_test.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "github.com/filecoin-project/go-state-types/network" "strconv" "strings" "testing" @@ -13,6 +12,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/exitcode" + "github.com/filecoin-project/go-state-types/network" cid "github.com/ipfs/go-cid" assert "github.com/stretchr/testify/assert" require "github.com/stretchr/testify/require" @@ -326,20 +326,12 @@ func TestPowerAndPledgeAccounting(t *testing.T) { actor.checkState(rt) }) - t.Run("after version 7, new miner updates MinerAboveMinPowerCount", func(t *testing.T) { + t.Run("new miner updates MinerAboveMinPowerCount", func(t *testing.T) { for _, test := range []struct { version network.Version proof abi.RegisteredSealProof expectedMiners int64 }{{ - version: network.Version6, - proof: abi.RegisteredSealProof_StackedDrg2KiBV1, // 2K sectors have zero consensus minimum - expectedMiners: 0, - }, { - version: network.Version6, - proof: abi.RegisteredSealProof_StackedDrg32GiBV1, - expectedMiners: 0, - }, { version: network.Version7, proof: abi.RegisteredSealProof_StackedDrg2KiBV1, // 2K sectors have zero consensus minimum expectedMiners: 1, @@ -780,6 +772,9 @@ func TestCron(t *testing.T) { require.NoError(t, err) assert.False(t, found) + // miner count has been reduced to 1 + assert.Equal(t, int64(1), st.MinerCount) + // Next epoch, only the reward actor is invoked rt.SetEpoch(3) rt.ExpectValidateCallerAddr(builtin.CronActorAddr) @@ -791,58 +786,6 @@ func TestCron(t *testing.T) { rt.Verify() actor.checkState(rt) }) - - t.Run("failed call decrements miner count at network version 7", func(t *testing.T) { - for _, test := range []struct { - version network.Version - versionLabel string - expectedMinerCount int64 - }{{ - version: network.Version6, - versionLabel: "Version6", - expectedMinerCount: 1, - }, { - version: network.Version7, - versionLabel: "Version7", - expectedMinerCount: 0, - }} { - rt := builder.WithNetworkVersion(test.version).Build(t) - rt.NetworkVersion() - actor.constructAndVerify(rt) - - rt.SetEpoch(1) - actor.createMinerBasic(rt, owner, owner, miner1) - - // expect one miner - st := getState(rt) - assert.Equal(t, int64(1), st.MinerCount) - - actor.enrollCronEvent(rt, miner1, 1, []byte{}) - - rt.SetEpoch(2) - rt.ExpectValidateCallerAddr(builtin.CronActorAddr) - - // process batch verifies first - rt.ExpectBatchVerifySeals(nil, nil, nil) - - // send fails - rt.ExpectSend(miner1, builtin.MethodsMiner.OnDeferredCronEvent, builtin.CBORBytes(nil), big.Zero(), nil, exitcode.ErrIllegalState) - - // Reward actor still invoked - power := abi.NewStoragePower(0) - rt.ExpectSend(builtin.RewardActorAddr, builtin.MethodsReward.UpdateNetworkKPI, &power, big.Zero(), nil, exitcode.Ok) - rt.SetCaller(builtin.CronActorAddr, builtin.CronActorCodeID) - rt.Call(actor.Actor.OnEpochTickEnd, nil) - rt.Verify() - - // expect cron failure was logged - rt.ExpectLogsContain("OnDeferredCronEvent failed for miner") - - // miner count has been changed or not depending on version - st = getState(rt) - assert.Equal(t, test.expectedMinerCount, st.MinerCount) - } - }) } func TestSubmitPoRepForBulkVerify(t *testing.T) { diff --git a/actors/test/multisig_delete_self_test.go b/actors/test/multisig_delete_self_test.go index 8e7686a6d..3a97e5e9b 100644 --- a/actors/test/multisig_delete_self_test.go +++ b/actors/test/multisig_delete_self_test.go @@ -11,7 +11,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/specs-actors/v3/actors/builtin" init_ "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" @@ -19,58 +18,9 @@ import ( vm "github.com/filecoin-project/specs-actors/v3/support/vm" ) -func TestV5MultisigDeleteSigner1Of2(t *testing.T) { +func TestMultisigDeleteSelf2Of3RemovedIsProposer(t *testing.T) { ctx := context.Background() v := vm.NewVMWithSingletons(ctx, t) - v, err := v.WithNetworkVersion(network.Version5) - require.NoError(t, err) - addrs := vm.CreateAccounts(ctx, t, v, 2, big.Mul(big.NewInt(10_000), big.NewInt(1e18)), 93837778) - - multisigParams := multisig.ConstructorParams{ - Signers: addrs, - NumApprovalsThreshold: 1, - } - - paramBuf := new(bytes.Buffer) - err = multisigParams.MarshalCBOR(paramBuf) - require.NoError(t, err) - - initParam := init_.ExecParams{ - CodeCID: builtin.MultisigActorCodeID, - ConstructorParams: paramBuf.Bytes(), - } - ret := vm.ApplyOk(t, v, addrs[0], builtin.InitActorAddr, big.Zero(), builtin.MethodsPower.CreateMiner, &initParam) - initRet := ret.(*init_.ExecReturn) - assert.NotNil(t, initRet) - multisigAddr := initRet.IDAddress - - removeParams := multisig.RemoveSignerParams{ - Signer: addrs[0], - Decrease: false, - } - - paramBuf = new(bytes.Buffer) - err = removeParams.MarshalCBOR(paramBuf) - require.NoError(t, err) - - proposeRemoveSignerParams := multisig.ProposeParams{ - To: multisigAddr, - Value: big.Zero(), - Method: builtin.MethodsMultisig.RemoveSigner, - Params: paramBuf.Bytes(), - } - // address 0 fails when trying to execute the transaction removing address 0 - _, code := v.ApplyMessage(addrs[0], multisigAddr, big.Zero(), builtin.MethodsMultisig.Propose, &proposeRemoveSignerParams) - assert.Equal(t, exitcode.ErrIllegalState, code) - // address 1 succeeds when trying to execute the transaction removing address 0 - vm.ApplyOk(t, v, addrs[1], multisigAddr, big.Zero(), builtin.MethodsMultisig.Propose, &proposeRemoveSignerParams) -} - -func TestV5MultisigDeleteSelf2Of3RemovedIsProposer(t *testing.T) { - ctx := context.Background() - v := vm.NewVMWithSingletons(ctx, t) - v, err := v.WithNetworkVersion(network.Version5) - require.NoError(t, err) addrs := vm.CreateAccounts(ctx, t, v, 3, big.Mul(big.NewInt(10_000), big.NewInt(1e18)), 93837778) multisigParams := multisig.ConstructorParams{ @@ -79,7 +29,7 @@ func TestV5MultisigDeleteSelf2Of3RemovedIsProposer(t *testing.T) { } paramBuf := new(bytes.Buffer) - err = multisigParams.MarshalCBOR(paramBuf) + err := multisigParams.MarshalCBOR(paramBuf) require.NoError(t, err) initParam := init_.ExecParams{ @@ -119,11 +69,9 @@ func TestV5MultisigDeleteSelf2Of3RemovedIsProposer(t *testing.T) { } -func TestV5MultisigDeleteSelf2Of3RemovedIsApprover(t *testing.T) { +func TestMultisigDeleteSelf2Of3RemovedIsApprover(t *testing.T) { ctx := context.Background() v := vm.NewVMWithSingletons(ctx, t) - v, err := v.WithNetworkVersion(network.Version5) - require.NoError(t, err) addrs := vm.CreateAccounts(ctx, t, v, 3, big.Mul(big.NewInt(10_000), big.NewInt(1e18)), 93837778) multisigParams := multisig.ConstructorParams{ @@ -132,7 +80,7 @@ func TestV5MultisigDeleteSelf2Of3RemovedIsApprover(t *testing.T) { } paramBuf := new(bytes.Buffer) - err = multisigParams.MarshalCBOR(paramBuf) + err := multisigParams.MarshalCBOR(paramBuf) require.NoError(t, err) initParam := init_.ExecParams{ @@ -172,11 +120,9 @@ func TestV5MultisigDeleteSelf2Of3RemovedIsApprover(t *testing.T) { } -func TestV5MultisigDeleteSelf2Of2(t *testing.T) { +func TestMultisigDeleteSelf2Of2(t *testing.T) { ctx := context.Background() v := vm.NewVMWithSingletons(ctx, t) - v, err := v.WithNetworkVersion(network.Version5) - require.NoError(t, err) addrs := vm.CreateAccounts(ctx, t, v, 2, big.Mul(big.NewInt(10_000), big.NewInt(1e18)), 93837778) multisigParams := multisig.ConstructorParams{ @@ -185,7 +131,7 @@ func TestV5MultisigDeleteSelf2Of2(t *testing.T) { } paramBuf := new(bytes.Buffer) - err = multisigParams.MarshalCBOR(paramBuf) + err := multisigParams.MarshalCBOR(paramBuf) require.NoError(t, err) initParam := init_.ExecParams{ @@ -223,63 +169,9 @@ func TestV5MultisigDeleteSelf2Of2(t *testing.T) { assert.Equal(t, exitcode.ErrNotFound, code) } -func TestV5MultisigSwapsSelf1Of2(t *testing.T) { +func TestMultisigSwapsSelf2Of3(t *testing.T) { ctx := context.Background() v := vm.NewVMWithSingletons(ctx, t) - v, err := v.WithNetworkVersion(network.Version5) - require.NoError(t, err) - addrs := vm.CreateAccounts(ctx, t, v, 3, big.Mul(big.NewInt(10_000), big.NewInt(1e18)), 93837778) - alice := addrs[0] - bob := addrs[1] - chuck := addrs[2] - - multisigParams := multisig.ConstructorParams{ - Signers: []address.Address{alice, bob}, - NumApprovalsThreshold: 1, - } - - paramBuf := new(bytes.Buffer) - err = multisigParams.MarshalCBOR(paramBuf) - require.NoError(t, err) - - initParam := init_.ExecParams{ - CodeCID: builtin.MultisigActorCodeID, - ConstructorParams: paramBuf.Bytes(), - } - ret := vm.ApplyOk(t, v, addrs[0], builtin.InitActorAddr, big.Zero(), builtin.MethodsPower.CreateMiner, &initParam) - initRet := ret.(*init_.ExecReturn) - assert.NotNil(t, initRet) - multisigAddr := initRet.IDAddress - - swapParams := multisig.SwapSignerParams{ - From: alice, - To: chuck, - } - - paramBuf = new(bytes.Buffer) - err = swapParams.MarshalCBOR(paramBuf) - require.NoError(t, err) - - proposeSwapSignerParams := multisig.ProposeParams{ - To: multisigAddr, - Value: big.Zero(), - Method: builtin.MethodsMultisig.SwapSigner, - Params: paramBuf.Bytes(), - } - - // alice fails when trying to execute the transaction swapping alice for chuck - _, code := v.ApplyMessage(alice, multisigAddr, big.Zero(), builtin.MethodsMultisig.Propose, &proposeSwapSignerParams) - assert.Equal(t, exitcode.ErrIllegalState, code) - // bob succeeds when trying to execute the transaction swapping alice for chuck - vm.ApplyOk(t, v, bob, multisigAddr, big.Zero(), builtin.MethodsMultisig.Propose, &proposeSwapSignerParams) - -} - -func TestV5MultisigSwapsSelf2Of3(t *testing.T) { - ctx := context.Background() - v := vm.NewVMWithSingletons(ctx, t) - v, err := v.WithNetworkVersion(network.Version5) - require.NoError(t, err) addrs := vm.CreateAccounts(ctx, t, v, 4, big.Mul(big.NewInt(10_000), big.NewInt(1e18)), 93837778) alice := addrs[0] bob := addrs[1] @@ -292,7 +184,7 @@ func TestV5MultisigSwapsSelf2Of3(t *testing.T) { } paramBuf := new(bytes.Buffer) - err = multisigParams.MarshalCBOR(paramBuf) + err := multisigParams.MarshalCBOR(paramBuf) require.NoError(t, err) initParam := init_.ExecParams{ @@ -440,5 +332,4 @@ func TestMultisigSwapsSelf1Of2(t *testing.T) { // alice succeeds when trying to execute the transaction swapping alice for chuck vm.ApplyOk(t, v, alice, multisigAddr, big.Zero(), builtin.MethodsMultisig.Propose, &proposeSwapSignerParams) - }