Merge branch 'master' into sbansal/nonce-coordination-and-consensus-for-chain-nodes
This commit is contained in:
@@ -837,7 +837,7 @@ func (a *API) doRetrieval(ctx context.Context, order api.RetrievalOrder, sel dat
|
||||
return 0, xerrors.Errorf("cannot make retrieval deal for zero bytes")
|
||||
}
|
||||
|
||||
ppb := types.BigDiv(order.Total, types.NewInt(order.Size))
|
||||
ppb := types.BigDiv(big.Sub(order.Total, order.UnsealPrice), types.NewInt(order.Size))
|
||||
|
||||
params, err := rm.NewParamsV1(ppb, order.PaymentInterval, order.PaymentIntervalIncrease, sel, order.Piece, order.UnsealPrice)
|
||||
if err != nil {
|
||||
|
||||
@@ -290,6 +290,10 @@ func gasEstimateGasLimit(
|
||||
if err != nil {
|
||||
return -1, xerrors.Errorf("CallWithGas failed: %w", err)
|
||||
}
|
||||
if res.MsgRct.ExitCode == exitcode.SysErrOutOfGas {
|
||||
return -1, &api.ErrOutOfGas{}
|
||||
}
|
||||
|
||||
if res.MsgRct.ExitCode != exitcode.Ok {
|
||||
return -1, xerrors.Errorf("message execution failed: exit %s, reason: %s", res.MsgRct.ExitCode, res.Error)
|
||||
}
|
||||
@@ -356,7 +360,7 @@ func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Messag
|
||||
if msg.GasLimit == 0 {
|
||||
gasLimit, err := m.GasEstimateGasLimit(ctx, msg, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("estimating gas used: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
msg.GasLimit = int64(float64(gasLimit) * m.Mpool.GetConfig().GasLimitOverestimation)
|
||||
}
|
||||
|
||||
+4
-13
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/ipfs/go-cid"
|
||||
"go.uber.org/fx"
|
||||
"golang.org/x/xerrors"
|
||||
@@ -41,7 +42,6 @@ type MpoolAPI struct {
|
||||
MpoolModuleAPI
|
||||
|
||||
WalletAPI
|
||||
|
||||
GasAPI
|
||||
|
||||
RaftAPI
|
||||
@@ -160,8 +160,8 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spe
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this uuid has already been processed
|
||||
if spec != nil {
|
||||
// Check if this uuid has already been processed. Ignore if uuid is not populated
|
||||
if (spec != nil) && (spec.MsgUuid != uuid.UUID{}) {
|
||||
signedMessage, err := a.MessageSigner.GetSignedMessage(ctx, spec.MsgUuid)
|
||||
if err == nil {
|
||||
log.Warnf("Message already processed. cid=%s", signedMessage.Cid())
|
||||
@@ -224,7 +224,7 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spe
|
||||
}
|
||||
|
||||
// Store uuid->signed message in datastore
|
||||
if spec != nil {
|
||||
if (spec != nil) && (spec.MsgUuid != uuid.UUID{}) {
|
||||
err = a.MessageSigner.StoreSignedMessage(ctx, spec.MsgUuid, signedMsg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -289,12 +289,3 @@ func (a *MpoolAPI) MpoolGetNonce(ctx context.Context, addr address.Address) (uin
|
||||
func (a *MpoolAPI) MpoolSub(ctx context.Context) (<-chan api.MpoolUpdate, error) {
|
||||
return a.Mpool.Updates(ctx)
|
||||
}
|
||||
|
||||
//func (a *MpoolAPI) GetRaftState(ctx context.Context) (consensus.RaftState, error) {
|
||||
// state, err := a.MessageSigner.GetRaftState(ctx)
|
||||
// raftState := state.()
|
||||
//}
|
||||
//
|
||||
//func (a *MpoolAPI) RaftLeader(ctx context.Context) (peer.ID, error) {
|
||||
// return a.MessageSigner.Leader(ctx)
|
||||
//}
|
||||
|
||||
@@ -177,6 +177,9 @@ func (m *StateModule) StateMinerInfo(ctx context.Context, actor address.Address,
|
||||
SectorSize: info.SectorSize,
|
||||
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
||||
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
|
||||
Beneficiary: info.Beneficiary,
|
||||
BeneficiaryTerm: &info.BeneficiaryTerm,
|
||||
PendingBeneficiaryTerm: info.PendingBeneficiaryTerm,
|
||||
}
|
||||
|
||||
if info.PendingWorkerKey != nil {
|
||||
@@ -479,7 +482,12 @@ func (m *StateModule) StateLookupID(ctx context.Context, addr address.Address, t
|
||||
return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
return m.StateManager.LookupID(ctx, addr, ts)
|
||||
ret, err := m.StateManager.LookupID(ctx, addr, ts)
|
||||
if err != nil && xerrors.Is(err, types.ErrActorNotFound) {
|
||||
return address.Undef, &api.ErrActorNotFound{}
|
||||
}
|
||||
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateLookupRobustAddress(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {
|
||||
|
||||
+31
-3
@@ -182,16 +182,20 @@ func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) (abi.SectorID, erro
|
||||
return abi.SectorID{}, err
|
||||
}
|
||||
|
||||
return sm.waitSectorStarted(ctx, sr.ID)
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) waitSectorStarted(ctx context.Context, si abi.SectorID) (abi.SectorID, error) {
|
||||
// wait for the sector to enter the Packing state
|
||||
// TODO: instead of polling implement some pubsub-type thing in storagefsm
|
||||
for {
|
||||
info, err := sm.Miner.SectorsStatus(ctx, sr.ID.Number, false)
|
||||
info, err := sm.Miner.SectorsStatus(ctx, si.Number, false)
|
||||
if err != nil {
|
||||
return abi.SectorID{}, xerrors.Errorf("getting pledged sector info: %w", err)
|
||||
}
|
||||
|
||||
if info.State != api.SectorState(sealing.UndefinedSectorState) {
|
||||
return sr.ID, nil
|
||||
return si, nil
|
||||
}
|
||||
|
||||
select {
|
||||
@@ -448,6 +452,15 @@ func (sm *StorageMinerAPI) SectorNumFree(ctx context.Context, name string) error
|
||||
return sm.Miner.NumFree(ctx, name)
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) SectorReceive(ctx context.Context, meta api.RemoteSectorMeta) error {
|
||||
if err := sm.Miner.Receive(ctx, meta); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := sm.waitSectorStarted(ctx, meta.Sector)
|
||||
return err
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]minertypes.SubmitWindowedPoStParams, error) {
|
||||
var ts *types.TipSet
|
||||
var err error
|
||||
@@ -1349,6 +1362,14 @@ func (sm *StorageMinerAPI) RuntimeSubsystems(context.Context) (res api.MinerSubs
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) ActorWithdrawBalance(ctx context.Context, amount abi.TokenAmount) (cid.Cid, error) {
|
||||
return sm.withdrawBalance(ctx, amount, true)
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) BeneficiaryWithdrawBalance(ctx context.Context, amount abi.TokenAmount) (cid.Cid, error) {
|
||||
return sm.withdrawBalance(ctx, amount, false)
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) withdrawBalance(ctx context.Context, amount abi.TokenAmount, fromOwner bool) (cid.Cid, error) {
|
||||
available, err := sm.Full.StateMinerAvailableBalance(ctx, sm.Miner.Address(), types.EmptyTSK)
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("Error getting miner balance: %w", err)
|
||||
@@ -1374,9 +1395,16 @@ func (sm *StorageMinerAPI) ActorWithdrawBalance(ctx context.Context, amount abi.
|
||||
return cid.Undef, xerrors.Errorf("Error getting miner's owner address: %w", err)
|
||||
}
|
||||
|
||||
var sender address.Address
|
||||
if fromOwner {
|
||||
sender = mi.Owner
|
||||
} else {
|
||||
sender = mi.Beneficiary
|
||||
}
|
||||
|
||||
smsg, err := sm.Full.MpoolPushMessage(ctx, &types.Message{
|
||||
To: sm.Miner.Address(),
|
||||
From: mi.Owner,
|
||||
From: sender,
|
||||
Value: types.NewInt(0),
|
||||
Method: builtintypes.MethodsMiner.WithdrawBalance,
|
||||
Params: params,
|
||||
|
||||
Reference in New Issue
Block a user