Skip to content

Commit

Permalink
fix: connext relayer minGasPrice (#5476)
Browse files Browse the repository at this point in the history
* fix: connext relayer minGasPrice

* chore: lint
  • Loading branch information
liu-zhipeng authored Jan 6, 2024
1 parent ab30b49 commit 5e841fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ops/testnet/prod/core/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ locals {
providers = ["https://base-goerli.g.alchemy.com/v2/${var.basegoerli_alchemy_key_0}", "https://lb.drpc.org/ogrpc?network=base-goerli&dkey=${var.drpc_key}", "https://goerli.base.org"]
}
"2016506996" = {
providers = ["https://testrpc.x1.tech", "https://x1testrpc.okx.com/"]
providers = ["https://testrpc.x1.tech", "https://x1testrpc.okx.com/"],
minGasPrice = "300000000000"
}
}
environment = var.stage
Expand Down
8 changes: 7 additions & 1 deletion packages/agents/relayer/src/bindings/relays/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ export const pollCache = async () => {
// TODO: For `proveAndProcess` calls, we should be providing:
// gas limit = expected gas cost + PROCESS_GAS + RESERVE_GAS
// We need to read those values from on-chain IFF this is a `proveAndProcess` call.
const gasPrice = await rpcProvider.getGasPrice();
let gasPrice = await rpcProvider.getGasPrice();
const minGasPrice = config.chains[domain].minGasPrice;
if (minGasPrice) {
gasPrice = gasPrice.lt(minGasPrice) ? BigNumber.from(minGasPrice) : gasPrice;
}

logger.debug(`Got the gasPrice for domain: ${domain}`, requestContext, methodContext, {
gasPrice: gasPrice.toString(),
});

const gasLimit = await txservice.getGasEstimate(+domain, transaction);
logger.debug(`Got the gasLimit for domain: ${domain}`, requestContext, methodContext, {
gasLimit: gasLimit.toString(),
Expand Down
3 changes: 2 additions & 1 deletion packages/agents/relayer/src/lib/entities/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Type, Static } from "@sinclair/typebox";
import { TAddress } from "@connext/nxtp-utils";
import { TAddress, TIntegerString } from "@connext/nxtp-utils";

export const TChainConfig = Type.Object({
providers: Type.Array(Type.String()),
confirmations: Type.Integer({ minimum: 1 }), // What we consider the "safe confirmations" number for this chain.
minGasPrice: Type.Optional(TIntegerString), // minimun gas price in wei
deployments: Type.Object({
connext: TAddress,
}),
Expand Down

0 comments on commit 5e841fd

Please sign in to comment.