Skip to content
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
17 changes: 15 additions & 2 deletions src/pages/ethereum/execution/gas-profiler/SimulatePage.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,21 @@ export const GAS_PARAMETER_GROUPS: GasParameterGroup[] = [
{ key: 'PC_BLS12_G2MSM_MUL_GAS', label: 'BLS12 G2MSM /Point', min: 0, max: 100000, step: 1000 },
],
},
// NOTE: Intrinsic gas (TX_BASE, TX_CREATE, TX_DATA_ZERO, TX_DATA_NONZERO) cannot be
// customized - it's calculated at the protocol level before EVM execution begins.
{
name: 'Intrinsic Gas',
color: '#d946ef', // fuchsia
parameters: [
{ key: 'TX_BASE', label: 'TX Base', min: 0, max: 100000, step: 1000 },
{ key: 'TX_CREATE_BASE', label: 'TX Create', min: 0, max: 200000, step: 1000 },
{ key: 'TX_DATA_ZERO', label: 'Calldata Zero', min: 0, max: 50, step: 1 },
{ key: 'TX_DATA_NONZERO', label: 'Calldata Non-Zero', min: 0, max: 200, step: 1 },
{ key: 'TX_ACCESS_LIST_ADDR', label: 'Access List Addr', min: 0, max: 10000, step: 100 },
{ key: 'TX_ACCESS_LIST_KEY', label: 'Access List Key', min: 0, max: 10000, step: 100 },
{ key: 'TX_INIT_CODE_WORD', label: 'Init Code Word', min: 0, max: 20, step: 1 },
{ key: 'TX_FLOOR_PER_TOKEN', label: 'Floor Per Token', min: 0, max: 50, step: 1 },
{ key: 'TX_AUTH_COST', label: 'Auth Cost', min: 0, max: 100000, step: 1000 },
],
},
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ function OpcodeRow({ op, maxGas }: { op: OpcodeRowData; maxGas: number }): JSX.E

return (
<Tooltip
title={op.opcode.startsWith('PC_') ? op.opcode.slice(3) : op.opcode}
title={
op.opcode.startsWith('PC_') ? op.opcode.slice(3) : op.opcode.startsWith('TX_') ? op.opcode.slice(3) : op.opcode
}
width="w-auto"
description={
<div className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 whitespace-nowrap">
Expand Down Expand Up @@ -443,7 +445,11 @@ function OpcodeRow({ op, maxGas }: { op: OpcodeRowData; maxGas: number }): JSX.E
<div className="flex items-center gap-2">
<div className="size-2 shrink-0 rounded-full" style={{ backgroundColor: op.categoryColor }} />
<span className="font-mono text-xs font-semibold text-foreground">
{op.opcode.startsWith('PC_') ? op.opcode.slice(3) : op.opcode}
{op.opcode.startsWith('PC_')
? op.opcode.slice(3)
: op.opcode.startsWith('TX_')
? op.opcode.slice(3)
: op.opcode}
</span>
{hasCountChange && (
<span className="font-mono text-[11px] text-muted tabular-nums">
Expand Down Expand Up @@ -553,7 +559,8 @@ function OpcodeBreakdownSection({
<div className="size-2.5 rounded-full" style={{ backgroundColor: cat.color }} />
<span className="text-xs font-semibold text-foreground">{cat.name}</span>
<span className="text-xs text-muted">
({cat.opcodes.length} {cat.name === 'Precompiles' ? 'contract' : 'opcode'}
({cat.opcodes.length}{' '}
{cat.name === 'Precompiles' ? 'contract' : cat.name === 'Intrinsic Gas' ? 'parameter' : 'opcode'}
{cat.opcodes.length !== 1 ? 's' : ''})
</span>
<div className="flex-1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getOpcodeCategory, CATEGORY_COLORS } from '../../utils/opcodeUtils';

/** Category ordering for display */
const CATEGORY_ORDER = [
'Intrinsic Gas',
'Storage',
'Transient Storage',
'Contract',
Expand Down Expand Up @@ -325,7 +326,7 @@ export function GasScheduleDrawer({
<MagnifyingGlassIcon className="size-4 text-muted" />
<input
type="text"
placeholder="Search opcodes..."
placeholder="Search..."
value={searchQuery}
onChange={e => setSearchQuery(e.target.value)}
className="w-full border-0 bg-transparent text-sm text-foreground placeholder:text-muted focus:ring-0 focus:outline-hidden"
Expand Down
10 changes: 10 additions & 0 deletions src/pages/ethereum/execution/gas-profiler/utils/opcodeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const CATEGORY_COLORS: Record<string, string> = {
'Precompiles (Fixed)': '#10b981', // emerald
'Precompiles (Variable)': '#059669', // emerald-600
Precompiles: '#10b981', // emerald - used for opcode breakdown chart
'Intrinsic Gas': '#d946ef', // fuchsia
Other: '#9ca3af', // gray-400
};

Expand Down Expand Up @@ -190,6 +191,11 @@ export function isGasParameter(name: string): boolean {
return true;
}

// Intrinsic gas parameters (TX_BASE, TX_DATA_ZERO, etc.)
if (name.startsWith('TX_')) {
return true;
}

// Known standalone parameters (not opcodes)
const standaloneParameters = [
'MEMORY', // Memory expansion cost
Expand All @@ -214,6 +220,9 @@ export function getOpcodeCategory(opcode: string): string {
// Direct lookup first
if (OPCODE_CATEGORIES[opcode]) return OPCODE_CATEGORIES[opcode];

// Intrinsic gas entries (TX_BASE, TX_DATA_ZERO, etc.)
if (opcode.startsWith('TX_')) return 'Intrinsic Gas';

// Precompile gas entries (PC_SHA256, PC_ECREC, etc.)
if (opcode.startsWith('PC_')) return 'Precompiles';

Expand Down Expand Up @@ -276,6 +285,7 @@ const HEX_TO_TAILWIND: Record<string, { bg: string; hover: string }> = {
'#0ea5e9': { bg: 'bg-sky-500', hover: 'hover:bg-sky-400' },
'#10b981': { bg: 'bg-emerald-500', hover: 'hover:bg-emerald-400' },
'#059669': { bg: 'bg-emerald-600', hover: 'hover:bg-emerald-500' },
'#d946ef': { bg: 'bg-fuchsia-500', hover: 'hover:bg-fuchsia-400' },
'#9ca3af': { bg: 'bg-gray-400', hover: 'hover:bg-gray-300' },
};

Expand Down
Loading