Merge remote-tracking branch 'origin/master' into feat/async-restartable-workers
This commit is contained in:
+10
-7
@@ -40,8 +40,11 @@ import (
|
||||
var log = logging.Logger("fullnode")
|
||||
|
||||
type ChainModuleAPI interface {
|
||||
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainHead(context.Context) (*types.TipSet, error)
|
||||
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
|
||||
ChainGetTipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)
|
||||
ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
@@ -67,8 +70,8 @@ type ChainAPI struct {
|
||||
Chain *store.ChainStore
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
|
||||
return a.Chain.SubHeadChanges(ctx), nil
|
||||
func (m *ChainModule) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
|
||||
return m.Chain.SubHeadChanges(ctx), nil
|
||||
}
|
||||
|
||||
func (m *ChainModule) ChainHead(context.Context) (*types.TipSet, error) {
|
||||
@@ -101,13 +104,13 @@ func (m *ChainModule) ChainGetTipSet(ctx context.Context, key types.TipSetKey) (
|
||||
return m.Chain.LoadTipSet(key)
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) (*api.BlockMessages, error) {
|
||||
b, err := a.Chain.GetBlock(msg)
|
||||
func (m *ChainModule) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) (*api.BlockMessages, error) {
|
||||
b, err := m.Chain.GetBlock(msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bmsgs, smsgs, err := a.Chain.MessagesForBlock(b)
|
||||
bmsgs, smsgs, err := m.Chain.MessagesForBlock(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -532,8 +535,8 @@ func (a *ChainAPI) ChainGetNode(ctx context.Context, p string) (*api.IpldObject,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error) {
|
||||
cm, err := a.Chain.GetCMessage(mc)
|
||||
func (m *ChainModule) ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error) {
|
||||
cm, err := m.Chain.GetCMessage(mc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"sort"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||
|
||||
"go.uber.org/fx"
|
||||
"golang.org/x/xerrors"
|
||||
@@ -16,8 +17,6 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
||||
@@ -259,7 +258,7 @@ func gasEstimateGasLimit(
|
||||
if !builtin.IsPaymentChannelActor(act.Code) {
|
||||
return res.MsgRct.GasUsed, nil
|
||||
}
|
||||
if msgIn.Method != builtin0.MethodsPaych.Collect {
|
||||
if msgIn.Method != paych.Methods.Collect {
|
||||
return res.MsgRct.GasUsed, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -187,6 +187,42 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spe
|
||||
})
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolBatchPush(ctx context.Context, smsgs []*types.SignedMessage) ([]cid.Cid, error) {
|
||||
var messageCids []cid.Cid
|
||||
for _, smsg := range smsgs {
|
||||
smsgCid, err := a.Mpool.Push(smsg)
|
||||
if err != nil {
|
||||
return messageCids, err
|
||||
}
|
||||
messageCids = append(messageCids, smsgCid)
|
||||
}
|
||||
return messageCids, nil
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolBatchPushUntrusted(ctx context.Context, smsgs []*types.SignedMessage) ([]cid.Cid, error) {
|
||||
var messageCids []cid.Cid
|
||||
for _, smsg := range smsgs {
|
||||
smsgCid, err := a.Mpool.PushUntrusted(smsg)
|
||||
if err != nil {
|
||||
return messageCids, err
|
||||
}
|
||||
messageCids = append(messageCids, smsgCid)
|
||||
}
|
||||
return messageCids, nil
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolBatchPushMessage(ctx context.Context, msgs []*types.Message, spec *api.MessageSendSpec) ([]*types.SignedMessage, error) {
|
||||
var smsgs []*types.SignedMessage
|
||||
for _, msg := range msgs {
|
||||
smsg, err := a.MpoolPushMessage(ctx, msg, spec)
|
||||
if err != nil {
|
||||
return smsgs, err
|
||||
}
|
||||
smsgs = append(smsgs, smsg)
|
||||
}
|
||||
return smsgs, nil
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
||||
return a.Mpool.GetNonce(addr)
|
||||
}
|
||||
|
||||
+11
-12
@@ -12,8 +12,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"go.uber.org/fx"
|
||||
@@ -85,7 +84,7 @@ func (a *MsigAPI) MsigAddPropose(ctx context.Context, msig address.Address, src
|
||||
return cid.Undef, actErr
|
||||
}
|
||||
|
||||
return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(builtin0.MethodsMultisig.AddSigner), enc)
|
||||
return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc)
|
||||
}
|
||||
|
||||
func (a *MsigAPI) MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (cid.Cid, error) {
|
||||
@@ -94,7 +93,7 @@ func (a *MsigAPI) MsigAddApprove(ctx context.Context, msig address.Address, src
|
||||
return cid.Undef, actErr
|
||||
}
|
||||
|
||||
return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(builtin0.MethodsMultisig.AddSigner), enc)
|
||||
return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc)
|
||||
}
|
||||
|
||||
func (a *MsigAPI) MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (cid.Cid, error) {
|
||||
@@ -103,7 +102,7 @@ func (a *MsigAPI) MsigAddCancel(ctx context.Context, msig address.Address, src a
|
||||
return cid.Undef, actErr
|
||||
}
|
||||
|
||||
return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(builtin0.MethodsMultisig.AddSigner), enc)
|
||||
return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(multisig.Methods.AddSigner), enc)
|
||||
}
|
||||
|
||||
func (a *MsigAPI) MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
|
||||
@@ -112,7 +111,7 @@ func (a *MsigAPI) MsigSwapPropose(ctx context.Context, msig address.Address, src
|
||||
return cid.Undef, actErr
|
||||
}
|
||||
|
||||
return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(builtin0.MethodsMultisig.SwapSigner), enc)
|
||||
return a.MsigPropose(ctx, msig, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc)
|
||||
}
|
||||
|
||||
func (a *MsigAPI) MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
|
||||
@@ -121,7 +120,7 @@ func (a *MsigAPI) MsigSwapApprove(ctx context.Context, msig address.Address, src
|
||||
return cid.Undef, actErr
|
||||
}
|
||||
|
||||
return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(builtin0.MethodsMultisig.SwapSigner), enc)
|
||||
return a.MsigApproveTxnHash(ctx, msig, txID, proposer, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc)
|
||||
}
|
||||
|
||||
func (a *MsigAPI) MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {
|
||||
@@ -130,7 +129,7 @@ func (a *MsigAPI) MsigSwapCancel(ctx context.Context, msig address.Address, src
|
||||
return cid.Undef, actErr
|
||||
}
|
||||
|
||||
return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(builtin0.MethodsMultisig.SwapSigner), enc)
|
||||
return a.MsigCancel(ctx, msig, txID, msig, big.Zero(), src, uint64(multisig.Methods.SwapSigner), enc)
|
||||
}
|
||||
|
||||
func (a *MsigAPI) MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) {
|
||||
@@ -151,7 +150,7 @@ func (a *MsigAPI) MsigRemoveSigner(ctx context.Context, msig address.Address, pr
|
||||
return cid.Undef, actErr
|
||||
}
|
||||
|
||||
return a.MsigPropose(ctx, msig, msig, types.NewInt(0), proposer, uint64(builtin0.MethodsMultisig.RemoveSigner), enc)
|
||||
return a.MsigPropose(ctx, msig, msig, types.NewInt(0), proposer, uint64(multisig.Methods.RemoveSigner), enc)
|
||||
}
|
||||
|
||||
func (a *MsigAPI) msigApproveOrCancelSimple(ctx context.Context, operation api.MsigProposeResponse, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) {
|
||||
@@ -242,7 +241,7 @@ func (a *MsigAPI) msigApproveOrCancelTxnHash(ctx context.Context, operation api.
|
||||
}
|
||||
|
||||
func serializeAddParams(new address.Address, inc bool) ([]byte, error) {
|
||||
enc, actErr := actors.SerializeParams(&multisig0.AddSignerParams{
|
||||
enc, actErr := actors.SerializeParams(&multisig2.AddSignerParams{
|
||||
Signer: new,
|
||||
Increase: inc,
|
||||
})
|
||||
@@ -254,7 +253,7 @@ func serializeAddParams(new address.Address, inc bool) ([]byte, error) {
|
||||
}
|
||||
|
||||
func serializeSwapParams(old address.Address, new address.Address) ([]byte, error) {
|
||||
enc, actErr := actors.SerializeParams(&multisig0.SwapSignerParams{
|
||||
enc, actErr := actors.SerializeParams(&multisig2.SwapSignerParams{
|
||||
From: old,
|
||||
To: new,
|
||||
})
|
||||
@@ -266,7 +265,7 @@ func serializeSwapParams(old address.Address, new address.Address) ([]byte, erro
|
||||
}
|
||||
|
||||
func serializeRemoveParams(rem address.Address, dec bool) ([]byte, error) {
|
||||
enc, actErr := actors.SerializeParams(&multisig0.RemoveSignerParams{
|
||||
enc, actErr := actors.SerializeParams(&multisig2.RemoveSignerParams{
|
||||
Signer: rem,
|
||||
Decrease: dec,
|
||||
})
|
||||
|
||||
+69
-46
@@ -40,12 +40,22 @@ import (
|
||||
)
|
||||
|
||||
type StateModuleAPI interface {
|
||||
StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
|
||||
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error)
|
||||
MsigGetAvailableBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.BigInt, error)
|
||||
MsigGetVested(ctx context.Context, addr address.Address, start types.TipSetKey, end types.TipSetKey) (types.BigInt, error)
|
||||
StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error)
|
||||
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
|
||||
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
||||
StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error)
|
||||
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error)
|
||||
StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error)
|
||||
StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error)
|
||||
StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error)
|
||||
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error)
|
||||
StateNetworkVersion(ctx context.Context, key types.TipSetKey) (network.Version, error)
|
||||
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
|
||||
StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error)
|
||||
}
|
||||
|
||||
// StateModule provides a default implementation of StateModuleAPI.
|
||||
@@ -112,13 +122,13 @@ func (a *StateAPI) StateMinerActiveSectors(ctx context.Context, maddr address.Ad
|
||||
return stmgr.GetMinerSectorSet(ctx, a.StateManager, ts, maddr, &activeSectors)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) {
|
||||
act, err := a.StateManager.LoadActorTsk(ctx, actor, tsk)
|
||||
func (m *StateModule) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) {
|
||||
act, err := m.StateManager.LoadActorTsk(ctx, actor, tsk)
|
||||
if err != nil {
|
||||
return miner.MinerInfo{}, xerrors.Errorf("failed to load miner actor: %w", err)
|
||||
}
|
||||
|
||||
mas, err := miner.Load(a.StateManager.ChainStore().Store(ctx), act)
|
||||
mas, err := miner.Load(m.StateManager.ChainStore().Store(ctx), act)
|
||||
if err != nil {
|
||||
return miner.MinerInfo{}, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||
}
|
||||
@@ -215,18 +225,18 @@ func (a *StateAPI) StateMinerPartitions(ctx context.Context, m address.Address,
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error) {
|
||||
ts, err := a.StateManager.ChainStore().GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
act, err := a.StateManager.LoadActor(ctx, addr, ts)
|
||||
act, err := m.StateManager.LoadActor(ctx, addr, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load miner actor: %w", err)
|
||||
}
|
||||
|
||||
mas, err := miner.Load(a.StateManager.ChainStore().Store(ctx), act)
|
||||
mas, err := miner.Load(m.StateManager.ChainStore().Store(ctx), act)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||
}
|
||||
@@ -310,19 +320,19 @@ func (a *StateAPI) StateMinerRecoveries(ctx context.Context, addr address.Addres
|
||||
return miner.AllPartSectors(mas, miner.Partition.RecoveringSectors)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMinerPower(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*api.MinerPower, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateMinerPower(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*api.MinerPower, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
m, net, hmp, err := stmgr.GetPower(ctx, a.StateManager, ts, addr)
|
||||
mp, net, hmp, err := stmgr.GetPower(ctx, m.StateManager, ts, addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &api.MinerPower{
|
||||
MinerPower: m,
|
||||
MinerPower: mp,
|
||||
TotalPower: net,
|
||||
HasMinPower: hmp,
|
||||
}, nil
|
||||
@@ -349,6 +359,7 @@ func (a *StateAPI) StateCall(ctx context.Context, msg *types.Message, tsk types.
|
||||
func (a *StateAPI) StateReplay(ctx context.Context, tsk types.TipSetKey, mc cid.Cid) (*api.InvocResult, error) {
|
||||
msgToReplay := mc
|
||||
var ts *types.TipSet
|
||||
var err error
|
||||
if tsk == types.EmptyTSK {
|
||||
mlkp, err := a.StateSearchMsg(ctx, mc)
|
||||
if err != nil {
|
||||
@@ -370,7 +381,10 @@ func (a *StateAPI) StateReplay(ctx context.Context, tsk types.TipSetKey, mc cid.
|
||||
return nil, xerrors.Errorf("loading parent tipset %s: %w", mlkp.TipSet, err)
|
||||
}
|
||||
} else {
|
||||
ts = a.Chain.GetHeaviestTipSet()
|
||||
ts, err = a.Chain.LoadTipSet(tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading specified tipset %s: %w", tsk, err)
|
||||
}
|
||||
}
|
||||
|
||||
m, r, err := a.StateManager.Replay(ctx, ts, msgToReplay)
|
||||
@@ -559,20 +573,20 @@ func (a *StateAPI) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLoo
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetReceipt(ctx context.Context, msg cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateGetReceipt(ctx context.Context, msg cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
return a.StateManager.GetReceipt(ctx, msg, ts)
|
||||
return m.StateManager.GetReceipt(ctx, msg, ts)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
return stmgr.ListMinerActors(ctx, a.StateManager, ts)
|
||||
return stmgr.ListMinerActors(ctx, m.StateManager, ts)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateListActors(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
|
||||
@@ -583,12 +597,12 @@ func (a *StateAPI) StateListActors(ctx context.Context, tsk types.TipSetKey) ([]
|
||||
return a.StateManager.ListAllActors(ctx, ts)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return api.MarketBalance{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
return a.StateManager.MarketBalance(ctx, addr, ts)
|
||||
return m.StateManager.MarketBalance(ctx, addr, ts)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSetKey) (map[string]api.MarketBalance, error) {
|
||||
@@ -672,12 +686,12 @@ func (a *StateAPI) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (m
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
return stmgr.GetStorageDeal(ctx, a.StateManager, dealId, ts)
|
||||
return stmgr.GetStorageDeal(ctx, m.StateManager, dealId, ts)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.Cid) (map[string]types.Actor, error) {
|
||||
@@ -1173,19 +1187,19 @@ func (a *StateAPI) StateVerifierStatus(ctx context.Context, addr address.Address
|
||||
// StateVerifiedClientStatus returns the data cap for the given address.
|
||||
// Returns zero if there is no entry in the data cap table for the
|
||||
// address.
|
||||
func (a *StateAPI) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
|
||||
act, err := a.StateGetActor(ctx, verifreg.Address, tsk)
|
||||
func (m *StateModule) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
|
||||
act, err := m.StateGetActor(ctx, verifreg.Address, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
aid, err := a.StateLookupID(ctx, addr, tsk)
|
||||
aid, err := m.StateLookupID(ctx, addr, tsk)
|
||||
if err != nil {
|
||||
log.Warnf("lookup failure %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vrs, err := verifreg.Load(a.StateManager.ChainStore().Store(ctx), act)
|
||||
vrs, err := verifreg.Load(m.StateManager.ChainStore().Store(ctx), act)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load verified registry state: %w", err)
|
||||
}
|
||||
@@ -1220,33 +1234,33 @@ var dealProviderCollateralDen = types.NewInt(100)
|
||||
|
||||
// StateDealProviderCollateralBounds returns the min and max collateral a storage provider
|
||||
// can issue. It takes the deal size and verified status as parameters.
|
||||
func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return api.DealCollateralBounds{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
pact, err := a.StateGetActor(ctx, power.Address, tsk)
|
||||
pact, err := m.StateGetActor(ctx, power.Address, tsk)
|
||||
if err != nil {
|
||||
return api.DealCollateralBounds{}, xerrors.Errorf("failed to load power actor: %w", err)
|
||||
}
|
||||
|
||||
ract, err := a.StateGetActor(ctx, reward.Address, tsk)
|
||||
ract, err := m.StateGetActor(ctx, reward.Address, tsk)
|
||||
if err != nil {
|
||||
return api.DealCollateralBounds{}, xerrors.Errorf("failed to load reward actor: %w", err)
|
||||
}
|
||||
|
||||
pst, err := power.Load(a.StateManager.ChainStore().Store(ctx), pact)
|
||||
pst, err := power.Load(m.StateManager.ChainStore().Store(ctx), pact)
|
||||
if err != nil {
|
||||
return api.DealCollateralBounds{}, xerrors.Errorf("failed to load power actor state: %w", err)
|
||||
}
|
||||
|
||||
rst, err := reward.Load(a.StateManager.ChainStore().Store(ctx), ract)
|
||||
rst, err := reward.Load(m.StateManager.ChainStore().Store(ctx), ract)
|
||||
if err != nil {
|
||||
return api.DealCollateralBounds{}, xerrors.Errorf("failed to load reward actor state: %w", err)
|
||||
}
|
||||
|
||||
circ, err := a.StateVMCirculatingSupplyInternal(ctx, ts.Key())
|
||||
circ, err := stateVMCirculatingSupplyInternal(ctx, ts.Key(), m.Chain, m.StateManager)
|
||||
if err != nil {
|
||||
return api.DealCollateralBounds{}, xerrors.Errorf("getting total circulating supply: %w", err)
|
||||
}
|
||||
@@ -1267,7 +1281,7 @@ func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size a
|
||||
powClaim.QualityAdjPower,
|
||||
rewPow,
|
||||
circ.FilCirculating,
|
||||
a.StateManager.GetNtwkVersion(ctx, ts.Height()))
|
||||
m.StateManager.GetNtwkVersion(ctx, ts.Height()))
|
||||
return api.DealCollateralBounds{
|
||||
Min: types.BigDiv(types.BigMul(min, dealProviderCollateralNum), dealProviderCollateralDen),
|
||||
Max: max,
|
||||
@@ -1288,23 +1302,32 @@ func (a *StateAPI) StateCirculatingSupply(ctx context.Context, tsk types.TipSetK
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateVMCirculatingSupplyInternal(ctx context.Context, tsk types.TipSetKey) (api.CirculatingSupply, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
return stateVMCirculatingSupplyInternal(ctx, tsk, a.Chain, a.StateManager)
|
||||
}
|
||||
func stateVMCirculatingSupplyInternal(
|
||||
ctx context.Context,
|
||||
tsk types.TipSetKey,
|
||||
cstore *store.ChainStore,
|
||||
smgr *stmgr.StateManager,
|
||||
) (api.CirculatingSupply, error) {
|
||||
ts, err := cstore.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return api.CirculatingSupply{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
sTree, err := a.stateForTs(ctx, ts)
|
||||
sTree, err := stateForTs(ctx, ts, cstore, smgr)
|
||||
if err != nil {
|
||||
return api.CirculatingSupply{}, err
|
||||
}
|
||||
return a.StateManager.GetVMCirculatingSupplyDetailed(ctx, ts.Height(), sTree)
|
||||
|
||||
return smgr.GetVMCirculatingSupplyDetailed(ctx, ts.Height(), sTree)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||
func (m *StateModule) StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error) {
|
||||
ts, err := m.Chain.GetTipSetFromKey(tsk)
|
||||
if err != nil {
|
||||
return network.VersionMax, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
return a.StateManager.GetNtwkVersion(ctx, ts.Height()), nil
|
||||
return m.StateManager.GetNtwkVersion(ctx, ts.Height()), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user