Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

fixing #799 (passing in data for confirmSectorProofValid) #1480

Merged
merged 12 commits into from
Sep 23, 2021
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
digest

# Test binary, built with `go test -c`
*.test
Expand Down
126 changes: 126 additions & 0 deletions actors/builtin/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions actors/builtin/miner/miner_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,11 @@ func (a Actor) ProveCommitAggregate(rt Runtime, params *ProveCommitAggregatePara
AggregateProof: abi.RegisteredAggregationProof_SnarkPackV1,
})
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "aggregate seal verify failed")
confirmSectorProofsValid(rt, precommitsToConfirm)

rewret := requestCurrentEpochBlockReward(rt)
pwr := requestCurrentTotalPower(rt)

confirmSectorProofsValid(rt, precommitsToConfirm, rewret.ThisEpochBaselinePower, rewret.ThisEpochRewardSmoothed, pwr.QualityAdjPowerSmoothed)

// Compute and burn the aggregate network fee. We need to re-load the state as
// confirmSectorProofsValid can change it.
Expand Down Expand Up @@ -1061,15 +1065,15 @@ func (a Actor) ConfirmSectorProofsValid(rt Runtime, params *builtin.ConfirmSecto
precommittedSectors, err := st.FindPrecommittedSectors(store, params.Sectors...)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load pre-committed sectors")

confirmSectorProofsValid(rt, precommittedSectors)
confirmSectorProofsValid(rt, precommittedSectors, params.RewardStatsThisEpochBaselinePower,
params.RewardStatsThisEpochRewardSmoothed, params.PwrTotalQualityAdjPowerSmoothed)

return nil
}

func confirmSectorProofsValid(rt Runtime, preCommits []*SectorPreCommitOnChainInfo) {
// get network stats from other actors
rewardStats := requestCurrentEpochBlockReward(rt)
pwrTotal := requestCurrentTotalPower(rt)
func confirmSectorProofsValid(rt Runtime, preCommits []*SectorPreCommitOnChainInfo, thisEpochBaselinePower big.Int,
thisEpochRewardSmoothed smoothing.FilterEstimate, qualityAdjPowerSmoothed smoothing.FilterEstimate) {

circulatingSupply := rt.TotalFilCircSupply()

// 1. Activate deals, skipping pre-commits with invalid deals.
Expand Down Expand Up @@ -1152,13 +1156,14 @@ func confirmSectorProofsValid(rt Runtime, preCommits []*SectorPreCommitOnChainIn
continue
}
pwr := QAPowerForWeight(info.SectorSize, duration, precommit.DealWeight, precommit.VerifiedDealWeight)
dayReward := ExpectedRewardForPower(rewardStats.ThisEpochRewardSmoothed, pwrTotal.QualityAdjPowerSmoothed, pwr, builtin.EpochsInDay)

dayReward := ExpectedRewardForPower(thisEpochRewardSmoothed, qualityAdjPowerSmoothed, pwr, builtin.EpochsInDay)
// The storage pledge is recorded for use in computing the penalty if this sector is terminated
// before its declared expiration.
// It's not capped to 1 FIL, so can exceed the actual initial pledge requirement.
storagePledge := ExpectedRewardForPower(rewardStats.ThisEpochRewardSmoothed, pwrTotal.QualityAdjPowerSmoothed, pwr, InitialPledgeProjectionPeriod)
initialPledge := InitialPledgeForPower(pwr, rewardStats.ThisEpochBaselinePower, rewardStats.ThisEpochRewardSmoothed,
pwrTotal.QualityAdjPowerSmoothed, circulatingSupply)
storagePledge := ExpectedRewardForPower(thisEpochRewardSmoothed, qualityAdjPowerSmoothed, pwr, InitialPledgeProjectionPeriod)
initialPledge := InitialPledgeForPower(pwr, thisEpochBaselinePower, thisEpochRewardSmoothed,
qualityAdjPowerSmoothed, circulatingSupply)

// Lower-bound the pledge by that of the sector being replaced.
// Record the replaced age and reward rate for termination fee calculations.
Expand Down
13 changes: 9 additions & 4 deletions actors/builtin/miner/miner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5029,6 +5029,8 @@ func (h *actorHarness) proveCommitAggregateSector(rt *mock.Runtime, conf proveCo
}
rt.ExpectSend(builtin.StorageMarketActorAddr, builtin.MethodsMarket.ComputeDataCommitment, &cdcParams, big.Zero(), &cdcRet, exitcode.Ok)
}
expectQueryNetworkInfo(rt, h)

// Expect randomness queries for provided precommits
var sealRands []abi.SealRandomness
var sealIntRands []abi.InteractiveSealRandomness
Expand Down Expand Up @@ -5089,9 +5091,6 @@ func (h *actorHarness) proveCommitAggregateSector(rt *mock.Runtime, conf proveCo
}

func (h *actorHarness) confirmSectorProofsValidInternal(rt *mock.Runtime, conf proveCommitConf, precommits ...*miner.SectorPreCommitOnChainInfo) {
// expect calls to get network stats
expectQueryNetworkInfo(rt, h)

// Prepare for and receive call to ConfirmSectorProofsValid.
var validPrecommits []*miner.SectorPreCommitOnChainInfo
for _, precommit := range precommits {
Expand Down Expand Up @@ -5152,7 +5151,13 @@ func (h *actorHarness) confirmSectorProofsValid(rt *mock.Runtime, conf proveComm
}
rt.SetCaller(builtin.StoragePowerActorAddr, builtin.StoragePowerActorCodeID)
rt.ExpectValidateCallerAddr(builtin.StoragePowerActorAddr)
rt.Call(h.a.ConfirmSectorProofsValid, &builtin.ConfirmSectorProofsParams{Sectors: allSectorNumbers})

rt.Call(h.a.ConfirmSectorProofsValid, &builtin.ConfirmSectorProofsParams{
Sectors: allSectorNumbers,
RewardStatsThisEpochRewardSmoothed: h.epochRewardSmooth,
RewardStatsThisEpochBaselinePower: h.baselinePower,
PwrTotalQualityAdjPowerSmoothed: h.epochQAPowerSmooth,
})
rt.Verify()
}

Expand Down
16 changes: 15 additions & 1 deletion actors/builtin/power/power_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/exitcode"
rtt "github.com/filecoin-project/go-state-types/rt"

power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/specs-actors/v6/actors/builtin"
initact "github.com/filecoin-project/specs-actors/v6/actors/builtin/init"
"github.com/filecoin-project/specs-actors/v6/actors/builtin/reward"
"github.com/filecoin-project/specs-actors/v6/actors/runtime"
"github.com/filecoin-project/specs-actors/v6/actors/runtime/proof"
"github.com/filecoin-project/specs-actors/v6/actors/util/adt"
Expand Down Expand Up @@ -386,6 +388,14 @@ func (a Actor) processBatchProofVerifies(rt Runtime) {
res, err := rt.BatchVerifySeals(verifies)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to batch verify")

var rewret reward.ThisEpochRewardReturn
rewretcode := rt.Send(builtin.RewardActorAddr, builtin.MethodsReward.ThisEpochReward, nil, big.Zero(), &rewret)
builtin.RequireSuccess(rt, rewretcode, "failed to check epoch baseline power")

var pwr CurrentTotalPowerReturn
powretcode := rt.Send(builtin.StoragePowerActorAddr, builtin.MethodsPower.CurrentTotalPower, nil, big.Zero(), &pwr)
laudiacay marked this conversation as resolved.
Show resolved Hide resolved
builtin.RequireSuccess(rt, powretcode, "failed to check current power")

for _, m := range miners {
vres, ok := res[m]
if !ok {
Expand Down Expand Up @@ -415,7 +425,11 @@ func (a Actor) processBatchProofVerifies(rt Runtime) {
_ = rt.Send(
m,
builtin.MethodsMiner.ConfirmSectorProofsValid,
&builtin.ConfirmSectorProofsParams{Sectors: successful},
&builtin.ConfirmSectorProofsParams{
Sectors: successful,
RewardStatsThisEpochRewardSmoothed: rewret.ThisEpochRewardSmoothed,
RewardStatsThisEpochBaselinePower: rewret.ThisEpochBaselinePower,
PwrTotalQualityAdjPowerSmoothed: pwr.QualityAdjPowerSmoothed},
abi.NewTokenAmount(0),
&builtin.Discard{},
)
Expand Down
Loading