From 634a7bfe1edc5e168df46f1688c7d4c74a1ce569 Mon Sep 17 00:00:00 2001 From: linagee Date: Fri, 24 Jul 2015 18:06:02 -0600 Subject: [PATCH 1/6] Keep looping if address is null This made embark-framework work for me. (More often than not.) --- lib/deploy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From fb8eb8e34c55e5771bde6321f317c187048cc70b Mon Sep 17 00:00:00 2001 From: Joris Bontje Date: Wed, 29 Jul 2015 14:33:19 +0200 Subject: [PATCH 2/6] ensure datadir exists, bypassing the interactive liabilities prompt --- lib/blockchain.js | 10 +++++++++- package.json | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index d089ae1b..12e4c548 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -1,3 +1,4 @@ +var mkdirp = require('mkdirp'); Blockchain = function(blockchainConfig) { this.config = blockchainConfig; @@ -73,6 +74,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 +105,3 @@ Blockchain.prototype.startChain = function(use_tmp) { } module.exports = Blockchain - diff --git a/package.json b/package.json index b3c5054e..b3e436af 100644 --- a/package.json +++ b/package.json @@ -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", From f1a02711bd188a510074cc519fbb342c5a9150e0 Mon Sep 17 00:00:00 2001 From: Joris Bontje Date: Wed, 29 Jul 2015 15:49:02 +0200 Subject: [PATCH 3/6] make genesis block configurable. fixes #41 --- .gitignore | 1 + boilerplate/config/blockchain.yml | 5 +++-- boilerplate/config/genesis.json | 12 ++++++++++++ demo/config/blockchain.yml | 5 +++-- demo/config/genesis.json | 12 ++++++++++++ demo_meteor/config/blockchain.yml | 3 ++- demo_meteor/config/genesis.json | 12 ++++++++++++ lib/blockchain.js | 4 +++- lib/config/blockchain.js | 2 +- test/blockchain.js | 2 +- test/config.blockchain.js | 4 +++- test/support/blockchain.yml | 3 ++- 12 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 boilerplate/config/genesis.json create mode 100644 demo/config/genesis.json create mode 100644 demo_meteor/config/genesis.json 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/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index cf9f329a..0457f510 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/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,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/boilerplate/config/genesis.json b/boilerplate/config/genesis.json new file mode 100644 index 00000000..9f60d776 --- /dev/null +++ b/boilerplate/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/demo/config/blockchain.yml b/demo/config/blockchain.yml index cf9f329a..0457f510 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.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.json b/demo/config/genesis.json new file mode 100644 index 00000000..9f60d776 --- /dev/null +++ b/demo/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/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..a93d00ff 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -25,6 +25,9 @@ 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 "; @@ -96,4 +99,3 @@ Blockchain.prototype.startChain = function(use_tmp) { } module.exports = Blockchain - diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index ca2e0f08..ec20cee6 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -38,6 +38,7 @@ 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, port: config.port || "30303", @@ -50,4 +51,3 @@ BlockchainConfig.prototype.config = function(env) { }; module.exports = BlockchainConfig; - diff --git a/test/blockchain.js b/test/blockchain.js index 4f94ca82..527ccf71 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 0 --password config/password "); }); }); diff --git a/test/config.blockchain.js b/test/config.blockchain.js index 80509835..7930ce67 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,6 +64,7 @@ describe('embark.config.blockchain', function() { gasPrice: 100, rpcWhitelist: "*", minerthreads: 1, + genesisBlock: 'config/genesis.json', datadir: '/tmp/embark', networkId: 0, port: "30303", @@ -103,6 +105,7 @@ describe('embark.config.blockchain', function() { gasPrice: 10000000000000, rpcWhitelist: "*", minerthreads: 1, + genesisBlock: undefined, datadir: '/tmp/embark', networkId: 0, port: "30303", @@ -122,4 +125,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: From 6ff72432d6a21173bd290715038e3a1e88bbe777 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 29 Jul 2015 21:40:49 -0400 Subject: [PATCH 4/6] make maxpeers configurable --- boilerplate/config/blockchain.yml | 3 +++ lib/blockchain.js | 2 +- lib/config/blockchain.js | 1 + test/blockchain.js | 2 +- test/config.blockchain.js | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 0457f510..7efb2258 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -6,6 +6,7 @@ development: genesis_block: config/genesis.json datadir: /tmp/embark mine_when_needed: true + max_peers: 0 gas_limit: 500000 gas_price: 10000000000000 console: false @@ -18,6 +19,7 @@ staging: rpc_whitelist: "*" datadir: default network_id: 0 + max_peers: 4 console: true account: init: false @@ -28,6 +30,7 @@ production: rpc_whitelist: "*" datadir: default network_id: 1 + max_peers: 4 console: true account: init: false diff --git a/lib/blockchain.js b/lib/blockchain.js index 23e46681..3b15b77a 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -31,7 +31,7 @@ Blockchain.prototype.generate_basic_command = function() { } //TODO: this should be configurable - cmd += "--maxpeers 0 "; + cmd += "--maxpeers " + config.maxPeers + " "; if (config.account.password !== void 0) { cmd += "--password " + config.account.password + " "; diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index ec20cee6..935ba130 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -41,6 +41,7 @@ BlockchainConfig.prototype.config = function(env) { 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, diff --git a/test/blockchain.js b/test/blockchain.js index 527ccf71..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 --genesis=\"config/genesis.json\" --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 7930ce67..fa86e16e 100644 --- a/test/config.blockchain.js +++ b/test/config.blockchain.js @@ -67,6 +67,7 @@ describe('embark.config.blockchain', function() { genesisBlock: 'config/genesis.json', datadir: '/tmp/embark', networkId: 0, + maxPeers: 4, port: "30303", console_toggle: false, mine_when_needed: true, @@ -108,6 +109,7 @@ describe('embark.config.blockchain', function() { genesisBlock: undefined, datadir: '/tmp/embark', networkId: 0, + maxPeers: 4, port: "30303", console_toggle: false, mine_when_needed: true, From e35a14ed88a0297f6f2f302a01c9f8c48fef99bb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 29 Jul 2015 22:05:48 -0400 Subject: [PATCH 5/6] move genesis blocks to its own folders --- boilerplate/config/blockchain.yml | 2 +- boilerplate/config/{genesis.json => genesis/dev_genesis.json} | 0 demo/config/blockchain.yml | 2 +- demo/config/{genesis.json => genesis/dev_genesis.json} | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename boilerplate/config/{genesis.json => genesis/dev_genesis.json} (100%) rename demo/config/{genesis.json => genesis/dev_genesis.json} (100%) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 7efb2258..0eafb67b 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -3,7 +3,7 @@ development: rpc_port: 8101 rpc_whitelist: "*" minerthreads: 1 - genesis_block: config/genesis.json + genesis_block: config/genesis/dev_genesis.json datadir: /tmp/embark mine_when_needed: true max_peers: 0 diff --git a/boilerplate/config/genesis.json b/boilerplate/config/genesis/dev_genesis.json similarity index 100% rename from boilerplate/config/genesis.json rename to boilerplate/config/genesis/dev_genesis.json diff --git a/demo/config/blockchain.yml b/demo/config/blockchain.yml index 0457f510..0072c4cb 100644 --- a/demo/config/blockchain.yml +++ b/demo/config/blockchain.yml @@ -3,7 +3,7 @@ development: rpc_port: 8101 rpc_whitelist: "*" minerthreads: 1 - genesis_block: config/genesis.json + genesis_block: config/genesis/dev_genesis.json datadir: /tmp/embark mine_when_needed: true gas_limit: 500000 diff --git a/demo/config/genesis.json b/demo/config/genesis/dev_genesis.json similarity index 100% rename from demo/config/genesis.json rename to demo/config/genesis/dev_genesis.json From 13c749760c8d40773465099e77d8bff91c6a3f90 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 29 Jul 2015 22:09:41 -0400 Subject: [PATCH 6/6] update to 0.7.1 --- bin/embark | 2 +- boilerplate/package.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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/package.json b/package.json index b3e436af..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"