Skip to content

Commit c253beb

Browse files
authored
fix(apps/price_pusher): address issues with alpha version (#1864)
This PR addresses the issues in the new alpha version that were reported by the users. It now handles more errors and also supports networks with legacy transactions. * fix(apps/price_pusher): handle more errors in evm * fix: use getGasPrice instead of estimateFee for compatibility * chore: bump version
1 parent c252a1c commit c253beb

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

apps/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/price-pusher",
3-
"version": "8.0.0-alpha",
3+
"version": "8.0.0",
44
"description": "Pyth Price Pusher",
55
"homepage": "https://pyth.network",
66
"main": "lib/index.js",

apps/price_pusher/src/evm/evm.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
FeeCapTooLowError,
2828
InternalRpcError,
2929
InsufficientFundsError,
30+
ContractFunctionExecutionError,
3031
} from "viem";
3132

3233
import { PythContract } from "./pyth-contract";
@@ -179,14 +180,13 @@ export class EvmPricePusher implements IPricePusher {
179180
throw e;
180181
}
181182

182-
const fees = await this.client.estimateFeesPerGas();
183-
184-
this.logger.debug({ fees }, "Estimated fees");
185-
183+
// Gas price in networks with transaction type eip1559 represents the
184+
// addition of baseFee and priorityFee required to land the transaction. We
185+
// are using this to remain compatible with the networks that doesn't
186+
// support this transaction type.
186187
let gasPrice =
187188
Number(await this.customGasStation?.getCustomGasPrice()) ||
188-
Number(fees.gasPrice) ||
189-
Number(fees.maxFeePerGas);
189+
Number(await this.client.getGasPrice());
190190

191191
// Try to re-use the same nonce and increase the gas if the last tx is not landed yet.
192192
if (this.pusherAddress === undefined) {
@@ -306,6 +306,16 @@ export class EvmPricePusher implements IPricePusher {
306306
return;
307307
}
308308

309+
// Sometimes the contract function execution fails in simulation and this error is thrown.
310+
if (err.walk((e) => e instanceof ContractFunctionExecutionError)) {
311+
this.logger.warn(
312+
{ err },
313+
"The contract function execution failed in simulation. This is an expected behaviour in high frequency or multi-instance setup. " +
314+
"Please review this error and file an issue if it is a bug. Skipping this push."
315+
);
316+
return;
317+
}
318+
309319
// We normally crash on unknown failures but we believe that this type of error is safe to skip. The other reason is that
310320
// wometimes we see a TransactionExecutionError because of the nonce without any details and it is not catchable.
311321
if (err.walk((e) => e instanceof TransactionExecutionError)) {

0 commit comments

Comments
 (0)