diff --git a/.gitignore b/.gitignore index 73a1bfee..cd7162c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules TODO +.node-xmlhttprequest-sync-* diff --git a/bin/embark b/bin/embark index 0786b1bd..bc9f8e91 100644 --- a/bin/embark +++ b/bin/embark @@ -25,7 +25,7 @@ var deploy = function(env, embarkConfig) { } program - .version('0.7.0') + .version('0.7.1') program.command('new [name]').description('New application').action(function(name) { if (name === undefined) { diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index cf9f329a..0eafb67b 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -3,8 +3,10 @@ development: rpc_port: 8101 rpc_whitelist: "*" minerthreads: 1 + genesis_block: config/genesis/dev_genesis.json datadir: /tmp/embark mine_when_needed: true + max_peers: 0 gas_limit: 500000 gas_price: 10000000000000 console: false @@ -17,17 +19,19 @@ staging: rpc_whitelist: "*" datadir: default network_id: 0 + max_peers: 4 console: true account: init: false - address: + address: production: rpc_host: localhost rpc_port: 8101 rpc_whitelist: "*" datadir: default network_id: 1 + max_peers: 4 console: true account: init: false - address: + address: diff --git a/boilerplate/config/genesis/dev_genesis.json b/boilerplate/config/genesis/dev_genesis.json new file mode 100644 index 00000000..9f60d776 --- /dev/null +++ b/boilerplate/config/genesis/dev_genesis.json @@ -0,0 +1,12 @@ +{ + "nonce": "0x0000000000000042", + "difficulty": "0x40000", + "alloc": { + }, + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x", + "gasLimit": "0x4c4b40" +} diff --git a/boilerplate/package.json b/boilerplate/package.json index 012df934..e72db260 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,7 +10,7 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "^0.7.0", + "embark-framework": "^0.7.1", "grunt-embark": "^0.2.0", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", diff --git a/demo/config/blockchain.yml b/demo/config/blockchain.yml index cf9f329a..0072c4cb 100644 --- a/demo/config/blockchain.yml +++ b/demo/config/blockchain.yml @@ -3,6 +3,7 @@ development: rpc_port: 8101 rpc_whitelist: "*" minerthreads: 1 + genesis_block: config/genesis/dev_genesis.json datadir: /tmp/embark mine_when_needed: true gas_limit: 500000 @@ -20,7 +21,7 @@ staging: console: true account: init: false - address: + address: production: rpc_host: localhost rpc_port: 8101 @@ -30,4 +31,4 @@ production: console: true account: init: false - address: + address: diff --git a/demo/config/genesis/dev_genesis.json b/demo/config/genesis/dev_genesis.json new file mode 100644 index 00000000..9f60d776 --- /dev/null +++ b/demo/config/genesis/dev_genesis.json @@ -0,0 +1,12 @@ +{ + "nonce": "0x0000000000000042", + "difficulty": "0x40000", + "alloc": { + }, + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x", + "gasLimit": "0x4c4b40" +} diff --git a/demo_meteor/config/blockchain.yml b/demo_meteor/config/blockchain.yml index e1a4936b..3bfb3fd2 100644 --- a/demo_meteor/config/blockchain.yml +++ b/demo_meteor/config/blockchain.yml @@ -3,6 +3,7 @@ development: rpc_port: 8101 rpc_whitelist: "*" minerthreads: 1 + genesis_block: config/genesis.json datadir: /tmp/embark mine_when_needed: true gas_limit: 500000 @@ -20,4 +21,4 @@ staging: console: true account: init: false - address: + address: diff --git a/demo_meteor/config/genesis.json b/demo_meteor/config/genesis.json new file mode 100644 index 00000000..9f60d776 --- /dev/null +++ b/demo_meteor/config/genesis.json @@ -0,0 +1,12 @@ +{ + "nonce": "0x0000000000000042", + "difficulty": "0x40000", + "alloc": { + }, + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x", + "gasLimit": "0x4c4b40" +} diff --git a/lib/blockchain.js b/lib/blockchain.js index d089ae1b..3b15b77a 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -1,3 +1,4 @@ +var mkdirp = require('mkdirp'); Blockchain = function(blockchainConfig) { this.config = blockchainConfig; @@ -25,9 +26,12 @@ Blockchain.prototype.generate_basic_command = function() { } cmd += "--mine "; + if (config.genesisBlock !== void 0) { + cmd += "--genesis=\"" + config.genesisBlock + "\" "; + } //TODO: this should be configurable - cmd += "--maxpeers 0 "; + cmd += "--maxpeers " + config.maxPeers + " "; if (config.account.password !== void 0) { cmd += "--password " + config.account.password + " "; @@ -73,6 +77,14 @@ Blockchain.prototype.get_address = function() { var address = null; if (config.account.init) { + // ensure datadir exists, bypassing the interactive liabilities prompt. + var newDir = mkdirp.sync(config.datadir); + if (newDir) { + console.log("=== datadir created"); + } else { + console.log("=== datadir already exists"); + } + console.log("running: " + this.list_command()); result = exec(this.list_command()); @@ -96,4 +108,3 @@ Blockchain.prototype.startChain = function(use_tmp) { } module.exports = Blockchain - diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index ca2e0f08..935ba130 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -38,8 +38,10 @@ BlockchainConfig.prototype.config = function(env) { gasPrice: config.gas_price || 10000000000000, rpcWhitelist: config.rpc_whitelist, minerthreads: config.minerthreads, + genesisBlock: config.genesis_block, datadir: config.datadir, networkId: networkId, + maxPeers: 4, port: config.port || "30303", console_toggle: config.console || false, mine_when_needed: config.mine_when_needed || false, @@ -50,4 +52,3 @@ BlockchainConfig.prototype.config = function(env) { }; module.exports = BlockchainConfig; - diff --git a/lib/deploy.js b/lib/deploy.js index a4b30044..41fac6de 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -71,7 +71,7 @@ Deploy.prototype.deploy_contracts = function(env) { console.log('trying to obtain ' + className + ' address...'); var receipt = null; - while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null) { + while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null || receipt.contractAddress === null) { sleep.sleep(1); } var contractAddress = receipt.contractAddress; diff --git a/package.json b/package.json index b3c5054e..149ee0bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-framework", - "version": "0.7.0", + "version": "0.7.1", "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -19,6 +19,7 @@ "jasmine": "^2.3.1", "meteor-build-client": "^0.1.6", "methodmissing": "^0.0.3", + "mkdirp": "^0.5.1", "python": "^0.0.4", "read-yaml": "^1.0.0", "shelljs": "^0.5.0", diff --git a/test/blockchain.js b/test/blockchain.js index 4f94ca82..3f3cca23 100644 --- a/test/blockchain.js +++ b/test/blockchain.js @@ -10,7 +10,7 @@ describe('embark.blockchain', function() { var blockchain = new Blockchain(blockchainConfig); it('should return correct cmd', function() { - assert.strictEqual(blockchain.generate_basic_command(), "geth --datadir=\"/tmp/embark\" --logfile=\"/tmp/embark.log\" --port 30303 --rpc --rpcport 8101 --networkid "+blockchainConfig.networkId+" --rpccorsdomain \"*\" --minerthreads \"1\" --mine --maxpeers 0 --password config/password "); + assert.strictEqual(blockchain.generate_basic_command(), "geth --datadir=\"/tmp/embark\" --logfile=\"/tmp/embark.log\" --port 30303 --rpc --rpcport 8101 --networkid "+blockchainConfig.networkId+" --rpccorsdomain \"*\" --minerthreads \"1\" --mine --genesis=\"config/genesis.json\" --maxpeers 4 --password config/password "); }); }); diff --git a/test/config.blockchain.js b/test/config.blockchain.js index 80509835..fa86e16e 100644 --- a/test/config.blockchain.js +++ b/test/config.blockchain.js @@ -41,6 +41,7 @@ describe('embark.config.blockchain', function() { rpc_whitelist: "*", network_id: 0, minerthreads: 1, + genesis_block: 'config/genesis.json', datadir: '/tmp/embark', mine_when_needed: true, gas_limit: 123, @@ -63,8 +64,10 @@ describe('embark.config.blockchain', function() { gasPrice: 100, rpcWhitelist: "*", minerthreads: 1, + genesisBlock: 'config/genesis.json', datadir: '/tmp/embark', networkId: 0, + maxPeers: 4, port: "30303", console_toggle: false, mine_when_needed: true, @@ -103,8 +106,10 @@ describe('embark.config.blockchain', function() { gasPrice: 10000000000000, rpcWhitelist: "*", minerthreads: 1, + genesisBlock: undefined, datadir: '/tmp/embark', networkId: 0, + maxPeers: 4, port: "30303", console_toggle: false, mine_when_needed: true, @@ -122,4 +127,3 @@ describe('embark.config.blockchain', function() { }); }); - diff --git a/test/support/blockchain.yml b/test/support/blockchain.yml index e1a4936b..3bfb3fd2 100644 --- a/test/support/blockchain.yml +++ b/test/support/blockchain.yml @@ -3,6 +3,7 @@ development: rpc_port: 8101 rpc_whitelist: "*" minerthreads: 1 + genesis_block: config/genesis.json datadir: /tmp/embark mine_when_needed: true gas_limit: 500000 @@ -20,4 +21,4 @@ staging: console: true account: init: false - address: + address: