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

fix(pindexer): correct encoding of Amount into Postgres #4772

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

cronokirby
Copy link
Contributor

I tried and tried to actually use Numeric directly in a smart way, instead the hack is to just cast text into it in the SQL query. Oh well.

Checklist before requesting a review

  • 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:

    pindexer bug fix

@conorsch
Copy link
Contributor

Context: while ingesting events from a devnet, we encountered this error in pindexer:

Error: error returned from database: operator does not exist: - bytea

Caused by:
    operator does not exist: - bytea

which we tracked down to

, specifically mismatched types.

@conorsch
Copy link
Contributor

Even with this place in place, when reindexing a devnet db, I encounter a new (but different) error:

2024-07-25T23:24:35.437139Z DEBUG index_event{height=18957 name="penumbra.core.component.dex.v1.EventArbExecution"}: sqlx::query: summary="INSERT INTO trace_step VALUES …" db.statement="\n\nINSERT INTO\n  trace_step\nVALUES\n  (DEFAULT, (CAST($1 AS Amount), $2)) RETURNING id;\n" rows_affected=0 rows_returned=1 elapsed=9.95282ms
2024-07-25T23:24:35.437480Z 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\nORDER BY\n  events.rowid ASC\n" rows_affected=0 rows_returned=1 elapsed=189.203787ms
Error: error occurred while decoding column 0: mismatched types; Rust type `i64` (as SQL type `INT8`) is not compatible with SQL type `INT4`

Caused by:
    mismatched types; Rust type `i64` (as SQL type `INT8`) is not compatible with SQL type `INT4`

which suggests we've still got some typecasting to sort out.

I tried and tried to actually use Numeric directly in a smart way,
instead the hack is to just cast text into it in the SQL query. Oh well.

Use i32 for small serial keys in dex indexing
@conorsch conorsch changed the title Bug: Correct encoding of Amount into Postgres fix(pindexer): correct encoding of Amount into Postgres Jul 26, 2024
@conorsch conorsch merged commit 899f3e6 into main Jul 26, 2024
13 checks passed
@conorsch conorsch deleted the amount-encoding-fix branch July 26, 2024 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants