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

fix: multicall return gas used in case of failure #534

Merged
merged 4 commits into from
Apr 17, 2024

Conversation

jsy1218
Copy link
Member

@jsy1218 jsy1218 commented Apr 17, 2024

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    feature

  • What is the current behavior? (You can also link to an open issue here)
    Meanwhile we are comparing the current quoter quotes vs new view-only quoter quotes in prod in shadow sampling for mainnet at 1%, we encounter a case, where we have some quotes that are failing due to the out-of-gas from multicall (e.g. this simulation), but from routing-api side, we don't have a good way to programmatically determine this is the case, within compareQuotes.

This is the case where some quotes from multicalls fail, but overall success rate is still above the threshold. This is different from the entire multicall failures due to out of gas. In that case, on-chain quote provider will throw ProviderOutOfGasError, and routing-api can generalize to where currentQuoterSucceeded = false

  • What is the new behavior (if this is a feature change)?
    Within SOR, we will return both gasUsed and gasLimit per call from the multicalls, so that routing-api can calculate that the difference between gasUsed and gasLimit may be small enough to be due to out of gas.

  • Other information:
    This works in tendom with routing-api changes.

Copy link
Contributor

@cgkol cgkol left a comment

Choose a reason for hiding this comment

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

When are we planning on doing this?

 so that routing-api can calculate that the difference between gasUsed and gasLimit may be small enough to be due to out of gas

Copy link
Member Author

jsy1218 commented Apr 17, 2024

When are we planning on doing this?

 so that routing-api can calculate that the difference between gasUsed and gasLimit may be small enough to be due to out of gas

Sometime today. I have the routing-api draft PR, just need to add some test

@jsy1218 jsy1218 force-pushed the jsy1218/multicall-return-gas-used-in-case-of-failure branch from d0677c4 to 83f4374 Compare April 17, 2024 15:41
@jsy1218 jsy1218 merged commit 9a3065a into main Apr 17, 2024
23 of 24 checks passed
@jsy1218 jsy1218 deleted the jsy1218/multicall-return-gas-used-in-case-of-failure branch April 17, 2024 15:55
@jsy1218 jsy1218 mentioned this pull request Apr 17, 2024
jsy1218 added a commit that referenced this pull request Apr 17, 2024
- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
Release #534
jsy1218 added a commit to Uniswap/routing-api that referenced this pull request Apr 17, 2024
Once SOR returns per-quote-call gasUsed and gasLimit (Uniswap/smart-order-router#534), then routing-api can calculate per-quote call failure is due to likely out-of-gas error. 

I was deciding between using gasUsed and gasLimit vs the encoded error from the return data, but the [simulation](https://www.tdly.co/shared/simulation/39de04bb-d794-43b0-aed2-8ea31957ca77) shows me that the encoded error from the return data might not be accurate. For this simulation, the error indicates [SLP](https://docs.uniswap.org/contracts/v3/reference/error-codes), which is not true:

 ```
cast 4byte-decode 0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000353504c0000000000000000000000000000000000000000000000000000000000
1) "Error(string)"
"SPL"
```

Now testing coverage added.
jsy1218 added a commit that referenced this pull request May 9, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 9, 2024
- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
Release #534
jsy1218 added a commit that referenced this pull request May 9, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 9, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 9, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* log quote success rate metric
jsy1218 added a commit that referenced this pull request May 9, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 9, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* 3.28.11
jsy1218 added a commit that referenced this pull request May 9, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 9, 2024
- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
Release #534
jsy1218 added a commit that referenced this pull request May 9, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* log quote success rate metric
jsy1218 added a commit that referenced this pull request May 9, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* 3.28.11
jsy1218 added a commit that referenced this pull request May 9, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 9, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* log optimistic quote metrics prefix in onchain quoting

* fix prettier

* add underscore metrics prefix

* use provider config
jsy1218 added a commit that referenced this pull request May 10, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 10, 2024
- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
Release #534
jsy1218 added a commit that referenced this pull request May 10, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* log quote success rate metric
jsy1218 added a commit that referenced this pull request May 10, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* 3.28.11
jsy1218 added a commit that referenced this pull request May 10, 2024
* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* log optimistic quote metrics prefix in onchain quoting

* fix prettier

* add underscore metrics prefix

* use provider config
jsy1218 added a commit that referenced this pull request May 10, 2024
* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit
jsy1218 added a commit that referenced this pull request May 10, 2024
#570)

* fix: multicall return gas used in case of failure (#534)

* return gas used from multicall in case of a failed quote

* fix compiling error

* add target contract address to the failed multicall debug log

* also return gas limit

* onchain quoter batch param differed by optimistic cached routes

* fix prettier onchain quoter

* fix build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants