diff --git a/chain/actors/builtin/builtin.go b/chain/actors/builtin/builtin.go index 4906f0fa4..9ad976564 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -3,7 +3,7 @@ package builtin import ( "fmt" - "github.com/filecoin-project/go-state-types/big" + smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing" "github.com/filecoin-project/go-state-types/network" ) @@ -25,7 +25,8 @@ func VersionForNetwork(version network.Version) Version { } // TODO: Why does actors have 2 different versions of this? -type FilterEstimate struct { - PositionEstimate big.Int - VelocityEstimate big.Int +type FilterEstimate = smoothing0.FilterEstimate + +func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate { + return (FilterEstimate)(v0) } diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index 27eee4c50..e184b668d 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -26,7 +26,7 @@ func (s *state0) TotalLocked() (abi.TokenAmount, error) { func (s *state0) BalancesChanged(otherState State) bool { otherState0, ok := otherState.(*state0) if !ok { - // there's no way to compare differnt versions of the state, so let's + // there's no way to compare different versions of the state, so let's // just say that means the state of balances has changed return true } @@ -36,7 +36,7 @@ func (s *state0) BalancesChanged(otherState State) bool { func (s *state0) StatesChanged(otherState State) bool { otherState0, ok := otherState.(*state0) if !ok { - // there's no way to compare differnt versions of the state, so let's + // there's no way to compare different versions of the state, so let's // just say that means the state of balances has changed return true } @@ -54,7 +54,7 @@ func (s *state0) States() (DealStates, error) { func (s *state0) ProposalsChanged(otherState State) bool { otherState0, ok := otherState.(*state0) if !ok { - // there's no way to compare differnt versions of the state, so let's + // there's no way to compare different versions of the state, so let's // just say that means the state of balances has changed return true } diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index d25652d30..704ea1291 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -2,6 +2,7 @@ package miner import ( "github.com/filecoin-project/go-state-types/dline" + "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -81,9 +82,30 @@ type Partition interface { ActiveSectors() (bitfield.BitField, error) } -type SectorOnChainInfo = miner0.SectorOnChainInfo +type SectorOnChainInfo struct { + SectorNumber abi.SectorNumber + SealProof abi.RegisteredSealProof + SealedCID cid.Cid + DealIDs []abi.DealID + Activation abi.ChainEpoch + Expiration abi.ChainEpoch + DealWeight abi.DealWeight + VerifiedDealWeight abi.DealWeight + InitialPledge abi.TokenAmount + ExpectedDayReward abi.TokenAmount + ExpectedStoragePledge abi.TokenAmount +} + type SectorPreCommitInfo = miner0.SectorPreCommitInfo -type SectorPreCommitOnChainInfo = miner0.SectorPreCommitOnChainInfo + +type SectorPreCommitOnChainInfo struct { + Info SectorPreCommitInfo + PreCommitDeposit abi.TokenAmount + PreCommitEpoch abi.ChainEpoch + DealWeight abi.DealWeight + VerifiedDealWeight abi.DealWeight +} + type PoStPartition = miner0.PoStPartition type RecoveryDeclaration = miner0.RecoveryDeclaration type FaultDeclaration = miner0.FaultDeclaration diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index 7985896f3..71306fafd 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -62,7 +62,8 @@ func (s *state0) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { return nil, err } - return info, nil + ret := fromV0SectorOnChainInfo(*info) + return &ret, nil } func (s *state0) FindSector(num abi.SectorNumber) (*SectorLocation, error) { @@ -154,7 +155,8 @@ func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return nil, err } - return info, nil + ret := fromV0SectorPreCommitOnChainInfo(*info) + return &ret, nil } func (s *state0) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) (adt.Array, error) { @@ -279,7 +281,11 @@ func (s *state0) sectors() (adt.Array, error) { func (s *state0) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { var si miner0.SectorOnChainInfo err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) - return si, err + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV0SectorOnChainInfo(si), nil } func (s *state0) precommits() (adt.Map, error) { @@ -289,7 +295,11 @@ func (s *state0) precommits() (adt.Map, error) { func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { var sp miner0.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) - return sp, err + if err != nil { + return SectorPreCommitOnChainInfo{}, err + } + + return fromV0SectorPreCommitOnChainInfo(sp), nil } func (d *deadline0) LoadPartition(idx uint64) (Partition, error) { @@ -336,3 +346,11 @@ func (p *partition0) FaultySectors() (bitfield.BitField, error) { func (p *partition0) RecoveringSectors() (bitfield.BitField, error) { return p.Partition.Recoveries, nil } + +func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo { + return (SectorOnChainInfo)(v0) +} + +func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { + return (SectorPreCommitOnChainInfo)(v0) +} diff --git a/chain/actors/builtin/power/v0.go b/chain/actors/builtin/power/v0.go index 94c8f749e..e19984f72 100644 --- a/chain/actors/builtin/power/v0.go +++ b/chain/actors/builtin/power/v0.go @@ -53,10 +53,7 @@ func (s *state0) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state0) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FilterEstimate{ - PositionEstimate: s.State.ThisEpochQAPowerSmoothed.PositionEstimate, - VelocityEstimate: s.State.ThisEpochQAPowerSmoothed.VelocityEstimate, - }, nil + return builtin.FromV0FilterEstimate(*s.State.ThisEpochQAPowerSmoothed), nil } func (s *state0) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/reward/v0.go b/chain/actors/builtin/reward/v0.go index 3efcaf93a..981905ba5 100644 --- a/chain/actors/builtin/reward/v0.go +++ b/chain/actors/builtin/reward/v0.go @@ -19,10 +19,7 @@ func (s *state0) ThisEpochReward() (abi.StoragePower, error) { } func (s *state0) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { - return builtin.FilterEstimate{ - PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, - VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, - }, nil + return builtin.FromV0FilterEstimate(*s.State.ThisEpochRewardSmoothed), nil } func (s *state0) ThisEpochBaselinePower() (abi.StoragePower, error) {