Skip to content

Commit

Permalink
Merge pull request #9778 from vegaprotocol/9773
Browse files Browse the repository at this point in the history
fix: Ensure new account types are created for existing assets
  • Loading branch information
jeremyletang authored Oct 13, 2023
2 parents caae176 + 50cb274 commit d624a75
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
- [8703](https://github.com/vegaprotocol/vega/issues/8703) - Wire stop orders cancellation
- [8698](https://github.com/vegaprotocol/vega/issues/8698) - Always set the `ToAccount` field when clearing fees.
- [9773](https://github.com/vegaprotocol/vega/issues/9773) - Ensure invalid market for transfer doesn't panic
- [9777](https://github.com/vegaprotocol/vega/issues/9777) - Ensure new account types are created for existing assets

## 0.71.0

Expand Down
2 changes: 0 additions & 2 deletions core/collateral/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ func (e *Engine) Load(ctx context.Context, data []byte) error {
ledgerMovements = append(ledgerMovements, lm)
}

e.getOrCreateNetTreasuryAndGlobalInsForAssets(ctx, assets)

if len(ledgerMovements) > 0 {
e.broker.Send(events.NewLedgerMovements(ctx, ledgerMovements))
}
Expand Down
14 changes: 0 additions & 14 deletions core/collateral/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,12 @@ func (e *Engine) restoreAccounts(ctx context.Context, accs *types.CollateralAcco
e.broker.SendBatch(pevts)
var err error
e.state.serialisedAccounts, err = proto.Marshal(p.IntoProto())
e.getOrCreateNetTreasuryAndGlobalInsForAssets(ctx, assets)
e.updateNextBalanceSnapshot(accs.NextBalanceSnapshot)
e.snapshotBalances()
e.activeRestore = true
return err
}

func (e *Engine) getOrCreateNetTreasuryAndGlobalInsForAssets(ctx context.Context, assets map[string]struct{}) {
// bit of migration - ensure that the network treasury and global insurance account are created for all assets
assetStr := make([]string, 0, len(assets))
for k := range assets {
assetStr = append(assetStr, k)
}
sort.Strings(assetStr)
for _, asset := range assetStr {
e.GetOrCreateNetworkTreasuryAccount(ctx, asset)
e.GetOrCreateGlobalInsuranceAccount(ctx, asset)
}
}

func (e *Engine) restoreAssets(assets *types.CollateralAssets, p *types.Payload) error {
// @TODO the ID and name might not be the same, perhaps we need
// to wrap the asset details to preserve that data
Expand Down

0 comments on commit d624a75

Please sign in to comment.