Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to fastnear #358

Merged
merged 9 commits into from
Dec 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
imrovement
kobayurii committed Dec 24, 2024
commit f4b425d115cc217ec8239b2dc1976d9b72f7587c
18 changes: 12 additions & 6 deletions configuration/src/configs/lake.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::configs::deserialize_optional_data_or_env;
use near_lake_framework::near_indexer_primitives::near_primitives;
use serde_derive::Deserialize;

use crate::configs::deserialize_optional_data_or_env;

#[derive(Debug, Clone)]
pub struct LakeConfig {
pub num_threads: Option<u64>,
@@ -12,13 +11,20 @@ impl LakeConfig {
pub async fn lake_config(
&self,
start_block_height: near_primitives::types::BlockHeight,
chain_id: crate::ChainId,
) -> anyhow::Result<near_lake_framework::FastNearConfig> {
let config_builder = near_lake_framework::FastNearConfigBuilder::default();
let mut config_builder = near_lake_framework::FastNearConfigBuilder::default();
match chain_id {
crate::ChainId::Mainnet => config_builder = config_builder.mainnet(),
// Testnet is the default chain for other chain_id
_ => config_builder = config_builder.testnet(),
};
if let Some(num_threads) = self.num_threads {
config_builder = config_builder.num_threads(num_threads);
};
Ok(config_builder
.mainnet()
.start_block_height(start_block_height)
.build()
.expect("Failed to build LakeConfig"))
.build()?)
}
}

3 changes: 2 additions & 1 deletion rpc-server/src/config.rs
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ impl GenesisInfo {

#[derive(Clone)]
pub struct ServerContext {
/// Lake s3 client
/// Fastnear client
pub fastnear_client: near_lake_framework::FastNearClient,
/// Database manager
pub db_manager: std::sync::Arc<Box<dyn database::ReaderDbManager + Sync + Send + 'static>>,
@@ -110,6 +110,7 @@ impl ServerContext {
.optimistic_cache_block()
.await
.block_height,
rpc_server_config.general.chain_id.clone(),
)
.await?;

5 changes: 4 additions & 1 deletion state-indexer/src/main.rs
Original file line number Diff line number Diff line change
@@ -36,7 +36,10 @@ async fn main() -> anyhow::Result<()> {
)
.await?;

let lake_config = indexer_config.lake_config.lake_config(start_block_height).await?;
let lake_config = indexer_config
.lake_config
.lake_config(start_block_height, indexer_config.general.chain_id.clone())
.await?;
let (sender, stream) = near_lake_framework::streamer(lake_config);

// Initiate metrics http server
2 changes: 1 addition & 1 deletion tx-indexer/src/main.rs
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ async fn main() -> anyhow::Result<()> {
tracing::info!(target: INDEXER, "Generating LakeConfig...");
let lake_config = indexer_config
.lake_config
.lake_config(start_block_height)
.lake_config(start_block_height, indexer_config.general.chain_id.clone())
.await?;

tracing::info!(target: INDEXER, "Creating cache storage...");