Skip to content

Commit

Permalink
Merge branch 'develop' into tooling-wallet/rebrand-home-update-coin
Browse files Browse the repository at this point in the history
  • Loading branch information
evavirseda authored Aug 12, 2024
2 parents 8067950 + cf22566 commit 93c566c
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 10 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,17 @@ on:
workflow_dispatch:
push:
branches:
- main
- develop

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
version:
runs-on: self-hosted
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # pin@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: checkout code repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
token: ${{ steps.generate_token.outputs.token }}
fetch-depth: 0
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # [email protected]
- name: Install Nodejs
Expand All @@ -40,4 +32,4 @@ jobs:
# https://github.com/changesets/action#with-version-script
version: pnpm changeset-version
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions crates/iota-indexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Iota indexer is an off-fullnode service to serve data from Iota protocol, includ
> - Nodes expose the `NameServiceConfig` API, whereas indexer instances do not.
> - Indexer instance expose the `ExtendedApi`, but nodes do not.
## Database Schema

For more in depth information check the [Database Schema](./schema.md).

## Steps to run locally

### Prerequisites
Expand Down
4 changes: 4 additions & 0 deletions crates/iota-indexer/database_schema.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions crates/iota-indexer/schema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Database Schema

The Indexer pulls checkpoint data from the full node and populates the tables shown in the ERD diagram:

![Database Schema](./database_schema.svg)

> **NOTE**
>
> Since all tables are populated from checkpoint data the entities are closely related, in the `SQL` files the foreign keys are not specified, a manual study of data is needed to understand all relations.
>
> Migrations are generated by diesel cli, the basic schema can be found [schema.rs](src/schema.rs).
> For more in depth understanding of the database tables, go to [migrations](migrations) folder, in the contained `SQL` the indexes, partitions & constraints are declared.
>
> - Tables `objects_history` & `transactions` have partitions, each partition is created based on `checkpoint_sequence_number` (related form the `checkpoints` table) it goes from `0` to `MAXVALUE`
> - `__diesel_schema_migrations` table is managed by `diesel` cli when applying migrations
## Indexes

### Table `checkpoints`

| Index name | Keys |
| ------------------ | ---------------------- |
| checkpoints_epoch | epoch, sequence_number |
| checkpoints_digest | checkpoint_digest |

### Table `events`

| Index name | Keys |
| --------------------------------- | ----------------------------------------------------------------------- |
| events_package | package, tx_sequence_number, event_sequence_number |
| events_package_module | package, module, tx_sequence_number, event_sequence_number |
| events_event_type | event_type, text_pattern_ops, tx_sequence_number, event_sequence_number |
| events_checkpoint_sequence_number | checkpoint_sequence_number |

### Table `objects`

| Index name | Keys | Condition |
| ---------------------------------- | -------------------------- | --------------------------------------------------------- |
| objects_owner | owner_type, owner_id | WHERE owner_type BETWEEN 1 AND 2 AND owner_id IS NOT NULL |
| objects_coin | owner_id, coin_type | WHERE coin_type IS NOT NULL AND owner_type = 1 |
| objects_checkpoint_sequence_number | checkpoint_sequence_number | |
| objects_type | object_type | |

### Table `objects_snapshot`

| Index name | Keys | Condition |
| ------------------------------------------- | ------------------------------- | --------------------------------------------------------- |
| objects_snapshot_checkpoint_sequence_number | checkpoint_sequence_number | |
| objects_snapshot_coin | owner_id, coin_type, object_id | WHERE coin_type IS NOT NULL AND owner_type = 1 |
| objects_snapshot_type | object_type, object_id | |
| objects_snapshot_owner | owner_type, owner_id, object_id | WHERE owner_type BETWEEN 1 AND 2 AND owner_id IS NOT NULL |

### Table `objects_history`

| Index name | Keys | Condition |
| --------------------- | ------------------------------------------------ | --------------------------------------------------------- |
| objects_history_owner | checkpoint_sequence_number, owner_type, owner_id | WHERE owner_type BETWEEN 1 AND 2 AND owner_id IS NOT NULL |
| objects_history_coin | checkpoint_sequence_number, owner_id, coin_type | WHERE coin_type IS NOT NULL AND owner_type = 1 |
| objects_history_type | checkpoint_sequence_number, object_type | |

### Table `transactions`

| Index name | Keys | Condition |
| --------------------------------------- | -------------------------- | -------------------------- |
| transactions_transaction_digest | transaction_digest | |
| transactions_checkpoint_sequence_number | checkpoint_sequence_number | |
| transactions_transaction_kind | transaction_kind | WHERE transaction_kind = 1 |

### Table `tx_calls`

| Index name | Keys |
| --------------------------- | ----------------------------------------- |
| tx_calls_module | package, module, tx_sequence_number |
| tx_calls_func | package, module, func, tx_sequence_number |
| tx_calls_tx_sequence_number | tx_sequence_number |

### Table `tx_senders`

| Index name | Keys | Condition |
| ----------------------------------- | ------------------ | --------- |
| tx_senders_tx_sequence_number_index | tx_sequence_number | ASC |

### Tables `tx_recipients`

| Index name | Keys | Condition |
| -------------------------------------- | ------------------ | --------- |
| tx_recipients_tx_sequence_number_index | tx_sequence_number | ASC |

## Partitions

### Tables `transactions`, `objects_history`

| Keys | Condition |
| :------------------------: | :-------------------------------: |
| checkpoint_sequence_number | FOR VALUES FROM (0) TO (MAXVALUE) |
6 changes: 6 additions & 0 deletions crates/iota-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6273,6 +6273,7 @@
"type": "object",
"required": [
"epochCommitments",
"epochSupplyChange",
"nextEpochCommittee",
"nextEpochProtocolVersion"
],
Expand All @@ -6284,6 +6285,11 @@
"$ref": "#/components/schemas/CheckpointCommitment"
}
},
"epochSupplyChange": {
"description": "The number of tokens that were minted (if positive) or burnt (if negative) in this epoch.",
"type": "integer",
"format": "int64"
},
"nextEpochCommittee": {
"description": "next_epoch_committee is `Some` if and only if the current checkpoint is the last checkpoint of an epoch. Therefore next_epoch_committee can be used to pick the last checkpoint of an epoch, which is often useful to get epoch level summary stats like total gas cost of an epoch, or the total number of transactions from genesis to the end of an epoch. The committee is stored as a vector of validator pub key and stake pairs. The vector should be sorted based on the Committee data structure.",
"type": "array",
Expand Down
1 change: 1 addition & 0 deletions sdk/graphql-transport/src/mappers/checkpint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function mapGraphQLCheckpointToRpcCheckpoint(
nextEpochProtocolVersion: String(
endOfEpochTx.kind.transactions.nodes[0].epoch?.protocolConfigs.protocolVersion,
),
epochSupplyChange: 0, // TODO: https://github.com/iotaledger/iota/issues/1738
};
}

Expand Down
2 changes: 2 additions & 0 deletions sdk/typescript/src/client/types/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ export interface ECMHLiveObjectSetDigest {
export interface EndOfEpochData {
/** Commitments to epoch specific state (e.g. live object set) */
epochCommitments: CheckpointCommitment[];
/** The number of tokens that were minted (if positive) or burnt (if negative) in this epoch. */
epochSupplyChange: number;
/**
* next_epoch_committee is `Some` if and only if the current checkpoint is the last checkpoint of an
* epoch. Therefore next_epoch_committee can be used to pick the last checkpoint of an epoch, which is
Expand Down

0 comments on commit 93c566c

Please sign in to comment.