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

ChainID stored as integer in intervals table - out of range #1572

Open
ant1g opened this issue Mar 1, 2025 · 3 comments · May be fixed by #1569
Open

ChainID stored as integer in intervals table - out of range #1572

ant1g opened this issue Mar 1, 2025 · 3 comments · May be fixed by #1569

Comments

@ant1g
Copy link

ant1g commented Mar 1, 2025

Version

v0.9

Current behavior

Hello,

I am using ponder with a chain id that doesn't fit into a postgres integer. The max value is 2147483647, but my chain id is 123220401683, as generated by my RaaS provider.

As a result, the ponder process fails to start, throwing the following error:

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
error: value "123220401683" is out of range for type integer
    at /redacted/node_modules/.pnpm/[email protected]/node_modules/pg/lib/client.js:535:17
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at PostgresConnection.executeQuery (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:69:28)
    at PostgresConnection.connection.executeQuery (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
    at file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
    at DefaultConnectionProvider.provideConnection (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
    at DefaultQueryExecutor.executeQuery (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
    at InsertQueryBuilder.execute (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
    at file:///redacted/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_h_agpaekvhde7rc4zyez2s62o6qu/node_modules/ponder/src/sync-store/index.ts:199:7
    at HeadlessKysely.wrap (file:///redacted/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_h_agpaekvhde7rc4zyez2s62o6qu/node_modules/ponder/src/database/kysely.ts:42:24)
    at PostgresConnection.executeQuery (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:88:41)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at PostgresConnection.connection.executeQuery (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/runtime-driver.js:89:24)
    at file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
    at DefaultConnectionProvider.provideConnection (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
    at DefaultQueryExecutor.executeQuery (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
    at InsertQueryBuilder.execute (file:///redacted/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-builder/insert-query-builder.js:515:24)
    at file:///redacted/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_h_agpaekvhde7rc4zyez2s62o6qu/node_modules/ponder/src/sync-store/index.ts:199:7

The integer field simply needs to be upgraded to a biginteger in the migrations:
https://github.com/ponder-sh/ponder/blob/main/packages/core/src/sync-store/migrations.ts#L911
There are other occurrences of the chain_id being an integer, so it has to be fixed there too.

I can probably make a PR if you want.

Expected behavior

I expect my chain_id to be stored correctly in the db.

Steps to reproduce

No response

Link to repository

No response

Anything else?

No response

@ant1g ant1g changed the title ChainID stored as integer in intervals table - too ChainID stored as integer in intervals table - too small Mar 1, 2025
@ant1g ant1g changed the title ChainID stored as integer in intervals table - too small ChainID stored as integer in intervals table - out of range Mar 1, 2025
@typedarray
Copy link
Collaborator

Thanks for opening. As a workaround to get unblocked, you should be able to just enter a smaller chainId in the config file.

We actually discussed this yesterday (lol) and are shipping the fix in 0.10, probably ~2 weeks out. Planning to use PG int8 and JS bigint for all internal chain IDs.

@ant1g
Copy link
Author

ant1g commented Mar 1, 2025

Ah all right, understood. I was actually updating the DB myself to fix this. Using a different chain id in the config won't cause any mismatch while using the rpc node?
I have made a PR to add a migration already, but feel free to discard. Thanks

@typedarray
Copy link
Collaborator

Nice, thanks for the quick PR. I would love to merge this, but unfortunately a database migration is a breaking change, so we'd have to release a minor. We're tackling this anyway in 0.10, so best to wait.

Using a different chain id in the config won't cause any mismatch while using the rpc node?

No, it should be fine. There will probably be a warning log but everything should work as intended - lmk if not.

@kyscott18 kyscott18 linked a pull request Mar 5, 2025 that will close this issue
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 a pull request may close this issue.

2 participants