Skip to content

Commit 3828a17

Browse files
committed
refactor(target_chains/ethereum): clean up unused batch update code
1 parent b511dea commit 3828a17

File tree

8 files changed

+0
-182
lines changed

8 files changed

+0
-182
lines changed

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

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -175,76 +175,6 @@ abstract contract Pyth is
175175
if (price.publishTime == 0) revert PythErrors.PriceFeedNotFound();
176176
}
177177

178-
function parseBatchAttestationHeader(
179-
bytes memory encoded
180-
)
181-
internal
182-
pure
183-
returns (uint index, uint nAttestations, uint attestationSize)
184-
{
185-
unchecked {
186-
index = 0;
187-
188-
// Check header
189-
{
190-
uint32 magic = UnsafeBytesLib.toUint32(encoded, index);
191-
index += 4;
192-
if (magic != 0x50325748) revert PythErrors.InvalidUpdateData();
193-
194-
uint16 versionMajor = UnsafeBytesLib.toUint16(encoded, index);
195-
index += 2;
196-
if (versionMajor != 3) revert PythErrors.InvalidUpdateData();
197-
198-
// This value is only used as the check below which currently
199-
// never reverts
200-
// uint16 versionMinor = UnsafeBytesLib.toUint16(encoded, index);
201-
index += 2;
202-
203-
// This check is always false as versionMinor is 0, so it is commented.
204-
// in the future that the minor version increases this will have effect.
205-
// if(versionMinor < 0) revert InvalidUpdateData();
206-
207-
uint16 hdrSize = UnsafeBytesLib.toUint16(encoded, index);
208-
index += 2;
209-
210-
// NOTE(2022-04-19): Currently, only payloadId comes after
211-
// hdrSize. Future extra header fields must be read using a
212-
// separate offset to respect hdrSize, i.e.:
213-
//
214-
// uint hdrIndex = 0;
215-
// bpa.header.payloadId = UnsafeBytesLib.toUint8(encoded, index + hdrIndex);
216-
// hdrIndex += 1;
217-
//
218-
// bpa.header.someNewField = UnsafeBytesLib.toUint32(encoded, index + hdrIndex);
219-
// hdrIndex += 4;
220-
//
221-
// // Skip remaining unknown header bytes
222-
// index += bpa.header.hdrSize;
223-
224-
uint8 payloadId = UnsafeBytesLib.toUint8(encoded, index);
225-
226-
// Skip remaining unknown header bytes
227-
index += hdrSize;
228-
229-
// Payload ID of 2 required for batch headerBa
230-
if (payloadId != 2) revert PythErrors.InvalidUpdateData();
231-
}
232-
233-
// Parse the number of attestations
234-
nAttestations = UnsafeBytesLib.toUint16(encoded, index);
235-
index += 2;
236-
237-
// Parse the attestation size
238-
attestationSize = UnsafeBytesLib.toUint16(encoded, index);
239-
index += 2;
240-
241-
// Given the message is valid the arithmetic below should not overflow, and
242-
// even if it overflows then the require would fail.
243-
if (encoded.length != (index + (attestationSize * nAttestations)))
244-
revert PythErrors.InvalidUpdateData();
245-
}
246-
}
247-
248178
function parsePriceFeedUpdatesInternal(
249179
bytes[] calldata updateData,
250180
bytes32[] calldata priceIds,

target_chains/ethereum/contracts/forge-test/utils/PythTestUtils.t.sol

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,6 @@ abstract contract PythTestUtils is Test, WormholeTestUtils, RandTestUtils {
322322
);
323323
}
324324

325-
// Generates a VAA for the given attestations.
326-
// This method calls generatePriceFeedUpdatePayload and then creates a VAA with it.
327-
// The VAAs generated from this method use block timestamp as their timestamp.
328-
function generateWhBatchUpdate(
329-
PriceAttestation[] memory attestations,
330-
uint64 sequence,
331-
uint8 numSigners
332-
) public returns (bytes memory vaa) {
333-
bytes memory payload = generatePriceFeedUpdatePayload(attestations);
334-
335-
vaa = generateVaa(
336-
uint32(block.timestamp),
337-
SOURCE_EMITTER_CHAIN_ID,
338-
SOURCE_EMITTER_ADDRESS,
339-
sequence,
340-
payload,
341-
numSigners
342-
);
343-
}
344-
345325
function pricesToPriceAttestations(
346326
bytes32[] memory priceIds,
347327
PythStructs.Price[] memory prices

target_chains/ethereum/sdk/solidity/IPythEvents.sol

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,4 @@ interface IPythEvents {
1515
int64 price,
1616
uint64 conf
1717
);
18-
19-
/// @dev Emitted when a batch price update is processed successfully.
20-
/// @param chainId ID of the source chain that the batch price update comes from.
21-
/// @param sequenceNumber Sequence number of the batch price update.
22-
event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber);
2318
}

target_chains/ethereum/sdk/solidity/MockPyth.sol

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import "./PythErrors.sol";
77

88
contract MockPyth is AbstractPyth {
99
mapping(bytes32 => PythStructs.PriceFeed) priceFeeds;
10-
uint64 sequenceNumber;
1110

1211
uint singleUpdateFeeInWei;
1312
uint validTimePeriod;
@@ -41,10 +40,6 @@ contract MockPyth is AbstractPyth {
4140
uint requiredFee = getUpdateFee(updateData);
4241
if (msg.value < requiredFee) revert PythErrors.InsufficientFee();
4342

44-
// Chain ID is id of the source chain that the price update comes from. Since it is just a mock contract
45-
// We set it to 1.
46-
uint16 chainId = 1;
47-
4843
for (uint i = 0; i < updateData.length; i++) {
4944
PythStructs.PriceFeed memory priceFeed = abi.decode(
5045
updateData[i],
@@ -64,12 +59,6 @@ contract MockPyth is AbstractPyth {
6459
);
6560
}
6661
}
67-
68-
// In the real contract, the input of this function contains multiple batches that each contain multiple prices.
69-
// This event is emitted when a batch is processed. In this mock contract we consider there is only one batch of prices.
70-
// Each batch has (chainId, sequenceNumber) as it's unique identifier. Here chainId is set to 1 and an increasing sequence number is used.
71-
emit BatchPriceFeedUpdate(chainId, sequenceNumber);
72-
sequenceNumber += 1;
7362
}
7463

7564
function getUpdateFee(

target_chains/ethereum/sdk/solidity/abis/AbstractPyth.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,6 @@
1414
"name": "StalePrice",
1515
"type": "error"
1616
},
17-
{
18-
"anonymous": false,
19-
"inputs": [
20-
{
21-
"indexed": false,
22-
"internalType": "uint16",
23-
"name": "chainId",
24-
"type": "uint16"
25-
},
26-
{
27-
"indexed": false,
28-
"internalType": "uint64",
29-
"name": "sequenceNumber",
30-
"type": "uint64"
31-
}
32-
],
33-
"name": "BatchPriceFeedUpdate",
34-
"type": "event"
35-
},
3617
{
3718
"anonymous": false,
3819
"inputs": [

target_chains/ethereum/sdk/solidity/abis/IPyth.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,4 @@
11
[
2-
{
3-
"anonymous": false,
4-
"inputs": [
5-
{
6-
"indexed": false,
7-
"internalType": "uint16",
8-
"name": "chainId",
9-
"type": "uint16"
10-
},
11-
{
12-
"indexed": false,
13-
"internalType": "uint64",
14-
"name": "sequenceNumber",
15-
"type": "uint64"
16-
}
17-
],
18-
"name": "BatchPriceFeedUpdate",
19-
"type": "event"
20-
},
212
{
223
"anonymous": false,
234
"inputs": [

target_chains/ethereum/sdk/solidity/abis/IPythEvents.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,4 @@
11
[
2-
{
3-
"anonymous": false,
4-
"inputs": [
5-
{
6-
"indexed": false,
7-
"internalType": "uint16",
8-
"name": "chainId",
9-
"type": "uint16"
10-
},
11-
{
12-
"indexed": false,
13-
"internalType": "uint64",
14-
"name": "sequenceNumber",
15-
"type": "uint64"
16-
}
17-
],
18-
"name": "BatchPriceFeedUpdate",
19-
"type": "event"
20-
},
212
{
223
"anonymous": false,
234
"inputs": [

target_chains/ethereum/sdk/solidity/abis/MockPyth.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,6 @@
4545
"name": "StalePrice",
4646
"type": "error"
4747
},
48-
{
49-
"anonymous": false,
50-
"inputs": [
51-
{
52-
"indexed": false,
53-
"internalType": "uint16",
54-
"name": "chainId",
55-
"type": "uint16"
56-
},
57-
{
58-
"indexed": false,
59-
"internalType": "uint64",
60-
"name": "sequenceNumber",
61-
"type": "uint64"
62-
}
63-
],
64-
"name": "BatchPriceFeedUpdate",
65-
"type": "event"
66-
},
6748
{
6849
"anonymous": false,
6950
"inputs": [

0 commit comments

Comments
 (0)