Skip to content

Commit

Permalink
Rebase with main SDK (#109)
Browse files Browse the repository at this point in the history
* Move enum under schema (#1527)

* need fix query get enum

* fix enum query, clean all enums

* add logic to handle original enum type

* fix check exclude constrain check missing schema and table (#1537)

* [SKIP CI] Prerelease

* manual prerelease node for node-core update (#1538)

* [SKIP CI] Prerelease

* resolution for sequelize and prerelease node (#1539)

* [SKIP CI] Prerelease

* fixed the version of sequelize and prerelease node (#1540)

* [SKIP CI] Prerelease

* improve force clean with deprecated enum (#1541)

* [SKIP CI] Prerelease

* Remove exclude constraint (#1543)

* deprecate exclude contraint

* remove unused

* [SKIP CI] Prerelease

* [release] 20230306 (#1544)

* [release] 20230307 (#1545)

* bump yarn.lock, update imports (#1546)

* [SKIP CI] Prerelease

* [release] 20230307 (#1547)

* increase wsProvider timeout (#1550)

* increase wsProvider timeout

* remove .mmr dir

* [SKIP CI] Prerelease

* Use performance.now instead of date for profiler. (#1549)

* add SmartBatchService and BlockSizeBuffer (#1506)

* add SmartBatchService and BlockSizeBuffer

* check memory usage before fetching a batch

* use v8 heap usage statistics

* set block to null after indexing

* extend smart batch service to workers

* make smart batch size injectible

* rebase

* bug fixes

* code cleanup

* assign workers based on free memory

* fix liniting

* cleanup code

* cleanup logs

* clear blocksizebuffer inside smartbatchservice

---------

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* Fix build issue with profiler

* [SKIP CI] Prerelease

* fix abi codegen runtime validation (#1552)

* [SKIP CI] Prerelease

* [release] 20230309 Cli (#1553)

* Fix enum under schema not being escaped (#1555)

* [SKIP CI] Prerelease

* rename `--sponsored-dictionary` to `--dictionary-resolver` (#1559)

* renamed flag

* add missing tpyo

* [SKIP CI] Prerelease

* handle bigint in json.stringify (#1562)

* [SKIP CI] Prerelease

* add validation for `codegen`, grapql conflicts (#1564)

* add test for codegen with reserved keys

* wip validateEntityName fn

* update test, update logc

* remove logs

* [SKIP CI] Prerelease

* Fix codegen when abi is not valid (#1570)

* Fix codegen when abi is not valid

* Update packages/cli/src/controller/codegen-controller.ts

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

---------

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* [SKIP CI] Prerelease

* Fix block offset been reset to 1 (#1571)

* [SKIP CI] Prerelease

* remove blocking in process queueing (#1572)

* remove blocking in process queueing

* redefine locking pattern

* fix fetchedBlocks status

* [SKIP CI] Prerelease

* improve api error handling (#1576)

* [SKIP CI] Prerelease

* generate sourcemap for projects (#1569)

* improve error handling

* use inline-source-map

* revert api error handling

* beautify minified output from webpack

* code cleanup

* move terser plugin dependency to cli

* log warnings for unresolved stack trace

* get entry file from datasource

* alter convertStack prototype

* add ES2020 to lib compiler option

* update polkadot api to 10.1.4 (#1580)

* update polkadot api to 10.1.4

* update rest of dep

* [release] 20230329 (#1587)

* Multiple endpoints (#1551)

* allow multiple endpoints

* add response time based load balancing

* handle endpoint disconnects

* move fetchBlockBatches to apiService

* cleanup code

* move ConnectionPoolService to node-core

* fix order of module injection in indexermodule

* remove manually disconnecting api

* move api creation code to ApiConnection class

* code cleanup

* handle reconnection error

* change networkEndpoints to networkEndpoint

* change to use yarn build (#1589)

* test prerelease build (#1590)

* [SKIP CI] Prerelease

* [release] 20230330 (#1592)

* Upgrade `apollo-links` (#1593)

* [SKIP CI] Prerelease

* improve blockSize function (#1602)

* improve blockSize function

* add return type to blockSize

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

---------

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* [SKIP CI] Prerelease

* [release] 20230405 (#1603)

* Add evmChainId to metadata (#1607)

* [SKIP CI] Prerelease

* [release] 20230411 query (#1608)

* Update progress string (#1612)

* [SKIP CI] Prerelease

* Update the jsonField directive to have an option for disabling the index (#1613)

* Update the jsonField directive to have an option for disabling the index

* Clean up

* [SKIP CI] Prerelease

* [release] 20230414 utils (#1615)

* Fix workers fetching blocks out of order (#1616)

* Fix workers fetching blocks out of order

* Remove logging endpoints with api keys

* [SKIP CI] Prerelease

* [release] 20230417 (#1617)

* DB cache and various other improvements (#1561)

* store cache

* improve on flush cache

* draft storeCache service

* update

* minor change

* Updates

* add historical data to cache (#1557)

* add __block_range to creation

* add historical record to cache

* correct range

* Complete cached store methods (#1563)

* add __block_range to creation

add historical record to cache

correct range

cache store methods

start add tests

* fix set

* update

* WIP cache with workers support

* Fix up dynamic ds service, clean up

* Update store serialisation over workers

* Improve unfinalized blocks to work without tx

* Move all chain agnostic code from block dispatchers to node core

* Add comments about worker store conversion

* Fix rebase build issues

* Implement cache for metadata entity (#1565)

* Implement cache for metadata entity

* Clean up and exclude unfinalized blocks keys from metadata cache

* Clean up

* flush with cache stored records size (#1566)

* flush with cache stored records size

* update

* Lfu get cache (#1568)

* still need fix get/count logic

fix method for LFU getCache

* Update tests

* Fix and more tests

* Update base on review

* Fix

* Run all store operations through cache (#1567)

* Run all store operations through hash

* Log when cache flushed, flush cache on application shutdown

* Cache fixes

* Fix removeCache not being init

* POI cache fixes

* Fixes

* Fix caches being cleared after db operation and potential cache changes have happened

* Fix issues with injected store

* Clean up

* Fix tests from rebase

* Fix get cache not being used

* Rename function

* Fix reindex issues

* Fix casing of import

* Clean up, log if finalized is enabled

* parent 8b0b558 (#1574)

author Scott Twiname <skott.twiname@gmail.com> 1679452749 +1300
committer JQQQ <jiqiang90@hotmail.com> 1679461182 +1300

Clean up, log if finalized is enabled

Fix rebase build issues

parent 5e4ea5d
author Scott Twiname <skott.twiname@gmail.com> 1679013784 +1300
committer JQQQ <jiqiang90@hotmail.com> 1679460224 +1300

parent 5e4ea5d
author Scott Twiname <skott.twiname@gmail.com> 1679013784 +1300
committer JQQQ <jiqiang90@hotmail.com> 1679460210 +1300

parent 5e4ea5d
author Scott Twiname <skott.twiname@gmail.com> 1679013784 +1300
committer JQQQ <jiqiang90@hotmail.com> 1679460149 +1300

parent 5e4ea5d
author Scott Twiname <skott.twiname@gmail.com> 1679013784 +1300
committer JQQQ <jiqiang90@hotmail.com> 1679460101 +1300

parent 5e4ea5d
author Scott Twiname <skott.twiname@gmail.com> 1679013784 +1300
committer JQQQ <jiqiang90@hotmail.com> 1679460038 +1300

Run all store operations through hash

Log when cache flushed, flush cache on application shutdown

Fix removeCache not being init

Fixes

Fix issues with injected store

Clean up

Fix removeCache not being init

Fixes

Fix issues with injected store

Clean up

Fix tests from rebase

Fix get cache not being used

tidy up

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* Update metadata when dictionary skips large number of blocks (#1577)

* Update metadata when dictionary skips large number of blocks

* Bring back option to log sql

* Dynamic cache threshold and metrics (#1578)

* Bring back fetch service tests

* Fix build issues

* Tidy up

* Fix workers historical disabled (#1579)

* Fix imports in node core

* improve close record sql, and add flag max size for getCache (#1583)

* improve close record sql, and add flag max size for getCache

* Fix

* escape id string

* Flush data at specific block heights (#1582)

* Flush data at specific block heights

* Add test

* Fix value fromBelowHeight being empty

* Fix mergedRecords potentially being empty

* Fix flushableRecordCounter

* Change log to debug

* Fix dictionary validation

* fix reindex storeCache missing EventEmitterModule (#1585)

* Make flushing cache configurable (#1586)

* Add an index to Id field on entities with historical (#1588)

* Fix tests

* Fix possible infinite loop with cache and fix test (#1591)

* Fix possible infinite loop with cache and fix test

* Add some comments

* Fix more tests

---------

Co-authored-by: JQQQ <jiqiang90@hotmail.com>

* Connect historical option up to cache model option (#1596)

* Only run delete query if there is data to delete

* Add support for non-historical indexing with cache (#1597)

* Add support for non-historical indexing with cache

* Fix api test

* remove constraintDeferrableQuery from hasOne

* fix createUniqueIndexQuery

---------

Co-authored-by: JQQQ <jiqiang90@hotmail.com>

* Cache and worker related fixes (#1598)

* fix index name too long issue (#1599)

* hash the indexes, except pk indexes

* handle existed indexes

* update

* Remove store count function (#1600)

* support cockroach db with non-historical (#1604)

* support cockroach db with non-historical

* Add more comments

* move fetchBlocks to node-core (#1611)

* move fetchBlocks to node-core

* code cleanup

* code cleanup

* remove extra args from fetchBlock

* Fix making data serializable for store bulkCreate and bulkUpdate (#1622)

* Improve big int error in workers (#1619)

* improve error handling in workers

* Make bigint stringifiable in worker and main threads

---------

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* fix type error (#1623)

* fix type error

* cast type

* Flush store cache in operational order (#1614)

* Init

* better log message

* tidy up

* Tidy up and test

* Update packages/node/src/yargs.ts

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* Update packages/node-core/src/indexer/storeCache/storeCache.service.ts

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* add benchmarking

* update benchmarking

* Tidy up

* test

* remove flag, use last flushed index, more tidy up

* make operationIndex required

* fix test

---------

Co-authored-by: Scott Twiname <skott.twiname@gmail.com>

* update default values

* fix missing indexes on cockroach db (#1624)

* fix getLatest() could be undefined

* Fix StoreOperation not pushing enums

---------

Co-authored-by: JQQQ <jiqiang90@hotmail.com>
Co-authored-by: Naveen V <velnaveen99@gmail.com>

* [SKIP CI] Prerelease

* Testing Framework (#1584)

* implement runTest

* check handler kind for running test

* implement testing service

* run tests in sandbox

* build test files through subql build

* run handlers in sandbox

* cleanup sandbox script and improve logging

* index data with `IndexerManager.indexData`

* use indexBlock() instead of indexData() for tests

* add getter _name to entities during codegen

* code cleanup

* improve logging

* improve logging

* bug fixes

* code cleanup

* improve logging

* indexBlock: get datasource from arguments

* move testingService to node-core

* code cleanup

* update ci

* code cleanup

* cleanup

* cleanup

* cleanup

* handle 0 test cases

* prevent calling getGqlType for 'contains' matcher (#1626)

* prevent calling getGqlType for 'contains' matcher

* get gqlType with ternary condition

* remove indexer module from testing module (#1628)

* remove indexer module from testing module

* cleanup

* cleanup

* Enable strict ts setting for node core (#1625)

* WIP enable strict ts setting for node core

* fix undefined in historicalMarkPreviousHeightRecordsBatch

* typo

* Update typescript, fix most strict related errors

* Strict changes for testing framework

* Runtime fixes

* change log level on cache poi

---------

Co-authored-by: JQQQ <jiqiang90@hotmail.com>

* fix prerelease (#1629)

* [SKIP CI] Prerelease

* [SKIPCI] fix testing publish order (#1630)

* fix missing @subql/testing in node-core (#1631)

* [SKIP CI] Prerelease

* manual prerelease for node-core fix (#1632)

* [SKIP CI] Prerelease

* Improve yargs descriptions (#1633)

* [SKIP CI] Prerelease

* Support tests from ./test and ./tests dirs, fix store blockheight issue

* Remove log

* [SKIP CI] Prerelease

* [release] 2.0.0 (#1627)

* release-2.0.0

* update

* update node changelog

* remove typescript from query dependency

* remove typescript from node dependency

* [SKIPCI] fix release

* [release] 2.0.0 republish (#1635)

* Fix ApiService abstract class, improve getting all DS (#1638)

* Fix ApiService abstract class, improve getting all DS

* Revert api import and minor test fixes

* [SKIP CI] Prerelease

* fix assertion error and pk index type (#1641)

* [SKIP CI] Prerelease

* update node-core

* Tidy up dependencies

* Remove unnecessary fiiles

* Fix worker DI issue

---------

Co-authored-by: Jay Ji <jiqiang90@hotmail.com>
Co-authored-by: Ben <89335033+bz888@users.noreply.github.com>
Co-authored-by: Scott Twiname <skott.twiname@gmail.com>
Co-authored-by: HZHAIX <zhaihaohk@gmail.com>
Co-authored-by: James Bayly <46693720+jamesbayly@users.noreply.github.com>
  • Loading branch information
6 people committed Apr 26, 2023
1 parent 2767d44 commit 503d744
Show file tree
Hide file tree
Showing 41 changed files with 1,605 additions and 2,100 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- run: yarn

- name: build
run: yarn workspaces foreach run build
run: yarn build

#Add remove-stable-version
- name: Bump types & deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- run: yarn

- name: build
run: yarn workspaces foreach run build
run: yarn build

#Publish to npm and github releases
- name: Publish Types
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@octokit/request": "^5.6.3",
"@types/cron-converter": "^1",
"@types/node": "^14.18.10",
"@types/node-fetch": "2.6.2",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"babel-jest": "^27.4.6",
Expand All @@ -30,13 +31,14 @@
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"tsconfig-paths": "^3.12.0",
"typescript": "^4.4.4"
"typescript": "^4.9.5"
},
"resolutions": {
"@polkadot/api": "9.11.1",
"@polkadot/util": "10.2.3",
"@polkadot/api": "10.1.4",
"@polkadot/util": "11.1.3",
"@cosmjs/cosmwasm-stargate": "^0.29.5",
"node-fetch": "2.6.7"
"node-fetch": "2.6.7",
"sequelize": "6.28.0"
},
"scripts": {
"build": "yarn workspaces foreach -ptA run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/common-cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"main": "dist/index.js",
"license": "Apache-2.0",
"dependencies": {
"@subql/common": "latest",
"@subql/common": "^2.0.0",
"@subql/types-cosmos": "workspace:*",
"class-transformer": "0.4.0",
"class-validator": "^0.13.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/common-cosmos/src/project/versioned/v0_3_0/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ export class CosmosProjectNetworkDeploymentV0_3_0 {
}

export class CosmosProjectNetworkV0_3_0 extends CosmosProjectNetworkDeploymentV0_3_0 {
@IsString()
endpoint: string;
@IsString({each: true})
@IsOptional()
endpoint?: string | string[];
@IsString()
@IsOptional()
dictionary?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface CosmosProjectManifestV0_3_0 extends ICosmosProjectManifest {
};

network: {
endpoint?: string;
endpoint?: string | string[];
dictionary?: string;
bypassBlocks?: (number | string)[];
chainId: string;
Expand Down
8 changes: 3 additions & 5 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
"@nestjs/event-emitter": "^1.3.0",
"@nestjs/platform-express": "^8.2.6",
"@nestjs/schedule": "^1.0.2",
"@polkadot/api": "9.11.1",
"@subql/common": "latest",
"@subql/common": "^2.0.0",
"@subql/common-cosmos": "workspace:*",
"@subql/node-core": "1.10.1-2",
"@subql/node-core": "2.0.1-1",
"@subql/types-cosmos": "workspace:*",
"@subql/utils": "^1.5.0",
"@subql/utils": "^2.0.0",
"@subql/x-merkle-mountain-range": "2.0.0-0.1.2",
"@willsoto/nestjs-prometheus": "^4.2.0",
"app-module-path": "^2.2.0",
Expand All @@ -52,7 +51,6 @@
"rxjs": "^7.5.2",
"sequelize": "6.28.0",
"tar": "^6.1.11",
"typescript": "^4.4.4",
"vm2": "^3.9.9",
"yargs": "^16.2.0"
},
Expand Down
14 changes: 10 additions & 4 deletions packages/node/src/configure/SubqueryProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { Block } from '@cosmjs/stargate';
import { Injectable } from '@nestjs/common';
import { RegisteredTypes } from '@polkadot/types/types';
import {
ReaderFactory,
ReaderOptions,
Expand Down Expand Up @@ -43,6 +42,7 @@ export type SubqlProjectDs = SubqlCosmosDataSource & {
};

export type CosmosProjectNetConfig = CosmosProjectNetworkConfig & {
chainId: string;
chainTypes: Map<string, CosmosChainType> & { protoRoot: protobuf.Root };
};

Expand All @@ -61,15 +61,17 @@ const NOT_SUPPORT = (name: string) => {
throw new Error(`Manifest specVersion ${name}() is not supported`);
};

// This is the runtime type after we have mapped genesisHash to chainId and endpoint/dict have been provided when dealing with deployments
type NetworkConfig = CosmosProjectNetworkConfig & { chainId: string };

@Injectable()
export class SubqueryProject {
id: string;
root: string;
network: Partial<CosmosProjectNetConfig>;
network: NetworkConfig;
dataSources: SubqlProjectDs[];
schema: GraphQLSchema;
templates: SubqlProjectDsTemplate[];
chainTypes?: RegisteredTypes;
runner?: RunnerSpecs;

static async create(
Expand Down Expand Up @@ -106,7 +108,7 @@ export class SubqueryProject {

export interface SubqueryProjectNetwork {
chainId: string;
endpoint?: string;
endpoint?: string[];
dictionary?: string;
chainTypes?: Map<string, CosmosChainType>;
}
Expand All @@ -121,6 +123,10 @@ async function loadProjectFromManifestBase(
): Promise<SubqueryProject> {
const root = await getProjectRoot(reader);

if (typeof projectManifest.network.endpoint === 'string') {
projectManifest.network.endpoint = [projectManifest.network.endpoint];
}

const network = await processNetworkConfig(
{
...projectManifest.network,
Expand Down
6 changes: 3 additions & 3 deletions packages/node/src/configure/configure.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const YargsNameMapping: Record<string, string> = {
'network-endpoint-param': 'networkEndpointParams',
};

type Args = typeof yargsOptions.argv['argv'];
type Args = (typeof yargsOptions.argv)['argv'];

function yargsToIConfig(yargs: Args): Partial<IConfig> {
return Object.entries(yargs).reduce((acc, [key, value]) => {
Expand Down Expand Up @@ -117,7 +117,7 @@ export class ConfigureModule {
config.subquery,
omitBy<CosmosProjectNetworkConfig>(
{
endpoint: config.networkEndpoint,
endpoint: config.networkEndpoints,
dictionary: config.networkDictionary,
},
isNil,
Expand Down Expand Up @@ -175,7 +175,7 @@ export class ConfigureModule {
argv.subquery,
omitBy<CosmosProjectNetworkConfig>(
{
endpoint: config.networkEndpoint,
endpoint: config.networkEndpoints,
dictionary: config.networkDictionary,
},
isNil,
Expand Down
14 changes: 10 additions & 4 deletions packages/node/src/indexer/api.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { toHex } from '@cosmjs/encoding';
import { Uint53 } from '@cosmjs/math';
import { toRfc3339WithNanoseconds } from '@cosmjs/tendermint-rpc';
import { INestApplication } from '@nestjs/common';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';
import { Test } from '@nestjs/testing';
import { loadFromJsonOrYaml } from '@subql/common';
import { NodeConfig } from '@subql/node-core';
import { ConnectionPoolService, delay, NodeConfig } from '@subql/node-core';
import { GraphQLSchema } from 'graphql';
import { SubqueryProject } from '../configure/SubqueryProject';
import { ApiService } from './api.service';
Expand Down Expand Up @@ -43,10 +43,16 @@ describe.skip('ApiService', () => {
const prepareApiService = async () => {
const module = await Test.createTestingModule({
providers: [
ConnectionPoolService,
{
provide: 'ISubqueryProject',
useFactory: () => testCosmosProject(),
},
{
provide: NodeConfig,
useFactory: () => ({}),
},
EventEmitter2,
ApiService,
NodeConfig,
],
Expand All @@ -63,7 +69,7 @@ describe.skip('ApiService', () => {
});

it('query block info', async () => {
const api = apiService.getApi();
const api = apiService.api;
const blockInfo = await api.blockInfo(TEST_BLOCKNUMBER);
const doc: any = loadFromJsonOrYaml(
path.join(projectsDir, 'block_3266772.json'),
Expand All @@ -85,7 +91,7 @@ describe.skip('ApiService', () => {
});

it('query tx info by height', async () => {
const api = apiService.getApi();
const api = apiService.api;
const txInfos = await api.txInfoByHeight(TEST_BLOCKNUMBER);
expect(txInfos.length).toEqual(4);
});
Expand Down
Loading

0 comments on commit 503d744

Please sign in to comment.