refactor: use abstract types instead of specs-actors

This commit is contained in:
Dirk McCormick 2020-09-25 15:54:27 +02:00
parent 7eb9bec13f
commit 80a7ed8116
4 changed files with 16 additions and 8 deletions

View File

@ -21,6 +21,10 @@ import (
// Unchanged between v0 and v1 actors // Unchanged between v0 and v1 actors
var PreCommitChallengeDelay = miner0.PreCommitChallengeDelay var PreCommitChallengeDelay = miner0.PreCommitChallengeDelay
var WPoStProvingPeriod = miner0.WPoStProvingPeriod var WPoStProvingPeriod = miner0.WPoStProvingPeriod
var WPoStPeriodDeadlines = miner0.WPoStPeriodDeadlines
var WPoStChallengeWindow = miner0.WPoStChallengeWindow
var WPoStChallengeLookback = miner0.WPoStChallengeLookback
var FaultDeclarationCutoff = miner0.FaultDeclarationCutoff
const MinSectorExpiration = miner0.MinSectorExpiration const MinSectorExpiration = miner0.MinSectorExpiration

View File

@ -7,7 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
@ -529,5 +529,9 @@ func nextDeadline(currentDeadline *dline.Info) *dline.Info {
periodStart = periodStart + miner.WPoStProvingPeriod periodStart = periodStart + miner.WPoStProvingPeriod
} }
return miner.NewDeadlineInfo(periodStart, newDeadline, currentDeadline.CurrentEpoch) return NewDeadlineInfo(periodStart, newDeadline, currentDeadline.CurrentEpoch)
}
func NewDeadlineInfo(periodStart abi.ChainEpoch, deadlineIdx uint64, currEpoch abi.ChainEpoch) *dline.Info {
return dline.NewInfo(periodStart, deadlineIdx, currEpoch, miner.WPoStPeriodDeadlines, miner.WPoStProvingPeriod, miner.WPoStChallengeWindow, miner.WPoStChallengeLookback, miner.FaultDeclarationCutoff)
} }

View File

@ -17,8 +17,8 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
) )
var dummyCid cid.Cid var dummyCid cid.Cid
@ -90,7 +90,7 @@ func (m *mockAPI) getDeadline(currentEpoch abi.ChainEpoch) *dline.Info {
close += miner.WPoStChallengeWindow close += miner.WPoStChallengeWindow
dlIdx++ dlIdx++
} }
return miner.NewDeadlineInfo(0, dlIdx, currentEpoch) return NewDeadlineInfo(0, dlIdx, currentEpoch)
} }
func (m *mockAPI) StateMinerProvingDeadline(ctx context.Context, address address.Address, key types.TipSetKey) (*dline.Info, error) { func (m *mockAPI) StateMinerProvingDeadline(ctx context.Context, address address.Address, key types.TipSetKey) (*dline.Info, error) {
@ -355,7 +355,7 @@ func TestChangeHandlerDontStartUntilProvingPeriod(t *testing.T) {
periodStart := miner.WPoStProvingPeriod periodStart := miner.WPoStProvingPeriod
dlIdx := uint64(1) dlIdx := uint64(1)
currentEpoch := abi.ChainEpoch(10) currentEpoch := abi.ChainEpoch(10)
di := miner.NewDeadlineInfo(periodStart, dlIdx, currentEpoch) di := NewDeadlineInfo(periodStart, dlIdx, currentEpoch)
mock.setDeadline(di) mock.setDeadline(di)
defer s.ch.shutdown() defer s.ch.shutdown()
@ -375,7 +375,7 @@ func TestChangeHandlerDontStartUntilProvingPeriod(t *testing.T) {
// Advance the head to the next proving period's first epoch // Advance the head to the next proving period's first epoch
currentEpoch = periodStart + miner.WPoStChallengeWindow currentEpoch = periodStart + miner.WPoStChallengeWindow
di = miner.NewDeadlineInfo(periodStart, dlIdx, currentEpoch) di = NewDeadlineInfo(periodStart, dlIdx, currentEpoch)
mock.setDeadline(di) mock.setDeadline(di)
go triggerHeadAdvance(t, s, currentEpoch) go triggerHeadAdvance(t, s, currentEpoch)

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
) )
func TestNextDeadline(t *testing.T) { func TestNextDeadline(t *testing.T) {
@ -14,7 +14,7 @@ func TestNextDeadline(t *testing.T) {
deadlineIdx := 0 deadlineIdx := 0
currentEpoch := abi.ChainEpoch(10) currentEpoch := abi.ChainEpoch(10)
di := miner.NewDeadlineInfo(periodStart, uint64(deadlineIdx), currentEpoch) di := NewDeadlineInfo(periodStart, uint64(deadlineIdx), currentEpoch)
require.EqualValues(t, 0, di.Index) require.EqualValues(t, 0, di.Index)
require.EqualValues(t, 0, di.PeriodStart) require.EqualValues(t, 0, di.PeriodStart)
require.EqualValues(t, -20, di.Challenge) require.EqualValues(t, -20, di.Challenge)