|
|
@@ -44,11 +44,9 @@ abstract contract Pulse is IPulse, PulseState {
|
|
|
req.publishTime = 1;
|
|
|
req.callbackGasLimit = 1;
|
|
|
req.requester = address(1);
|
|
|
- req.numPriceIds = 0;
|
|
|
- // Pre-warm the priceIds array storage
|
|
|
- for (uint8 j = 0; j < MAX_PRICE_IDS; j++) {
|
|
|
- req.priceIds[j] = bytes32(0);
|
|
|
- }
|
|
|
+ req.priceIdsHash = bytes32(uint256(1));
|
|
|
+ req.fee = 1;
|
|
|
+ req.provider = address(1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -83,16 +81,12 @@ abstract contract Pulse is IPulse, PulseState {
|
|
|
Request storage req = allocRequest(requestSequenceNumber);
|
|
|
req.sequenceNumber = requestSequenceNumber;
|
|
|
req.publishTime = publishTime;
|
|
|
- req.callbackGasLimit = callbackGasLimit;
|
|
|
+ req.callbackGasLimit = SafeCast.toUint128(callbackGasLimit);
|
|
|
req.requester = msg.sender;
|
|
|
- req.numPriceIds = uint8(priceIds.length);
|
|
|
req.provider = provider;
|
|
|
req.fee = SafeCast.toUint128(msg.value - _state.pythFeeInWei);
|
|
|
+ req.priceIdsHash = keccak256(abi.encodePacked(priceIds));
|
|
|
|
|
|
- // Copy price IDs to storage
|
|
|
- for (uint8 i = 0; i < priceIds.length; i++) {
|
|
|
- req.priceIds[i] = priceIds[i];
|
|
|
- }
|
|
|
_state.accruedFeesInWei += _state.pythFeeInWei;
|
|
|
|
|
|
emit PriceUpdateRequested(req, priceIds);
|
|
|
@@ -119,14 +113,9 @@ abstract contract Pulse is IPulse, PulseState {
|
|
|
|
|
|
// Verify priceIds match
|
|
|
require(
|
|
|
- priceIds.length == req.numPriceIds,
|
|
|
- "Price IDs length mismatch"
|
|
|
+ req.priceIdsHash == keccak256(abi.encodePacked(priceIds)),
|
|
|
+ "Price IDs mismatch"
|
|
|
);
|
|
|
- for (uint8 i = 0; i < req.numPriceIds; i++) {
|
|
|
- if (priceIds[i] != req.priceIds[i]) {
|
|
|
- revert InvalidPriceIds(priceIds[i], req.priceIds[i]);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
// TODO: should this use parsePriceFeedUpdatesUnique? also, do we need to add 1 to maxPublishTime?
|
|
|
IPyth pyth = IPyth(_state.pyth);
|
|
|
@@ -154,12 +143,14 @@ abstract contract Pulse is IPulse, PulseState {
|
|
|
// TODO: I'm pretty sure this is going to use a lot of gas because it's doing a storage lookup for each sequence number.
|
|
|
// a better solution would be a doubly-linked list of active requests.
|
|
|
// After successful callback, update firstUnfulfilledSeq if needed
|
|
|
+ /*
|
|
|
while (
|
|
|
_state.firstUnfulfilledSeq < _state.currentSequenceNumber &&
|
|
|
!isActive(findRequest(_state.firstUnfulfilledSeq))
|
|
|
) {
|
|
|
_state.firstUnfulfilledSeq++;
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
try
|
|
|
IPulseConsumer(req.requester)._pulseCallback{
|
|
|
@@ -463,7 +454,8 @@ abstract contract Pulse is IPulse, PulseState {
|
|
|
actualCount = 0;
|
|
|
|
|
|
// Start from the first unfulfilled sequence and work forwards
|
|
|
- uint64 currentSeq = _state.firstUnfulfilledSeq;
|
|
|
+ // uint64 currentSeq = _state.firstUnfulfilledSeq;
|
|
|
+ uint64 currentSeq = 0;
|
|
|
|
|
|
// Continue until we find enough active requests or reach current sequence
|
|
|
while (
|