Skip to content

Commit

Permalink
fix dynamic tx stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
wanwiset25 committed Jun 20, 2024
1 parent 9ee0383 commit 91727af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/service/mainnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class MainnetService {
}

async submitTxsDynamic(results: Array<{ encodedRLP: string; blockNum: number }>): Promise<void> {
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{
Expand All @@ -141,6 +141,7 @@ export class MainnetService {
} catch (error){}
}

let errorCount = 0;
//loop while reducing tx size
while (results.length) {
let i = 0;
Expand All @@ -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);
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/service/subnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ export class SubnetService {
return;
} catch (error){}
}

let errorCount = 0;
while (results.length) {
let i = 0;
while (i < blocksPerTx.length){
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 91727af

Please sign in to comment.