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

Commit

Permalink
integrating code review
Browse files Browse the repository at this point in the history
  • Loading branch information
laudiacay committed Sep 22, 2021
1 parent 42282b0 commit a45699b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
29 changes: 10 additions & 19 deletions actors/builtin/miner/miner_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions actors/builtin/power/power_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions actors/builtin/power/power_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down
4 changes: 2 additions & 2 deletions actors/test/power_scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
{
Expand All @@ -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},
{
Expand Down

0 comments on commit a45699b

Please sign in to comment.