From 6342aedba3633bc309b156ba942c9d34681ef6c0 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:35:36 -0400 Subject: [PATCH 1/2] fix: return a new tenderly simulation status in case of tenderly downtime --- src/providers/simulation-provider.ts | 1 + src/providers/tenderly-simulation-provider.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/providers/simulation-provider.ts b/src/providers/simulation-provider.ts index 4b6127a43..4ae6e1aec 100644 --- a/src/providers/simulation-provider.ts +++ b/src/providers/simulation-provider.ts @@ -31,6 +31,7 @@ export enum SimulationStatus { Succeeded = 2, InsufficientBalance = 3, NotApproved = 4, + SystemDown = 5, } /** diff --git a/src/providers/tenderly-simulation-provider.ts b/src/providers/tenderly-simulation-provider.ts index 63eea56ef..680cabe60 100644 --- a/src/providers/tenderly-simulation-provider.ts +++ b/src/providers/tenderly-simulation-provider.ts @@ -223,7 +223,7 @@ export class FallbackTenderlySimulator extends Simulator { MetricLoggerUnit.Count ); } - return { ...swapRoute, simulationStatus: SimulationStatus.Failed }; + return { ...swapRoute, simulationStatus: SimulationStatus.SystemDown }; } } } @@ -440,6 +440,12 @@ export class TenderlySimulator extends Simulator { 1, MetricLoggerUnit.Count ); + // technically, we can also early return SimulationStatus.SystemDown when http status is not 200. + // in reality, when tenderly is down for whatever reason, i see it always throw during axios http request + // so that it hits the catch block in https://github.com/Uniswap/smart-order-router/blob/8bfec299001d3204483f761f57a38be04512a948/src/providers/tenderly-simulation-provider.ts#L226 + // which is where we want to actually return SimulationStatus.SystemDown + // in other words, I've never see a TenderlySimulationUniversalRouterResponseStatus metric with a non-200 status + // if there's downtime, it won't log metric at https://github.com/Uniswap/smart-order-router/blob/8bfec299001d3204483f761f57a38be04512a948/src/providers/tenderly-simulation-provider.ts#L434 // Validate tenderly response body if ( From 2bf9abf2137e2b255fd7b25bdd257b3e98505bb5 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:48:33 -0400 Subject: [PATCH 2/2] fix: unit test assertion --- test/unit/providers/simulation-provider.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/providers/simulation-provider.test.ts b/test/unit/providers/simulation-provider.test.ts index 6b0f469c6..0b201117a 100644 --- a/test/unit/providers/simulation-provider.test.ts +++ b/test/unit/providers/simulation-provider.test.ts @@ -270,7 +270,7 @@ describe('Fallback Tenderly simulator', () => { ); expect(tenderlySimulator.simulateTransaction.called).toBeTruthy(); expect(swapRouteWithGasEstimate.simulationStatus).toEqual( - SimulationStatus.Failed + SimulationStatus.SystemDown ); }); test('when eth estimate gas simulator throws, try tenderly anyway', async () => {