2020-04-06 18:07:26 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"context"
|
2020-09-07 06:08:53 +00:00
|
|
|
|
2020-04-06 18:07:26 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-address"
|
2020-09-07 03:49:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
2021-01-13 21:19:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/dline"
|
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
2020-09-21 22:24:45 +00:00
|
|
|
|
2020-10-08 01:09:33 +00:00
|
|
|
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
2021-05-17 20:02:23 +00:00
|
|
|
market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market"
|
2020-04-06 18:07:26 +00:00
|
|
|
|
2020-08-20 04:49:10 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
2021-01-29 20:01:00 +00:00
|
|
|
"github.com/filecoin-project/lotus/blockstore"
|
2020-06-04 13:54:37 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
2020-04-06 18:07:26 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
2020-09-17 07:32:10 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
2020-09-12 03:07:52 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
2020-04-06 18:07:26 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/store"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-08-17 13:39:33 +00:00
|
|
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
2020-04-06 18:07:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ sealing.SealingAPI = new(SealingAPIAdapter)
|
|
|
|
|
|
|
|
type SealingAPIAdapter struct {
|
|
|
|
delegate storageMinerApi
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSealingAPIAdapter(api storageMinerApi) SealingAPIAdapter {
|
|
|
|
return SealingAPIAdapter{delegate: api}
|
|
|
|
}
|
|
|
|
|
2020-04-06 20:23:37 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerSectorSize(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (abi.SectorSize, error) {
|
2020-04-16 17:36:36 +00:00
|
|
|
// TODO: update storage-fsm to just StateMinerInfo
|
2020-11-05 05:34:29 +00:00
|
|
|
mi, err := s.StateMinerInfo(ctx, maddr, tok)
|
2020-04-16 17:36:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return mi.SectorSize, nil
|
2020-04-06 20:23:37 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 18:55:20 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerPreCommitDepositForPower(ctx context.Context, a address.Address, pci miner.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return big.Zero(), xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateMinerPreCommitDepositForPower(ctx, a, pci, tsk)
|
|
|
|
}
|
|
|
|
|
2020-06-26 15:59:34 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context, a address.Address, pci miner.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) {
|
2020-04-23 19:39:34 +00:00
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return big.Zero(), xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
2020-06-26 15:59:34 +00:00
|
|
|
return s.delegate.StateMinerInitialPledgeCollateral(ctx, a, pci, tsk)
|
2020-04-23 19:39:34 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 05:34:29 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerInfo(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (miner.MinerInfo, error) {
|
2020-04-10 21:29:05 +00:00
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
2020-11-05 05:34:29 +00:00
|
|
|
return miner.MinerInfo{}, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
2020-04-10 21:29:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 17:36:36 +00:00
|
|
|
// TODO: update storage-fsm to just StateMinerInfo
|
2020-11-05 05:34:29 +00:00
|
|
|
return s.delegate.StateMinerInfo(ctx, maddr, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s SealingAPIAdapter) StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (address.Address, error) {
|
|
|
|
// TODO: update storage-fsm to just StateMinerInfo
|
|
|
|
mi, err := s.StateMinerInfo(ctx, maddr, tok)
|
2020-04-16 17:36:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return address.Undef, err
|
|
|
|
}
|
|
|
|
return mi.Worker, nil
|
2020-04-10 21:29:05 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 15:30:15 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerDeadlines(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) ([]api.Deadline, error) {
|
2020-04-15 20:22:58 +00:00
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateMinerDeadlines(ctx, maddr, tsk)
|
|
|
|
}
|
|
|
|
|
2020-10-13 19:35:29 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerSectorAllocated(ctx context.Context, maddr address.Address, sid abi.SectorNumber, tok sealing.TipSetToken) (bool, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return false, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateMinerSectorAllocated(ctx, maddr, sid, tsk)
|
|
|
|
}
|
|
|
|
|
2020-04-06 18:07:26 +00:00
|
|
|
func (s SealingAPIAdapter) StateWaitMsg(ctx context.Context, mcid cid.Cid) (sealing.MsgLookup, error) {
|
2020-06-03 21:42:06 +00:00
|
|
|
wmsg, err := s.delegate.StateWaitMsg(ctx, mcid, build.MessageConfidence)
|
2020-04-06 18:07:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return sealing.MsgLookup{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return sealing.MsgLookup{
|
|
|
|
Receipt: sealing.MessageReceipt{
|
|
|
|
ExitCode: wmsg.Receipt.ExitCode,
|
|
|
|
Return: wmsg.Receipt.Return,
|
|
|
|
GasUsed: wmsg.Receipt.GasUsed,
|
|
|
|
},
|
2020-07-12 03:54:25 +00:00
|
|
|
TipSetTok: wmsg.TipSet.Bytes(),
|
|
|
|
Height: wmsg.Height,
|
2020-04-06 18:07:26 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-08-18 16:02:13 +00:00
|
|
|
func (s SealingAPIAdapter) StateSearchMsg(ctx context.Context, c cid.Cid) (*sealing.MsgLookup, error) {
|
|
|
|
wmsg, err := s.delegate.StateSearchMsg(ctx, c)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if wmsg == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &sealing.MsgLookup{
|
|
|
|
Receipt: sealing.MessageReceipt{
|
|
|
|
ExitCode: wmsg.Receipt.ExitCode,
|
|
|
|
Return: wmsg.Receipt.Return,
|
|
|
|
GasUsed: wmsg.Receipt.GasUsed,
|
|
|
|
},
|
|
|
|
TipSetTok: wmsg.TipSet.Bytes(),
|
|
|
|
Height: wmsg.Height,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-06-15 16:30:49 +00:00
|
|
|
func (s SealingAPIAdapter) StateComputeDataCommitment(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tok sealing.TipSetToken) (cid.Cid, error) {
|
2020-04-06 18:07:26 +00:00
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
2021-06-01 18:27:09 +00:00
|
|
|
nv, err := s.delegate.StateNetworkVersion(ctx, tsk)
|
2021-05-17 20:02:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Cid{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var ccparams []byte
|
|
|
|
if nv < network.Version13 {
|
|
|
|
ccparams, err = actors.SerializeParams(&market2.ComputeDataCommitmentParams{
|
|
|
|
DealIDs: deals,
|
|
|
|
SectorType: sectorType,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
ccparams, err = actors.SerializeParams(&market5.ComputeDataCommitmentParams{
|
|
|
|
Inputs: []*market5.SectorDataSpec{
|
|
|
|
{
|
|
|
|
DealIDs: deals,
|
|
|
|
SectorType: sectorType,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-04-06 18:07:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("computing params for ComputeDataCommitment: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
ccmt := &types.Message{
|
2020-09-21 22:24:45 +00:00
|
|
|
To: market.Address,
|
2020-08-01 14:23:13 +00:00
|
|
|
From: maddr,
|
|
|
|
Value: types.NewInt(0),
|
2020-10-08 20:32:54 +00:00
|
|
|
Method: market.Methods.ComputeDataCommitment,
|
2020-08-01 14:23:13 +00:00
|
|
|
Params: ccparams,
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
r, err := s.delegate.StateCall(ctx, ccmt, tsk)
|
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("calling ComputeDataCommitment: %w", err)
|
|
|
|
}
|
|
|
|
if r.MsgRct.ExitCode != 0 {
|
|
|
|
return cid.Undef, xerrors.Errorf("receipt for ComputeDataCommitment had exit code %d", r.MsgRct.ExitCode)
|
|
|
|
}
|
|
|
|
|
2021-05-17 20:02:23 +00:00
|
|
|
if nv < network.Version13 {
|
|
|
|
var c cbg.CborCid
|
|
|
|
if err := c.UnmarshalCBOR(bytes.NewReader(r.MsgRct.Return)); err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("failed to unmarshal CBOR to CborCid: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cid.Cid(c), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var cr market5.ComputeDataCommitmentReturn
|
|
|
|
if err := cr.UnmarshalCBOR(bytes.NewReader(r.MsgRct.Return)); err != nil {
|
2020-04-06 18:07:26 +00:00
|
|
|
return cid.Undef, xerrors.Errorf("failed to unmarshal CBOR to CborCid: %w", err)
|
|
|
|
}
|
|
|
|
|
2021-05-17 20:02:23 +00:00
|
|
|
if len(cr.CommDs) != 1 {
|
|
|
|
return cid.Undef, xerrors.Errorf("CommD output must have 1 entry")
|
|
|
|
}
|
|
|
|
|
|
|
|
return cid.Cid(cr.CommDs[0]), nil
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-06 21:03:47 +00:00
|
|
|
func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok sealing.TipSetToken) (*miner.SectorPreCommitOnChainInfo, error) {
|
2020-04-06 18:07:26 +00:00
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
act, err := s.delegate.StateGetActor(ctx, maddr, tsk)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("handleSealFailed(%d): temp error: %+v", sectorNumber, err)
|
|
|
|
}
|
|
|
|
|
2021-01-29 20:01:00 +00:00
|
|
|
stor := store.ActorStore(ctx, blockstore.NewAPIBlockstore(s.delegate))
|
2020-04-06 18:07:26 +00:00
|
|
|
|
2020-09-12 03:07:52 +00:00
|
|
|
state, err := miner.Load(stor, act)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("handleSealFailed(%d): temp error: loading miner state: %+v", sectorNumber, err)
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
2020-04-13 21:05:34 +00:00
|
|
|
|
2020-09-17 02:34:13 +00:00
|
|
|
pci, err := state.GetPrecommittedSector(sectorNumber)
|
2020-06-04 13:54:36 +00:00
|
|
|
if err != nil {
|
2020-04-06 18:07:26 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
2020-09-17 15:30:15 +00:00
|
|
|
if pci == nil {
|
2020-09-17 02:34:13 +00:00
|
|
|
set, err := state.IsAllocated(sectorNumber)
|
2020-08-05 01:35:40 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("checking if sector is allocated: %w", err)
|
|
|
|
}
|
|
|
|
if set {
|
2020-08-18 16:02:13 +00:00
|
|
|
return nil, sealing.ErrSectorAllocated
|
2020-08-05 01:35:40 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 13:54:36 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
2020-04-06 18:07:26 +00:00
|
|
|
|
2020-09-17 02:34:13 +00:00
|
|
|
return pci, nil
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
2020-05-28 00:06:29 +00:00
|
|
|
func (s SealingAPIAdapter) StateSectorGetInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok sealing.TipSetToken) (*miner.SectorOnChainInfo, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateSectorGetInfo(ctx, maddr, sectorNumber, tsk)
|
|
|
|
}
|
|
|
|
|
2020-07-14 12:32:17 +00:00
|
|
|
func (s SealingAPIAdapter) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok sealing.TipSetToken) (*sealing.SectorLocation, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
l, err := s.delegate.StateSectorPartition(ctx, maddr, sectorNumber, tsk)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if l != nil {
|
|
|
|
return &sealing.SectorLocation{
|
|
|
|
Deadline: l.Deadline,
|
|
|
|
Partition: l.Partition,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, nil // not found
|
|
|
|
}
|
|
|
|
|
2021-01-14 16:14:26 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerPartitions(ctx context.Context, maddr address.Address, dlIdx uint64, tok sealing.TipSetToken) ([]api.Partition, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateMinerPartitions(ctx, maddr, dlIdx, tsk)
|
|
|
|
}
|
|
|
|
|
2021-01-25 10:28:39 +00:00
|
|
|
func (s SealingAPIAdapter) StateLookupID(ctx context.Context, addr address.Address, tok sealing.TipSetToken) (address.Address, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return address.Undef, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateLookupID(ctx, addr, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s SealingAPIAdapter) StateMarketStorageDeal(ctx context.Context, dealID abi.DealID, tok sealing.TipSetToken) (*api.MarketDeal, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateMarketStorageDeal(ctx, dealID, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s SealingAPIAdapter) StateMarketStorageDealProposal(ctx context.Context, dealID abi.DealID, tok sealing.TipSetToken) (market.DealProposal, error) {
|
2020-04-06 18:07:26 +00:00
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
2020-05-22 16:26:14 +00:00
|
|
|
return market.DealProposal{}, err
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
deal, err := s.delegate.StateMarketStorageDeal(ctx, dealID, tsk)
|
|
|
|
if err != nil {
|
2020-05-22 16:26:14 +00:00
|
|
|
return market.DealProposal{}, err
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
2020-05-22 16:26:14 +00:00
|
|
|
return deal.Proposal, nil
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 02:34:13 +00:00
|
|
|
func (s SealingAPIAdapter) StateNetworkVersion(ctx context.Context, tok sealing.TipSetToken) (network.Version, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
2020-09-17 08:17:14 +00:00
|
|
|
return network.VersionMax, err
|
2020-09-17 02:34:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateNetworkVersion(ctx, tsk)
|
|
|
|
}
|
|
|
|
|
2021-01-13 21:19:10 +00:00
|
|
|
func (s SealingAPIAdapter) StateMinerProvingDeadline(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (*dline.Info, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.StateMinerProvingDeadline(ctx, maddr, tsk)
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:47:00 +00:00
|
|
|
func (s SealingAPIAdapter) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error) {
|
2020-04-06 18:07:26 +00:00
|
|
|
msg := types.Message{
|
2020-08-12 17:47:00 +00:00
|
|
|
To: to,
|
|
|
|
From: from,
|
|
|
|
Value: value,
|
|
|
|
Method: method,
|
|
|
|
Params: params,
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 20:17:21 +00:00
|
|
|
smsg, err := s.delegate.MpoolPushMessage(ctx, &msg, &api.MessageSendSpec{MaxFee: maxFee})
|
2020-04-06 18:07:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return smsg.Cid(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s SealingAPIAdapter) ChainHead(ctx context.Context) (sealing.TipSetToken, abi.ChainEpoch, error) {
|
|
|
|
head, err := s.delegate.ChainHead(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, 0, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return head.Key().Bytes(), head.Height(), nil
|
|
|
|
}
|
|
|
|
|
2021-06-09 01:40:52 +00:00
|
|
|
func (s SealingAPIAdapter) ChainBaseFee(ctx context.Context, tok sealing.TipSetToken) (abi.TokenAmount, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return big.Zero(), err
|
|
|
|
}
|
|
|
|
|
|
|
|
ts, err := s.delegate.ChainGetTipSet(ctx, tsk)
|
|
|
|
if err != nil {
|
|
|
|
return big.Zero(), err
|
|
|
|
}
|
|
|
|
|
|
|
|
return ts.Blocks()[0].ParentBaseFee, nil
|
|
|
|
}
|
|
|
|
|
2021-01-25 10:28:39 +00:00
|
|
|
func (s SealingAPIAdapter) ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error) {
|
|
|
|
return s.delegate.ChainGetMessage(ctx, mc)
|
|
|
|
}
|
|
|
|
|
2020-08-11 23:58:35 +00:00
|
|
|
func (s SealingAPIAdapter) ChainGetRandomnessFromBeacon(ctx context.Context, tok sealing.TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
|
2020-04-06 18:07:26 +00:00
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-08-11 23:58:35 +00:00
|
|
|
return s.delegate.ChainGetRandomnessFromBeacon(ctx, tsk, personalization, randEpoch, entropy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s SealingAPIAdapter) ChainGetRandomnessFromTickets(ctx context.Context, tok sealing.TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
|
|
|
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.delegate.ChainGetRandomnessFromTickets(ctx, tsk, personalization, randEpoch, entropy)
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s SealingAPIAdapter) ChainReadObj(ctx context.Context, ocid cid.Cid) ([]byte, error) {
|
|
|
|
return s.delegate.ChainReadObj(ctx, ocid)
|
|
|
|
}
|