|
|
|
@@ -39,15 +39,27 @@ type StateAPI struct {
|
|
|
|
|
Chain *store.ChainStore
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*api.ChainSectorInfo, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetMinerSectorSet(ctx, a.StateManager, ts, addr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerProvingSet(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*api.ChainSectorInfo, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerProvingSet(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetMinerProvingSet(ctx, a.StateManager, ts, addr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerPower(ctx context.Context, maddr address.Address, ts *types.TipSet) (api.MinerPower, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerPower(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (api.MinerPower, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return api.MinerPower{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
mpow, tpow, err := stmgr.GetPower(ctx, a.StateManager, ts, maddr)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return api.MinerPower{}, err
|
|
|
|
@@ -69,27 +81,52 @@ func (a *StateAPI) StateMinerPower(ctx context.Context, maddr address.Address, t
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerWorker(ctx context.Context, m address.Address, ts *types.TipSet) (address.Address, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerWorker(ctx context.Context, m address.Address, tsk types.TipSetKey) (address.Address, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetMinerWorker(ctx, a.StateManager, ts, m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerPeerID(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerPeerID(ctx context.Context, m address.Address, tsk types.TipSetKey) (peer.ID, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetMinerPeerID(ctx, a.StateManager, ts, m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, tsk types.TipSetKey) (uint64, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetMinerElectionPeriodStart(ctx, a.StateManager, ts, actor)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerSectorSize(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerSectorSize(ctx context.Context, actor address.Address, tsk types.TipSetKey) (uint64, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetMinerSectorSize(ctx, a.StateManager, ts, actor)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerFaults(ctx context.Context, addr address.Address, ts *types.TipSet) ([]uint64, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerFaults(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]uint64, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetMinerFaults(ctx, a.StateManager, ts, addr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StatePledgeCollateral(ctx context.Context, ts *types.TipSet) (types.BigInt, error) {
|
|
|
|
|
func (a *StateAPI) StatePledgeCollateral(ctx context.Context, tsk types.TipSetKey) (types.BigInt, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
param, err := actors.SerializeParams(&actors.PledgeCollateralParams{Size: types.NewInt(0)})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return types.NewInt(0), err
|
|
|
|
@@ -113,11 +150,19 @@ func (a *StateAPI) StatePledgeCollateral(ctx context.Context, ts *types.TipSet)
|
|
|
|
|
return types.BigFromBytes(ret.Return), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*api.MethodCall, error) {
|
|
|
|
|
func (a *StateAPI) StateCall(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (*api.MethodCall, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return a.StateManager.Call(ctx, msg, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateReplay(ctx context.Context, ts *types.TipSet, mc cid.Cid) (*api.ReplayResults, error) {
|
|
|
|
|
func (a *StateAPI) StateReplay(ctx context.Context, tsk types.TipSetKey, mc cid.Cid) (*api.ReplayResults, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
m, r, err := a.StateManager.Replay(ctx, ts, mc)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@@ -150,7 +195,11 @@ func (a *StateAPI) stateForTs(ctx context.Context, ts *types.TipSet) (*state.Sta
|
|
|
|
|
return state.LoadStateTree(cst, st)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) {
|
|
|
|
|
func (a *StateAPI) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
state, err := a.stateForTs(ctx, ts)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("computing tipset state failed: %w", err)
|
|
|
|
@@ -159,7 +208,11 @@ func (a *StateAPI) StateGetActor(ctx context.Context, actor address.Address, ts
|
|
|
|
|
return state.GetActor(actor)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateLookupID(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
|
|
|
|
|
func (a *StateAPI) StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
state, err := a.stateForTs(ctx, ts)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return address.Undef, err
|
|
|
|
@@ -168,7 +221,11 @@ func (a *StateAPI) StateLookupID(ctx context.Context, addr address.Address, ts *
|
|
|
|
|
return state.LookupID(addr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateReadState(ctx context.Context, act *types.Actor, ts *types.TipSet) (*api.ActorState, error) {
|
|
|
|
|
func (a *StateAPI) StateReadState(ctx context.Context, act *types.Actor, tsk types.TipSetKey) (*api.ActorState, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
state, err := a.stateForTs(ctx, ts)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@@ -191,7 +248,11 @@ func (a *StateAPI) StateReadState(ctx context.Context, act *types.Actor, ts *typ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is on StateAPI because miner.Miner requires this, and MinerAPI requires miner.Miner
|
|
|
|
|
func (a *StateAPI) MinerCreateBlock(ctx context.Context, addr address.Address, parents *types.TipSet, ticket *types.Ticket, proof *types.EPostProof, msgs []*types.SignedMessage, height, ts uint64) (*types.BlockMsg, error) {
|
|
|
|
|
func (a *StateAPI) MinerCreateBlock(ctx context.Context, addr address.Address, parentsTSK types.TipSetKey, ticket *types.Ticket, proof *types.EPostProof, msgs []*types.SignedMessage, height, ts uint64) (*types.BlockMsg, error) {
|
|
|
|
|
parents, err := a.Chain.GetTipSetFromKey(parentsTSK)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", parentsTSK, err)
|
|
|
|
|
}
|
|
|
|
|
fblk, err := gen.MinerCreateBlock(ctx, a.StateManager, a.Wallet, addr, parents, ticket, proof, msgs, height, ts)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@@ -223,26 +284,46 @@ func (a *StateAPI) StateWaitMsg(ctx context.Context, msg cid.Cid) (*api.MsgWait,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateGetReceipt(ctx context.Context, msg cid.Cid, ts *types.TipSet) (*types.MessageReceipt, error) {
|
|
|
|
|
func (a *StateAPI) StateGetReceipt(ctx context.Context, msg cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return a.StateManager.GetReceipt(ctx, msg, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateListMiners(ctx context.Context, ts *types.TipSet) ([]address.Address, error) {
|
|
|
|
|
func (a *StateAPI) StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.ListMinerActors(ctx, a.StateManager, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateListActors(ctx context.Context, ts *types.TipSet) ([]address.Address, error) {
|
|
|
|
|
func (a *StateAPI) StateListActors(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return a.StateManager.ListAllActors(ctx, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMarketBalance(ctx context.Context, addr address.Address, ts *types.TipSet) (actors.StorageParticipantBalance, error) {
|
|
|
|
|
func (a *StateAPI) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (actors.StorageParticipantBalance, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return actors.StorageParticipantBalance{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return a.StateManager.MarketBalance(ctx, addr, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMarketParticipants(ctx context.Context, ts *types.TipSet) (map[string]actors.StorageParticipantBalance, error) {
|
|
|
|
|
func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSetKey) (map[string]actors.StorageParticipantBalance, error) {
|
|
|
|
|
out := map[string]actors.StorageParticipantBalance{}
|
|
|
|
|
|
|
|
|
|
var state actors.StorageMarketState
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
if _, err := a.StateManager.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@@ -271,10 +352,14 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, ts *types.TipSet
|
|
|
|
|
return out, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[string]actors.OnChainDeal, error) {
|
|
|
|
|
func (a *StateAPI) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[string]actors.OnChainDeal, error) {
|
|
|
|
|
out := map[string]actors.OnChainDeal{}
|
|
|
|
|
|
|
|
|
|
var state actors.StorageMarketState
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
if _, err := a.StateManager.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@@ -298,7 +383,11 @@ func (a *StateAPI) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[
|
|
|
|
|
return out, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMarketStorageDeal(ctx context.Context, dealId uint64, ts *types.TipSet) (*actors.OnChainDeal, error) {
|
|
|
|
|
func (a *StateAPI) StateMarketStorageDeal(ctx context.Context, dealId uint64, tsk types.TipSetKey) (*actors.OnChainDeal, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.GetStorageDeal(ctx, a.StateManager, dealId, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -353,11 +442,19 @@ func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.
|
|
|
|
|
return out, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Address, ts *types.TipSet) (api.MinerSectors, error) {
|
|
|
|
|
func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MinerSectors, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return api.MinerSectors{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.SectorSetSizes(ctx, a.StateManager, addr, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateListMessages(ctx context.Context, match *types.Message, ts *types.TipSet, toheight uint64) ([]cid.Cid, error) {
|
|
|
|
|
func (a *StateAPI) StateListMessages(ctx context.Context, match *types.Message, tsk types.TipSetKey, toheight uint64) ([]cid.Cid, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
if ts == nil {
|
|
|
|
|
ts = a.Chain.GetHeaviestTipSet()
|
|
|
|
|
}
|
|
|
|
@@ -406,13 +503,18 @@ func (a *StateAPI) StateListMessages(ctx context.Context, match *types.Message,
|
|
|
|
|
return out, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) StateCompute(ctx context.Context, height uint64, msgs []*types.Message, ts *types.TipSet) (cid.Cid, error) {
|
|
|
|
|
func (a *StateAPI) StateCompute(ctx context.Context, height uint64, msgs []*types.Message, tsk types.TipSetKey) (cid.Cid, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return cid.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
return stmgr.ComputeState(ctx, a.StateManager, height, msgs, ts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *StateAPI) MsigGetAvailableBalance(ctx context.Context, addr address.Address, ts *types.TipSet) (types.BigInt, error) {
|
|
|
|
|
if ts == nil {
|
|
|
|
|
ts = a.Chain.GetHeaviestTipSet()
|
|
|
|
|
func (a *StateAPI) MsigGetAvailableBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.BigInt, error) {
|
|
|
|
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var st actors.MultiSigActorState
|
|
|
|
|