Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Milk and Cookies 🥛🍪
Browse files Browse the repository at this point in the history
Merge 'develop' into 'beta'
  • Loading branch information
nicholasjpaterno authored May 19, 2020
2 parents 9319f49 + 17b69c4 commit 31522bb
Show file tree
Hide file tree
Showing 7 changed files with 10,378 additions and 4,247 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ganache-cli CD

on:
push:
branches: [ master, beta ]

jobs:
release:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '10'

- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_OTP_KEY: ${{ secrets.NPM_OTP_KEY }}
run: npm run otp && npx semantic-release
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $ ganache-cli <options>
* `-g` or `--gasPrice`: The price of gas in wei (defaults to 20000000000)
* `-l` or `--gasLimit`: The block gas limit (defaults to 0x6691b7)
* `--callGasLimit`: Sets the transaction gas limit for `eth_call` and `eth_estimateGas` calls. Must be specified as a `hex` string. Defaults to `"0x1fffffffffffff"` (`Number.MAX_SAFE_INTEGER`)
* `-k` or `--hardfork`: Allows users to specify which hardfork should be used. Supported hardforks are `byzantium`, `constantinople`, `petersburg`, and `istanbul` (default).
* `-k` or `--hardfork`: Allows users to specify which hardfork should be used. Supported hardforks are `byzantium`, `constantinople`, `petersburg`, `istanbul`, and `muirGlacier` (default).
* `-f` or `--fork`: Fork from another currently running Ethereum client at a given block. Input should be the HTTP location and port of the other client, e.g. `http://localhost:8545`. You can optionally specify the block to fork from using an `@` sign: `http://localhost:8545@1599200`.
* `-i` or `--networkId`: Specify the network id ganache-cli will use to identify itself (defaults to the current time or the network id of the forked blockchain if configured)
* `--db`: Specify a path to a directory to save the chain database. If a database already exists, ganache-cli will initialize that chain instead of creating a new one.
Expand All @@ -77,6 +77,7 @@ $ ganache-cli <options>
* `--allowUnlimitedContractSize`: Allows unlimited contract sizes while debugging. By enabling this flag, the check within the EVM for contract size limit of 24KB (see EIP-170) is bypassed. Enabling this flag **will** cause ganache-cli to behave differently than production environments.
* `--keepAliveTimeout`: Sets the HTTP server's `keepAliveTimeout` in milliseconds. See the [NodeJS HTTP docs](https://nodejs.org/api/http.html#http_server_keepalivetimeout) for details. `5000` by default.
* `-t` or `--time`: Date (ISO 8601) that the first block should start. Use this feature, along with the evm_increaseTime method to test time-dependent code.
* `--deasync`: `boolean` Synchronizes ganache server startup. Useful in certain scenarios - see ganache-cli issue [#733](https://github.com/trufflesuite/ganache-cli/issues/733).

Special Options:

Expand Down Expand Up @@ -162,7 +163,7 @@ Both `.provider()` and `.server()` take a single object which allows you to spec
* `"account_keys_path"`: `String` - Specifies a file to save accounts and private keys to, for testing.
* `"vmErrorsOnRPCResponse"`: `boolean` - Whether or not to transmit transaction failures as RPC errors. Set to `false` for error reporting behaviour which is compatible with other clients such as geth and Parity. This is `true` by default to replicate the error reporting behavior of previous versions of ganache.
* `"hdPath"`: The hierarchical deterministic path to use when generating accounts. Default: "m/44'/60'/0'/0/"
* `"hardfork"`: `String` Allows users to specify which hardfork should be used. Supported hardforks are `byzantium`, `constantinople`, `petersburg`, and `istanbul` (default).
* `"hardfork"`: `String` Allows users to specify which hardfork should be used. Supported hardforks are `byzantium`, `constantinople`, `petersburg`, `istanbul`, and `muirGlacier` (default).
* `"allowUnlimitedContractSize"`: `boolean` - Allows unlimited contract sizes while debugging (NOTE: this setting is often used in conjuction with an increased `gasLimit`). By setting this to `true`, the check within the EVM for contract size limit of 24KB (see [EIP-170](https://git.io/vxZkK)) is bypassed. Setting this to `true` **will** cause `ganache-cli` to behave differently than production environments. (default: `false`; **ONLY** set to `true` during debugging).
* `"gasPrice"`: `String::hex` Sets the default gas price for transactions if not otherwise specified. Must be specified as a `hex` encoded string in `wei`. Defaults to `"0x77359400"` (2 `gwei`).
* `"gasLimit"`: `String::hex | number` Sets the block gas limit. Must be specified as a `hex` string or `number`. Defaults to `"0x6691b7"`.
Expand Down
17 changes: 15 additions & 2 deletions args.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ module.exports = exports = function(yargs, version, isDocker) {
group: 'Chain:',
alias: 'hardfork',
type: 'string',
describe: "Allows users to specify which hardfork should be used. Supported hardforks are `byzantium`, `constantinople`, `petersburg` (default), and `istanbul` (beta).",
default: "istanbul"
describe: "Allows users to specify which hardfork should be used. Supported hardforks are `byzantium`, `constantinople`, `petersburg`, `istanbul` and `muirGlacier` (default).",
default: "muirGlacier"
})
.option('f', {
group: 'Chain:',
Expand All @@ -96,6 +96,13 @@ module.exports = exports = function(yargs, version, isDocker) {
conflicts: 'd',
demandOption: false
})
.option('hdPath', {
group: 'Accounts:',
alias: 'hd_path',
describe: `The hierarchical deterministic path to use when generating accounts. Default: "m/44'/60'/0'/0/"`,
type: 'string',
demandOption: false
})
.option('d', {
group: 'Chain:',
alias: 'deterministic',
Expand Down Expand Up @@ -198,6 +205,12 @@ module.exports = exports = function(yargs, version, isDocker) {
type: 'boolean',
default: false
})
.option('deasync', {
group: 'Other::',
describe: 'Synchronize ganache server startup. Useful in certain scenarios (see ganache-cli issue #733).',
type: 'boolean',
default: false
})
.showHelpOnFail(false, 'Specify -? or --help for available options')
.help('help')
.alias('help', '?')
Expand Down
94 changes: 54 additions & 40 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ var detailedVersion = "Ganache CLI v" + pkg.version + " (ganache-core: " + ganac

var isDocker = "DOCKER" in process.env && process.env.DOCKER.toLowerCase() === "true";
var argv = initArgs(yargs, detailedVersion, isDocker).argv;
var deasync;
try {
deasync = argv.deasync ? require("deasync") : false;
} catch(e) {
deasync = false;
}

function parseAccounts(accounts) {
function splitAccount(account) {
Expand Down Expand Up @@ -92,6 +98,7 @@ var options = {
verbose: argv.v,
secure: argv.n,
db_path: argv.db,
hd_path: argv.hdPath,
account_keys_path: argv.account_keys_path,
vmErrorsOnRPCResponse: !argv.noVMErrorsOnRPCResponse,
logger: logger,
Expand All @@ -101,33 +108,58 @@ var options = {
}

var fork_address;
var server = ganache.server(options);

// If we're forking from another client, don't try to use the same port.
if (options.fork) {
var split = options.fork.split("@");
fork_address = split[0];
var block;
if (split.length > 1) {
block = split[1];
}
console.log(detailedVersion);

if (URL.parse(fork_address).port == options.port) {
options.port = (parseInt(options.port) + 1);
let started = false;
process.on("uncaughtException", function(e) {
if (started) {
console.log(e);
} else {
console.log(e.stack);
}
process.exit(1);
})

options.fork = fork_address + (block != null ? "@" + block : "");
// See http://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
if (process.platform === "win32") {
require("readline").createInterface({
input: process.stdin,
output: process.stdout
})
.on("SIGINT", function () {
process.emit("SIGINT");
});
}

var server = ganache.server(options);
const closeHandler = function () {
// graceful shutdown
server.close(function(err) {
if (err) {
// https://nodejs.org/api/process.html#process_process_exit_code
// writes to process.stdout in Node.js are sometimes asynchronous and may occur over
// multiple ticks of the Node.js event loop. Calling process.exit(), however, forces
// the process to exit before those additional writes to stdout can be performed.
if(process.stdout._handle) process.stdout._handle.setBlocking(true);
console.log(err.stack || err);
process.exit();
} else {
process.exit(0);
}
});
}

console.log(detailedVersion);
process.on("SIGINT", closeHandler);
process.on("SIGTERM", closeHandler);
process.on("SIGHUP", closeHandler);

server.listen(options.port, options.hostname, function(err, result) {
function startGanache(err, result) {
if (err) {
console.log(err);
return;
}

started = true;
var state = result ? result : server.provider.manager.state;

console.log("");
Expand Down Expand Up @@ -206,30 +238,12 @@ server.listen(options.port, options.hostname, function(err, result) {

console.log("");
console.log("Listening on " + options.hostname + ":" + options.port);
});

process.on('uncaughtException', function(e) {
console.log(e.stack);
process.exit(1);
})

// See http://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
if (process.platform === "win32") {
require("readline").createInterface({
input: process.stdin,
output: process.stdout
})
.on("SIGINT", function () {
process.emit("SIGINT");
});
}

process.on("SIGINT", function () {
// graceful shutdown
server.close(function(err) {
if (err) {
console.log(err.stack || err);
}
process.exit();
});
});
if (deasync) {
const listen = deasync(server.listen);
const result = listen(options.port, options.hostname);
startGanache(null, result);
} else {
server.listen(options.port, options.hostname, startGanache);
}
Loading

0 comments on commit 31522bb

Please sign in to comment.