Skip to content

Commit

Permalink
Merge pull request #44 from helix-bridge/xiaoch05-fixGasLimit
Browse files Browse the repository at this point in the history
fix gasLimit for some special chain
  • Loading branch information
xiaoch05 authored Oct 18, 2024
2 parents b4bd329 + b328e7a commit 7d508de
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 38 deletions.
10 changes: 8 additions & 2 deletions src/base/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ export class EthereumContract {
return null;
}
} catch (error) {
return null;
if (hasReturnValue) {
return null;
} else {
return error;
}
}
}
}
Expand Down Expand Up @@ -235,6 +239,7 @@ export class SafeContract extends EthereumContract {
innervalue: bigint,
operation: number,
signatures: string,
gasLimit: bigint | null = null,
value: bigint | null = null
): Promise<string> | null {
return await this.staticCall(
Expand All @@ -252,7 +257,8 @@ export class SafeContract extends EthereumContract {
signatures,
],
false,
value
value,
gasLimit
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/base/safewallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,11 @@ export class SafeWallet {
readyExecute ? "ready" : "waiting"
} to execute, tx ${safeTxHash} on chain ${chainId}`
);
const newSignatures = signatureInfo.size >= this.threshold ? signatureInfo.signatures : signatureInfo.signatures + signature.data.substring(2);
return {
...propose,
readyExecute: readyExecute,
signatures: signatureInfo.signatures + signature.data.substring(2),
signatures: newSignatures,
};
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/configure/configure.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export interface RpcNode {
rpcs: string[];
fixedGasPrice: number;
notSupport1559: boolean;
gasPriceStretching: number;
relayGasLimit: number;
lendMarket: LendInfo[];
}

Expand Down Expand Up @@ -95,7 +97,6 @@ export interface BridgeInfo {
export interface ConfigInfo {
env: string;
indexer: string;
relayGasLimit: number;
rpcnodes: RpcNode[];
bridges: BridgeInfo[];
}
Expand Down
4 changes: 2 additions & 2 deletions src/dataworker/dataworker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ export class DataworkerService implements OnModuleInit {
let feeUsed: bigint;
if (gasPrice.isEip1559) {
let maxFeePerGas = new GWei(gasPrice.eip1559fee.maxFeePerGas).mul(
1.05
1.00
).Number;
const maxPriorityFeePerGas = new GWei(
gasPrice.eip1559fee.maxPriorityFeePerGas
).mul(1.1).Number;
).mul(1.0).Number;
if (maxFeePerGas < maxPriorityFeePerGas) {
maxFeePerGas = maxPriorityFeePerGas;
}
Expand Down
21 changes: 14 additions & 7 deletions src/relayer/relayer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export class ChainInfo {
provider: EthereumProvider;
fixedGasPrice: number;
notSupport1559: boolean;
gasPriceStretching: number;
relayGasLimit: number;
lnv3Address: string;
adjustingFee: boolean;
lendMarket: LendMarket[];
Expand Down Expand Up @@ -224,6 +226,8 @@ export class RelayerService implements OnModuleInit {
provider: provider,
fixedGasPrice: rpcnode.fixedGasPrice,
notSupport1559: rpcnode.notSupport1559,
gasPriceStretching: rpcnode.gasPriceStretching ?? 1.1,
relayGasLimit: rpcnode.relayGasLimit,
lnv2DefaultAddress: chainInfo.protocol["lnv2-default"],
lnv2OppositeAddress: chainInfo.protocol["lnv2-opposite"],
lnv3Address: chainInfo.protocol.lnv3,
Expand Down Expand Up @@ -405,7 +409,7 @@ export class RelayerService implements OnModuleInit {
toBridge: toConnectInfo,
lnProviders: lnProviders,
heartBeatTime: this.heartBeatInterval,
toWallet: toWallet,
toWallet: toWallet
};
})
.filter((item) => item !== null)
Expand All @@ -422,7 +426,7 @@ export class RelayerService implements OnModuleInit {
eip1559fee: null,
};
} else {
return await chainInfo.provider.feeData(1, chainInfo.notSupport1559);
return await chainInfo.provider.feeData(chainInfo.gasPriceStretching, chainInfo.notSupport1559);
}
}

Expand Down Expand Up @@ -1052,7 +1056,7 @@ export class RelayerService implements OnModuleInit {
},
expectedTransferId: last(record.id.split("-")),
};
const configuredGasLimit = this.configureService.config.relayGasLimit;
const configuredGasLimit = toChainInfo.relayGasLimit;
const relayGasLimit =
configuredGasLimit !== undefined
? new EtherBigNumber(configuredGasLimit).Number
Expand Down Expand Up @@ -1141,24 +1145,27 @@ export class RelayerService implements OnModuleInit {
txInfo.txData,
txInfo.value,
txInfo.operation,
txInfo.signatures
txInfo.signatures,
relayGasLimit
);
if (err != null) {
this.logger.warn(
`[${fromChainInfo.chainName}>>${toChainInfo.chainName}] try to relay using safe failed, id: ${record.id}, err ${err}`
`[${fromChainInfo.chainName}>>${toChainInfo.chainName}] try to relay using safe failed, id: ${record.id}, gasLimit ${relayGasLimit}, err ${err}`
);
continue;
} else {
this.logger.log(
`[${fromChainInfo.chainName}>>${toChainInfo.chainName}] ready to exec safe tx, id: ${record.id}, gasPrice: ${gasPriceToString(gasPrice)}`
`[${fromChainInfo.chainName}>>${toChainInfo.chainName}] ready to exec safe tx, id: ${record.id}, gasPrice: ${gasPriceToString(gasPrice)}, gasLimit: ${relayGasLimit}`
);
const tx = await safeContract.execTransaction(
txInfo.to,
txInfo.txData,
txInfo.value,
txInfo.operation,
txInfo.signatures,
gasPrice
gasPrice,
null,
relayGasLimit
);
await this.store.savePendingTransaction(
toChainInfo.chainName,
Expand Down
40 changes: 15 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1113,10 +1113,10 @@
resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861"
integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==

"@helixbridge/[email protected].15":
version "1.1.15"
resolved "https://registry.yarnpkg.com/@helixbridge/helixconf/-/helixconf-1.1.15.tgz#4299f2700c1c8c859d023bd8012a9d77c8fa6add"
integrity sha512-4sufGHiqx84FEyizf8pp3bNkzPzOO9b29b/SYzlDoBEG0AIoxWIzUjI/IEIVEB7b6Ngc1lDw3imH3ZqCBEONWw==
"@helixbridge/[email protected].17":
version "1.1.17"
resolved "https://registry.yarnpkg.com/@helixbridge/helixconf/-/helixconf-1.1.17.tgz#77ebf6ee15af05e570fa8a049c01f7b01e67655f"
integrity sha512-HyJe9BqFb2MD8s2yPeKfrpwJxDb8OKvyynkzkSFZY8duCTF+fXLwsASIOpCyFXh1mZ+tyxBuRDbwukgORTIP3A==

"@humanwhocodes/config-array@^0.13.0":
version "0.13.0"
Expand Down Expand Up @@ -2054,7 +2054,7 @@
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690"
integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==

"@types/node@*":
"@types/node@*", "@types/[email protected]":
version "22.7.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.5.tgz#cfde981727a7ab3611a481510b473ae54442b92b"
integrity sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==
Expand All @@ -2066,11 +2066,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==

"@types/[email protected]":
version "18.15.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469"
integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==

"@types/node@^12.12.6":
version "12.20.55"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
Expand Down Expand Up @@ -4124,16 +4119,16 @@ ethereumjs-util@^7.1.5:
rlp "^2.2.4"

ethers@^6.13.0, ethers@^6.7.1:
version "6.13.3"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.3.tgz#b87afdadb91cc8df5f56b9c59c96e5b206f4a600"
integrity sha512-/DzbZOLVtoO4fKvvQwpEucHAQgIwBGWuRvBdwE/lMXgXvvHHTSkn7XqAQ2b+gjJzZDJjWA9OD05bVceVOsBHbg==
version "6.13.4"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.4.tgz#bd3e1c3dc1e7dc8ce10f9ffb4ee40967a651b53c"
integrity sha512-21YtnZVg4/zKkCQPjrDj38B1r4nQvTZLopUGMLQ1ePU2zV/joCfDC3t3iKQjWRzjjjbzR+mdAIoikeBRNkdllA==
dependencies:
"@adraffy/ens-normalize" "1.10.1"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.2"
"@types/node" "18.15.13"
"@types/node" "22.7.5"
aes-js "4.0.0-beta.5"
tslib "2.4.0"
tslib "2.7.0"
ws "8.17.1"

[email protected]:
Expand Down Expand Up @@ -7744,26 +7739,21 @@ [email protected], tsconfig-paths@^4.1.2:
minimist "^1.2.6"
strip-bom "^3.0.0"

[email protected]:
version "2.4.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==

[email protected]:
version "2.5.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.3.tgz#24944ba2d990940e6e982c4bea147aba80209913"
integrity sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==

[email protected], tslib@^2.1.0, tslib@^2.4.0, tslib@^2.5.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01"
integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==

tslib@^1.8.1:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.1.0, tslib@^2.4.0, tslib@^2.5.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01"
integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
Expand Down

0 comments on commit 7d508de

Please sign in to comment.