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

pindexer::block panics on timestamp #4761

Closed
ejmg opened this issue Jul 25, 2024 · 1 comment · Fixed by #4764
Closed

pindexer::block panics on timestamp #4761

ejmg opened this issue Jul 25, 2024 · 1 comment · Fixed by #4764
Labels
needs-refinement unclear, incomplete, or stub issue that needs work

Comments

@ejmg
Copy link
Collaborator

ejmg commented Jul 25, 2024

Describe the bug
As it stands, the custom app view introduced by #4713 for tracking block timestamps throws a hard error whenever it tries to extract a timestamp from a EventBlockRoot.

To Reproduce
Steps to reproduce the behavior:

  1. Stand up a raw indexer db and destination db for pindexer and run the binary as the README instructs
  2. You will immediately hit an application error

Expected behavior
It should correctly extract and index timestamp events for EventBlockRoot events without immediately killing pindexer.
Screenshots
basic stack trace with RUST_LOG=debug

     Running `target/debug/pindexer -s 'postgresql://localhost:5432/raw_79_1?sslmode=disable' -d 'postgresql://localhost:5432/compiled_79_1?sslmode=disable' -g genesis.json`
2024-07-25T02:23:54.653952Z  INFO cometindex::indexer: self.opts=Options { src_database_url: "postgresql://localhost:5432/raw_79_1?sslmode=disable", dst_database_url: "postgresql://localhost:5432/compiled_79_1?sslmode=disable", chain_id: None, poll_ms: 500ms, genesis_json: "genesis.json" }
2024-07-25T02:23:54.666144Z DEBUG sqlx::query: summary="SET SESSION CHARACTERISTICS AS …" db.statement="\n\nSET\n  SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;\n" rows_affected=0 rows_returned=0 elapsed=994.125µs
2024-07-25T02:23:54.682616Z DEBUG sqlx::query: summary="SELECT EXISTS ( SELECT …" db.statement="\n\nSELECT\n  EXISTS (\n    SELECT\n    FROM\n      information_schema.tables\n    WHERE\n      table_name = 'index_watermark'\n  )\n" rows_affected=0 rows_returned=1 elapsed=7.050917ms
2024-07-25T02:23:54.682672Z  INFO cometindex::indexer: skipping genesis initialization
2024-07-25T02:23:54.689818Z DEBUG sqlx::query: summary="SELECT events_rowid FROM index_watermark" db.statement="" rows_affected=0 rows_returned=1 elapsed=1.210667ms
2024-07-25T02:23:54.689880Z DEBUG cometindex::indexer: fetched index watermark row_id=37835
2024-07-25T02:23:54.715392Z DEBUG sqlx::query: summary="SELECT COUNT(*) FROM events …" db.statement="\n\nSELECT\n  COUNT(*)\nFROM\n  events\nWHERE\n  rowid > $1\n" rows_affected=0 rows_returned=1 elapsed=24.90375ms
2024-07-25T02:23:54.715454Z  INFO cometindex::indexer: new events since last watermark count=99841 watermark=37835
2024-07-25T02:23:54.718582Z DEBUG sqlx::query: summary="SET SESSION CHARACTERISTICS AS …" db.statement="\n\nSET\n  SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;\n" rows_affected=0 rows_returned=0 elapsed=284.167µs
2024-07-25T02:23:54.753133Z DEBUG cometindex::indexer: local_rowid=37836 type_str="penumbra.core.component.sct.v1.EventBlockRoot" height=9461 tx_hash=None
2024-07-25T02:23:54.753175Z  INFO cometindex::indexer: scanned_events=0 relevant_events=0
2024-07-25T02:23:54.753550Z DEBUG sqlx::query: summary="BEGIN" db.statement="" rows_affected=0 rows_returned=0 elapsed=133.25µs
2024-07-25T02:23:54.753574Z DEBUG cometindex::indexer: relevant to index event=ContextualizedEvent { event: Event { kind: "penumbra.core.component.sct.v1.EventBlockRoot", attributes: [EventAttribute { key: "root", value: "{\"inner\":\"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"}", index: false }, EventAttribute { key: "height", value: "\"9461\"", index: false }] }, block_height: 9461, tx_hash: None, local_rowid: 37836 } index=Block
2024-07-25T02:23:54.757237Z DEBUG sqlx::query: summary="SELECT events.rowid, events.type, blocks.height …" db.statement="\n\nSELECT\n  events.rowid,\n  events.type,\n  blocks.height AS block_height,\n  tx_results.tx_hash,\n  jsonb_object_agg(attributes.key, attributes.value) AS attrs\nFROM\n  events\n  LEFT JOIN attributes ON events.rowid = attributes.event_id\n  JOIN blocks ON events.block_id = blocks.rowid\n  LEFT JOIN tx_results ON events.tx_id = tx_results.rowid\nWHERE\n  events.rowid > $1\nGROUP BY\n  events.rowid,\n  events.type,\n  blocks.height,\n  tx_results.tx_hash\n" rows_affected=0 rows_returned=1 elapsed=35.387083ms
Error: block at height 9461 has no timestamp

Additional context
I encountered this while finishing up changes to #4752 and have commented it out in my PR given that it will make pindexer immediately fail for anyone trying to use it or build their own indexers.

@github-actions github-actions bot added the needs-refinement unclear, incomplete, or stub issue that needs work label Jul 25, 2024
@vacekj vacekj linked a pull request Jul 25, 2024 that will close this issue
1 task
@cronokirby
Copy link
Contributor

This indicates that you're using a version of pd that doesn't emit timestamps with block events. Using the pd on main to emit events will fix this, and this change should be in an upcoming point release too.

hdevalence pushed a commit that referenced this issue Jul 26, 2024
## Describe your changes

this sets timestamp to default for blocks without one to

## Issue ticket number and link

fixes #4761

## 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 changes only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-refinement unclear, incomplete, or stub issue that needs work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants