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 22 forks source link

Support partial update when sending an `updateMarket` #5750

Open edd opened 2 years ago

edd commented 2 years ago

Updating a market is validated here: https://github.com/vegaprotocol/protos/blob/c2c2c20d06bc2e8b03ec3f26b1ae093610efcfd8/commands/proposal_submission.go#L403-L406

Note that this is much the same as newMarket: https://github.com/vegaprotocol/protos/blob/c2c2c20d06bc2e8b03ec3f26b1ae093610efcfd8/commands/proposal_submission.go#L378-L381

Reading the spec (https://github.com/vegaprotocol/specs-internal/blob/master/protocol/0028-GOVE-governance.md#2-change-market-parameters):

Ideally, it should be possible to not repeat things that are not changing or are immutable but we leave this to implementation detail.

Cool! newMarket is huge, submitting less is great. However, due to the shared functions, every updateMarket needs to supply all of the oracle data, even if it isn't changing.

To recreate

./vegawallet command send --wallet edd --pubkey 7e84f93c7f5595b57c6924e5fb2647bb13fe64e7eb5540fc5436772f2a2c1d8a --network fairground '{"proposalSubmission":{"rationale":{"description":"Update Lorem Ipsum market"},"terms":{"updateMarket":{"marketId":"123","changes":{"instrument":{"code":"ORANGES.24h","future":{"quoteName":"tEuro","settlementPriceDecimals":5}},"logNormal":{"tau":0.0001140771161,"riskAversionParameter":0.001,"params":{"mu":0,"r":0.016,"sigma":0.8}}}},"closingTimestamp":1656258137394,"enactmentTimestamp":1656344537394}}}'

Should be valid. However it returns this error:

✗ invalid request: proposal_submission.terms.change.update_market.changes.instrument.product.future.oracle_spec_binding (is required), proposal_submission.terms.change.update_market.changes.instrument.product.future.oracle_spec_for_settlement_price (is required), proposal_submission.terms.change.update_market.changes.instrument.product.future.oracle_spec_for_trading_termination (is required)

Tasks

ValentinTrinque commented 2 years ago

That's the ideal solution, indeed. But for sake of simplicity, we didn't implement it as a "patch" but as a full update. That is intended.

ValentinTrinque commented 2 years ago

Note that the hard part doesn't come from the validation, but the actual process to update with partial data, meaning retrieving the previous data, then apply the validation against various parameters (network, markets, etc.), and to finally, trigger the update process.