|
|
@@ -27,6 +27,7 @@ import {
|
|
|
FeeCapTooLowError,
|
|
|
InternalRpcError,
|
|
|
InsufficientFundsError,
|
|
|
+ ContractFunctionExecutionError,
|
|
|
} from "viem";
|
|
|
|
|
|
import { PythContract } from "./pyth-contract";
|
|
|
@@ -179,14 +180,13 @@ export class EvmPricePusher implements IPricePusher {
|
|
|
throw e;
|
|
|
}
|
|
|
|
|
|
- const fees = await this.client.estimateFeesPerGas();
|
|
|
-
|
|
|
- this.logger.debug({ fees }, "Estimated fees");
|
|
|
-
|
|
|
+ // Gas price in networks with transaction type eip1559 represents the
|
|
|
+ // addition of baseFee and priorityFee required to land the transaction. We
|
|
|
+ // are using this to remain compatible with the networks that doesn't
|
|
|
+ // support this transaction type.
|
|
|
let gasPrice =
|
|
|
Number(await this.customGasStation?.getCustomGasPrice()) ||
|
|
|
- Number(fees.gasPrice) ||
|
|
|
- Number(fees.maxFeePerGas);
|
|
|
+ Number(await this.client.getGasPrice());
|
|
|
|
|
|
// Try to re-use the same nonce and increase the gas if the last tx is not landed yet.
|
|
|
if (this.pusherAddress === undefined) {
|
|
|
@@ -306,6 +306,16 @@ export class EvmPricePusher implements IPricePusher {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // Sometimes the contract function execution fails in simulation and this error is thrown.
|
|
|
+ if (err.walk((e) => e instanceof ContractFunctionExecutionError)) {
|
|
|
+ this.logger.warn(
|
|
|
+ { err },
|
|
|
+ "The contract function execution failed in simulation. This is an expected behaviour in high frequency or multi-instance setup. " +
|
|
|
+ "Please review this error and file an issue if it is a bug. Skipping this push."
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// We normally crash on unknown failures but we believe that this type of error is safe to skip. The other reason is that
|
|
|
// wometimes we see a TransactionExecutionError because of the nonce without any details and it is not catchable.
|
|
|
if (err.walk((e) => e instanceof TransactionExecutionError)) {
|