Skip to content

Conversation

ali-behjati
Copy link
Collaborator

When updating the price we only need to know the publish time of the cached price and don't need to read the whole memory. This change adds a method to get the publish time directly and uses it all the places that is possible within the code base here. We can use it in updatePriceFeedsIfNecessary too, but since it's in the sdk right now we cannot change it. Will do that later when we move the sdk inside this repo.

Snapshot difference:

testBenchmarkGetUpdateFee() (gas: 22 (0.016%)) 
testBenchmarkUpdatePriceFeedsFresh() (gas: -6822 (-1.740%)) 
testBenchmarkUpdatePriceFeedsIfNecessaryFresh() (gas: -7878 (-1.891%)) 
testBenchmarkUpdatePriceFeedsIfNecessaryNotFresh() (gas: -4834 (-2.388%)) 
testBenchmarkUpdatePriceFeedsNotFresh() (gas: -14822 (-4.056%)) 

@ali-behjati ali-behjati merged commit 8db2af6 into main Nov 4, 2022
@ali-behjati ali-behjati deleted the abehjati/eth-gas-improvement-add-price-time-getter branch November 4, 2022 16:16
@ali-behjati ali-behjati changed the title [eth] Use latestPriceInfoPublishTime when possible [eth] Gas improvement: Use latestPriceInfoPublishTime when possible Nov 14, 2022
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