From 8051c4062da19abf3bc60e511ec7d3e1b05c8594 Mon Sep 17 00:00:00 2001 From: "Siyu Jiang (See-You John)" <91580504+jsy1218@users.noreply.github.com> Date: Thu, 31 Oct 2024 09:51:03 -0700 Subject: [PATCH] chore: bump to 4.7.8 - fix: return a new tenderly simulation status in case of tenderly downtime (#759) - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Bug fix - **What is the current behavior?** (You can also link to an open issue here) Right now when tenderly has system downtime, we do not differentiate from when tenderly simulation returns a failed simulated transaction, in case of the Simulation Status, as FAILED. - **What is the new behavior (if this is a feature change)?** In case of tenderly downtime, we return SystemDown simulation status from SOR. - **Other information**: It will get populated in routing to return a new simulation status as "SYSTEM_DOWN" --- src/providers/simulation-provider.ts | 1 + src/providers/tenderly-simulation-provider.ts | 8 +++++++- test/unit/providers/simulation-provider.test.ts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) 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 ( 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 () => {