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: change block timestamp db type #139

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ export class V3FundsDeposited {
createdAt: Date;

@Column({ nullable: true })
blockTimestamp?: number;
blockTimestamp?: Date;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class V3FundsDeposited1733407862579 implements MigrationInterface {
name = "V3FundsDeposited1733407862579";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "evm"."v3_funds_deposited" DROP COLUMN "blockTimestamp"`,
);
await queryRunner.query(
`ALTER TABLE "evm"."v3_funds_deposited" ADD "blockTimestamp" TIMESTAMP`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "evm"."v3_funds_deposited" DROP COLUMN "blockTimestamp"`,
);
}
}
8 changes: 4 additions & 4 deletions packages/indexer/src/database/SpokePoolRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export class SpokePoolRepository extends dbUtils.BlockchainEventRepository {
delete event.updatedRecipient;
delete event.updatedOutputAmount;
delete event.updatedMessage;

const blockTimestamp = new Date(blockTimes[event.blockNumber]! * 1000);
return {
...event,
relayHash: across.utils.getRelayHashFromEvent(event),
...this.formatRelayData(event),
quoteTimestamp: new Date(event.quoteTimestamp * 1000),
finalised: event.blockNumber <= lastFinalisedBlock,
blockTimestamp: blockTimes[event.blockNumber],
blockTimestamp,
};
});
const chunkedEvents = across.utils.chunk(formattedEvents, this.chunkSize);
Expand All @@ -70,10 +70,10 @@ export class SpokePoolRepository extends dbUtils.BlockchainEventRepository {
const result = savedEvents.flat();

// Log the time difference for each deposit event for profiling in datadog
const now = Date.now();
const now = new Date();
formattedEvents.forEach((event) => {
if (event.blockTimestamp === undefined) return;
const timeDifference = now - event.blockTimestamp * 1000;
const timeDifference = now.getTime() - event.blockTimestamp.getTime();
this.logger.debug({
at: "SpokePoolRepository#formatAndSaveV3FundsDepositedEvents",
message: "V3FundsDepositedEvent profile",
Expand Down
Loading