Skip to content

Commit 20fd5e7

Browse files
Adding configuration to make number of accounts fetched by gma (#8)
1 parent 1bd6d1a commit 20fd5e7

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

bin/autobahn-router/examples/grpc_source_tester.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub async fn main() {
2929
grpc_sources: Some(vec![]),
3030
dedup_queue_size: 0,
3131
request_timeout_in_seconds: None,
32+
number_of_accounts_per_gma: None,
3233
};
3334

3435
// Raydium

bin/autobahn-router/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ async fn main() -> anyhow::Result<()> {
125125
.unwrap_or_else(|| panic!("did not find a source config for region {}", region));
126126

127127
let rpc = build_rpc(&source_config);
128+
let number_of_accounts_per_gma = source_config.number_of_accounts_per_gma.unwrap_or(100);
128129

129130
// handle sigint
130131
let exit_flag: Arc<atomic::AtomicBool> = Arc::new(atomic::AtomicBool::new(false));
@@ -313,7 +314,12 @@ async fn main() -> anyhow::Result<()> {
313314
info!("Using {} mints", mints.len(),);
314315

315316
let token_cache = {
316-
let mint_metadata = request_mint_metadata(&source_config.rpc_http_url, &mints).await;
317+
let mint_metadata = request_mint_metadata(
318+
&source_config.rpc_http_url,
319+
&mints,
320+
number_of_accounts_per_gma,
321+
)
322+
.await;
317323
let mut data: HashMap<Pubkey, token_cache::Decimals> = HashMap::new();
318324
for (mint_pubkey, Token { mint, decimals }) in mint_metadata {
319325
assert_eq!(mint_pubkey, mint);

bin/autobahn-router/src/source/grpc_plugin_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ use yellowstone_grpc_proto::geyser::{
4343
use yellowstone_grpc_proto::tonic::codec::CompressionEncoding;
4444

4545
const MAX_GRPC_ACCOUNT_SUBSCRIPTIONS: usize = 100;
46-
const MAX_GMA_ACCOUNTS: usize = 100;
4746

4847
// limit number of concurrent gMA/gPA requests
4948
const MAX_PARALLEL_HEAVY_RPC_REQUESTS: usize = 4;
@@ -72,6 +71,7 @@ pub async fn feed_data_geyser(
7271
sender: async_channel::Sender<SourceMessage>,
7372
) -> anyhow::Result<()> {
7473
let use_compression = snapshot_config.rpc_support_compression.unwrap_or(false);
74+
let number_of_accounts_per_gma = snapshot_config.number_of_accounts_per_gma.unwrap_or(100);
7575
let grpc_connection_string = match &grpc_config.connection_string.chars().next().unwrap() {
7676
'$' => env::var(&grpc_config.connection_string[1..])
7777
.expect("reading connection string from env"),
@@ -336,7 +336,7 @@ pub async fn feed_data_geyser(
336336
let permits_parallel_rpc_requests = Arc::new(Semaphore::new(MAX_PARALLEL_HEAVY_RPC_REQUESTS));
337337

338338
info!("Requesting snapshot from gMA for {} filter accounts", accounts_filter.len());
339-
for pubkey_chunk in accounts_filter.iter().chunks(MAX_GMA_ACCOUNTS).into_iter() {
339+
for pubkey_chunk in accounts_filter.iter().chunks(number_of_accounts_per_gma).into_iter() {
340340
let rpc_http_url = snapshot_rpc_http_url.clone();
341341
let account_ids = pubkey_chunk.cloned().collect_vec();
342342
let sender = snapshot_gma_sender.clone();

bin/autobahn-router/src/source/mint_accounts_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::time::Instant;
1616
use tokio::sync::Semaphore;
1717
use tracing::{info, trace};
1818

19-
const MAX_GMA_ACCOUNTS: usize = 100;
2019
// 4: 388028 mints -> 61 sec
2120
// 16: 388028 mints -> 35 sec
2221
const MAX_PARALLEL_HEAVY_RPC_REQUESTS: usize = 16;
@@ -30,6 +29,7 @@ pub struct Token {
3029
pub async fn request_mint_metadata(
3130
rpc_http_url: &str,
3231
mint_account_ids: &HashSet<Pubkey>,
32+
max_gma_accounts: usize,
3333
) -> HashMap<Pubkey, Token> {
3434
info!(
3535
"Requesting data for mint accounts via chunked gMA for {} pubkey ..",
@@ -51,7 +51,7 @@ pub async fn request_mint_metadata(
5151

5252
let mut threads = Vec::new();
5353
let count = Arc::new(AtomicU64::new(0));
54-
for pubkey_chunk in mint_account_ids.iter().chunks(MAX_GMA_ACCOUNTS).into_iter() {
54+
for pubkey_chunk in mint_account_ids.iter().chunks(max_gma_accounts).into_iter() {
5555
let pubkey_chunk = pubkey_chunk.into_iter().cloned().collect_vec();
5656
let count = count.clone();
5757
let rpc_client = rpc_client.clone();

bin/autobahn-router/src/source/quic_plugin_source.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ use router_feed_lib::get_program_account::{
2626
use solana_program::clock::Slot;
2727
use tokio::sync::Semaphore;
2828

29-
const MAX_GMA_ACCOUNTS: usize = 100;
30-
3129
// limit number of concurrent gMA/gPA requests
3230
const MAX_PARALLEL_HEAVY_RPC_REQUESTS: usize = 4;
3331

@@ -46,6 +44,7 @@ pub async fn feed_data_geyser(
4644
sender: async_channel::Sender<SourceMessage>,
4745
) -> anyhow::Result<()> {
4846
let use_compression = snapshot_config.rpc_support_compression.unwrap_or(false);
47+
let number_of_accounts_per_gma = snapshot_config.number_of_accounts_per_gma.unwrap_or(100);
4948

5049
let snapshot_rpc_http_url = match &snapshot_config.rpc_http_url.chars().next().unwrap() {
5150
'$' => env::var(&snapshot_config.rpc_http_url[1..])
@@ -194,7 +193,7 @@ pub async fn feed_data_geyser(
194193
let permits_parallel_rpc_requests = Arc::new(Semaphore::new(MAX_PARALLEL_HEAVY_RPC_REQUESTS));
195194

196195
info!("Requesting snapshot from gMA for {} filter accounts", subscribed_accounts.len());
197-
for pubkey_chunk in subscribed_accounts.iter().chunks(MAX_GMA_ACCOUNTS).into_iter() {
196+
for pubkey_chunk in subscribed_accounts.iter().chunks(number_of_accounts_per_gma).into_iter() {
198197
let rpc_http_url = snapshot_rpc_http_url.clone();
199198
let account_ids = pubkey_chunk.map(|x| *x).collect_vec();
200199
let sender = snapshot_gma_sender.clone();

lib/router-config-lib/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ pub struct AccountDataSourceConfig {
9696
pub grpc_sources: Option<Vec<GrpcSourceConfig>>,
9797
pub dedup_queue_size: usize,
9898
pub request_timeout_in_seconds: Option<u64>,
99+
pub number_of_accounts_per_gma: Option<usize>,
99100
}
100101

101102
#[derive(Clone, Debug, serde_derive::Deserialize)]

0 commit comments

Comments
 (0)