You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+75-42
Original file line number
Diff line number
Diff line change
@@ -1,37 +1,42 @@
1
1
## IMPORTANT: See Prerequisites below
2
2
3
3
## Digital Asset RPC API Infrastructure
4
-
This repo houses the API Ingester and Database Types components of the Metaplex Digital Asset RPC API. Together these
5
-
components are responsible for the aggregation of Solana Validator Data into an extremely fast and well typed api. This
6
-
api provides a nice interface on top of the Metaplex programs. It abstracts the byte layout on chain, allows for
7
-
super-fast querying and searching, as well as serves the merkle proofs needed to operate over compressed nfts.
4
+
5
+
This repo houses the API Ingester and Database Types components of the Metaplex Digital Asset RPC API. Together these
6
+
components are responsible for the aggregation of Solana Validator Data into an extremely fast and well typed api. This
7
+
api provides a nice interface on top of the Metaplex programs. It abstracts the byte layout on chain, allows for
8
+
super-fast querying and searching, as well as serves the merkle proofs needed to operate over compressed nfts.
8
9
9
10
### Components
11
+
10
12
1. Ingester -> A background processing system that gets messages from a [Messenger](https://github.com/metaplex-foundation/digital-asset-validator-plugin), and uses [BlockBuster](https://github.com/metaplex-foundation/blockbuster) Parsers to store the canonical representation of Metaplex types in a storage system. This system also holds the re-articulated Merkle tree that supports the compressed NFTs system.
11
13
2. Api -> A JSON Rpc api that serves Metaplex objects. This api allows filtering, pagination and searching over Metaplex data. This data includes serving the merkle proofs for the compressed NFTs system. It is intended to be run right alongside the Solana RPC and works in much the same way. Just like the solana RPC takes data from the validator and serves it in a new format, so this api takes data off the validator and serves it.
12
14
13
15
The API specification is located here https://github.com/metaplex-foundation/api-specifications
14
16
This spec is what providers of this api must implement against.
15
17
16
18
### Infrastructure and Deployment Examples
17
-
Along with the above rust binaries, this repo also maintains examples and best practice settings for running the entire infrastructure.
18
-
The example infrastructure is as follows.
19
19
20
-
* A Solana No-Vote Validator - This validator is configured to only have secure access to the validator ledger and account data under consensus.
21
-
* A Geyser Plugin (Plerkle) - The above validator is further configured to load this geyser plugin that sends Plerkle Serialized Messages over a messaging system.
22
-
* A Redis Cluster (Stream Optimized) - The example messaging system is a light weight redis deployment that supports the streaming configuration.
23
-
* A Kubernetes Cluster - The orchestration system for the API and Ingester processes. Probably overkill for a small installation, but it's a rock solid platform for critical software.
20
+
Along with the above rust binaries, this repo also maintains examples and best practice settings for running the entire infrastructure.
21
+
The example infrastructure is as follows.
22
+
23
+
- A Solana No-Vote Validator - This validator is configured to only have secure access to the validator ledger and account data under consensus.
24
+
- A Geyser Plugin (Plerkle) - The above validator is further configured to load this geyser plugin that sends Plerkle Serialized Messages over a messaging system.
25
+
- A Redis Cluster (Stream Optimized) - The example messaging system is a light weight redis deployment that supports the streaming configuration.
26
+
- A Kubernetes Cluster - The orchestration system for the API and Ingester processes. Probably overkill for a small installation, but it's a rock solid platform for critical software.
24
27
25
28
This repo houses Helm Charts, Docker files and Terraform files to assist in the deployment of the example infrastructure.
26
29
27
30
### Developing
28
31
29
32
#### Prerequisites:
33
+
30
34
You must clone the https://github.com/metaplex-foundation/blockbuster repo, this is un publishable for now due to active development in like 1000 branches and serious mathematics avoiding dependency hell.
31
35
32
36
Because this is a multi component system the easiest way to develop or locally test this system is with docker but developing locally without docker is possible.
33
37
34
38
#### Regenerating DB Types
39
+
35
40
Edit the init.sql, then run `docker compose up db`
36
41
Then with a local `DATABASE_URL` var exported like this `export DATABASE_URL=postgres://solana:solana@localhost/solana` you can run
37
42
`sea-orm-cli generate entity -o ./digital_asset_types/src/dao/generated/ --database-url $DATABASE_URL --with-serde both --expanded-format`
@@ -40,18 +45,19 @@ If you need to install `sea-orm-cli` run `cargo install sea-orm-cli`.
40
45
41
46
Note: The current SeaORM types were generated using version 0.9.3 so unless you want to upgrade you can install using `cargo install sea-orm-cli --version 0.9.3`.
42
47
43
-
Also note: The migration `m20230224_093722_performance_improvements` needs to be commented out of the migration lib.rs in order for the Sea ORM `Relations` to generate correctly.
44
-
45
48
#### Developing Locally
46
-
*Prerequisites*
47
-
* A Postgres Server running with the database setup according to ./init.sql
48
-
* A Redis instance that has streams enabled or a version that supports streams
49
-
* A local solana validator with the Plerkle plugin running.
50
-
* Environment Variables set to allow your validator, ingester and api to access those prerequisites.
49
+
50
+
_Prerequisites_
51
+
52
+
- A Postgres Server running with the database setup according to ./init.sql
53
+
- A Redis instance that has streams enabled or a version that supports streams
54
+
- A local solana validator with the Plerkle plugin running.
55
+
- Environment Variables set to allow your validator, ingester and api to access those prerequisites.
51
56
52
57
See [Plugin Configuration](https://github.com/metaplex-foundation/digital-asset-validator-plugin#building-locally) for how to locally configure the test validator plugin to work.
53
58
54
59
For the API you need the following environment variables:
60
+
55
61
```bash
56
62
APP_DATABASE_URL=postgres://solana:solana@db/solana #change to your db host
57
63
APP_SERVER_PORT=9090
@@ -62,6 +68,7 @@ cargo run -p das_api
62
68
```
63
69
64
70
For the Ingester you need the following environment variables:
71
+
65
72
```bash
66
73
INGESTER_DATABASE_CONFIG: '{listener_channel="backfill_item_added", url="postgres://solana:solana@db/solana"}'# your database host
@@ -72,13 +79,14 @@ INGESTER_RPC_CONFIG: '{url="http://validator:8899", commitment="finalized"}' # y
72
79
cargo run -p nft_ingester
73
80
```
74
81
75
-
76
82
When making changes you will need to stop the cargo process and re-run. Someday we will have auto rebuild for local cargo stuff but for now you are on your own.
77
83
78
84
#### NOTE
85
+
79
86
```
80
-
INGESTER_ROLE
87
+
INGESTER_ROLE
81
88
```
89
+
82
90
This environment variable can be used to split the work load.
83
91
84
92
All for a combined setup
@@ -89,44 +97,49 @@ Background for just the background tasks.
89
97
For production you should split the coponents up.
90
98
91
99
### Developing With Docker
100
+
92
101
Developing with Docker is much easier, but has some nuances to it. This test docker compose system relies on a programs folder being accessible, this folder needs to have the shared object files for the following programs
93
-
* Token Metadata
94
-
* Bubblegum
95
-
* Gummyroll
96
-
* Token 2022
97
-
* Latest version of the Associated token program
102
+
103
+
- Token Metadata
104
+
- Bubblegum
105
+
- Gummyroll
106
+
- Token 2022
107
+
- Latest version of the Associated token program
98
108
99
109
You need to run the following script in order to get the .so files.
100
110
101
111
```bash
102
112
./prepare-local-docker-env.sh
103
113
```
104
-
This script downloads these programs from mainnet and puts them in the `programs/` folder.
114
+
115
+
This script grabs all the code for these programs and compiles it, and chucks it into your programs folder. Go grab some coffe because this will take a while/
116
+
If you get some permissions errors, just sudo delete the programs directory and start again.
105
117
106
118
#### Authentication with Docker and AWS
107
119
108
-
_This step is not normally needed for basic local docker usage._
We use ``docker-compose`` to build the multi-container Docker application. On some systems its ``docker compose``.
124
+
We use `docker-compose` to build the multi-container Docker application. On some systems its `docker compose`.
125
+
114
126
```bash
115
-
docker-compose build
127
+
docker-compose build
116
128
```
129
+
117
130
This builds the docker container for API and the Ingester components and will download the appropriate Redis, Postgres and Solana+plerkle docker images.
118
131
Keep in mind that the version `latest` on the Solana Validator image will match the latest version available on the docs, for other versions please change that version in your docker compose file.
119
132
120
133
```bash
121
-
docker-compose up
134
+
docker-compose up
122
135
```
123
136
124
137
#### Developing
125
138
126
-
When making changes you will need to ``docker compose up --build --force-recreate`` again to get the latest changes.
139
+
When making changes you will need to `docker compose up --build --force-recreate` again to get the latest changes.
127
140
Also when mucking about with the docker file if your gut tells you that something is wrong, and you are getting build errors run `docker compose build --no-cache`
128
141
129
-
Sometimes you will want to delete the db do so with `sudo rm -rf db-data`. You can also delete the ledger with `sudo rm -rf ledger`.
142
+
Sometimes you will want to delete the db do so with `sudo rm -rf db-data`. You can also delete the ledger with `sudo rm -rf ledger`.
130
143
131
144
#### Running Bubblegum Test Sequences
132
145
@@ -137,13 +150,16 @@ sudo rm -rf db-data/
137
150
sudo rm -rf ledger/
138
151
docker compose up --force-recreate --build
139
152
```
153
+
140
154
_In another terminal:_
155
+
141
156
```bash
142
157
cd tools/txn_forwarder/bubblegum_tests/
143
158
./run-bubblegum-sequences.sh
144
159
```
145
160
146
161
You should see it log something like:
162
+
147
163
```
148
164
Running 10 scenarios forwards
149
165
mint_transfer_burn.scenario initial asset table state passed
@@ -160,26 +176,33 @@ ALL TESTS PASSED FORWARDS!
160
176
```
161
177
162
178
You can also run the sequences in reverse:
179
+
163
180
```bash
164
181
./run-bubblegum-sequences.sh reverse
165
182
```
183
+
166
184
And after it runs you should see `ALL TESTS PASSED IN REVERSE!`
167
185
168
186
A few detailed notes about this test script:
169
-
* This script is not all-encompassing. It is only meant to automate some normal basic tests that were previously done manually. The reason this test is not added to CI is because requires a more powerful system to run the Docker application, which contains the no-vote Solana validator.
170
-
* The test sequences are in `.scenario` files, but instead of sending those files to the `txn_forwarder` directly (which supports the file format), we parse them out and send them individually using the `single` parameter. This is because using the `.scenario` file directly results in random ordering of the transactions and we are explicity trying to test them going forwards and in reverse.
171
-
* In general the expected database results are the same when running the transactions forwards and backwards. However, for assets that are decompressed, this is not true because we don't index some of the asset information from Bubblegum mint indexing if we already know the asset has been decompressed. We instead let Token Metadata account based indexing fill in that information. This is not reflected by this test script so the results differ when running these sequences in reverse. The differing results are reflected in test files with the `_reverse` suffix.
187
+
188
+
- This script is not all-encompassing. It is only meant to automate some normal basic tests that were previously done manually. The reason this test is not added to CI is because requires a more powerful system to run the Docker application, which contains the no-vote Solana validator.
189
+
- The test sequences are in `.scenario` files, but instead of sending those files to the `txn_forwarder` directly (which supports the file format), we parse them out and send them individually using the `single` parameter. This is because using the `.scenario` file directly results in random ordering of the transactions and we are explicity trying to test them going forwards and in reverse.
190
+
- In general the expected database results are the same when running the transactions forwards and backwards. However, for assets that are decompressed, this is not true because we don't index some of the asset information from Bubblegum mint indexing if we already know the asset has been decompressed. We instead let Token Metadata account based indexing fill in that information. This is not reflected by this test script so the results differ when running these sequences in reverse. The differing results are reflected in test files with the `_reverse` suffix.
172
191
173
192
#### Logs
193
+
174
194
To get a reasonable amount of logs while running Docker, direct grafana logs to a file:
195
+
175
196
```
176
197
grafana:
177
198
...
178
199
environment:
179
200
...
180
201
- GF_LOG_MODE=file
181
202
```
182
-
and set Solana Rust logs to error level (it is already set to error level now in the current docker compose file):
203
+
204
+
and set Solana Rust logs to error level:
205
+
183
206
```
184
207
solana:
185
208
...
@@ -190,10 +213,13 @@ and set Solana Rust logs to error level (it is already set to error level now in
190
213
#### Interacting with API
191
214
192
215
Once everything is working you can see that there is a api being served on
0 commit comments