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

added single pool query #4549

Merged
merged 26 commits into from
Mar 24, 2023
Merged

added single pool query #4549

merged 26 commits into from
Mar 24, 2023

Conversation

nicolaslara
Copy link
Contributor

Closes: #4481

What is the purpose of the change

Estimate swap queries can't be executed via LCD endpoints due to an issue with grpc gateway that prevents (repeated?) nested structures from being specified as query params.

This adds simple queries for estimating the price when using a single pool. This also simplifies querying in most cases (where users just care about one pool)

Brief Changelog

  • Added two new queries:
    • /osmosis.poolmanager.v1beta1.Query/EstimateSinglePoolSwapExactAmountOut
    • /osmosis.poolmanager.v1beta1.Query/EstimateSinglePoolSwapExactAmountIn

Testing and Verifying

Added tests that check that the results of those queries is the same as the underlying implementations
All other tests pass

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes )
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes /)
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented)

@nicolaslara nicolaslara added the V:state/compatible/no_backport State machine compatible PR, depends on prior breaks label Mar 9, 2023
@mattverse mattverse self-requested a review March 13, 2023 11:08
Comment on lines 61 to +63
message EstimateSwapExactAmountInRequest {
// TODO: CHANGE THIS TO RESERVED IN A PATCH RELEASE
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
reserved 1;
reserved "sender";
Copy link
Member

@ValarDragon ValarDragon Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this query in the stargate whitelist? If so, then seems important to reason about if this would cause a state break on mainnet. My first pass thought is it wouldn't, and should be safe. This is because the only gas difference would come from the rust side. But the Rust side is fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. It's also potentially used by contracts.

One place that may be state breaking is https://github.com/osmosis-labs/osmosis/pull/4549/files#diff-417b3334c7fd0aefd80aafa70e8feb77a81586dc63b266105aa25bad2ab09a2fL53. It was (unnecessarily) checking that the sender wasn't empty. So a call with an empty sender would've failed before and would pass now.

Copy link
Member

@mattverse mattverse Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, this leads me to think that we might want to add queries included in stargate queries to e2e testing, since we can mistakenly merge a query PR and have it state breaking. Going to create an issue to track this and further discuss this

Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but feels like we should try to get this backported / into a patch release

@ValarDragon
Copy link
Member

In a second non-state compatible PR, lets add these new queries to the whitelist?

@nicolaslara nicolaslara added V:state/breaking State machine breaking PR and removed V:state/compatible/no_backport State machine compatible PR, depends on prior breaks labels Mar 14, 2023
proto/osmosis/poolmanager/v1beta1/query.proto Outdated Show resolved Hide resolved
proto/osmosis/poolmanager/v1beta1/query.proto Outdated Show resolved Hide resolved
proto/osmosis/poolmanager/v1beta1/query.proto Outdated Show resolved Hide resolved
proto/osmosis/poolmanager/v1beta1/query.proto Outdated Show resolved Hide resolved
Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question I have in the change in the cli test, otherwise LGTM

x/poolmanager/client/cli/cli_test.go Outdated Show resolved Hide resolved
@nicolaslara
Copy link
Contributor Author

nicolaslara commented Mar 20, 2023

Since this is not gonna be state compatible anyway, added the stargate whitelist queries here.

Should we maybe backport this without the sender change so that thosse queries are available in a minor release? I think that's not really necessary, as these can still be queried from typescript via the rpc endpoints

@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Mar 20, 2023
@mattverse
Copy link
Member

Should we maybe backport this without the sender change so that thosse queries are available in a minor release? I think that's not really necessary, as these can still be queried from typescript via the rpc endpoints

I don't think it should be necessary as well, it has been in the current state for years, I personally think it can wait

@nicolaslara nicolaslara merged commit 695c3c9 into main Mar 24, 2023
@nicolaslara nicolaslara deleted the nicolas/simple-swap-endpoint branch March 24, 2023 14:56
czarcas7ic added a commit that referenced this pull request Mar 25, 2023
…ug (#4735)

* link (#4708)

* daily check for broken links (#4712)

* Update README.md

* Create check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update README.md

* Update AutoStake seed from .net to .com (#4711)

Co-authored-by: AutoStake <[email protected]>

* [tests/e2e]: simplify the logic for adding accounts to genesis sdk side and integrate into e2e (#4706)

* update logic add account genesis

* clean unused package

* golint

* XCS + Registries integration: IBC forward generation using registries (#4694)

* initial attempt at splitting registries. Issues with circular deps

* properly split registries

* added reverse prefix map

* channel validation done by registries

* integrating registry into xcs and fixing the tests

* Printing error context on failure

* full integration with unwrapping

* remove replace

* removed unused deps

* clippy

* x86 bytecode

* fmt after lints

* gofumpt

* fix re-export

* lint

* added test-contract addr

* added missing newline

* remove recovery states

* x86 bytecode

* new bytecode

* added single pool query (#4549)

* added single pool query

* added changelog

* remove empty tests as they are invalid

* removed sender and made reserved

* remove and reserve unused sender

* removed sender

* actually remove sender

* querygen

* move impl to correct file

* more flexible querygen

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* protos

* added cli

* fixed command parsing

* single line

* lint

* fix cli

* run proto gen

* added whitelisted query

* fix test for v15

---------

Co-authored-by: Matt, Park <[email protected]>

* Revert "[tests/e2e]: simplify the logic for adding accounts to genesis sdk side and integrate into e2e (#4706)" (#4727)

This reverts commit a9725d6.

* ProtoRev: Adding Txs to CLI (#4567)

* init set hot routes cli command

* adding remaining txs

* few more tests

* comments

* Update upgrade_test.go (#4734)

* refactor tests and fix incentive forfeiting bug

* update create position tx

* feat: whitelist poolmanager Pool, CL Params and ClaimableFees queries (#4725)

* feat: whitelist poolmanager Pool, CL Params and ClaimableFees queries

* lint

* conflict

* fix e2e query parsing

* increase gas

---------

Co-authored-by: Ruslan Akhtariev <[email protected]>
Co-authored-by: Master Pi <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: Nguyen Thanh Nhan <[email protected]>
Co-authored-by: Nicolas Lara <[email protected]>
Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: David Terpay <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Roman <[email protected]>
czarcas7ic added a commit that referenced this pull request Mar 30, 2023
* utilize new position id in position key

* add position id to migration response

* regen proto

* modify withdraw pos in e2e

* cmd order

* avoid store key formatting with fmt.Sprintf

* set default NextPositionId to 1

* lint

* return positionId from CreatePos E2E

* utilize bytes.Buffer to build keys

* Revert "utilize bytes.Buffer to build keys"

This reverts commit 0c1bc13.

* utilize sprintf for key

* remove extra positions logic

* initial push

* regen proto

* Update go.mod

* lints

* fix sim

* add posid to sim collectincentive

* e2e test fix

* lint

* clean up

* remove extra fields

* regen proto

* only use pos id for fees

* update cli and e2e

* fee accum updates

* modify claim to use only positionId

* fix functional fees test

* pool to position id map

* add pool store to delete position

* fix conflicts from main merge

* test updates

* lints / cleanup

* add position Id to create position response

* regen proto

* regen proto

* switch order

* regen proto

* add error comment to collectFees

* move key format to types

* rename to positionFields

* Remove unnecessary test field

* revert refactor to functional fees test

* define custom errors

* remove duplicate events emitted

* correct validatePositionUpdate inputs

* Update x/concentrated-liquidity/position.go

Co-authored-by: Roman <[email protected]>

* update README for KV stores

* other readme updates

* feat: query position by id (added to stargate whitelist) (#4718)

* feat(CL): position by id query (stargate whitelisted)

* fix test

* Update app/upgrades/v15/upgrade_test.go

---------

Co-authored-by: Adam Tucker <[email protected]>

* initial push

* remove position age as input param

* [CL][bugfix] Refactor incentives tests and fix incentive forfeiting bug (#4735)

* link (#4708)

* daily check for broken links (#4712)

* Update README.md

* Create check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update check-broken-links.yml

* Update README.md

* Update AutoStake seed from .net to .com (#4711)

Co-authored-by: AutoStake <[email protected]>

* [tests/e2e]: simplify the logic for adding accounts to genesis sdk side and integrate into e2e (#4706)

* update logic add account genesis

* clean unused package

* golint

* XCS + Registries integration: IBC forward generation using registries (#4694)

* initial attempt at splitting registries. Issues with circular deps

* properly split registries

* added reverse prefix map

* channel validation done by registries

* integrating registry into xcs and fixing the tests

* Printing error context on failure

* full integration with unwrapping

* remove replace

* removed unused deps

* clippy

* x86 bytecode

* fmt after lints

* gofumpt

* fix re-export

* lint

* added test-contract addr

* added missing newline

* remove recovery states

* x86 bytecode

* new bytecode

* added single pool query (#4549)

* added single pool query

* added changelog

* remove empty tests as they are invalid

* removed sender and made reserved

* remove and reserve unused sender

* removed sender

* actually remove sender

* querygen

* move impl to correct file

* more flexible querygen

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* Update proto/osmosis/poolmanager/v1beta1/query.proto

Co-authored-by: Matt, Park <[email protected]>

* protos

* added cli

* fixed command parsing

* single line

* lint

* fix cli

* run proto gen

* added whitelisted query

* fix test for v15

---------

Co-authored-by: Matt, Park <[email protected]>

* Revert "[tests/e2e]: simplify the logic for adding accounts to genesis sdk side and integrate into e2e (#4706)" (#4727)

This reverts commit a9725d6.

* ProtoRev: Adding Txs to CLI (#4567)

* init set hot routes cli command

* adding remaining txs

* few more tests

* comments

* Update upgrade_test.go (#4734)

* refactor tests and fix incentive forfeiting bug

* update create position tx

* feat: whitelist poolmanager Pool, CL Params and ClaimableFees queries (#4725)

* feat: whitelist poolmanager Pool, CL Params and ClaimableFees queries

* lint

* conflict

* fix e2e query parsing

* increase gas

---------

Co-authored-by: Ruslan Akhtariev <[email protected]>
Co-authored-by: Master Pi <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: Nguyen Thanh Nhan <[email protected]>
Co-authored-by: Nicolas Lara <[email protected]>
Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: David Terpay <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Roman <[email protected]>

* refactor collect incentives test

* remove any final references to freezing

* merge main

* add back ParsePositionFromBz

* add comments to test

* add forfeit incentives withdraw test case

* add negative duration validation and test

* clean up

* add back multi-position test

* regen proto

---------

Co-authored-by: czarcas7ic <[email protected]>
Co-authored-by: Roman <[email protected]>
Co-authored-by: alpo <[email protected]>
Co-authored-by: Ruslan Akhtariev <[email protected]>
Co-authored-by: Master Pi <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: AutoStake <[email protected]>
Co-authored-by: Nguyen Thanh Nhan <[email protected]>
Co-authored-by: Nicolas Lara <[email protected]>
Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: David Terpay <[email protected]>
@github-actions github-actions bot mentioned this pull request Apr 15, 2024
@github-actions github-actions bot mentioned this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:CLI C:x/poolmanager V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make sure estimate swap_exact_amount in/out query works via LCD
4 participants