ponder-with-flashblocks 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3427 -0
- package/README.md +186 -0
- package/dist/esm/bin/commands/codegen.js +46 -0
- package/dist/esm/bin/commands/codegen.js.map +1 -0
- package/dist/esm/bin/commands/createViews.js +196 -0
- package/dist/esm/bin/commands/createViews.js.map +1 -0
- package/dist/esm/bin/commands/dev.js +430 -0
- package/dist/esm/bin/commands/dev.js.map +1 -0
- package/dist/esm/bin/commands/list.js +148 -0
- package/dist/esm/bin/commands/list.js.map +1 -0
- package/dist/esm/bin/commands/prune.js +223 -0
- package/dist/esm/bin/commands/prune.js.map +1 -0
- package/dist/esm/bin/commands/serve.js +198 -0
- package/dist/esm/bin/commands/serve.js.map +1 -0
- package/dist/esm/bin/commands/start.js +253 -0
- package/dist/esm/bin/commands/start.js.map +1 -0
- package/dist/esm/bin/isolatedController.js +200 -0
- package/dist/esm/bin/isolatedController.js.map +1 -0
- package/dist/esm/bin/isolatedWorker.js +146 -0
- package/dist/esm/bin/isolatedWorker.js.map +1 -0
- package/dist/esm/bin/ponder.js +137 -0
- package/dist/esm/bin/ponder.js.map +1 -0
- package/dist/esm/bin/utils/codegen.js +25 -0
- package/dist/esm/bin/utils/codegen.js.map +1 -0
- package/dist/esm/bin/utils/exit.js +100 -0
- package/dist/esm/bin/utils/exit.js.map +1 -0
- package/dist/esm/build/config.js +746 -0
- package/dist/esm/build/config.js.map +1 -0
- package/dist/esm/build/factory.js +76 -0
- package/dist/esm/build/factory.js.map +1 -0
- package/dist/esm/build/index.js +567 -0
- package/dist/esm/build/index.js.map +1 -0
- package/dist/esm/build/plugin.js +53 -0
- package/dist/esm/build/plugin.js.map +1 -0
- package/dist/esm/build/pre.js +83 -0
- package/dist/esm/build/pre.js.map +1 -0
- package/dist/esm/build/schema.js +202 -0
- package/dist/esm/build/schema.js.map +1 -0
- package/dist/esm/build/stacktrace.js +137 -0
- package/dist/esm/build/stacktrace.js.map +1 -0
- package/dist/esm/client/index.js +441 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/config/address.js +2 -0
- package/dist/esm/config/address.js.map +1 -0
- package/dist/esm/config/eventFilter.js +2 -0
- package/dist/esm/config/eventFilter.js.map +1 -0
- package/dist/esm/config/index.js +2 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/config/utilityTypes.js +2 -0
- package/dist/esm/config/utilityTypes.js.map +1 -0
- package/dist/esm/database/actions.js +445 -0
- package/dist/esm/database/actions.js.map +1 -0
- package/dist/esm/database/index.js +604 -0
- package/dist/esm/database/index.js.map +1 -0
- package/dist/esm/database/queryBuilder.js +314 -0
- package/dist/esm/database/queryBuilder.js.map +1 -0
- package/dist/esm/drizzle/bigint.js +38 -0
- package/dist/esm/drizzle/bigint.js.map +1 -0
- package/dist/esm/drizzle/bytes.js +47 -0
- package/dist/esm/drizzle/bytes.js.map +1 -0
- package/dist/esm/drizzle/hex.js +40 -0
- package/dist/esm/drizzle/hex.js.map +1 -0
- package/dist/esm/drizzle/index.js +28 -0
- package/dist/esm/drizzle/index.js.map +1 -0
- package/dist/esm/drizzle/json.js +123 -0
- package/dist/esm/drizzle/json.js.map +1 -0
- package/dist/esm/drizzle/kit/index.js +927 -0
- package/dist/esm/drizzle/kit/index.js.map +1 -0
- package/dist/esm/drizzle/onchain.js +184 -0
- package/dist/esm/drizzle/onchain.js.map +1 -0
- package/dist/esm/drizzle/text.js +61 -0
- package/dist/esm/drizzle/text.js.map +1 -0
- package/dist/esm/graphql/graphiql.html.js +59 -0
- package/dist/esm/graphql/graphiql.html.js.map +1 -0
- package/dist/esm/graphql/index.js +934 -0
- package/dist/esm/graphql/index.js.map +1 -0
- package/dist/esm/graphql/json.js +42 -0
- package/dist/esm/graphql/json.js.map +1 -0
- package/dist/esm/graphql/middleware.js +83 -0
- package/dist/esm/graphql/middleware.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/indexing/addStackTrace.js +54 -0
- package/dist/esm/indexing/addStackTrace.js.map +1 -0
- package/dist/esm/indexing/client.js +675 -0
- package/dist/esm/indexing/client.js.map +1 -0
- package/dist/esm/indexing/index.js +663 -0
- package/dist/esm/indexing/index.js.map +1 -0
- package/dist/esm/indexing/profile.js +584 -0
- package/dist/esm/indexing/profile.js.map +1 -0
- package/dist/esm/indexing-store/cache.js +666 -0
- package/dist/esm/indexing-store/cache.js.map +1 -0
- package/dist/esm/indexing-store/index.js +461 -0
- package/dist/esm/indexing-store/index.js.map +1 -0
- package/dist/esm/indexing-store/profile.js +428 -0
- package/dist/esm/indexing-store/profile.js.map +1 -0
- package/dist/esm/indexing-store/utils.js +111 -0
- package/dist/esm/indexing-store/utils.js.map +1 -0
- package/dist/esm/internal/common.js +2 -0
- package/dist/esm/internal/common.js.map +1 -0
- package/dist/esm/internal/errors.js +300 -0
- package/dist/esm/internal/errors.js.map +1 -0
- package/dist/esm/internal/logger.js +178 -0
- package/dist/esm/internal/logger.js.map +1 -0
- package/dist/esm/internal/metrics.js +1049 -0
- package/dist/esm/internal/metrics.js.map +1 -0
- package/dist/esm/internal/options.js +73 -0
- package/dist/esm/internal/options.js.map +1 -0
- package/dist/esm/internal/shutdown.js +24 -0
- package/dist/esm/internal/shutdown.js.map +1 -0
- package/dist/esm/internal/telemetry.js +200 -0
- package/dist/esm/internal/telemetry.js.map +1 -0
- package/dist/esm/internal/types.js +2 -0
- package/dist/esm/internal/types.js.map +1 -0
- package/dist/esm/rpc/actions.js +988 -0
- package/dist/esm/rpc/actions.js.map +1 -0
- package/dist/esm/rpc/http.js +130 -0
- package/dist/esm/rpc/http.js.map +1 -0
- package/dist/esm/rpc/index.js +751 -0
- package/dist/esm/rpc/index.js.map +1 -0
- package/dist/esm/runtime/events.js +664 -0
- package/dist/esm/runtime/events.js.map +1 -0
- package/dist/esm/runtime/filter.js +443 -0
- package/dist/esm/runtime/filter.js.map +1 -0
- package/dist/esm/runtime/fragments.js +478 -0
- package/dist/esm/runtime/fragments.js.map +1 -0
- package/dist/esm/runtime/historical.js +950 -0
- package/dist/esm/runtime/historical.js.map +1 -0
- package/dist/esm/runtime/index.js +316 -0
- package/dist/esm/runtime/index.js.map +1 -0
- package/dist/esm/runtime/isolated.js +463 -0
- package/dist/esm/runtime/isolated.js.map +1 -0
- package/dist/esm/runtime/multichain.js +510 -0
- package/dist/esm/runtime/multichain.js.map +1 -0
- package/dist/esm/runtime/omnichain.js +545 -0
- package/dist/esm/runtime/omnichain.js.map +1 -0
- package/dist/esm/runtime/realtime.js +724 -0
- package/dist/esm/runtime/realtime.js.map +1 -0
- package/dist/esm/server/error.js +56 -0
- package/dist/esm/server/error.js.map +1 -0
- package/dist/esm/server/index.js +121 -0
- package/dist/esm/server/index.js.map +1 -0
- package/dist/esm/sync-historical/index.js +711 -0
- package/dist/esm/sync-historical/index.js.map +1 -0
- package/dist/esm/sync-realtime/bloom.js +76 -0
- package/dist/esm/sync-realtime/bloom.js.map +1 -0
- package/dist/esm/sync-realtime/index.js +928 -0
- package/dist/esm/sync-realtime/index.js.map +1 -0
- package/dist/esm/sync-store/encode.js +105 -0
- package/dist/esm/sync-store/encode.js.map +1 -0
- package/dist/esm/sync-store/index.js +885 -0
- package/dist/esm/sync-store/index.js.map +1 -0
- package/dist/esm/sync-store/migrations.js +1595 -0
- package/dist/esm/sync-store/migrations.js.map +1 -0
- package/dist/esm/sync-store/schema.js +181 -0
- package/dist/esm/sync-store/schema.js.map +1 -0
- package/dist/esm/types/db.js +2 -0
- package/dist/esm/types/db.js.map +1 -0
- package/dist/esm/types/eth.js +2 -0
- package/dist/esm/types/eth.js.map +1 -0
- package/dist/esm/types/utils.js +2 -0
- package/dist/esm/types/utils.js.map +1 -0
- package/dist/esm/types/virtual.js +2 -0
- package/dist/esm/types/virtual.js.map +1 -0
- package/dist/esm/ui/app.js +157 -0
- package/dist/esm/ui/app.js.map +1 -0
- package/dist/esm/ui/index.js +29 -0
- package/dist/esm/ui/index.js.map +1 -0
- package/dist/esm/ui/patch.js +140 -0
- package/dist/esm/ui/patch.js.map +1 -0
- package/dist/esm/utils/abi.js +55 -0
- package/dist/esm/utils/abi.js.map +1 -0
- package/dist/esm/utils/bigint.js +37 -0
- package/dist/esm/utils/bigint.js.map +1 -0
- package/dist/esm/utils/chains.js +21 -0
- package/dist/esm/utils/chains.js.map +1 -0
- package/dist/esm/utils/checkpoint.js +139 -0
- package/dist/esm/utils/checkpoint.js.map +1 -0
- package/dist/esm/utils/chunk.js +8 -0
- package/dist/esm/utils/chunk.js.map +1 -0
- package/dist/esm/utils/copy.js +129 -0
- package/dist/esm/utils/copy.js.map +1 -0
- package/dist/esm/utils/date.js +27 -0
- package/dist/esm/utils/date.js.map +1 -0
- package/dist/esm/utils/debug.js +2 -0
- package/dist/esm/utils/debug.js.map +1 -0
- package/dist/esm/utils/decodeAbiParameters.js +290 -0
- package/dist/esm/utils/decodeAbiParameters.js.map +1 -0
- package/dist/esm/utils/decodeEventLog.js +75 -0
- package/dist/esm/utils/decodeEventLog.js.map +1 -0
- package/dist/esm/utils/dedupe.js +29 -0
- package/dist/esm/utils/dedupe.js.map +1 -0
- package/dist/esm/utils/duplicates.js +19 -0
- package/dist/esm/utils/duplicates.js.map +1 -0
- package/dist/esm/utils/estimate.js +6 -0
- package/dist/esm/utils/estimate.js.map +1 -0
- package/dist/esm/utils/finality.js +38 -0
- package/dist/esm/utils/finality.js.map +1 -0
- package/dist/esm/utils/format.js +20 -0
- package/dist/esm/utils/format.js.map +1 -0
- package/dist/esm/utils/generators.js +121 -0
- package/dist/esm/utils/generators.js.map +1 -0
- package/dist/esm/utils/hash.js +11 -0
- package/dist/esm/utils/hash.js.map +1 -0
- package/dist/esm/utils/interval.js +171 -0
- package/dist/esm/utils/interval.js.map +1 -0
- package/dist/esm/utils/lowercase.js +7 -0
- package/dist/esm/utils/lowercase.js.map +1 -0
- package/dist/esm/utils/mutex.js +26 -0
- package/dist/esm/utils/mutex.js.map +1 -0
- package/dist/esm/utils/never.js +4 -0
- package/dist/esm/utils/never.js.map +1 -0
- package/dist/esm/utils/offset.js +101 -0
- package/dist/esm/utils/offset.js.map +1 -0
- package/dist/esm/utils/order.js +18 -0
- package/dist/esm/utils/order.js.map +1 -0
- package/dist/esm/utils/partition.js +46 -0
- package/dist/esm/utils/partition.js.map +1 -0
- package/dist/esm/utils/pg.js +175 -0
- package/dist/esm/utils/pg.js.map +1 -0
- package/dist/esm/utils/pglite.js +80 -0
- package/dist/esm/utils/pglite.js.map +1 -0
- package/dist/esm/utils/port.js +30 -0
- package/dist/esm/utils/port.js.map +1 -0
- package/dist/esm/utils/print.js +23 -0
- package/dist/esm/utils/print.js.map +1 -0
- package/dist/esm/utils/promiseAllSettledWithThrow.js +19 -0
- package/dist/esm/utils/promiseAllSettledWithThrow.js.map +1 -0
- package/dist/esm/utils/promiseWithResolvers.js +13 -0
- package/dist/esm/utils/promiseWithResolvers.js.map +1 -0
- package/dist/esm/utils/queue.js +150 -0
- package/dist/esm/utils/queue.js.map +1 -0
- package/dist/esm/utils/range.js +8 -0
- package/dist/esm/utils/range.js.map +1 -0
- package/dist/esm/utils/result.js +10 -0
- package/dist/esm/utils/result.js.map +1 -0
- package/dist/esm/utils/sql-parse.js +1326 -0
- package/dist/esm/utils/sql-parse.js.map +1 -0
- package/dist/esm/utils/timer.js +9 -0
- package/dist/esm/utils/timer.js.map +1 -0
- package/dist/esm/utils/truncate.js +15 -0
- package/dist/esm/utils/truncate.js.map +1 -0
- package/dist/esm/utils/wait.js +10 -0
- package/dist/esm/utils/wait.js.map +1 -0
- package/dist/esm/utils/zipper.js +67 -0
- package/dist/esm/utils/zipper.js.map +1 -0
- package/dist/types/bin/commands/codegen.d.ts +5 -0
- package/dist/types/bin/commands/codegen.d.ts.map +1 -0
- package/dist/types/bin/commands/createViews.d.ts +8 -0
- package/dist/types/bin/commands/createViews.d.ts.map +1 -0
- package/dist/types/bin/commands/dev.d.ts +5 -0
- package/dist/types/bin/commands/dev.d.ts.map +1 -0
- package/dist/types/bin/commands/list.d.ts +5 -0
- package/dist/types/bin/commands/list.d.ts.map +1 -0
- package/dist/types/bin/commands/prune.d.ts +5 -0
- package/dist/types/bin/commands/prune.d.ts.map +1 -0
- package/dist/types/bin/commands/serve.d.ts +5 -0
- package/dist/types/bin/commands/serve.d.ts.map +1 -0
- package/dist/types/bin/commands/start.d.ts +19 -0
- package/dist/types/bin/commands/start.d.ts.map +1 -0
- package/dist/types/bin/isolatedController.d.ts +13 -0
- package/dist/types/bin/isolatedController.d.ts.map +1 -0
- package/dist/types/bin/isolatedWorker.d.ts +9 -0
- package/dist/types/bin/isolatedWorker.d.ts.map +1 -0
- package/dist/types/bin/ponder.d.ts +37 -0
- package/dist/types/bin/ponder.d.ts.map +1 -0
- package/dist/types/bin/utils/codegen.d.ts +6 -0
- package/dist/types/bin/utils/codegen.d.ts.map +1 -0
- package/dist/types/bin/utils/exit.d.ts +10 -0
- package/dist/types/bin/utils/exit.d.ts.map +1 -0
- package/dist/types/build/config.d.ts +97 -0
- package/dist/types/build/config.d.ts.map +1 -0
- package/dist/types/build/factory.d.ts +13 -0
- package/dist/types/build/factory.d.ts.map +1 -0
- package/dist/types/build/index.d.ts +84 -0
- package/dist/types/build/index.d.ts.map +1 -0
- package/dist/types/build/plugin.d.ts +4 -0
- package/dist/types/build/plugin.d.ts.map +1 -0
- package/dist/types/build/pre.d.ts +29 -0
- package/dist/types/build/pre.d.ts.map +1 -0
- package/dist/types/build/schema.d.ts +20 -0
- package/dist/types/build/schema.d.ts.map +1 -0
- package/dist/types/build/stacktrace.d.ts +13 -0
- package/dist/types/build/stacktrace.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +27 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/config/address.d.ts +24 -0
- package/dist/types/config/address.d.ts.map +1 -0
- package/dist/types/config/eventFilter.d.ts +18 -0
- package/dist/types/config/eventFilter.d.ts.map +1 -0
- package/dist/types/config/index.d.ts +150 -0
- package/dist/types/config/index.d.ts.map +1 -0
- package/dist/types/config/utilityTypes.d.ts +43 -0
- package/dist/types/config/utilityTypes.d.ts.map +1 -0
- package/dist/types/database/actions.d.ts +99 -0
- package/dist/types/database/actions.d.ts.map +1 -0
- package/dist/types/database/index.d.ts +493 -0
- package/dist/types/database/index.d.ts.map +1 -0
- package/dist/types/database/queryBuilder.d.ts +65 -0
- package/dist/types/database/queryBuilder.d.ts.map +1 -0
- package/dist/types/drizzle/bigint.d.ts +25 -0
- package/dist/types/drizzle/bigint.d.ts.map +1 -0
- package/dist/types/drizzle/bytes.d.ts +31 -0
- package/dist/types/drizzle/bytes.d.ts.map +1 -0
- package/dist/types/drizzle/hex.d.ts +25 -0
- package/dist/types/drizzle/hex.d.ts.map +1 -0
- package/dist/types/drizzle/index.d.ts +6 -0
- package/dist/types/drizzle/index.d.ts.map +1 -0
- package/dist/types/drizzle/json.d.ts +51 -0
- package/dist/types/drizzle/json.d.ts.map +1 -0
- package/dist/types/drizzle/kit/index.d.ts +187 -0
- package/dist/types/drizzle/kit/index.d.ts.map +1 -0
- package/dist/types/drizzle/onchain.d.ts +298 -0
- package/dist/types/drizzle/onchain.d.ts.map +1 -0
- package/dist/types/drizzle/text.d.ts +29 -0
- package/dist/types/drizzle/text.d.ts.map +1 -0
- package/dist/types/graphql/graphiql.html.d.ts +2 -0
- package/dist/types/graphql/graphiql.html.d.ts.map +1 -0
- package/dist/types/graphql/index.d.ts +12 -0
- package/dist/types/graphql/index.d.ts.map +1 -0
- package/dist/types/graphql/json.d.ts +3 -0
- package/dist/types/graphql/json.d.ts.map +1 -0
- package/dist/types/graphql/middleware.d.ts +29 -0
- package/dist/types/graphql/middleware.d.ts.map +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/indexing/addStackTrace.d.ts +3 -0
- package/dist/types/indexing/addStackTrace.d.ts.map +1 -0
- package/dist/types/indexing/client.d.ts +154 -0
- package/dist/types/indexing/client.d.ts.map +1 -0
- package/dist/types/indexing/index.d.ts +72 -0
- package/dist/types/indexing/index.d.ts.map +1 -0
- package/dist/types/indexing/profile.d.ts +16 -0
- package/dist/types/indexing/profile.d.ts.map +1 -0
- package/dist/types/indexing-store/cache.d.ts +115 -0
- package/dist/types/indexing-store/cache.d.ts.map +1 -0
- package/dist/types/indexing-store/index.d.ts +24 -0
- package/dist/types/indexing-store/index.d.ts.map +1 -0
- package/dist/types/indexing-store/profile.d.ts +7 -0
- package/dist/types/indexing-store/profile.d.ts.map +1 -0
- package/dist/types/indexing-store/utils.d.ts +19 -0
- package/dist/types/indexing-store/utils.d.ts.map +1 -0
- package/dist/types/internal/common.d.ts +15 -0
- package/dist/types/internal/common.d.ts.map +1 -0
- package/dist/types/internal/errors.d.ts +101 -0
- package/dist/types/internal/errors.d.ts.map +1 -0
- package/dist/types/internal/logger.d.ts +37 -0
- package/dist/types/internal/logger.d.ts.map +1 -0
- package/dist/types/internal/metrics.d.ts +120 -0
- package/dist/types/internal/metrics.d.ts.map +1 -0
- package/dist/types/internal/options.d.ts +62 -0
- package/dist/types/internal/options.d.ts.map +1 -0
- package/dist/types/internal/shutdown.d.ts +8 -0
- package/dist/types/internal/shutdown.d.ts.map +1 -0
- package/dist/types/internal/telemetry.d.ts +43 -0
- package/dist/types/internal/telemetry.d.ts.map +1 -0
- package/dist/types/internal/types.d.ts +434 -0
- package/dist/types/internal/types.d.ts.map +1 -0
- package/dist/types/rpc/actions.d.ts +360 -0
- package/dist/types/rpc/actions.d.ts.map +1 -0
- package/dist/types/rpc/http.d.ts +17 -0
- package/dist/types/rpc/http.d.ts.map +1 -0
- package/dist/types/rpc/index.d.ts +43 -0
- package/dist/types/rpc/index.d.ts.map +1 -0
- package/dist/types/runtime/events.d.ts +40 -0
- package/dist/types/runtime/events.d.ts.map +1 -0
- package/dist/types/runtime/filter.d.ts +87 -0
- package/dist/types/runtime/filter.d.ts.map +1 -0
- package/dist/types/runtime/fragments.d.ts +30 -0
- package/dist/types/runtime/fragments.d.ts.map +1 -0
- package/dist/types/runtime/historical.d.ts +123 -0
- package/dist/types/runtime/historical.d.ts.map +1 -0
- package/dist/types/runtime/index.d.ts +89 -0
- package/dist/types/runtime/index.d.ts.map +1 -0
- package/dist/types/runtime/isolated.d.ts +14 -0
- package/dist/types/runtime/isolated.d.ts.map +1 -0
- package/dist/types/runtime/multichain.d.ts +13 -0
- package/dist/types/runtime/multichain.d.ts.map +1 -0
- package/dist/types/runtime/omnichain.d.ts +23 -0
- package/dist/types/runtime/omnichain.d.ts.map +1 -0
- package/dist/types/runtime/realtime.d.ts +93 -0
- package/dist/types/runtime/realtime.d.ts.map +1 -0
- package/dist/types/server/error.d.ts +5 -0
- package/dist/types/server/error.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +13 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/sync-historical/index.d.ts +36 -0
- package/dist/types/sync-historical/index.d.ts.map +1 -0
- package/dist/types/sync-realtime/bloom.d.ts +18 -0
- package/dist/types/sync-realtime/bloom.d.ts.map +1 -0
- package/dist/types/sync-realtime/index.d.ts +47 -0
- package/dist/types/sync-realtime/index.d.ts.map +1 -0
- package/dist/types/sync-store/encode.d.ts +25 -0
- package/dist/types/sync-store/encode.d.ts.map +1 -0
- package/dist/types/sync-store/index.d.ts +135 -0
- package/dist/types/sync-store/index.d.ts.map +1 -0
- package/dist/types/sync-store/migrations.d.ts +8 -0
- package/dist/types/sync-store/migrations.d.ts.map +1 -0
- package/dist/types/sync-store/schema.d.ts +1828 -0
- package/dist/types/sync-store/schema.d.ts.map +1 -0
- package/dist/types/types/db.d.ts +213 -0
- package/dist/types/types/db.d.ts.map +1 -0
- package/dist/types/types/eth.d.ts +196 -0
- package/dist/types/types/eth.d.ts.map +1 -0
- package/dist/types/types/utils.d.ts +38 -0
- package/dist/types/types/utils.d.ts.map +1 -0
- package/dist/types/types/virtual.d.ts +99 -0
- package/dist/types/types/virtual.d.ts.map +1 -0
- package/dist/types/ui/app.d.ts +22 -0
- package/dist/types/ui/app.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +5 -0
- package/dist/types/ui/index.d.ts.map +1 -0
- package/dist/types/ui/patch.d.ts +7 -0
- package/dist/types/ui/patch.d.ts.map +1 -0
- package/dist/types/utils/abi.d.ts +23 -0
- package/dist/types/utils/abi.d.ts.map +1 -0
- package/dist/types/utils/bigint.d.ts +15 -0
- package/dist/types/utils/bigint.d.ts.map +1 -0
- package/dist/types/utils/chains.d.ts +42 -0
- package/dist/types/utils/chains.d.ts.map +1 -0
- package/dist/types/utils/checkpoint.d.ts +52 -0
- package/dist/types/utils/checkpoint.d.ts.map +1 -0
- package/dist/types/utils/chunk.d.ts +2 -0
- package/dist/types/utils/chunk.d.ts.map +1 -0
- package/dist/types/utils/copy.d.ts +16 -0
- package/dist/types/utils/copy.d.ts.map +1 -0
- package/dist/types/utils/date.d.ts +7 -0
- package/dist/types/utils/date.d.ts.map +1 -0
- package/dist/types/utils/debug.d.ts +105 -0
- package/dist/types/utils/debug.d.ts.map +1 -0
- package/dist/types/utils/decodeAbiParameters.d.ts +28 -0
- package/dist/types/utils/decodeAbiParameters.d.ts.map +1 -0
- package/dist/types/utils/decodeEventLog.d.ts +12 -0
- package/dist/types/utils/decodeEventLog.d.ts.map +1 -0
- package/dist/types/utils/dedupe.d.ts +20 -0
- package/dist/types/utils/dedupe.d.ts.map +1 -0
- package/dist/types/utils/duplicates.d.ts +7 -0
- package/dist/types/utils/duplicates.d.ts.map +1 -0
- package/dist/types/utils/estimate.d.ts +11 -0
- package/dist/types/utils/estimate.d.ts.map +1 -0
- package/dist/types/utils/finality.d.ts +12 -0
- package/dist/types/utils/finality.d.ts.map +1 -0
- package/dist/types/utils/format.d.ts +3 -0
- package/dist/types/utils/format.d.ts.map +1 -0
- package/dist/types/utils/generators.d.ts +42 -0
- package/dist/types/utils/generators.d.ts.map +1 -0
- package/dist/types/utils/hash.d.ts +11 -0
- package/dist/types/utils/hash.d.ts.map +1 -0
- package/dist/types/utils/interval.d.ts +53 -0
- package/dist/types/utils/interval.d.ts.map +1 -0
- package/dist/types/utils/lowercase.d.ts +5 -0
- package/dist/types/utils/lowercase.d.ts.map +1 -0
- package/dist/types/utils/mutex.d.ts +5 -0
- package/dist/types/utils/mutex.d.ts.map +1 -0
- package/dist/types/utils/never.d.ts +2 -0
- package/dist/types/utils/never.d.ts.map +1 -0
- package/dist/types/utils/offset.d.ts +8 -0
- package/dist/types/utils/offset.d.ts.map +1 -0
- package/dist/types/utils/order.d.ts +2 -0
- package/dist/types/utils/order.d.ts.map +1 -0
- package/dist/types/utils/partition.d.ts +22 -0
- package/dist/types/utils/partition.d.ts.map +1 -0
- package/dist/types/utils/pg.d.ts +8 -0
- package/dist/types/utils/pg.d.ts.map +1 -0
- package/dist/types/utils/pglite.d.ts +25 -0
- package/dist/types/utils/pglite.d.ts.map +1 -0
- package/dist/types/utils/port.d.ts +5 -0
- package/dist/types/utils/port.d.ts.map +1 -0
- package/dist/types/utils/print.d.ts +2 -0
- package/dist/types/utils/print.d.ts.map +1 -0
- package/dist/types/utils/promiseAllSettledWithThrow.d.ts +8 -0
- package/dist/types/utils/promiseAllSettledWithThrow.d.ts.map +1 -0
- package/dist/types/utils/promiseWithResolvers.d.ts +10 -0
- package/dist/types/utils/promiseWithResolvers.d.ts.map +1 -0
- package/dist/types/utils/queue.d.ts +33 -0
- package/dist/types/utils/queue.d.ts.map +1 -0
- package/dist/types/utils/range.d.ts +8 -0
- package/dist/types/utils/range.d.ts.map +1 -0
- package/dist/types/utils/result.d.ts +17 -0
- package/dist/types/utils/result.d.ts.map +1 -0
- package/dist/types/utils/sql-parse.d.ts +21 -0
- package/dist/types/utils/sql-parse.d.ts.map +1 -0
- package/dist/types/utils/timer.d.ts +6 -0
- package/dist/types/utils/timer.d.ts.map +1 -0
- package/dist/types/utils/truncate.d.ts +9 -0
- package/dist/types/utils/truncate.d.ts.map +1 -0
- package/dist/types/utils/wait.d.ts +6 -0
- package/dist/types/utils/wait.d.ts.map +1 -0
- package/dist/types/utils/zipper.d.ts +36 -0
- package/dist/types/utils/zipper.d.ts.map +1 -0
- package/package.json +114 -0
- package/src/bin/commands/codegen.ts +56 -0
- package/src/bin/commands/createViews.ts +318 -0
- package/src/bin/commands/dev.ts +490 -0
- package/src/bin/commands/list.ts +208 -0
- package/src/bin/commands/prune.ts +322 -0
- package/src/bin/commands/serve.ts +236 -0
- package/src/bin/commands/start.ts +319 -0
- package/src/bin/isolatedController.ts +300 -0
- package/src/bin/isolatedWorker.ts +192 -0
- package/src/bin/ponder.ts +208 -0
- package/src/bin/utils/codegen.ts +32 -0
- package/src/bin/utils/exit.ts +112 -0
- package/src/build/config.ts +1142 -0
- package/src/build/factory.ts +122 -0
- package/src/build/index.ts +790 -0
- package/src/build/plugin.ts +58 -0
- package/src/build/pre.ts +114 -0
- package/src/build/schema.ts +358 -0
- package/src/build/stacktrace.ts +137 -0
- package/src/client/index.ts +551 -0
- package/src/config/address.ts +32 -0
- package/src/config/eventFilter.ts +33 -0
- package/src/config/index.ts +246 -0
- package/src/config/utilityTypes.ts +152 -0
- package/src/database/actions.ts +873 -0
- package/src/database/index.ts +1029 -0
- package/src/database/queryBuilder.ts +537 -0
- package/src/drizzle/bigint.ts +57 -0
- package/src/drizzle/bytes.ts +68 -0
- package/src/drizzle/hex.ts +58 -0
- package/src/drizzle/index.ts +40 -0
- package/src/drizzle/json.ts +159 -0
- package/src/drizzle/kit/index.ts +1348 -0
- package/src/drizzle/onchain.ts +476 -0
- package/src/drizzle/text.ts +77 -0
- package/src/graphql/graphiql.html.ts +59 -0
- package/src/graphql/index.ts +1351 -0
- package/src/graphql/json.ts +62 -0
- package/src/graphql/middleware.ts +115 -0
- package/src/index.ts +139 -0
- package/src/indexing/addStackTrace.ts +69 -0
- package/src/indexing/client.ts +1184 -0
- package/src/indexing/index.ts +976 -0
- package/src/indexing/profile.ts +771 -0
- package/src/indexing-store/cache.ts +1057 -0
- package/src/indexing-store/index.ts +628 -0
- package/src/indexing-store/profile.ts +557 -0
- package/src/indexing-store/utils.ts +162 -0
- package/src/internal/common.ts +15 -0
- package/src/internal/errors.ts +228 -0
- package/src/internal/logger.ts +252 -0
- package/src/internal/metrics.ts +1030 -0
- package/src/internal/options.ts +130 -0
- package/src/internal/shutdown.ts +32 -0
- package/src/internal/telemetry.ts +303 -0
- package/src/internal/types.ts +597 -0
- package/src/rpc/actions.ts +1344 -0
- package/src/rpc/http.ts +164 -0
- package/src/rpc/index.ts +961 -0
- package/src/runtime/events.ts +875 -0
- package/src/runtime/filter.ts +664 -0
- package/src/runtime/fragments.ts +674 -0
- package/src/runtime/historical.ts +1509 -0
- package/src/runtime/index.ts +569 -0
- package/src/runtime/isolated.ts +778 -0
- package/src/runtime/multichain.ts +860 -0
- package/src/runtime/omnichain.ts +920 -0
- package/src/runtime/realtime.ts +1166 -0
- package/src/server/error.ts +68 -0
- package/src/server/index.ts +173 -0
- package/src/sync-historical/index.ts +1072 -0
- package/src/sync-realtime/bloom.ts +102 -0
- package/src/sync-realtime/index.ts +1312 -0
- package/src/sync-store/encode.ts +153 -0
- package/src/sync-store/index.ts +1633 -0
- package/src/sync-store/migrations.ts +1801 -0
- package/src/sync-store/schema.ts +248 -0
- package/src/types/db.ts +292 -0
- package/src/types/eth.ts +216 -0
- package/src/types/utils.ts +47 -0
- package/src/types/virtual.ts +244 -0
- package/src/types.d.ts +38 -0
- package/src/ui/app.ts +207 -0
- package/src/ui/index.ts +37 -0
- package/src/ui/patch.ts +204 -0
- package/src/utils/abi.ts +103 -0
- package/src/utils/bigint.ts +41 -0
- package/src/utils/chains.ts +22 -0
- package/src/utils/checkpoint.ts +203 -0
- package/src/utils/chunk.ts +7 -0
- package/src/utils/copy.ts +151 -0
- package/src/utils/date.ts +26 -0
- package/src/utils/debug.ts +110 -0
- package/src/utils/decodeAbiParameters.ts +428 -0
- package/src/utils/decodeEventLog.ts +100 -0
- package/src/utils/dedupe.ts +32 -0
- package/src/utils/duplicates.ts +19 -0
- package/src/utils/estimate.ts +27 -0
- package/src/utils/finality.ts +40 -0
- package/src/utils/format.ts +22 -0
- package/src/utils/generators.ts +157 -0
- package/src/utils/hash.ts +22 -0
- package/src/utils/interval.ts +212 -0
- package/src/utils/lowercase.ts +6 -0
- package/src/utils/mutex.ts +33 -0
- package/src/utils/never.ts +3 -0
- package/src/utils/offset.ts +133 -0
- package/src/utils/order.ts +16 -0
- package/src/utils/partition.ts +53 -0
- package/src/utils/pg.ts +230 -0
- package/src/utils/pglite.ts +97 -0
- package/src/utils/port.ts +34 -0
- package/src/utils/print.ts +31 -0
- package/src/utils/promiseAllSettledWithThrow.ts +27 -0
- package/src/utils/promiseWithResolvers.ts +20 -0
- package/src/utils/queue.ts +258 -0
- package/src/utils/range.ts +8 -0
- package/src/utils/result.ts +26 -0
- package/src/utils/sql-parse.ts +1477 -0
- package/src/utils/timer.ts +8 -0
- package/src/utils/truncate.ts +15 -0
- package/src/utils/wait.ts +8 -0
- package/src/utils/zipper.ts +80 -0
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
import { dedupe } from '../utils/dedupe.js';
|
|
2
|
+
import { toLowerCase } from '../utils/lowercase.js';
|
|
3
|
+
import { orderObject } from '../utils/order.js';
|
|
4
|
+
import { startClock } from '../utils/timer.js';
|
|
5
|
+
import { wait } from '../utils/wait.js';
|
|
6
|
+
import { BlockNotFoundError, TransactionNotFoundError, TransactionReceiptNotFoundError, createClient, custom, decodeFunctionData, decodeFunctionResult, encodeFunctionData, encodeFunctionResult, getAbiItem, hexToNumber, multicall3Abi, publicActions, toFunctionSelector, toHex, } from "viem";
|
|
7
|
+
import { getProfilePatternKey, recordProfilePattern, recoverProfilePattern, } from "./profile.js";
|
|
8
|
+
const MULTICALL_SELECTOR = toFunctionSelector(getAbiItem({ abi: multicall3Abi, name: "aggregate3" }));
|
|
9
|
+
const SAMPLING_RATE = 10;
|
|
10
|
+
const DB_PREDICTION_THRESHOLD = 0.2;
|
|
11
|
+
const RPC_PREDICTION_THRESHOLD = 0.8;
|
|
12
|
+
const MAX_CONSTANT_PATTERN_COUNT = 10;
|
|
13
|
+
/**
|
|
14
|
+
* RPC responses that are not cached. These are valid responses
|
|
15
|
+
* that are sometimes erroneously returned by the RPC.
|
|
16
|
+
*
|
|
17
|
+
* `"0x"` is returned by `eth_call` and causes the `ContractFunctionZeroDataError`.
|
|
18
|
+
* `null` is returned by `eth_getBlockByNumber` and `eth_getBlockByHash` and causes the `BlockNotFoundError`.
|
|
19
|
+
*/
|
|
20
|
+
const UNCACHED_RESPONSES = ["0x", null];
|
|
21
|
+
/** RPC methods that reference a block number. */
|
|
22
|
+
const blockDependentMethods = new Set([
|
|
23
|
+
"eth_getBalance",
|
|
24
|
+
"eth_getTransactionCount",
|
|
25
|
+
"eth_getBlockByNumber",
|
|
26
|
+
"eth_getBlockTransactionCountByNumber",
|
|
27
|
+
"eth_getTransactionByBlockNumberAndIndex",
|
|
28
|
+
"eth_call",
|
|
29
|
+
"eth_estimateGas",
|
|
30
|
+
"eth_feeHistory",
|
|
31
|
+
"eth_getProof",
|
|
32
|
+
"eth_getCode",
|
|
33
|
+
"eth_getStorageAt",
|
|
34
|
+
"eth_getUncleByBlockNumberAndIndex",
|
|
35
|
+
"debug_traceBlockByNumber",
|
|
36
|
+
]);
|
|
37
|
+
/** RPC methods that don't reference a block number. */
|
|
38
|
+
const nonBlockDependentMethods = new Set([
|
|
39
|
+
"eth_getBlockByHash",
|
|
40
|
+
"eth_getTransactionByHash",
|
|
41
|
+
"eth_getBlockTransactionCountByHash",
|
|
42
|
+
"eth_getTransactionByBlockHashAndIndex",
|
|
43
|
+
"eth_getTransactionConfirmations",
|
|
44
|
+
"eth_getTransactionReceipt",
|
|
45
|
+
"eth_getUncleByBlockHashAndIndex",
|
|
46
|
+
"eth_getUncleCountByBlockHash",
|
|
47
|
+
"debug_traceBlockByHash",
|
|
48
|
+
"debug_traceTransaction",
|
|
49
|
+
"debug_traceCall",
|
|
50
|
+
]);
|
|
51
|
+
/** Viem actions where the `block` property is optional and implicit. */
|
|
52
|
+
const blockDependentActions = [
|
|
53
|
+
"getBalance",
|
|
54
|
+
"call",
|
|
55
|
+
"estimateGas",
|
|
56
|
+
"getFeeHistory",
|
|
57
|
+
"getProof",
|
|
58
|
+
"getCode",
|
|
59
|
+
"getStorageAt",
|
|
60
|
+
"getEnsAddress",
|
|
61
|
+
"getEnsAvatar",
|
|
62
|
+
"getEnsName",
|
|
63
|
+
"getEnsResolver",
|
|
64
|
+
"getEnsText",
|
|
65
|
+
"readContract",
|
|
66
|
+
"multicall",
|
|
67
|
+
"simulateContract",
|
|
68
|
+
];
|
|
69
|
+
/** Viem actions where the `block` property is required. */
|
|
70
|
+
const blockRequiredActions = [
|
|
71
|
+
"getBlock",
|
|
72
|
+
"getTransactionCount",
|
|
73
|
+
"getBlockTransactionCount",
|
|
74
|
+
];
|
|
75
|
+
/** Viem actions where the `block` property is non-existent. */
|
|
76
|
+
const nonBlockDependentActions = [
|
|
77
|
+
"getTransaction",
|
|
78
|
+
"getTransactionReceipt",
|
|
79
|
+
"getTransactionConfirmations",
|
|
80
|
+
];
|
|
81
|
+
/** Viem actions that should be retried if they fail. */
|
|
82
|
+
const retryableActions = [
|
|
83
|
+
"readContract",
|
|
84
|
+
"simulateContract",
|
|
85
|
+
"multicall",
|
|
86
|
+
"getBlock",
|
|
87
|
+
"getTransaction",
|
|
88
|
+
"getTransactionReceipt",
|
|
89
|
+
"getTransactionConfirmations",
|
|
90
|
+
];
|
|
91
|
+
export const getCacheKey = (request) => {
|
|
92
|
+
return toLowerCase(JSON.stringify(orderObject(request)));
|
|
93
|
+
};
|
|
94
|
+
export const encodeRequest = (request) => ({
|
|
95
|
+
method: "eth_call",
|
|
96
|
+
params: [
|
|
97
|
+
{
|
|
98
|
+
to: request.address,
|
|
99
|
+
data: encodeFunctionData({
|
|
100
|
+
abi: request.abi,
|
|
101
|
+
functionName: request.functionName,
|
|
102
|
+
args: request.args,
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
request.blockNumber === "latest" ? "latest" : toHex(request.blockNumber),
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
export const decodeResponse = (response) => {
|
|
109
|
+
// Note: I don't actually remember why we had to add the try catch.
|
|
110
|
+
try {
|
|
111
|
+
return JSON.parse(response);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return response;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
export const createCachedViemClient = ({ common, indexingBuild, syncStore, eventCount, }) => {
|
|
118
|
+
let event = undefined;
|
|
119
|
+
const cache = new Map();
|
|
120
|
+
const profile = new Map();
|
|
121
|
+
const profileConstantLRU = new Map();
|
|
122
|
+
for (const chain of indexingBuild.chains) {
|
|
123
|
+
cache.set(chain.id, new Map());
|
|
124
|
+
}
|
|
125
|
+
const ponderActions = (client) => {
|
|
126
|
+
const actions = {};
|
|
127
|
+
const _publicActions = publicActions(client);
|
|
128
|
+
const addProfilePattern = ({ pattern, hasConstant, }) => {
|
|
129
|
+
const profilePatternKey = getProfilePatternKey(pattern);
|
|
130
|
+
const eventName = event.eventCallback.name;
|
|
131
|
+
if (profile.get(eventName).has(profilePatternKey)) {
|
|
132
|
+
profile.get(eventName).get(profilePatternKey).count++;
|
|
133
|
+
if (hasConstant) {
|
|
134
|
+
profileConstantLRU.get(eventName).delete(profilePatternKey);
|
|
135
|
+
profileConstantLRU.get(eventName).add(profilePatternKey);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
profile
|
|
140
|
+
.get(eventName)
|
|
141
|
+
.set(profilePatternKey, { pattern, hasConstant, count: 1 });
|
|
142
|
+
if (hasConstant) {
|
|
143
|
+
profileConstantLRU.get(eventName).add(profilePatternKey);
|
|
144
|
+
if (profileConstantLRU.get(eventName).size > MAX_CONSTANT_PATTERN_COUNT) {
|
|
145
|
+
const firstKey = profileConstantLRU
|
|
146
|
+
.get(eventName)
|
|
147
|
+
.keys()
|
|
148
|
+
.next().value;
|
|
149
|
+
if (firstKey) {
|
|
150
|
+
profile.get(eventName).delete(firstKey);
|
|
151
|
+
profileConstantLRU.get(eventName).delete(firstKey);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const getPonderAction = (action) => {
|
|
158
|
+
return ({ cache, blockNumber: userBlockNumber, ...args }) => {
|
|
159
|
+
// Note: prediction only possible when block number is managed by Ponder.
|
|
160
|
+
if (event.type !== "setup" &&
|
|
161
|
+
userBlockNumber === undefined &&
|
|
162
|
+
eventCount[event.eventCallback.name] % SAMPLING_RATE === 1) {
|
|
163
|
+
const eventName = event.eventCallback.name;
|
|
164
|
+
if (profile.has(eventName) === false) {
|
|
165
|
+
profile.set(eventName, new Map());
|
|
166
|
+
profileConstantLRU.set(eventName, new Set());
|
|
167
|
+
}
|
|
168
|
+
// profile "readContract" and "multicall" actions
|
|
169
|
+
if (action === "readContract") {
|
|
170
|
+
const recordPatternResult = recordProfilePattern({
|
|
171
|
+
event: event,
|
|
172
|
+
args: { ...args, cache },
|
|
173
|
+
hints: Array.from(profile.get(eventName).values()),
|
|
174
|
+
});
|
|
175
|
+
if (recordPatternResult) {
|
|
176
|
+
addProfilePattern(recordPatternResult);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (action === "multicall") {
|
|
180
|
+
const contracts = { ...args, cache }.contracts;
|
|
181
|
+
if (contracts.length < 10) {
|
|
182
|
+
for (const contract of contracts) {
|
|
183
|
+
const recordPatternResult = recordProfilePattern({
|
|
184
|
+
event: event,
|
|
185
|
+
args: contract,
|
|
186
|
+
hints: Array.from(profile.get(eventName).values()),
|
|
187
|
+
});
|
|
188
|
+
if (recordPatternResult) {
|
|
189
|
+
addProfilePattern(recordPatternResult);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const blockNumber = event.type === "setup" ? event.block : event.event.block.number;
|
|
196
|
+
// @ts-expect-error
|
|
197
|
+
return _publicActions[action]({
|
|
198
|
+
...args,
|
|
199
|
+
...(cache === "immutable"
|
|
200
|
+
? { blockTag: "latest" }
|
|
201
|
+
: { blockNumber: userBlockNumber ?? blockNumber }),
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
const getRetryAction = (action, actionName) => {
|
|
206
|
+
return async (...args) => {
|
|
207
|
+
const RETRY_COUNT = 9;
|
|
208
|
+
const BASE_DURATION = 125;
|
|
209
|
+
for (let i = 0; i <= RETRY_COUNT; i++) {
|
|
210
|
+
try {
|
|
211
|
+
// @ts-ignore
|
|
212
|
+
return await action(...args);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
const eventName = event.type === "setup"
|
|
216
|
+
? event.setupCallback.name
|
|
217
|
+
: event.eventCallback.name;
|
|
218
|
+
if ((error instanceof BlockNotFoundError === false &&
|
|
219
|
+
error instanceof TransactionNotFoundError === false &&
|
|
220
|
+
error instanceof TransactionReceiptNotFoundError === false &&
|
|
221
|
+
// Note: Another way to catch this error is:
|
|
222
|
+
// `error instanceof ContractFunctionExecutionError && error.cause instanceOf ContractFunctionZeroDataError`
|
|
223
|
+
error?.message?.includes("returned no data") ===
|
|
224
|
+
false) ||
|
|
225
|
+
i === RETRY_COUNT ||
|
|
226
|
+
args[0].retryEmptyResponse === false) {
|
|
227
|
+
const chain = indexingBuild.chains.find((n) => n.id === event.chain.id);
|
|
228
|
+
common.logger.warn({
|
|
229
|
+
msg: "Failed 'context.client' action",
|
|
230
|
+
action: actionName,
|
|
231
|
+
event: eventName,
|
|
232
|
+
chain: chain.name,
|
|
233
|
+
chain_id: chain.id,
|
|
234
|
+
retry_count: i,
|
|
235
|
+
error: error,
|
|
236
|
+
});
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
const duration = BASE_DURATION * 2 ** i;
|
|
240
|
+
const chain = indexingBuild.chains.find((n) => n.id === event.chain.id);
|
|
241
|
+
common.logger.warn({
|
|
242
|
+
msg: "Failed 'context.client' action",
|
|
243
|
+
action: actionName,
|
|
244
|
+
event: eventName,
|
|
245
|
+
chain: chain.name,
|
|
246
|
+
chain_id: chain.id,
|
|
247
|
+
retry_count: i,
|
|
248
|
+
retry_delay: duration,
|
|
249
|
+
error: error,
|
|
250
|
+
});
|
|
251
|
+
await wait(duration);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
for (const action of blockDependentActions) {
|
|
257
|
+
actions[action] = getPonderAction(action);
|
|
258
|
+
}
|
|
259
|
+
for (const action of nonBlockDependentActions) {
|
|
260
|
+
// @ts-ignore
|
|
261
|
+
actions[action] = _publicActions[action];
|
|
262
|
+
}
|
|
263
|
+
for (const action of blockRequiredActions) {
|
|
264
|
+
// @ts-ignore
|
|
265
|
+
actions[action] = _publicActions[action];
|
|
266
|
+
}
|
|
267
|
+
for (const action of retryableActions) {
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
actions[action] = getRetryAction(actions[action], action);
|
|
270
|
+
}
|
|
271
|
+
const actionsWithMetrics = {};
|
|
272
|
+
for (const [action, actionFn] of Object.entries(actions)) {
|
|
273
|
+
// @ts-ignore
|
|
274
|
+
actionsWithMetrics[action] = async (...args) => {
|
|
275
|
+
const endClock = startClock();
|
|
276
|
+
try {
|
|
277
|
+
// @ts-ignore
|
|
278
|
+
return await actionFn(...args);
|
|
279
|
+
}
|
|
280
|
+
finally {
|
|
281
|
+
common.metrics.ponder_indexing_rpc_action_duration.observe({ action }, endClock());
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return actionsWithMetrics;
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
getClient(chain) {
|
|
289
|
+
const rpc = indexingBuild.rpcs[indexingBuild.chains.findIndex((n) => n === chain)];
|
|
290
|
+
return createClient({
|
|
291
|
+
transport: cachedTransport({
|
|
292
|
+
common,
|
|
293
|
+
chain,
|
|
294
|
+
rpc,
|
|
295
|
+
syncStore,
|
|
296
|
+
cache,
|
|
297
|
+
event: () => event,
|
|
298
|
+
}),
|
|
299
|
+
chain: chain.viemChain,
|
|
300
|
+
// @ts-expect-error overriding `readContract` is not supported by viem
|
|
301
|
+
}).extend(ponderActions);
|
|
302
|
+
},
|
|
303
|
+
async prefetch({ events }) {
|
|
304
|
+
const context = {
|
|
305
|
+
logger: common.logger.child({ action: "prefetch_rpc_requests" }),
|
|
306
|
+
};
|
|
307
|
+
const prefetchEndClock = startClock();
|
|
308
|
+
// Use profiling metadata + next event batch to determine which
|
|
309
|
+
// rpc requests are going to be made, and preload them into the cache.
|
|
310
|
+
const prediction = [];
|
|
311
|
+
for (const event of events) {
|
|
312
|
+
if (profile.has(event.eventCallback.name)) {
|
|
313
|
+
for (const [, { pattern, count }] of profile.get(event.eventCallback.name)) {
|
|
314
|
+
// Expected value of times the prediction will be used.
|
|
315
|
+
const ev = (count * SAMPLING_RATE) / eventCount[event.eventCallback.name];
|
|
316
|
+
prediction.push({
|
|
317
|
+
ev,
|
|
318
|
+
request: recoverProfilePattern(pattern, event),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const chainRequests = new Map();
|
|
324
|
+
for (const chain of indexingBuild.chains) {
|
|
325
|
+
chainRequests.set(chain.id, []);
|
|
326
|
+
}
|
|
327
|
+
for (const { ev, request } of dedupe(prediction, ({ request }) => getCacheKey(encodeRequest(request)))) {
|
|
328
|
+
chainRequests.get(request.chainId).push({
|
|
329
|
+
ev,
|
|
330
|
+
request: encodeRequest(request),
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
await Promise.all(Array.from(chainRequests.entries()).map(async ([chainId, requests]) => {
|
|
334
|
+
const i = indexingBuild.chains.findIndex((n) => n.id === chainId);
|
|
335
|
+
const chain = indexingBuild.chains[i];
|
|
336
|
+
const rpc = indexingBuild.rpcs[i];
|
|
337
|
+
const dbRequests = requests.filter(({ ev }) => ev > DB_PREDICTION_THRESHOLD);
|
|
338
|
+
common.metrics.ponder_indexing_rpc_prefetch_total.inc({
|
|
339
|
+
chain: chain.name,
|
|
340
|
+
method: "eth_call",
|
|
341
|
+
type: "database",
|
|
342
|
+
}, dbRequests.length);
|
|
343
|
+
const cachedResults = await syncStore.getRpcRequestResults({
|
|
344
|
+
requests: dbRequests.map(({ request }) => request),
|
|
345
|
+
chainId,
|
|
346
|
+
}, context);
|
|
347
|
+
for (let i = 0; i < dbRequests.length; i++) {
|
|
348
|
+
const request = dbRequests[i];
|
|
349
|
+
const cachedResult = cachedResults[i];
|
|
350
|
+
if (cachedResult !== undefined) {
|
|
351
|
+
cache
|
|
352
|
+
.get(chainId)
|
|
353
|
+
.set(getCacheKey(request.request), cachedResult);
|
|
354
|
+
}
|
|
355
|
+
else if (request.ev > RPC_PREDICTION_THRESHOLD) {
|
|
356
|
+
const resultPromise = rpc
|
|
357
|
+
.request(request.request, context)
|
|
358
|
+
.then((result) => JSON.stringify(result))
|
|
359
|
+
.catch((error) => error);
|
|
360
|
+
common.metrics.ponder_indexing_rpc_prefetch_total.inc({
|
|
361
|
+
chain: chain.name,
|
|
362
|
+
method: "eth_call",
|
|
363
|
+
type: "rpc",
|
|
364
|
+
});
|
|
365
|
+
// Note: Unawaited request added to cache
|
|
366
|
+
cache
|
|
367
|
+
.get(chainId)
|
|
368
|
+
.set(getCacheKey(request.request), resultPromise);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (dbRequests.length > 0) {
|
|
372
|
+
common.logger.debug({
|
|
373
|
+
msg: "Prefetched JSON-RPC requests",
|
|
374
|
+
chain: chain.name,
|
|
375
|
+
chain_id: chain.id,
|
|
376
|
+
request_count: dbRequests.length,
|
|
377
|
+
duration: prefetchEndClock(),
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}));
|
|
381
|
+
},
|
|
382
|
+
clear() {
|
|
383
|
+
for (const chain of indexingBuild.chains) {
|
|
384
|
+
cache.get(chain.id).clear();
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
set event(_event) {
|
|
388
|
+
event = _event;
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
export const cachedTransport = ({ common, chain, rpc, syncStore, cache, event, }) => ({ chain: viemChain }) => custom({
|
|
393
|
+
async request({ method, params }) {
|
|
394
|
+
const _event = event();
|
|
395
|
+
const context = {
|
|
396
|
+
logger: common.logger.child({
|
|
397
|
+
action: "cache JSON-RPC request",
|
|
398
|
+
event: _event.type === "setup"
|
|
399
|
+
? _event.setupCallback.name
|
|
400
|
+
: _event.eventCallback.name,
|
|
401
|
+
}),
|
|
402
|
+
};
|
|
403
|
+
const body = { method, params };
|
|
404
|
+
// multicall
|
|
405
|
+
if (method === "eth_call" &&
|
|
406
|
+
params[0]?.data?.startsWith(MULTICALL_SELECTOR)) {
|
|
407
|
+
let blockNumber = undefined;
|
|
408
|
+
[, blockNumber] = params;
|
|
409
|
+
const multicallRequests = decodeFunctionData({
|
|
410
|
+
abi: multicall3Abi,
|
|
411
|
+
data: params[0].data,
|
|
412
|
+
}).args[0];
|
|
413
|
+
if (multicallRequests.length === 0) {
|
|
414
|
+
// empty multicall result
|
|
415
|
+
return "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000";
|
|
416
|
+
}
|
|
417
|
+
const requests = multicallRequests.map((call) => ({
|
|
418
|
+
method: "eth_call",
|
|
419
|
+
params: [
|
|
420
|
+
{
|
|
421
|
+
to: call.target,
|
|
422
|
+
data: call.callData,
|
|
423
|
+
},
|
|
424
|
+
blockNumber ?? "latest",
|
|
425
|
+
],
|
|
426
|
+
}));
|
|
427
|
+
const results = new Map();
|
|
428
|
+
const requestsToInsert = new Set();
|
|
429
|
+
for (const request of requests) {
|
|
430
|
+
const cacheKey = getCacheKey(request);
|
|
431
|
+
if (cache.get(chain.id).has(cacheKey)) {
|
|
432
|
+
const cachedResult = cache.get(chain.id).get(cacheKey);
|
|
433
|
+
if (cachedResult instanceof Promise) {
|
|
434
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
435
|
+
chain: chain.name,
|
|
436
|
+
method,
|
|
437
|
+
type: "prefetch_rpc",
|
|
438
|
+
});
|
|
439
|
+
const result = await cachedResult;
|
|
440
|
+
// Note: we don't attempt to cache or prefetch errors, instead relying on the eventual RPC request.
|
|
441
|
+
if (result instanceof Error)
|
|
442
|
+
continue;
|
|
443
|
+
if (UNCACHED_RESPONSES.includes(result) === false) {
|
|
444
|
+
requestsToInsert.add(request);
|
|
445
|
+
}
|
|
446
|
+
results.set(request, {
|
|
447
|
+
success: true,
|
|
448
|
+
returnData: decodeResponse(result),
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
453
|
+
chain: chain.name,
|
|
454
|
+
method,
|
|
455
|
+
type: "prefetch_database",
|
|
456
|
+
});
|
|
457
|
+
results.set(request, {
|
|
458
|
+
success: true,
|
|
459
|
+
returnData: decodeResponse(cachedResult),
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const dbRequests = requests.filter((request) => results.has(request) === false);
|
|
465
|
+
const dbResults = await syncStore.getRpcRequestResults({ requests: dbRequests, chainId: chain.id }, context);
|
|
466
|
+
for (let i = 0; i < dbRequests.length; i++) {
|
|
467
|
+
const request = dbRequests[i];
|
|
468
|
+
const result = dbResults[i];
|
|
469
|
+
if (result !== undefined) {
|
|
470
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
471
|
+
chain: chain.name,
|
|
472
|
+
method,
|
|
473
|
+
type: "database",
|
|
474
|
+
});
|
|
475
|
+
results.set(request, {
|
|
476
|
+
success: true,
|
|
477
|
+
returnData: decodeResponse(result),
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (results.size < requests.length) {
|
|
482
|
+
const _requests = requests.filter((request) => results.has(request) === false);
|
|
483
|
+
const multicallResult = await rpc
|
|
484
|
+
.request({
|
|
485
|
+
method: "eth_call",
|
|
486
|
+
params: [
|
|
487
|
+
{
|
|
488
|
+
to: params[0].to,
|
|
489
|
+
data: encodeFunctionData({
|
|
490
|
+
abi: multicall3Abi,
|
|
491
|
+
functionName: "aggregate3",
|
|
492
|
+
args: [
|
|
493
|
+
multicallRequests.filter((_, i) => results.has(requests[i]) === false),
|
|
494
|
+
],
|
|
495
|
+
}),
|
|
496
|
+
},
|
|
497
|
+
blockNumber,
|
|
498
|
+
],
|
|
499
|
+
}, context)
|
|
500
|
+
.then((result) => decodeFunctionResult({
|
|
501
|
+
abi: multicall3Abi,
|
|
502
|
+
functionName: "aggregate3",
|
|
503
|
+
data: result,
|
|
504
|
+
}));
|
|
505
|
+
for (let i = 0; i < _requests.length; i++) {
|
|
506
|
+
const request = _requests[i];
|
|
507
|
+
const result = multicallResult[i];
|
|
508
|
+
if (result.success &&
|
|
509
|
+
UNCACHED_RESPONSES.includes(result.returnData) === false) {
|
|
510
|
+
requestsToInsert.add(request);
|
|
511
|
+
}
|
|
512
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
513
|
+
chain: chain.name,
|
|
514
|
+
method,
|
|
515
|
+
type: "rpc",
|
|
516
|
+
});
|
|
517
|
+
results.set(request, result);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
const encodedBlockNumber = blockNumber === undefined
|
|
521
|
+
? undefined
|
|
522
|
+
: blockNumber === "latest"
|
|
523
|
+
? 0
|
|
524
|
+
: hexToNumber(blockNumber);
|
|
525
|
+
// Note: insertRpcRequestResults errors can be ignored and not awaited, since
|
|
526
|
+
// the response is already fetched.
|
|
527
|
+
syncStore
|
|
528
|
+
.insertRpcRequestResults({
|
|
529
|
+
requests: Array.from(requestsToInsert).map((request) => ({
|
|
530
|
+
request,
|
|
531
|
+
blockNumber: encodedBlockNumber,
|
|
532
|
+
result: JSON.stringify(results.get(request).returnData),
|
|
533
|
+
})),
|
|
534
|
+
chainId: chain.id,
|
|
535
|
+
}, context)
|
|
536
|
+
.catch(() => { });
|
|
537
|
+
// Note: at this point, it is an invariant that either `allowFailure` is true or
|
|
538
|
+
// there are no failed requests.
|
|
539
|
+
// Note: viem <= 2.23.6 had a bug with `encodeFunctionResult` which can be worked around by adding
|
|
540
|
+
// another layer of array nesting.
|
|
541
|
+
// Fixed by this commit https://github.com/wevm/viem/commit/9c442de0ff38ac1f654b5c751d292e9a9f8d574c
|
|
542
|
+
const resultsToEncode = requests.map((request) => results.get(request));
|
|
543
|
+
try {
|
|
544
|
+
return encodeFunctionResult({
|
|
545
|
+
abi: multicall3Abi,
|
|
546
|
+
functionName: "aggregate3",
|
|
547
|
+
result: resultsToEncode,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
catch (e) {
|
|
551
|
+
return encodeFunctionResult({
|
|
552
|
+
abi: multicall3Abi,
|
|
553
|
+
functionName: "aggregate3",
|
|
554
|
+
result: [
|
|
555
|
+
// @ts-expect-error known issue in viem <= 2.23.6
|
|
556
|
+
resultsToEncode,
|
|
557
|
+
],
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
else if (blockDependentMethods.has(method) ||
|
|
562
|
+
nonBlockDependentMethods.has(method)) {
|
|
563
|
+
const blockNumber = extractBlockNumberParam(body);
|
|
564
|
+
const encodedBlockNumber = blockNumber === undefined
|
|
565
|
+
? undefined
|
|
566
|
+
: blockNumber === "latest"
|
|
567
|
+
? 0
|
|
568
|
+
: hexToNumber(blockNumber);
|
|
569
|
+
const cacheKey = getCacheKey(body);
|
|
570
|
+
if (cache.get(chain.id).has(cacheKey)) {
|
|
571
|
+
const cachedResult = cache.get(chain.id).get(cacheKey);
|
|
572
|
+
// `cachedResult` is a Promise if the request had to be fetched from the RPC.
|
|
573
|
+
if (cachedResult instanceof Promise) {
|
|
574
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
575
|
+
chain: chain.name,
|
|
576
|
+
method,
|
|
577
|
+
type: "prefetch_rpc",
|
|
578
|
+
});
|
|
579
|
+
const result = await cachedResult;
|
|
580
|
+
if (result instanceof Error)
|
|
581
|
+
throw result;
|
|
582
|
+
if (UNCACHED_RESPONSES.includes(result) === false) {
|
|
583
|
+
// Note: insertRpcRequestResults errors can be ignored and not awaited, since
|
|
584
|
+
// the response is already fetched.
|
|
585
|
+
syncStore
|
|
586
|
+
.insertRpcRequestResults({
|
|
587
|
+
requests: [
|
|
588
|
+
{
|
|
589
|
+
request: body,
|
|
590
|
+
blockNumber: encodedBlockNumber,
|
|
591
|
+
result,
|
|
592
|
+
},
|
|
593
|
+
],
|
|
594
|
+
chainId: chain.id,
|
|
595
|
+
}, context)
|
|
596
|
+
.catch(() => { });
|
|
597
|
+
}
|
|
598
|
+
return decodeResponse(result);
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
602
|
+
chain: chain.name,
|
|
603
|
+
method,
|
|
604
|
+
type: "prefetch_database",
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
return decodeResponse(cachedResult);
|
|
608
|
+
}
|
|
609
|
+
const [cachedResult] = await syncStore.getRpcRequestResults({ requests: [body], chainId: chain.id }, context);
|
|
610
|
+
if (cachedResult !== undefined) {
|
|
611
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
612
|
+
chain: chain.name,
|
|
613
|
+
method,
|
|
614
|
+
type: "database",
|
|
615
|
+
});
|
|
616
|
+
return decodeResponse(cachedResult);
|
|
617
|
+
}
|
|
618
|
+
common.metrics.ponder_indexing_rpc_requests_total.inc({
|
|
619
|
+
chain: chain.name,
|
|
620
|
+
method,
|
|
621
|
+
type: "rpc",
|
|
622
|
+
});
|
|
623
|
+
const response = await rpc.request(body, context);
|
|
624
|
+
if (UNCACHED_RESPONSES.includes(response) === false) {
|
|
625
|
+
// Note: insertRpcRequestResults errors can be ignored and not awaited, since
|
|
626
|
+
// the response is already fetched.
|
|
627
|
+
syncStore
|
|
628
|
+
.insertRpcRequestResults({
|
|
629
|
+
requests: [
|
|
630
|
+
{
|
|
631
|
+
request: body,
|
|
632
|
+
blockNumber: encodedBlockNumber,
|
|
633
|
+
result: JSON.stringify(response),
|
|
634
|
+
},
|
|
635
|
+
],
|
|
636
|
+
chainId: chain.id,
|
|
637
|
+
}, context)
|
|
638
|
+
.catch(() => { });
|
|
639
|
+
}
|
|
640
|
+
return response;
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
return rpc.request(body, context);
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
})({ chain: viemChain, retryCount: 0 });
|
|
647
|
+
export const extractBlockNumberParam = (request) => {
|
|
648
|
+
let blockNumber = undefined;
|
|
649
|
+
switch (request.method) {
|
|
650
|
+
case "eth_getBlockByNumber":
|
|
651
|
+
case "eth_getBlockTransactionCountByNumber":
|
|
652
|
+
case "eth_getTransactionByBlockNumberAndIndex":
|
|
653
|
+
case "eth_getUncleByBlockNumberAndIndex":
|
|
654
|
+
case "debug_traceBlockByNumber":
|
|
655
|
+
// @ts-expect-error
|
|
656
|
+
[blockNumber] = request.params;
|
|
657
|
+
break;
|
|
658
|
+
case "eth_getBalance":
|
|
659
|
+
case "eth_call":
|
|
660
|
+
case "eth_getCode":
|
|
661
|
+
case "eth_estimateGas":
|
|
662
|
+
case "eth_feeHistory":
|
|
663
|
+
case "eth_getTransactionCount":
|
|
664
|
+
// @ts-expect-error
|
|
665
|
+
[, blockNumber] = request.params;
|
|
666
|
+
break;
|
|
667
|
+
case "eth_getProof":
|
|
668
|
+
case "eth_getStorageAt":
|
|
669
|
+
// @ts-expect-error
|
|
670
|
+
[, , blockNumber] = request.params;
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
return blockNumber;
|
|
674
|
+
};
|
|
675
|
+
//# sourceMappingURL=client.js.map
|