|
|
@ -22,9 +22,7 @@ class DataCollector { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (this.validOpcodes[info.opcode.name] && info.stack.length > 0){ |
|
|
|
if (this.validOpcodes[info.opcode.name] && info.stack.length > 0){ |
|
|
|
const idx = info.stack.length - 1; |
|
|
|
const idx = info.stack.length - 1; |
|
|
|
let hash = web3Utils.toHex(info.stack[idx]).toString(); |
|
|
|
let hash = "0x" + info.stack[idx].toString(16,64); |
|
|
|
hash = this._normalizeHash(hash); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.instrumentationData[hash]){ |
|
|
|
if(this.instrumentationData[hash]){ |
|
|
|
this.instrumentationData[hash].hits++; |
|
|
|
this.instrumentationData[hash].hits++; |
|
|
|
} |
|
|
|
} |
|
|
@ -32,23 +30,6 @@ class DataCollector { |
|
|
|
} catch (err) { /*Ignore*/ }; |
|
|
|
} catch (err) { /*Ignore*/ }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Left-pads zero prefixed bytes 32 hashes to length 66. The '59' in the |
|
|
|
|
|
|
|
* comparison below is arbitrary. It provides a margin for recurring zeros |
|
|
|
|
|
|
|
* but prevents left-padding shorter irrelevant hashes (like fn sigs) |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {String} hash data hash from evm stack. |
|
|
|
|
|
|
|
* @return {String} 0x prefixed hash of length 66. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_normalizeHash(hash){ |
|
|
|
|
|
|
|
if (hash.length < 66 && hash.length > 59){ |
|
|
|
|
|
|
|
hash = hash.slice(2); |
|
|
|
|
|
|
|
while(hash.length < 64) hash = '0' + hash; |
|
|
|
|
|
|
|
hash = '0x' + hash |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return hash; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Unit test helper |
|
|
|
* Unit test helper |
|
|
|
* @param {Object} data Instrumenter.instrumentationData |
|
|
|
* @param {Object} data Instrumenter.instrumentationData |
|
|
@ -58,4 +39,4 @@ class DataCollector { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = DataCollector; |
|
|
|
module.exports = DataCollector; |
|
|
|