Skip to content

Initial version of parsePriceFeed with uniqueness validation #1089

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 6 commits into from
Oct 13, 2023

Conversation

m30m
Copy link
Contributor

@m30m m30m commented Oct 11, 2023

Tried to reuse the logic as much as possible to limit additional bytecode.
After the changes the PythUpgradable bytecode is 24.22 KiB.

@vercel
Copy link

vercel bot commented Oct 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
example-oracle-amm ⬜️ Ignored (Inspect) Visit Preview Oct 13, 2023 11:46am
xc-admin-frontend ⬜️ Ignored (Inspect) Visit Preview Oct 13, 2023 11:46am

@m30m m30m marked this pull request as draft October 11, 2023 13:49
@m30m m30m force-pushed the publish-time-uniqueness branch from e9931ef to f9e5e8d Compare October 12, 2023 12:19
@m30m m30m marked this pull request as ready for review October 12, 2023 16:17
@@ -418,7 +418,7 @@ contract PythWormholeMerkleAccumulatorTest is
assertPriceFeedMessageStored(priceFeedMessages1[0]);
}

function testParsePriceFeedUpdatesWithWormholeMerklWorksWithOurOfOrderUpdateMultiCall()
function testParsePriceFeedUpdatesWithWormholeMerklWorksWithOutOfOrderUpdateMultiCall()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice catch 😅 there's still a typo "Merkl"

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

Can you run the gas benchmarks and post them before merging this PR? I wanna know the impact on gas usage. (would be good to add a single gas benchmark test for this new method too)

@m30m
Copy link
Contributor Author

m30m commented Oct 13, 2023

Gas Benchmarks:
Before the changes:

| contracts/pyth/PythUpgradable.sol:PythUpgradable contract |                 |        |        |        |         |
|-----------------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost                                           | Deployment Size |        |        |        |         |
| 4911235                                                   | 24805           |        |        |        |         |
| Function Name                                             | min             | avg    | median | max    | # calls |
| getEmaPrice                                               | 7712            | 7712   | 7712   | 7712   | 1       |
| getPrice                                                  | 5600            | 5600   | 5600   | 5600   | 1       |
| getUpdateFee                                              | 1657            | 2576   | 2725   | 4725   | 402     |
| initialize                                                | 234176          | 234176 | 234176 | 234176 | 33      |
| parsePriceFeedUpdates                                     | 131729          | 145681 | 139743 | 168701 | 10      |
| updatePriceFeeds                                          | 131969          | 269496 | 308959 | 308959 | 45      |
| updatePriceFeedsIfNecessary                               | 13685           | 99657  | 99657  | 185630 | 2       |

After the changes:

| contracts/pyth/PythUpgradable.sol:PythUpgradable contract |                 |        |        |        |         |
|-----------------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost                                           | Deployment Size |        |        |        |         |
| 4990352                                                   | 25200           |        |        |        |         |
| Function Name                                             | min             | avg    | median | max    | # calls |
| getEmaPrice                                               | 7734            | 7734   | 7734   | 7734   | 1       |
| getPrice                                                  | 5600            | 5600   | 5600   | 5600   | 1       |
| getUpdateFee                                              | 1657            | 2575   | 2725   | 4725   | 426     |
| initialize                                                | 234176          | 234176 | 234176 | 234176 | 35      |
| parsePriceFeedUpdates                                     | 131876          | 146647 | 140346 | 170796 | 10      |
| parsePriceFeedUpdatesUnique                               | 133707          | 134522 | 134522 | 135337 | 2       |
| updatePriceFeeds                                          | 132308          | 271408 | 308959 | 308959 | 47      |
| updatePriceFeedsIfNecessary                               | 13707           | 99679  | 99679  | 185652 | 2       |

After the changes with 200 optimization runs:

| contracts/pyth/PythUpgradable.sol:PythUpgradable contract |                 |        |        |        |         |
|-----------------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost                                           | Deployment Size |        |        |        |         |
| 4474433                                                   | 22624           |        |        |        |         |
| Function Name                                             | min             | avg    | median | max    | # calls |
| getEmaPrice                                               | 7925            | 7925   | 7925   | 7925   | 1       |
| getPrice                                                  | 5769            | 5769   | 5769   | 5769   | 1       |
| getUpdateFee                                              | 1755            | 2698   | 2853   | 4853   | 426     |
| initialize                                                | 234401          | 234401 | 234401 | 234401 | 35      |
| parsePriceFeedUpdates                                     | 132957          | 149231 | 142302 | 175534 | 10      |
| parsePriceFeedUpdatesUnique                               | 135428          | 136285 | 136285 | 137142 | 2       |
| updatePriceFeeds                                          | 133774          | 273593 | 311023 | 311023 | 47      |
| updatePriceFeedsIfNecessary                               | 13978           | 100770 | 100770 | 187563 | 2       |

@m30m m30m merged commit eb95266 into main Oct 13, 2023
@m30m m30m deleted the publish-time-uniqueness branch October 13, 2023 12:15
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.

2 participants