From a4dc47827c12cf526e41efee3b3e7b048bd030f1 Mon Sep 17 00:00:00 2001 From: Josef Date: Thu, 25 Jul 2024 20:56:05 +0200 Subject: [PATCH] docs: create pindexer readme and mention pindexer<>pd compat in errors (#4768) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Describe your changes adds some explanation for a common issue with pindexer ## Issue ticket number and link fixes #4765 ## Checklist before requesting a review - [x] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: indexer-only changes --------- Signed-off-by: Lúcás Meier Co-authored-by: Lúcás Meier --- crates/bin/pindexer/README.md | 11 +++++++++++ crates/bin/pindexer/src/block.rs | 3 ++- crates/bin/pindexer/src/lib.rs | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 crates/bin/pindexer/README.md diff --git a/crates/bin/pindexer/README.md b/crates/bin/pindexer/README.md new file mode 100644 index 0000000000..3e94221e2e --- /dev/null +++ b/crates/bin/pindexer/README.md @@ -0,0 +1,11 @@ +# pindexer + +A indexer that ingests ABCI events emitted by pd and transforms them into useful data. + +## Usage + +1. Follow the setup instructions in cometindex README +2. `cargo run --bin pindexer -- -s "postgresql://localhost:5432/testnet_raw?sslmode=disable" -d "postgresql://localhost:5432/testnet_compiled?sslmode=disable"` + +## pd compatibility + diff --git a/crates/bin/pindexer/src/block.rs b/crates/bin/pindexer/src/block.rs index 6f3aa3b676..21ee69dc79 100644 --- a/crates/bin/pindexer/src/block.rs +++ b/crates/bin/pindexer/src/block.rs @@ -1,3 +1,4 @@ +use crate::PD_COMPAT; use anyhow::anyhow; use cometindex::{async_trait, sqlx, AppView, ContextualizedEvent, PgTransaction}; use penumbra_proto::{core::component::sct::v1 as pb, event::ProtoEvent}; @@ -52,7 +53,7 @@ CREATE TABLE IF NOT EXISTS block_details ( .bind(i64::try_from(pe.height)?) .bind( DateTime::from_timestamp(timestamp.seconds, u32::try_from(timestamp.nanos)?) - .ok_or(anyhow!("failed to convert timestamp"))?, + .ok_or(anyhow!(format!("failed to convert timestamp. {PD_COMPAT}")))?, ) .bind(pe.root.unwrap().inner) .execute(dbtx.as_mut()) diff --git a/crates/bin/pindexer/src/lib.rs b/crates/bin/pindexer/src/lib.rs index 9c443724d8..b4e5b3c89e 100644 --- a/crates/bin/pindexer/src/lib.rs +++ b/crates/bin/pindexer/src/lib.rs @@ -7,3 +7,5 @@ pub mod dex; pub mod shielded_pool; mod sql; pub mod stake; + +pub(crate) const PD_COMPAT: &'static str = "Check that your pd and pindexer versions match. See pd compatibility section in README for more information.";