Skip to content

Commit

Permalink
Remove blob propagator enabled (#628)
Browse files Browse the repository at this point in the history
* refactor: remove BLOB_PROPAGATOR_ENABLED configuration and related documentation

* chore: adds changeset

* Update .changeset/eighty-lobsters-rest.md

Co-authored-by: Francisco Jiménez <[email protected]>

* chore: fix type error

---------

Co-authored-by: Francisco Jiménez <[email protected]>
  • Loading branch information
luis-herasme and xFJA authored Nov 25, 2024
1 parent 91fbe0a commit 6512745
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-lobsters-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blobscan/blob-propagator": patch
---

Removed `BLOB_PROPAGATOR_ENABLED` variable.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ NETWORK_NAME=mainnet
# GOOGLE_SERVICE_KEY=
# GOOGLE_STORAGE_API_ENDPOINT=http://localhost:4443

BLOB_PROPAGATOR_ENABLED=false

GOOGLE_STORAGE_ENABLED=false
POSTGRES_STORAGE_ENABLED=true
SWARM_STORAGE_ENABLED=false
Expand Down
1 change: 0 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ FILE_SYSTEM_STORAGE_PATH=test-blobscan-blobs

# Blob Propagator

BLOB_PROPAGATOR_ENABLED=false
BLOB_PROPAGATOR_TMP_BLOB_STORAGE=FILE_SYSTEM
REDIS_URI=redis://localhost:6379/1
6 changes: 1 addition & 5 deletions apps/docs/src/app/docs/background-jobs/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@ Blobscan requires [BullMQ](https://bullmq.io/) to run the following tasks in the

For more information, check out the [@blobscan/syncers](https://github.com/Blobscan/blobscan/tree/next/packages/syncers/src/syncers) package.

The BullMQ queue is also used to upload blobs in parallel to different Storages. Although this is not recommended, you can disable parallel uploads by setting:

```shell
BLOB_PROPAGATOR_ENABLED=false
```
The BullMQ queue is also used to upload blobs in parallel to different Storages.
2 changes: 0 additions & 2 deletions apps/docs/src/app/docs/environment/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ nextjs:
| `SENTRY_ORG` | Sentry organization | No | (empty) |
| `METRICS_ENABLED` | Expose the /metrics endpoint | No | `false` |
| `TRACES_ENABLED` | Enable instrumentation of functions and sending traces to a collector | No | `false` |
| `BLOB_PROPAGATOR_ENABLED` | Enable uploading blobs to multiple storages in parallel | No | `false` |
| `NEXT_PUBLIC_POSTHOG_ID` | PostHog project API key used for tracking events and analytics | No | (empty) |
| `NEXT_PUBLIC_POSTHOG_HOST` | Host URL for the PostHog instance used for analytics tracking | No | `https://us.i.posthog.com` |

Expand Down Expand Up @@ -59,7 +58,6 @@ nextjs:
| `STATS_SYNCER_DAILY_CRON_PATTERN` | Cron pattern for the daily stats job | No | `30 0 * * * *` |
| `STATS_SYNCER_OVERALL_CRON_PATTERN` | Cron pattern for the overall stats job | No | `*/15 * * * *` |
| `SWARM_STAMP_CRON_PATTERN` | Cron pattern for swarm job | No | `*/15 * * * *` |
| `BLOB_PROPAGATOR_ENABLED` | Enable parallel uploading of blobs to multiple storage locations | No | `false` |
| `BLOB_PROPAGATOR_COMPLETED_JOBS_AGE` | Remove completed jobs after the specified number of seconds (default: 1 day) | No | `86400` |
| `BLOB_PROPAGATOR_FAILED_JOBS_AGE` | Remove completed jobs after the specified number of seconds (default: 7 days) | No | `604800` |
| `POSTHOG_ID` | PostHog project API key used for tracking events and analytics | No | (empty) |
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "pnpm with-env next start",
"svg:format": "svgo -r ./src/icons ./public",
"type-check": "tsc --noEmit",
"with-env": "dotenv -e ../../.env -v BLOB_PROPAGATOR_ENABLED=false --"
"with-env": "dotenv -e ../../.env --"
},
"dependencies": {
"@blobscan/api": "workspace:^0.15.0",
Expand Down
21 changes: 15 additions & 6 deletions packages/api/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import type {
import cookie from "cookie";
import jwt from "jsonwebtoken";

import { getBlobPropagator } from "@blobscan/blob-propagator";
import { getBlobStorageManager } from "@blobscan/blob-storage-manager";
import { BlobPropagator, getBlobPropagator } from "@blobscan/blob-propagator";
import {
BlobStorageManager,
getBlobStorageManager,
} from "@blobscan/blob-storage-manager";
import { prisma } from "@blobscan/db";
import { env } from "@blobscan/env";

Expand Down Expand Up @@ -50,7 +53,16 @@ export function getJWTFromRequest(req: NodeHTTPRequest | NextHTTPRequest) {
}
}

export async function createTRPCInnerContext(opts?: CreateInnerContextOptions) {
export type TRPCInnerContext = {
prisma: typeof prisma;
blobStorageManager: BlobStorageManager;
blobPropagator: BlobPropagator | undefined;
apiClient: string | null | undefined;
};

export async function createTRPCInnerContext(
opts?: CreateInnerContextOptions
): Promise<TRPCInnerContext> {
const blobStorageManager = await getBlobStorageManager();
const blobPropagator = await getBlobPropagator();

Expand Down Expand Up @@ -142,6 +154,3 @@ export function createTRPCContext(
export type TRPCContext = inferAsyncReturnType<
ReturnType<typeof createTRPCContext>
>;
export type TRPCInnerContext = inferAsyncReturnType<
typeof createTRPCInnerContext
>;
4 changes: 0 additions & 4 deletions packages/blob-propagator/src/blob-propagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ async function createBlobPropagator(
let blobPropagator: BlobPropagator | undefined;

async function getBlobPropagator() {
if (!env.BLOB_PROPAGATOR_ENABLED) {
return;
}

if (!blobPropagator) {
const blobStorageManager = await getBlobStorageManager();

Expand Down
5 changes: 1 addition & 4 deletions packages/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const env = createEnv({
.url()
.default(`http://localhost:${process.env.BLOBSCAN_API_PORT ?? 3001}`),
BLOBSCAN_API_PORT: z.coerce.number().positive().default(3001),
BLOB_PROPAGATOR_ENABLED: booleanSchema.default("false"),
BLOB_PROPAGATOR_TMP_BLOB_STORAGE:
blobStorageSchema.default("FILE_SYSTEM"),
BLOB_PROPAGATOR_COMPLETED_JOBS_AGE: z.coerce
Expand Down Expand Up @@ -95,9 +94,7 @@ export const env = createEnv({
console.log(
`API configuration: secretKey: ${maskSensitiveData(
env.SECRET_KEY
)} Blob propagator configuration: enabled=${
env.BLOB_PROPAGATOR_ENABLED
} redisUri=${maskPassword(env.REDIS_URI)} temporalBlobStorage=${
)} redisUri=${maskPassword(env.REDIS_URI)} temporalBlobStorage=${
env.BLOB_PROPAGATOR_TMP_BLOB_STORAGE
} completedJobsAge=${
env.BLOB_PROPAGATOR_COMPLETED_JOBS_AGE
Expand Down
3 changes: 1 addition & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"ANALYZE",
"BEACON_NODE_ENDPOINT",
"BEE_ENDPOINT",
"BLOB_PROPAGATOR_ENABLED",
"BLOB_PROPAGATOR_TMP_BLOB_STORAGE",
"BLOBSCAN_API_PORT",
"CHAIN_ID",
Expand Down Expand Up @@ -100,4 +99,4 @@
"VERCEL_URL",
"TS_NODE"
]
}
}

0 comments on commit 6512745

Please sign in to comment.