From b15e401b59c1bc0aa445c05c68f88e56612e5765 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Fri, 17 Nov 2023 13:12:40 +0000 Subject: [PATCH 1/2] fix: nil pointer panic Signed-off-by: Elias Van Ootegem --- CHANGELOG.md | 1 + core/processor/gastimator.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad1ce3087ab..0dd18bc9eda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - [10103](https://github.com/vegaprotocol/vega/issues/10103) - List ledgers `API` returns bad error when filtering by transfer type only. - [10120](https://github.com/vegaprotocol/vega/issues/10120) - Assure theoretical and actual funding payment calculations are consistent. - [10121](https://github.com/vegaprotocol/vega/issues/10121) - Assure `EstimatePosition` API works correctly with sparse perps data +- [10126](https://github.com/vegaprotocol/vega/issues/10126) - Account for invalid stop orders in batch, charge default gas. ## 0.73.0 diff --git a/core/processor/gastimator.go b/core/processor/gastimator.go index ad15bcb4ad3..7362a2e39d1 100644 --- a/core/processor/gastimator.go +++ b/core/processor/gastimator.go @@ -209,9 +209,11 @@ func (g *Gastimator) batchGastimate(batch *commandspb.BatchMarketInstructions) u factor = 1.0 } var marketId string + // if both are nil, marketId will be empty string, yielding default gas + // the order is invalid, but validation is applied later. if os.FallsBelow != nil { marketId = os.FallsBelow.OrderSubmission.MarketId - } else { + } else if os.RisesAbove != nil { marketId = os.RisesAbove.OrderSubmission.MarketId } orderGas := g.orderGastimate(marketId) From 924209950c1846c6ab8606f8c7bb0bd7f6fc4c2a Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Fri, 17 Nov 2023 13:18:51 +0000 Subject: [PATCH 2/2] fix: review comments Signed-off-by: Elias Van Ootegem --- core/processor/gastimator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/processor/gastimator.go b/core/processor/gastimator.go index 7362a2e39d1..f76e115a28b 100644 --- a/core/processor/gastimator.go +++ b/core/processor/gastimator.go @@ -211,9 +211,9 @@ func (g *Gastimator) batchGastimate(batch *commandspb.BatchMarketInstructions) u var marketId string // if both are nil, marketId will be empty string, yielding default gas // the order is invalid, but validation is applied later. - if os.FallsBelow != nil { + if os.FallsBelow != nil && os.FallsBelow.OrderSubmission != nil { marketId = os.FallsBelow.OrderSubmission.MarketId - } else if os.RisesAbove != nil { + } else if os.RisesAbove != nil && os.RisesAbove.OrderSubmission != nil { marketId = os.RisesAbove.OrderSubmission.MarketId } orderGas := g.orderGastimate(marketId)