diff --git a/apps/api/env/.env b/apps/api/env/.env index 8ed9f3d79..6a1f3ca6c 100644 --- a/apps/api/env/.env +++ b/apps/api/env/.env @@ -1,5 +1,5 @@ AKASHLYTICS_CORS_WEBSITE_URLS=https://cloudmos.io,https://www.cloudmos.io,http://debug.cloudmos.io,https://deploy.cloudmos.io,https://beta.cloudmos.io,https://stats.akash.network,https://console.akash.network,https://akash.network,https://akash.hooman.digital,http://localhost:3000,http://localhost:3001,https://beta2.cloudmos.io,https://beta3.cloudmos.io,https://akashconsole.vercel.app,https://console-beta.akash.network -WebsiteUrl=https://console-beta.akash.network +WEBSITE_URL=https://console-beta.akash.network TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT=10000000 DEPLOYMENT_ALLOWANCE_REFILL_AMOUNT=10000000 DEPLOYMENT_ALLOWANCE_REFILL_THRESHOLD=1000000 diff --git a/apps/api/env/.env.functional.test b/apps/api/env/.env.functional.test index 7b3633ae7..554f5bcff 100644 --- a/apps/api/env/.env.functional.test +++ b/apps/api/env/.env.functional.test @@ -1,5 +1,5 @@ -AkashSandboxDatabaseCS=postgres://postgres:password@localhost:5432/console-akash-sandbox -UserDatabaseCS=postgres://postgres:password@localhost:5432/console-users +AKASH_SANDBOX_DATABASE_CS=postgres://postgres:password@localhost:5432/console-akash-sandbox +USER_DATABASE_CS=postgres://postgres:password@localhost:5432/console-users POSTGRES_DB_URI=postgres://postgres:password@localhost:5432/console-users MASTER_WALLET_MNEMONIC="motion isolate mother convince snack twenty tumble boost elbow bundle modify balcony" NETWORK=sandbox diff --git a/apps/api/env/.env.production b/apps/api/env/.env.production index 71e414942..50846f66a 100644 --- a/apps/api/env/.env.production +++ b/apps/api/env/.env.production @@ -1,8 +1,8 @@ -Auth0JWKSUri=https://cloudmos-prod.us.auth0.com/.well-known/jwks.json -Auth0Audience=https://api.cloudmos.io -Auth0Issuer=https://auth.cloudmos.io/ +AUTH0_JWKS_URI=https://cloudmos-prod.us.auth0.com/.well-known/jwks.json +AUTH0_AUDIENCE=https://api.cloudmos.io +AUTH0_ISSUER=https://auth.cloudmos.io/ PORT=80 -ServerOrigin=https://api.cloudmos.io +SERVER_ORIGIN=https://api.cloudmos.io DRIZZLE_MIGRATIONS_FOLDER=./dist/drizzle SENTRY_ENABLED=true BILLING_ENABLED=false diff --git a/apps/api/env/.env.sample b/apps/api/env/.env.sample index 3e0439b3a..879a0139c 100644 --- a/apps/api/env/.env.sample +++ b/apps/api/env/.env.sample @@ -1,22 +1,21 @@ # Secrets -AkashDatabaseCS= -AkashlyticsGithubPAT= +AKASH_DATABASE_CS= +AKASHLYTICS_GITHUB_PAT= ANONYMOUS_USER_TOKEN_SECRET= HealthChecks_SyncAKTMarketData= MASTER_WALLET_MNEMONIC= POSTGRES_DB_URI= -SecretToken= -SentryDSN= +SECRET_TOKEN= SENTRY_DSN= -UserDatabaseCS= STRIPE_SECRET_KEY= STRIPE_PRICE_ID= +USER_DATABASE_CS= # Configuration AKASHLYTICS_CORS_WEBSITE_URLS= -Auth0Audience= -Auth0Issuer= -Auth0JWKSUri= +AUTH0_AUDIENCE= +AUTH0_ISSUER= +AUTH0_JWKS_URI= BILLING_ENABLED= DEPLOYMENT_ALLOWANCE_REFILL_AMOUNT= DEPLOYMENT_ALLOWANCE_REFILL_THRESHOLD= @@ -25,7 +24,7 @@ DEPLOYMENT_GRANT_DENOM= DRIZZLE_MIGRATIONS_FOLDER= FEE_ALLOWANCE_REFILL_AMOUNT= FEE_ALLOWANCE_REFILL_THRESHOLD= -HealthchecksEnabled= +HEALTHCHECKS_ENABLED= LOG_LEVEL= NETWORK= PORT= @@ -34,7 +33,7 @@ SENTRY_ENABLED= SENTRY_SERVER_NAME= SentryServerName= SENTRY_TRACES_RATE= -ServerOrigin= +SERVER_ORIGIN= TRIAL_DEPLOYMENT_ALLOWANCE_AMOUNT= TRIAL_FEES_ALLOWANCE_AMOUNT= -WebsiteUrl= \ No newline at end of file +WEBSITE_URL= \ No newline at end of file diff --git a/apps/api/env/.env.staging b/apps/api/env/.env.staging index f214a695a..de43a1679 100644 --- a/apps/api/env/.env.staging +++ b/apps/api/env/.env.staging @@ -1,8 +1,8 @@ -ServerOrigin=https://api-sandbox.cloudmos.io +SERVER_ORIGIN=https://api-sandbox.cloudmos.io DRIZZLE_MIGRATIONS_FOLDER=./dist/drizzle -Auth0JWKSUri=https://dev-5aprb0lr.us.auth0.com/.well-known/jwks.json -Auth0Audience=https://api.cloudmos.io -Auth0Issuer=https://dev-5aprb0lr.us.auth0.com/ +AUTH0_JWKS_URI=https://dev-5aprb0lr.us.auth0.com/.well-known/jwks.json +AUTH0_AUDIENCE=https://api.cloudmos.io +AUTH0_ISSUER=https://dev-5aprb0lr.us.auth0.com/ SENTRY_TRACES_RATE=1.0 SENTRY_ENABLED=true BILLING_ENABLED=true diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index 3290a049c..d1dc65cf2 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -40,7 +40,7 @@ appHono.use( const { PORT = 3080, BILLING_ENABLED } = process.env; const scheduler = new Scheduler({ - healthchecksEnabled: env.HealthchecksEnabled === "true", + healthchecksEnabled: env.HEALTHCHECKS_ENABLED === "true", errorHandler: (task, error) => { console.error(`Task "${task.name}" failed: ${error}`); getSentry().captureException(error); diff --git a/apps/api/src/auth/services/auth.interceptor.ts b/apps/api/src/auth/services/auth.interceptor.ts index 8146e2fab..84e22dd3d 100644 --- a/apps/api/src/auth/services/auth.interceptor.ts +++ b/apps/api/src/auth/services/auth.interceptor.ts @@ -53,7 +53,7 @@ export class AuthInterceptor implements HonoInterceptor { private async getValidUserId(bearer: string, c: Context) { const token = bearer.replace(/^Bearer\s+/i, ""); - const jwks = await getJwks(env.Auth0JWKSUri || c.env?.JWKS_URI, useKVStore(kvStore || c.env?.VERIFY_RSA_JWT), c.env?.VERIFY_RSA_JWT_JWKS_CACHE_KEY); + const jwks = await getJwks(env.AUTH0_JWKS_URI || c.env?.JWKS_URI, useKVStore(kvStore || c.env?.VERIFY_RSA_JWT), c.env?.VERIFY_RSA_JWT_JWKS_CACHE_KEY); const result = await verify(token, jwks); return (result.payload as { sub: string }).sub; diff --git a/apps/api/src/db/dbConnection.ts b/apps/api/src/db/dbConnection.ts index 3d36b29fa..242f649c8 100644 --- a/apps/api/src/db/dbConnection.ts +++ b/apps/api/src/db/dbConnection.ts @@ -13,9 +13,9 @@ function isValidNetwork(network: string): network is keyof typeof csMap { } const csMap = { - mainnet: env.AkashDatabaseCS, - testnet: env.AkashTestnetDatabaseCS, - sandbox: env.AkashSandboxDatabaseCS + mainnet: env.AKASH_DATABASE_CS, + testnet: env.AKASH_TESTNET_DATABASE_CS, + sandbox: env.AKASH_SANDBOX_DATABASE_CS }; if (!isValidNetwork(env.NETWORK)) { @@ -63,7 +63,7 @@ export const chainDbs: { [key: string]: Sequelize } = Object.keys(chainDefinitio {} ); -export const userDb = new Sequelize(env.UserDatabaseCS, { +export const userDb = new Sequelize(env.USER_DATABASE_CS, { dialectModule: pg, logging, logQueryParameters: true, diff --git a/apps/api/src/middlewares/privateMiddleware.ts b/apps/api/src/middlewares/privateMiddleware.ts index 5b7562272..52e3030f3 100644 --- a/apps/api/src/middlewares/privateMiddleware.ts +++ b/apps/api/src/middlewares/privateMiddleware.ts @@ -3,9 +3,9 @@ import { Context, Next } from "hono"; import { env } from "@src/utils/env"; export async function privateMiddleware(c: Context, next: Next) { - if (!env.SecretToken) { + if (!env.SECRET_TOKEN) { await next(); - } else if (c.req.query("token") === env.SecretToken) { + } else if (c.req.query("token") === env.SECRET_TOKEN) { await next(); } else { return c.text("Unauthorized", 401); diff --git a/apps/api/src/middlewares/userMiddleware.ts b/apps/api/src/middlewares/userMiddleware.ts index 8acc3bc3e..968f97587 100644 --- a/apps/api/src/middlewares/userMiddleware.ts +++ b/apps/api/src/middlewares/userMiddleware.ts @@ -21,12 +21,12 @@ export const kvStore = { }; export const requiredUserMiddleware = verifyRsaJwt({ - jwksUri: env.Auth0JWKSUri, + jwksUri: env.AUTH0_JWKS_URI, kvStore: kvStore }); export const optionalUserMiddleware = verifyRsaJwt({ - jwksUri: env.Auth0JWKSUri, + jwksUri: env.AUTH0_JWKS_URI, kvStore: kvStore, optional: true }); diff --git a/apps/api/src/routers/apiRouter.ts b/apps/api/src/routers/apiRouter.ts index f8193347e..5be0780c3 100644 --- a/apps/api/src/routers/apiRouter.ts +++ b/apps/api/src/routers/apiRouter.ts @@ -11,7 +11,7 @@ function registerApiVersion(version: string, baseRouter: OpenAPIHono, versionRou versionRouter.doc(`/doc`, { openapi: "3.0.0", - servers: [{ url: `${env.ServerOrigin}/${version}` }], + servers: [{ url: `${env.SERVER_ORIGIN}/${version}` }], info: { title: "Console API", description: "Access Akash data from our indexer", diff --git a/apps/api/src/routers/internalRouter.ts b/apps/api/src/routers/internalRouter.ts index ed1f55d76..8f4502932 100644 --- a/apps/api/src/routers/internalRouter.ts +++ b/apps/api/src/routers/internalRouter.ts @@ -8,7 +8,7 @@ export const internalRouter = new OpenAPIHono(); internalRouter.doc(`/doc`, { openapi: "3.0.0", - servers: [{ url: `${env.ServerOrigin}/internal` }], + servers: [{ url: `${env.SERVER_ORIGIN}/internal` }], info: { title: "Console Internal API", description: "APIs for internal use that are not part of the public API. There is no garantees of stability or backward compatibility.", diff --git a/apps/api/src/routes/internal/gpu.ts b/apps/api/src/routes/internal/gpu.ts index 25f612078..5239b89d3 100644 --- a/apps/api/src/routes/internal/gpu.ts +++ b/apps/api/src/routes/internal/gpu.ts @@ -113,7 +113,7 @@ export default new OpenAPIHono().openapi(route, async c => { memory_size: memory_size ?? null, provider_address: provider_address ?? null, provider_hosturi: provider_hosturi ?? null, - grace_date: toUTC(sub(new Date(), { minutes: env.ProviderUptimeGracePeriodMinutes })) + grace_date: toUTC(sub(new Date(), { minutes: env.PROVIDER_UPTIME_GRACE_PERIOD_MINUTES })) } } ); diff --git a/apps/api/src/routes/internal/gpuPrices.ts b/apps/api/src/routes/internal/gpuPrices.ts index 74eb8eb6b..50d972938 100644 --- a/apps/api/src/routes/internal/gpuPrices.ts +++ b/apps/api/src/routes/internal/gpuPrices.ts @@ -365,7 +365,7 @@ async function getGpus() { { type: QueryTypes.SELECT, replacements: { - grace_date: toUTC(sub(new Date(), { minutes: env.ProviderUptimeGracePeriodMinutes })) + grace_date: toUTC(sub(new Date(), { minutes: env.PROVIDER_UPTIME_GRACE_PERIOD_MINUTES })) } } ); diff --git a/apps/api/src/routes/internal/providerVersions.ts b/apps/api/src/routes/internal/providerVersions.ts index e4ea77b5f..2f70bc779 100644 --- a/apps/api/src/routes/internal/providerVersions.ts +++ b/apps/api/src/routes/internal/providerVersions.ts @@ -43,7 +43,7 @@ export default new OpenAPIHono().openapi(route, async c => { { type: QueryTypes.SELECT, replacements: { - grace_date: toUTC(sub(new Date(), { minutes: env.ProviderUptimeGracePeriodMinutes })) + grace_date: toUTC(sub(new Date(), { minutes: env.PROVIDER_UPTIME_GRACE_PERIOD_MINUTES })) } } ); diff --git a/apps/api/src/services/db/providerStatusService.ts b/apps/api/src/services/db/providerStatusService.ts index 3d4a8dda6..ec3d967d4 100644 --- a/apps/api/src/services/db/providerStatusService.ts +++ b/apps/api/src/services/db/providerStatusService.ts @@ -19,7 +19,7 @@ export async function getNetworkCapacity() { required: true, model: ProviderSnapshot, as: "lastSuccessfulSnapshot", - where: { checkDate: { [Op.gte]: toUTC(sub(new Date(), { minutes: env.ProviderUptimeGracePeriodMinutes })) } } + where: { checkDate: { [Op.gte]: toUTC(sub(new Date(), { minutes: env.PROVIDER_UPTIME_GRACE_PERIOD_MINUTES })) } } } ] }); diff --git a/apps/api/src/services/db/statsService.ts b/apps/api/src/services/db/statsService.ts index fcbd6c4a7..53e554b67 100644 --- a/apps/api/src/services/db/statsService.ts +++ b/apps/api/src/services/db/statsService.ts @@ -225,7 +225,7 @@ export const getProviderGraphData = async (dataName: ProviderStatsKey) => { { type: QueryTypes.SELECT, replacements: { - grace_duration: env.ProviderUptimeGracePeriodMinutes + grace_duration: env.PROVIDER_UPTIME_GRACE_PERIOD_MINUTES } } ); diff --git a/apps/api/src/services/external/githubService.ts b/apps/api/src/services/external/githubService.ts index b58dbe091..561a7143e 100644 --- a/apps/api/src/services/external/githubService.ts +++ b/apps/api/src/services/external/githubService.ts @@ -6,10 +6,10 @@ import { Auditor, ProviderAttributesSchema } from "@src/types/provider"; import { env } from "@src/utils/env"; export function getOctokit() { - const githubPAT = env.AkashlyticsGithubPAT; + const githubPAT = env.AKASHLYTICS_GITHUB_PAT; if (!githubPAT) { - throw new Error("AkashlyticsGithubPAT is missing"); + throw new Error("AKASHLYTICS_GITHUB_PAT is missing"); } return new Octokit({ diff --git a/apps/api/src/utils/constants.ts b/apps/api/src/utils/constants.ts index 24bc25835..86f73975a 100644 --- a/apps/api/src/utils/constants.ts +++ b/apps/api/src/utils/constants.ts @@ -20,6 +20,6 @@ export const defaultNodeUrlMapping: { [key: string]: string } = { testnet: "https://api.testnet-02.aksh.pw" }; -export const apiNodeUrl = env.RestApiNodeUrl ?? defaultNodeUrlMapping[env.NETWORK] ?? defaultNodeUrlMapping.mainnet; +export const apiNodeUrl = env.REST_API_NODE_URL ?? defaultNodeUrlMapping[env.NETWORK] ?? defaultNodeUrlMapping.mainnet; export const betaTypeVersion = "v1beta3"; export const betaTypeVersionMarket = "v1beta4"; diff --git a/apps/api/src/utils/env.ts b/apps/api/src/utils/env.ts index 9445584bb..efa9de7bd 100644 --- a/apps/api/src/utils/env.ts +++ b/apps/api/src/utils/env.ts @@ -4,21 +4,21 @@ export const env = z .object({ AKASHLYTICS_CORS_WEBSITE_URLS: z.string().optional(), NODE_ENV: z.string().optional(), - HealthchecksEnabled: z.string().optional(), - AkashDatabaseCS: z.string().optional(), - AkashTestnetDatabaseCS: z.string().optional(), - AkashSandboxDatabaseCS: z.string().optional(), - UserDatabaseCS: z.string().optional(), + HEALTHCHECKS_ENABLED: z.string().optional(), + AKASH_DATABASE_CS: z.string().optional(), + AKASH_TESTNET_DATABASE_CS: z.string().optional(), + AKASH_SANDBOX_DATABASE_CS: z.string().optional(), + USER_DATABASE_CS: z.string().optional(), NETWORK: z.string().default("mainnet"), - RestApiNodeUrl: z.string().optional(), - ServerOrigin: z.string().optional().default("http://localhost:3080"), - AkashlyticsGithubPAT: z.string().optional(), - Auth0JWKSUri: z.string().optional(), - Auth0Audience: z.string().optional(), - Auth0Issuer: z.string().optional(), - WebsiteUrl: z.string().optional(), - SecretToken: z.string().optional(), - ProviderUptimeGracePeriodMinutes: z + REST_API_NODE_URL: z.string().optional(), + SERVER_ORIGIN: z.string().optional().default("http://localhost:3080"), + AKASHLYTICS_GITHUB_PAT: z.string().optional(), + AUTH0_JWKS_URI: z.string().optional(), + AUTH0_AUDIENCE: z.string().optional(), + AUTH0_ISSUER: z.string().optional(), + WEBSITE_URL: z.string().optional(), + SECRET_TOKEN: z.string().optional(), + PROVIDER_UPTIME_GRACE_PERIOD_MINUTES: z .number() .optional() .default(3 * 60), diff --git a/apps/indexer/README.md b/apps/indexer/README.md index 5a84af749..5daafb8e5 100644 --- a/apps/indexer/README.md +++ b/apps/indexer/README.md @@ -21,17 +21,17 @@ You can make sure the api is working by accessing the status endpoint: `http://l |Name|Value|Note| |-|-|- -HealthchecksEnabled|`true` or `false`|Specify if the [Scheduler](./src/index.ts#L42) should send health check pings. -SentryDSN|ex: `"https://1234...789@z645.ingest.sentry.io/1234"`|[Sentry DSN](https://docs.sentry.io/product/sentry-basics/dsn-explainer/) used when [initializing](./src/index.ts#L25) Sentry -HealthChecks_SyncBlocks|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncBlocks` task. -HealthChecks_SyncAKTPriceHistory|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncAKTPriceHistory` task. -HealthChecks_SyncProviderInfo|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncProviderInfo` task. -HealthChecks_SyncKeybaseInfo|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncKeybaseInfo` task. -AkashDatabaseCS|ex: `postgres://user:password@localhost:5432/cloudmos-akash`|Akash Database Connection String -ActiveChain|ex: `akash`|Chain code from [chainDefinitions.ts](../shared/chainDefinitions.ts) -KeepCache|`true` or `false`|Specify if the [block & block response cache](#block-cache-structure) should be kept on drive. Takes a lot of space, but allow rebuilding the database without redownloading every blocks. -Standby|`true` or `false`|If `true`, indexer will not start. Useful for stopping an indexer deployed on akash without needing to close the lease. -DataFolder|ex: `./data/`|Directory where block cache and node statuses should be saved. Defaults to `./data/`. +HEALTH_CHECKS_ENABLED|`true` or `false`|Specify if the [Scheduler](./src/index.ts#L42) should send health check pings. +SENTRY_DSN|ex: `"https://1234...789@z645.ingest.sentry.io/1234"`|[Sentry DSN](https://docs.sentry.io/product/sentry-basics/dsn-explainer/) used when [initializing](./src/index.ts#L25) Sentry +HEALTHCHECKS_SYNC_BLOCKS|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncBlocks` task. +HEALTHCHECKS_SYNC_AKT_PRICE_HISTORY|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncAKTPriceHistory` task. +HEALTHCHECKS_SYNC_PROVIDER_INFO|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncProviderInfo` task. +HEALTHCHECKS_SYNC_KEYBASE_INFO|ex: `041b2561-be28-4a36-bb3f-36a68f86224e`|[HealthChecks.io](https://healthchecks.io) check ID for the `SyncKeybaseInfo` task. +AKASH_DATABASE_CS|ex: `postgres://user:password@localhost:5432/cloudmos-akash`|Akash Database Connection String +ACTIVE_CHAIN|ex: `akash`|Chain code from [chainDefinitions.ts](../shared/chainDefinitions.ts) +KEEP_CACHE|`true` or `false`|Specify if the [block & block response cache](#block-cache-structure) should be kept on drive. Takes a lot of space, but allow rebuilding the database without redownloading every blocks. +STANDBY|`true` or `false`|If `true`, indexer will not start. Useful for stopping an indexer deployed on akash without needing to close the lease. +DATA_FOLDER|ex: `./data/`|Directory where block cache and node statuses should be saved. Defaults to `./data/`. ## Scheduled Tasks diff --git a/apps/indexer/deploy.yml b/apps/indexer/deploy.yml index ac3b66f17..9a0a00c72 100644 --- a/apps/indexer/deploy.yml +++ b/apps/indexer/deploy.yml @@ -5,15 +5,15 @@ services: syncer: image: redm4x/console-syncer:1.0.0 env: - - HealthchecksEnabled=true - - SentryDSN= - - SentryServerName= - - HealthChecks_SyncBlocks= - - HealthChecks_SyncAKTPriceHistory= - - HealthChecks_SyncProviderInfo= - - HealthChecks_SyncKeybaseInfo= + - HEALTH_CHECKS_ENABLED=true + - SENTRY_DSN= + - SENTRY_SERVER_NAME= + - HEALTHCHECKS_SYNC_BLOCKS= + - HEALTHCHECKS_SYNC_AKT_PRICE_HISTORY= + - HEALTHCHECKS_SYNC_PROVIDER_INFO= + - HEALTHCHECKS_SYNC_KEYBASE_INFO= - ChainDatabaseCS= - - ActiveChain= + - ACTIVE_CHAIN= expose: - port: 3079 as: 80 diff --git a/apps/indexer/src/chain/chainSync.ts b/apps/indexer/src/chain/chainSync.ts index a648e60b4..3216afee3 100644 --- a/apps/indexer/src/chain/chainSync.ts +++ b/apps/indexer/src/chain/chainSync.ts @@ -85,7 +85,7 @@ export async function syncBlocks() { if (latestHeightInCache >= latestBlockToDownload) { console.log("No blocks to download"); } else { - let startHeight = !env.KeepCache ? latestInsertedHeight + 1 : Math.max(latestHeightInCache, 1); + let startHeight = !env.KEEP_CACHE ? latestInsertedHeight + 1 : Math.max(latestHeightInCache, 1); // If database is empty if (latestInsertedHeight === 0) { @@ -118,7 +118,7 @@ export async function syncBlocks() { if (executionMode === ExecutionMode.RebuildAll) { await sequelize.query("DROP INDEX message_height"); - if (env.ActiveChain === "akash") { + if (env.ACTIVE_CHAIN === "akash") { await sequelize.query("DROP INDEX message_related_deployment_id"); } @@ -144,7 +144,7 @@ export async function syncBlocks() { benchmark.displayTimes(); - if (!env.KeepCache) { + if (!env.KEEP_CACHE) { await deleteCache(); } } diff --git a/apps/indexer/src/index.ts b/apps/indexer/src/index.ts index 878e10f29..f44c6266f 100644 --- a/apps/indexer/src/index.ts +++ b/apps/indexer/src/index.ts @@ -26,9 +26,9 @@ const app = express(); const { PORT = 3079 } = process.env; Sentry.init({ - dsn: env.SentryDSN, + dsn: env.SENTRY_DSN, environment: env.NODE_ENV, - serverName: env.SentryServerName, + serverName: env.SENTRY_SERVER_NAME, release: packageJson.version, enabled: isProd, integrations: [], @@ -40,10 +40,10 @@ Sentry.init({ tracesSampleRate: 0.01 }); -Sentry.setTag("chain", env.ActiveChain); +Sentry.setTag("chain", env.ACTIVE_CHAIN); const scheduler = new Scheduler({ - healthchecksEnabled: env.HealthchecksEnabled === "true", + healthchecksEnabled: env.HEALTH_CHECKS_ENABLED === "true", errorHandler: (task, error) => { console.error(`Task "${task.name}" failed: `, error); Sentry.captureException(error, { tags: { task: task.name } }); @@ -84,17 +84,17 @@ app.get("/nodes", async (req, res) => { function startScheduler() { scheduler.registerTask("Sync Blocks", syncBlocks, "7 seconds", true, { - id: env.HealthChecks_SyncBlocks + id: env.HEALTHCHECKS_SYNC_BLOCKS }); scheduler.registerTask("Sync Price History", syncPriceHistory, "1 hour", true, { - id: env.HealthChecks_SyncAKTPriceHistory, + id: env.HEALTHCHECKS_SYNC_AKT_PRICE_HISTORY, measureDuration: true }); scheduler.registerTask("Address Balance Monitor", () => addressBalanceMonitor.run(), "10 minutes"); - if (env.ActiveChain === "akash" || env.ActiveChain === "akashTestnet" || env.ActiveChain === "akashSandbox") { + if (env.ACTIVE_CHAIN === "akash" || env.ACTIVE_CHAIN === "akashTestnet" || env.ACTIVE_CHAIN === "akashSandbox") { scheduler.registerTask("Sync Providers Info", syncProvidersInfo, "10 seconds", true, { - id: env.HealthChecks_SyncProviderInfo, + id: env.HEALTHCHECKS_SYNC_PROVIDER_INFO, measureDuration: true }); @@ -106,7 +106,7 @@ function startScheduler() { if (!activeChain.startHeight) { scheduler.registerTask("Sync Keybase Info", fetchValidatorKeybaseInfos, "6 hours", true, { - id: env.HealthChecks_SyncKeybaseInfo, + id: env.HEALTHCHECKS_SYNC_KEYBASE_INFO, measureDuration: true }); } @@ -122,16 +122,16 @@ function startScheduler() { */ async function initApp() { try { - if (env.Standby) { - console.log("Standby mode enabled. Doing nothing."); + if (env.STANDBY) { + console.log("STANDBY mode enabled. Doing nothing."); // eslint-disable-next-line no-constant-condition while (true) { await sleep(5_000); } } - if (!(process.env.ActiveChain in chainDefinitions)) { - throw new Error(`Unknown chain with code: ${process.env.ActiveChain}`); + if (!(process.env.ACTIVE_CHAIN in chainDefinitions)) { + throw new Error(`Unknown chain with code: ${process.env.ACTIVE_CHAIN}`); } await initDatabase(); diff --git a/apps/indexer/src/shared/constants.ts b/apps/indexer/src/shared/constants.ts index 15ffe62be..37a767dcd 100644 --- a/apps/indexer/src/shared/constants.ts +++ b/apps/indexer/src/shared/constants.ts @@ -19,5 +19,5 @@ export enum ExecutionMode { export const executionMode: ExecutionMode = ExecutionMode.SyncOnly; export const lastBlockToSync = Number.POSITIVE_INFINITY; -export const dataFolderPath = path.join(env.DataFolder, activeChain.code); +export const dataFolderPath = path.join(env.DATA_FOLDER, activeChain.code); export const concurrentNodeQuery = 5; diff --git a/apps/indexer/src/shared/utils/env.ts b/apps/indexer/src/shared/utils/env.ts index 79a1e82c5..c11ea145a 100644 --- a/apps/indexer/src/shared/utils/env.ts +++ b/apps/indexer/src/shared/utils/env.ts @@ -2,19 +2,19 @@ import dotenv from "dotenv"; dotenv.config(); export const env = { - HealthChecks_SyncBlocks: process.env.HealthChecks_SyncBlocks, - HealthChecks_SyncAKTPriceHistory: process.env.HealthChecks_SyncAKTPriceHistory, - HealthChecks_SyncProviderInfo: process.env.HealthChecks_SyncProviderInfo, - HealthChecks_SyncKeybaseInfo: process.env.HealthChecks_SyncKeybaseInfo, - SentryDSN: process.env.SentryDSN, + HEALTHCHECKS_SYNC_BLOCKS: process.env.HEALTHCHECKS_SYNC_BLOCKS, + HEALTHCHECKS_SYNC_AKT_PRICE_HISTORY: process.env.HEALTHCHECKS_SYNC_AKT_PRICE_HISTORY, + HEALTHCHECKS_SYNC_PROVIDER_INFO: process.env.HEALTHCHECKS_SYNC_PROVIDER_INFO, + HEALTHCHECKS_SYNC_KEYBASE_INFO: process.env.HEALTHCHECKS_SYNC_KEYBASE_INFO, + SENTRY_DSN: process.env.SENTRY_DSN, NODE_ENV: process.env.NODE_ENV, - SentryServerName: process.env.SentryServerName, - HealthchecksEnabled: process.env.HealthchecksEnabled, - AkashDatabaseCS: process.env.AkashDatabaseCS, - PassageDatabaseCS: process.env.PassageDatabaseCS, - JunoDatabaseCS: process.env.JunoDatabaseCS, - ActiveChain: process.env.ActiveChain, - KeepCache: process.env.KeepCache === "true", - Standby: process.env.Standby === "true", - DataFolder: process.env.DataFolder ?? "./data" + SENTRY_SERVER_NAME: process.env.SENTRY_SERVER_NAME, + HEALTH_CHECKS_ENABLED: process.env.HEALTH_CHECKS_ENABLED, + AKASH_DATABASE_CS: process.env.AKASH_DATABASE_CS, + PASSAGE_DATABASE_CS: process.env.PASSAGE_DATABASE_CS, + JUNO_DATABASE_CS: process.env.JUNO_DATABASE_CS, + ACTIVE_CHAIN: process.env.ACTIVE_CHAIN, + KEEP_CACHE: process.env.KEEP_CACHE === "true", + STANDBY: process.env.STANDBY === "true", + DATA_FOLDER: process.env.DATA_FOLDER ?? "./data" }; diff --git a/packages/database/chainDefinitions.ts b/packages/database/chainDefinitions.ts index b017adf30..d79b91e79 100644 --- a/packages/database/chainDefinitions.ts +++ b/packages/database/chainDefinitions.ts @@ -55,7 +55,7 @@ export const chainDefinitions: { [key: string]: ChainDef } = { "https://akash-rpc.kleomedes.network" ], cosmosDirectoryId: "akash", - connectionString: process.env.AkashDatabaseCS, + connectionString: process.env.AKASH_DATABASE_CS, genesisFileUrl: "https://raw.githubusercontent.com/akash-network/net/master/mainnet/genesis.json", coinGeckoId: "akash-network", logoUrlSVG: "https://raw.githubusercontent.com/cosmos/chain-registry/master/akash/images/akt.svg",