MCPcopy Create free account
hub / github.com/NomicFoundation/hardhat / compare

Method compare

packages/hardhat-verify/src/internal/bytecode.ts:93–114  ·  view source on GitHub ↗

* Compares the executable sections of the deployed and compiled bytecode, * ignoring differences in metadata, library link references, immutable * variables, and call protection placeholders. * * This is necessary because deployed bytecode contains dynamically inserted * values (e.g.

(compilerOutputBytecode: CompilerOutputBytecode)

Source from the content-addressed store, hash-verified

91 * equivalent, `false` otherwise.
92 */
93 public compare(compilerOutputBytecode: CompilerOutputBytecode): boolean {
94 const unlinkedExecutableSection = inferExecutableSection(
95 compilerOutputBytecode.object,
96 );
97
98 // If the lengths differ, the bytecodes cannot match, so we can return early
99 if (this.executableSection.length !== unlinkedExecutableSection.length) {
100 return false;
101 }
102
103 const normalizedBytecode = nullifyBytecodeOffsets(
104 this.executableSection,
105 compilerOutputBytecode,
106 );
107
108 const normalizedUnlinkedBytecode = nullifyBytecodeOffsets(
109 unlinkedExecutableSection,
110 compilerOutputBytecode,
111 );
112
113 return normalizedBytecode === normalizedUnlinkedBytecode;
114 }
115}
116
117/**

Callers 2

bytecode.tsFile · 0.45
#matchAndBuildMethod · 0.45

Calls 2

inferExecutableSectionFunction · 0.85
nullifyBytecodeOffsetsFunction · 0.85

Tested by

no test coverage detected