Running ganache-cli -b 60 would only mine 1 block every 60 seconds.
Seems to just automine. Start ganache-cli -b 60 then running truffle deploy allows all the contracts to be deployed immediately.
Output:
root@dc56b1cb883d:/app# ganache-cli -b 60
Ganache CLI v6.1.0 (ganache-core: 2.1.0)
Available Accounts
==================
(0) 0xbb6ae9bd672c840470ec8ba72640166fb659b051
(1) 0xcfedd3831d471908c0530e9cceb20baf8ca72e40
(2) 0x9c5f81b908bef999c99afdf665d8954b12f4a73e
(3) 0x6b44aae8649acaf61bcf16b8fbf35607c3ba8aaa
(4) 0x86aa0c1705e7538a98ab6416e7909d1edbb7a2bc
(5) 0xcea338d2bf95643a86ba95ddb7f69f75ead99ca5
(6) 0x59f45f80f395805c99bb9c8d28cd6d62ca932f70
(7) 0x8c603255c9fbb5ae1da8b478310c1d62b7c71a60
(8) 0x3b291c5c25e33d381a6bdb4885c21ead4ba2f0c5
(9) 0xcfe1e1c4f8b950216d7bdde8093d1d8ccf0ed158
Private Keys
==================
(0) be6d229e01785663b8368a0904923e84d484e666fc0f35f198b7ec90e8e10413
(1) fb5263df95397091dd5682d997d2dcaafd6814fd9c14491c07e3f82106bdee22
(2) ce60e20bee51c3a31571e910fd8435c8eacdd253e2ffca0ffd2a2e640e574913
(3) ad321253b3e17ef6f2f19605291a6df5d2f7de34c37cbccc6f90c2240c662d64
(4) 1121aecc42b3dceae0d24f489206ee38fd572f1fd1ad097d7a2025a0cc10ff1f
(5) f9d6c34e403ed55eade157e79dc5949a0999bad65808151822cadc28a1277056
(6) c88075bc6eb6509e4388b7aa964233314758758f09b09800cd15da8da7c999f3
(7) b09fe03bd00236791bfe674a40b151f229ee25e47df020dea30f958ef09ab416
(8) fd4ff60ca58359b3e2eeb3fd5f9d653ddd60a1778b6b24466c661708451308ca
(9) 30e7b27f9c78cf5b6d8f4ada07c906de6301456d5e4d1c6acf24d4fc52c62355
HD Wallet
==================
Mnemonic: protect rebel romance kidney ladder couple upgrade label garbage end neglect hotel
Base HD Path: m/44'/60'/0'/0/{account_index}
Listening on localhost:8545
net_version
eth_accounts
eth_accounts
net_version
net_version
eth_sendTransaction
Transaction: 0xadf8f412c612c22daca5e62a76ed20011b0db591a6af1c9db32354d2e12cef8f
Contract created: 0x3f1b7c508c8549b8e6d7a08507525a9dc959a07a
Gas usage: 221871
Block Number: 1
Block Time: Tue Apr 10 2018 04:00:39 GMT+0000 (UTC)
eth_newBlockFilter
eth_getFilterChanges
eth_getTransactionReceipt
eth_getCode
eth_uninstallFilter
eth_sendTransaction
Transaction: 0xa5e86dd6026cc5aabdd4792db49e92013f9a7d04beb644613096a9258398a063
Gas usage: 41915
Block Number: 2
Block Time: Tue Apr 10 2018 04:00:40 GMT+0000 (UTC)
eth_getTransactionReceipt
eth_accounts
net_version
net_version
eth_sendTransaction
Transaction: 0x8fa2e4692670c9803c0417f2affc3ee4dc270fdef07084b226ea7c6bef91e7f6
Contract created: 0xd9f9ca7c40c8fcd78b84305e9625a8d1eb77f2e9
Gas usage: 3265879
Block Number: 3
Block Time: Tue Apr 10 2018 04:00:40 GMT+0000 (UTC)
eth_newBlockFilter
eth_getFilterChanges
eth_getTransactionReceipt
eth_getCode
eth_uninstallFilter
net_version
net_version
eth_sendTransaction
Transaction: 0x07734e91c26bb0d5134ba0c3bcb37110bd048625b1c6d480271c0faad2ac25bc
Contract created: 0x6abbdeae2e5fff74885cb862226d1730065e51c0
Gas usage: 215922
Block Number: 4
Block Time: Tue Apr 10 2018 04:00:40 GMT+0000 (UTC)
eth_newBlockFilter
eth_getFilterChanges
eth_getTransactionReceipt
eth_getCode
eth_uninstallFilter
eth_sendTransaction
Transaction: 0xd13b11e1cf288853af7cf85a5612c334ea644106f2a68f881787c1f949caad27
Gas usage: 26915
Block Number: 5
Block Time: Tue Apr 10 2018 04:00:40 GMT+0000 (UTC)
eth_getTransactionReceipt
ganache-cli -b 60I'm trying to emulate what live networks are like, they are not mined instantly.
FROM node:9Running into the same exact issue, was just about to post. I tried with both the -b and --blockTime flags but all blocks are still mined instantly.
Same issue :'(((((((((((((((((((
The other issue says our tests will run much faster with automining but imagine you want to have 500 transactions per block, if automining is on you have to mine 500 blocks.
Do you think block "mining" computation is insignificant so it wouldn't matter if 500 blocks with 1 tx each or 1 block with 500 tx? I can't test because it automines instantly, any way to batch those txs?
@EralpB I've had success with the Ganache UI app, the setting for block time does work: http://truffleframework.com/ganache/
Does the Ganache UI run ontop of the CLI and if so which version? Maybe a recent update to the CLI broke the --blockTime flag
It does, looks like 6.1.0. I tried copying what I saw in the UI for initializing ganache-cli, looks like it sends options with {blocktime: X} but could not get it to work. Tried blockTime also, no luck:
const ganacheLib = require("ganache-cli");
const settings = {
googleAnalyticsTracking: false,
cpuAndMemoryProfiling: false,
verboseLogging: false,
firstRun: true,
randomizeMnemonicOnStart: false,
server: {
hostname: "127.0.0.1",
port: 7545,
blocktime: 60,
network_id: 5777,
total_accounts: 10,
unlocked_accounts: [],
vmErrorsOnRPCResponse: true
}
};
const server = ganacheLib.server(settings);
server.listen(settings.server.port, settings.server.hostname, function(err, result) {
const state = result ? result : server.provider.manager.state;
const addresses = Object.keys(state.accounts);
addresses.forEach(function(address, index) {
console.log("Address: " + address);
console.log("Private key: " + accounts[address].secretKey.toString("hex"));
});
console.log("Waiting for requests...");
});
const oldSend = server.provider.send.bind(server.provider);
server.provider.send = function(payload, callback) {
if (payload.internal !== true) {
if (Array.isArray(payload)) {
payload.forEach(function(item) {
console.log(JSON.stringify(item));
})
} else {
console.log(JSON.stringify(payload));
}
}
oldSend(payload, callback);
};
Odd. I just ran the Ganache UI and blockTime worked me using that as well. However it's rather inconvenient to use for my current setup.
This is where I compiled the above code from if you want to try it yourself, maybe I missed something:
https://github.com/trufflesuite/ganache/blob/master/src/chain.js
https://github.com/trufflesuite/ganache/blob/master/src/Services/Settings.js
The UI part that sets server.blocktime:
https://github.com/trufflesuite/ganache/blob/master/src/Components/Config/ConfigScreens/ServerScreen.js
@kingjerod
Ya I can see that here
https://github.com/trufflesuite/ganache-cli/blob/develop/cli.js
line 118
blockTime: argv.b || argv.blockTime,
it sets blockTime as the option that goes to ganache-core
https://github.com/trufflesuite/ganache-core/blob/develop/lib/statemanager.js
line 63
this.blocktime = options.blocktime;
it looking for blocktime without a capital t
Looks like I can confirm that the issue is
line 118 in https://github.com/trufflesuite/ganache-cli/blob/develop/cli.js
blockTime has a capital T
I forked ganache-cli and did the fix, built the code and it seems to be working
https://github.com/Plinpod/ganache-cli/
same issue
ganache 1.1.0 gui works fine
How can I install the develop branch from npm? Do I need to wait for a release?
I tried upgrading the cli but didn't help.
This fix was merged in April and there have been no releases since March. The current Ganache CLI v6.1.0 uses ganache-core: 2.1.0 which does not include it. @benjamincburns ?
Hey @EralpB, you can install a specific branch doing the following:
npm install --save trufflesuite/ganache-cli#develop
or you can modify your package.json and do an npm install:
// package.json
...
"dependencies": {
"ganache-cli": "trufflesuite/ganache-cli#develop",
}
....
I just joined the Truffle team, so I'm not quite sure what our release schedule is looking like, but I'll chat with Ben to see what we can. In the meantime, you can use the above technique.
Most helpful comment
@EralpB I've had success with the Ganache UI app, the setting for block time does work: http://truffleframework.com/ganache/