Skip to content

Commit 62408ea

Browse files
committed
Clean up logs / comments
1 parent 4dbfbc7 commit 62408ea

File tree

7 files changed

+10
-24
lines changed

7 files changed

+10
-24
lines changed

lib/api.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ class API {
9393
target.canonicalPath
9494
);
9595

96-
//console.log('instrumented.contract --> ' + instrumented.contract);
97-
9896
this.coverage.addContract(instrumented, target.canonicalPath);
9997

10098
outputs.push({

lib/collector.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ class DataCollector {
4040
if (this.validOpcodes[info.opcode.name] && info.stack.length > 0){
4141
const idx = info.stack.length - 1;
4242
let hash = '0x' + info.stack[idx].toString(16);
43-
4443
this._registerHash(hash)
45-
4644
}
4745
} catch (err) { /*Ignore*/ };
4846
}
@@ -67,7 +65,7 @@ class DataCollector {
6765
hash = this._normalizeHash(hash);
6866

6967
if(this.instrumentationData[hash]){
70-
// abi.encode (used to circumvent viaIR) puts the hash on the stack twice
68+
// abi.encode (used to circumvent viaIR) sometimes puts the hash on the stack twice
7169
if (this.lastHash !== hash) {
7270
this.lastHash = hash;
7371
this.instrumentationData[hash].hits++
@@ -76,7 +74,6 @@ class DataCollector {
7674
}
7775

7876
// Detect and recover from viaIR mangled hashes by left-padding single `0`
79-
// for some cases
8077
if(this.viaIR && hash.length === 18) {
8178
hash = hash.slice(2);
8279
hash = '0' + hash;
@@ -100,7 +97,7 @@ class DataCollector {
10097
* @return {String} 0x prefixed hash of length 18.
10198
*/
10299
_normalizeHash(hash){
103-
// viaIR sometimes zero right-pads the hashes out to 32bytes
100+
// viaIR sometimes right-pads the hashes out to 32 bytes
104101
// but it doesn't preserve leading zeroes when it does this
105102
if (this.viaIR && hash.length >= 18) {
106103
hash = hash.slice(0,18);

lib/injector.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ class Injector {
5454
return `c_mod${web3Utils.keccak256(id).slice(2,10)}`
5555
}
5656

57-
// Way to get hash on the stack with viaIR (which seems to ignore abi.encode (v0.8.24))
58-
// If you visiting solidity-coverage & understand what's happening here, please do not mention
59-
// this obscure and irrelevant optimization opportunity in the issues at ethereum/solidity
60-
_getAbiEncodeStatementHash(hash){
57+
// Way to get hash on the stack with viaIR (which seems to ignore abi.encode builtin)
58+
// Tested with v0.8.17, v0.8.24
59+
_getAbiEncodeStatementHash(hash){
6160
return `abi.encode(${hash}); `
6261
}
6362

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"name": "solidity-coverage",
33
"version": "0.8.6",
44
"description": "Code coverage for Solidity testing",

plugins/hardhat.plugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ subtask(TASK_COMPILE_SOLIDITY_GET_COMPILATION_JOB_FOR_FILE).setAction(async (_,
5252
if (settings.optimizer === undefined) {
5353
settings.optimizer = {};
5454
}
55-
5655
// Unset useLiteralContent due to solc metadata size restriction
5756
settings.metadata.useLiteralContent = false;
5857

5958
// Beginning with v0.8.7, we let the optimizer run if viaIR is true and
60-
// instrument using `verbatim` YUL keyword. Otherwise turn the optimizer off.
59+
// instrument using `abi.encode(bytes8 covHash)`. Otherwise turn the optimizer off.
6160
if (!settings.viaIR) settings.optimizer.enabled = false;
6261

63-
// This is fixes a stack too deep bug in ABIEncoderV2
64-
// Experimental because not sure this works as expected across versions....
62+
// This sometimes fixed a stack-too-deep bug in ABIEncoderV2 for coverage plugin versions up to 0.8.6
63+
// Although issue should be fixed in 0.8.7, am leaving this option in because it may still be necessary
64+
// to configure optimizer details in some cases.
6565
if (configureYulOptimizer) {
6666
if (optimizerDetails === undefined) {
6767
settings.optimizer.details = {

plugins/resources/nomiclabs.utils.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ function normalizeConfig(config, args={}){
3636
? sources = path.join(config.paths.sources, args.sources)
3737
: sources = config.paths.sources;
3838

39-
//const { inspect } = require('util');
40-
//console.log('config --> ' + inspect(config.solidity.compilers));
41-
4239
if (config.solidity && config.solidity.compilers.length) {
4340
config.viaIR = isUsingViaIR(config.solidity);
4441
}

test/util/util.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ function instrumentAndCompile(sourceName, api={ config: {} }) {
9696
const instrumenter = new Instrumenter(api.config);
9797
const instrumented = instrumenter.instrument(contract, filePath);
9898

99-
//console.log('instrumented: --> ' + instrumented.contract);
100-
10199
return {
102100
contract: contract,
103101
instrumented: instrumented,
@@ -121,9 +119,6 @@ function report(output=[]) {
121119
async function bootstrapCoverage(file, api, provider){
122120
const info = instrumentAndCompile(file, api);
123121

124-
const {inspect} = require('util');
125-
//console.log('info --> ' + inspect(info.solcOutput));
126-
127122
// Need to define a gasLimit for contract calls because otherwise ethers will estimateGas
128123
// and cause duplicate hits for everything
129124
info.gas = { gasLimit: 2_000_000 }

0 commit comments

Comments
 (0)