Skip to content

Commit 6f47537

Browse files
committed
docs: describe abci event indexing
Collects some information from the cuiloa README [0], as well as some generalized instructions captured in #4566, particularly the use of `--ready-to-start` from #4499. Refs #4494, closes #4566. [0] https://github.com/penumbra-zone/cuiloa/blob/dc4133f7b36706cdf5a3ee6b4e0fb2c09e5a8bb8/README.md
1 parent 45a9435 commit 6f47537

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

docs/guide/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [Joining a testnet](./node/pd/join-testnet.md)
1717
- [Becoming a validator](./node/pd/validator.md)
1818
- [Performing a chain upgrade](./node/pd/chain-upgrade.md)
19+
- [Indexing ABCI events](./node/pd/indexing-events.md)
1920
- [Debugging](./node/pd/debugging.md)
2021
- [Ultralight node: `pclientd`](./node/pclientd.md)
2122
- [Configuring `pclientd`](./node/pclientd/configure.md)
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Indexing ABCI events
2+
3+
The `pd` software emits ABCI events while processing blocks. By default,
4+
these blocks are stored in CometBFT's key-value database locally, but node operators
5+
can opt-in to writing the events to an external PostgreSQL database.
6+
7+
## Configuring a Penumbra node to write events to postgres
8+
9+
1. Create a Postgres database, username, and credentials.
10+
2. Apply the [CometBFT schema] to the database: `psql -d $DATABASE_NAME -f <path/to/schema.sql>`
11+
3. Edit the CometBFT config file, by default located at `~/.penumbra/testnet_data/node0/cometbft/config/config.toml`,
12+
specifically its `[tx_index]`, and set:
13+
1. `indexer = "psql"`
14+
2. `psql-conn = "<DATABASE_URL>"`
15+
4. Run `pd` and `cometbft` as normal.
16+
17+
The format for `DATABASE_URL` is specified in the [Postgres docs](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS).
18+
After the node is running, check the logs for errors. Query the database with `SELECT height FROM blocks ORDER BY height DESC LIMIT 10;` and confirm
19+
you're seeing the latest blocks being added to the database.
20+
21+
## Rebuilding an index database from scratch
22+
23+
If you are joining the network after a chain upgrade, the events behind the upgrade boundary
24+
will not be available to your node for syncing while catching up to current height. To emit
25+
historical events, you will need access to archives of CometBFT state created before (each)
26+
planned upgrade. The process then becomes:
27+
28+
1. Restore node state from backup.
29+
2. Ensure you're using the appropriate `pd` and `cometbft` versions for the associated state.
30+
3. Run `pd migrate --ready-to-start` to permit `pd` to start up.
31+
4. Run CometBFT with extra options: `--p2p.pex=false --p2p.seeds='' --moniker archive-node-1`
32+
5. Run `pd` and `cometbft` as normal, taking care to use the appropriate versions.
33+
34+
Then configure another node with indexing support, as described above, and join the second
35+
node to the archive node. As it streams blocks, the ABCI events will be recorded in the database.
36+
37+
[CometBFT schema]: https://github.com/cometbft/cometbft/blob/main/state/indexer/sink/psql/schema.sql

0 commit comments

Comments
 (0)