Skip to content

Commit

Permalink
style: apply pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PJColombo committed Feb 24, 2025
1 parent bdf3c4e commit 6b248e1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/pages/block/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { NextPage } from "next";
import { useRouter } from "next/router";
import type { NextRouter } from "next/router";

import { getNetworkBlobConfig } from "@blobscan/network-blob-config";
import { getNetworkBlobConfigBySlot } from "@blobscan/network-blob-config";

import { Card } from "~/components/Cards/Card";
import { BlobTransactionCard } from "~/components/Cards/SurfaceCards/BlobTransactionCard";
Expand Down Expand Up @@ -72,7 +72,7 @@ const Block: NextPage = function () {
let detailsFields: DetailsLayoutProps["fields"] | undefined;

if (blockData && env) {
const networkBlobConfig = getNetworkBlobConfig(
const networkBlobConfig = getNetworkBlobConfigBySlot(
env.PUBLIC_NETWORK_NAME,
blockData.slot
);
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/blocks.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo, useState } from "react";
import type { NextPage } from "next";

import { getNetworkBlobConfig } from "@blobscan/network-blob-config";
import { getNetworkBlobConfigBySlot } from "@blobscan/network-blob-config";

import { Copyable } from "~/components/Copyable";
import { BlobGasUsageDisplay } from "~/components/Displays/BlobGasUsageDisplay";
Expand Down Expand Up @@ -265,7 +265,7 @@ const Blocks: NextPage = function () {
{
item: (
<BlobGasUsageDisplay
networkBlobConfig={getNetworkBlobConfig(
networkBlobConfig={getNetworkBlobConfigBySlot(
env.PUBLIC_NETWORK_NAME,
slot
)}
Expand Down
13 changes: 7 additions & 6 deletions packages/api/src/routers/indexer/indexData.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
import { Prisma } from "@blobscan/db";
import { Category } from "@blobscan/db/prisma/enums";
import { env } from "@blobscan/env";
import { getNetworkBlobConfig } from "@blobscan/network-blob-config";
import { getNetworkBlobConfigBySlot } from "@blobscan/network-blob-config";
import { getRollupByAddress } from "@blobscan/rollups";

import type { IndexDataFormattedInput } from "./indexData";
Expand Down Expand Up @@ -66,10 +66,8 @@ export function calculateBlobGasPrice(
slot: number,
excessBlobGas: bigint
): bigint {
const { minBlobBaseFee, blobBaseFeeUpdateFraction } = getNetworkBlobConfig(
env.CHAIN_ID,
slot
);
const { minBlobBaseFee, blobBaseFeeUpdateFraction } =
getNetworkBlobConfigBySlot(env.CHAIN_ID, slot);

return BigInt(
fakeExponential(minBlobBaseFee, excessBlobGas, blobBaseFeeUpdateFraction)
Expand All @@ -94,7 +92,10 @@ export function createDBTransactions({
BigInt(0)
);

const ethereumConfig = getNetworkBlobConfig(env.CHAIN_ID, block.slot);
const ethereumConfig = getNetworkBlobConfigBySlot(
env.CHAIN_ID,
block.slot
);
const blobGasPrice = calculateBlobGasPrice(
block.slot,
block.excessBlobGas
Expand Down
14 changes: 6 additions & 8 deletions packages/db/prisma/seed/DataGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
ROLLUP_ADDRESSES,
} from "./web3";

const BLOB_GAS_PER_BLOB = FORK_BLOB_CONFIGS["dencun"].gasPerBlob;
const GAS_PER_BLOB = FORK_BLOB_CONFIGS["dencun"].gasPerBlob;

export type FullBlock = Block & {
transactions: (Transaction & {
Expand Down Expand Up @@ -87,7 +87,7 @@ export class DataGenerator {
});
const proof = faker.string.hexadecimal({ length: 96 });
const versionedHash = `0x01${sha256(commitment).slice(2)}`;
const size = Number(BLOB_GAS_PER_BLOB);
const size = Number(GAS_PER_BLOB);

return {
commitment,
Expand Down Expand Up @@ -130,7 +130,7 @@ export class DataGenerator {
min: 1,
max: 6,
});
const blobGasUsed = BLOB_GAS_PER_BLOB * BigInt(txsCount);
const blobGasUsed = GAS_PER_BLOB * BigInt(txsCount);
const excessBlobGas = calculateExcessBlobGas(
BigInt(parentBlock.excessBlobGas.toString()),
BigInt(
Expand Down Expand Up @@ -162,7 +162,7 @@ export class DataGenerator {
uniqueAddresses: string[]
): Transaction[] {
const now = new Date();
const maxBlobs = Number(block.blobGasUsed) / Number(BLOB_GAS_PER_BLOB);
const maxBlobs = Number(block.blobGasUsed) / Number(GAS_PER_BLOB);

const txCount = faker.number.int({
min: 1,
Expand Down Expand Up @@ -207,9 +207,7 @@ export class DataGenerator {
.arrayElement(COMMON_MAX_FEE_PER_BLOB_GAS)
.toString();
const extraBlobs = faker.number.int({ min: 0, max: remainingBlobs });
const blobGasUsed = (
BigInt(1 + extraBlobs) * BLOB_GAS_PER_BLOB
).toString();
const blobGasUsed = (BigInt(1 + extraBlobs) * GAS_PER_BLOB).toString();

remainingBlobs -= extraBlobs;

Expand All @@ -236,7 +234,7 @@ export class DataGenerator {

generateTransactionBlobs(tx: Transaction, prevBlobs: Blob[]): Blob[] {
return Array.from({
length: Number(tx.blobGasUsed) / Number(BLOB_GAS_PER_BLOB),
length: Number(tx.blobGasUsed) / Number(GAS_PER_BLOB),
}).map(() => {
const isUnique = tx.rollup
? true
Expand Down
9 changes: 6 additions & 3 deletions packages/network-blob-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export const FORK_BLOB_CONFIGS: Record<NetworkFork, NetworkBlobConfig> = {
},
};

export function getNetworkFork(network: Network, slot: number): NetworkFork {
export function getNetworkForkBySlot(
network: Network,
slot: number
): NetworkFork {
switch (network) {
case "holesky": {
return slot >= 3710976 ? "pectra" : "dencun";
Expand All @@ -72,15 +75,15 @@ function getNetworkNameById(networkId: number): Network {
return "devnet";
}
}

Check warning on line 77 in packages/network-blob-config/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/network-blob-config/index.ts#L64-L77

Added lines #L64 - L77 were not covered by tests
export function getNetworkBlobConfig(
export function getNetworkBlobConfigBySlot(
networkNameOrId: Network | number,
slot: number
): NetworkBlobConfig {
const network =
typeof networkNameOrId === "number"
? getNetworkNameById(networkNameOrId)

Check warning on line 84 in packages/network-blob-config/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/network-blob-config/index.ts#L84

Added line #L84 was not covered by tests
: networkNameOrId;
const upgrade = getNetworkFork(network, slot);
const upgrade = getNetworkForkBySlot(network, slot);

return FORK_BLOB_CONFIGS[upgrade];
}

0 comments on commit 6b248e1

Please sign in to comment.