-
Notifications
You must be signed in to change notification settings - Fork 1
2. Ethereum
(documentation in progress)
This page describes the setup of a local blockchain (using Parity client) and the DAISEE application on a Raspberry Pi 3.
An image is available with Parity and Geth clients:
➡ http://ethraspbian.com/downloads/image_2017-04-19-EthRaspbian-parity-1.6.6-lite.zip
(see repository diglos/pi-gen for more informations).
This image is compatible with Rapsberry Pi 2 and 3 and runs Parity Ethereum client as a boot service (full Ethereum node).
After turning on the Raspberry Pi, disable the Parity service for now:
$ sudo systemctl stop parity
$ sudo systemctl disable parity
Removed symlink /etc/systemd/system/multi-user.target.wants/parity.service.
And update/upgrade Raspbian:
$ sudo aptitude update && sudo aptitude upgrade
Parity can be easily configure through a configuration file:
➡ https://github.com/paritytech/parity/wiki/Configuring-Parity#config-file
For testing purposes and due to ressources limitations, a private/local blockchain will be set up with Proof-of-Authority consensus engine, for this version of DAISEE prototype.
[Proof-of-Authority] does not depend on nodes solving arbitrarily difficult mathematical problems, but instead uses a hard-configured set of "authorities" - nodes that are explicitly allowed to create new blocks and secure the blockchain. This makes it easier to maintain a private chain and keep the block issuers accountable.
All steps for setting up a local blockchain with Proof-of-Authority are described here:
➡ Demo PoA tutorial
After following the tutorial, here are the differents files used for one node of the prototype:
- blockchain specifications (demo-spec.json):
{
"name": "DemoPoA",
"engine": {
"authorityRound": {
"params": {
"gasLimitBoundDivisor": "0x400",
"stepDuration": "5",
"validators" : {
"list": [
"0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e",
"0x00Aa39d30F0D20FF03a22cCfc30B7EfbFca597C2",
"0x002e28950558fbede1a9675cb113f0bd20912019"
]
}
}
}
},
"params": {
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x2323"
},
"genesis": {
"seal": {
"authorityRound": {
"step": "0x0",
"signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
},
"difficulty": "0x20000",
"gasLimit": "0x5B8D80"
},
"accounts": {
"0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
"0x0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
"0x0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
"0x0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
"0x004ec07d2329997267Ec62b4166639513386F32E": { "balance": "10000000000000000000000" }
}
}
- config.toml
[parity]
chain = "/home/pi/demo-spec.json"
base_path = "/home/pi/parity/"
[network]
port = 30300
bootnodes = ["enode://ff14ae0a273e08ffbbe20b4b398460eb471e23f1b4301ce46b92a86ad420f67b9b470d097f1939fa7b9b2aae7d24e72cf7c63fe67217bdf3fd6cb60bbb7ecc59@192.168.0.47:30300"]
discovery = false
[rpc]
disable = false
interface = "192.168.0.15"
port = 8545
cors = "*"
apis = ["web3", "eth", "net", "personal", "parity", "parity_set", "traces", "rpc", "parity_accounts"]
[ui]
force = false
disable = false
port = 8180
interface = "192.168.0.15"
path = "/home/pi/parity/signer/"
[dapps]
port = 8088
[account]
password = ["node.pwds"]
[mining]
engine_signer = "0x002e28950558fbede1a9675cb113f0bd20912019"
reseal_on_txs = "none"
- Running Parity
$ parity
- Adding a node
Since the blockchain is private/locale, adding a node can be done with the configuration file in Network part.
[network]
bootnodes = ["enode://ff14ae0a273e08ffbbe20b4b398460eb471e23f1b4301ce46b92a86ad420f67b9b470d097f1939fa7b9b2aae7d24e72cf7c63fe67217bdf3fd6cb60bbb7ecc59@192.168.0.47:30300"]
discovery = false
The Public node Node is displayed on Parity Client launch. It can also be find on Parity UI, in Status tab:
- In the case where a new validator node is added, after modifying lists of validators, the following message may appear during blocks import:
Error: Engine(NotProposer(Mismatch { expected: 00aa39d30f0d20ff03a22ccfc30b7efbfca597c2, found: 00bd138abd70e2f00903268f3db08f2d25677c9e }))
The workaround is to modify the chain specifications to revert to the precedent version, until a new error message.
Exemple:
Only 3 blocks are imported with the last version of chain-specs.json (3 validators). In order to import the next blocks, the last validator is removed from chain specs, and blocks are imported until block #55. After this message, using the last version of chain specs (with the 3 validators) allows to import the full blockchain.
The best solution would be to add the new validator account only after importing the full blockchain on the node.
2 smart-contracts (in Solidity) are used:
-
token.sol
This is the smart-contract described in the tutorial "Create your own crypto-currency".
It allows to create a token, according to the ERC20 Token Standard. -
daisee.sol
The current version allows to :- store energy data on blockchain (consumption and production)
- make transactions between peers
For now, the rules that trigger transactions are not implemented in a smart contract. Note: the smart contract is still under development, the code may change (see Issues).
Several methods exist for deploying and testing a smart contract.
For this wiki, the use of the online compiler and the Parity UI will be described.
The online compiler is available at the following URL: https://ethereum.github.io/browser-solidity