From de392ca14121d254ca266ada13a7ed7bcde2c236 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 17 Jun 2020 03:42:05 +0200 Subject: [PATCH 1/3] Add ChargeGas method to Runtime (#493) It will be used in the current effort of setting sane values for gas. Virtual gas is added for observing how changes to gas numbers affect the balance without affecting the stateroot of the chain. Signed-off-by: Jakub Sztandera --- actors/runtime/runtime.go | 7 +++++++ support/mock/mockrt.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/actors/runtime/runtime.go b/actors/runtime/runtime.go index 22700d889..1d27bfe71 100644 --- a/actors/runtime/runtime.go +++ b/actors/runtime/runtime.go @@ -87,6 +87,13 @@ type Runtime interface { // Starts a new tracing span. The span must be End()ed explicitly, typically with a deferred invocation. StartSpan(name string) TraceSpan + + // ChargeGas charges specified amount of `gas` for execution. + // `name` provides information about gas charging point + // `virtual` sets virtual amount of gas to charge, this amount is not counted + // toward execution cost. This functionality is used for observing global changes + // in total gas charged if amount of gas charged was to be changed. + ChargeGas(name string, gas int64, virtual int64) } // Store defines the storage module exposed to actors. diff --git a/support/mock/mockrt.go b/support/mock/mockrt.go index 30bbfecff..9b3172aad 100644 --- a/support/mock/mockrt.go +++ b/support/mock/mockrt.go @@ -803,6 +803,8 @@ func (rt *Runtime) TotalFilCircSupply() abi.TokenAmount { panic("todo crypto econ") } +func (rt *Runtime) ChargeGas(_ string, _, _ int64) {} + type ReturnWrapper struct { V runtime.CBORMarshaler } From 2cd72643a5cf921c3f4ff609191cd54cb396f09c Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 2 Jul 2020 19:08:46 +0200 Subject: [PATCH 2/3] Make order deterministic Signed-off-by: Jakub Sztandera --- actors/builtin/miner/miner_state.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/actors/builtin/miner/miner_state.go b/actors/builtin/miner/miner_state.go index 7434331a9..46da0f5cb 100644 --- a/actors/builtin/miner/miner_state.go +++ b/actors/builtin/miner/miner_state.go @@ -3,6 +3,7 @@ package miner import ( "fmt" "reflect" + "sort" addr "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" @@ -577,7 +578,17 @@ func (st *State) RemoveFaults(store adt.Store, sectorNos *abi.BitField) error { return err } - for i, newFaults := range epochsChanged { + epochsChangedKeys := make([]uint64, 0, len(epochsChanged)) + for k := range epochsChanged { + epochsChangedKeys = append(epochsChangedKeys, k) + } + sort.Slice(epochsChangedKeys, func(i, j int) bool { + return epochsChangedKeys[i] < epochsChangedKeys[j] + }) + + for _, i := range epochsChangedKeys { + newFaults := epochsChanged[i] + if empty, err := newFaults.IsEmpty(); err != nil { return err } else if empty { From 6a2de2520a3a1da75f3c67a13d1ef767d83307a9 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Thu, 2 Jul 2020 14:41:17 +0200 Subject: [PATCH 3/3] trying to reduce window periods --- actors/builtin/miner/policy.go | 12 ----------- actors/builtin/miner/policy_params.go | 20 +++++++++++++++++++ .../builtin/miner/policy_params_testground.go | 19 ++++++++++++++++++ 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 actors/builtin/miner/policy_params.go create mode 100644 actors/builtin/miner/policy_params_testground.go diff --git a/actors/builtin/miner/policy.go b/actors/builtin/miner/policy.go index 3dbb3b0e6..bec25e396 100644 --- a/actors/builtin/miner/policy.go +++ b/actors/builtin/miner/policy.go @@ -8,15 +8,6 @@ import ( builtin "github.com/filecoin-project/specs-actors/actors/builtin" ) -// The period over which all a miner's active sectors will be challenged. -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(40 * 60 / builtin.EpochDurationSeconds) // 40 minutes (36 per day) - -// The number of non-overlapping PoSt deadlines in each proving period. -const WPoStPeriodDeadlines = uint64(WPoStProvingPeriod / WPoStChallengeWindow) - func init() { // Check that the challenge windows divide the proving period evenly. if WPoStProvingPeriod%WPoStChallengeWindow != 0 { @@ -81,9 +72,6 @@ const WPoStChallengeLookback = abi.ChainEpoch(20) // PARAM_FINISH // epoch completed, and hence before the challenge was knowable. const FaultDeclarationCutoff = WPoStChallengeLookback // PARAM_FINISH -// The maximum age of a fault before the sector is terminated. -const FaultMaxAge = WPoStProvingPeriod*14 - 1 - // Staging period for a miner worker key change. const WorkerKeyChangeDelay = 2 * ElectionLookback // PARAM_FINISH diff --git a/actors/builtin/miner/policy_params.go b/actors/builtin/miner/policy_params.go new file mode 100644 index 000000000..6339270d3 --- /dev/null +++ b/actors/builtin/miner/policy_params.go @@ -0,0 +1,20 @@ +// +build !testground + +package miner + +import ( + abi "github.com/filecoin-project/specs-actors/actors/abi" + builtin "github.com/filecoin-project/specs-actors/actors/builtin" +) + +// The period over which all a miner's active sectors will be challenged. +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(40 * 60 / builtin.EpochDurationSeconds) // 40 minutes (36 per day) + +// The number of non-overlapping PoSt deadlines in each proving period. +const WPoStPeriodDeadlines = uint64(WPoStProvingPeriod / WPoStChallengeWindow) + +// The maximum age of a fault before the sector is terminated. +const FaultMaxAge = WPoStProvingPeriod*14 - 1 diff --git a/actors/builtin/miner/policy_params_testground.go b/actors/builtin/miner/policy_params_testground.go new file mode 100644 index 000000000..19cce1de1 --- /dev/null +++ b/actors/builtin/miner/policy_params_testground.go @@ -0,0 +1,19 @@ +// +build testground + +package miner + +import ( + abi "github.com/filecoin-project/specs-actors/actors/abi" +) + +// The period over which all a miner's active sectors will be challenged. +const WPoStProvingPeriod = abi.ChainEpoch(360) // proving period set to 360 epochs ~ 6min. instead of 24 hours (assuming block time delay of 1sec.) + +// The duration of a deadline's challenge window, the period before a deadline when the challenge is available. +const WPoStChallengeWindow = abi.ChainEpoch(10) // challenge window set to 10 epochs ~ 10sec. instead of 40 minutes (assuming block time delay of 1sec.) + +// The number of non-overlapping PoSt deadlines in each proving period. +const WPoStPeriodDeadlines = uint64(WPoStProvingPeriod / WPoStChallengeWindow) // Again 36 non-overlapping windows, same as production. + +// The maximum age of a fault before the sector is terminated. +const FaultMaxAge = WPoStProvingPeriod*14 - 1