From 9ee0383a3ebbba22483667c531fc9b9e8369a66d Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Thu, 20 Jun 2024 14:35:13 +0400 Subject: [PATCH 1/2] Revert "remove bad error catch" This reverts commit 43447c865a8fd9f448b74f029cec48843ce9643c. --- src/service/mainnet/index.ts | 10 ++++++++-- src/service/subnet/index.ts | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/service/mainnet/index.ts b/src/service/mainnet/index.ts index 29e991b..af57ed8 100644 --- a/src/service/mainnet/index.ts +++ b/src/service/mainnet/index.ts @@ -134,9 +134,11 @@ export class MainnetService { const blocksPerTx = [30, 15, 5, 1]; //make 1 initial try, this is for when blocks are caught up if (results.length < blocksPerTx[0]){ + try{ this.logger.info("submitDynamic startblock", results[0].blockNum, "pushing", results.length, "blocks,",results.length, "remaining(inclusive) into PARENTNET"); await this.submitTxs(results); return; + } catch (error){} } //loop while reducing tx size @@ -145,13 +147,17 @@ export class MainnetService { while (i < blocksPerTx.length){ const val = blocksPerTx[i]; if (results.length >= val){ + try{ this.logger.info("submitDynamic startblock", results[0].blockNum, "pushing", val, "blocks,",results.length, "remaining(inclusive) into PARENTNET"); await this.submitTxs(results.slice(0, val)); results = results.slice(val, results.length); break; //if push success, reset push size + } catch (error){} + } + if (i < blocksPerTx.length){ + i++; + await sleep(3000); } - i++; - await sleep(3000); } } } diff --git a/src/service/subnet/index.ts b/src/service/subnet/index.ts index ef9b36e..0b28267 100644 --- a/src/service/subnet/index.ts +++ b/src/service/subnet/index.ts @@ -306,22 +306,28 @@ export class SubnetService { const blocksPerTx = [20, 10, 5, 1]; //make 1 initial try, this is for when blocks are caught up if (results.length < blocksPerTx[0]){ + try{ this.logger.info("submitDynamic startblock", results[0].blockNum, "pushing", results.length, "blocks,",results.length, "remaining(inclusive) into SUBNET"); await this.submitTxs(results); return; + } catch (error){} } while (results.length) { let i = 0; while (i < blocksPerTx.length){ const val = blocksPerTx[i]; if (results.length >= val){ + try{ this.logger.info("submitDynamic startblock", results[0].blockNum, "pushing", val, "blocks,", results.length, "remaining(inclusive) into SUBNET"); await this.submitTxs(results.slice(0, val)); results = results.slice(val, results.length); break; //if push success, reset push size + } catch (error){} + } + if (i < blocksPerTx.length){ + i++; + await sleep(3000); } - i++; - await sleep(3000); } } } From 91727af8104d96410f9b07b09b3abcc3a9c5d87f Mon Sep 17 00:00:00 2001 From: wanwiset25 Date: Thu, 20 Jun 2024 15:23:22 +0400 Subject: [PATCH 2/2] fix dynamic tx stuck --- src/service/mainnet/index.ts | 14 ++++++++++---- src/service/subnet/index.ts | 13 ++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/service/mainnet/index.ts b/src/service/mainnet/index.ts index af57ed8..6c270bd 100644 --- a/src/service/mainnet/index.ts +++ b/src/service/mainnet/index.ts @@ -131,7 +131,7 @@ export class MainnetService { } async submitTxsDynamic(results: Array<{ encodedRLP: string; blockNum: number }>): Promise { - const blocksPerTx = [30, 15, 5, 1]; + const blocksPerTx = [20, 10, 5, 1]; //make 1 initial try, this is for when blocks are caught up if (results.length < blocksPerTx[0]){ try{ @@ -141,6 +141,7 @@ export class MainnetService { } catch (error){} } + let errorCount = 0; //loop while reducing tx size while (results.length) { let i = 0; @@ -152,12 +153,17 @@ export class MainnetService { await this.submitTxs(results.slice(0, val)); results = results.slice(val, results.length); break; //if push success, reset push size - } catch (error){} + } catch (error){ + errorCount++; + if (errorCount > 10){ + throw Error("submitDynamic failed 10X times, reset relayer process"); + } + } } - if (i < blocksPerTx.length){ + if (i < blocksPerTx.length - 1){ i++; - await sleep(3000); } + await sleep(3000); } } } diff --git a/src/service/subnet/index.ts b/src/service/subnet/index.ts index 0b28267..0c383e8 100644 --- a/src/service/subnet/index.ts +++ b/src/service/subnet/index.ts @@ -312,6 +312,8 @@ export class SubnetService { return; } catch (error){} } + + let errorCount = 0; while (results.length) { let i = 0; while (i < blocksPerTx.length){ @@ -322,12 +324,17 @@ export class SubnetService { await this.submitTxs(results.slice(0, val)); results = results.slice(val, results.length); break; //if push success, reset push size - } catch (error){} + } catch (error){ + errorCount++; + if (errorCount > 10){ + throw Error("submitDynamic failed 10X times, reset relayer process"); + } + } } - if (i < blocksPerTx.length){ + if (i < blocksPerTx.length-1){ i++; - await sleep(3000); } + await sleep(3000); } } }