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: add mainnet warning (tmp) #139

Merged
merged 2 commits into from
Dec 19, 2023
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
756 changes: 754 additions & 2 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<the-header :class="$route?.name" />
<div class="container-app">
<NetworkDeprecated v-if="!currentNetwork.maintenance && currentNetwork.name === 'goerli'" />
<IssuesBanner v-if="!currentNetwork.maintenance && currentNetwork.name === 'mainnet'" />
<MaintenanceView v-if="currentNetwork.maintenance" />
<router-view v-else />
</div>
Expand All @@ -13,6 +14,7 @@
<script setup lang="ts">
import { useTitle } from "@vueuse/core";

import IssuesBanner from "@/components/IssuesBanner.vue";
import NetworkDeprecated from "@/components/NetworkDeprecated.vue";
import TheFooter from "@/components/TheFooter.vue";
import TheHeader from "@/components/header/TheHeader.vue";
Expand Down
31 changes: 31 additions & 0 deletions packages/app/src/components/IssuesBanner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template v-if="newNetworkUrl">
<div class="issues-alert">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M21.0907 18.7005C20.8457 19.1905 20.3449 19.5 19.7971 19.5H4.20288C3.65506 19.5 3.15426 19.1905 2.90927 18.7005C2.69455 18.2711 2.70694 17.7631 2.94232 17.3446L10.9455 3.11671C11.1598 2.73575 11.5629 2.5 12 2.5C12.4371 2.5 12.8402 2.73575 13.0545 3.11671L21.0577 17.3446C21.2931 17.7631 21.3054 18.2711 21.0907 18.7005Z"
stroke="#FFC81A"
/>
<circle cx="12" cy="16" r="1" fill="#FFC81A" />
<path d="M12 14V6" stroke="#FFC81A" />
</svg>
<span>
The network is under a heavy load at the moment and transaction indexing on the explorer is lagging behind.
Transactions are being processed normally and will gradually show up. You can also use
<a href="https://hyperscan.xyz/">hyperscan.xyz</a> meanwhile.
</span>
</div>
</template>

<style scoped lang="scss">
.issues-alert {
@apply flex text-white rounded-2xl border border-amber-400/50 bg-amber-400/10 mb-6 py-3 px-4;

svg {
@apply mr-2 shrink-0;
}

a {
@apply text-inherit;
}
}
</style>
8 changes: 8 additions & 0 deletions packages/app/src/components/header/TheHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ const hasContent = computed(() => {
.hero-banner-container {
@apply absolute left-0 top-full flex h-64 w-full items-end justify-end overflow-hidden bg-primary-900;

&.mainnet {
@apply h-[27rem] md:h-[23rem] lg:h-[20rem];
}

&.goerli {
@apply h-[25rem] md:h-[23rem] lg:h-[19rem];
}
Expand All @@ -316,6 +320,10 @@ const hasContent = computed(() => {
.home-banner {
@apply h-80;

&.mainnet {
@apply h-[32rem] md:h-[28rem] lg:h-[25rem];
}

&.goerli {
@apply h-[30rem] md:h-[27rem] lg:h-[24rem];
}
Expand Down
1 change: 1 addition & 0 deletions packages/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@willsoto/nestjs-prometheus": "^4.7.0",
"axios": "^1.4.0",
"ethers": "^5.7.1",
"firebase": "^10.7.1",
"nest-winston": "^1.7.0",
"pg": "^8.8.0",
"prom-client": "^14.1.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/worker/src/health/health.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ describe("HealthController", () => {
});

describe("check", () => {
it("checks health of the DB", async () => {
await healthController.check();
expect(dbHealthCheckerMock.pingCheck).toHaveBeenCalledTimes(1);
expect(dbHealthCheckerMock.pingCheck).toHaveBeenCalledWith("database");
});
// it("checks health of the DB", async () => {
// await healthController.check();
// expect(dbHealthCheckerMock.pingCheck).toHaveBeenCalledTimes(1);
// expect(dbHealthCheckerMock.pingCheck).toHaveBeenCalledWith("database");
// });

it("checks health of the JSON RPC provider", async () => {
await healthController.check();
Expand Down
6 changes: 3 additions & 3 deletions packages/worker/src/health/health.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger, Controller, Get } from "@nestjs/common";
import { HealthCheckService, TypeOrmHealthIndicator, HealthCheck, HealthCheckResult } from "@nestjs/terminus";
import { HealthCheckService, /*TypeOrmHealthIndicator,*/ HealthCheck, HealthCheckResult } from "@nestjs/terminus";
import { JsonRpcHealthIndicator } from "./jsonRpcProvider.health";

@Controller(["health", "ready"])
Expand All @@ -8,7 +8,7 @@ export class HealthController {

constructor(
private readonly healthCheckService: HealthCheckService,
private readonly dbHealthChecker: TypeOrmHealthIndicator,
//private readonly dbHealthChecker: TypeOrmHealthIndicator,
private readonly jsonRpcHealthIndicator: JsonRpcHealthIndicator
) {
this.logger = new Logger(HealthController.name);
Expand All @@ -19,7 +19,7 @@ export class HealthController {
public async check(): Promise<HealthCheckResult> {
try {
return await this.healthCheckService.check([
() => this.dbHealthChecker.pingCheck("database"),
//() => this.dbHealthChecker.pingCheck("database"),
() => this.jsonRpcHealthIndicator.isHealthy("jsonRpcProvider"),
]);
} catch (error) {
Expand Down
43 changes: 43 additions & 0 deletions packages/worker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,55 @@ import { ConfigService } from "@nestjs/config";
import logger from "./logger";
import { AppModule } from "./app.module";

import { initializeApp } from "firebase/app";
import { getFirestore, onSnapshot, doc } from "firebase/firestore";

const firebaseApp = initializeApp({
projectId: "scan-v2",
});
const db = getFirestore(firebaseApp);

const getConfig = async (instanceId: string): Promise<{ fromBlock: string; toBlock: string }> => {
return new Promise((resolve, reject) => {
const unsubscribe = onSnapshot(
doc(db, "config", "worker"),
(data) => {
if (data.exists()) {
const config = data.data() as Record<string, { fromBlock: string; toBlock: string }>;
if (config[instanceId] && config[instanceId].fromBlock && config[instanceId].toBlock) {
unsubscribe();
resolve(config[instanceId]);
}
}
},
(e) => {
logger.error(e);
reject(e);
}
);
});
};

async function bootstrap() {
process.on("uncaughtException", function (error) {
logger.error(error.message, error.stack, "UnhandledExceptions");
process.exit(1);
});

if (process.env.USE_REMOTE_CONFIG === "true") {
const config = await getConfig(process.env.HOSTNAME);
if (!config.fromBlock || !config.toBlock) {
throw new Error("Missing fromBlock or toBlock in config");
}
logger.log(`Using fromBlock: ${config.fromBlock}, toBlock: ${config.toBlock}`);
process.env.FROM_BLOCK = config.fromBlock;
process.env.TO_BLOCK = config.toBlock;
process.env.DISABLE_BATCHES_PROCESSING = "true";
process.env.DISABLE_COUNTERS_PROCESSING = "true";
process.env.DISABLE_OLD_BALANCES_CLEANER = "true";
process.env.DISABLE_BLOCKS_REVERT = "true";
}

const app = await NestFactory.create(AppModule, {
logger,
});
Expand Down
Loading