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

Commit

Permalink
Temporary param update (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
zixuanzh authored and aarshkshah1992 committed Jun 29, 2020
1 parent d6f6f16 commit d549797
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
9 changes: 7 additions & 2 deletions actors/builtin/market/policy.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package market

import "github.com/filecoin-project/specs-actors/actors/abi"
import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
)

// DealUpdatesInterval is the number of blocks between payouts for deals
const DealUpdatesInterval = 100

// Bounds (inclusive) on deal duration
func dealDurationBounds(size abi.PaddedPieceSize) (min abi.ChainEpoch, max abi.ChainEpoch) {
return abi.ChainEpoch(0), abi.ChainEpoch(10000) // PARAM_FINISH
// Cryptoeconomic modelling to date has used an assumption of a maximum deal duration of up to one year.
// It very likely can be much longer, but we're not sure yet.
return abi.ChainEpoch(0), abi.ChainEpoch(1 * builtin.EpochsInYear) // PARAM_FINISH
}

func dealPricePerEpochBounds(size abi.PaddedPieceSize, duration abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount) {
Expand Down
19 changes: 7 additions & 12 deletions actors/builtin/miner/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ import (
"fmt"

abi "github.com/filecoin-project/specs-actors/actors/abi"
builtin "github.com/filecoin-project/specs-actors/actors/builtin"
big "github.com/filecoin-project/specs-actors/actors/abi/big"
)

// The duration of a chain epoch.
// This is used for deriving epoch-denominated periods that are more naturally expressed in clock time.
const EpochDurationSeconds = 25
const SecondsInYear = 31556925
const SecondsInDay = 86400

// The period over which all a miner's active sectors will be challenged.
const WPoStProvingPeriod = abi.ChainEpoch(SecondsInDay / EpochDurationSeconds)
const WPoStProvingPeriod = abi.ChainEpoch(builtin.EpochsInDay) // 24 hours

// The duration of a deadline's challenge window, the period before a deadline when the challenge is available.
const WPoStChallengeWindow = abi.ChainEpoch(1800 / EpochDurationSeconds) // Half an hour (=48 per day)
const WPoStChallengeWindow = abi.ChainEpoch(1800 / builtin.EpochDurationSeconds) // Half an hour (=48 per day)

// The number of non-overlapping PoSt deadlines in each proving period.
const WPoStPeriodDeadlines = uint64(WPoStProvingPeriod / WPoStChallengeWindow)
Expand Down Expand Up @@ -130,10 +125,10 @@ type VestSpec struct {
}

var PledgeVestingSpec = VestSpec{
InitialDelay: abi.ChainEpoch(SecondsInYear / EpochDurationSeconds), // 1 year, PARAM_FINISH
VestPeriod: abi.ChainEpoch(SecondsInYear / EpochDurationSeconds), // 1 year, PARAM_FINISH
StepDuration: abi.ChainEpoch(7 * SecondsInDay / EpochDurationSeconds), // 1 week, PARAM_FINISH
Quantization: SecondsInDay / EpochDurationSeconds, // 1 day, PARAM_FINISH
InitialDelay: abi.ChainEpoch(7 * builtin.EpochsInDay), // 1 week for testnet, PARAM_FINISH
VestPeriod: abi.ChainEpoch(7 * builtin.EpochsInDay), // 1 week for testnet, PARAM_FINISH
StepDuration: abi.ChainEpoch(1 * builtin.EpochsInDay), // 1 day for testnet, PARAM_FINISH
Quantization: 12 * builtin.EpochsInHour, // 12 hours for testnet, PARAM_FINISH
}

func rewardForConsensusSlashReport(elapsedEpoch abi.ChainEpoch, collateral abi.TokenAmount) abi.TokenAmount {
Expand Down
27 changes: 27 additions & 0 deletions actors/builtin/network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package builtin

import "fmt"

// The duration of a chain epoch.
// This is used for deriving epoch-denominated periods that are more naturally expressed in clock time.
// TODO: In lieu of a real configuration mechanism for this value, we'd like to make it a var so that implementations
// can override it at runtime. Doing so requires changing all the static references to it in this repo to go through
// late-binding function calls, or they'll see the "wrong" value.
// https://github.com/filecoin-project/specs-actors/issues/353
const EpochDurationSeconds = 25
const SecondsInHour = 3600
const SecondsInDay = 86400
const SecondsInYear = 31556925
const EpochsInHour = SecondsInHour / EpochDurationSeconds
const EpochsInDay = SecondsInDay / EpochDurationSeconds
const EpochsInYear = SecondsInYear / EpochDurationSeconds

func init() {
//noinspection GoBoolExpressions
if SecondsInHour % EpochDurationSeconds != 0 {
// This even division is an assumption that other code might unwittingly make.
// Don't rely on it on purpose, though.
// While we're pretty sure everything will still work fine, we're safer maintaining this invariant anyway.
panic(fmt.Sprintf("epoch duration %d does not evenly divide one hour (%d)", EpochDurationSeconds, SecondsInHour))
}
}
7 changes: 4 additions & 3 deletions actors/builtin/reward/reward_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ func (a Actor) computePerEpochReward(st *State, clockTime abi.ChainEpoch, networ
return perEpochReward
}

const baselinePower = 1 << 50 // 1PiB for testnet, PARAM_FINISH
func (a Actor) newBaselinePower(st *State) abi.StoragePower {
// TODO: this is not the final baseline
return big.NewInt(1 << 60)
// TODO: this is not the final baseline function or value, PARAM_FINISH
return big.NewInt(baselinePower)
}

func (a Actor) getEffectiveNetworkTime(st *State, cumsumBaseline abi.Spacetime, cumsumRealized abi.Spacetime) abi.ChainEpoch {
// TODO: this function depends on the final baseline
realizedCumsum := big.Min(cumsumBaseline, cumsumRealized)
return abi.ChainEpoch(big.Div(realizedCumsum, big.NewInt(1<<60)).Int64())
return abi.ChainEpoch(big.Div(realizedCumsum, big.NewInt(baselinePower)).Int64())
}

func (a Actor) UpdateNetworkKPI(rt vmr.Runtime, currRealizedPower *abi.StoragePower) *adt.EmptyValue {
Expand Down
6 changes: 3 additions & 3 deletions actors/builtin/reward/reward_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ type State struct {

type AddrKey = adt.AddrKey

// These numbers are placeholders, but should be in units of attoFIL
var SimpleTotal, _ = big.FromString("1000000000000000000000000")
var BaselineTotal, _ = big.FromString("1000000000000000000000000")
// These numbers are placeholders, but should be in units of attoFIL, 10^-18 FIL
var SimpleTotal = big.Mul(big.NewInt(100e6), big.NewInt(1e18)) // 100M for testnet, PARAM_FINISH
var BaselineTotal = big.Mul(big.NewInt(900e6), big.NewInt(1e18)) // 900M for testnet, PARAM_FINISH

func ConstructState(emptyMultiMapCid cid.Cid) *State {
return &State{
Expand Down

0 comments on commit d549797

Please sign in to comment.