Skip to content

Commit

Permalink
Merge pull request #9529 from vegaprotocol/9528-orders-while-gov-susp…
Browse files Browse the repository at this point in the history
…ended

fix: allow order submission when in governance suspended auction
  • Loading branch information
wwestgarth authored Sep 25, 2023
2 parents f407798 + 08cabdd commit bfd63da
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
- [8800](https://github.com/vegaprotocol/vega/issues/8800) - `expiresAt` is always null in the Stop Orders `API`.
- [8796](https://github.com/vegaprotocol/vega/issues/8796) - Avoid updating active proposals slice while iterating over it.
- [8631](https://github.com/vegaprotocol/vega/issues/8631) - Prevent duplicate Ethereum call chain event after snapshot start
- [9528](https://github.com/vegaprotocol/vega/issues/9528) - Allow order submission when in governance suspended auction.
- [8679](https://github.com/vegaprotocol/vega/issues/8679) - Disallow snapshot state-sync if local snapshots exist
- [8364](https://github.com/vegaprotocol/vega/issues/8364) - Initialising from network history not working after database wipe
- [8827](https://github.com/vegaprotocol/vega/issues/8827) - Add block height validation to validator initiated transactions and pruning to the `pow` engine cache
Expand Down
3 changes: 2 additions & 1 deletion core/execution/future/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -4000,7 +4000,8 @@ func (m *Market) settlementDataWithLock(ctx context.Context, finalState types.Ma
func (m *Market) canTrade() bool {
return m.mkt.State == types.MarketStateActive ||
m.mkt.State == types.MarketStatePending ||
m.mkt.State == types.MarketStateSuspended
m.mkt.State == types.MarketStateSuspended ||
m.mkt.State == types.MarketStateSuspendedViaGovernance
}

// cleanupOnReject remove all resources created while the
Expand Down
52 changes: 52 additions & 0 deletions core/execution/update_market_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package execution_test

import (
"context"
"encoding/hex"
"fmt"
"testing"
"time"

dstypes "code.vegaprotocol.io/vega/core/datasource/common"
"code.vegaprotocol.io/vega/core/execution"
"code.vegaprotocol.io/vega/core/types"
vgcontext "code.vegaprotocol.io/vega/libs/context"
"code.vegaprotocol.io/vega/libs/num"
vgtest "code.vegaprotocol.io/vega/libs/test"
paths2 "code.vegaprotocol.io/vega/paths"
Expand Down Expand Up @@ -135,3 +137,53 @@ func TestSuspendMarketViaGovernance(t *testing.T) {
require.Equal(t, types.MarketStateActive, state.MarketState)
require.Equal(t, types.MarketTradingModeContinuous, state.MarketTradingMode)
}

func TestSubmitOrderWhenSuspended(t *testing.T) {
ctx := vgtest.VegaContext("chainid", 100)
now := time.Now()
exec := getEngineWithParties(t, now, num.NewUint(1000000000), "lp", "p1", "p2", "p3", "p4")
pubKey := &dstypes.SignerPubKey{
PubKey: &dstypes.PubKey{
Key: "0xDEADBEEF",
},
}
mkt := newMarket("MarketID", pubKey)
err := exec.engine.SubmitMarket(context.Background(), mkt, "", now)
require.NoError(t, err)

exec.engine.StartOpeningAuction(context.Background(), mkt.ID)

// during opening auction
state, err := exec.engine.GetMarketData(mkt.ID)
require.NoError(t, err)
require.Equal(t, types.MarketStateActive, state.MarketState)
require.Equal(t, types.MarketTradingModeContinuous, state.MarketTradingMode)

config := &types.MarketStateUpdateConfiguration{
MarketID: mkt.ID,
UpdateType: types.MarketStateUpdateTypeSuspend,
SettlementPrice: num.NewUint(100),
}
require.NoError(t, exec.engine.UpdateMarketState(ctx, config))

// after governance suspension
state, err = exec.engine.GetMarketData(mkt.ID)
require.NoError(t, err)
require.Equal(t, types.MarketStateSuspendedViaGovernance, state.MarketState)
require.Equal(t, types.MarketTradingModeSuspendedViaGovernance, state.MarketTradingMode)

// check we can submit an order
os1 := &types.OrderSubmission{
MarketID: mkt.ID,
Price: num.NewUint(99),
Size: 1,
Side: types.SideBuy,
TimeInForce: types.OrderTimeInForceGTC,
Type: types.OrderTypeLimit,
Reference: "o1",
}
idgen := &stubIDGen{}
vgctx := vgcontext.WithTraceID(context.Background(), hex.EncodeToString([]byte("0deadbeef")))
_, err = exec.engine.SubmitOrder(vgctx, os1, "p1", idgen, "o1p1")
require.NoError(t, err)
}

0 comments on commit bfd63da

Please sign in to comment.