Ethereum Parity fast sync for Ropsten testnet
Originally published at www.ziggify.com on February 15, 2017.
There appears to be a bug with Geth syncing with Ropsten testnet on some systems. This was the case with attempting to sync the full blockchain and with the –fast flag (including using -cache=512, etc) and despite having a high powered computer with a SSD .
After trying various workarounds for several days and getting advice on the Geth Gitter channel, I ended up swapping over to Parity for the node and Geth for the JS Console.
I wish I had done it sooner. Details on the the Parity Wiki make this extremely quick and easy to set up (15 mins) and it also requires far less disk space. There is also help available on the Parity Gitter channel.
$ bash <(curl https://get.parity.io -Lk)
$ parity --warp --chain ropsten
or for the live env
$ parity --warp
Point your browser to http://localhost:8080/ and work through the steps.
Parity Ethereum client console using web3
Ethereum has the web3 Javascript API for interacting with an Ethereum client. You can install node/NPM and use its console to interact with the Parity Ethereum client using web3. To use the command line, install Node.js / npm and then use it to install web3 library:
$ sudo apt-get install nodejs $ npm install web3$ node
> Web3 = require("web3")
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
After this point, you’ll be able to use the web3 API from with this environment, e.g.:
> web3.eth.blockNumber 743397
Exit that and create a new file called parityNode.js with the following:
#!/usr/bin/node
repl = require("repl");
Web3 = require("web3");
context = repl.start("$ ").context;
context.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
You can then start node.js using that script and access Parity via web3 immediately:
$ chomd 744 parityNode.js
$ ./parityNode.js
> web3.eth.blockNumber
743397
If you want to run an external javascript file, you will need to start node.js manually and then run the following (replacing ‘./EthereumJS/ensutils.js’ with your file):
> Web3 = require("web3");
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
> var vm = require("vm");
> var fs = require("fs");
> var data = fs.readFileSync("./EthereumJS/ensutils.js");
> vm.runInThisContext(data);
Then in your node.js (stared using parityNode.js from above):
> web3.personal.listAccounts
Parity Node using Geth Javascript Console
Probably the best configuration option until either Parity create its own console ethcore/parity#4143 or Geth resolves its fast sync would be to use Parity for the node and browser integration and Geth for the Javascript Console. This option will also make it easier to follow more tutorials as a lot of them tend to be written for the Geth command line.
Start Parity with the -geth option:
$ parity --geth --chain ropsten
Then in a new terminal start geth console in attach mode:
$ geth attach
Welcome to the Geth JavaScript console!
instance: Parity//v1.5.2-beta-948a538-20170208/x86_64-linux-gnu/rustc1.15.0
coinbase: 0xfa97ba626a1a257620a50c72ed30e2e2738c8554
at block: 538771 (Wed, 15 Feb 2017 12:58:21 GMT)
modules: eth:1.0 net:1.0 parity:1.0 parity_accounts:1.0 personal:1.0 rpc:1.0 traces:1.0 web3:1.0> personal.listAccounts
Note, the keys you use will be managed under Parity which currently reside here for the testnet:
~/.local/share/io.parity.ethereum/keys/test
Mining with Parity
Encore’s wiki covers it well. Summary as follows:
$ sudo add-apt-repository ppa:ethereum/ethereum
$ sudo apt-get update
$ sudo apt-get install ethmine
Pass the — author flag to parity so it knows what account to add the ETH to:
parity --geth --chain ropsten --author 0xda9b1a939350dc7198165ff84c43ce77a723ef73
In a new terminal start the miner:
ethminer --opencl-device 0
You wont see any ETH in your account until the DAG has been generated. It took approx a day for me. This post tells you how to get Ether on testnet.
Thanks to Tomasz Drwięga for helping with various questions related to Parity. They also have a gitter channel Parity Gitter channel.
Originally published at www.ziggify.com on February 15, 2017.