8000 perf(oracle): store price onto stack by Rubilmax · Pull Request #113 · morpho-org/morpho-blue · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf(oracle): store price onto stack #113

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

Merged
merged 8 commits into from
Jul 24, 2023
Merged

perf(oracle): store price onto stack #113

merged 8 commits into from
Jul 24, 2023

Conversation

Rubilmax
Copy link
Collaborator
@Rubilmax Rubilmax commented Jul 11, 2023

@Rubilmax Rubilmax marked this pull request as ready for review July 11, 2023 12:38
@Rubilmax Rubilmax linked an issue Jul 11, 2023 that may be closed by this pull request
@Jean-Grimal
Copy link
Contributor

Gas diff is not much per our tests...

Liquidate was the only function that implied 2 calls to the oracle anyway, am I right ?

@pakim249CAL
Copy link
Contributor

The gas diff may not be representative of the true cost savings because of the use of a very basic mock oracle. A real oracle may be much more expensive to call.

8000
Base automatically changed from refactor/shares-math to refactor/morpho-utils July 11, 2023 16:27
@MathisGD
Copy link
Contributor

Note that if you have custom oracles, they can also take into account that they are called twice (to consume much less gas the second time).

@MathisGD
Copy link
Contributor

Note also that when the opti of setting address zero as oracle for the quote asset (which I believe happens in a lot of markets) in order for it not to be called, it reduces the gas improvement of this PR.

@MerlinEgalite
Copy link
Contributor

@MathisGD @QGarchery do you approve?

Copy link
Contributor
@QGarchery QGarchery left a comment

Choose a reason for hiding this comment

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

I agree that we want to optimize oracle calls: they can be more complicated, we don't want to add a constraint on them to return early when called twice, and we want to limit external calls (anyone create a market with custom oracles). This PR is a straightforward solution to that problem, but it introduces some duplication.

I'm wondering if there is a different approach, see #137 (not entirely convinced by it yet, it may need more work)

pakim249CAL
pakim249CAL previously approved these changes Jul 17, 2023
MerlinEgalite
MerlinEgalite previously approved these changes Jul 17, 2023
Base automatically changed from refactor/morpho-utils to main July 21, 2023 13:47
@Rubilmax Rubilmax dismissed stale reviews from Jean-Grimal, makcandrov, MerlinEgalite, and pakim249CAL July 21, 2023 13:47

The base branch was changed.

@Rubilmax Rubilmax requested a review from Jean-Grimal July 21, 2023 13:52
@Rubilmax Rubilmax marked this pull request as ready for review July 21, 2023 13:52
pakim249CAL
pakim249CAL previously approved these changes Jul 21, 2023
Copy link
Contributor
@QGarchery QGarchery left a comment

Choose a reason for hiding this comment

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

Looks good, one small change to make

makcandrov
makcandrov previously approved these changes Jul 21, 2023
@MerlinEgalite MerlinEgalite requested a review from QGarchery July 21, 2023 15:18
Jean-Grimal
Jean-Grimal previously approved these changes Jul 21, 2023
Copy link
Contributor
@MathisGD MathisGD left a comment

Choose a reason for hiding this comment

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

I'm not a huge fan to be honest, but at the same time I don't have in mind any better implem to avoid calling oracle twice.

@MerlinEgalite
Copy link
Contributor

We can merge @Rubilmax since @QGarchery is not available

@Rubilmax Rubilmax merged commit 0e5f22a into main Jul 24, 2023
@Rubilmax Rubilmax deleted the refactor/oracle-prices branch July 24, 2023 13:27
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.

Each oracle is called twice on each liquidation for the same data.
7 participants
0