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

Release/v0.73.9 #10235

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.73.9

### 🐛 Fixes

- [10218](https://github.com/vegaprotocol/vega/issues/10218) - Volume discount stats shows volumes even if party doesn't qualify for a discount tier.
- [10233](https://github.com/vegaprotocol/vega/issues/10233) - Fix expiring stop orders panic.

## 0.73.8

### 🐛 Fixes
Expand Down
2 changes: 1 addition & 1 deletion core/execution/future/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ func (m *Market) removeAllStopOrders(
sos, _ := m.stopOrders.Cancel(v.Party(), "")
for _, so := range sos {
if so.Expiry.Expires() {
_ = m.expiringOrders.RemoveOrder(so.Expiry.ExpiresAt.UnixNano(), so.ID)
_ = m.expiringStopOrders.RemoveOrder(so.Expiry.ExpiresAt.UnixNano(), so.ID)
}
evts = append(evts, events.NewStopOrderEvent(ctx, so))
}
Expand Down
10 changes: 10 additions & 0 deletions core/volumediscount/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (e *Engine) computeFactorsByParty(ctx context.Context, epoch uint64) {

for _, party := range parties {
notionalVolume := e.avgVolumePerParty[party]
qualifiedForTier := false
for i := tiersLen - 1; i >= 0; i-- {
tier := e.currentProgram.VolumeBenefitTiers[i]
if notionalVolume.GreaterThanOrEqual(tier.MinimumRunningNotionalTakerVolume.ToDecimal()) {
Expand All @@ -202,9 +203,18 @@ func (e *Engine) computeFactorsByParty(ctx context.Context, epoch uint64) {
DiscountFactor: tier.VolumeDiscountFactor.String(),
RunningVolume: notionalVolume.Round(0).String(),
})
qualifiedForTier = true
break
}
}
// if the party hasn't qualified, then still send the stats but with a zero factor
if !qualifiedForTier {
evt.Stats = append(evt.Stats, &eventspb.PartyVolumeDiscountStats{
PartyId: party.String(),
DiscountFactor: "0",
RunningVolume: notionalVolume.Round(0).String(),
})
}
}

e.broker.Send(events.NewVolumeDiscountStatsUpdatedEvent(ctx, evt))
Expand Down
4 changes: 2 additions & 2 deletions core/volumediscount/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestDiscountFactor(t *testing.T) {
}).Times(1)

// end the epoch to get the market activity recorded
expectStatsUpdated(t, broker)
expectStatsUpdatedWithUnqualifiedParties(t, broker)
currentTime = currentTime.Add(1 * time.Minute)
endEpoch(t, engine, currentEpoch, currentTime.Add(1*time.Minute))

Expand Down Expand Up @@ -278,7 +278,7 @@ func TestDiscountFactorWithWindow(t *testing.T) {
"p7": num.NewUint(5000),
}).Times(1)

expectStatsUpdated(t, broker)
expectStatsUpdatedWithUnqualifiedParties(t, broker)
currentTime = currentTime.Add(1 * time.Minute)
endEpoch(t, engine, currentEpoch, currentTime)
// start a new epoch for the discount factors to be in place
Expand Down
19 changes: 19 additions & 0 deletions core/volumediscount/helpers_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ func expectStatsUpdated(t *testing.T, broker *mocks.MockBroker) {
}).Times(1)
}

func expectStatsUpdatedWithUnqualifiedParties(t *testing.T, broker *mocks.MockBroker) {
t.Helper()

broker.EXPECT().Send(gomock.Any()).Do(func(evt events.Event) {
update, ok := evt.(*events.VolumeDiscountStatsUpdated)
require.Truef(t, ok, "expecting event of type *events.VolumeDiscountStatsUpdated but got %T", evt)
stats := update.VolumeDiscountStatsUpdated()
foundUnqualifiedParty := false
for _, s := range stats.Stats {
if s.PartyId == "p1" {
foundUnqualifiedParty = true
require.Equal(t, "0", s.DiscountFactor)
require.Equal(t, "900", s.RunningVolume)
}
}
require.True(t, foundUnqualifiedParty)
}).Times(1)
}

func expectProgramStarted(t *testing.T, broker *mocks.MockBroker, p1 *types.VolumeDiscountProgram) {
t.Helper()

Expand Down
19 changes: 14 additions & 5 deletions datanode/sqlstore/volume_discount_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func TestVolumeDiscountStats_GetVolumeDiscountStats(t *testing.T) {
ps := sqlstore.NewParties(connectionSource)
vds := sqlstore.NewVolumeDiscountStats(connectionSource)

parties := make([]entities.Party, 0, 5)
for i := 0; i < 5; i++ {
parties := make([]entities.Party, 0, 6)
for i := 0; i < 6; i++ {
block := addTestBlockForTime(t, ctx, bs, time.Now().Add(time.Duration(i-10)*time.Minute))
parties = append(parties, addTestParty(t, ctx, ps, block))
}
Expand Down Expand Up @@ -231,8 +231,8 @@ func flattenVolumeDiscountStatsForParty(flattenStats []entities.FlattenVolumeDis
func setupPartyVolumeDiscountStats(t *testing.T, ctx context.Context, ps *sqlstore.Parties, bs *sqlstore.Blocks) []*eventspb.PartyVolumeDiscountStats {
t.Helper()

parties := make([]entities.Party, 0, 5)
for i := 0; i < 5; i++ {
parties := make([]entities.Party, 0, 6)
for i := 0; i < 6; i++ {
block := addTestBlockForTime(t, ctx, bs, time.Now().Add(time.Duration(i-10)*time.Minute))
parties = append(parties, addTestParty(t, ctx, ps, block))
}
Expand All @@ -249,8 +249,17 @@ func setupPartyVolumeDiscountStats(t *testing.T, ctx context.Context, ps *sqlsto
func setupPartyVolumeDiscountStatsMod(t *testing.T, parties []entities.Party, f func(i int, party entities.Party) *eventspb.PartyVolumeDiscountStats) []*eventspb.PartyVolumeDiscountStats {
t.Helper()

partiesStats := make([]*eventspb.PartyVolumeDiscountStats, 0, 5)
partiesStats := make([]*eventspb.PartyVolumeDiscountStats, 0, 6)
for i, p := range parties {
// make the last party an unqualified party
if i == len(parties)-1 {
partiesStats = append(partiesStats, &eventspb.PartyVolumeDiscountStats{
PartyId: p.ID.String(),
DiscountFactor: "0",
RunningVolume: "99",
})
continue
}
partiesStats = append(partiesStats, f(i, p))
}

Expand Down
2 changes: 1 addition & 1 deletion protos/blockexplorer/api/v1/blockexplorer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protos/data-node/api/v2/trading_data.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protos/sources/blockexplorer/api/v1/blockexplorer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ option go_package = "code.vegaprotocol.io/vega/protos/blockexplorer/api/v1";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Vega block explorer APIs";
version: "v0.73.8";
version: "v0.73.9";
}
schemes: [
HTTP,
Expand Down
2 changes: 1 addition & 1 deletion protos/sources/data-node/api/v2/trading_data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ option go_package = "code.vegaprotocol.io/vega/protos/data-node/api/v2";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Vega data node APIs";
version: "v0.73.8";
version: "v0.73.9";
}
schemes: [
HTTP,
Expand Down
2 changes: 1 addition & 1 deletion protos/sources/vega/api/v1/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ option go_package = "code.vegaprotocol.io/vega/protos/vega/api/v1";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Vega core APIs";
version: "v0.73.8";
version: "v0.73.9";
}
schemes: [
HTTP,
Expand Down
2 changes: 1 addition & 1 deletion protos/sources/vega/api/v1/corestate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ option go_package = "code.vegaprotocol.io/vega/protos/vega/api/v1";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Vega core state APIs";
version: "v0.73.8";
version: "v0.73.9";
}
schemes: [
HTTP,
Expand Down
2 changes: 1 addition & 1 deletion protos/vega/api/v1/core.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protos/vega/api/v1/corestate.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

var (
cliVersionHash = ""
cliVersion = "v0.73.8"
cliVersion = "v0.73.9"
)

func init() {
Expand Down
Loading