Skip to content

Commit 87c6654

Browse files
committed
feat: don't store update in contract storage in parsePriceFeedUpdates
1 parent 528e7d9 commit 87c6654

File tree

2 files changed

+1
-81
lines changed

2 files changed

+1
-81
lines changed

target_chains/ethereum/contracts/contracts/pyth/Pyth.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ abstract contract Pyth is
238238
encoded,
239239
offset
240240
);
241-
updateLatestPriceIfNecessary(priceId, priceInfo);
242241
{
243242
// check whether caller requested for this data
244243
uint k = findIndexOfPriceId(priceIds, priceId);
@@ -397,6 +396,6 @@ abstract contract Pyth is
397396
}
398397

399398
function version() public pure returns (string memory) {
400-
return "1.4.4-alpha.1";
399+
return "1.4.5-alpha.1";
401400
}
402401
}

target_chains/ethereum/contracts/forge-test/Pyth.WormholeMerkleAccumulator.t.sol

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -897,85 +897,6 @@ contract PythWormholeMerkleAccumulatorTest is
897897
);
898898
}
899899

900-
function testParsePriceFeedUniqueWithWormholeMerkleUpdatesLatestPriceIfNecessary(
901-
uint seed
902-
) public {
903-
setRandSeed(seed);
904-
905-
uint64 numPriceFeeds = (getRandUint64() % 10) + 2;
906-
PriceFeedMessage[]
907-
memory priceFeedMessages = generateRandomPriceFeedMessage(
908-
numPriceFeeds
909-
);
910-
uint64 publishTime = getRandUint64();
911-
bytes32[] memory priceIds = new bytes32[](1);
912-
priceIds[0] = priceFeedMessages[0].priceId;
913-
for (uint64 i = 0; i < numPriceFeeds; i++) {
914-
priceFeedMessages[i].priceId = priceFeedMessages[0].priceId;
915-
priceFeedMessages[i].publishTime = publishTime;
916-
priceFeedMessages[i].prevPublishTime = publishTime;
917-
}
918-
919-
// firstUpdate is the one we expect to be returned and latestUpdate is the one we expect to be stored
920-
uint latestUpdate = (getRandUint() % numPriceFeeds);
921-
priceFeedMessages[latestUpdate].prevPublishTime = publishTime + 1000;
922-
priceFeedMessages[latestUpdate].publishTime = publishTime + 1000;
923-
924-
uint firstUpdate = (getRandUint() % numPriceFeeds);
925-
while (firstUpdate == latestUpdate) {
926-
firstUpdate = (getRandUint() % numPriceFeeds);
927-
}
928-
priceFeedMessages[firstUpdate].prevPublishTime = publishTime - 1;
929-
(
930-
bytes[] memory updateData,
931-
uint updateFee
932-
) = createWormholeMerkleUpdateData(priceFeedMessages);
933-
934-
// firstUpdate is returned but latestUpdate is stored
935-
PythStructs.PriceFeed[] memory priceFeeds = pyth
936-
.parsePriceFeedUpdatesUnique{value: updateFee}(
937-
updateData,
938-
priceIds,
939-
publishTime,
940-
MAX_UINT64
941-
);
942-
assertEq(priceFeeds.length, 1);
943-
assertParsedPriceFeedEqualsMessage(
944-
priceFeeds[0],
945-
priceFeedMessages[firstUpdate],
946-
priceIds[0]
947-
);
948-
assertPriceFeedMessageStored(priceFeedMessages[latestUpdate]);
949-
950-
// increase the latestUpdate publish time and make a new updateData
951-
priceFeedMessages[latestUpdate].publishTime = publishTime + 2000;
952-
(updateData, updateFee) = createWormholeMerkleUpdateData(
953-
priceFeedMessages
954-
);
955-
956-
// since there is a revert, the latestUpdate is not stored
957-
vm.expectRevert(PythErrors.PriceFeedNotFoundWithinRange.selector);
958-
pyth.parsePriceFeedUpdatesUnique{value: updateFee}(
959-
updateData,
960-
priceIds,
961-
publishTime - 1,
962-
MAX_UINT64
963-
);
964-
assertEq(
965-
pyth.getPriceUnsafe(priceIds[0]).publishTime,
966-
publishTime + 1000
967-
);
968-
969-
// there is no revert, the latestPrice is updated with the latestUpdate
970-
pyth.parsePriceFeedUpdatesUnique{value: updateFee}(
971-
updateData,
972-
priceIds,
973-
publishTime,
974-
MAX_UINT64
975-
);
976-
assertPriceFeedMessageStored(priceFeedMessages[latestUpdate]);
977-
}
978-
979900
function testParsePriceFeedWithWormholeMerkleWorksRandomDistinctUpdatesInput(
980901
uint seed
981902
) public {

0 commit comments

Comments
 (0)