From a45699b0e38ae44d706aed2ff0ce796d7c210d58 Mon Sep 17 00:00:00 2001 From: Claudia Richoux Date: Wed, 22 Sep 2021 16:47:22 -0500 Subject: [PATCH] integrating code review --- actors/builtin/miner/miner_actor.go | 29 ++++++++++------------------- actors/builtin/power/power_actor.go | 5 ++--- actors/builtin/power/power_test.go | 4 ++-- actors/test/power_scenario_test.go | 4 ++-- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/actors/builtin/miner/miner_actor.go b/actors/builtin/miner/miner_actor.go index 12509850e..c261dc5c5 100644 --- a/actors/builtin/miner/miner_actor.go +++ b/actors/builtin/miner/miner_actor.go @@ -956,12 +956,8 @@ func (a Actor) ProveCommitAggregate(rt Runtime, params *ProveCommitAggregatePara }) builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "aggregate seal verify failed") - 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 power.CurrentTotalPowerReturn - powretcode := rt.Send(builtin.StoragePowerActorAddr, builtin.MethodsPower.CurrentTotalPower, nil, big.Zero(), &pwr) - builtin.RequireSuccess(rt, powretcode, "failed to check current power") + rewret := requestCurrentEpochBlockReward(rt) + pwr := requestCurrentTotalPower(rt) confirmSectorProofsValid(rt, precommitsToConfirm, rewret.ThisEpochBaselinePower, rewret.ThisEpochRewardSmoothed, pwr.QualityAdjPowerSmoothed) @@ -1069,19 +1065,14 @@ 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, - params.RewardStatsThisEpochBaselinePower, - params.RewardStatsThisEpochRewardSmoothed, - params.PwrTotalQualityAdjPowerSmoothed) + confirmSectorProofsValid(rt, precommittedSectors, params.RewardStatsThisEpochBaselinePower, + params.RewardStatsThisEpochRewardSmoothed, params.PwrTotalQualityAdjPowerSmoothed) return nil } -func confirmSectorProofsValid(rt Runtime, - preCommits []*SectorPreCommitOnChainInfo, - rewardStatsThisEpochBaselinePower big.Int, - rewardStatsThisEpochRewardSmoothed smoothing.FilterEstimate, - pwrTotalQualityAdjPowerSmoothed smoothing.FilterEstimate) { +func confirmSectorProofsValid(rt Runtime, preCommits []*SectorPreCommitOnChainInfo, thisEpochBaselinePower big.Int, + thisEpochRewardSmoothed smoothing.FilterEstimate, qualityAdjPowerSmoothed smoothing.FilterEstimate) { circulatingSupply := rt.TotalFilCircSupply() @@ -1166,13 +1157,13 @@ func confirmSectorProofsValid(rt Runtime, } pwr := QAPowerForWeight(info.SectorSize, duration, precommit.DealWeight, precommit.VerifiedDealWeight) - dayReward := ExpectedRewardForPower(rewardStatsThisEpochRewardSmoothed, pwrTotalQualityAdjPowerSmoothed, 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(rewardStatsThisEpochRewardSmoothed, pwrTotalQualityAdjPowerSmoothed, pwr, InitialPledgeProjectionPeriod) - initialPledge := InitialPledgeForPower(pwr, rewardStatsThisEpochBaselinePower, rewardStatsThisEpochRewardSmoothed, - pwrTotalQualityAdjPowerSmoothed, 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. diff --git a/actors/builtin/power/power_actor.go b/actors/builtin/power/power_actor.go index 50ba7fb48..e7a4875df 100644 --- a/actors/builtin/power/power_actor.go +++ b/actors/builtin/power/power_actor.go @@ -10,8 +10,6 @@ import ( "github.com/filecoin-project/go-state-types/exitcode" rtt "github.com/filecoin-project/go-state-types/rt" - //"github.com/filecoin-project/specs-actors/actors/builtin/power" - power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" "github.com/ipfs/go-cid" @@ -427,7 +425,8 @@ 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}, diff --git a/actors/builtin/power/power_test.go b/actors/builtin/power/power_test.go index a8676e077..f43d19108 100644 --- a/actors/builtin/power/power_test.go +++ b/actors/builtin/power/power_test.go @@ -1114,8 +1114,8 @@ func newHarness(t *testing.T) *spActorHarness { t: t, sealProof: abi.RegisteredSealProof_StackedDrg32GiBV1_1, windowPoStProof: abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, - thisEpochBaselinePower: abi.NewStoragePower(1 << 50), // XXX: unsure if this is right - thisEpochRewardSmoothed: smoothing.TestingConstantEstimate(rwd), // XXX: unsure if this is right + thisEpochBaselinePower: abi.NewStoragePower(1 << 50), + thisEpochRewardSmoothed: smoothing.TestingConstantEstimate(rwd), } } diff --git a/actors/test/power_scenario_test.go b/actors/test/power_scenario_test.go index 6fb7b14fb..1a16d662f 100644 --- a/actors/test/power_scenario_test.go +++ b/actors/test/power_scenario_test.go @@ -111,7 +111,7 @@ func TestOnEpochTickEnd(t *testing.T) { To: builtin.StoragePowerActorAddr, Method: builtin.MethodsPower.OnEpochTickEnd, SubInvocations: []vm.ExpectInvocation{ - // get data from reward and power actors for any eventual calls to confirmsectorproofsparams + // get data from reward and power actors for any eventual calls to confirmsectorproofvalid {To: builtin.RewardActorAddr, Method: builtin.MethodsReward.ThisEpochReward}, {To: builtin.StoragePowerActorAddr, Method: builtin.MethodsPower.CurrentTotalPower}, { @@ -136,7 +136,7 @@ func TestOnEpochTickEnd(t *testing.T) { To: builtin.StoragePowerActorAddr, Method: builtin.MethodsPower.OnEpochTickEnd, SubInvocations: []vm.ExpectInvocation{ - // get data from reward and power actors for any eventual calls to confirmsectorproofsparams + // get data from reward and power actors for any eventual calls to confirmsectorproofsvalid {To: builtin.RewardActorAddr, Method: builtin.MethodsReward.ThisEpochReward}, {To: builtin.StoragePowerActorAddr, Method: builtin.MethodsPower.CurrentTotalPower}, {