From b328e7aa6c76f3cd0ed582c6b3284ab9fa2272bf Mon Sep 17 00:00:00 2001 From: xiaoch05 Date: Fri, 18 Oct 2024 16:50:22 +0800 Subject: [PATCH] fix gasLimit for some special chain --- src/base/contract.ts | 10 +++++-- src/base/safewallet.ts | 3 ++- src/configure/configure.service.ts | 3 ++- src/dataworker/dataworker.service.ts | 4 +-- src/relayer/relayer.service.ts | 21 ++++++++++----- yarn.lock | 40 +++++++++++----------------- 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/base/contract.ts b/src/base/contract.ts index 2c8e325..dffefbc 100644 --- a/src/base/contract.ts +++ b/src/base/contract.ts @@ -125,7 +125,11 @@ export class EthereumContract { return null; } } catch (error) { - return null; + if (hasReturnValue) { + return null; + } else { + return error; + } } } } @@ -235,6 +239,7 @@ export class SafeContract extends EthereumContract { innervalue: bigint, operation: number, signatures: string, + gasLimit: bigint | null = null, value: bigint | null = null ): Promise | null { return await this.staticCall( @@ -252,7 +257,8 @@ export class SafeContract extends EthereumContract { signatures, ], false, - value + value, + gasLimit ); } diff --git a/src/base/safewallet.ts b/src/base/safewallet.ts index a98b721..4437a16 100644 --- a/src/base/safewallet.ts +++ b/src/base/safewallet.ts @@ -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, }; } } diff --git a/src/configure/configure.service.ts b/src/configure/configure.service.ts index 22b22ee..b7afe7c 100644 --- a/src/configure/configure.service.ts +++ b/src/configure/configure.service.ts @@ -63,6 +63,8 @@ export interface RpcNode { rpcs: string[]; fixedGasPrice: number; notSupport1559: boolean; + gasPriceStretching: number; + relayGasLimit: number; lendMarket: LendInfo[]; } @@ -95,7 +97,6 @@ export interface BridgeInfo { export interface ConfigInfo { env: string; indexer: string; - relayGasLimit: number; rpcnodes: RpcNode[]; bridges: BridgeInfo[]; } diff --git a/src/dataworker/dataworker.service.ts b/src/dataworker/dataworker.service.ts index 3211189..9f0489a 100644 --- a/src/dataworker/dataworker.service.ts +++ b/src/dataworker/dataworker.service.ts @@ -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; } diff --git a/src/relayer/relayer.service.ts b/src/relayer/relayer.service.ts index 2c8499b..906cba5 100644 --- a/src/relayer/relayer.service.ts +++ b/src/relayer/relayer.service.ts @@ -48,6 +48,8 @@ export class ChainInfo { provider: EthereumProvider; fixedGasPrice: number; notSupport1559: boolean; + gasPriceStretching: number; + relayGasLimit: number; lnv3Address: string; adjustingFee: boolean; lendMarket: LendMarket[]; @@ -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, @@ -405,7 +409,7 @@ export class RelayerService implements OnModuleInit { toBridge: toConnectInfo, lnProviders: lnProviders, heartBeatTime: this.heartBeatInterval, - toWallet: toWallet, + toWallet: toWallet }; }) .filter((item) => item !== null) @@ -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); } } @@ -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 @@ -1141,16 +1145,17 @@ 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, @@ -1158,7 +1163,9 @@ export class RelayerService implements OnModuleInit { txInfo.value, txInfo.operation, txInfo.signatures, - gasPrice + gasPrice, + null, + relayGasLimit ); await this.store.savePendingTransaction( toChainInfo.chainName, diff --git a/yarn.lock b/yarn.lock index 010644a..4fd7eff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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/helixconf@1.1.15": - version "1.1.15" - resolved "https://registry.yarnpkg.com/@helixbridge/helixconf/-/helixconf-1.1.15.tgz#4299f2700c1c8c859d023bd8012a9d77c8fa6add" - integrity sha512-4sufGHiqx84FEyizf8pp3bNkzPzOO9b29b/SYzlDoBEG0AIoxWIzUjI/IEIVEB7b6Ngc1lDw3imH3ZqCBEONWw== +"@helixbridge/helixconf@1.1.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" @@ -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/node@22.7.5": version "22.7.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.5.tgz#cfde981727a7ab3611a481510b473ae54442b92b" integrity sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ== @@ -2066,11 +2066,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== -"@types/node@18.15.13": - 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" @@ -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" ethjs-unit@0.1.6: @@ -7744,26 +7739,21 @@ tsconfig-paths@4.2.0, tsconfig-paths@^4.1.2: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" - integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== - tslib@2.5.3: version "2.5.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.3.tgz#24944ba2d990940e6e982c4bea147aba80209913" integrity sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w== +tslib@2.7.0, 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"