Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packages/basic-indexer-pg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# @eclesia/basic-pg-indexer

## 2.14.1

### Patch Changes

- 95bdc3a: Improve insert performance

## 2.14.0

### Minor Changes

- b7ed332: Refactor indexer flow

## 2.13.0

### Minor Changes

- 9d237a5: Add RPC connect timeout

## 2.12.0

### Minor Changes

- Fix metrics and increase save TX performance

## 2.11.2

### Patch Changes

- Fix type export

## 2.11.1

### Patch Changes

- Refactor PgIndexerConfig type

## 2.11.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/basic-indexer-pg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclesia/basic-pg-indexer",
"version": "2.11.0",
"version": "2.14.1",
"description": "Basic PostGres eclesia indexer",
"type": "module",
"scripts": {
Expand Down
17 changes: 4 additions & 13 deletions packages/basic-indexer-pg/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,8 @@ function validatePostgresConnectionString(connectionString: string): void {
}

/** Configuration options for the PostgreSQL indexer */
export type PgIndexerConfig = {
startHeight: number // Block height to start indexing from
batchSize: number // Number of blocks to keep pre-fetched when syncing
modules: string[] // List of module names to enable
rpcUrl: string // Tendermint RPC endpoint URL
logLevel: "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly" // Logging verbosity
usePolling: boolean // Whether to use polling vs WebSocket subscription
export type PgIndexerConfig = Omit<Types.EcleciaIndexerConfig, "init" | "getNextHeight" | "beginTransaction" | "endTransaction" | "shouldProcessGenesis"> & {
processGenesis?: boolean // Whether to process genesis state
pollingInterval: number // Interval between polls (ms) when using polling
minimal: boolean // Whether to use minimal indexing (blocks only)
genesisPath?: string // Path to genesis file for processing
enablePrometheus?: boolean // Enable Prometheus metrics server
prometheusPort?: number // Prometheus metrics server port
dbConnectionString: string // PostgreSQL connection string
};

Expand Down Expand Up @@ -189,7 +178,7 @@ export class PgIndexer {
}
else {
// No blocks found, start from configured height
return this.config.startHeight;
return this.config.startHeight!;
}
}
catch (e) {
Expand Down Expand Up @@ -305,12 +294,14 @@ export class PgIndexer {
*/
public getInstance(): Client {
if (this.config.logLevel !== "silly") {
this.db.query("SET synchronous_commit = OFF;");
return this.db;
}
else {
// Create a proxy client that logs query performance
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
self.db.query("SET synchronous_commit = OFF;");
return {
...self.db,
query: async (...args: Parameters<Client["query"]>): Promise<ReturnType<Client["query"]>> => {
Expand Down
42 changes: 42 additions & 0 deletions packages/core-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# @eclesia/core-modules-pg

## 2.14.3

### Patch Changes

- 95bdc3a: Improve insert performance

## 2.14.2

### Patch Changes

- 49c4028: Better stringify performance

## 2.14.1

### Patch Changes

- 2091bb8: ensure we only increment retry counter once

## 2.14.0

### Minor Changes

- b7ed332: Refactor indexer flow

## 2.13.0

### Minor Changes

- 9d237a5: Add RPC connect timeout

## 2.12.1

### Patch Changes

- Fix saveTx

## 2.12.0

### Minor Changes

- Fix metrics and increase save TX performance

## 2.11.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core-modules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclesia/core-modules-pg",
"version": "2.11.0",
"version": "2.14.3",
"description": "Eclesia postgres indexer core modules",
"type": "module",
"scripts": {
Expand Down
18 changes: 8 additions & 10 deletions packages/core-modules/src/blocks/full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ import {
import {
Tx,
} from "cosmjs-types/cosmos/tx/v1beta1/tx.js";
import {
JSONStringify,
} from "json-with-bigint";

import {
BigintStringify,
calculateGas,
} from "./helpers.js";

Expand Down Expand Up @@ -136,7 +134,7 @@ export class FullBlocksModule implements Types.IndexingModule {
),
block.block.header.time,
// Store validator signatures in structured JSON format
JSONStringify(block.block.lastCommit?.signatures.map((x) => {
BigintStringify(block.block.lastCommit?.signatures.map((x) => {
return {
validator: Utils.chainAddressfromKeyhash(
this.chainPrefix + "valcons", Buffer.from(x.validatorAddress ?? new Uint8Array()).toString("hex"),
Expand All @@ -157,11 +155,11 @@ export class FullBlocksModule implements Types.IndexingModule {
await this.saveTransaction(txHash, event.height, tx, block_results.results[i], registryMap);
}
}
this.indexer.log.silly("Value passed to blocks indexing module: " + JSONStringify(event.value));
this.indexer.log.silly("Value passed to blocks indexing module: " + BigintStringify(event.value));
});

// Calculate and store average block times every 100 blocks
this.indexer.on("periodic/100", async (event) => {
this.indexer.on("periodic/medium", async (event) => {
if (event.timestamp && event.height) {
const dt = new Date(event.timestamp);

Expand Down Expand Up @@ -324,7 +322,7 @@ export class FullBlocksModule implements Types.IndexingModule {
txHash.toUpperCase(),
height,
txdata.code == 0, // Transaction success is determined by code == 0
JSONStringify(
BigintStringify(
tx.body?.messages.map((x) => {
// Attempt to decode message using registered protobuf types
const msgtype = registryMap.get(x.typeUrl);
Expand All @@ -342,14 +340,14 @@ export class FullBlocksModule implements Types.IndexingModule {
),
tx.body?.memo,
tx.signatures,
JSON.stringify(Utils.toPlainObject(tx.authInfo?.signerInfos)),
JSON.stringify(Utils.toPlainObject(tx.authInfo?.fee)),
BigintStringify(tx.authInfo?.signerInfos),
BigintStringify(tx.authInfo?.fee),
txdata.gasWanted,
txdata.gasUsed,
// Remove null bytes from log string to prevent database issues
// eslint-disable-next-line no-control-regex
txdata.log?.replace(/\u0000/g, ""),
JSON.stringify(Utils.toPlainObject(txdata.events)),
BigintStringify(txdata.events),
],
});
endTimer?.();
Expand Down
7 changes: 7 additions & 0 deletions packages/core-modules/src/blocks/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ const calculateGas = (block: BlockResultsResponse | BlockResultsResponse38): big
}, 0n);
};

const BigintStringify = (obj: unknown): string => {
return JSON.stringify(obj,
(key, value) => (typeof value === "bigint" ? value.toString() : value), // return everything else unchanged
);
};

export {
BigintStringify,
calculateGas,
};
5 changes: 4 additions & 1 deletion packages/core-modules/src/blocks/sql/full.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ CREATE TABLE transactions
CONSTRAINT unique_tx UNIQUE (hash, height)
);
-- Indexes for efficient transaction queries
CREATE INDEX transaction_hash_index ON transactions (hash);
CREATE INDEX transaction_height_index ON transactions (height DESC NULLS LAST);

ALTER TABLE transactions ALTER COLUMN messages SET STORAGE EXTERNAL;
ALTER TABLE transactions ALTER COLUMN logs SET STORAGE EXTERNAL;
ALTER TABLE transactions ALTER COLUMN signer_infos SET STORAGE EXTERNAL;
ALTER TABLE transactions ALTER COLUMN fee SET STORAGE EXTERNAL;

-- Single-row tables for storing network performance metrics
-- These use a boolean primary key trick to ensure only one row exists
Expand Down
2 changes: 1 addition & 1 deletion packages/core-modules/src/cosmos.staking.v1beta1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ export class StakingModule implements Types.IndexingModule {
}
});

this.indexer.on("periodic/1000", async (event) => {
this.indexer.on("periodic/large", async (event) => {
const q = QueryPoolRequest.fromPartial({
});
const poolreq = QueryPoolRequest.encode(q).finish();
Expand Down
36 changes: 36 additions & 0 deletions packages/indexer-engine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# @eclesia/indexer-engine

## 2.14.2

### Patch Changes

- 2091bb8: ensure we only increment retry counter once

## 2.14.1

### Patch Changes

- 68a9454: catch block listening setup error

## 2.14.0

### Minor Changes

- b7ed332: Refactor indexer flow

## 2.13.0

### Minor Changes

- 9d237a5: Add RPC connect timeout

## 2.12.0

### Minor Changes

- Fix metrics and increase save TX performance

## 2.11.1

### Patch Changes

- Fix type export

## 2.11.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-engine/benchmarks/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function createBenchmarkIndexer(config: BenchmarkConfig): {
(indexer as any).client = mockRpc;
(indexer as any).blockClient = mockRpc;
(indexer as any).initialized = true;
(indexer as any).connect = () => Promise.resolve();
(indexer as any).connect = () => Promise.resolve(true);
}

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eclesia/indexer-engine",
"version": "2.11.0",
"version": "2.14.2",
"description": "Core eclesia indexer engine",
"scripts": {
"build": "tsc --noEmit && tsdown",
Expand Down
6 changes: 6 additions & 0 deletions packages/indexer-engine/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export const DEFAULT_PROMETHEUS_PORT = 9090;
*/
export const DEFAULT_POLLING_INTERVAL_MS = 5000;

/**
* Timeout for connecting to the Tendermint RPC in milliseconds
* If connection is not established within this time, it will be aborted
*/
export const CONNECT_TIMEOUT_MS = 10000;

/**
* Timeout for RPC calls in milliseconds
* If a call takes longer than this, it will be rejected
Expand Down
Loading
Loading