-
Notifications
You must be signed in to change notification settings - Fork 110
bringing back indexer-processor #262
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
solc | ||
grpcurl | ||
grpcui | ||
redis | ||
]; | ||
|
||
# Specific version of toolchain | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[package] | ||
name = "aptos-indexer-grpc-file-store" | ||
description = "Indexer gRPC file store saves transactions to persistent storage." | ||
version = "1.0.0" | ||
|
||
# Workspace inherited keys | ||
authors = { workspace = true } | ||
edition = { workspace = true } | ||
homepage = { workspace = true } | ||
license = { workspace = true } | ||
publish = { workspace = true } | ||
repository = { workspace = true } | ||
rust-version = { workspace = true } | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
aptos-indexer-grpc-server-framework = { workspace = true } | ||
aptos-indexer-grpc-utils = { workspace = true } | ||
aptos-metrics-core = { workspace = true } | ||
aptos-moving-average = { workspace = true } | ||
async-trait = { workspace = true } | ||
clap = { workspace = true } | ||
futures = { workspace = true } | ||
once_cell = { workspace = true } | ||
redis = { workspace = true } | ||
serde = { workspace = true } | ||
tokio = { workspace = true } | ||
tracing = { workspace = true } | ||
|
||
[target.'cfg(unix)'.dependencies] | ||
jemallocator = { workspace = true } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "indexer-grpc-cache-worker" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
authors.workspace = true | ||
repository.workspace = true | ||
homepage.workspace = true | ||
publish.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
|
||
[lints] | ||
workspace = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::{Context, Result}; | ||
use aptos_indexer_grpc_utils::{config::IndexerGrpcCacheWorkerConfig, IndexerGrpcFileStoreConfig, types::RedisUrl}; | ||
use serde::{Deserialize, Serialize}; | ||
use url::Url; | ||
|
||
const RUNTIME_WORKER_MULTIPLIER: usize = 2; | ||
|
||
fn main() -> Result<()> { | ||
|
||
use tracing_subscriber::EnvFilter; | ||
|
||
tracing_subscriber::fmt() | ||
.with_env_filter( | ||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")), | ||
) | ||
.init(); | ||
|
||
let dot_movement = dot_movement::DotMovement::try_from_env()?; | ||
let config = dot_movement.try_get_config_from_json::<suzuka_config::Config>()?; | ||
|
||
|
||
let fullnode_grpc_address = format!( | ||
"http://{}:{}", | ||
config.execution_config.maptos_config.client.maptos_indexer_grpc_connection_hostname, | ||
config.execution_config.maptos_config.client.maptos_indexer_grpc_connection_port | ||
); | ||
println!("Connecting to indexer gRPC server at: {}", fullnode_grpc_address.clone()); | ||
|
||
let config = IndexerGrpcCacheWorkerConfig { | ||
fullnode_grpc_address: fullnode_grpc_address.clone(), | ||
file_store_config: IndexerGrpcFileStoreConfig { | ||
// variable provideded by gcs file store and local file store | ||
// https://github.com/aptos-labs/aptos-core/blob/main/ecosystem/indexer-grpc/indexer-grpc-utils/src/config.rs#L45 | ||
}, | ||
redis_main_instance_address: RedisUrl::new("redis://localhost:6379")?, | ||
enable_cache_compression: true, | ||
}; | ||
|
||
let num_cpus = num_cpus::get(); | ||
let worker_threads = (num_cpus * RUNTIME_WORKER_MULTIPLIER).max(16); | ||
println!( | ||
"[Indexer cache worker] Starting cache worker tokio runtime: num_cpus={}, worker_threads={}", | ||
num_cpus, worker_threads | ||
); | ||
|
||
let mut builder = tokio::runtime::Builder::new_multi_thread(); | ||
builder | ||
.disable_lifo_slot() | ||
.enable_all() | ||
.worker_threads(worker_threads) | ||
.build() | ||
.unwrap() | ||
.block_on(async { | ||
config.run().await | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "indexer-grpc-data-service" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
authors.workspace = true | ||
repository.workspace = true | ||
homepage.workspace = true | ||
publish.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
|
||
[lints] | ||
workspace = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "suzuka-indexer-processor" | ||
description = "Indexer GRPC processor in Rust." | ||
version = "1.0.0" | ||
|
||
# Workspace inherited keys | ||
authors = ["Aptos Labs <[email protected]>"] | ||
edition = "2021" | ||
homepage = "https://aptoslabs.com" | ||
license = "Apache-2.0" | ||
publish = false | ||
repository = "https://github.com/aptos-labs/aptos-core" | ||
rust-version = { workspace = true } | ||
|
||
[dependencies] | ||
processor = { workspace = true } | ||
server-framework = { workspace = true } | ||
tokio = { workspace = true } | ||
anyhow = { workspace = true } | ||
num_cpus = { workspace = true } | ||
dot-movement = { workspace = true } | ||
suzuka-config = { workspace = true } | ||
ahash = { workspace = true } | ||
tracing = { workspace = true } | ||
tracing-subscriber = { workspace = true } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::Result; | ||
use processor::IndexerGrpcProcessorConfig; | ||
use processor::processors::ProcessorConfig; | ||
use server_framework::RunnableConfig; | ||
use ahash::AHashMap; | ||
|
||
const RUNTIME_WORKER_MULTIPLIER: usize = 2; | ||
|
||
fn main() -> Result<()> { | ||
|
||
use tracing_subscriber::EnvFilter; | ||
|
||
tracing_subscriber::fmt() | ||
.with_env_filter( | ||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")), | ||
) | ||
.init(); | ||
|
||
let dot_movement = dot_movement::DotMovement::try_from_env()?; | ||
let config = dot_movement.try_get_config_from_json::<suzuka_config::Config>()?; | ||
|
||
|
||
let url = format!( | ||
"http://{}:{}", | ||
config.execution_config.maptos_config.client.maptos_indexer_grpc_connection_hostname, | ||
config.execution_config.maptos_config.client.maptos_indexer_grpc_connection_port | ||
); | ||
println!("Connecting to indexer gRPC server at: {}", url); | ||
|
||
let config = IndexerGrpcProcessorConfig { | ||
processor_config: ProcessorConfig::DefaultProcessor, | ||
postgres_connection_string: config.execution_config.maptos_config.indexer_processor.postgres_connection_string.clone(), | ||
indexer_grpc_data_service_address: format!( | ||
"http://{}:{}", | ||
config.execution_config.maptos_config.client.maptos_indexer_grpc_connection_hostname, | ||
config.execution_config.maptos_config.client.maptos_indexer_grpc_connection_port | ||
).parse()?, | ||
grpc_http2_config: Default::default(), | ||
auth_token: config.execution_config.maptos_config.indexer_processor.indexer_processor_auth_token.clone(), | ||
starting_version: None, | ||
ending_version: None, | ||
number_concurrent_processing_tasks: None, | ||
db_pool_size: None, | ||
gap_detection_batch_size: IndexerGrpcProcessorConfig::default_gap_detection_batch_size(), | ||
parquet_gap_detection_batch_size: IndexerGrpcProcessorConfig::default_gap_detection_batch_size(), | ||
pb_channel_txn_chunk_size: IndexerGrpcProcessorConfig::default_pb_channel_txn_chunk_size(), | ||
per_table_chunk_sizes: AHashMap::new(), | ||
enable_verbose_logging: None, | ||
grpc_response_item_timeout_in_secs: IndexerGrpcProcessorConfig::default_grpc_response_item_timeout_in_secs(), | ||
transaction_filter: Default::default(), | ||
deprecated_tables: Default::default(), | ||
}; | ||
|
||
let num_cpus = num_cpus::get(); | ||
let worker_threads = (num_cpus * RUNTIME_WORKER_MULTIPLIER).max(16); | ||
println!( | ||
"[Processor] Starting processor tokio runtime: num_cpus={}, worker_threads={}", | ||
num_cpus, worker_threads | ||
); | ||
|
||
let mut builder = tokio::runtime::Builder::new_multi_thread(); | ||
builder | ||
.disable_lifo_slot() | ||
.enable_all() | ||
.worker_threads(worker_threads) | ||
.build() | ||
.unwrap() | ||
.block_on(async { | ||
config.run().await | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// seems like we could only run an instance of redis-server in a separate process, and then connect to it from the other services. | ||
// we might want to spin up a redis server then. | ||
// https://discourse.nixos.org/t/how-can-i-spawn-a-redis-instance-within-a-nix-build/5155 | ||
// For testing purposes we could use: | ||
// https://medium.com/@suyashkant.srivastava/this-post-aims-to-help-setting-up-a-minimal-redis-cluster-on-nix-environment-d607e3628e08 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,3 +75,28 @@ processes: | |
exec: | ||
command: curl http://0.0.0.0:30732 | ||
|
||
suzuka-indexer-processor: | ||
|
||
command : | | ||
#/bin/bash | ||
# todo: this fails with gRPC Unimplemented error on the RawData.GetTransactions call | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to test the |
||
RUST_LOG=debug suzuka-indexer-processor | ||
# for now, we will just prove the service is running with a grpcurl call | ||
# we will check the output | ||
RESPONSE=$(grpcurl -plaintext 0.0.0.0:30734 list aptos.indexer.v1.RawData) | ||
echho $RESPONSE | ||
EXPECTED="aptos.indexer.v1.RawData.GetTransactions" | ||
if [[ "$RESPONSE" == "$EXPECTED" ]]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
depends_on: | ||
suzuka-full-node: | ||
condition: process_healthy | ||
readiness_probe: | ||
initial_delay_seconds: 30 | ||
exec: | ||
command: echo "true" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,4 @@ | |
set -e | ||
|
||
# change symbolic link to be Cargo.$1.toml | ||
ln -sf Cargo.$1.toml Cargo.toml | ||
|
||
|
||
ln -sf Cargo.$1.toml Cargo.toml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be deleted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should update this to the latest rather than the commit on my branch.