Skip to content

Conversation

@chevdor
Copy link
Contributor

@chevdor chevdor commented Jun 19, 2018

$ ./solcjs-get --help
Usage: [options| version]

Options:
  --version   Show version number                                      [boolean]
  --list      List all the versions
  --all       Download all the versions. Additionnaly, use --nightly to get the
              nightly builds.
  --nightly   Combined with --all, it adds the nightly to the list
  --releases  Get all the release builds
  --clean     Delete all the compiler in ./bin
  --help      Show help                                                [boolean]

@chevdor chevdor mentioned this pull request Jun 19, 2018
@coveralls
Copy link

coveralls commented Jun 19, 2018

Coverage Status

Coverage remained the same at 85.828% when pulling 2fa53cd on chevdor:solcjs-get into e5fab6f on ethereum:master.

@chevdor
Copy link
Contributor Author

chevdor commented Jun 21, 2018

@axic you were asking for this one

Copy link
Contributor

@axic axic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shares a lot of code with downloadCurrentVersion.js. The common code should be pulled into helpers.

Alternatively, this should just replace downloadCurrentVersion.js.

@chevdor
Copy link
Contributor Author

chevdor commented Jan 17, 2019

It replaces downloadCurrentVersion.js

@axic
Copy link
Contributor

axic commented Jan 18, 2019

It replaces downloadCurrentVersion.js

In the PR it doesn't do that yet. I can look into fixing it if you don't have time (which I understand, given how long it took to get into reviewing the PR).

@chevdor
Copy link
Contributor Author

chevdor commented Jan 18, 2019

I admit I lost the history of this one...
I initially made a big PR (very likely too big). Upon your request I then shrunk it a bit so parts may have been left out intentionally. Feel free to fix it as you wish but keep an eye on the other PRs as your fixes may be already done elsewhere.

@chevdor
Copy link
Contributor Author

chevdor commented Jul 8, 2021

Hello, coud this PR be reviewed and either merged or closed ?

@chevdor chevdor requested a review from axic July 8, 2021 08:43
@chriseth
Copy link
Contributor

chriseth commented Jul 8, 2021

Can you explain the benefit over downloadCurrentVersion.js?

@chevdor
Copy link
Contributor Author

chevdor commented Jul 8, 2021

Can you explain the benefit over downloadCurrentVersion.js?

Back in 2018 I surely could have 😄
From what I recall, instead of downloading ONLY the current version, it allowed the user downloading the version of their choice.

@cameel
Copy link
Collaborator

cameel commented Jul 9, 2021

I think this looks useful. It's at least an improvement over the original script.

I rebased it on the latest master and added some small tweaks (typos, parameter descriptions, style). I also modified so that the new script actually replaces downloadCurrentVersion.js.

There are some things that I think get unnecessarily removed. I'll point them out in review.

BTW, the diff is much better if you look at the individual commits. In the combined diff github does not detect that the file was actually just renamed.

Comment on lines 51 to 55
var hash = '0x' + keccak256(fs.readFileSync(outputName, { encoding: 'binary' }));
if (expectedHash !== hash) {
console.log('Hash mismatch: ' + expectedHash + ' vs ' + hash);
process.exit(1);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new script removes the code responsible for verifying checksums of downloaded binaries. I don't think it's a good thing. I'd keep that code.

Comment on lines 68 to 72
var expectedFile = list.builds.filter(function (entry) { return entry.path === releaseFileName; })[0];
if (!expectedFile) {
console.log('Version list is invalid or corrupted?');
process.exit(1);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is gone too in the new version.

Comment on lines 36 to 40
process.on('SIGINT', function () {
console.log('Interrupted, removing file.');
fs.unlinkSync(outputName);
process.exit(1);
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to remove a partially downloaded file. I'd keep it.

solcjs-get Outdated
var MemoryStream = require('memorystream');
var keccak256 = require('js-sha3').keccak256;
var path = require('path');
var compilerDir = 'bin';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add an option to specify this directory (bin could still be the default though).

Comment on lines 15 to 34
.option('list', {
describe: 'List all the versions',
type: 'bool'
})
.option('all', {
describe: 'Download all the versions. Additionnaly, use --nightly to get the nightly builds.',
type: 'bool'
})
.option('nightly', {
describe: 'Combined with --all, it adds the nightly to the list',
type: 'bool'
})
.option('releases', {
describe: 'Get all the release builds',
type: 'bool'
})
.option('clean', {
describe: 'Delete all the compiler in ./bin',
type: 'bool'
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These options all seem to be mutually exclusive but the script does not print any error if you use more than one. This was pretty confusing when I tried running it for the first time. Using more than one should not be allowed unless it actually does something.

BTW, I think that combining --list with --all/--nightly/--releases might actually be useful. I'd even make --list print only releases by default because the whole list is pretty long.

solcjs-get Outdated
Comment on lines 131 to 133
if (!requestedVersion){
fs.copy(file, 'soljson.js'); // for backward compatibility
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be a symlink (at least if the FS supports it).

Actually, this does not seem like something just for backwards compatibility. Can solc-js even use the compiler when it's inside bin/? I think that an option to relink it to another version might be useful because that's basically how the select the compiler version now.

solcjs-get Outdated
Comment on lines 91 to 97
console.log('Removing all local compilers in ' + compilerDir + ' ...');
fs.remove(compilerDir, function (err) {
if (err) return console.error(err);

console.log('Success! Cleaned ' + compilerDir);
process.exit(0);
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's a good idea to remove the whole dir. As a user I think I'd expect this to be more intelligent and only remove the binaries (otherwise why even provide an option for something that can be easily done with rm?). I think it would be safer to only remove files matching the valid name regex.

solcjs-get Outdated
list = JSON.parse(list).builds;
for (var i = list.length - 1; i >= 0; i--) {
var target = list[i].path;
if (target.indexOf('nightly') > 0 && !argv.nightly) continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list contains a releases array. I think that checking if the file name is not in it would be a more future-proof check for a nightly.

solcjs-get Outdated
var compilerDir = 'bin';

var yargs = require('yargs')
.usage('Usage: [options| version]')
Copy link
Collaborator

@cameel cameel Jul 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually supposed to work with a version or only with the whole file name?
Something like ./solcjs-get 0.8.6 or ./solcjs-get v0.8.6 does not not say that the file does not exist. The script tries to download it:

Retrieving available version list...
Requested version: v0.8.6
Downloading version v0.8.6
Error downloading file: 404

@chevdor
Copy link
Contributor Author

chevdor commented Jul 14, 2021

Closing because I don't really have a use for this PR anymore and it is so long ago, I don't even remember the details...

@chevdor chevdor closed this Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants