Skip to content

Commit 35a2fb6

Browse files
authored
[price-pusher] Bug fix on revert and crash (#652)
1 parent 9459107 commit 35a2fb6

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

price_pusher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-evm-price-pusher",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "Pyth EVM Price Pusher",
55
"homepage": "https://pyth.network",
66
"main": "lib/index.js",

price_pusher/src/controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export class Controller {
2222
await this.sourcePriceListener.start();
2323
await this.targetPriceListener.start();
2424

25+
// wait for the listeners to get updated. There could be a restart
26+
// before this run and we need to respect the cooldown duration as
27+
// their might be a message sent before.
28+
await sleep(this.cooldownDuration * 1000);
29+
2530
for (;;) {
2631
const pricesToPush: PriceConfig[] = [];
2732
const pubTimesToPush: UnixTimestamp[] = [];

price_pusher/src/evm/evm.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,20 @@ export class EvmPricePusher implements IPricePusher {
150150
"Pushing ",
151151
priceIdsWith0x.map((priceIdWith0x) => `${priceIdWith0x}`)
152152
);
153-
const updateFee = await this.pythContract.methods
154-
.getUpdateFee(priceFeedUpdateData)
155-
.call();
156-
console.log(`Update fee: ${updateFee}`);
153+
154+
let updateFee;
155+
156+
try {
157+
updateFee = await this.pythContract.methods
158+
.getUpdateFee(priceFeedUpdateData)
159+
.call();
160+
console.log(`Update fee: ${updateFee}`);
161+
} catch (e: any) {
162+
console.error(
163+
"An unidentified error has occured when getting the update fee:"
164+
);
165+
throw e;
166+
}
157167

158168
const gasPrice = await this.customGasStation?.getCustomGasPrice();
159169

@@ -168,11 +178,7 @@ export class EvmPricePusher implements IPricePusher {
168178
console.log(`Successful. Tx hash: ${hash}`);
169179
})
170180
.on("error", (err: Error, receipt?: TransactionReceipt) => {
171-
if (
172-
err.message.includes(
173-
"VM Exception while processing transaction: revert"
174-
)
175-
) {
181+
if (err.message.includes("revert")) {
176182
// Since we are using custom error structs on solidity the rejection
177183
// doesn't return any information why the call has reverted. Assuming that
178184
// the update data is valid there is no possible rejection cause other than

0 commit comments

Comments
 (0)