Skip to content

Commit

Permalink
chore: cherry-pick #2141: adding logs for eth_call size and gas (#2141)…
Browse files Browse the repository at this point in the history
… (#2143)

adding logs for eth_call size and gas (#2141)

Signed-off-by: Alfredo Gutierrez <alfredo@swirldslabs.com>
  • Loading branch information
AlfredoG87 authored Feb 23, 2024
1 parent 41d165f commit 534f06b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1455,9 +1455,15 @@ export class EthImpl implements Eth {
* @param blockParam
*/
async call(call: any, blockParam: string | object | null, requestIdPrefix?: string): Promise<string | JsonRpcError> {
const callData = call.data ? call.data : call.value;
// log request
this.logger.trace(
`${requestIdPrefix} call({to=${call.to}, from=${call.from}, value=${call.value}, gas=${call.gas}, ...}, blockParam=${blockParam})`,
`${requestIdPrefix} call({to=${call.to}, from=${call.from}, data=${callData}, gas=${call.gas}, ...}, blockParam=${blockParam})`,
);
// log call data size and gas
const callDataSize = callData ? callData.length : 0;
this.logger.trace(`${requestIdPrefix} call data size: ${callDataSize}, gas: ${call.gas}`);
// metrics for selector
if (call.data?.length >= constants.FUNCTION_SELECTOR_CHAR_LENGTH)
this.ethExecutionsCounter
.labels(EthImpl.ethCall, call.data.substring(0, constants.FUNCTION_SELECTOR_CHAR_LENGTH))
Expand Down

0 comments on commit 534f06b

Please sign in to comment.