From 5101f027fd72b7d0d969fc4a8a2158d79d72e81b Mon Sep 17 00:00:00 2001 From: ze97286 Date: Fri, 13 Oct 2023 13:02:31 +0100 Subject: [PATCH] fix: Ensure new account types are created for existing assets --- CHANGELOG.md | 1 + core/collateral/checkpoint.go | 2 -- core/collateral/snapshot.go | 14 -------------- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 707b81030a5..94601e6824a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/core/collateral/checkpoint.go b/core/collateral/checkpoint.go index e857d853f1a..1782c2a000d 100644 --- a/core/collateral/checkpoint.go +++ b/core/collateral/checkpoint.go @@ -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)) } diff --git a/core/collateral/snapshot.go b/core/collateral/snapshot.go index bd973712b2e..52093ef6e71 100644 --- a/core/collateral/snapshot.go +++ b/core/collateral/snapshot.go @@ -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