Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support PENUMBRA_INDEXER_CA_CERT env var override #56

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ In order to run the dex-explorer, you'll need to [deploy a Penumbra fullnode](ht
with [ABCI event indexing enabled](https://guide.penumbra.zone/node/pd/indexing-events). The relevant env vars
you'll want to set are:

* `PENUMBRA_GRPC_ENDPOINT`
* `PENUMBRA_INDEXER_ENDPOINT`
* `NEXT_PUBLIC_CHAIN_ID`
* `NEXT_PUBLIC_CUILOA_URL`
* `PENUMBRA_GRPC_ENDPOINT`: the URL to a remote node's `pd` gRPC service
* `PENUMBRA_INDEXER_ENDPOINT`: the URL to a Postgre database containing ABCI events
* `PENUMBRA_INDEXER_CA_CERT`: optional; if set, the database connection will use the provided certificate authority when validating TLS
* `NEXT_PUBLIC_CHAIN_ID`: the chain id for the network being indexed, controls asset-registry lookups
* `NEXT_PUBLIC_CUILOA_URL`: the URL for a block-explorer application, for generating URLs for more block/transaction info

## Name

Expand Down
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# A justfile for dex-explorer development.
# Documents common tasks for local dev.

# build container image
container:
podman build -f Containerfile .
15 changes: 14 additions & 1 deletion src/utils/indexer/connector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ export class IndexerQuerier {
private pool: Pool;

constructor(connectionString: string) {
this.pool = new Pool({ connectionString });
const dbConfig = {
connectionString: connectionString,
// If a CA certificate was specified as an env var, pass that info to the database config.
// Be advised that if PENUMBRA_INDEXER_CA_CERT is set, then PENUMBRA_INDEXER_ENDPOINT must
// *lack* an `sslmode` param! This is documented here:
// https://node-postgres.com/features/ssl#usage-with-connectionstring
...(process.env.PENUMBRA_INDEXER_CA_CERT != null && {
ssl: {
rejectUnauthorized: true,
ca: process.env.PENUMBRA_INDEXER_CA_CERT,
},
}),
};
this.pool = new Pool(dbConfig);
}

/**
Expand Down
Loading