From 6e15341a66285e074e39aadc8279ad39aeb83515 Mon Sep 17 00:00:00 2001 From: Sergiu Popescu <44298302+sergiupopescu199@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:37:23 +0200 Subject: [PATCH] refactor(iota-indexer): add new tables to db schema (#1975) Co-authored-by: Thibault Martinez --- crates/iota-indexer/database_schema.svg | 2 +- crates/iota-indexer/schema.md | 29 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/crates/iota-indexer/database_schema.svg b/crates/iota-indexer/database_schema.svg index 8f5adc652f0..86997161b05 100644 --- a/crates/iota-indexer/database_schema.svg +++ b/crates/iota-indexer/database_schema.svg @@ -1,4 +1,4 @@ -
display
PK
object_type text NN
bcs      bytea NN
id      bytea NN
version         int2 NN
objects
PK
object_id  bytea NN
checkpoint_sequence_number ref(checkpoints)    int8 NN
coin_balance                    int8
coint_type             text
df_kind            int2
df_name             bytea
df_object_id             bytea
df_object_type                  text
object_digest                 bytea NN
object_type            text
object_version                 in8 NN
owner_id             bytea
owner_type              int2 NN
serialized_object            bytea NN
objects_snapshot
PK
object_id  ref(objects_history) bytea NN
checkpoint_sequence_number   int8 NN
coin_balance                          int8
coint_type          text
df_kind              int2
df_name           bytea
df_object_id           bytea
df_object_type              text
object_digest                       bytea
object_status             int2 NN
object_type       text
object_version                     in8 NN
owner_id               bytea
owner_type                      int2
serialized_object                          bytea
objects_history
PK
checkpoint_sequence_number ref(checkpoints) int8 NN
PK
object_id  ref(objects) bytea NN
PK
object_version  int8 NN
coin_balance                                               int8
coint_type            text
df_kind           int2
df_name   bytea
df_object_id   bytea
df_object_type      text
object_digest                bytea
object_status           int2 NN
object_type      text
owner_id    bytea
owner_type                   int2
serialized_object                 bytea
epochs
PK
epoch  int8 NN
burn_leftover_amount             int8
burn_tokens_amount              int8
epoch_commitments      bytea
epoch_end_timestamp             int8
epoch_start_timestamp int8 NN
epoch_total_transactions             int8
first_checkpoint_id ref(checkpoints) int8 NN
last_checkpoint_id ref(checkpoints)            int8
minted_tokens_amount             int8
protocol_version                 int8 NN
reference_gas_price int8 NN
stake_subsidy_amount             int8
storage_charge             int8
storage_fund_balance int8 NN
storage_rebate             int8
system_state          bytea NN
total_gas_fees             int8
total_stake int8 NN
total_stake_reward_distributed            int8
checkpoints
PK
sequence_number  int8 NN
checkpoint_digest           bytea NN
epoch      int8 NN
network_total_transactions     int8 NN
previous_checkpoint_digest    bytea
end_of_epoch        bool NN
end_of_epoch_data    bytea
tx_digests    bytea[] NN
timestamp_ms                        int8 NN
total_gas_cost                        int8 NN
computation_cost                   int8 NN
storage_cost                           int8 NN
storage_rebate                       int8 NN
non_refundable_storage_fee int8 NN
checkpoint_commitments    bytea NN
validator_signature              bytea NN
end_of_epoch_data                   bytea
transactions
PK
checkpoint_sequence_number     ref(checkpoints) int8 NN
PK
tx_sequence_number int8 NN
balance_changes                         bytea[] NN
events                                           bytea[] NN
object_changes                                 bytea[] NN
raw_effects                                             bytea NN
raw_transaction                                   bytea NN
success_command_count                    int2 NN
timestamp_ms    ref(checkpoints)                                   int8 NN
transaction_digest    ref(checkpoints)                          bytea NN
transaction_kind                                    int2 NN
events
PK
event_ sequence_number int8 NN
PK
tx_sequence_number    ref(transactions) int8 NN
bcs                        bytea NN
checkpoint_sequence_number    ref(checkpoints) int8 NN
event_type         text NN
module text NN
package            bytea NN
senders                bytea[] NN
timestamp_ms    ref(checkpoints)                            int8 NN
transaction_digest    ref(transactions)                         bytea NN
tx_senders
PK
sender bytea NN
PK
tx_sequence_number    ref(transactions).    int8 NN
tx_recipients
PK
recipient bytea NN
PK
tx_sequence_number    ref(transactions).   int8 NN
tx_calls
PK
package    ref(packages)     bytea NN
PK
tx_sequence_number    ref(transactions)   int8 NN
bcs        bytea NN
id      bytea NN
version             int2 NN
tx_input_objects
PK
object_id bytea NN
PK
tx_sequence_number     ref(transactions)    int8 NN
tx_changed_objects
PK
object_id bytea NN
PK
tx_sequence_number     ref(transactions)  int8 NN
packages
PK
package_id bytea NN
move_package bytea NN
__diesel_schema_migrations
PK
version varchar(50) NN
run_on                       timestamp NN
Legend
Database schema
ref(< table-name >)    Possible Foreign Key link
\ No newline at end of file +
display
PK
object_type text NN
bcs      bytea NN
id      bytea NN
version         int2 NN
objects
PK
object_id  bytea NN
checkpoint_sequence_number ref(checkpoints)    int8 NN
coin_balance                    int8
coint_type             text
df_kind            int2
df_name             bytea
df_object_id             bytea
df_object_type                  text
object_digest                 bytea NN
object_type            text
object_version                 in8 NN
owner_id             bytea
owner_type              int2 NN
serialized_object            bytea NN
objects_snapshot
PK
object_id  ref(objects_history) bytea NN
checkpoint_sequence_number   int8 NN
coin_balance                          int8
coint_type          text
df_kind              int2
df_name           bytea
df_object_id           bytea
df_object_type              text
object_digest                       bytea
object_status             int2 NN
object_type       text
object_version                     in8 NN
owner_id               bytea
owner_type                      int2
serialized_object                          bytea
objects_history
PK
checkpoint_sequence_number ref(checkpoints) int8 NN
PK
object_id  ref(objects) bytea NN
PK
object_version  int8 NN
coin_balance                                               int8
coint_type            text
df_kind           int2
df_name   bytea
df_object_id   bytea
df_object_type      text
object_digest                bytea
object_status           int2 NN
object_type      text
owner_id    bytea
owner_type                   int2
serialized_object                 bytea
epochs
PK
epoch  int8 NN
burn_leftover_amount             int8
burn_tokens_amount              int8
epoch_commitments      bytea
epoch_end_timestamp             int8
epoch_start_timestamp int8 NN
epoch_total_transactions             int8
first_checkpoint_id ref(checkpoints) int8 NN
last_checkpoint_id ref(checkpoints)            int8
minted_tokens_amount             int8
protocol_version                 int8 NN
reference_gas_price int8 NN
stake_subsidy_amount             int8
storage_charge             int8
storage_fund_balance int8 NN
storage_rebate             int8
system_state          bytea NN
total_gas_fees             int8
total_stake int8 NN
total_stake_reward_distributed            int8
checkpoints
PK
sequence_number  int8 NN
checkpoint_digest           bytea NN
epoch      int8 NN
network_total_transactions     int8 NN
previous_checkpoint_digest    bytea
end_of_epoch        bool NN
end_of_epoch_data    bytea
tx_digests    bytea[] NN
timestamp_ms                        int8 NN
total_gas_cost                        int8 NN
computation_cost                   int8 NN
storage_cost                           int8 NN
storage_rebate                       int8 NN
non_refundable_storage_fee int8 NN
checkpoint_commitments    bytea NN
validator_signature              bytea NN
end_of_epoch_data                   bytea
transactions
PK
checkpoint_sequence_number     ref(checkpoints) int8 NN
PK
tx_sequence_number int8 NN
balance_changes                         bytea[] NN
events                                           bytea[] NN
object_changes                                 bytea[] NN
raw_effects                                             bytea NN
raw_transaction                                   bytea NN
success_command_count                    int2 NN
timestamp_ms    ref(checkpoints)                                   int8 NN
transaction_digest    ref(checkpoints)                          bytea NN
transaction_kind                                    int2 NN
events
PK
event_ sequence_number int8 NN
PK
tx_sequence_number    ref(transactions) int8 NN
bcs                        bytea NN
checkpoint_sequence_number    ref(checkpoints) int8 NN
event_type         text NN
module text NN
package            bytea NN
senders                bytea[] NN
timestamp_ms    ref(checkpoints)                            int8 NN
transaction_digest    ref(transactions)                         bytea NN
tx_senders
PK
sender bytea NN
PK
tx_sequence_number    ref(transactions).    int8 NN
tx_recipients
PK
recipient bytea NN
PK
tx_sequence_number    ref(transactions).   int8 NN
tx_calls
PK
package    ref(packages)     bytea NN
PK
tx_sequence_number    ref(transactions)   int8 NN
bcs        bytea NN
id      bytea NN
version             int2 NN
tx_input_objects
PK
object_id bytea NN
PK
tx_sequence_number     ref(transactions)    int8 NN
tx_changed_objects
PK
object_id bytea NN
PK
tx_sequence_number     ref(transactions)  int8 NN
packages
PK
package_id bytea NN
move_package bytea NN
__diesel_schema_migrations
PK
version varchar(50) NN
run_on                       timestamp NN
Legend
Database schema
ref(< table-name >)    Possible Foreign Key link
tx_count_metrics
PK
checkpoint_sequence_number  ref(checkpoints) int8 NN
epoch ref(epochs) int8 NN
timestamp_ms       int8 NN
total_transaction_blocks       int8 NN
total_successful_transaction_blocks                    int8 NN
total_successful_transactions       int8 NN
move_calls
PK
transactions_sequence_number ref(transactions) int8 NN
PK
move_package     bytea NN
PK
move_module text NN
PK
move_function text NN
checkpoint_sequence_number ref(checkpoints) int8 NN
epoch ref(epochs) int8 NN
move_call_metrics
PK
id  bigserial NN
count  int8 NN
day   int8 NN
epoch ref(epochs)   int8 NN
move_function text NN
move_module text NN
move_package text NN
addresses
PK
address bytea NN
first_appearance_time   int8 NN
first_appearance_tx    int8 NN
last_appearance_time    int8 NN
last_appearance_tx int8 NN
active_addresses
PK
address bytea NN
first_appearance_time   int8 NN
first_appearance_tx    int8 NN
last_appearance_time    int8 NN
last_appearance_tx int8 NN
address_metrics
PK
checkpoint ref(checkpoints) int8 NN
cumulative_active_addresses   int8 NN
cumulative_addresses     int8 NN
daily_active_addresses     int8 NN
epoch ref(epochs) int8 NN
timestamp_ms int8 NN
epoch_peak_tps
PK
epoch ref(epochs) int8 NN
peak_tps          float8 NN
peak_tps_30d              float8 NN
\ No newline at end of file diff --git a/crates/iota-indexer/schema.md b/crates/iota-indexer/schema.md index 2dad7161ac9..39b99baf6b2 100644 --- a/crates/iota-indexer/schema.md +++ b/crates/iota-indexer/schema.md @@ -86,10 +86,35 @@ The Indexer pulls checkpoint data from the full node and populates the tables sh | -------------------------------------- | ------------------ | --------- | | tx_recipients_tx_sequence_number_index | tx_sequence_number | ASC | +### Table `tx_count_metrics` + +| Index name | Keys | +| ----------------------------- | ------------ | +| tx_count_metrics_epoch | epoch | +| tx_count_metrics_timestamp_ms | timestamp_ms | + +### Table `move_calls` + +| Index name | Keys | +| ------------------------ | ----------------------------------------------- | +| idx_move_calls_epoch_etc | epoch, move_package, move_module, move_function | + +### Table `move_call_metrics` + +| Index name | Keys | +| --------------------------- | ---------- | +| move_call_metrics_epoch_day | epoch, day | + +### Table `address_metrics` + +| Index name | Keys | +| ------------------------- | ----- | +| address_metrics_epoch_idx | epoch | + ## Partitions ### Tables `transactions`, `objects_history` -| Keys | Condition | -| :------------------------: | :-------------------------------: | +| Keys | Condition | +| -------------------------- | --------------------------------- | | checkpoint_sequence_number | FOR VALUES FROM (0) TO (MAXVALUE) |