Skip to content

Commit 807d623

Browse files
feat: cherry pick to release/0.69.3 (#3885)
Signed-off-by: nikolay <[email protected]> Co-authored-by: konstantinabl <[email protected]>
1 parent e231e99 commit 807d623

File tree

15 files changed

+13
-264
lines changed

15 files changed

+13
-264
lines changed

docs/configuration.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Unless you need to set a non-default value, it is recommended to only populate o
3434
| `CLIENT_TRANSPORT_SECURITY` | "false" | Flag to enable or disable TLS for both networks. |
3535
| `CONSENSUS_MAX_EXECUTION_TIME` | "15000" | Maximum time in ms the SDK will wait when submitting a transaction/query before throwing a TIMEOUT error. |
3636
| `CONTRACT_CALL_GAS_LIMIT` | "50_000_000" | Maximum gas limit applied to eth_call endpoint networks, the Relay will accept up to 50M but keep it capped at 15M for the actual call. |
37-
| `CONTRACT_CODE_SIZE_LIMIT` | 24576 | Maximum contract code size in bytes (24KB by default) allowed for contract deployment transactions. This limit is enforced during transaction validation to prevent excessive gas consumption from oversized contracts. |
3837
| `CONTRACT_QUERY_TIMEOUT_RETRIES` | "3" | Maximum retries for failed contract call query with timeout exceeded error |
3938
| `DEBUG_API_ENABLED` | "false" | Enables all debug related methods: `debug_traceTransaction` |
4039
| `DEFAULT_RATE_LIMIT` | "200" | default fallback rate limit, if no other is configured. |

packages/config-service/src/services/globalConfig.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ const _CONFIG = {
148148
required: false,
149149
defaultValue: 50_000_000,
150150
},
151-
CONTRACT_CODE_SIZE_LIMIT: {
152-
envName: 'CONTRACT_CODE_SIZE_LIMIT',
153-
type: 'number',
154-
required: false,
155-
defaultValue: 24576, // 24KB
156-
},
157151
CONTRACT_QUERY_TIMEOUT_RETRIES: {
158152
envName: 'CONTRACT_QUERY_TIMEOUT_RETRIES',
159153
type: 'number',

packages/relay/src/lib/clients/mirrorNodeClient.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,6 @@ export class MirrorNodeClient {
15551555
* Retrieves and processes transaction record metrics from the mirror node based on the provided transaction ID.
15561556
*
15571557
* @param {string} transactionId - The ID of the transaction for which the record is being retrieved.
1558-
* @param {string} callerName - The name of the caller requesting the transaction record.
15591558
* @param {string} txConstructorName - The name of the transaction constructor associated with the transaction.
15601559
* @param {string} operatorAccountId - The account ID of the operator, used to calculate transaction fees.
15611560
* @param {RequestDetails} requestDetails - The request details for logging and tracking.
@@ -1564,7 +1563,6 @@ export class MirrorNodeClient {
15641563
*/
15651564
public async getTransactionRecordMetrics(
15661565
transactionId: string,
1567-
callerName: string,
15681566
txConstructorName: string,
15691567
operatorAccountId: string,
15701568
requestDetails: RequestDetails,
@@ -1573,7 +1571,7 @@ export class MirrorNodeClient {
15731571

15741572
if (this.logger.isLevelEnabled('debug')) {
15751573
this.logger.debug(
1576-
`${formattedRequestId} Get transaction record via mirror node: transactionId=${transactionId}, txConstructorName=${txConstructorName}, callerName=${callerName}`,
1574+
`${formattedRequestId} Get transaction record via mirror node: transactionId=${transactionId}, txConstructorName=${txConstructorName}`,
15771575
);
15781576
}
15791577

@@ -1591,7 +1589,7 @@ export class MirrorNodeClient {
15911589
);
15921590

15931591
if (!transactionRecords) {
1594-
const notFoundMessage = `No transaction record retrieved: transactionId=${transactionId}, txConstructorName=${txConstructorName}, callerName=${callerName}.`;
1592+
const notFoundMessage = `No transaction record retrieved: transactionId=${transactionId}, txConstructorName=${txConstructorName}.`;
15951593
throw new MirrorNodeClientError({ message: notFoundMessage }, MirrorNodeClientError.statusCodes.NOT_FOUND);
15961594
}
15971595

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,8 @@ export class SDKClient {
387387
executionMode: constants.EXECUTION_MODE.QUERY,
388388
transactionId: query.paymentTransactionId?.toString(),
389389
txConstructorName: queryConstructorName,
390-
callerName,
391390
cost: queryCost,
392391
gasUsed: 0,
393-
interactingEntity,
394392
status,
395393
requestDetails,
396394
originalCallerAddress,
@@ -487,11 +485,9 @@ export class SDKClient {
487485
if (transactionId?.length) {
488486
this.eventEmitter.emit(constants.EVENTS.EXECUTE_TRANSACTION, {
489487
transactionId,
490-
callerName,
491488
requestDetails,
492489
txConstructorName,
493490
operatorAccountId: this.clientMain.operatorAccountId!.toString(),
494-
interactingEntity,
495491
originalCallerAddress,
496492
} as IExecuteTransactionEventPayload);
497493
}
@@ -558,11 +554,9 @@ export class SDKClient {
558554
if (transactionResponse.transactionId) {
559555
this.eventEmitter.emit(constants.EVENTS.EXECUTE_TRANSACTION, {
560556
transactionId: transactionResponse.transactionId.toString(),
561-
callerName,
562557
requestDetails,
563558
txConstructorName,
564559
operatorAccountId: this.clientMain.operatorAccountId!.toString(),
565-
interactingEntity,
566560
originalCallerAddress,
567561
} as IExecuteTransactionEventPayload);
568562
}
@@ -736,7 +730,6 @@ export class SDKClient {
736730
*/
737731
public async getTransactionRecordMetrics(
738732
transactionId: string,
739-
callerName: string,
740733
txConstructorName: string,
741734
operatorAccountId: string,
742735
requestDetails: RequestDetails,
@@ -747,7 +740,7 @@ export class SDKClient {
747740
try {
748741
if (this.logger.isLevelEnabled('debug')) {
749742
this.logger.debug(
750-
`${requestDetails.formattedRequestId} Get transaction record via consensus node: transactionId=${transactionId}, txConstructorName=${txConstructorName}, callerName=${callerName}`,
743+
`${requestDetails.formattedRequestId} Get transaction record via consensus node: transactionId=${transactionId}, txConstructorName=${txConstructorName}`,
751744
);
752745
}
753746

@@ -769,7 +762,7 @@ export class SDKClient {
769762
const sdkClientError = new SDKClientError(e, e.message);
770763
this.logger.warn(
771764
e,
772-
`${requestDetails.formattedRequestId} Error raised during TransactionRecordQuery: transactionId=${transactionId}, txConstructorName=${txConstructorName}, callerName=${callerName}, recordStatus=${sdkClientError.status} (${sdkClientError.status._code}), cost=${transactionFee}, gasUsed=${gasUsed}`,
765+
`${requestDetails.formattedRequestId} Error raised during TransactionRecordQuery: transactionId=${transactionId}, txConstructorName=${txConstructorName}, recordStatus=${sdkClientError.status} (${sdkClientError.status._code}), cost=${transactionFee}, gasUsed=${gasUsed}`,
773766
);
774767
throw sdkClientError;
775768
}

packages/relay/src/lib/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ export default {
237237

238238
MAX_TRANSACTION_FEE_THRESHOLD: ConfigService.get('MAX_TRANSACTION_FEE_THRESHOLD'),
239239
SEND_RAW_TRANSACTION_SIZE_LIMIT: ConfigService.get('SEND_RAW_TRANSACTION_SIZE_LIMIT'),
240-
CONTRACT_CODE_SIZE_LIMIT: ConfigService.get('CONTRACT_CODE_SIZE_LIMIT'),
241240
CALL_DATA_SIZE_LIMIT: ConfigService.get('CALL_DATA_SIZE_LIMIT'),
242241

243242
INVALID_EVM_INSTRUCTION: '0xfe',

packages/relay/src/lib/errors/JsonRpcError.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ export const predefined = {
289289
code: -32201,
290290
message: `Oversized data: call data size ${actualSize}, call data size limit ${expectedSize}`,
291291
}),
292-
CONTRACT_CODE_SIZE_LIMIT_EXCEEDED: (actualSize: number, expectedSize: number) =>
293-
new JsonRpcError({
294-
code: -32201,
295-
message: `Oversized data: contract code size ${actualSize}, contract code size limit ${expectedSize}`,
296-
}),
297292
BATCH_REQUESTS_DISABLED: new JsonRpcError({
298293
code: -32202,
299294
message: 'Batch requests are disabled',

packages/relay/src/lib/precheck.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export class Precheck {
6363
networkGasPriceInWeiBars: number,
6464
requestDetails: RequestDetails,
6565
): Promise<void> {
66-
this.contractCodeSize(parsedTx);
6766
this.callDataSize(parsedTx);
6867
this.transactionSize(parsedTx);
6968
this.transactionType(parsedTx, requestDetails);
@@ -383,21 +382,4 @@ export class Precheck {
383382
}
384383
}
385384
}
386-
387-
/**
388-
* Validates that the contract code size is within the allowed limit.
389-
* This check is only performed for contract creation transactions (where tx.to is null).
390-
* This limits contract code size to prevent excessive gas consumption.
391-
*
392-
* @param {Transaction} tx - The transaction to validate.
393-
* @throws {JsonRpcError} If the contract code size exceeds the configured limit.
394-
*/
395-
contractCodeSize(tx: Transaction): void {
396-
if (!tx.to) {
397-
const contractCodeSize = tx.data.replace('0x', '').length / 2;
398-
if (contractCodeSize > constants.CONTRACT_CODE_SIZE_LIMIT) {
399-
throw predefined.CONTRACT_CODE_SIZE_LIMIT_EXCEEDED(contractCodeSize, constants.CONTRACT_CODE_SIZE_LIMIT);
400-
}
401-
}
402-
}
403385
}

packages/relay/src/lib/services/metricService/metricService.ts

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,14 @@ export default class MetricService {
136136
* @returns {Promise<void>} - A promise that resolves when the transaction metrics have been captured.
137137
*/
138138
public async captureTransactionMetrics({
139-
callerName,
140139
transactionId,
141140
txConstructorName,
142141
operatorAccountId,
143-
interactingEntity,
144142
requestDetails,
145143
originalCallerAddress,
146144
}: IExecuteTransactionEventPayload): Promise<void> {
147145
const transactionRecordMetrics = await this.getTransactionRecordMetrics(
148146
transactionId,
149-
callerName,
150147
txConstructorName,
151148
operatorAccountId,
152149
requestDetails,
@@ -159,10 +156,8 @@ export default class MetricService {
159156
executionMode: constants.EXECUTION_MODE.TRANSACTION,
160157
transactionId,
161158
txConstructorName,
162-
callerName,
163159
cost: transactionFee,
164160
gasUsed,
165-
interactingEntity,
166161
status,
167162
requestDetails,
168163
originalCallerAddress,
@@ -174,10 +169,8 @@ export default class MetricService {
174169
executionMode: constants.EXECUTION_MODE.RECORD,
175170
transactionId,
176171
txConstructorName,
177-
callerName,
178172
cost: txRecordChargeAmount,
179173
gasUsed: 0,
180-
interactingEntity,
181174
status,
182175
requestDetails,
183176
originalCallerAddress,
@@ -193,10 +186,8 @@ export default class MetricService {
193186
* @param {string} payload.executionMode - The mode of the execution (TRANSACTION, QUERY, RECORD).
194187
* @param {string} payload.transactionId - The unique identifier for the transaction.
195188
* @param {string} payload.txConstructorName - The name of the transaction constructor.
196-
* @param {string} payload.callerName - The name of the entity calling the transaction.
197189
* @param {number} payload.cost - The cost of the transaction in tinybars.
198190
* @param {number} payload.gasUsed - The amount of gas used during the transaction.
199-
* @param {string} payload.interactingEntity - The entity interacting with the transaction.
200191
* @param {string} payload.status - The entity interacting with the transaction.
201192
* @param {string} payload.requestDetails - The request details for logging and tracking.
202193
* @param {string | undefined} payload.originalCallerAddress - The address of the original caller making the request.
@@ -206,22 +197,20 @@ export default class MetricService {
206197
executionMode,
207198
transactionId,
208199
txConstructorName,
209-
callerName,
210200
cost,
211201
gasUsed,
212-
interactingEntity,
213202
status,
214203
requestDetails,
215204
originalCallerAddress,
216205
}: IExecuteQueryEventPayload): Promise<void> => {
217206
if (this.logger.isLevelEnabled('debug')) {
218207
this.logger.debug(
219-
`${requestDetails.formattedRequestId} Capturing transaction fee charged to operator: executionMode=${executionMode} transactionId=${transactionId}, txConstructorName=${txConstructorName}, callerName=${callerName}, cost=${cost} tinybars`,
208+
`${requestDetails.formattedRequestId} Capturing transaction fee charged to operator: executionMode=${executionMode} transactionId=${transactionId}, txConstructorName=${txConstructorName}, cost=${cost} tinybars`,
220209
);
221210
}
222211

223212
await this.hbarLimitService.addExpense(cost, originalCallerAddress ?? '', requestDetails);
224-
this.captureMetrics(executionMode, txConstructorName, status, cost, gasUsed, callerName, interactingEntity);
213+
this.captureMetrics(executionMode, txConstructorName, status, cost, gasUsed);
225214
};
226215

227216
/**
@@ -235,7 +224,7 @@ export default class MetricService {
235224
return new Histogram({
236225
name: metricHistogramCost,
237226
help: 'Relay consensusnode mode type status cost histogram',
238-
labelNames: ['mode', 'type', 'status', 'caller', 'interactingEntity'],
227+
labelNames: ['mode', 'type', 'status'],
239228
registers: [register],
240229
});
241230
}
@@ -251,7 +240,7 @@ export default class MetricService {
251240
return new Histogram({
252241
name: metricHistogramGasFee,
253242
help: 'Relay consensusnode mode type status gas fee histogram',
254-
labelNames: ['mode', 'type', 'status', 'caller', 'interactingEntity'],
243+
labelNames: ['mode', 'type', 'status'],
255244
registers: [register],
256245
});
257246
}
@@ -275,21 +264,11 @@ export default class MetricService {
275264
* @param {string} status - The status of the transaction.
276265
* @param {number} cost - The cost of the transaction in tinybars.
277266
* @param {number} gas - The gas used by the transaction.
278-
* @param {string} caller - The name of the caller executing the transaction.
279-
* @param {string} interactingEntity - The entity interacting with the transaction.
280267
* @returns {void}
281268
*/
282-
private captureMetrics = (
283-
mode: string,
284-
type: string,
285-
status: string,
286-
cost: number,
287-
gas: number,
288-
caller: string,
289-
interactingEntity: string,
290-
): void => {
291-
this.consensusNodeClientHistogramCost.labels(mode, type, status, caller, interactingEntity).observe(cost);
292-
this.consensusNodeClientHistogramGasFee.labels(mode, type, status, caller, interactingEntity).observe(gas);
269+
private captureMetrics = (mode: string, type: string, status: string, cost: number, gas: number): void => {
270+
this.consensusNodeClientHistogramCost.labels(mode, type, status).observe(cost);
271+
this.consensusNodeClientHistogramGasFee.labels(mode, type, status).observe(gas);
293272
};
294273

295274
/**
@@ -298,15 +277,13 @@ export default class MetricService {
298277
* consensus node via the SDK client or from the mirror node.
299278
*
300279
* @param {string} transactionId - The ID of the transaction for which metrics are being retrieved.
301-
* @param {string} callerName - The name of the caller requesting the metrics.
302280
* @param {string} txConstructorName - The name of the transaction constructor.
303281
* @param {string} operatorAccountId - The account ID of the operator.
304282
* @param {RequestDetails} requestDetails - The request details for logging and tracking.
305283
* @returns {Promise<ITransactionRecordMetric | undefined>} - The transaction record metrics or undefined if retrieval fails.
306284
*/
307285
private async getTransactionRecordMetrics(
308286
transactionId: string,
309-
callerName: string,
310287
txConstructorName: string,
311288
operatorAccountId: string,
312289
requestDetails: RequestDetails,
@@ -318,15 +295,13 @@ export default class MetricService {
318295
if (defaultToConsensusNode) {
319296
return await this.sdkClient.getTransactionRecordMetrics(
320297
transactionId,
321-
callerName,
322298
txConstructorName,
323299
operatorAccountId,
324300
requestDetails,
325301
);
326302
} else {
327303
return await this.mirrorNodeClient.getTransactionRecordMetrics(
328304
transactionId,
329-
callerName,
330305
txConstructorName,
331306
operatorAccountId,
332307
requestDetails,

packages/relay/src/lib/types/events.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ export interface IExecuteQueryEventPayload {
1616
executionMode: string;
1717
transactionId: string;
1818
txConstructorName: string;
19-
callerName: string;
2019
cost: number;
2120
gasUsed: number;
22-
interactingEntity: string;
2321
status: string;
2422
requestDetails: RequestDetails;
2523
originalCallerAddress: string | undefined;

packages/relay/tests/lib/mirrorNodeClient.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,6 @@ describe('MirrorNodeClient', async function () {
14671467

14681468
const transactionRecordMetrics = await mirrorNodeInstance.getTransactionRecordMetrics(
14691469
mockedTransactionId,
1470-
mockedCallerName,
14711470
mockedConstructorName,
14721471
operatorAcocuntId,
14731472
requestDetails,
@@ -1482,15 +1481,14 @@ describe('MirrorNodeClient', async function () {
14821481
try {
14831482
await mirrorNodeInstance.getTransactionRecordMetrics(
14841483
mockedTransactionId,
1485-
mockedCallerName,
14861484
mockedConstructorName,
14871485
operatorAcocuntId,
14881486
requestDetails,
14891487
);
14901488

14911489
expect.fail('should have thrown an error');
14921490
} catch (error) {
1493-
const notFoundMessage = `No transaction record retrieved: transactionId=${mockedTransactionId}, txConstructorName=${mockedConstructorName}, callerName=${mockedCallerName}.`;
1491+
const notFoundMessage = `No transaction record retrieved: transactionId=${mockedTransactionId}, txConstructorName=${mockedConstructorName}.`;
14941492
const expectedError = new MirrorNodeClientError(
14951493
{ message: notFoundMessage },
14961494
MirrorNodeClientError.statusCodes.NOT_FOUND,

0 commit comments

Comments
 (0)