Introduce v1 actors
This commit is contained in:
parent
e5873d5dea
commit
ebad0ded3d
@ -6,6 +6,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -20,6 +21,13 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
case builtin1.AccountActorCodeID:
|
||||
out := state1{store: store}
|
||||
err := store.Get(store.Context(), act.Head, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
18
chain/actors/builtin/account/v1.go
Normal file
18
chain/actors/builtin/account/v1.go
Normal file
@ -0,0 +1,18 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/specs-actors/v2/actors/builtin/account"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
account.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) PubkeyAddress() (address.Address, error) {
|
||||
return s.Address, nil
|
||||
}
|
@ -8,6 +8,7 @@ import (
|
||||
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||
|
||||
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
||||
smoothing1 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
)
|
||||
@ -41,3 +42,7 @@ func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
|
||||
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
|
||||
return miner0.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
|
||||
}
|
||||
|
||||
func FromV1FilterEstimate(v1 smoothing1.FilterEstimate) FilterEstimate {
|
||||
return (FilterEstimate)(v1)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -24,6 +25,13 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
case builtin1.InitActorCodeID:
|
||||
out := state1{store: store}
|
||||
err := store.Get(store.Context(), act.Head, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
47
chain/actors/builtin/init/v1.go
Normal file
47
chain/actors/builtin/init/v1.go
Normal file
@ -0,0 +1,47 @@
|
||||
package init
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
|
||||
init_ "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
|
||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
init_.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) ResolveAddress(address address.Address) (address.Address, bool, error) {
|
||||
return s.State.ResolveAddress(s.store, address)
|
||||
}
|
||||
|
||||
func (s *state1) MapAddressToNewID(address address.Address) (address.Address, error) {
|
||||
return s.State.MapAddressToNewID(s.store, address)
|
||||
}
|
||||
|
||||
func (s *state1) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
|
||||
addrs, err := adt1.AsMap(s.store, s.State.AddressMap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var actorID cbg.CborInt
|
||||
return addrs.ForEach(&actorID, func(key string) error {
|
||||
addr, err := address.NewFromBytes([]byte(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cb(abi.ActorID(actorID), addr)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state1) NetworkName() (dtypes.NetworkName, error) {
|
||||
return dtypes.NetworkName(s.State.NetworkName), nil
|
||||
}
|
@ -6,11 +6,13 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -26,6 +28,13 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
case builtin1.StorageMarketActorCodeID:
|
||||
out := state1{store: store}
|
||||
err := store.Get(store.Context(), act.Head, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
186
chain/actors/builtin/market/v1.go
Normal file
186
chain/actors/builtin/market/v1.go
Normal file
@ -0,0 +1,186 @@
|
||||
package market
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
market.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) TotalLocked() (abi.TokenAmount, error) {
|
||||
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
|
||||
fml = types.BigAdd(fml, s.TotalClientStorageFee)
|
||||
return fml, nil
|
||||
}
|
||||
|
||||
func (s *state1) BalancesChanged(otherState State) bool {
|
||||
otherState1, ok := otherState.(*state1)
|
||||
if !ok {
|
||||
// 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
|
||||
}
|
||||
return !s.State.EscrowTable.Equals(otherState1.State.EscrowTable) || !s.State.LockedTable.Equals(otherState1.State.LockedTable)
|
||||
}
|
||||
|
||||
func (s *state1) StatesChanged(otherState State) bool {
|
||||
otherState1, ok := otherState.(*state1)
|
||||
if !ok {
|
||||
// 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
|
||||
}
|
||||
return !s.State.States.Equals(otherState1.State.States)
|
||||
}
|
||||
|
||||
func (s *state1) States() (DealStates, error) {
|
||||
stateArray, err := adt1.AsArray(s.store, s.State.States)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dealStates1{stateArray}, nil
|
||||
}
|
||||
|
||||
func (s *state1) ProposalsChanged(otherState State) bool {
|
||||
otherState1, ok := otherState.(*state1)
|
||||
if !ok {
|
||||
// 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
|
||||
}
|
||||
return !s.State.Proposals.Equals(otherState1.State.Proposals)
|
||||
}
|
||||
|
||||
func (s *state1) Proposals() (DealProposals, error) {
|
||||
proposalArray, err := adt1.AsArray(s.store, s.State.Proposals)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dealProposals1{proposalArray}, nil
|
||||
}
|
||||
|
||||
func (s *state1) EscrowTable() (BalanceTable, error) {
|
||||
bt, err := adt1.AsBalanceTable(s.store, s.State.EscrowTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &balanceTable1{bt}, nil
|
||||
}
|
||||
|
||||
func (s *state1) LockedTable() (BalanceTable, error) {
|
||||
bt, err := adt1.AsBalanceTable(s.store, s.State.LockedTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &balanceTable1{bt}, nil
|
||||
}
|
||||
|
||||
func (s *state1) VerifyDealsForActivation(
|
||||
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
|
||||
) (weight, verifiedWeight abi.DealWeight, err error) {
|
||||
w, vw, _, err := market.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
|
||||
return w, vw, err
|
||||
}
|
||||
|
||||
type balanceTable1 struct {
|
||||
*adt1.BalanceTable
|
||||
}
|
||||
|
||||
func (bt *balanceTable1) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
|
||||
asMap := (*adt1.Map)(bt.BalanceTable)
|
||||
var ta abi.TokenAmount
|
||||
return asMap.ForEach(&ta, func(key string) error {
|
||||
a, err := address.NewFromBytes([]byte(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cb(a, ta)
|
||||
})
|
||||
}
|
||||
|
||||
type dealStates1 struct {
|
||||
adt.Array
|
||||
}
|
||||
|
||||
func (s *dealStates1) Get(dealID abi.DealID) (*DealState, bool, error) {
|
||||
var deal1 market.DealState
|
||||
found, err := s.Array.Get(uint64(dealID), &deal1)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
deal := fromV1DealState(deal1)
|
||||
return &deal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealStates1) decode(val *cbg.Deferred) (*DealState, error) {
|
||||
var ds1 market.DealState
|
||||
if err := ds1.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ds := fromV1DealState(ds1)
|
||||
return &ds, nil
|
||||
}
|
||||
|
||||
func (s *dealStates1) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV1DealState(v1 market.DealState) DealState {
|
||||
return (DealState)(v1)
|
||||
}
|
||||
|
||||
type dealProposals1 struct {
|
||||
adt.Array
|
||||
}
|
||||
|
||||
func (s *dealProposals1) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
var proposal1 market.DealProposal
|
||||
found, err := s.Array.Get(uint64(dealID), &proposal1)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV1DealProposal(proposal1)
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals1) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp1 market.DealProposal
|
||||
return s.Array.ForEach(&dp1, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV1DealProposal(dp1))
|
||||
})
|
||||
}
|
||||
|
||||
func (s *dealProposals1) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
var dp1 market.DealProposal
|
||||
if err := dp1.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV1DealProposal(dp1)
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals1) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV1DealProposal(v1 market.DealProposal) DealProposal {
|
||||
return (DealProposal)(v1)
|
||||
}
|
403
chain/actors/builtin/miner/v1.go
Normal file
403
chain/actors/builtin/miner/v1.go
Normal file
@ -0,0 +1,403 @@
|
||||
package miner
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
miner1.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
type deadline1 struct {
|
||||
miner1.Deadline
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
type partition1 struct {
|
||||
miner1.Partition
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) AvailableBalance(bal abi.TokenAmount) (abi.TokenAmount, error) {
|
||||
return s.GetAvailableBalance(bal), nil
|
||||
}
|
||||
|
||||
func (s *state1) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||
return s.CheckVestedFunds(s.store, epoch)
|
||||
}
|
||||
|
||||
func (s *state1) LockedFunds() (LockedFunds, error) {
|
||||
return LockedFunds{
|
||||
VestingFunds: s.State.LockedFunds,
|
||||
InitialPledgeRequirement: s.State.InitialPledge,
|
||||
PreCommitDeposits: s.State.PreCommitDeposits,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state1) InitialPledge() (abi.TokenAmount, error) {
|
||||
return s.State.InitialPledge, nil
|
||||
}
|
||||
|
||||
func (s *state1) PreCommitDeposits() (abi.TokenAmount, error) {
|
||||
return s.State.PreCommitDeposits, nil
|
||||
}
|
||||
|
||||
func (s *state1) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := fromV1SectorOnChainInfo(*info)
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state1) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
||||
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SectorLocation{
|
||||
Deadline: dlIdx,
|
||||
Partition: partIdx,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetSectorExpiration returns the effective expiration of the given sector.
|
||||
//
|
||||
// If the sector isn't found or has already been terminated, this method returns
|
||||
// nil and no error. If the sector does not expire early, the Early expiration
|
||||
// field is 0.
|
||||
func (s *state1) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// NOTE: this can be optimized significantly.
|
||||
// 1. If the sector is non-faulty, it will either expire on-time (can be
|
||||
// learned from the sector info), or in the next quantized expiration
|
||||
// epoch (i.e., the first element in the partition's expiration queue.
|
||||
// 2. If it's faulty, it will expire early within the first 14 entries
|
||||
// of the expiration queue.
|
||||
stopErr := errors.New("stop")
|
||||
out := SectorExpiration{}
|
||||
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner1.Deadline) error {
|
||||
partitions, err := dl.PartitionsArray(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
quant := s.State.QuantSpecForDeadline(dlIdx)
|
||||
var part miner1.Partition
|
||||
return partitions.ForEach(&part, func(partIdx int64) error {
|
||||
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if !found {
|
||||
return nil
|
||||
}
|
||||
if found, err := part.Terminated.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if found {
|
||||
// already terminated
|
||||
return stopErr
|
||||
}
|
||||
|
||||
q, err := miner1.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var exp miner1.ExpirationSet
|
||||
return q.ForEach(&exp, func(epoch int64) error {
|
||||
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if early {
|
||||
out.Early = abi.ChainEpoch(epoch)
|
||||
return nil
|
||||
}
|
||||
if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if onTime {
|
||||
out.OnTime = abi.ChainEpoch(epoch)
|
||||
return stopErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
})
|
||||
})
|
||||
if err == stopErr {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out.Early == 0 && out.OnTime == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state1) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := fromV1SectorPreCommitOnChainInfo(*info)
|
||||
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state1) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) (adt.Array, error) {
|
||||
a, err := adt1.AsArray(s.store, s.State.Sectors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := adt1.MakeEmptyArray(s.store)
|
||||
var v cbg.Deferred
|
||||
if err := a.ForEach(&v, func(i int64) error {
|
||||
include := true
|
||||
if filter != nil {
|
||||
set, err := filter.IsSet(uint64(i))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("filter check error: %w", err)
|
||||
}
|
||||
if set == filterOut {
|
||||
include = false
|
||||
}
|
||||
}
|
||||
|
||||
if include {
|
||||
var oci miner1.SectorOnChainInfo
|
||||
if err := oci.UnmarshalCBOR(bytes.NewReader(v.Raw)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
noci := SectorOnChainInfo{
|
||||
SectorNumber: oci.SectorNumber,
|
||||
SealProof: oci.SealProof,
|
||||
SealedCID: oci.SealedCID,
|
||||
DealIDs: oci.DealIDs,
|
||||
Activation: oci.Activation,
|
||||
Expiration: oci.Expiration,
|
||||
DealWeight: oci.DealWeight,
|
||||
VerifiedDealWeight: oci.VerifiedDealWeight,
|
||||
InitialPledge: oci.InitialPledge,
|
||||
ExpectedDayReward: oci.ExpectedDayReward,
|
||||
ExpectedStoragePledge: oci.ExpectedStoragePledge,
|
||||
}
|
||||
|
||||
if err := ret.Set(uint64(i), &noci); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (s *state1) LoadPreCommittedSectors() (adt.Map, error) {
|
||||
return adt1.AsMap(s.store, s.State.PreCommittedSectors)
|
||||
}
|
||||
|
||||
func (s *state1) IsAllocated(num abi.SectorNumber) (bool, error) {
|
||||
var allocatedSectors bitfield.BitField
|
||||
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return allocatedSectors.IsSet(uint64(num))
|
||||
}
|
||||
|
||||
func (s *state1) LoadDeadline(idx uint64) (Deadline, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dl, err := dls.LoadDeadline(s.store, idx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &deadline1{*dl, s.store}, nil
|
||||
}
|
||||
|
||||
func (s *state1) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return dls.ForEach(s.store, func(i uint64, dl *miner1.Deadline) error {
|
||||
return cb(i, &deadline1{*dl, s.store})
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state1) NumDeadlines() (uint64, error) {
|
||||
return miner1.WPoStPeriodDeadlines, nil
|
||||
}
|
||||
|
||||
func (s *state1) DeadlinesChanged(other State) bool {
|
||||
other1, ok := other.(*state1)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true
|
||||
}
|
||||
|
||||
return s.State.Deadlines.Equals(other1.Deadlines)
|
||||
}
|
||||
|
||||
func (s *state1) Info() (MinerInfo, error) {
|
||||
info, err := s.State.GetInfo(s.store)
|
||||
if err != nil {
|
||||
return MinerInfo{}, err
|
||||
}
|
||||
|
||||
var pid *peer.ID
|
||||
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
|
||||
pid = &peerID
|
||||
}
|
||||
|
||||
mi := MinerInfo{
|
||||
Owner: info.Owner,
|
||||
Worker: info.Worker,
|
||||
ControlAddresses: info.ControlAddresses,
|
||||
|
||||
NewWorker: address.Undef,
|
||||
WorkerChangeEpoch: -1,
|
||||
|
||||
PeerId: pid,
|
||||
Multiaddrs: info.Multiaddrs,
|
||||
SealProofType: info.SealProofType,
|
||||
SectorSize: info.SectorSize,
|
||||
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
||||
}
|
||||
|
||||
if info.PendingWorkerKey != nil {
|
||||
mi.NewWorker = info.PendingWorkerKey.NewWorker
|
||||
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
|
||||
}
|
||||
|
||||
return mi, nil
|
||||
}
|
||||
|
||||
func (s *state1) DeadlineInfo(epoch abi.ChainEpoch) *dline.Info {
|
||||
return s.State.DeadlineInfo(epoch)
|
||||
}
|
||||
|
||||
func (s *state1) sectors() (adt.Array, error) {
|
||||
return adt1.AsArray(s.store, s.Sectors)
|
||||
}
|
||||
|
||||
func (s *state1) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
||||
var si miner1.SectorOnChainInfo
|
||||
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return SectorOnChainInfo{}, err
|
||||
}
|
||||
|
||||
ret := fromV1SectorOnChainInfo(si)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (s *state1) precommits() (adt.Map, error) {
|
||||
return adt1.AsMap(s.store, s.PreCommittedSectors)
|
||||
}
|
||||
|
||||
func (s *state1) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner1.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
ret := fromV1SectorPreCommitOnChainInfo(sp)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (d *deadline1) LoadPartition(idx uint64) (Partition, error) {
|
||||
p, err := d.Deadline.LoadPartition(d.store, idx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &partition1{*p, d.store}, nil
|
||||
}
|
||||
|
||||
func (d *deadline1) ForEachPartition(cb func(uint64, Partition) error) error {
|
||||
ps, err := d.Deadline.PartitionsArray(d.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var part miner1.Partition
|
||||
return ps.ForEach(&part, func(i int64) error {
|
||||
return cb(uint64(i), &partition1{part, d.store})
|
||||
})
|
||||
}
|
||||
|
||||
func (d *deadline1) PartitionsChanged(other Deadline) bool {
|
||||
other1, ok := other.(*deadline1)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true
|
||||
}
|
||||
|
||||
return d.Deadline.Partitions.Equals(other1.Deadline.Partitions)
|
||||
}
|
||||
|
||||
func (d *deadline1) PostSubmissions() (bitfield.BitField, error) {
|
||||
return d.Deadline.PostSubmissions, nil
|
||||
}
|
||||
|
||||
func (p *partition1) AllSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Sectors, nil
|
||||
}
|
||||
|
||||
func (p *partition1) FaultySectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Faults, nil
|
||||
}
|
||||
|
||||
func (p *partition1) RecoveringSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Recoveries, nil
|
||||
}
|
||||
|
||||
func fromV1SectorOnChainInfo(v1 miner1.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return SectorOnChainInfo{
|
||||
SectorNumber: v1.SectorNumber,
|
||||
SealProof: v1.SealProof,
|
||||
SealedCID: v1.SealedCID,
|
||||
DealIDs: v1.DealIDs,
|
||||
Activation: v1.Activation,
|
||||
Expiration: v1.Expiration,
|
||||
DealWeight: v1.DealWeight,
|
||||
VerifiedDealWeight: v1.VerifiedDealWeight,
|
||||
InitialPledge: v1.InitialPledge,
|
||||
ExpectedDayReward: v1.ExpectedDayReward,
|
||||
ExpectedStoragePledge: v1.ExpectedStoragePledge,
|
||||
}
|
||||
}
|
||||
|
||||
func fromV1SectorPreCommitOnChainInfo(v1 miner1.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
return SectorPreCommitOnChainInfo{
|
||||
Info: (SectorPreCommitInfo)(v1.Info),
|
||||
PreCommitDeposit: v1.PreCommitDeposit,
|
||||
PreCommitEpoch: v1.PreCommitEpoch,
|
||||
DealWeight: v1.DealWeight,
|
||||
VerifiedDealWeight: v1.VerifiedDealWeight,
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -23,6 +24,13 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
case builtin1.MultisigActorCodeID:
|
||||
out := state1{store: store}
|
||||
err := store.Get(store.Context(), act.Head, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
30
chain/actors/builtin/multisig/v1.go
Normal file
30
chain/actors/builtin/multisig/v1.go
Normal file
@ -0,0 +1,30 @@
|
||||
package multisig
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
multisig.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
|
||||
}
|
||||
|
||||
func (s *state1) StartEpoch() abi.ChainEpoch {
|
||||
return s.State.StartEpoch
|
||||
}
|
||||
|
||||
func (s *state1) UnlockDuration() abi.ChainEpoch {
|
||||
return s.State.UnlockDuration
|
||||
}
|
||||
|
||||
func (s *state1) InitialBalance() abi.TokenAmount {
|
||||
return s.State.InitialBalance
|
||||
}
|
@ -7,8 +7,10 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
big "github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -24,6 +26,13 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
case builtin1.PaymentChannelActorCodeID:
|
||||
out := state1{store: store}
|
||||
err := store.Get(store.Context(), act.Head, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
91
chain/actors/builtin/paych/v1.go
Normal file
91
chain/actors/builtin/paych/v1.go
Normal file
@ -0,0 +1,91 @@
|
||||
package paych
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
|
||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
paych.State
|
||||
store adt.Store
|
||||
lsAmt *adt1.Array
|
||||
}
|
||||
|
||||
// Channel owner, who has funded the actor
|
||||
func (s *state1) From() address.Address {
|
||||
return s.State.From
|
||||
}
|
||||
|
||||
// Recipient of payouts from channel
|
||||
func (s *state1) To() address.Address {
|
||||
return s.State.To
|
||||
}
|
||||
|
||||
// Height at which the channel can be `Collected`
|
||||
func (s *state1) SettlingAt() abi.ChainEpoch {
|
||||
return s.State.SettlingAt
|
||||
}
|
||||
|
||||
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
||||
func (s *state1) ToSend() abi.TokenAmount {
|
||||
return s.State.ToSend
|
||||
}
|
||||
|
||||
func (s *state1) getOrLoadLsAmt() (*adt1.Array, error) {
|
||||
if s.lsAmt != nil {
|
||||
return s.lsAmt, nil
|
||||
}
|
||||
|
||||
// Get the lane state from the chain
|
||||
lsamt, err := adt1.AsArray(s.store, s.State.LaneStates)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.lsAmt = lsamt
|
||||
return lsamt, nil
|
||||
}
|
||||
|
||||
// Get total number of lanes
|
||||
func (s *state1) LaneCount() (uint64, error) {
|
||||
lsamt, err := s.getOrLoadLsAmt()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return lsamt.Length(), nil
|
||||
}
|
||||
|
||||
// Iterate lane states
|
||||
func (s *state1) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
|
||||
// Get the lane state from the chain
|
||||
lsamt, err := s.getOrLoadLsAmt()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Note: we use a map instead of an array to store laneStates because the
|
||||
// client sets the lane ID (the index) and potentially they could use a
|
||||
// very large index.
|
||||
var ls paych.LaneState
|
||||
return lsamt.ForEach(&ls, func(i int64) error {
|
||||
return cb(uint64(i), &laneState1{ls})
|
||||
})
|
||||
}
|
||||
|
||||
type laneState1 struct {
|
||||
paych.LaneState
|
||||
}
|
||||
|
||||
func (ls *laneState1) Redeemed() big.Int {
|
||||
return ls.LaneState.Redeemed
|
||||
}
|
||||
|
||||
func (ls *laneState1) Nonce() uint64 {
|
||||
return ls.LaneState.Nonce
|
||||
}
|
85
chain/actors/builtin/power/v1.go
Normal file
85
chain/actors/builtin/power/v1.go
Normal file
@ -0,0 +1,85 @@
|
||||
package power
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
power1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
power1.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) TotalLocked() (abi.TokenAmount, error) {
|
||||
return s.TotalPledgeCollateral, nil
|
||||
}
|
||||
|
||||
func (s *state1) TotalPower() (Claim, error) {
|
||||
return Claim{
|
||||
RawBytePower: s.TotalRawBytePower,
|
||||
QualityAdjPower: s.TotalQualityAdjPower,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Committed power to the network. Includes miners below the minimum threshold.
|
||||
func (s *state1) TotalCommitted() (Claim, error) {
|
||||
return Claim{
|
||||
RawBytePower: s.TotalBytesCommitted,
|
||||
QualityAdjPower: s.TotalQABytesCommitted,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state1) MinerPower(addr address.Address) (Claim, bool, error) {
|
||||
claims, err := adt.AsMap(s.store, s.Claims)
|
||||
if err != nil {
|
||||
return Claim{}, false, err
|
||||
}
|
||||
var claim power1.Claim
|
||||
ok, err := claims.Get(abi.AddrKey(addr), &claim)
|
||||
if err != nil {
|
||||
return Claim{}, false, err
|
||||
}
|
||||
return Claim{
|
||||
RawBytePower: claim.RawBytePower,
|
||||
QualityAdjPower: claim.QualityAdjPower,
|
||||
}, ok, nil
|
||||
}
|
||||
|
||||
func (s *state1) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
|
||||
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
|
||||
}
|
||||
|
||||
func (s *state1) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
||||
return builtin.FromV1FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil
|
||||
}
|
||||
|
||||
func (s *state1) MinerCounts() (uint64, uint64, error) {
|
||||
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
|
||||
}
|
||||
|
||||
func (s *state1) ListAllMiners() ([]address.Address, error) {
|
||||
claims, err := adt.AsMap(s.store, s.Claims)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var miners []address.Address
|
||||
err = claims.ForEach(nil, func(k string) error {
|
||||
a, err := address.NewFromBytes([]byte(k))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
miners = append(miners, a)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return miners, nil
|
||||
}
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
@ -24,6 +25,13 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
case builtin1.RewardActorCodeID:
|
||||
out := state1{store: store}
|
||||
err := store.Get(store.Context(), act.Head, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
74
chain/actors/builtin/reward/v1.go
Normal file
74
chain/actors/builtin/reward/v1.go
Normal file
@ -0,0 +1,74 @@
|
||||
package reward
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
|
||||
"github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
reward.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) ThisEpochReward() (abi.StoragePower, error) {
|
||||
return s.State.ThisEpochReward, nil
|
||||
}
|
||||
|
||||
func (s *state1) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
||||
return builtin.FilterEstimate{
|
||||
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
|
||||
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state1) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
||||
return s.State.ThisEpochBaselinePower, nil
|
||||
}
|
||||
|
||||
func (s *state1) TotalStoragePowerReward() (abi.TokenAmount, error) {
|
||||
return s.State.TotalStoragePowerReward, nil
|
||||
}
|
||||
|
||||
func (s *state1) EffectiveBaselinePower() (abi.StoragePower, error) {
|
||||
return s.State.EffectiveBaselinePower, nil
|
||||
}
|
||||
|
||||
func (s *state1) EffectiveNetworkTime() (abi.ChainEpoch, error) {
|
||||
return s.State.EffectiveNetworkTime, nil
|
||||
}
|
||||
|
||||
func (s *state1) CumsumBaseline() (abi.StoragePower, error) {
|
||||
return s.State.CumsumBaseline, nil
|
||||
}
|
||||
|
||||
func (s *state1) CumsumRealized() (abi.StoragePower, error) {
|
||||
return s.State.CumsumBaseline, nil
|
||||
}
|
||||
|
||||
func (s *state1) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
|
||||
return miner1.InitialPledgeForPower(
|
||||
qaPower,
|
||||
s.State.ThisEpochBaselinePower,
|
||||
s.State.ThisEpochRewardSmoothed,
|
||||
smoothing.FilterEstimate{
|
||||
PositionEstimate: networkQAPower.PositionEstimate,
|
||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||
},
|
||||
circSupply,
|
||||
), nil
|
||||
}
|
||||
|
||||
func (s *state1) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
|
||||
return miner1.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
|
||||
smoothing.FilterEstimate{
|
||||
PositionEstimate: networkQAPower.PositionEstimate,
|
||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||
},
|
||||
sectorWeight), nil
|
||||
}
|
39
chain/actors/builtin/verifreg/v1.go
Normal file
39
chain/actors/builtin/verifreg/v1.go
Normal file
@ -0,0 +1,39 @@
|
||||
package verifreg
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
adt1 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
verifreg1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state1)(nil)
|
||||
|
||||
type state1 struct {
|
||||
verifreg1.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state1) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||
if addr.Protocol() != address.ID {
|
||||
return false, big.Zero(), xerrors.Errorf("can only look up ID addresses")
|
||||
}
|
||||
|
||||
vh, err := adt1.AsMap(s.store, s.VerifiedClients)
|
||||
if err != nil {
|
||||
return false, big.Zero(), xerrors.Errorf("loading verified clients: %w", err)
|
||||
}
|
||||
|
||||
var dcap abi.StoragePower
|
||||
if found, err := vh.Get(abi.AddrKey(addr), &dcap); err != nil {
|
||||
return false, big.Zero(), xerrors.Errorf("looking up verified clients: %w", err)
|
||||
} else if !found {
|
||||
return false, big.Zero(), nil
|
||||
}
|
||||
|
||||
return true, dcap, nil
|
||||
}
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -23,6 +24,13 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
case builtin1.VerifiedRegistryActorCodeID:
|
||||
out := state1{store: store}
|
||||
err := store.Get(store.Context(), act.Head, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
@ -31,6 +31,17 @@ import (
|
||||
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
account1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account"
|
||||
init1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
|
||||
market1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
msig1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
|
||||
paych1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
|
||||
power1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
|
||||
reward1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
|
||||
verifreg1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||
@ -545,6 +556,18 @@ func init() {
|
||||
builtin0.MultisigActorCodeID: {builtin0.MethodsMultisig, msig0.Actor{}},
|
||||
builtin0.RewardActorCodeID: {builtin0.MethodsReward, reward0.Actor{}},
|
||||
builtin0.VerifiedRegistryActorCodeID: {builtin0.MethodsVerifiedRegistry, verifreg0.Actor{}},
|
||||
|
||||
// builtin1.SystemActorCodeID: {builtin1.MethodsSystem, system.Actor{} }- apparently it doesn't have methods
|
||||
builtin1.InitActorCodeID: {builtin1.MethodsInit, init1.Actor{}},
|
||||
builtin1.CronActorCodeID: {builtin1.MethodsCron, cron.Actor{}},
|
||||
builtin1.AccountActorCodeID: {builtin1.MethodsAccount, account1.Actor{}},
|
||||
builtin1.StoragePowerActorCodeID: {builtin1.MethodsPower, power1.Actor{}},
|
||||
builtin1.StorageMinerActorCodeID: {builtin1.MethodsMiner, miner1.Actor{}},
|
||||
builtin1.StorageMarketActorCodeID: {builtin1.MethodsMarket, market1.Actor{}},
|
||||
builtin1.PaymentChannelActorCodeID: {builtin1.MethodsPaych, paych1.Actor{}},
|
||||
builtin1.MultisigActorCodeID: {builtin1.MethodsMultisig, msig1.Actor{}},
|
||||
builtin1.RewardActorCodeID: {builtin1.MethodsReward, reward1.Actor{}},
|
||||
builtin1.VerifiedRegistryActorCodeID: {builtin1.MethodsVerifiedRegistry, verifreg1.Actor{}},
|
||||
}
|
||||
|
||||
for c, m := range cidToMethods {
|
||||
@ -552,6 +575,7 @@ func init() {
|
||||
methods := make(map[abi.MethodNum]MethodMeta, len(exports))
|
||||
|
||||
// Explicitly add send, it's special.
|
||||
// Note that builtin1.MethodSend = builtin0.MethodSend = 0.
|
||||
methods[builtin0.MethodSend] = MethodMeta{
|
||||
Name: "Send",
|
||||
Params: reflect.TypeOf(new(abi.EmptyValue)),
|
||||
@ -592,8 +616,10 @@ func init() {
|
||||
}
|
||||
|
||||
switch abi.MethodNum(number) {
|
||||
// Note that builtin1.MethodSend = builtin0.MethodSend = 0.
|
||||
case builtin0.MethodSend:
|
||||
panic("method 0 is reserved for Send")
|
||||
// Note that builtin1.MethodConstructor = builtin0.MethodConstructor = 1.
|
||||
case builtin0.MethodConstructor:
|
||||
if fnName != "Constructor" {
|
||||
panic("method 1 is reserved for Constructor")
|
||||
|
@ -22,7 +22,20 @@ import (
|
||||
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||
system0 "github.com/filecoin-project/specs-actors/actors/builtin/system"
|
||||
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||
|
||||
vmr "github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
account1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account"
|
||||
cron1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron"
|
||||
init1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
|
||||
market1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
msig1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
|
||||
paych1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
|
||||
power1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
|
||||
reward1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
|
||||
system1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system"
|
||||
verifreg1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
@ -45,7 +58,6 @@ func NewInvoker() *Invoker {
|
||||
}
|
||||
|
||||
// add builtInCode using: register(cid, singleton)
|
||||
// NETUPGRADE: register code IDs for v2, etc.
|
||||
inv.Register(builtin0.SystemActorCodeID, system0.Actor{}, abi.EmptyValue{})
|
||||
inv.Register(builtin0.InitActorCodeID, init0.Actor{}, init0.State{})
|
||||
inv.Register(builtin0.RewardActorCodeID, reward0.Actor{}, reward0.State{})
|
||||
@ -58,6 +70,18 @@ func NewInvoker() *Invoker {
|
||||
inv.Register(builtin0.VerifiedRegistryActorCodeID, verifreg0.Actor{}, verifreg0.State{})
|
||||
inv.Register(builtin0.AccountActorCodeID, account0.Actor{}, account0.State{})
|
||||
|
||||
inv.Register(builtin1.SystemActorCodeID, system1.Actor{}, abi.EmptyValue{})
|
||||
inv.Register(builtin1.InitActorCodeID, init1.Actor{}, init1.State{})
|
||||
inv.Register(builtin1.RewardActorCodeID, reward1.Actor{}, reward1.State{})
|
||||
inv.Register(builtin1.CronActorCodeID, cron1.Actor{}, cron1.State{})
|
||||
inv.Register(builtin1.StoragePowerActorCodeID, power1.Actor{}, power1.State{})
|
||||
inv.Register(builtin1.StorageMarketActorCodeID, market1.Actor{}, market1.State{})
|
||||
inv.Register(builtin1.StorageMinerActorCodeID, miner1.Actor{}, miner1.State{})
|
||||
inv.Register(builtin1.MultisigActorCodeID, msig1.Actor{}, msig1.State{})
|
||||
inv.Register(builtin1.PaymentChannelActorCodeID, paych1.Actor{}, paych1.State{})
|
||||
inv.Register(builtin1.VerifiedRegistryActorCodeID, verifreg1.Actor{}, verifreg1.State{})
|
||||
inv.Register(builtin1.AccountActorCodeID, account1.Actor{}, account1.State{})
|
||||
|
||||
return inv
|
||||
}
|
||||
|
||||
|
1
go.mod
1
go.mod
@ -37,6 +37,7 @@ require (
|
||||
github.com/filecoin-project/go-statestore v0.1.0
|
||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
|
||||
github.com/filecoin-project/specs-actors v0.9.10
|
||||
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200918035954-4caac0a9b252
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796
|
||||
github.com/filecoin-project/test-vectors/schema v0.0.1
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||
|
6
go.sum
6
go.sum
@ -232,6 +232,8 @@ github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3
|
||||
github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM=
|
||||
github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24=
|
||||
github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24=
|
||||
github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM=
|
||||
github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0/go.mod h1:7aWZdaQ1b16BVoQUYR+eEvrDCGJoPLxFpDynFjYfBjI=
|
||||
github.com/filecoin-project/go-jsonrpc v0.1.2-0.20200822201400-474f4fdccc52 h1:FXtCp0ybqdQL9knb3OGDpkNTaBbPxgkqPeWKotUwkH0=
|
||||
github.com/filecoin-project/go-jsonrpc v0.1.2-0.20200822201400-474f4fdccc52/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4=
|
||||
github.com/filecoin-project/go-multistore v0.0.3 h1:vaRBY4YiA2UZFPK57RNuewypB8u0DzzQwqsL0XarpnI=
|
||||
@ -254,8 +256,11 @@ github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
|
||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8=
|
||||
github.com/filecoin-project/specs-actors v0.9.4/go.mod h1:BStZQzx5x7TmCkLv0Bpa07U6cPKol6fd3w9KjMPZ6Z4=
|
||||
github.com/filecoin-project/specs-actors v0.9.7/go.mod h1:wM2z+kwqYgXn5Z7scV1YHLyd1Q1cy0R8HfTIWQ0BFGU=
|
||||
github.com/filecoin-project/specs-actors v0.9.9/go.mod h1:czlvLQGEX0fjLLfdNHD7xLymy6L3n7aQzRWzsYGf+ys=
|
||||
github.com/filecoin-project/specs-actors v0.9.10 h1:gU0TrRhgkCsBEOP42sGDE7RQuR0Cov9hJhBqq+RJmjU=
|
||||
github.com/filecoin-project/specs-actors v0.9.10/go.mod h1:czlvLQGEX0fjLLfdNHD7xLymy6L3n7aQzRWzsYGf+ys=
|
||||
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200918035954-4caac0a9b252 h1:0vOZo6xlVDyPhuRS3ArrAy1fml7H2FEY65IFx6rwp3o=
|
||||
github.com/filecoin-project/specs-actors/v2 v2.0.0-20200918035954-4caac0a9b252/go.mod h1:vV1UOOKlmdKg4dy3YKixtJtVf15WMuZsS6KgKRDxkWg=
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796 h1:dJsTPWpG2pcTeojO2pyn0c6l+x/3MZYCBgo/9d11JEk=
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796/go.mod h1:nJRRM7Aa9XVvygr3W9k6xGF46RWzr2zxF/iGoAIfA/g=
|
||||
github.com/filecoin-project/test-vectors/schema v0.0.1 h1:5fNF76nl4qolEvcIsjc0kUADlTMVHO73tW4kXXPnsus=
|
||||
@ -1367,6 +1372,7 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200414195334-429a0b5e922e/go.mod h1:X
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200504204219-64967432584d/go.mod h1:W5MvapuoHRP8rz4vxjwCK1pDqF1aQcWsV5PZ+AHbqdg=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200710004633-5379fc63235d/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200715143311-227fab5a2377/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200806213330-63aa96ca5488/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200810223238-211df3b9e24c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200812213548-958ddffe352c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200814224545-656e08ce49ee h1:U7zWWvvAjT76EiuWPSOiZlQDnaQYPxPoxugTtTAcJK0=
|
||||
|
Loading…
Reference in New Issue
Block a user