diff --git a/configuration/example.config.toml b/configuration/example.config.toml index d75d21d8..40285420 100644 --- a/configuration/example.config.toml +++ b/configuration/example.config.toml @@ -17,7 +17,7 @@ near_rpc_url = "https://beta.rpc.mainnet.near.org" #near_archival_rpc_url = "https://beta.rpc.mainnet.near.org" ### Rpc server general configuration -#[general.rpc_server] +[general.rpc_server] ## Referer header value ## We want to set a custom referer to let NEAR JSON RPC nodes know that we are a read-rpc instance @@ -48,7 +48,7 @@ near_rpc_url = "https://beta.rpc.mainnet.near.org" #block_cache_size = 0.125 ### Tx indexer general configuration -#[general.tx_indexer] +[general.tx_indexer] ## Indexer ID to handle meta data about the instance ## Unique indexer ID @@ -67,7 +67,7 @@ near_rpc_url = "https://beta.rpc.mainnet.near.org" #cache_restore_blocks_range = 1000 ### State indexer general configuration -#[general.state_indexer] +[general.state_indexer] ## Indexer ID to handle meta data about the instance ## Unique indexer ID @@ -84,7 +84,7 @@ near_rpc_url = "https://beta.rpc.mainnet.near.org" #concurrency = 1 ## Epoch indexer general configuration -#[general.epoch_indexer] +[general.epoch_indexer] ## Indexer ID to handle meta data about the instance ## Unique indexer ID @@ -93,7 +93,7 @@ near_rpc_url = "https://beta.rpc.mainnet.near.org" #indexer_id = "epoch-indexer" ### Tracking acconunts and state changes configuration -#[rightsizing] +[rightsizing] ## Accounts to track. By default we track all accounts. ## You can specify a list of accounts to track. @@ -159,7 +159,7 @@ database_url = "postgresql://postgres:password@localhost:5432/near-indexer" #database_password = "password" ### Database configuration for rpc server -#[database.rpc_server] +[database.rpc_server] ## ScyllaDB preferred DataCenter ## Accepts the DC name of the ScyllaDB to filter the connection to that DC only (preferrably). @@ -186,7 +186,7 @@ database_url = "postgresql://postgres:password@localhost:5432/near-indexer" #keepalive_interval = 60 ### Database configuration for tx indexer -#[database.tx_indexer] +[database.tx_indexer] ## ScyllaDB preferred DataCenter ## Accepts the DC name of the ScyllaDB to filter the connection to that DC only (preferrably). @@ -213,7 +213,7 @@ database_url = "postgresql://postgres:password@localhost:5432/near-indexer" #max_db_parallel_queries = 144 ## Database configuration for state indexer -#[database.state_indexer] +[database.state_indexer] ## ScyllaDB preferred DataCenter ## Accepts the DC name of the ScyllaDB to filter the connection to that DC only (preferrably). @@ -233,25 +233,3 @@ database_url = "postgresql://postgres:password@localhost:5432/near-indexer" ## before giving up, and moving to the next piece of data ## For indexers we use true by default #strict_mode = true - -## Database configuration for epoch indexer -#[database.epoch_indexer] - -## ScyllaDB preferred DataCenter -## Accepts the DC name of the ScyllaDB to filter the connection to that DC only (preferrably). -## If you connect to multi-DC cluter, you might experience big latencies while working with the DB. -## This is due to the fact that ScyllaDB driver tries to connect to any of the nodes in the cluster disregarding of the location of the DC. -## This option allows to filter the connection to the DC you need. -## Example: "DC1" where DC1 is located in the same region as the application. -## Default value is None -#preferred_dc = "DC1" # Optional - -## Max retry count for ScyllaDB if `strict_mode` is `false` -## For indexers we use 5 attempts by default -#max_retry = 5 - -## Attempts to store data in the database should be infinite to ensure no data is missing. -## Disable it to perform a limited write attempts (`max_retry`) -## before giving up, and moving to the next piece of data -## For indexers we use true by default -#strict_mode = true diff --git a/configuration/src/configs/database.rs b/configuration/src/configs/database.rs index 1ceca08f..afc35f61 100644 --- a/configuration/src/configs/database.rs +++ b/configuration/src/configs/database.rs @@ -17,8 +17,6 @@ pub struct DatabaseConfig { pub tx_indexer: DatabaseTxIndexerConfig, #[serde(default)] pub state_indexer: DatabaseStateIndexerConfig, - #[serde(default)] - pub epoch_indexer: DatabaseEpochIndexerConfig, } #[derive(Deserialize, Debug, Clone)] @@ -148,39 +146,3 @@ impl Default for DatabaseStateIndexerConfig { } } } - -#[derive(Deserialize, Debug, Clone)] -pub struct DatabaseEpochIndexerConfig { - #[serde(deserialize_with = "deserialize_data_or_env", default)] - pub preferred_dc: Option, - #[serde( - deserialize_with = "deserialize_data_or_env", - default = "DatabaseEpochIndexerConfig::default_max_retry" - )] - pub max_retry: u32, - #[serde( - deserialize_with = "deserialize_data_or_env", - default = "DatabaseEpochIndexerConfig::default_strict_mode" - )] - pub strict_mode: bool, -} - -impl DatabaseEpochIndexerConfig { - pub fn default_max_retry() -> u32 { - 5 - } - - pub fn default_strict_mode() -> bool { - true - } -} - -impl Default for DatabaseEpochIndexerConfig { - fn default() -> Self { - Self { - preferred_dc: Default::default(), - max_retry: Self::default_max_retry(), - strict_mode: Self::default_strict_mode(), - } - } -} diff --git a/rpc-server/src/main.rs b/rpc-server/src/main.rs index 62d75f9c..6fe134b1 100644 --- a/rpc-server/src/main.rs +++ b/rpc-server/src/main.rs @@ -1,7 +1,5 @@ use crate::modules::blocks::FinalBlockInfo; -use crate::utils::{ - get_final_cache_block, gigabytes_to_bytes, update_final_block_height_regularly, -}; +use crate::utils::{gigabytes_to_bytes, update_final_block_height_regularly}; use jsonrpc_v2::{Data, Server}; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; @@ -87,10 +85,6 @@ async fn main() -> anyhow::Result<()> { .clone(), )?; - let final_block = get_final_cache_block(&near_rpc_client) - .await - .expect("Error to get final block"); - let limit_memory_cache_in_bytes = if let Some(limit_memory_cache) = rpc_server_config.general.rpc_server.limit_memory_cache { Some(gigabytes_to_bytes(limit_memory_cache).await) @@ -131,7 +125,13 @@ async fn main() -> anyhow::Result<()> { .call(near_jsonrpc_client::methods::EXPERIMENTAL_genesis_config::RpcGenesisConfigRequest) .await?; let lake_config = rpc_server_config - .to_lake_config(final_block.block_height) + .to_lake_config( + finale_block_info + .read() + .await + .final_block_cache + .block_height, + ) .await?; let lake_s3_client = rpc_server_config.to_s3_client().await; diff --git a/rpc-server/src/utils.rs b/rpc-server/src/utils.rs index 0519729f..86713710 100644 --- a/rpc-server/src/utils.rs +++ b/rpc-server/src/utils.rs @@ -9,7 +9,7 @@ const DEFAULT_RETRY_COUNT: u8 = 3; /// JsonRpcClient represents a client capable of interacting with NEAR JSON-RPC endpoints, /// The client is capable of handling requests to both regular and archival nodes. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct JsonRpcClient { regular_client: near_jsonrpc_client::JsonRpcClient, archival_client: near_jsonrpc_client::JsonRpcClient, @@ -108,7 +108,10 @@ pub async fn get_final_cache_block(near_rpc_client: &JsonRpcClient) -> Option None, + Err(err) => { + tracing::warn!("Error to get final block: {:?}", err); + None + }, } }