@@ -94,21 +94,23 @@ async function fundWallets(
9494
9595 let outputs : Output [ ] = [ ] ;
9696
97- // Process mnemonics sequentially with small delays to avoid overwhelming the system
98- const LOG_INTERVAL = 100 ;
99- const maxRetries = 3 ; // Used for all retry logic in this function
97+ // due to some unexpected errors during setup, there is retry logic on exceptions
98+ // related issue: https://github.com/nodejs/undici/issues/3492
99+ const maxRetries = 3 ;
100100
101101 for ( let i = 0 ; i < mnemonics . length ; i ++ ) {
102- const mnemonic = mnemonics [ i ] ;
103- const directwallet = await DirectSecp256k1HdWallet . fromMnemonic ( mnemonic , {
104- prefix : prefix ,
105- } ) ;
106-
107102 // Get accounts with retry logic
108103 let accounts = null ;
109104 let retries = 0 ;
110105 while ( retries < maxRetries && ! accounts ) {
106+ const mnemonic = mnemonics [ i ] ;
111107 try {
108+ const directwallet = await DirectSecp256k1HdWallet . fromMnemonic (
109+ mnemonic ,
110+ {
111+ prefix : prefix ,
112+ } ,
113+ ) ;
112114 accounts = await directwallet . getAccounts ( ) ;
113115 } catch ( error ) {
114116 retries ++ ;
@@ -133,12 +135,6 @@ async function fundWallets(
133135 coins : [ { denom : denom , amount : poorAmount } ] ,
134136 } ;
135137 outputs . push ( output ) ;
136-
137- // Log progress and add small delay every 100 wallets to let system breathe
138- if ( ( i + 1 ) % LOG_INTERVAL === 0 ) {
139- // Small delay to prevent connection pool exhaustion
140- await waitSeconds ( 0.5 ) ;
141- }
142138 }
143139
144140 if ( prefix === NEUTRON_PREFIX ) {
@@ -178,7 +174,7 @@ async function fundWallets(
178174 `Connection attempt ${ connectRetries } /${ maxRetries } failed, retrying...` ,
179175 ) ;
180176 if ( connectRetries < maxRetries ) {
181- await waitSeconds ( 2 ) ;
177+ await waitSeconds ( 1 ) ;
182178 } else {
183179 throw error ;
184180 }
@@ -199,7 +195,7 @@ async function fundWallets(
199195 ] ;
200196 const value : MsgMultiSend = {
201197 inputs,
202- outputs : outputs ,
198+ outputs,
203199 } ;
204200 const msg : any = {
205201 typeUrl : MsgMultiSend . typeUrl ,
@@ -223,7 +219,7 @@ async function fundWallets(
223219 `Broadcast attempt ${ broadcastRetries } /${ maxRetries } failed, retrying...` ,
224220 ) ;
225221 if ( broadcastRetries < maxRetries ) {
226- await waitSeconds ( 2 ) ;
222+ await waitSeconds ( 1 ) ;
227223 } else {
228224 throw error ;
229225 }
0 commit comments