Skip to content

Commit

Permalink
improvement according pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayurii committed Jan 29, 2024
1 parent 177d780 commit bcb5d13
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 27 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The indexer built on top of Lake Framework that watches the network and stores t

### [config](configuration/README.md)

The configuration module is responsible for managing the configuration settings of the NEAR readnode project.
The configuration module is responsible for managing the configuration settings of the NEAR ReadRPC project.

## Docker compose

Expand Down
4 changes: 0 additions & 4 deletions configuration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ tracing-subscriber = { version = "0.3.15", features = [
tracing-opentelemetry = { version = "0.19", optional = true }
tracing-stackdriver = "0.7.2" # GCP logs


near-indexer-primitives = "1.36.0"
near-lake-framework = "0.7.6"



[features]
tracing-instrumentation = ["dep:opentelemetry-jaeger", "dep:tracing-opentelemetry"]
4 changes: 2 additions & 2 deletions configuration/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration

The configuration module is responsible for managing the configuration settings of the NEAR readnode project.
The configuration module is responsible for managing the configuration settings of the NEAR ReadRPC project.
It reads and parses the configuration from a TOML file and provides these settings to other parts of the application.

## Environment Variables
Expand All @@ -13,7 +13,7 @@ For example, `${DATABASE_URL}` specifies the `DATABASE_URL` environment variable

## Files

- `example.config.toml`: This file contains an example configuration for the NEAR readnode.
- `example.config.toml`: This file contains an example configuration for the NEAR ReadRPC.
It includes settings for the general configuration,
RPC server, transaction indexer, state indexer, epoch indexer, rightsizing, lake framework, and database.

Expand Down
5 changes: 2 additions & 3 deletions configuration/example.config.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
### General configuration for NEAR readnode
### General configuration for NEAR ReadRPC
[general]

## Chain ID: testnet or mainnet
## mainnet or testnet
chain_id = "mainnet"

## Near network rpc url
## Using for proxying some requests to near network and to hendle finality block
## Using for proxying some requests to near network and to handle finality block
near_rpc_url = "https://beta.rpc.mainnet.near.org"

## near network archival rpc url
Expand Down
3 changes: 2 additions & 1 deletion configuration/src/configs/database.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::configs::{deserialize_data_or_env, deserialize_optional_data_or_env};
use serde_derive::Deserialize;

use crate::configs::{deserialize_data_or_env, deserialize_optional_data_or_env};

#[derive(Deserialize, Debug, Clone, Default)]
pub struct DatabaseConfig {
#[serde(deserialize_with = "deserialize_data_or_env")]
Expand Down
6 changes: 4 additions & 2 deletions configuration/src/configs/general.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::configs::{deserialize_data_or_env, deserialize_optional_data_or_env};
use serde_derive::Deserialize;
use std::str::FromStr;

use serde_derive::Deserialize;

use crate::configs::{deserialize_data_or_env, deserialize_optional_data_or_env};

#[derive(Deserialize, Debug, Clone, Default)]
pub struct GeneralConfig {
#[serde(deserialize_with = "deserialize_data_or_env")]
Expand Down
5 changes: 3 additions & 2 deletions configuration/src/configs/lake.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::configs::deserialize_data_or_env;
use near_indexer_primitives::near_primitives;
use near_lake_framework::near_indexer_primitives::near_primitives;
use serde_derive::Deserialize;

use crate::configs::deserialize_data_or_env;

#[derive(Deserialize, Debug, Clone, Default)]
pub struct LakeConfig {
#[serde(deserialize_with = "deserialize_data_or_env")]
Expand Down
12 changes: 8 additions & 4 deletions configuration/src/configs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use std::str::FromStr;

use near_lake_framework::{
near_indexer_primitives, near_indexer_primitives::views::StateChangeValueView,
};
use serde::Deserialize;

pub(crate) mod database;
pub(crate) mod general;
mod lake;
mod rightsizing;

use near_indexer_primitives::views::StateChangeValueView;
use serde::Deserialize;
use std::str::FromStr;

lazy_static::lazy_static! {
static ref RE_NAME_ENV: regex::Regex = regex::Regex::new(r"\$\{(?<env_name>\w+)}").unwrap();
}
Expand Down Expand Up @@ -89,6 +92,7 @@ impl Config {
) -> anyhow::Result<near_lake_framework::LakeConfig> {
self.lake_config.lake_config(start_block_height).await
}

pub async fn to_s3_client(&self) -> near_lake_framework::s3_fetchers::LakeS3Client {
let s3_config = self.lake_config.s3_config().await;
near_lake_framework::s3_fetchers::LakeS3Client::new(aws_sdk_s3::Client::from_conf(
Expand Down
4 changes: 3 additions & 1 deletion configuration/src/configs/rightsizing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use near_indexer_primitives::views::StateChangeValueView;
use near_lake_framework::{
near_indexer_primitives, near_indexer_primitives::views::StateChangeValueView,
};
use serde_derive::Deserialize;

#[derive(Deserialize, Debug, Clone, Default)]
Expand Down
12 changes: 6 additions & 6 deletions tx-indexer/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) async fn index_transactions(
)
.await?;
collect_receipts_and_outcomes(
indexer_config.general.chain_id.clone(),
&indexer_config.general.chain_id,
streamer_message,
db_manager,
tx_collecting_storage,
Expand Down Expand Up @@ -144,7 +144,7 @@ async fn new_transaction_details_to_collecting_pool(

#[cfg_attr(feature = "tracing-instrumentation", tracing::instrument(skip_all))]
async fn collect_receipts_and_outcomes(
chain_id: configuration::ChainId,
chain_id: &configuration::ChainId,
streamer_message: &near_indexer_primitives::StreamerMessage,
db_manager: &std::sync::Arc<Box<dyn database::TxIndexerDbManager + Sync + Send + 'static>>,
tx_collecting_storage: &std::sync::Arc<impl TxCollectingStorage>,
Expand All @@ -154,7 +154,7 @@ async fn collect_receipts_and_outcomes(

let shard_futures = streamer_message.shards.iter().map(|shard| {
process_shard(
chain_id.clone(),
chain_id,
db_manager,
tx_collecting_storage,
block_height,
Expand All @@ -170,7 +170,7 @@ async fn collect_receipts_and_outcomes(

#[cfg_attr(feature = "tracing-instrumentation", tracing::instrument(skip_all))]
async fn process_shard(
chain_id: configuration::ChainId,
chain_id: &configuration::ChainId,
db_manager: &std::sync::Arc<Box<dyn database::TxIndexerDbManager + Sync + Send + 'static>>,
tx_collecting_storage: &std::sync::Arc<impl TxCollectingStorage>,
block_height: u64,
Expand All @@ -183,7 +183,7 @@ async fn process_shard(
.iter()
.map(|receipt_execution_outcome| {
process_receipt_execution_outcome(
chain_id.clone(),
chain_id,
db_manager,
tx_collecting_storage,
block_height,
Expand All @@ -200,7 +200,7 @@ async fn process_shard(

#[cfg_attr(feature = "tracing-instrumentation", tracing::instrument(skip_all))]
async fn process_receipt_execution_outcome(
chain_id: configuration::ChainId,
chain_id: &configuration::ChainId,
db_manager: &std::sync::Arc<Box<dyn database::TxIndexerDbManager + Sync + Send + 'static>>,
tx_collecting_storage: &std::sync::Arc<impl TxCollectingStorage>,
block_height: u64,
Expand Down

0 comments on commit bcb5d13

Please sign in to comment.