[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 <julianmerlo@julians-MacBook-Pro.local>
This commit is contained in:
Julian 2024-02-15 16:18:53 -03:00 committed by GitHub
parent 024c29d67d
commit 87f6383f4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 19 deletions

View File

@ -18,7 +18,7 @@ export class PollSuiTransactions extends RunPollingJob {
protected readonly logger: Logger; protected readonly logger: Logger;
private cursor?: Cursor; private cursor?: Cursor;
private lastCheckpoint?: bigint; private currentCheckpoint?: bigint;
constructor( constructor(
private readonly cfg: PollSuiTransactionsConfig, private readonly cfg: PollSuiTransactionsConfig,
@ -33,6 +33,7 @@ export class PollSuiTransactions extends RunPollingJob {
protected async preHook(): Promise<void> { protected async preHook(): Promise<void> {
const metadata = await this.metadataRepo.get(this.cfg.id); const metadata = await this.metadataRepo.get(this.cfg.id);
if (metadata) { if (metadata) {
this.currentCheckpoint = metadata.lastCursor?.checkpoint;
this.cursor = metadata.lastCursor; this.cursor = metadata.lastCursor;
} }
} }
@ -48,23 +49,6 @@ export class PollSuiTransactions extends RunPollingJob {
return true; 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<any[]> { protected async get(): Promise<any[]> {
this.cursor = await this.getCursor(); this.cursor = await this.getCursor();
@ -119,6 +103,23 @@ export class PollSuiTransactions extends RunPollingJob {
await this.metadataRepo.save(this.cfg.id, { lastCursor: this.cursor }); 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 { export class PollSuiTransactionsConfig {

View File

@ -36,7 +36,7 @@ export const evmRedeemedTransactionFoundMapper = (
if (protocol && protocol.type && protocol.method) { if (protocol && protocol.type && protocol.method) {
logger.debug( 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 { return {