feat: disable loader rate limiter for non solana endpoints (#13018)
This commit is contained in:
parent
e4231d1028
commit
8863b773c1
|
@ -1446,6 +1446,7 @@ export type ConfirmedSignatureInfo = {
|
|||
* A connection to a fullnode JSON RPC endpoint
|
||||
*/
|
||||
export class Connection {
|
||||
_rpcEndpoint: string;
|
||||
_rpcRequest: RpcRequest;
|
||||
_rpcWebSocket: RpcWebSocketClient;
|
||||
_rpcWebSocketConnected: boolean = false;
|
||||
|
@ -1487,6 +1488,8 @@ export class Connection {
|
|||
* @param commitment optional default commitment level
|
||||
*/
|
||||
constructor(endpoint: string, commitment: ?Commitment) {
|
||||
this._rpcEndpoint = endpoint;
|
||||
|
||||
let url = urlParse(endpoint);
|
||||
const useHttps = url.protocol === 'https:';
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ export class Loader {
|
|||
// Fetch program account info to check if it has already been created
|
||||
const programInfo = await connection.getAccountInfo(
|
||||
program.publicKey,
|
||||
'single',
|
||||
'singleGossip',
|
||||
);
|
||||
|
||||
let transaction: Transaction | null = null;
|
||||
|
@ -127,7 +127,7 @@ export class Loader {
|
|||
transaction,
|
||||
[payer, program],
|
||||
{
|
||||
commitment: 'single',
|
||||
commitment: 'singleGossip',
|
||||
skipPreflight: true,
|
||||
},
|
||||
);
|
||||
|
@ -169,22 +169,15 @@ export class Loader {
|
|||
});
|
||||
transactions.push(
|
||||
sendAndConfirmTransaction(connection, transaction, [payer, program], {
|
||||
commitment: 'single',
|
||||
commitment: 'singleGossip',
|
||||
skipPreflight: true,
|
||||
}),
|
||||
);
|
||||
|
||||
// Delay between sends in an attempt to reduce rate limit errors
|
||||
const REQUESTS_PER_SECOND = 4;
|
||||
await sleep(1000 / REQUESTS_PER_SECOND);
|
||||
|
||||
// Run up to 8 Loads in parallel to prevent too many parallel transactions from
|
||||
// getting retried due to AccountInUse errors.
|
||||
//
|
||||
// TODO: 8 was selected empirically and should probably be revisited
|
||||
if (transactions.length === 8) {
|
||||
await Promise.all(transactions);
|
||||
transactions = [];
|
||||
if (connection._rpcEndpoint.includes('solana.com')) {
|
||||
const REQUESTS_PER_SECOND = 4;
|
||||
await sleep(1000 / REQUESTS_PER_SECOND);
|
||||
}
|
||||
|
||||
offset += chunkSize;
|
||||
|
@ -217,7 +210,7 @@ export class Loader {
|
|||
transaction,
|
||||
[payer, program],
|
||||
{
|
||||
commitment: 'single',
|
||||
commitment: 'singleGossip',
|
||||
skipPreflight: true,
|
||||
},
|
||||
);
|
||||
|
|
|
@ -27,7 +27,7 @@ test('load BPF C program', async () => {
|
|||
|
||||
const data = await fs.readFile('test/fixtures/noop-c/noop.so');
|
||||
|
||||
const connection = new Connection(url, 'recent');
|
||||
const connection = new Connection(url, 'singleGossip');
|
||||
const {feeCalculator} = await connection.getRecentBlockhash();
|
||||
const fees =
|
||||
feeCalculator.lamportsPerSignature *
|
||||
|
@ -53,7 +53,7 @@ test('load BPF C program', async () => {
|
|||
programId: program.publicKey,
|
||||
});
|
||||
await sendAndConfirmTransaction(connection, transaction, [from], {
|
||||
commitment: 'single',
|
||||
commitment: 'singleGossip',
|
||||
skipPreflight: true,
|
||||
});
|
||||
});
|
||||
|
@ -64,7 +64,7 @@ describe('load BPF Rust program', () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const connection = new Connection(url, 'recent');
|
||||
const connection = new Connection(url, 'singleGossip');
|
||||
|
||||
let program: Account;
|
||||
let signature: string;
|
||||
|
|
|
@ -30,7 +30,7 @@ export async function newAccountWithLamports(
|
|||
account.publicKey,
|
||||
lamports,
|
||||
);
|
||||
await connection.confirmTransaction(signature, 'single');
|
||||
await connection.confirmTransaction(signature, 'singleGossip');
|
||||
|
||||
return account;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue