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
35 changes: 35 additions & 0 deletions src/pages/ethereum/execution/gas-profiler/SimulatePage.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,41 @@ export const GAS_PARAMETER_GROUPS: GasParameterGroup[] = [
{ key: 'KECCAK256_WORD', label: 'KECCAK256 Word', min: 0, max: 50, step: 1 },
],
},
{
name: 'Precompiles (Fixed)',
color: '#10b981', // emerald
parameters: [
{ key: 'PC_ECREC', label: 'ECRECOVER', min: 0, max: 20000, step: 100 },
{ key: 'PC_BN254_ADD', label: 'BN254 Add', min: 0, max: 2000, step: 10 },
{ key: 'PC_BN254_MUL', label: 'BN254 Mul', min: 0, max: 30000, step: 500 },
{ key: 'PC_BLS12_G1ADD', label: 'BLS12 G1Add', min: 0, max: 5000, step: 25 },
{ key: 'PC_BLS12_G2ADD', label: 'BLS12 G2Add', min: 0, max: 5000, step: 25 },
{ key: 'PC_BLS12_MAP_FP_TO_G1', label: 'BLS12 MapFpToG1', min: 0, max: 30000, step: 500 },
{ key: 'PC_BLS12_MAP_FP2_TO_G2', label: 'BLS12 MapFp2ToG2', min: 0, max: 100000, step: 1000 },
{ key: 'PC_KZG_POINT_EVALUATION', label: 'KZG Point Eval', min: 0, max: 250000, step: 5000 },
{ key: 'PC_P256VERIFY', label: 'P256 Verify', min: 0, max: 20000, step: 100 },
],
},
{
name: 'Precompiles (Variable)',
color: '#059669', // emerald-600
parameters: [
{ key: 'PC_SHA256_BASE', label: 'SHA256 Base', min: 0, max: 500, step: 5 },
{ key: 'PC_SHA256_PER_WORD', label: 'SHA256 /Word', min: 0, max: 100, step: 1 },
{ key: 'PC_RIPEMD160_BASE', label: 'RIPEMD160 Base', min: 0, max: 3000, step: 50 },
{ key: 'PC_RIPEMD160_PER_WORD', label: 'RIPEMD160 /Word', min: 0, max: 500, step: 10 },
{ key: 'PC_ID_BASE', label: 'Identity Base', min: 0, max: 100, step: 1 },
{ key: 'PC_ID_PER_WORD', label: 'Identity /Word', min: 0, max: 50, step: 1 },
{ key: 'PC_MODEXP_MIN_GAS', label: 'MODEXP Min Gas', min: 0, max: 2000, step: 10 },
{ key: 'PC_BN254_PAIRING_BASE', label: 'BN254 Pairing Base', min: 0, max: 200000, step: 5000 },
{ key: 'PC_BN254_PAIRING_PER_PAIR', label: 'BN254 Pairing /Pair', min: 0, max: 200000, step: 1000 },
{ key: 'PC_BLAKE2F_PER_ROUND', label: 'BLAKE2F /Round', min: 0, max: 20, step: 1 },
{ key: 'PC_BLS12_PAIRING_CHECK_BASE', label: 'BLS12 Pairing Base', min: 0, max: 200000, step: 5000 },
{ key: 'PC_BLS12_PAIRING_CHECK_PER_PAIR', label: 'BLS12 Pairing /Pair', min: 0, max: 200000, step: 1000 },
{ key: 'PC_BLS12_G1MSM_MUL_GAS', label: 'BLS12 G1MSM /Point', min: 0, max: 50000, step: 1000 },
{ 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.
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ function OpcodeRow({ op, maxGas }: { op: OpcodeRowData; maxGas: number }): JSX.E

return (
<Tooltip
title={op.opcode}
title={op.opcode.startsWith('PC_') ? 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 @@ -442,7 +442,9 @@ function OpcodeRow({ op, maxGas }: { op: OpcodeRowData; maxGas: number }): JSX.E
{/* Main row — mirrors category header pattern */}
<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}</span>
<span className="font-mono text-xs font-semibold text-foreground">
{op.opcode.startsWith('PC_') ? op.opcode.slice(3) : op.opcode}
</span>
{hasCountChange && (
<span className="font-mono text-[11px] text-muted tabular-nums">
{formatGas(op.originalCount)} &rarr; {formatGas(op.simulatedCount)} execs
Expand Down Expand Up @@ -551,7 +553,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} opcode{cat.opcodes.length !== 1 ? 's' : ''})
({cat.opcodes.length} {cat.name === 'Precompiles' ? 'contract' : 'opcode'}
{cat.opcodes.length !== 1 ? 's' : ''})
</span>
<div className="flex-1" />
<span className="mr-1 font-mono text-xs text-muted tabular-nums">
Expand Down Expand Up @@ -1033,7 +1036,7 @@ export function BlockSimulationResultsV2({
<div className="flex items-center justify-between gap-4 border-b border-border">
<ScrollableTabs className="border-b-0">
<Tab>Summary</Tab>
<Tab>Opcode Breakdown</Tab>
<Tab>Gas Breakdown</Tab>
<Tab>Transactions</Tab>
</ScrollableTabs>
<div className="flex items-center gap-2 pb-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const CATEGORY_ORDER = [
'Swap',
'Memory',
'Misc',
'Precompiles (Fixed)',
'Precompiles (Variable)',
'Other',
];

Expand Down Expand Up @@ -476,10 +478,16 @@ export function GasScheduleDrawer({
'truncate font-mono text-xs',
isModified ? 'font-semibold text-primary' : 'text-foreground'
)}
title={key}
>
{key}
{key.startsWith('PC_') ? key.slice(3) : key}
</span>
{param.description && <InfoTooltip title={key} description={param.description} />}
{param.description && (
<InfoTooltip
title={key.startsWith('PC_') ? key.slice(3) : key}
description={param.description}
/>
)}
</div>

{/* Number Input */}
Expand Down
13 changes: 13 additions & 0 deletions src/pages/ethereum/execution/gas-profiler/utils/opcodeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export const CATEGORY_COLORS: Record<string, string> = {
Swap: '#84cc16', // lime
Log: '#eab308', // yellow
Contract: '#0ea5e9', // sky
'Precompiles (Fixed)': '#10b981', // emerald
'Precompiles (Variable)': '#059669', // emerald-600
Precompiles: '#10b981', // emerald - used for opcode breakdown chart
Other: '#9ca3af', // gray-400
};

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

// Precompile gas parameters (PC_SHA256_BASE, PC_ECREC, etc.)
if (name.startsWith('PC_')) {
return true;
}

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

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

// Push opcodes (PUSH0-PUSH32)
if (opcode.startsWith('PUSH')) return 'Push';

Expand Down Expand Up @@ -263,6 +274,8 @@ const HEX_TO_TAILWIND: Record<string, { bg: string; hover: string }> = {
'#84cc16': { bg: 'bg-lime-500', hover: 'hover:bg-lime-400' },
'#eab308': { bg: 'bg-yellow-500', hover: 'hover:bg-yellow-400' },
'#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' },
'#9ca3af': { bg: 'bg-gray-400', hover: 'hover:bg-gray-300' },
};

Expand Down
Loading