From 87f6383f4a81a6a8d1b7bac8c6d56c214550a316 Mon Sep 17 00:00:00 2001 From: Julian <52217955+julianmerlo95@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:18:53 -0300 Subject: [PATCH] [Blockchain Watcher] (FIX) Improve evm logs (#1130) * Improve evm log * Mapped last cursos for sui * Mapped last cursos for sui --------- Co-authored-by: julian merlo --- .../domain/actions/sui/PollSuiTransactions.ts | 37 ++++++++++--------- .../evm/evmRedeemedTransactionFoundMapper.ts | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/blockchain-watcher/src/domain/actions/sui/PollSuiTransactions.ts b/blockchain-watcher/src/domain/actions/sui/PollSuiTransactions.ts index 953b9707..2ede0498 100644 --- a/blockchain-watcher/src/domain/actions/sui/PollSuiTransactions.ts +++ b/blockchain-watcher/src/domain/actions/sui/PollSuiTransactions.ts @@ -18,7 +18,7 @@ export class PollSuiTransactions extends RunPollingJob { protected readonly logger: Logger; private cursor?: Cursor; - private lastCheckpoint?: bigint; + private currentCheckpoint?: bigint; constructor( private readonly cfg: PollSuiTransactionsConfig, @@ -33,6 +33,7 @@ export class PollSuiTransactions extends RunPollingJob { protected async preHook(): Promise { const metadata = await this.metadataRepo.get(this.cfg.id); if (metadata) { + this.currentCheckpoint = metadata.lastCursor?.checkpoint; this.cursor = metadata.lastCursor; } } @@ -48,23 +49,6 @@ export class PollSuiTransactions extends RunPollingJob { return true; } - protected report(): void { - const labels = { - job: this.cfg.id, - chain: "sui", - commitment: "immediate", - }; - this.statsRepo.count("job_execution", labels); - this.statsRepo.measure("polling_cursor", BigInt(this.lastCheckpoint ?? 0), { - ...labels, - type: "max", - }); - this.statsRepo.measure("polling_cursor", BigInt(this.cursor?.checkpoint ?? 0n), { - ...labels, - type: "current", - }); - } - protected async get(): Promise { this.cursor = await this.getCursor(); @@ -119,6 +103,23 @@ export class PollSuiTransactions extends RunPollingJob { await this.metadataRepo.save(this.cfg.id, { lastCursor: this.cursor }); } } + + protected report(): void { + const labels = { + job: this.cfg.id, + chain: "sui", + commitment: "immediate", + }; + this.statsRepo.count("job_execution", labels); + this.statsRepo.measure("polling_cursor", BigInt(this.cursor?.checkpoint ?? 0), { + ...labels, + type: "max", + }); + this.statsRepo.measure("polling_cursor", BigInt(this.currentCheckpoint ?? 0n), { + ...labels, + type: "current", + }); + } } export class PollSuiTransactionsConfig { diff --git a/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts b/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts index a0128fa6..fdbd75c0 100644 --- a/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts +++ b/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts @@ -36,7 +36,7 @@ export const evmRedeemedTransactionFoundMapper = ( if (protocol && protocol.type && protocol.method) { logger.debug( - `[${transaction.chain}] Transaction info: [hash: ${transaction.hash}][VAA: ${emitterChain}/${emitterAddress}/${sequence}]` + `[${transaction.chain}] Transaction info: [hash: ${transaction.hash}][VAA: ${emitterChain}/${emitterAddress}/${sequence}][protocol: ${protocol.type}/${protocol.method}]` ); return {