Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: dont crash on startup if funds migration fails #4827

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions node/modules/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,20 @@ func HandleMigrateClientFunds(lc fx.Lifecycle, ds dtypes.MetadataDS, wallet full
if xerrors.Is(err, datastore.ErrNotFound) {
return nil
}
return err
log.Errorf("client funds migration - getting datastore value: %w", err)
return nil
}

var value abi.TokenAmount
if err = value.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return err
log.Errorf("client funds migration - unmarshalling datastore value: %w", err)
return nil
}
_, err = fundMgr.Reserve(ctx, addr, addr, value)
if err != nil {
return err
log.Errorf("client funds migration - reserving funds (wallet %s, addr %s, funds %d): %w",
addr, addr, value, err)
return nil
}

return ds.Delete(datastore.NewKey("/marketfunds/client"))
Expand Down
10 changes: 7 additions & 3 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,21 @@ func HandleMigrateProviderFunds(lc fx.Lifecycle, ds dtypes.MetadataDS, node api.
}
ts, err := node.ChainHead(ctx)
if err != nil {
return err
log.Errorf("provider funds migration - getting chain head: %w", err)
return nil
}

mi, err := node.StateMinerInfo(ctx, address.Address(minerAddress), ts.Key())
if err != nil {
return err
log.Errorf("provider funds migration - getting miner info %s: %w", minerAddress, err)
return nil
}

_, err = node.MarketReserveFunds(ctx, mi.Worker, address.Address(minerAddress), value)
if err != nil {
return err
log.Errorf("provider funds migration - reserving funds (wallet %s, addr %s, funds %d): %w",
mi.Worker, minerAddress, value, err)
return nil
}

return ds.Delete(datastore.NewKey("/marketfunds/provider"))
Expand Down