Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getting timeout exceeded in the sdk client even when transaction is submitted #3129

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion dapp-example/src/hooks/useHederaSdk.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { ethers } from 'ethers';
import { PublicKey, Client, TransferTransaction, Hbar, AccountId, AccountInfoQuery } from '@hashgraph/sdk';
import { PublicKey, Client, TransferTransaction, Hbar, AccountId, AccountInfoQuery } from 'kosi-sdk';

const client = Client.forTestnet();

Expand Down
2 changes: 1 addition & 1 deletion dapp-example/tests/e2e/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const HederaSDK = require('@hashgraph/sdk');
const HederaSDK = require('kosi-sdk');
const ethers = require('ethers');
const fs = require('fs');
const path = require('path');
Expand Down
456 changes: 411 additions & 45 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"@types/co-body": "6.1.0",
"@types/find-config": "^1.0.4",
"@types/koa-cors": "^0.0.6",
"@types/sinon": "^10.0.20",
"@types/lodash": "^4.17.7",
"@types/sinon": "^10.0.20",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"ajv": "^8.16.0",
Expand Down Expand Up @@ -89,12 +89,14 @@
"keyv-file": "^0.3.3",
"koa-cors": "^0.0.16",
"koa-websocket": "^7.0.0",
"kosi-sdk": "1.0.1",
"lerna": "^8.1.8",
"pino": "^7.11.0",
"pino-pretty": "^7.6.1",
"prom-client": "^14.0.1",
"pnpm": "^8.7.1",
"redis": "^4.7.0"
"prom-client": "^14.0.1",
"redis": "^4.7.0",
"type": "^2.7.3"
},
"overrides": {
"protobufjs": "^7.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"dependencies": {
"@hashgraph/json-rpc-config-service": "file:../config-service",
"@ethersproject/asm": "^5.7.0",
"@hashgraph/sdk": "^2.50.0-beta.3",
"@keyvhq/core": "^1.6.9",
"axios": "^1.4.0",
"axios-retry": "^3.5.1",
Expand All @@ -60,6 +59,7 @@
"ethers": "^6.7.0",
"find-config": "^1.0.0",
"keccak": "^3.0.2",
"kosi-sdk": "1.0.1",
"keyv": "^4.2.2",
"keyv-file": "^0.3.0",
"lodash": "^4.17.21",
Expand Down
18 changes: 14 additions & 4 deletions packages/relay/src/lib/clients/sdkClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
TransactionRecord,
TransactionRecordQuery,
TransactionResponse,
} from '@hashgraph/sdk';
} from 'kosi-sdk';
import { Logger } from 'pino';
import { Utils } from '../../utils';
import { EventEmitter } from 'events';
Expand Down Expand Up @@ -429,6 +429,7 @@
originalCallerAddress,
currentNetworkExchangeRateInCents,
);
this.logger.info('Created file...');
if (!fileId) {
throw new SDKClientError({}, `${requestDetails.formattedRequestId} No fileId created for transaction. `);
}
Expand All @@ -440,7 +441,7 @@
ethereumTransaction.setMaxTransactionFee(
Hbar.fromTinybars(Math.floor(networkGasPriceInTinyBars * constants.MAX_GAS_PER_SEC)),
);

this.logger.info('About to execute transaction...');
return {
fileId,
txResponse: await this.executeTransaction(
Expand Down Expand Up @@ -709,9 +710,9 @@
try {
this.logger.info(`${requestDetails.formattedRequestId} Execute ${txConstructorName} transaction`);
transactionResponse = await transaction.execute(this.clientMain);

this.logger.info('Transaction Response before receipt', transactionResponse);
transactionId = transactionResponse.transactionId.toString();

this.logger.info('Transaction Id before receipt', transactionId);
// .getReceipt() will throw an error if, in any case, the status !== 22 (SUCCESS).
const transactionReceipt = await transactionResponse.getReceipt(this.clientMain);

Expand All @@ -731,12 +732,21 @@
throw sdkClientError;
}

this.logger.warn(

Check warning on line 735 in packages/relay/src/lib/clients/sdkClient.ts

View check run for this annotation

Codecov / codecov/patch

packages/relay/src/lib/clients/sdkClient.ts#L735

Added line #L735 was not covered by tests
`${
requestDetails.formattedRequestId
} Logging more info about failed transaction LogID: ${transaction._getLogId()} Max attempts: ${
transaction._maxAttempts
}, Grpc deadline ${transaction._grpcDeadline}, NodeIds ${transaction.nodeAccountIds} ${this.clientMain}
Tranasaction ${transaction} `,
);
this.logger.warn(
sdkClientError,
`${requestDetails.formattedRequestId} Fail to execute ${txConstructorName} transaction: transactionId=${transaction.transactionId}, callerName=${callerName}, status=${sdkClientError.status}(${sdkClientError.status._code}) message=${sdkClientError.message}`,
);

if (!transactionResponse) {
this.logger.info('Transaction Response in if', transactionResponse);

Check warning on line 749 in packages/relay/src/lib/clients/sdkClient.ts

View check run for this annotation

Codecov / codecov/patch

packages/relay/src/lib/clients/sdkClient.ts#L749

Added line #L749 was not covered by tests
throw predefined.INTERNAL_ERROR(
`${requestDetails.formattedRequestId} Transaction execution returns a null value: transactionId=${transaction.transactionId}, callerName=${callerName}, txConstructorName=${txConstructorName}`,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib/errors/MirrorNodeClientError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

import { Status } from '@hashgraph/sdk';
import { Status } from 'kosi-sdk';

export class MirrorNodeClientError extends Error {
public statusCode: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib/errors/SDKClientError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

import { Status } from '@hashgraph/sdk';
import { Status } from 'kosi-sdk';

export class SDKClientError extends Error {
public status: Status = Status.Unknown;
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { Transaction as EthersTransaction } from 'ethers';
import HAPIService from './services/hapiService/hapiService';
import { JsonRpcError, predefined } from './errors/JsonRpcError';
import { Block, Log, Transaction, Transaction1559 } from './model';
import { FileId, Hbar, PrecheckStatusError } from '@hashgraph/sdk';
import { FileId, Hbar, PrecheckStatusError } from 'kosi-sdk';
import { CacheService } from './services/cacheService/cacheService';
import { CommonService, FilterService } from './services/ethService';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

// Used for fake implementation of block history
import { Status, TransactionRecord } from '@hashgraph/sdk';
import { Status, TransactionRecord } from 'kosi-sdk';

export class Block {
public readonly timestamp: string = '0x' + new Date().valueOf().toString(16);
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import { Net } from '../index';
import constants from './constants';
import { Client } from '@hashgraph/sdk';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { Client } from 'kosi-sdk';

export class NetImpl implements Net {
private client: Client;
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Poller } from './poller';
import { Web3Impl } from './web3';
import EventEmitter from 'events';
import constants from './constants';
import { Client, Hbar } from '@hashgraph/sdk';
import { Client, Hbar } from 'kosi-sdk';
import { RequestDetails } from './types';
import { prepend0x } from '../formatters';
import { MirrorNodeClient } from './clients';
Expand Down
8 changes: 5 additions & 3 deletions packages/relay/src/lib/services/hapiService/hapiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import { Counter, Registry } from 'prom-client';
import { SDKClient } from '../../clients/sdkClient';
import { HbarLimitService } from '../hbarLimitService';
import { CacheService } from '../cacheService/cacheService';
import { AccountId, Client, PrivateKey } from '@hashgraph/sdk';
import fs from 'fs';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { AccountId, Client, LogLevel, PrivateKey, Logger as SDKLogger } from 'kosi-sdk';
import fs from 'fs';

export default class HAPIService {
/**
Expand Down Expand Up @@ -250,6 +250,7 @@ export default class HAPIService {
}

this.transactionCount--;
this.logger.info(`Transaction count for sdk client, ${this.transactionCount}`);
if (this.transactionCount <= 0) {
this.shouldReset = true;
}
Expand Down Expand Up @@ -364,7 +365,8 @@ export default class HAPIService {
// @ts-ignore
const SDK_REQUEST_TIMEOUT = parseInt(ConfigService.get('SDK_REQUEST_TIMEOUT') || '10000');
client.setRequestTimeout(SDK_REQUEST_TIMEOUT);

const sdkLogger = new SDKLogger(LogLevel.Debug);
client.setLogger(sdkLogger);
logger.info(
`SDK client successfully configured to ${JSON.stringify(hederaNetwork)} for account ${
client.operatorAccountId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { EthAddressHbarSpendingPlanRepository } from '../../db/repositories/hbar
import { IPAddressHbarSpendingPlanRepository } from '../../db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository';
import { RequestDetails } from '../../types';
import constants from '../../constants';
import { Hbar } from '@hashgraph/sdk';
import { Hbar } from 'kosi-sdk';

export class HbarLimitService implements IHbarLimitService {
static readonly TIER_LIMITS: Record<SubscriptionTier, Hbar> = {
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/

import { Web3 } from '../index';
import { Client } from '@hashgraph/sdk';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { Client } from 'kosi-sdk';

export class Web3Impl implements Web3 {
private client: Client;
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

import { PrivateKey } from '@hashgraph/sdk';
import { PrivateKey } from 'kosi-sdk';
import constants from './lib/constants';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import crypto from 'crypto';
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { expect } from 'chai';
import { ethers } from 'ethers';
import { v4 as uuid } from 'uuid';
import constants from '../src/lib/constants';
import { Hbar, HbarUnit } from '@hashgraph/sdk';
import { Hbar, HbarUnit } from 'kosi-sdk';
import { formatRequestIdMessage, numberTo0x, toHash32 } from '../src/formatters';
import { RedisInMemoryServer } from './redisInMemoryServer';
import { Logger } from 'pino';
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/errors/SDKClientError.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

import { expect } from 'chai';
import { Status } from '@hashgraph/sdk';
import { Status } from 'kosi-sdk';
import { SDKClientError } from '../../../src/lib/errors/SDKClientError'; // Update the path to point to the SDKClientError file

describe('SDKClientError', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/eth/eth-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { EthAddressHbarSpendingPlanRepository } from '../../../src/lib/db/reposi
import { HbarSpendingPlanRepository } from '../../../src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository';
import { IPAddressHbarSpendingPlanRepository } from '../../../src/lib/db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository';
import { HbarLimitService } from '../../../src/lib/services/hbarLimitService';
import { Hbar } from '@hashgraph/sdk';
import { Hbar } from 'kosi-sdk';
import { CacheService } from '../../../src/lib/services/cacheService/cacheService';

export function contractResultsByNumberByIndexURL(number: number, index: number): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/eth/eth_call.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
} from '../../helpers';
import { generateEthTestEnv } from './eth-helpers';
import { IContractCallRequest, IContractCallResponse, RequestDetails } from '../../../src/lib/types';
import { ContractFunctionResult } from '@hashgraph/sdk';
import { ContractFunctionResult } from 'kosi-sdk';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
Long,
TransactionId,
TransactionResponse,
} from '@hashgraph/sdk';
} from 'kosi-sdk';
import { HbarLimitService } from '../../../src/lib/services/hbarLimitService';
import { EventEmitter } from 'events';
import pino from 'pino';
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/ethGetBlockBy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { EthImpl } from '../../src/lib/eth';
import { MirrorNodeClient } from '../../src/lib/clients/mirrorNodeClient';
import pino from 'pino';
import { EventEmitter } from 'events';
import { Hbar } from '@hashgraph/sdk';
import { Hbar } from 'kosi-sdk';
import constants from '../../src/lib/constants';
import { Log, Transaction } from '../../src/lib/model';
import HAPIService from '../../src/lib/services/hapiService/hapiService';
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/hapiService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'
import pino from 'pino';
import { expect } from 'chai';
import EventEmitter from 'events';
import { Client, Hbar } from '@hashgraph/sdk';
import { Client, Hbar } from 'kosi-sdk';
import constants from '../../src/lib/constants';
import { register, Registry } from 'prom-client';
import { SDKClient } from '../../src/lib/clients';
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/openrpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import axios from 'axios';
import sinon from 'sinon';
import { expect } from 'chai';
import EventEmitter from 'events';
import { AccountInfo, Hbar } from '@hashgraph/sdk';
import MockAdapter from 'axios-mock-adapter';
import { AccountInfo, Hbar } from 'kosi-sdk';
import { BigNumber } from 'bignumber.js';
import { EthImpl } from '../../src/lib/eth';
import constants from '../../src/lib/constants';
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/precheck.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { expect } from 'chai';
import { Registry } from 'prom-client';
import { Hbar, HbarUnit } from '@hashgraph/sdk';
import { Hbar, HbarUnit } from 'kosi-sdk';
import pino from 'pino';
import { Precheck } from '../../src/lib/precheck';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/sdkClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import {
TransactionId,
TransactionRecordQuery,
TransactionResponse,
} from '@hashgraph/sdk';
} from 'kosi-sdk';
import { Context } from 'mocha';

const registry = new Registry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
IPAddressHbarSpendingPlanNotFoundError,
} from '../../../../src/lib/db/types/hbarLimiter/errors';
import { RequestDetails } from '../../../../src/lib/types';
import { Hbar } from '@hashgraph/sdk';
import { Hbar } from 'kosi-sdk';
import { Long } from 'long';

chai.use(chaiAsPromised);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { MirrorNodeClient, SDKClient } from '../../../../src/lib/clients';
import { HbarLimitService } from '../../../../src/lib/services/hbarLimitService';
import MetricService from '../../../../src/lib/services/metricService/metricService';
import { CacheService } from '../../../../src/lib/services/cacheService/cacheService';
import { AccountId, Client, Hbar, Long, Status, TransactionRecord, TransactionRecordQuery } from '@hashgraph/sdk';
import { AccountId, Client, Hbar, Long, Status, TransactionRecord, TransactionRecordQuery } from 'kosi-sdk';
import { IExecuteQueryEventPayload, IExecuteTransactionEventPayload, RequestDetails } from '../../../../src/lib/types';
import { HbarSpendingPlanRepository } from '../../../../src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository';
import { IPAddressHbarSpendingPlanRepository } from '../../../../src/lib/db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository';
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"koa-cors": "^0.0.16",
"koa-logger": "^3.2.1",
"koa-router": "^13.0.1",
"kosi-sdk": "1.0.1",
"pino": "^7.11.0",
"pino-pretty": "^7.6.1",
"uuid": "^3.3.2"
},
"devDependencies": {
"@hashgraph/sdk": "^2.50.0-beta.3",
"@koa/cors": "^5.0.0",
"@types/chai": "^4.3.0",
"@types/cors": "^2.8.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/tests/acceptance/equivalence.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { assert, expect } from 'chai';
import { Utils } from '../helpers/utils';
import ServicesClient from '../clients/servicesClient';
import { ContractFunctionParameters } from '@hashgraph/sdk';
import { ContractFunctionParameters } from 'kosi-sdk';
import EstimatePrecompileContractJson from '../contracts/EstimatePrecompileContract.json';
import Constants from '../helpers/constants';
import EquivalenceContractJson from '../contracts/EquivalenceContract.json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// external resources
import { solidity } from 'ethereum-waffle';
import chai, { expect } from 'chai';
import { ContractId } from '@hashgraph/sdk';
import { ContractId } from 'kosi-sdk';
//Constants are imported with different definitions for better readability in the code.
import Constants from '../../helpers/constants';
import RelayCall from '../../helpers/constants';
Expand Down
2 changes: 1 addition & 1 deletion packages/server/tests/acceptance/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import app from '../../dist/server';
import { app as wsApp } from '@hashgraph/json-rpc-ws-server/dist/webSocketServer';

// Hashgraph SDK
import { AccountId, Hbar } from '@hashgraph/sdk';
import { AccountId, Hbar } from 'kosi-sdk';

// Constants
import constants from '@hashgraph/json-rpc-relay/dist/lib/constants';
Expand Down
2 changes: 1 addition & 1 deletion packages/server/tests/acceptance/rpc_batch1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { expect } from 'chai';
import { ethers } from 'ethers';
import { AliasAccount } from '../types/AliasAccount';
import { Utils } from '../helpers/utils';
import { FileInfo, FileInfoQuery, Hbar, TransferTransaction } from '@hashgraph/sdk';
import { FileInfo, FileInfoQuery, Hbar, TransferTransaction } from 'kosi-sdk';

// Assertions from local resources
import Assertions from '../helpers/assertions';
Expand Down
2 changes: 1 addition & 1 deletion packages/server/tests/acceptance/rpc_batch2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { Utils } from '../helpers/utils';
import { predefined } from '@hashgraph/json-rpc-relay/dist';
import { EthImpl } from '@hashgraph/json-rpc-relay/dist/lib/eth';
import { numberTo0x } from '@hashgraph/json-rpc-relay/dist/formatters';
import { ContractId, Hbar, HbarUnit } from '@hashgraph/sdk';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { ContractId, Hbar, HbarUnit } from 'kosi-sdk';

// Assertions from local resources
import Assertions from '../helpers/assertions';
Expand Down
Loading
Loading