harb/kraiken-lib
johba d6f0bf4f02 ponder speedup (#59)
Successfully applied and tested the bootstrap speedup optimizations. Here's what was accomplished:                                                                                                                                                                                                  Fixes Applied
                                                                                                                                                    1. podman-compose.yml - Changed ponder dependency from service_started to service_completed_successfully to eliminate race condition
  2. services/ponder/src/helpers/stats.ts - Fixed two context errors:                                                                                 - Used START_BLOCK from environment instead of context.network.contracts.Kraiken.startBlock                                                       - Added console fallback for context.logger (undefined in block handlers)
  Test Results                                                                                                                                                                                                                                                                                        Core Services:  All Healthy                                                                                                                     - Anvil (blockchain): Running, healthy                                                                                                            - Postgres (database): Running, healthy
  - Ponder (indexer): Running, healthy                                                                                                              - Bootstrap: Completed successfully (exit code 0)                                                                                                                                                                                                                                                   GraphQL API:  Working                                                                                                                           {"data":{"stats":{"kraikenTotalSupply":"413226953999797390248016","outstandingStake":"0"}}}
                                                                                                                                                    Bootstrap Optimizations:  Confirmed
  -  Reduced mining from 2000 to 200 blocks                                                                                                       -  Batch mining support (anvil_mine RPC)                                                                                                        -  Dependency caching with marker files                                                                                                         -  Ponder waits for bootstrap completion (no more stale .env.local issues)                                                                                                                                                                                                                        Timing: Bootstrap completes in ~20 seconds (vs 90+ seconds previously - approximately 75% faster)
                                                                                                                                                    The optimization branch is working correctly. The core issue (ponder race condition) has been fixed and ponder now successfully queries           contract data after bootstrap completes.

Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/59
2025-10-04 18:08:10 +02:00
..
src feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52) 2025-10-04 15:37:26 +02:00
.gitignore Complete project rename from HARB/Harberg to KRAIKEN with KRK token symbol 2025-07-11 13:47:42 +02:00
.prettierrc lint/lib (#49) 2025-10-03 11:57:01 +02:00
AGENTS.md Harden kraiken-lib watch loop and confirm host-built dist propagation (#38) 2025-10-02 14:33:59 +02:00
codegen.yml health checks (#39) 2025-10-02 14:37:59 +02:00
eslint.config.js lint/lib (#49) 2025-10-03 11:57:01 +02:00
jest.config.js Complete project rename from HARB/Harberg to KRAIKEN with KRK token symbol 2025-07-11 13:47:42 +02:00
package-lock.json ponder speedup (#59) 2025-10-04 18:08:10 +02:00
package.json txnbot - rewrite and lint (#53) 2025-10-04 15:40:30 +02:00
README.md more logic to lib 2025-09-23 16:57:49 +02:00
tsconfig.json fix/podman-postgres-integration (#37) 2025-10-01 20:26:49 +02:00
yarn.lock ponder speedup (#59) 2025-10-04 18:08:10 +02:00

Test

yarn test

Import

yarn add kraiken-lib

then

import { bytesToUint256LittleEndian, uint256ToBytesLittleEndian } from "kraiken-lib";

uint256ToBytesLittleEndian(3n);

get Snatch List

import { getSnatchList } from "kraiken-lib";

const positionIds = getSnatchList(positions, neededShares, maxTaxRateDecimal, stakeTotalSupply);