Skip to content

Commit cf75e6a

Browse files
leovctmds1
andauthored
fix: remove hardfork properties from diff algorithm (#56)
* fix: remove hardfork from opcode diff algo * fix: remove hardfork from eip diff algo * fix: remove eip-4399 mainnet note * chore: rename section and hide consensus nodes from UI --------- Co-authored-by: Matt Solomon <[email protected]>
1 parent 8c5837a commit cf75e6a

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

src/chains/mainnet/eips.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,6 @@ export const eip4399: EIP = {
465465

466466
status: EIPState.Final,
467467
activeHardforks: hardforksFromParis,
468-
notes: [
469-
"PREVRANDAO returns the random output of the L1 beacon chain's oracle from approximately 5 L1 blocks ago.",
470-
],
471468
references: ['https://eips.ethereum.org/EIPS/eip-4399'],
472469
};
473470

src/components/diff/DiffEIPs.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export const DiffEIPs = ({ base, target, onlyShowDiff }: Props): JSX.Element =>
2323
{eipNumbers.map((number) => {
2424
const baseEIP = base.find((eip) => eip.number === number);
2525
const targetEIP = target.find((eip) => eip.number === number);
26-
if (!baseEIP && !targetEIP) {
26+
if (!baseEIP || !targetEIP) {
2727
return <></>;
2828
}
2929

30-
const isEqual = JSON.stringify(baseEIP) === JSON.stringify(targetEIP);
30+
const isEqual =
31+
JSON.stringify(convertToComparableEIP(baseEIP)) ===
32+
JSON.stringify(convertToComparableEIP(targetEIP));
3133
const showOpcode = !isEqual || !onlyShowDiff;
3234

3335
return (
@@ -129,3 +131,20 @@ const formatEIPParameters = (params: EIPParameter[]): JSX.Element => {
129131
);
130132
return <Collapsible kind='custom' title='Parameters' contents={contents} />;
131133
};
134+
135+
// Convert an `EIP` object to a simpler struct in order to compare it to other EIPs.
136+
// Note: casting an object from a type with properties X, Y and Z to a subset type with properties
137+
// X and Y using the `as` keyword will still retain the field Z unless you explicitly remove it.
138+
// That's why this function exists.
139+
export const convertToComparableEIP = (eip: EIP): Omit<EIP, 'activeHardforks'> => {
140+
return {
141+
number: eip.number,
142+
title: eip.title,
143+
category: eip.category,
144+
status: eip.status,
145+
deprecated: eip.deprecated,
146+
parameters: eip.parameters,
147+
notes: eip.notes,
148+
references: eip.references,
149+
};
150+
};

src/components/diff/DiffOpcodes.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export const DiffOpcodes = ({ base, target, onlyShowDiff }: Props): JSX.Element
285285
// That's why this function exists.
286286
export const convertToComparableOpcode = (
287287
opcode: Opcode
288-
): Omit<Opcode, 'examples' | 'playgroundLink' | 'notes' | 'references'> => {
288+
): Omit<Opcode, 'examples' | 'playgroundLink' | 'notes' | 'references' | 'supportedHardforks'> => {
289289
return {
290290
number: opcode.number,
291291
name: opcode.name,
@@ -295,6 +295,5 @@ export const convertToComparableOpcode = (
295295
inputs: opcode.inputs,
296296
outputs: opcode.outputs,
297297
errorCases: opcode.errorCases,
298-
supportedHardforks: opcode.supportedHardforks,
299298
};
300299
};

src/pages/diff.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ const SECTION_MAP: Record<string, Section> = {
4040
opcodes: { title: 'Opcodes', component: DiffOpcodes },
4141
mempools: { title: 'Mempools', component: DiffMempools },
4242
deployedContracts: { title: 'Deployed Contracts', component: DiffDeployedContracts },
43-
eips: { title: 'EIPs', component: DiffEIPs },
43+
eips: { title: 'Execution EIPs', component: DiffEIPs },
4444
executionNodes: { title: 'Execution Nodes', component: DiffNodes },
45-
consensusNodes: { title: 'Consensus Nodes', component: DiffNodes },
45+
consensusNodes: { title: 'Consensus Nodes', component: DiffNodes, hide: true }, // Hidden to scope UI to execution data
4646
};
4747

4848
const Diff = () => {

0 commit comments

Comments
 (0)