Skip to content

Commit

Permalink
renames and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
wlmyng committed Oct 30, 2024
1 parent d11b7a5 commit 54c6cee
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 38 deletions.
77 changes: 77 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ members = [
"crates/sui-move",
"crates/sui-move-build",
"crates/sui-move-lsp",
"crates/sui-mvr-indexer",
"crates/sui-network",
"crates/sui-node",
"crates/sui-open-rpc",
Expand Down Expand Up @@ -649,6 +650,7 @@ sui-metric-checker = { path = "crates/sui-metric-checker" }
sui-move = { path = "crates/sui-move" }
sui-move-build = { path = "crates/sui-move-build" }
sui-move-lsp = { path = "crates/sui-move-lsp" }
sui-mvr-indexer = { path = "crates/sui-mvr-indexer" }
sui-network = { path = "crates/sui-network" }
sui-node = { path = "crates/sui-node" }
sui-open-rpc = { path = "crates/sui-open-rpc" }
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-mvr-indexer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "mvr-indexer"
name = "sui-mvr-indexer"
version.workspace = true
authors = ["Mysten Labs <[email protected]>"]
license = "Apache-2.0"
Expand Down Expand Up @@ -85,5 +85,5 @@ ntest.workspace = true
criterion.workspace = true

[[bin]]
name = "mvr-indexer"
name = "sui-mvr-indexer"
path = "src/main.rs"
4 changes: 2 additions & 2 deletions crates/sui-mvr-indexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ brew services start postgresql@version
## DB reset
When making db-related changes, you may find yourself having to run migrations and reset dbs often. The commands below are how you can invoke these actions.
```sh
cargo run --bin mvr-indexer -- --database-url "<DATABASE_URL>" reset-database --force
cargo run --bin sui-mvr-indexer -- --database-url "<DATABASE_URL>" reset-database --force
```

## Start the indexer
```SH
cargo run --bin mvr-indexer -- --db-url "<DATABASE_URL>" indexer --rpc-client-url "https://fullnode.devnet.sui.io:443" --remote-store-url http://lax-suifn-t99eb.devnet.sui.io:9000/rest
cargo run --bin sui-mvr-indexer -- --db-url "<DATABASE_URL>" indexer --rpc-client-url "https://fullnode.devnet.sui.io:443" --remote-store-url http://lax-suifn-t99eb.devnet.sui.io:9000/rest
```

## Migrations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Mysten Labs, Inc.
# SPDX-License-Identifier: Apache-2.0

INDEXER=${INDEXER:-"mvr-indexer"}
INDEXER=${INDEXER:-"sui-mvr-indexer"}
DB=${DB:-"postgres://postgres:postgrespw@localhost:5432/postgres"}
"$INDEXER" --database-url "$DB" run-back-fill "$1" "$2" sql "UPDATE events SET sender = CASE WHEN cardinality(senders) > 0 THEN senders[1] ELSE NULL END" checkpoint_sequence_number
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Mysten Labs, Inc.
# SPDX-License-Identifier: Apache-2.0

INDEXER=${INDEXER:-"mvr-indexer"}
INDEXER=${INDEXER:-"sui-mvr-indexer"}
DB=${DB:-"postgres://postgres:postgrespw@localhost:5432/postgres"}
"$INDEXER" --database-url "$DB" run-back-fill "$1" "$2" sql "INSERT INTO full_objects_history (object_id, object_version, serialized_object) SELECT object_id, object_version, serialized_object FROM objects_history" checkpoint_sequence_number
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Mysten Labs, Inc.
# SPDX-License-Identifier: Apache-2.0

INDEXER=${INDEXER:-"mvr-indexer"}
INDEXER=${INDEXER:-"sui-mvr-indexer"}
DB=${DB:-"postgres://postgres:postgrespw@localhost:5432/postgres"}
"$INDEXER" --database-url "$DB" run-back-fill "$1" "$2" sql "INSERT INTO tx_affected_addresses SELECT tx_sequence_number, sender AS affected, sender FROM tx_senders" tx_sequence_number
"$INDEXER" --database-url "$DB" run-back-fill "$1" "$2" sql "INSERT INTO tx_affected_addresses SELECT tx_sequence_number, recipient AS affected, sender FROM tx_recipients" tx_sequence_number
22 changes: 11 additions & 11 deletions crates/sui-mvr-indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
// SPDX-License-Identifier: Apache-2.0

use clap::Parser;
use sui_indexer::backfill::backfill_runner::BackfillRunner;
use sui_indexer::benchmark::run_indexer_benchmark;
use sui_indexer::config::{Command, UploadOptions};
use sui_indexer::database::ConnectionPool;
use sui_indexer::db::setup_postgres::clear_database;
use sui_indexer::db::{
use sui_mvr_indexer::backfill::backfill_runner::BackfillRunner;
use sui_mvr_indexer::benchmark::run_indexer_benchmark;
use sui_mvr_indexer::config::{Command, UploadOptions};
use sui_mvr_indexer::database::ConnectionPool;
use sui_mvr_indexer::db::setup_postgres::clear_database;
use sui_mvr_indexer::db::{
check_db_migration_consistency, check_prunable_tables_valid, reset_database, run_migrations,
};
use sui_indexer::indexer::Indexer;
use sui_indexer::metrics::{
use sui_mvr_indexer::indexer::Indexer;
use sui_mvr_indexer::metrics::{
spawn_connection_pool_metric_collector, start_prometheus_server, IndexerMetrics,
};
use sui_indexer::restorer::formal_snapshot::IndexerFormalSnapshotRestorer;
use sui_indexer::store::PgIndexerStore;
use sui_mvr_indexer::restorer::formal_snapshot::IndexerFormalSnapshotRestorer;
use sui_mvr_indexer::store::PgIndexerStore;
use tokio_util::sync::CancellationToken;
use tracing::warn;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let opts = sui_indexer::config::IndexerConfig::parse();
let opts = sui_mvr_indexer::config::IndexerConfig::parse();

// NOTE: this is to print out tracing like info, warn & error.
let _guard = telemetry_subscribers::TelemetryConfig::new()
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-mvr-indexer/src/schema.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff --git a/crates/mvr-indexer/src/schema.rs b/crates/mvr-indexer/src/schema.rs
--- a/crates/mvr-indexer/src/schema.rs
+++ b/crates/mvr-indexer/src/schema.rs
diff --git a/crates/sui-mvr-indexer/src/schema.rs b/crates/sui-mvr-indexer/src/schema.rs
--- a/crates/sui-mvr-indexer/src/schema.rs
+++ b/crates/sui-mvr-indexer/src/schema.rs
@@ -1 +1,3 @@
+// Copyright (c) Mysten Labs, Inc.
+// SPDX-License-Identifier: Apache-2.0
Expand Down
20 changes: 10 additions & 10 deletions crates/sui-mvr-indexer/tests/ingestion_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ use diesel::ExpressionMethods;
use diesel::QueryDsl;
use diesel_async::RunQueryDsl;
use simulacrum::Simulacrum;
use sui_indexer::errors::IndexerError;
use sui_indexer::handlers::TransactionObjectChangesToCommit;
use sui_indexer::models::{
use sui_mvr_indexer::errors::IndexerError;
use sui_mvr_indexer::handlers::TransactionObjectChangesToCommit;
use sui_mvr_indexer::models::{
checkpoints::StoredCheckpoint, objects::StoredObject, objects::StoredObjectSnapshot,
transactions::StoredTransaction,
};
use sui_indexer::schema::{checkpoints, objects, objects_snapshot, transactions};
use sui_indexer::store::indexer_store::IndexerStore;
use sui_indexer::test_utils::{
use sui_mvr_indexer::schema::{checkpoints, objects, objects_snapshot, transactions};
use sui_mvr_indexer::store::indexer_store::IndexerStore;
use sui_mvr_indexer::test_utils::{
set_up, set_up_with_start_and_end_checkpoints, wait_for_checkpoint, wait_for_objects_snapshot,
};
use sui_indexer::types::EventIndex;
use sui_indexer::types::IndexedDeletedObject;
use sui_indexer::types::IndexedObject;
use sui_indexer::types::TxIndex;
use sui_mvr_indexer::types::EventIndex;
use sui_mvr_indexer::types::IndexedDeletedObject;
use sui_mvr_indexer::types::IndexedObject;
use sui_mvr_indexer::types::TxIndex;
use sui_types::base_types::SuiAddress;
use sui_types::effects::TransactionEffectsAPI;
use sui_types::gas_coin::GasCoin;
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-mvr-indexer/tests/read_api_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
use jsonrpsee::core::RpcResult;
use simulacrum::Simulacrum;
use std::sync::Arc;
use sui_indexer::apis::read_api::ReadApi;
use sui_indexer::indexer_reader::IndexerReader;
use sui_indexer::test_utils::{set_up, wait_for_checkpoint};
use sui_json_rpc_api::ReadApiServer;
use sui_mvr_indexer::apis::read_api::ReadApi;
use sui_mvr_indexer::indexer_reader::IndexerReader;
use sui_mvr_indexer::test_utils::{set_up, wait_for_checkpoint};
use tempfile::tempdir;

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG GIT_REVISION
ENV GIT_REVISION=$GIT_REVISION
WORKDIR "$WORKDIR/sui"

# mvr-indexer needs postgres libpq5 and ca-certificates
# sui-mvr-indexer needs postgres libpq5 and ca-certificates
RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql

RUN apt-get update && apt-get install -y cmake clang
Expand All @@ -20,15 +20,15 @@ COPY sui-execution sui-execution
COPY narwhal narwhal
COPY external-crates external-crates

RUN cargo build --profile ${PROFILE} --bin mvr-indexer
RUN cargo build --profile ${PROFILE} --bin sui-mvr-indexer

# Production Image
FROM debian:bullseye-slim AS runtime
# Use jemalloc as memory allocator
RUN apt-get update && apt-get install -y libjemalloc-dev ca-certificates curl
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so
WORKDIR "$WORKDIR/sui"
COPY --from=builder /sui/target/release/mvr-indexer /usr/local/bin
COPY --from=builder /sui/target/release/sui-mvr-indexer /usr/local/bin
RUN apt update && apt install -y libpq5 ca-certificates libpq-dev postgresql

ARG BUILD_DATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GIT_REVISION="$(git describe --always --abbrev=12 --dirty --exclude '*')"
BUILD_DATE="$(date -u +'%Y-%m-%d')"

echo
echo "Building mvr-indexer docker image"
echo "Building sui-mvr-indexer docker image"
echo "Dockerfile: \t$DOCKERFILE"
echo "docker context: $REPO_ROOT"
echo "build date: \t$BUILD_DATE"
Expand Down

0 comments on commit 54c6cee

Please sign in to comment.