Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protorev smarter logic and more testing (backport #4181) #4352

Merged
merged 2 commits into from
Feb 17, 2023

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 16, 2023

This is an automatic backport of pull request #4181 done by Mergify.
Cherry-pick of 23b13a1 has failed:

On branch mergify/bp/v15.x/pr-4181
Your branch is up to date with 'origin/v15.x'.

You are currently cherry-picking commit 23b13a1d.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   proto/osmosis/protorev/v1beta1/genesis.proto
	modified:   proto/osmosis/protorev/v1beta1/protorev.proto
	modified:   tests/e2e/containers/config.go
	modified:   tests/e2e/e2e_test.go
	modified:   tests/e2e/initialization/config.go
	new file:   tests/e2e/scripts/protorevPool1.json
	new file:   tests/e2e/scripts/protorevPool2.json
	new file:   tests/e2e/scripts/protorevPool3.json
	modified:   x/protorev/genesis.go
	modified:   x/protorev/keeper/developer_fees_test.go
	modified:   x/protorev/keeper/epoch_hook_test.go
	modified:   x/protorev/keeper/grpc_query_test.go
	modified:   x/protorev/keeper/keeper_test.go
	modified:   x/protorev/keeper/msg_server.go
	modified:   x/protorev/keeper/msg_server_test.go
	modified:   x/protorev/keeper/posthandler.go
	modified:   x/protorev/keeper/posthandler_test.go
	modified:   x/protorev/keeper/protorev.go
	modified:   x/protorev/keeper/protorev_test.go
	modified:   x/protorev/keeper/rebalance.go
	modified:   x/protorev/keeper/rebalance_test.go
	modified:   x/protorev/keeper/routes.go
	modified:   x/protorev/keeper/routes_test.go
	modified:   x/protorev/keeper/statistics_test.go
	modified:   x/protorev/types/constants.go
	modified:   x/protorev/types/genesis.go
	modified:   x/protorev/types/genesis.pb.go
	modified:   x/protorev/types/genesis_test.go
	modified:   x/protorev/types/msg_test.go
	modified:   x/protorev/types/protorev.pb.go
	modified:   x/protorev/types/token_pair_arb_routes.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   tests/e2e/configurer/chain/queries.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

* 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 <[email protected]>
(cherry picked from commit 23b13a1)

# Conflicts:
#	tests/e2e/configurer/chain/queries.go
@ValarDragon ValarDragon merged commit 6d5fae9 into v15.x Feb 17, 2023
@ValarDragon ValarDragon deleted the mergify/bp/v15.x/pr-4181 branch February 17, 2023 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants