|
1 | | -# Kadena Indexer |
| 1 | +# Kadindexer - Kadena Indexer |
2 | 2 |
|
3 | 3 | This project is a monorepo that contains the following packages: |
4 | 4 |
|
5 | | -- `@kadena-indexer/indexer`: The indexer package, which is responsible for scanning and storing blocks for Kadena blockchain. |
6 | | -- `@kadena-indexer/terraform`: The Terraform configuration for provisioning the infrastructure required to run the indexer and the node. |
| 5 | +- [`@kadena-indexer/indexer`](indexer/README.md): The indexer package, which is responsible for scanning and storing blocks for Kadena blockchain. |
| 6 | +- [`@kadena-indexer/terraform`](terraform/README.md): The Terraform configuration for provisioning the infrastructure required to run the indexer and the node. |
| 7 | +- [`@kadena-indexer/backfill`](backfill/README.md): The backfill package, which is responsible for backfilling the indexer data. |
7 | 8 |
|
8 | | -## Prerequisites |
| 9 | +## Requirements |
9 | 10 |
|
10 | | -- [Terraform](https://www.terraform.io/downloads.html) |
11 | | -- [AWS CLI](https://aws.amazon.com/cli/) |
12 | | -- [AWS Account](https://aws.amazon.com/) |
13 | | -- [AWS Access Key](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) |
14 | | - |
15 | | -### Dev Container |
16 | | - |
17 | | -This project is configured to run in a dev container. You can use the `Dev Containers: Open Folder in Container` command in VSCode to open the project in a dev container. This will automatically install the required dependencies and set up the environment. To use the dev container, you need to have Docker installed on your machine. |
18 | | - |
19 | | -If you don't have Dev Containers installed, you can install it from the [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). |
20 | | - |
21 | | -### Configure Environment Variables |
22 | | - |
23 | | -Under the `/terraform` directory, create an `.env` file using the `.env.template` as a reference and set the environment variables accordingly. |
24 | | - |
25 | | -```bash |
26 | | -cp terraform/.env.template terraform/.env |
27 | | -``` |
28 | | - |
29 | | -`TF_VAR_AWS_ACCESS_KEY_ID` is your AWS access key ID. |
30 | | -`TF_VAR_AWS_SECRET_ACCESS_KEY` is your AWS secret access key. |
31 | | -`TF_VAR_AWS_ACCOUNT_ID` is your AWS account ID. |
32 | | -`TF_VAR_AWS_USER_NAME` is the name of the user you created in AWS. |
33 | | -`TF_VAR_AWS_DB_USERNAME` is the username for the postgress database. |
34 | | -`TF_VAR_AWS_DB_PASSWORD` is the password for the postgress database. |
35 | | - |
36 | | -Under the `/indexer` directory, create an `.env` file using the `.env.template` as a reference and set the environment variables accordingly. |
37 | | - |
38 | | -```bash |
39 | | -cp indexer/.env.template indexer/.env |
40 | | -``` |
41 | | - |
42 | | -`AWS_S3_REGION` is the region where the S3 bucket is located. |
43 | | -`AWS_S3_BUCKET_NAME` is the name of the S3 bucket where the data will be stored. |
44 | | -`AWS_ACCESS_KEY_ID` is the access key ID for the S3 bucket. |
45 | | -`AWS_SECRET_ACCESS_KEY` is the secret access key for the S3 bucket. |
46 | | - |
47 | | -`SYNC_BASE_URL` is the base URL for the Kadena node. |
48 | | -`SYNC_MIN_HEIGHT` is the minimum height to start syncing from. |
49 | | -`SYNC_FETCH_INTERVAL_IN_BLOCKS` is the interval in blocks to fetch. |
50 | | -`SYNC_TIME_BETWEEN_REQUESTS_IN_MS` is the time between requests in milliseconds. |
51 | | -`SYNC_ATTEMPTS_MAX_RETRY` is the maximum number of attempts to retry. |
52 | | -`SYNC_ATTEMPTS_INTERVAL_IN_MS` is the interval in milliseconds between attempts. |
53 | | -`SYNC_NETWORK` is the network to sync. |
54 | | - |
55 | | -`DB_USERNAME` is the username for the postgress database. |
56 | | -`DB_PASSWORD` is the password for the postgress database. |
57 | | -`DB_NAME` is the name of the postgress database. |
58 | | -`DB_HOST` is the host for the postgress database. You have the host after the resource creation, so you can check for this information in the AWS console or in terraform output (postgres_db_host). |
59 | | - |
60 | | -### Initialize Terraform |
61 | | - |
62 | | -Initialize your Terraform workspace, which will download the provider and initialize it with the values provided in the terraform.`tfvars`` file. |
63 | | - |
64 | | -```bash |
65 | | -terraform init |
66 | | -``` |
67 | | - |
68 | | -### Deploy Infrastructure |
69 | | - |
70 | | -Plan and apply the Terraform configuration to provision your AWS resources: |
71 | | - |
72 | | -```bash |
73 | | -yarn terraform plan |
74 | | -yarn terraform apply |
75 | | -``` |
76 | | - |
77 | | -### Destroy Infrastructure |
78 | | - |
79 | | -If you want to destroy the infrastructure created, you can use the following command: |
80 | | - |
81 | | -```bash |
82 | | -yarn terraform destroy |
83 | | -``` |
| 11 | +- Install dependencies |
| 12 | +- See individual package READMEs for specific prerequisites |
84 | 13 |
|
85 | 14 | ## Installation |
86 | 15 |
|
87 | | -Set up the indexer with the following commands: |
| 16 | +Install dependencies with the following command: |
88 | 17 |
|
89 | 18 | ```bash |
90 | | -yarn && yarn indexer build |
| 19 | +yarn install |
91 | 20 | ``` |
92 | 21 |
|
93 | | -## Features |
| 22 | +## Quick Start |
94 | 23 |
|
95 | | -### Run processing |
| 24 | +This is the quickest way to get the indexer running. |
96 | 25 |
|
97 | | -Continuous process of streaming, headers, payloads and missing blocks from node to s3 bucket and from s3 bucket to database |
| 26 | +Install [Docker](https://www.docker.com/). |
98 | 27 |
|
99 | | -```bash |
100 | | -yarn indexer dev:run |
101 | | -``` |
102 | | - |
103 | | -## Additional Commands |
104 | | - |
105 | | -### Running with Docker |
| 28 | +Fill the `.env` file in the `indexer` folder. See [Environment Variables Reference](../indexer/README.md#32-environment-variables-reference). |
106 | 29 |
|
107 | 30 | ```bash |
108 | | -sudo docker build -t kadena-indexer:latest . |
109 | | -sudo docker run --env-file ./indexer/.env -p 3000:3000 kadena-indexer:latest |
110 | | -``` |
111 | | - |
112 | | -### Backfilling Blocks |
113 | | - |
114 | | -Scan for and store historical blocks. |
115 | | - |
116 | | -```bash |
117 | | -yarn indexer dev:backfill |
118 | | -``` |
119 | | - |
120 | | -### Streaming Blocks |
121 | | - |
122 | | -Listen for new blocks and store them in real-time. |
123 | | - |
124 | | -```bash |
125 | | -yarn indexer dev:streaming |
126 | | -``` |
127 | | - |
128 | | -### Identifying Missing Blocks |
129 | | - |
130 | | -Scan for and store any blocks that were missed. |
131 | | - |
132 | | -```bash |
133 | | -yarn indexer dev:missing |
134 | | -``` |
135 | | - |
136 | | -### Processing Headers |
137 | | - |
138 | | -Start the header processing from S3 to the database. |
139 | | - |
140 | | -```bash |
141 | | -yarn indexer dev:headers |
142 | | -``` |
143 | | - |
144 | | -### Processing Payloads |
145 | | - |
146 | | -Start the payload processing from S3 to the database. |
147 | | - |
148 | | -```bash |
149 | | -yarn indexer dev:payloads |
150 | | -``` |
151 | | - |
152 | | -## Advanced Usage |
153 | | - |
154 | | -### Local Workflow Testing |
155 | | - |
156 | | -For testing workflows locally, act is required. Install it using Homebrew: |
157 | | - |
158 | | -```bash |
159 | | -brew install act |
| 31 | +cp indexer/.env.template indexer/.env |
160 | 32 | ``` |
161 | 33 |
|
162 | | -### Run Terraform Workflow Manually |
163 | | - |
164 | | -If you want to run the terraform workflow manually, you can use the following command: |
165 | | - |
| 34 | +To start all services: |
166 | 35 | ```bash |
167 | | -yarn run-terraform-workflow |
| 36 | +yarn indexer dev |
168 | 37 | ``` |
169 | 38 |
|
170 | | -### Run Indexer Workflow Manually |
171 | | - |
172 | | -If you want to run the indexer workflow manually, you can use the following command: |
| 39 | +**NOTE:** Using the image on with the composer require the database `DB_USERNAME` to default to `postgres`. |
173 | 40 |
|
174 | | -```bash |
175 | | -yarn run-indexer-workflow |
176 | | -``` |
0 commit comments