Skip to content

Commit

Permalink
Fix arb gas (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiguantong authored May 24, 2024
1 parent 9bb3632 commit 2dcb76a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/relay-relayer/src/client/contract_relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,25 @@ export class RelayerContractClient {
// }
// }
const contractOptions: EthersRequestOptions = {};

// console.log("options", options);
const enableGasCheck =
[
421614, // arbitrum sepolia
42161, // arbitrum one
].indexOf(options.chainId) > -1;
].indexOf(Number(options.chainId)) > -1;
if (enableGasCheck) {
const estimatedGas = await this.contract["relay"].estimateGas(
options.message
);
contractOptions.gasLimit = estimatedGas + estimatedGas;
contractOptions.gasLimit =
((options.gasLimit + estimatedGas) * BigInt(3)) / BigInt(2);
console.log(
`contractOptions.gasLimit: ${contractOptions.gasLimit}, options.gasLimit: ${options.gasLimit}, estimatedGas: ${estimatedGas}`
);
} else {
contractOptions.gasLimit = options.gasLimit;
}
switch (options.chainId) {
switch (Number(options.chainId)) {
case 42161: // arbitrum
contractOptions.maxFeePerGas = BigInt(300000000);
contractOptions.maxPriorityFeePerGas = BigInt(100000000);
Expand Down
5 changes: 5 additions & 0 deletions packages/relay-relayer/src/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ export class RelayerRelay extends CommonRelay<RelayerRelayLifecycle> {

let targetTxRelayMessage;
try {
// console.log("\n\n###########")
// console.log("sourceNextMessageAccepted.messageGasLimit", sourceNextMessageAccepted.messageGasLimit)
// console.log("baseGas", baseGas)
// console.log("BigInt(sourceNextMessageAccepted.messageGasLimit) * BigInt(64) / BigInt(63) + baseGas + BigInt(100000)", BigInt(sourceNextMessageAccepted.messageGasLimit) * BigInt(64) / BigInt(63) + baseGas + BigInt(100000));
// console.log("###########\n\n")
targetTxRelayMessage = await this.targetRelayerClient.relay({
message,
gasLimit: BigInt(sourceNextMessageAccepted.messageGasLimit) * BigInt(64) / BigInt(63) + baseGas + BigInt(100000),
Expand Down

0 comments on commit 2dcb76a

Please sign in to comment.