don't wait for msg to land on chain
This commit is contained in:
parent
e9705c4e26
commit
e0e0b0b62f
@ -50,10 +50,8 @@ type StorageMiner interface {
|
|||||||
|
|
||||||
// WithdrawBalance allows to withdraw balance from miner actor to owner address
|
// WithdrawBalance allows to withdraw balance from miner actor to owner address
|
||||||
// Specify amount as "0" to withdraw full balance. This method returns a message CID
|
// Specify amount as "0" to withdraw full balance. This method returns a message CID
|
||||||
// even when StateWaitMessage() fails and receipt exit code is non-zero
|
// and does not wait for message execution
|
||||||
// User should check for message execution manually if this method returns a
|
WithdrawBalance(ctx context.Context, amount abi.TokenAmount) (cid.Cid, error) //perm:admin
|
||||||
// "Timeout waiting for withdrawal message" error.
|
|
||||||
WithdrawBalance(ctx context.Context, amount abi.TokenAmount, confidence uint64) (cid.Cid, error) //perm:admin
|
|
||||||
|
|
||||||
MiningBase(context.Context) (*types.TipSet, error) //perm:read
|
MiningBase(context.Context) (*types.TipSet, error) //perm:read
|
||||||
|
|
||||||
|
@ -880,7 +880,7 @@ type StorageMinerStruct struct {
|
|||||||
|
|
||||||
StorageTryLock func(p0 context.Context, p1 abi.SectorID, p2 storiface.SectorFileType, p3 storiface.SectorFileType) (bool, error) `perm:"admin"`
|
StorageTryLock func(p0 context.Context, p1 abi.SectorID, p2 storiface.SectorFileType, p3 storiface.SectorFileType) (bool, error) `perm:"admin"`
|
||||||
|
|
||||||
WithdrawBalance func(p0 context.Context, p1 abi.TokenAmount, p2 uint64) (cid.Cid, error) `perm:"admin"`
|
WithdrawBalance func(p0 context.Context, p1 abi.TokenAmount) (cid.Cid, error) `perm:"admin"`
|
||||||
|
|
||||||
WorkerConnect func(p0 context.Context, p1 string) error `perm:"admin"`
|
WorkerConnect func(p0 context.Context, p1 string) error `perm:"admin"`
|
||||||
|
|
||||||
@ -5188,14 +5188,14 @@ func (s *StorageMinerStub) StorageTryLock(p0 context.Context, p1 abi.SectorID, p
|
|||||||
return false, ErrNotSupported
|
return false, ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StorageMinerStruct) WithdrawBalance(p0 context.Context, p1 abi.TokenAmount, p2 uint64) (cid.Cid, error) {
|
func (s *StorageMinerStruct) WithdrawBalance(p0 context.Context, p1 abi.TokenAmount) (cid.Cid, error) {
|
||||||
if s.Internal.WithdrawBalance == nil {
|
if s.Internal.WithdrawBalance == nil {
|
||||||
return *new(cid.Cid), ErrNotSupported
|
return *new(cid.Cid), ErrNotSupported
|
||||||
}
|
}
|
||||||
return s.Internal.WithdrawBalance(p0, p1, p2)
|
return s.Internal.WithdrawBalance(p0, p1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StorageMinerStub) WithdrawBalance(p0 context.Context, p1 abi.TokenAmount, p2 uint64) (cid.Cid, error) {
|
func (s *StorageMinerStub) WithdrawBalance(p0 context.Context, p1 abi.TokenAmount) (cid.Cid, error) {
|
||||||
return *new(cid.Cid), ErrNotSupported
|
return *new(cid.Cid), ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -243,24 +243,29 @@ var actorWithdrawCmd = &cli.Command{
|
|||||||
|
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
res, err := nodeApi.WithdrawBalance(ctx, amount, uint64(cctx.Int("confidence")))
|
res, err := nodeApi.WithdrawBalance(ctx, amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := api.StateSearchMsg(ctx, res)
|
// wait for it to get mined into a block
|
||||||
|
wait, err := api.StateWaitMsg(ctx, res, uint64(cctx.Int("confidence")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return xerrors.Errorf("Timeout waiting for withdrawal message %s", wait.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
nv, err := api.StateNetworkVersion(ctx, msg.TipSet)
|
if wait.Receipt.ExitCode != 0 {
|
||||||
|
return xerrors.Errorf("Failed to execute withdrawal message %s: %w", wait.Message, wait.Receipt.ExitCode.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
nv, err := api.StateNetworkVersion(ctx, wait.TipSet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if nv >= network.Version14 {
|
if nv >= network.Version14 {
|
||||||
var withdrawn abi.TokenAmount
|
var withdrawn abi.TokenAmount
|
||||||
if err := withdrawn.UnmarshalCBOR(bytes.NewReader(msg.Receipt.Return)); err != nil {
|
if err := withdrawn.UnmarshalCBOR(bytes.NewReader(wait.Receipt.Return)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3670,9 +3670,7 @@ Response: `true`
|
|||||||
### WithdrawBalance
|
### WithdrawBalance
|
||||||
WithdrawBalance allows to withdraw balance from miner actor to owner address
|
WithdrawBalance allows to withdraw balance from miner actor to owner address
|
||||||
Specify amount as "0" to withdraw full balance. This method returns a message CID
|
Specify amount as "0" to withdraw full balance. This method returns a message CID
|
||||||
even when StateWaitMessage() fails and receipt exit code is non-zero
|
and does not wait for message execution
|
||||||
User should check for message execution manually if this method returns a
|
|
||||||
"Timeout waiting for withdrawal message" error.
|
|
||||||
|
|
||||||
|
|
||||||
Perms: admin
|
Perms: admin
|
||||||
@ -3680,8 +3678,7 @@ Perms: admin
|
|||||||
Inputs:
|
Inputs:
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
"0",
|
"0"
|
||||||
42
|
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1283,7 +1283,7 @@ func (sm *StorageMinerAPI) RuntimeSubsystems(context.Context) (res api.MinerSubs
|
|||||||
return sm.EnabledSubsystems, nil
|
return sm.EnabledSubsystems, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) WithdrawBalance(ctx context.Context, amount abi.TokenAmount, confidence uint64) (cid.Cid, error) {
|
func (sm *StorageMinerAPI) WithdrawBalance(ctx context.Context, amount abi.TokenAmount) (cid.Cid, error) {
|
||||||
available, err := sm.Full.StateMinerAvailableBalance(ctx, sm.Miner.Address(), types.EmptyTSK)
|
available, err := sm.Full.StateMinerAvailableBalance(ctx, sm.Miner.Address(), types.EmptyTSK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("Error getting miner balance: %w", err)
|
return cid.Undef, xerrors.Errorf("Error getting miner balance: %w", err)
|
||||||
@ -1320,15 +1320,5 @@ func (sm *StorageMinerAPI) WithdrawBalance(ctx context.Context, amount abi.Token
|
|||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for it to get mined into a block
|
return smsg.Cid(), nil
|
||||||
wait, err := sm.Full.StateWaitMsg(ctx, smsg.Cid(), confidence, abi.ChainEpoch(2), true)
|
|
||||||
if err != nil {
|
|
||||||
return smsg.Cid(), xerrors.Errorf("Timeout waiting for withdrawal message")
|
|
||||||
}
|
|
||||||
|
|
||||||
if wait.Receipt.ExitCode != 0 {
|
|
||||||
return wait.Message, xerrors.Errorf("Failed to execute withdrawal message: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return wait.Message, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user