Skip to content

Commit

Permalink
Indexer pipeline (#13075)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
longbowlu authored Jul 25, 2023
1 parent f08be7a commit 4754648
Show file tree
Hide file tree
Showing 8 changed files with 586 additions and 521 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/sui-indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ backoff.workspace = true
bcs.workspace = true
chrono.workspace = true
clap.workspace = true
tap.workspace = true
diesel.workspace = true
diesel-derive-enum.workspace = true
futures.workspace = true
Expand Down
38 changes: 1 addition & 37 deletions crates/sui-indexer/benches/indexer_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ use tokio::runtime::Runtime;

use sui_indexer::metrics::IndexerMetrics;
use sui_indexer::models::checkpoints::Checkpoint;
use sui_indexer::models::objects::{NamedBcsBytes, Object as DBObject, ObjectStatus};
use sui_indexer::models::owners::OwnerType;
use sui_indexer::models::transactions::Transaction;
use sui_indexer::new_pg_connection_pool;
use sui_indexer::store::{
IndexerStore, PgIndexerStore, TemporaryCheckpointStore, TransactionObjectChanges,
};
use sui_indexer::store::{IndexerStore, PgIndexerStore, TemporaryCheckpointStore};
use sui_indexer::utils::reset_database;
use sui_json_rpc_types::CheckpointId;
use sui_types::base_types::{ObjectDigest, ObjectID, SequenceNumber, SuiAddress};
use sui_types::crypto::AggregateAuthoritySignature;
use sui_types::digests::TransactionDigest;
use sui_types::gas_coin::GasCoin;
use sui_types::messages_checkpoint::CheckpointDigest;
use sui_types::object::Object;
use sui_types::transaction::{TransactionData, TEST_ONLY_GAS_UNIT_FOR_TRANSFER};

fn indexer_benchmark(c: &mut Criterion) {
Expand Down Expand Up @@ -83,10 +77,6 @@ fn create_checkpoint(sequence_number: i64) -> TemporaryCheckpointStore {
.map(|_| create_transaction(sequence_number))
.collect(),
events: vec![],
object_changes: vec![TransactionObjectChanges {
changed_objects: (1..1000).map(|_| create_object(sequence_number)).collect(),
deleted_objects: vec![],
}],
packages: vec![],
input_objects: vec![],
changed_objects: vec![],
Expand Down Expand Up @@ -137,32 +127,6 @@ fn create_transaction(sequence_number: i64) -> Transaction {
}
}

fn create_object(sequence_number: i64) -> DBObject {
DBObject {
epoch: 0,
checkpoint: sequence_number,
object_id: ObjectID::random().to_string(),
version: 0,
object_digest: ObjectDigest::random().to_string(),
owner_type: OwnerType::AddressOwner,
owner_address: Some(SuiAddress::random_for_testing_only().to_string()),
initial_shared_version: None,
previous_transaction: TransactionDigest::random().base58_encode(),
object_type: GasCoin::type_().to_string(),
object_status: ObjectStatus::Created,
has_public_transfer: true,
storage_rebate: 0,
bcs: vec![NamedBcsBytes(
"data".to_string(),
Object::new_gas_for_testing()
.data
.try_as_move()
.unwrap()
.contents()
.to_vec(),
)],
}
}
criterion_group! {
name = benches;
config = Criterion::default().sample_size(50).measurement_time(Duration::from_secs(10));
Expand Down
16 changes: 16 additions & 0 deletions crates/sui-indexer/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ use thiserror::Error;
use sui_types::base_types::ObjectIDParseError;
use sui_types::error::{SuiError, SuiObjectResponseError, UserInputError};

#[derive(Debug, Error)]
pub struct DataDownloadError {
pub error: IndexerError,
pub next_checkpoint_sequence_number: u64,
}

impl std::fmt::Display for DataDownloadError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"next_checkpoint_seq: {}, error: {}",
self.next_checkpoint_sequence_number, self.error
)
}
}

#[derive(Debug, Error)]
pub enum IndexerError {
#[error("Indexer failed to convert timestamp to NaiveDateTime with error: `{0}`")]
Expand Down
Loading

2 comments on commit 4754648

@vercel
Copy link

@vercel vercel bot commented on 4754648 Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sui-typescript-docs – ./sdk/docs

sui-typescript-docs.vercel.app
sui-typescript-docs-mysten-labs.vercel.app
sui-typescript-docs-git-main-mysten-labs.vercel.app

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 Validators 500/s Owned Transactions Benchmark Results

Benchmark Report:
+-------------+-----+-----+--------+---------------+---------------+---------------+-----------------------+----------------------------+
| duration(s) | tps | cps | error% | latency (min) | latency (p50) | latency (p99) | gas used (MIST total) | gas used/hr (MIST approx.) |
+=======================================================================================================================================+
| 60          | 586 | 586 | 0      | 18            | 8367          | 9135          | 458,205,792,000       | 27,492,347,520,000         |
Stress Performance Report:
+-----------+-----+-----+
| metric    | p50 | p99 |
+=======================+
| cpu usage | 12  | 100 |

4 Validators 500/s Shared Transactions Benchmark Results

Benchmark Report:
+-------------+-----+-----+--------+---------------+---------------+---------------+-----------------------+----------------------------+
| duration(s) | tps | cps | error% | latency (min) | latency (p50) | latency (p99) | gas used (MIST total) | gas used/hr (MIST approx.) |
+=======================================================================================================================================+
| 60          | 476 | 476 | 0      | 20            | 9519          | 13895         | 426,082,296,000       | 25,564,937,760,000         |
Stress Performance Report:
+-----------+-----+-----+
| metric    | p50 | p99 |
+=======================+
| cpu usage | 11  | 100 |

20 Validators 50/s Owned Transactions Benchmark Results

Benchmark Report:
+-------------+-----+-----+--------+---------------+---------------+---------------+-----------------------+----------------------------+
| duration(s) | tps | cps | error% | latency (min) | latency (p50) | latency (p99) | gas used (MIST total) | gas used/hr (MIST approx.) |
+=======================================================================================================================================+
| 60          | 200 | 200 | 0      | 21            | 65            | 91            | 144,990,720,000       | 8,699,443,200,000          |
Stress Performance Report:
+-----------+-----+-----+
| metric    | p50 | p99 |
+=======================+
| cpu usage | 26  | 52  |

20 Validators 50/s Shared Transactions Benchmark Results

Benchmark Report:
+-------------+-----+-----+--------+---------------+---------------+---------------+-----------------------+----------------------------+
| duration(s) | tps | cps | error% | latency (min) | latency (p50) | latency (p99) | gas used (MIST total) | gas used/hr (MIST approx.) |
+=======================================================================================================================================+
| 60          | 193 | 193 | 0      | 65            | 1446          | 2253          | 161,635,368,000       | 9,698,122,080,000          |
Stress Performance Report:
+-----------+-----+-----+
| metric    | p50 | p99 |
+=======================+
| cpu usage | 25  | 58  |

Narwhal Benchmark Results

 SUMMARY:
-----------------------------------------
 + CONFIG:
 Faults: 0 node(s)
 Committee size: 4 node(s)
 Worker(s) per node: 1 worker(s)
 Collocate primary and workers: True
 Input rate: 50,000 tx/s
 Transaction size: 512 B
 Execution time: 0 s

 Header number of batches threshold: 32 digests
 Header maximum number of batches: 1,000 digests
 Max header delay: 2,000 ms
 GC depth: 50 round(s)
 Sync retry delay: 10,000 ms
 Sync retry nodes: 3 node(s)
 batch size: 500,000 B
 Max batch delay: 200 ms
 Max concurrent requests: 500,000 

 + RESULTS:
 Batch creation avg latency: 201 ms
 Header creation avg latency: -1 ms
 	Batch to header avg latency: -1 ms
 Header to certificate avg latency: 1 ms
 	Request vote outbound avg latency: 0 ms
 Certificate commit avg latency: 731 ms

 Consensus TPS: 0 tx/s
 Consensus BPS: 0 B/s
 Consensus latency: 0 ms

 End-to-end TPS: 0 tx/s
 End-to-end BPS: 0 B/s
 End-to-end latency: 0 ms
-----------------------------------------

Please sign in to comment.