From a802d8dac43321d9b6419ec9bfd243d6eed2bdfa Mon Sep 17 00:00:00 2001 From: Atris Date: Wed, 17 Jul 2024 23:02:16 +0200 Subject: [PATCH] feat: fix and enable block timestamp indexing --- crates/bin/pindexer/src/block/block.rs | 4 ++-- crates/bin/pindexer/src/lib.rs | 2 +- crates/bin/pindexer/src/main.rs | 3 +++ crates/core/component/sct/Cargo.toml | 2 +- crates/core/component/sct/src/component/tree.rs | 1 - 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/bin/pindexer/src/block/block.rs b/crates/bin/pindexer/src/block/block.rs index 1a148d4aa0..1532b12e4d 100644 --- a/crates/bin/pindexer/src/block/block.rs +++ b/crates/bin/pindexer/src/block/block.rs @@ -5,7 +5,7 @@ pub struct Block {} #[async_trait] impl AppView for Block { - async fn init_chain(&self, dbtx: &mut PgTransaction) -> Result<(), anyhow::Error> { + async fn init_chain(&self, dbtx: &mut PgTransaction, _: &serde_json::Value) -> Result<(), anyhow::Error> { sqlx::query( // table name is module path + struct name " @@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS block_details ( } fn is_relevant(&self, type_str: &str) -> bool { - type_str == "penumbra.core.component.sct.v1.EventBlockTimestamp.timestamp" + type_str == "penumbra.core.component.sct.v1.EventBlockRoot" } async fn index_event( diff --git a/crates/bin/pindexer/src/lib.rs b/crates/bin/pindexer/src/lib.rs index 11b0ac6603..e3eae33e85 100644 --- a/crates/bin/pindexer/src/lib.rs +++ b/crates/bin/pindexer/src/lib.rs @@ -4,5 +4,5 @@ mod indexer_ext; pub use indexer_ext::IndexerExt; pub mod shielded_pool; - pub mod stake; +pub mod block; diff --git a/crates/bin/pindexer/src/main.rs b/crates/bin/pindexer/src/main.rs index 081a3ea274..f91dcf4e79 100644 --- a/crates/bin/pindexer/src/main.rs +++ b/crates/bin/pindexer/src/main.rs @@ -1,11 +1,14 @@ use anyhow::Result; use pindexer::{Indexer, IndexerExt as _}; +use pindexer::block::block::Block; #[tokio::main] async fn main() -> Result<()> { + dbg!("hello"); Indexer::new() .with_default_tracing() .with_default_penumbra_app_views() + .with_index(Block {}) .run() .await?; diff --git a/crates/core/component/sct/Cargo.toml b/crates/core/component/sct/Cargo.toml index d6ae5c696c..da99b806e4 100644 --- a/crates/core/component/sct/Cargo.toml +++ b/crates/core/component/sct/Cargo.toml @@ -44,7 +44,7 @@ serde = {workspace = true, features = ["derive"]} tendermint = {workspace = true} tonic = {workspace = true, optional = true} tracing = {workspace = true} -chrono = { workspace = true, default-features = false, features = ["serde"] } +chrono = { workspace = true, default-features = false, features = ["serde", "now"] } [dev-dependencies] getrandom = {workspace = true} \ No newline at end of file diff --git a/crates/core/component/sct/src/component/tree.rs b/crates/core/component/sct/src/component/tree.rs index 9557e0dbb8..3bd4021c81 100644 --- a/crates/core/component/sct/src/component/tree.rs +++ b/crates/core/component/sct/src/component/tree.rs @@ -5,7 +5,6 @@ use penumbra_proto::{StateReadProto, StateWriteProto}; use penumbra_tct as tct; use tct::builder::{block, epoch}; use tracing::{instrument}; -use tracing::field::debug; use crate::{ component::clock::EpochRead, event, state_key, CommitmentSource, NullificationInfo, Nullifier,