vegaprotocol / vega

A Go implementation of the Vega Protocol, a protocol for creating and trading derivatives on a fully decentralised network.
https://vega.xyz
GNU Affero General Public License v3.0
37 stars 19 forks source link

[Bug]: Market in auction suspended via governance becomes active before being suspended via governance #9161

Closed MuthuVega closed 10 months ago

MuthuVega commented 11 months ago

Problem encountered

Spec Ref: Market Governance - https://github.com/vegaprotocol/specs/blob/cosmicelevator/protocol/0028-GOVE-governance.md

Trying to test the below acceptance criteria.

AC: Governance vote to suspend a market that's currently in auction trading mode keeps it in auction mode at vote enactment time. Even if the trigger that originally put the market into auction mode is no longer violated the market must remain in auction. (0028-GOVE-114)

When testing able to see that the market goes into ACTIVE before being successfully STATE_SUSPENDED_VIA_GOVERNANCE

However, the AC states that the market should be held in suspended state and should not return back to ACTIVE.

Observed behaviour

As explained above

Proposal Events:

{"id":"252-5","block":"181A3D0DAD436260849B235DBD23A328DC4A34AED4872138BC399545A63098CF","type":"BUS_EVENT_TYPE_PROPOSAL","proposal":{"id":"6dc09df7fc443b8e2b4528093abc8f60a9306b31731c8648b006303710c2b421","reference":"91F3299D61","partyId":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a","state":"STATE_OPEN","timestamp":"1692713093362237537","terms":{"closingTimestamp":"1692713101","enactmentTimestamp":"1692713115","updateMarketState":{"changes":{"marketId":"04f5e92db86e67d50438c8da8f8d3f24f52f7087e234d17fec7dc5f8f2054b70","updateType":"MARKET_STATE_UPDATE_TYPE_SUSPEND"}}},"rationale":{"description":"Market State Update","title":"Market State Update Proposal: Suspend"},"requiredParticipation":"0.00000015","requiredMajority":"0.66","requiredLiquidityProviderParticipation":"0.00001","requiredLiquidityProviderMajority":"0.66"},"version":1,"chainId":"testnet-001","txHash":"AD560412FCB85943860C1AA7F68878706D2A82E76F7E30D6F402F546E10A7C7B"}
{"id":"265-13","block":"132FDF4CFCA7C62031A3185480B68C17B4E89CFE67CEFB2AD1E9BD3031AC4CCD","type":"BUS_EVENT_TYPE_PROPOSAL","proposal":{"id":"6dc09df7fc443b8e2b4528093abc8f60a9306b31731c8648b006303710c2b421","reference":"91F3299D61","partyId":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a","state":"STATE_PASSED","timestamp":"1692713093362237537","terms":{"closingTimestamp":"1692713101","enactmentTimestamp":"1692713115","updateMarketState":{"changes":{"marketId":"04f5e92db86e67d50438c8da8f8d3f24f52f7087e234d17fec7dc5f8f2054b70","updateType":"MARKET_STATE_UPDATE_TYPE_SUSPEND"}}},"rationale":{"description":"Market State Update","title":"Market State Update Proposal: Suspend"},"requiredParticipation":"0.00000015","requiredMajority":"0.66","requiredLiquidityProviderParticipation":"0.00001","requiredLiquidityProviderMajority":"0.66"},"version":1,"chainId":"testnet-001","txHash":"132FDF4CFCA7C62031A3185480B68C17B4E89CFE67CEFB2AD1E9BD3031AC4CCD"}
{"id":"286-10","block":"7185AF16CA854EFBEDA66DCED52BEDA9A4722C04E2DD1595CEF05B31D65A219B","type":"BUS_EVENT_TYPE_PROPOSAL","proposal":{"id":"6dc09df7fc443b8e2b4528093abc8f60a9306b31731c8648b006303710c2b421","reference":"91F3299D61","partyId":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a","state":"STATE_ENACTED","timestamp":"1692713093362237537","terms":{"closingTimestamp":"1692713101","enactmentTimestamp":"1692713115","updateMarketState":{"changes":{"marketId":"04f5e92db86e67d50438c8da8f8d3f24f52f7087e234d17fec7dc5f8f2054b70","updateType":"MARKET_STATE_UPDATE_TYPE_SUSPEND"}}},"rationale":{"description":"Market State Update","title":"Market State Update Proposal: Suspend"},"requiredParticipation":"0.00000015","requiredMajority":"0.66","requiredLiquidityProviderParticipation":"0.00001","requiredLiquidityProviderMajority":"0.66"},"version":1,"chainId":"testnet-001","txHash":"7185AF16CA854EFBEDA66DCED52BEDA9A4722C04E2DD1595CEF05B31D65A219B"}

Market Update Events:

{"id":"250-13","block":"ACA5504AA15F4314A69102174987E807D4E5EC5E013EF97AFB119FD3E4278C3E","type":"BUS_EVENT_TYPE_MARKET_UPDATED","marketUpdated":{"id":"04f5e92db86e67d50438c8da8f8d3f24f52f7087e234d17fec7dc5f8f2054b70","tradableInstrument":{"instrument":{"code":"CRYPTO:VEGA CORE SYS TEST","name":"Futures System-Tests Market","metadata":{"tags":["asset_class:fx/crypto","product:futures"]},"future":{"settlementAsset":"5d6b420fd8571b0dc8c01dcbfc5da3a07cc4b28245f1d9c8389d2437a361c152","quoteName":"USD","dataSourceSpecForSettlementData":{"id":"084e9fff91818981e70ecc4aef6b15a665bdd8785548c3eea28c74e3526f412f","data":{"external":{"oracle":{"signers":[{"pubKey":{"key":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a"}}],"filters":[{"key":{"name":"external.test.settlement_F21C51C945","type":"TYPE_INTEGER","numberDecimalPlaces":"3"},"conditions":[{"operator":"OPERATOR_GREATER_THAN_OR_EQUAL","value":"0"}]}]}}}},"dataSourceSpecForTradingTermination":{"id":"f132fa43da2c0146a6c348e272584b455233e05c0e7233dee7eb5cea3203fac4","data":{"external":{"oracle":{"signers":[{"pubKey":{"key":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a"}}],"filters":[{"key":{"name":"external.test.termination_3BF84BAAC5","type":"TYPE_BOOLEAN"},"conditions":[{"operator":"OPERATOR_EQUALS","value":"True"}]}]}}}},"dataSourceSpecBinding":{"settlementDataProperty":"external.test.settlement_F21C51C945","tradingTerminationProperty":"external.test.termination_3BF84BAAC5"}}},"marginCalculator":{"scalingFactors":{"searchLevel":1.1,"initialMargin":1.2,"collateralRelease":1.4}},"logNormalRiskModel":{"riskAversionParameter":0.001,"tau":0.00011407711613050422,"params":{"r":0.016,"sigma":2}}},"decimalPlaces":"5","fees":{"factors":{"makerFee":"0.004","infrastructureFee":"0.001","liquidityFee":"0.3"}},"openingAuction":{"duration":"1"},"priceMonitoringSettings":{"parameters":{"triggers":[{"horizon":"1","probability":"0.99","auctionExtension":"10"}]}},"liquidityMonitoringParameters":{"targetStakeParameters":{"timeWindow":"10","scalingFactor":5},"triggeringRatio":"0","auctionExtension":"1"},"tradingMode":"TRADING_MODE_MONITORING_AUCTION","state":"STATE_SUSPENDED","marketTimestamps":{"proposed":"1692713065646447732","pending":"1692713072000000000","open":"1692713090014085530"},"positionDecimalPlaces":"5","lpPriceRange":"1","linearSlippageFactor":"0.01","quadraticSlippageFactor":"0"},"version":1,"chainId":"testnet-001","txHash":"9F0F9A41A27F4D7A6B61EEF43734535755E31B7ECEB04B28763848E6DAEF7124"}
{"id":"266-39","block":"EF42537FAD318DF83C6E1C1A4F6F6612B047BE5E685D8D64ACA4E275828EBE7F","type":"BUS_EVENT_TYPE_MARKET_UPDATED","marketUpdated":{"id":"04f5e92db86e67d50438c8da8f8d3f24f52f7087e234d17fec7dc5f8f2054b70","tradableInstrument":{"instrument":{"code":"CRYPTO:VEGA CORE SYS TEST","name":"Futures System-Tests Market","metadata":{"tags":["asset_class:fx/crypto","product:futures"]},"future":{"settlementAsset":"5d6b420fd8571b0dc8c01dcbfc5da3a07cc4b28245f1d9c8389d2437a361c152","quoteName":"USD","dataSourceSpecForSettlementData":{"id":"084e9fff91818981e70ecc4aef6b15a665bdd8785548c3eea28c74e3526f412f","data":{"external":{"oracle":{"signers":[{"pubKey":{"key":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a"}}],"filters":[{"key":{"name":"external.test.settlement_F21C51C945","type":"TYPE_INTEGER","numberDecimalPlaces":"3"},"conditions":[{"operator":"OPERATOR_GREATER_THAN_OR_EQUAL","value":"0"}]}]}}}},"dataSourceSpecForTradingTermination":{"id":"f132fa43da2c0146a6c348e272584b455233e05c0e7233dee7eb5cea3203fac4","data":{"external":{"oracle":{"signers":[{"pubKey":{"key":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a"}}],"filters":[{"key":{"name":"external.test.termination_3BF84BAAC5","type":"TYPE_BOOLEAN"},"conditions":[{"operator":"OPERATOR_EQUALS","value":"True"}]}]}}}},"dataSourceSpecBinding":{"settlementDataProperty":"external.test.settlement_F21C51C945","tradingTerminationProperty":"external.test.termination_3BF84BAAC5"}}},"marginCalculator":{"scalingFactors":{"searchLevel":1.1,"initialMargin":1.2,"collateralRelease":1.4}},"logNormalRiskModel":{"riskAversionParameter":0.001,"tau":0.00011407711613050422,"params":{"r":0.016,"sigma":2}}},"decimalPlaces":"5","fees":{"factors":{"makerFee":"0.004","infrastructureFee":"0.001","liquidityFee":"0.3"}},"openingAuction":{"duration":"1"},"priceMonitoringSettings":{"parameters":{"triggers":[{"horizon":"1","probability":"0.99","auctionExtension":"10"}]}},"liquidityMonitoringParameters":{"targetStakeParameters":{"timeWindow":"10","scalingFactor":5},"triggeringRatio":"0","auctionExtension":"1"},"tradingMode":"TRADING_MODE_CONTINUOUS","state":"STATE_ACTIVE","marketTimestamps":{"proposed":"1692713065646447732","pending":"1692713072000000000","open":"1692713090014085530"},"positionDecimalPlaces":"5","lpPriceRange":"1","linearSlippageFactor":"0.01","quadraticSlippageFactor":"0"},"version":1,"chainId":"testnet-001","txHash":"EF42537FAD318DF83C6E1C1A4F6F6612B047BE5E685D8D64ACA4E275828EBE7F"}
{"id":"286-9","block":"7185AF16CA854EFBEDA66DCED52BEDA9A4722C04E2DD1595CEF05B31D65A219B","type":"BUS_EVENT_TYPE_MARKET_UPDATED","marketUpdated":{"id":"04f5e92db86e67d50438c8da8f8d3f24f52f7087e234d17fec7dc5f8f2054b70","tradableInstrument":{"instrument":{"code":"CRYPTO:VEGA CORE SYS TEST","name":"Futures System-Tests Market","metadata":{"tags":["asset_class:fx/crypto","product:futures"]},"future":{"settlementAsset":"5d6b420fd8571b0dc8c01dcbfc5da3a07cc4b28245f1d9c8389d2437a361c152","quoteName":"USD","dataSourceSpecForSettlementData":{"id":"084e9fff91818981e70ecc4aef6b15a665bdd8785548c3eea28c74e3526f412f","data":{"external":{"oracle":{"signers":[{"pubKey":{"key":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a"}}],"filters":[{"key":{"name":"external.test.settlement_F21C51C945","type":"TYPE_INTEGER","numberDecimalPlaces":"3"},"conditions":[{"operator":"OPERATOR_GREATER_THAN_OR_EQUAL","value":"0"}]}]}}}},"dataSourceSpecForTradingTermination":{"id":"f132fa43da2c0146a6c348e272584b455233e05c0e7233dee7eb5cea3203fac4","data":{"external":{"oracle":{"signers":[{"pubKey":{"key":"811d0ef737bf395ebf781c5f2e806f01db6fc584e6a8213208db72d587253d3a"}}],"filters":[{"key":{"name":"external.test.termination_3BF84BAAC5","type":"TYPE_BOOLEAN"},"conditions":[{"operator":"OPERATOR_EQUALS","value":"True"}]}]}}}},"dataSourceSpecBinding":{"settlementDataProperty":"external.test.settlement_F21C51C945","tradingTerminationProperty":"external.test.termination_3BF84BAAC5"}}},"marginCalculator":{"scalingFactors":{"searchLevel":1.1,"initialMargin":1.2,"collateralRelease":1.4}},"logNormalRiskModel":{"riskAversionParameter":0.001,"tau":0.00011407711613050422,"params":{"r":0.016,"sigma":2}}},"decimalPlaces":"5","fees":{"factors":{"makerFee":"0.004","infrastructureFee":"0.001","liquidityFee":"0.3"}},"openingAuction":{"duration":"1"},"priceMonitoringSettings":{"parameters":{"triggers":[{"horizon":"1","probability":"0.99","auctionExtension":"10"}]}},"liquidityMonitoringParameters":{"targetStakeParameters":{"timeWindow":"10","scalingFactor":5},"triggeringRatio":"0","auctionExtension":"1"},"tradingMode":"TRADING_MODE_SUSPENDED_VIA_GOVERNANCE","state":"STATE_SUSPENDED_VIA_GOVERNANCE","marketTimestamps":{"proposed":"1692713065646447732","pending":"1692713072000000000","open":"1692713090014085530"},"positionDecimalPlaces":"5","lpPriceRange":"1","linearSlippageFactor":"0.01","quadraticSlippageFactor":"0"},"version":1,"chainId":"testnet-001","txHash":"7185AF16CA854EFBEDA66DCED52BEDA9A4722C04E2DD1595CEF05B31D65A219B"}

Expected behaviour

As per the AC.

Steps to reproduce

Run the below system test:

System Test Name - test_suspend_already_auction
System Test Branch - save_governance_market_states

Software version

vega - develop

Failing test

test_suspend_already_auction

Jenkins run

https://jenkins.ops.vega.xyz/job/common/job/system-tests-wrapper/97090/testReport/junit/tests.governance/market_state_update_test/test_suspend_already_auction_market_/

Configuration used

No response

Relevant log output

market_id = 04f5e92db86e67d50438c8da8f8d3f24f52f7087e234d17fec7dc5f8f2054b70

All events for the test

https://jenkins.ops.vega.xyz/job/common/job/system-tests-wrapper/97090/artifact/test_logs/tests.governance.market_state_update_test/test_suspend_already_auction%5Bmarket%5D/

Proposal Events 

https://jenkins.ops.vega.xyz/job/common/job/system-tests-wrapper/97090/artifact/test_logs/tests.governance.market_state_update_test/test_suspend_already_auction%5Bmarket%5D/BUS_EVENT_TYPE_PROPOSAL.txt

Market Update Events

https://jenkins.ops.vega.xyz/job/common/job/system-tests-wrapper/97090/artifact/test_logs/tests.governance.market_state_update_test/test_suspend_already_auction%5Bmarket%5D/BUS_EVENT_TYPE_MARKET_UPDATED.txt
ze97286 commented 10 months ago

could not reproduce, confirmed with @MuthuVega @vega-paul