From 89e55be9ab75fa44655b580283f41ae378027340 Mon Sep 17 00:00:00 2001 From: Jeremy Liu <31809888+NotJeremyLiu@users.noreply.github.com> Date: Thu, 16 Feb 2023 13:21:53 -0500 Subject: [PATCH] Protorev smarter logic and more testing (#4181) * Add generalized tests Added: - 4 pool mainnet route test - 2 pool mainnet route test - Non-osmo/atom denom test * Add stableswap doomsday test - Currently panics due to solveCFMMBinarySearchMulti in stableswap calculation * Add tests for pool point limits - Tests that the per tx limit works properly - Tests that the per block limit works properly * Add pre-check before binary search - Adds a pre-check before the binary search that tells us if we need to run the binary search at all - Reduces overall computation/time by avoiding binary searching profit amounts over routes without any profit opportunity * Add denom to make test pass - Added "test/3" denom to test non-osmo/atom denoms in previous PR - didn't notice it broke one test that expected us to only have 2 denoms, so adding "test/3" here so everything passes * Implement minimum change to have smarter binary search bounds - This implements a way for us to have a binary search bound that can increase in size to account for large trades above the default range - I believe this is the minimum-amount-of-new-code approach, but may not be the optimal approach (what this method avoids is having to save the amount in or amount out of the original swap, and then backtracking/converting that amount to the base denom for an arb, and creating bounds off of that) * Switch range increasing logic - Doubling isn't the wanted behavior (only wanted if lower bound is 1), just increasing bound by the same range size is wanted (so adding MaxInputAmount achieves this) * Add logic to extend search bounds when finding optimal amount in - Increases max iterations to 17 to allow for situation when we need to increase the upper bound - Add new ExtendedMaxInputAmount variable for us to use as this new max bound range - Replace bound changing logic from iteratively changing the range to immediately giving our max range * Move range extension into it's own helper function * basic benchmark testing for posthandler and epoch hook * Add SwapAmountOut Test * Add extended range test - Tests binary search range extension logic works properly * Add panic catching test - This currently fails, this is on purpose so we don't merge the PR and think we are good until this passes and the panics are handled properly * dynamic step size * pool points only incremented if profitable * adding sanity checks for pool point calcs, nits * Update doomsday testing accounting for refund system - Makes pool 41 reserves to have an arb opportunity in the doomsday routes - Changes tx limit and block limit specifically for doomsday testing * Return nil for no profit opportunity * adding E2E, removing atom as a base denom, more testing for post handler * find max profit test fix * nit * backporting version tag to 14.x * comment update for protorev admin account --------- Co-authored-by: David Terpay --- tests/e2e/containers/config.go | 2 +- tests/e2e/initialization/config.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/containers/config.go b/tests/e2e/containers/config.go index b1b0b9df4e8..901b68f6a89 100644 --- a/tests/e2e/containers/config.go +++ b/tests/e2e/containers/config.go @@ -27,7 +27,7 @@ const ( previousVersionOsmoTag = "v14.x-4d4583fa-1676370337" // Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion) previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain" - previousVersionInitTag = "v14.x-4d4583fa-1676370337-manual" + previousVersionInitTag = "v14.x-937d601e-1676550460-manual" // Hermes repo/version for relayer relayerRepository = "informalsystems/hermes" relayerTag = "1.2.0" diff --git a/tests/e2e/initialization/config.go b/tests/e2e/initialization/config.go index baf8a9af73a..d7fec0758d2 100644 --- a/tests/e2e/initialization/config.go +++ b/tests/e2e/initialization/config.go @@ -56,6 +56,8 @@ const ( OsmoIBCDenom = "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518" StakeIBCDenom = "ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B7787" E2EFeeToken = "e2e-default-feetoken" + UstIBCDenom = "ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC" + LuncIBCDenom = "ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0" MinGasPrice = "0.000" IbcSendAmount = 3300000000 ValidatorWalletName = "val"