Skip to content

Commit

Permalink
Merge pull request #10353 from vegaprotocol/update-snapshot-migrations
Browse files Browse the repository at this point in the history
chore: update snapshot migrations given mainnet patches
  • Loading branch information
jeremyletang authored Jan 10, 2024
2 parents 5ef4d15 + c681b23 commit c546152
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/execution/future/market_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func NewMarketFromSnapshot(

as := monitor.NewAuctionStateFromSnapshot(mkt, em.AuctionState)

if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.10") {
// protocol upgrade from v0.73.9, lets populate the new liquidity-fee-settings with a default marginal-cost method
if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.12") {
// protocol upgrade from v0.73.12, lets populate the new liquidity-fee-settings with a default marginal-cost method
log.Info("migrating liquidity fee settings for existing market", logging.String("mid", mkt.ID))
mkt.Fees.LiquidityFeeSettings = &types.LiquidityFeeSettings{
Method: types.LiquidityFeeMethodMarginalCost,
Expand Down
2 changes: 1 addition & 1 deletion core/execution/future/market_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestRestoreMarketUpgradeV0_73_2(t *testing.T) {
em.Market.Fees.LiquidityFeeSettings = nil

// and set in the context the information that says we are upgrading
ctx := vegacontext.WithSnapshotInfo(context.Background(), "v0.73.10", true)
ctx := vegacontext.WithSnapshotInfo(context.Background(), "v0.73.12", true)
snap, err := newMarketFromSnapshot(t, ctx, ctrl, em, oracleEngine)
require.NoError(t, err)
require.NotEmpty(t, snap)
Expand Down
6 changes: 3 additions & 3 deletions core/governance/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (e *Engine) restoreActiveProposals(ctx context.Context, active *types.Gover
invalidVotes: votesAsMap(p.Invalid),
}

if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.10") {
if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.12") {
if nm := pp.Proposal.Terms.GetNewMarket(); nm != nil {
e.log.Info("migrating liquidity fee settings for new market proposal", logging.String("pid", pp.ID))
nm.Changes.LiquidityFeeSettings = &types.LiquidityFeeSettings{
Expand All @@ -275,7 +275,7 @@ func (e *Engine) restoreActiveProposals(ctx context.Context, active *types.Gover
}
}
}
if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.10") {
if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.12") {
if pp.Terms.IsNewMarket() {
pp.Terms.GetNewMarket().Changes.MarkPriceConfiguration = defaultMarkPriceConfig.DeepClone()
}
Expand Down Expand Up @@ -328,7 +328,7 @@ func (e *Engine) restoreBatchActiveProposals(ctx context.Context, active *types.

evts = append(evts, events.NewProposalEventFromProto(ctx, bp.BatchProposal.ToProto()))
for _, p := range bp.BatchProposal.Proposals {
if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.10") {
if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.12") {
if p.Terms.IsNewMarket() {
p.Terms.GetNewMarket().Changes.MarkPriceConfiguration = defaultMarkPriceConfig.DeepClone()
}
Expand Down
2 changes: 1 addition & 1 deletion core/products/perpetual_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func NewPerpetualFromSnapshot(
perps.startedAt = state.StartedAt
perps.seq = state.Seq

if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.10") {
if vgcontext.InProgressUpgradeFrom(ctx, "v0.73.12") {
// do it the old way where we'd regenerate the cached values by adding the points again
perps.externalTWAP = NewCachedTWAP(log, state.StartedAt, perps.auctions)
perps.internalTWAP = NewCachedTWAP(log, state.StartedAt, perps.auctions)
Expand Down

0 comments on commit c546152

Please sign in to comment.