Improve organization of edge case code in collector (#869)

pull/871/head
cgewecke 9 months ago committed by GitHub
parent e6df717d8d
commit 6839e92d8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 35
      lib/collector.js

@ -49,18 +49,6 @@ class DataCollector {
} catch (err) { /*Ignore*/ };
}
// Temporarily disabled because some relevant traces aren't available
/**
* Converts pushData value to string and registers in instrumentation map.
* @param {HardhatEVMTraceInstruction} instruction
*/
/*trackHardhatEVMInstruction(instruction){
if (instruction && instruction.pushData){
let hash = `0x` + instruction.pushData.toString('hex');
this._registerHash(hash)
}
}*/
/**
* Normalizes has string and marks hit.
* @param {String} hash bytes32 hash
@ -78,20 +66,6 @@ class DataCollector {
}
return;
}
// Detect and recover from viaIR mangled hashes by left-padding single `0`
if(this.viaIR && hash.length === 18) {
hash = hash.slice(2);
hash = '0' + hash;
hash = hash.slice(0,16);
hash = '0x' + hash;
if(this.instrumentationData[hash]){
if (this.lastHash !== hash) {
this.lastHash = hash;
this.instrumentationData[hash].hits++
}
}
}
}
/**
@ -107,6 +81,15 @@ class DataCollector {
// but it doesn't preserve leading zeroes when it does this
if (this.viaIR && hash.length >= 18) {
hash = hash.slice(0,18);
// Detect and recover from viaIR mangled hashes by left-padding single `0`
if(!this.instrumentationData[hash]) {
hash = hash.slice(2);
hash = '0' + hash;
hash = hash.slice(0,16);
hash = '0x' + hash;
}
} else if (hash.length < 18 && hash.length > 11){
hash = hash.slice(2);
while(hash.length < 16) hash = '0' + hash;

Loading…
Cancel
Save