-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,38 @@ | ||
Hubble is an omnichain indexer. | ||
# Overview | ||
|
||
> **Warning** | ||
> This is not ready for public usage. It can index tendermint chains, but the schema is not public yet. | ||
Hubble spawns multiple indexers inside [tokio](https://tokio.rs/) tasks. Each indexer is configured through a JSON config passed through the CLI: | ||
|
||
``` | ||
--indexers '[{"type": "tendermint", "url": "http://localhost:26657"}]' | ||
``` | ||
|
||
Each indexer inserts data into a Postgres DB. The migrations are included in the `hasura` directory. | ||
|
||
```mermaid | ||
erDiagram | ||
Hubble ||--|{ Hasura : posts | ||
Hasura ||--|{ Timescale : stores | ||
User ||--|{ Hasura : queries | ||
``` | ||
|
||
## Database Schema | ||
|
||
Hubble is unopinionated regarding database schema. It has three conceptual models, chains, blocks, and events. Events are stored as JSONB, which means that further destructuring and aggregation occurs inside the DB itself. For this, we recommend [Timescale](https://github.com/timescale/timescaledb). | ||
|
||
As an example, Tendermint's `coin_received` event can be destructured like so: | ||
|
||
```sql | ||
CREATE OR REPLACE VIEW "v0"."coin_receiveds" AS | ||
SELECT events.block_id, | ||
events.index, | ||
events."time", | ||
(((events.data -> 'attributes'::text) -> 0) ->> 'value'::text) AS receiver, | ||
("substring"((((events.data -> 'attributes'::text) -> 1) ->> 'value'::text), '^\d+'::text))::numeric AS amount, | ||
"substring"((((events.data -> 'attributes'::text) -> 1) ->> 'value'::text), '[a-zA-Z].*'::text) AS denom | ||
FROM v0.events | ||
WHERE ((events.data ->> 'type'::text) = 'coin_received'::text); | ||
``` | ||
|
||
DBAs should choose between using views or materialized views. | ||
|
||
Data can be aggregated using time_buckets, and subsequently summed into totals, i.e. aggregate transfers into 1h buckets, and then sum over these buckets to obtain the current balances. Use [real-time aggregates](https://docs.timescale.com/use-timescale/latest/continuous-aggregates/real-time-aggregates/) for this. |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: faucet_claims | ||
schema: demo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: queue | ||
schema: demo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: txes | ||
schema: demo |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,3 @@ | ||
table: | ||
name: blocks | ||
schema: public | ||
object_relationships: | ||
- name: chain | ||
using: | ||
foreign_key_constraint_on: chain_id | ||
array_relationships: | ||
- name: events | ||
using: | ||
foreign_key_constraint_on: | ||
column: block_id | ||
table: | ||
name: events | ||
schema: public | ||
select_permissions: | ||
- role: user | ||
permission: | ||
columns: | ||
- is_finalized | ||
- chain_id | ||
- height | ||
- id | ||
- hash | ||
filter: {} | ||
limit: 50 | ||
allow_aggregations: true | ||
comment: "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
table: | ||
name: chains | ||
schema: public | ||
array_relationships: | ||
- name: blocks | ||
using: | ||
foreign_key_constraint_on: | ||
column: chain_id | ||
table: | ||
name: blocks | ||
schema: public |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
table: | ||
name: events | ||
schema: public | ||
object_relationships: | ||
- name: block | ||
using: | ||
foreign_key_constraint_on: block_id |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
- "!include public_addresses.yaml" | ||
- "!include demo_faucet_claims.yaml" | ||
- "!include demo_queue.yaml" | ||
- "!include demo_txes.yaml" | ||
- "!include public_blocks.yaml" | ||
- "!include public_chains.yaml" | ||
- "!include public_coin_receiveds.yaml" | ||
- "!include public_coin_spents.yaml" | ||
- "!include public_coinbases.yaml" | ||
- "!include public_commissions.yaml" | ||
- "!include public_events.yaml" | ||
- "!include public_messages.yaml" | ||
- "!include public_mints.yaml" | ||
- "!include public_rewards.yaml" | ||
- "!include public_transfers.yaml" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- "!include v0_blocks.yaml" | ||
- "!include v0_chains.yaml" | ||
- "!include v0_coin_receiveds.yaml" | ||
- "!include v0_coin_receiveds_30m.yaml" | ||
- "!include v0_coin_receiveds_totals.yaml" | ||
- "!include v0_events.yaml" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: blocks | ||
schema: v0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: chains | ||
schema: v0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: coin_receiveds | ||
schema: v0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: coin_receiveds_30m | ||
schema: v0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: coin_receiveds_totals | ||
schema: v0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: events | ||
schema: v0 |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
[] | ||
- name: faucet | ||
definition: | ||
url: https://faucet.0xc0dejug.uno/graphql | ||
timeout_seconds: 60 | ||
customization: | ||
root_fields_namespace: union | ||
forward_client_headers: true | ||
comment: "" |