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

feat: enable via-ir #21

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
QueryProcessorTest:testFindNearestSample_CanFindExactValue(uint32,uint256,uint256,uint256) (runs: 256, μ: 65806302, ~: 74826166)
QueryProcessorTest:testFindNearestSample_CanFindIntermediateValue(uint32,uint256,uint256,uint256) (runs: 256, μ: 64996916, ~: 74226210)
QueryProcessorTest:testFindNearestSample_NotInitialized() (gas: 1056944892)
QueryProcessorTest:testFindNearestSample_OneSample(uint256) (runs: 256, μ: 80136, ~: 80169)
QueryProcessorTest:testGetInstantValue() (gas: 123891)
QueryProcessorTest:testGetInstantValue_NotInitialized(uint256) (runs: 256, μ: 19378, ~: 19378)
QueryProcessorTest:testGetInstantValue_NotInitialized_BeyondBufferSize(uint8,uint16) (runs: 256, μ: 68260435, ~: 68260368)
QueryProcessorTest:testGetPastAccumulator_BufferEmpty(uint8) (runs: 256, μ: 26902, ~: 26962)
QueryProcessorTest:testGetPastAccumulator_ExactMatch(uint32,uint256,uint256,uint16) (runs: 256, μ: 71271543, ~: 80081087)
QueryProcessorTest:testGetPastAccumulator_ExactMatch_LatestAccumulator(uint32,uint256,uint256) (runs: 256, μ: 67118170, ~: 76073918)
QueryProcessorTest:testGetPastAccumulator_ExactMatch_OldestAccumulator(uint32,uint256,uint256) (runs: 256, μ: 67147892, ~: 76105399)
QueryProcessorTest:testGetPastAccumulator_ExtrapolatesBeyondLatest(uint32,uint256,uint256,uint256) (runs: 256, μ: 64971065, ~: 74197796)
QueryProcessorTest:testGetPastAccumulator_InterpolatesBetweenPastAccumulators(uint32,uint256,uint256,uint256) (runs: 256, μ: 65004847, ~: 74232436)
QueryProcessorTest:testGetPastAccumulator_InvalidAgo(uint32,uint256,uint256,uint256) (runs: 256, μ: 64962680, ~: 74189873)
QueryProcessorTest:testGetPastAccumulator_QueryTooOld(uint32,uint256,uint256,uint256) (runs: 256, μ: 64974173, ~: 74199723)
QueryProcessorTest:testGetTimeWeightedAverage(uint32,uint256,uint256,uint256,uint256) (runs: 256, μ: 107958222, ~: 115516665)
QueryProcessorTest:testGetTimeWeightedAverage_BadSecs() (gas: 10981)
ReservoirPriceOracleTest:testClearRoute() (gas: 52216)
ReservoirPriceOracleTest:testClearRoute_AllWordsCleared() (gas: 159654)
ReservoirPriceOracleTest:testDesignatePair() (gas: 29038)
ReservoirPriceOracleTest:testDesignatePair_IncorrectPair() (gas: 21133)
ReservoirPriceOracleTest:testDesignatePair_NotOwner() (gas: 17541)
ReservoirPriceOracleTest:testDesignatePair_TokenOrderReversed() (gas: 30605)
ReservoirPriceOracleTest:testGetQuote(uint256,uint256) (runs: 256, μ: 33681, ~: 33805)
ReservoirPriceOracleTest:testGetQuote_AmountInTooLarge() (gas: 12950)
ReservoirPriceOracleTest:testGetQuote_BaseIsVault(uint256) (runs: 256, μ: 401378, ~: 401124)
ReservoirPriceOracleTest:testGetQuote_ComplicatedDecimals() (gas: 10127860)
ReservoirPriceOracleTest:testGetQuote_Inverse(uint256,uint256) (runs: 256, μ: 35804, ~: 35867)
ReservoirPriceOracleTest:testGetQuote_MultipleHops() (gas: 111603)
ReservoirPriceOracleTest:testGetQuote_MultipleHops_Inverse() (gas: 111924)
ReservoirPriceOracleTest:testGetQuote_MultipleHops_PriceZero() (gas: 122238)
ReservoirPriceOracleTest:testGetQuote_NoFallbackOracle() (gas: 20788)
ReservoirPriceOracleTest:testGetQuote_PriceZero() (gas: 15930)
ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_1HopRoute(uint256,uint256,address,address,uint8,uint8) (runs: 256, μ: 5198032, ~: 5198035)
ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_2HopRoute(uint256,uint256,uint256,address,address,address,uint8,uint8,uint8) (runs: 256, μ: 10269567, ~: 10269655)
ReservoirPriceOracleTest:testGetQuote_SameBaseQuote(uint256,address) (runs: 256, μ: 8927, ~: 8927)
ReservoirPriceOracleTest:testGetQuote_UseFallback() (gas: 38250)
ReservoirPriceOracleTest:testGetQuote_ZeroIn() (gas: 36635)
ReservoirPriceOracleTest:testGetQuotes(uint256,uint256) (runs: 256, μ: 26203, ~: 26327)
ReservoirPriceOracleTest:testPriceCache_Inverted() (gas: 21949)
ReservoirPriceOracleTest:testSetFallbackOracle_NotOwner() (gas: 10928)
ReservoirPriceOracleTest:testSetRoute() (gas: 61014)
ReservoirPriceOracleTest:testSetRoute_InvalidRewardThreshold() (gas: 37278)
ReservoirPriceOracleTest:testSetRoute_InvalidRoute() (gas: 20106)
ReservoirPriceOracleTest:testSetRoute_InvalidRouteLength() (gas: 19253)
ReservoirPriceOracleTest:testSetRoute_MultipleHops() (gas: 201105)
ReservoirPriceOracleTest:testSetRoute_NotSorted() (gas: 13006)
ReservoirPriceOracleTest:testSetRoute_OverwriteExisting() (gas: 169491)
ReservoirPriceOracleTest:testSetRoute_SameToken() (gas: 13019)
ReservoirPriceOracleTest:testUndesignatePair() (gas: 30215)
ReservoirPriceOracleTest:testUndesignatePair_NotOwner() (gas: 15344)
ReservoirPriceOracleTest:testUpdatePrice_AboveThresholdBelowMaxReward(uint256) (runs: 256, μ: 163637, ~: 163657)
ReservoirPriceOracleTest:testUpdatePrice_BelowThreshold(uint256) (runs: 256, μ: 148532, ~: 148476)
ReservoirPriceOracleTest:testUpdatePrice_BeyondMaxReward(uint256) (runs: 256, μ: 161152, ~: 161177)
ReservoirPriceOracleTest:testUpdatePrice_FirstUpdate() (gas: 152255)
ReservoirPriceOracleTest:testUpdatePrice_IntermediateRoutes() (gas: 15927172)
ReservoirPriceOracleTest:testUpdatePrice_PriceOutOfRange() (gas: 5288225)
ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_ContractNoReceive() (gas: 151436)
ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_InsufficientReward(uint256) (runs: 256, μ: 209567, ~: 209771)
ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_ZeroRecipient() (gas: 145106)
ReservoirPriceOracleTest:testUpdateRewardGasAmount() (gas: 19027)
ReservoirPriceOracleTest:testUpdateRewardGasAmount_NotOwner() (gas: 10930)
ReservoirPriceOracleTest:testUpdateTwapPeriod(uint256) (runs: 256, μ: 21571, ~: 21656)
ReservoirPriceOracleTest:testUpdateTwapPeriod_InvalidTwapPeriod(uint256) (runs: 256, μ: 17706, ~: 17994)
ReservoirPriceOracleTest:testWritePriceCache(uint256) (runs: 256, μ: 30061, ~: 29807)
RoutesLibTest:testGetDecimalDifference() (gas: 3966)
RoutesLibTest:testIsCompositeRoute() (gas: 4332)
RoutesLibTest:testPackSimplePrice(int8,uint256) (runs: 256, μ: 8097, ~: 7862)
SamplesTest:testAccumulator() (gas: 3952)
SamplesTest:testAccumulator_BadVariableRequest() (gas: 3355)
SamplesTest:testInstant() (gas: 3902)
SamplesTest:testInstant_BadVariableRequest() (gas: 3398)
QueryProcessorTest:testFindNearestSample_CanFindExactValue(uint32,uint256,uint256,uint256) (runs: 257, μ: 66620664, ~: 73765944)
QueryProcessorTest:testFindNearestSample_CanFindIntermediateValue(uint32,uint256,uint256,uint256) (runs: 257, μ: 66271867, ~: 75016316)
QueryProcessorTest:testFindNearestSample_NotInitialized() (gas: 1056944255)
QueryProcessorTest:testFindNearestSample_OneSample(uint256) (runs: 257, μ: 80507, ~: 80528)
QueryProcessorTest:testGetInstantValue() (gas: 123646)
QueryProcessorTest:testGetInstantValue_NotInitialized(uint256) (runs: 257, μ: 19472, ~: 19472)
QueryProcessorTest:testGetInstantValue_NotInitialized_BeyondBufferSize(uint8,uint16) (runs: 257, μ: 68993719, ~: 68993666)
QueryProcessorTest:testGetPastAccumulator_BufferEmpty(uint8) (runs: 257, μ: 27288, ~: 27332)
QueryProcessorTest:testGetPastAccumulator_ExactMatch(uint32,uint256,uint256,uint16) (runs: 257, μ: 71082888, ~: 80014760)
QueryProcessorTest:testGetPastAccumulator_ExactMatch_LatestAccumulator(uint32,uint256,uint256) (runs: 257, μ: 72840219, ~: 80235424)
QueryProcessorTest:testGetPastAccumulator_ExactMatch_OldestAccumulator(uint32,uint256,uint256) (runs: 257, μ: 72875303, ~: 80272187)
QueryProcessorTest:testGetPastAccumulator_ExtrapolatesBeyondLatest(uint32,uint256,uint256,uint256) (runs: 257, μ: 66241508, ~: 74983858)
QueryProcessorTest:testGetPastAccumulator_InterpolatesBetweenPastAccumulators(uint32,uint256,uint256,uint256) (runs: 257, μ: 66280019, ~: 75022624)
QueryProcessorTest:testGetPastAccumulator_InvalidAgo(uint32,uint256,uint256,uint256) (runs: 257, μ: 66232831, ~: 74974993)
QueryProcessorTest:testGetPastAccumulator_QueryTooOld(uint32,uint256,uint256,uint256) (runs: 257, μ: 66245097, ~: 74985178)
QueryProcessorTest:testGetTimeWeightedAverage(uint32,uint256,uint256,uint256,uint256) (runs: 257, μ: 103892291, ~: 112072978)
QueryProcessorTest:testGetTimeWeightedAverage_BadSecs() (gas: 10704)
ReservoirPriceOracleTest:testClearRoute() (gas: 52978)
ReservoirPriceOracleTest:testClearRoute_AllWordsCleared() (gas: 160339)
ReservoirPriceOracleTest:testDesignatePair() (gas: 30696)
ReservoirPriceOracleTest:testDesignatePair_IncorrectPair() (gas: 22121)
ReservoirPriceOracleTest:testDesignatePair_NotOwner() (gas: 18200)
ReservoirPriceOracleTest:testDesignatePair_TokenOrderReversed() (gas: 32405)
ReservoirPriceOracleTest:testGetQuote(uint256,uint256) (runs: 257, μ: 32680, ~: 32753)
ReservoirPriceOracleTest:testGetQuote_AmountInTooLarge() (gas: 13370)
ReservoirPriceOracleTest:testGetQuote_BaseIsVault(uint256) (runs: 257, μ: 458652, ~: 458499)
ReservoirPriceOracleTest:testGetQuote_ComplicatedDecimals() (gas: 9984934)
ReservoirPriceOracleTest:testGetQuote_Inverse(uint256,uint256) (runs: 257, μ: 34606, ~: 34722)
ReservoirPriceOracleTest:testGetQuote_MultipleHops() (gas: 111498)
ReservoirPriceOracleTest:testGetQuote_MultipleHops_Inverse() (gas: 111328)
ReservoirPriceOracleTest:testGetQuote_MultipleHops_PriceZero() (gas: 120962)
ReservoirPriceOracleTest:testGetQuote_NoFallbackOracle() (gas: 21697)
ReservoirPriceOracleTest:testGetQuote_PriceZero() (gas: 16176)
ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_1HopRoute(uint256,uint256,address,address,uint8,uint8) (runs: 257, μ: 5127553, ~: 5127481)
ReservoirPriceOracleTest:testGetQuote_RandomizeAllParam_2HopRoute(uint256,uint256,uint256,address,address,address,uint8,uint8,uint8) (runs: 257, μ: 10127566, ~: 10127552)
ReservoirPriceOracleTest:testGetQuote_SameBaseQuote(uint256,address) (runs: 257, μ: 9322, ~: 9322)
ReservoirPriceOracleTest:testGetQuote_UseFallback() (gas: 38463)
ReservoirPriceOracleTest:testGetQuote_ZeroIn() (gas: 35239)
ReservoirPriceOracleTest:testGetQuotes(uint256,uint256) (runs: 257, μ: 26353, ~: 26426)
ReservoirPriceOracleTest:testPriceCache_Inverted() (gas: 22129)
ReservoirPriceOracleTest:testSetFallbackOracle_NotOwner() (gas: 11418)
ReservoirPriceOracleTest:testSetRoute() (gas: 61524)
ReservoirPriceOracleTest:testSetRoute_InvalidRewardThreshold() (gas: 38385)
ReservoirPriceOracleTest:testSetRoute_InvalidRoute() (gas: 20684)
ReservoirPriceOracleTest:testSetRoute_InvalidRouteLength() (gas: 19652)
ReservoirPriceOracleTest:testSetRoute_MultipleHops() (gas: 202160)
ReservoirPriceOracleTest:testSetRoute_NotSorted() (gas: 14220)
ReservoirPriceOracleTest:testSetRoute_OverwriteExisting() (gas: 170628)
ReservoirPriceOracleTest:testSetRoute_SameToken() (gas: 13497)
ReservoirPriceOracleTest:testUndesignatePair() (gas: 31936)
ReservoirPriceOracleTest:testUndesignatePair_NotOwner() (gas: 16393)
ReservoirPriceOracleTest:testUpdatePrice_AboveThresholdBelowMaxReward(uint256) (runs: 257, μ: 165534, ~: 165527)
ReservoirPriceOracleTest:testUpdatePrice_BelowThreshold(uint256) (runs: 257, μ: 150926, ~: 150723)
ReservoirPriceOracleTest:testUpdatePrice_BeyondMaxReward(uint256) (runs: 257, μ: 163295, ~: 163291)
ReservoirPriceOracleTest:testUpdatePrice_FirstUpdate() (gas: 156257)
ReservoirPriceOracleTest:testUpdatePrice_IntermediateRoutes() (gas: 15708887)
ReservoirPriceOracleTest:testUpdatePrice_PriceOutOfRange() (gas: 5219577)
ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_ContractNoReceive() (gas: 154619)
ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_InsufficientReward(uint256) (runs: 257, μ: 211498, ~: 211560)
ReservoirPriceOracleTest:testUpdatePrice_RewardEligible_ZeroRecipient() (gas: 147388)
ReservoirPriceOracleTest:testUpdateRewardGasAmount() (gas: 20508)
ReservoirPriceOracleTest:testUpdateRewardGasAmount_NotOwner() (gas: 12170)
ReservoirPriceOracleTest:testUpdateTwapPeriod(uint256) (runs: 257, μ: 22157, ~: 22201)
ReservoirPriceOracleTest:testUpdateTwapPeriod_InvalidTwapPeriod(uint256) (runs: 257, μ: 18782, ~: 18827)
ReservoirPriceOracleTest:testWritePriceCache(uint256) (runs: 257, μ: 30511, ~: 30358)
RoutesLibTest:testGetDecimalDifference() (gas: 4142)
RoutesLibTest:testIsCompositeRoute() (gas: 4474)
RoutesLibTest:testPackSimplePrice(int8,uint256) (runs: 257, μ: 7910, ~: 7828)
SamplesTest:testAccumulator() (gas: 3818)
SamplesTest:testAccumulator_BadVariableRequest() (gas: 3374)
SamplesTest:testInstant() (gas: 3876)
SamplesTest:testInstant_BadVariableRequest() (gas: 3496)
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[profile.default]
solc = "0.8.28"
evm_version = "cancun"
via-ir = true
bytecode_hash = "ipfs"
optimizer_runs = 1_000_000
libs = ['lib']
Expand Down
5 changes: 4 additions & 1 deletion test/unit/libraries/QueryProcessor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { Buffer, OracleErrors } from "src/libraries/QueryProcessor.sol";
import { QueryProcessorWrapper, ReservoirPair, Observation, PriceType } from "test/wrapper/QueryProcessorWrapper.sol";
import { console2 } from "forge-std/console2.sol";

Check failure on line 8 in test/unit/libraries/QueryProcessor.t.sol

View workflow job for this annotation

GitHub Actions / lint

Unexpected import of console file

contract QueryProcessorTest is BaseTest {
using FactoryStoreLib for GenericFactory;
Expand Down Expand Up @@ -179,7 +180,9 @@
uint16 lObservationsToWrite = uint16(bound(aObservationsToWrite, 3, Buffer.SIZE * 3)); // go around it 3 times maximum

// arrange
uint256 lStartTime = block.timestamp;
// the following two lines are a workaround to the via-ir bug when working with forge-std's time wrap. See https://github.com/foundry-rs/foundry/issues/1373
uint256 lStartTime = (block.timestamp << 1) >> 1;
console2.log(lStartTime);

Check failure on line 185 in test/unit/libraries/QueryProcessor.t.sol

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
_fillBuffer(lBlockTime, lObservationsToWrite);
(,,, uint16 lIndex) = _pair.getReserves();

Expand Down
Loading