Skip to content

Commit

Permalink
Remove healthcheck from fast indexer docker image, upgrade version wh…
Browse files Browse the repository at this point in the history
…ere necessary
  • Loading branch information
Fly-Style committed Nov 26, 2024
1 parent a0d7873 commit 8dfca70
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
16 changes: 8 additions & 8 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ eyre = "0.6"
futures-util = "0.3.30"
log = "0.4"
prometheus = "0.13"
reqwest = { version = "0.12.8", features = ["json"] }
reqwest = { version = "0.12.9", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
Expand Down
2 changes: 2 additions & 0 deletions docker-compose-fastnear.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ services:
- "2"
- --rollup-ids
- "3"
- --metrics-ip-port-address
- "0.0.0.0:9090"
networks:
- nffl

Expand Down
9 changes: 5 additions & 4 deletions indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ edition = "2021"
actix = "0.13.1"
actix-web = "4.5.1"
futures = "0.3.5"
tokio = { version = "1.28.2", features = ["sync", "time"] }
tokio = { version = "1", features = ["sync", "time"] }
deadpool = "0.10.0"
lapin = "2.3.1"
deadpool-lapin = "0.11.0"
tokio-executor-trait = "2.1.0"
tokio-reactor-trait = "1.1.0"
prometheus = "0.13.3"

clap = { version = "4.4.11", features = ["color", "derive", "env"] }
clap = { version = "4.5.21", features = ["color", "derive", "env"] }
openssl-probe = "0.1.4"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.68"

tracing = { version = "0.1.36", features = ["std"] }
thiserror = "1.0.56"
tracing = { version = "0.1.40", features = ["std"] }
thiserror = "1.0.69"
anyhow = "1.0.79"

near-indexer = { git = "https://github.com/near/nearcore", rev = "93073d762ff377382ebf54e7cbff448b492e72c6" }
Expand All @@ -33,6 +33,7 @@ near-config-utils = { git = "https://github.com/near/nearcore", rev = "93073d762
near-client-primitives = { git = "https://github.com/near/nearcore", rev = "93073d762ff377382ebf54e7cbff448b492e72c6" }
borsh = { version = "1.0.0", features = ["derive", "rc"] }
serde_yaml = "0.9.34"
#reqwest = {workspace = true}
reqwest = { version = "0.12.9", features = ["json"] }

[dev-dependencies]
Expand Down
18 changes: 9 additions & 9 deletions indexer/FastIndexer.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ RUN chmod +x ./entrypoint.sh

EXPOSE 3030

HEALTHCHECK --interval=20s --timeout=30s --retries=10000 \
CMD (curl -f -s -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"block","params":{"finality":"optimistic"},"id":"dontcare"}' \
http://localhost:3030 | \
jq -es 'if . == [] then null else .[] | (now - (.result.header.timestamp / 1000000000)) < 10 end') && \
(curl -f -s -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"status","params":[],"id":"dontcare"}' \
http://localhost:3030 | \
jq -es 'if . == [] then null else .[] | .result.sync_info.syncing == false end')
#HEALTHCHECK --interval=20s --timeout=30s --retries=10000 \
# CMD (curl -f -s -X POST -H "Content-Type: application/json" \
# -d '{"jsonrpc":"2.0","method":"block","params":{"finality":"optimistic"},"id":"dontcare"}' \
# http://localhost:3030 | \
# jq -es 'if . == [] then null else .[] | (now - (.result.header.timestamp / 1000000000)) < 10 end') && \
# (curl -f -s -X POST -H "Content-Type: application/json" \
# -d '{"jsonrpc":"2.0","method":"status","params":[],"id":"dontcare"}' \
# http://localhost:3030 | \
# jq -es 'if . == [] then null else .[] | .result.sync_info.syncing == false end')

ENTRYPOINT [ "./entrypoint.sh" ]
18 changes: 9 additions & 9 deletions indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ const INDEXER: &str = "indexer";

fn run(home_dir: std::path::PathBuf, config: RunConfigArgs) -> Result<()> {
let addresses_to_rollup_ids = config.compile_addresses_to_ids_map()?;
let indexer_config = near_indexer::IndexerConfig {
home_dir,
sync_mode: near_indexer::SyncModeEnum::LatestSynced,
await_for_node_synced: near_indexer::AwaitForNodeSyncedEnum::WaitForFullSync,
validate_genesis: true,
};

let system = actix::System::new();
let registry = Registry::new();
let server_handle = if let Some(metrics_addr) = config.metrics_ip_port_address {
Expand All @@ -42,14 +35,21 @@ fn run(home_dir: std::path::PathBuf, config: RunConfigArgs) -> Result<()> {
} else {
None
};
// TODO[sasha/firat]: refactor, added some logic to handle the case when fastnear is enabled.
// Needs tests and maybe refactoring for base case

// TODO[sasha/firat]: refactor and tests.
let block_res = system.block_on(async move {
let validated_stream: Receiver<PublishData>;
if cfg!(feature = "use_fastnear") {
let fastnear_indexer = FastNearIndexer::new(addresses_to_rollup_ids);
validated_stream = fastnear_indexer.run();
} else {
let indexer_config = near_indexer::IndexerConfig {
home_dir,
sync_mode: near_indexer::SyncModeEnum::LatestSynced,
await_for_node_synced: near_indexer::AwaitForNodeSyncedEnum::WaitForFullSync,
validate_genesis: true,
};

let mut indexer = IndexerWrapper::new(indexer_config, addresses_to_rollup_ids);
if config.metrics_ip_port_address.is_some() {
indexer.enable_metrics(registry.clone())?;
Expand Down
2 changes: 1 addition & 1 deletion indexer/test_data/config/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ download_config: false
# boot_nodes:

# Specify a custom max_gas_burnt_view limit.
# max_gas_burnt_view:
# max_gas_burnt_view:

0 comments on commit 8dfca70

Please sign in to comment.