This document is a scrapbook for the Infineon Blockchain Starter Kit road test.
1 (YES) see if it is possible to run a blockchain ledger on a Raspberry Pi
Before applying (check this thread that shows several people moving from not interested to interested) we floated some balloons on how to use the kit to show a real world case, and how we could learn from it.
The project will try using hyperledger and blockchain to create a record of trusted transactions.
| install hyperledger burrow https://wiki.hyperledger.org/display/burrow |
|---|
|
dependency for docker: python 3.6. I don't know if docker is needed , because you can also install from binary and source...
Not needed with latest raspbian. It has version 3.7.
Install python 3.6
https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f |
|
dependency for hyperledger
Install docker and docker-compose
Not needed if build from source.
https://withblue.ink/2019/07/13/yes-you-can-run-docker-on-raspbian.html
docker-compose --version |
|
If Java is a prereq (yes for the SDK, no for Burrow, I believe):
sudo apt-get install -y openjdk-11-jdk |
|
If building from source
needed if build from source.
sudo apt install git
get go https://golang.org/doc/install
nano ~/.bashrc
#20200203 jc added $GOPATH export GOPATH=$HOME/go source ~/.bashrc |
|
For deploying contracts you will need a local installation of Solidity
https://solidity.readthedocs.io/en/v0.6.2/installing-solidity.html
failed with ubuntu and docker image
snap: install of snap worked but then the instal of solc not sudo apt-get install snap Ah, needs snapd:
sudo apt-get install snapd sudo snap install solc
2020-02-03T19:44:25+01:00 INFO Waiting for restart... solc v0.5.2 from Ethereum Build Automation (builds-c) installed
There's an error message. pi@raspberrypi:~ $ snap run solc
ERROR: ld.so: object '/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
solc, the Solidity commandline compiler.
I may have a different version than latest raspberry now because I ran sudo raspi-update, as advised by
sudo mv /etc/ld.so.preload /etc/ld.so.preloadbak |
| Now Burrow |
|
from source: https://github.com/hyperledger/burrow/tree/master/docs#source
go get github.com/hyperledger/burrow cd $GOPATH/src/github.com/hyperledger/burrow make build To install in ~/go/bin:
make install
Yay
pi@raspberrypi:~/go/bin $ ./burrow --version
0.29.7+commit.v0.29.7-2-gbfa9180e+2020-02-03 |
|
Start a session; for test only
The genesys is lost after doing this , so you can't restart burrow. Delete the .burrow subfolder for a fresh start
pi@raspberrypi:~/go/bin $ ./burrow spec -v1 | ./burrow configure -s- | ./burrow start -c-
Sourcing config from first of: Config from STDIN then defaults
Sourcing config from Config from STDIN
Using validator address: 13B9648F4115CBB6E8671AD12012877952B5A995
{"caller":"blockchain.go:55","database_key":"426C6F636B636861696E5374617465","height":0,"log_channel":"Info","message":"Trying to load blockchain state from database","run_id":"1eedf0c6-46c5-11ea-8697-79aff69a1094","scope":"LoadOrNewBlockchain","time":"2020-02-03T20:38:23.038665957Z"}
{"caller":"blockchain.go:76","height":0,"log_channel":"Info","message":"No existing blockchain state found in database, making new blockchain","run_id":"1eedf0c6-46c5-11ea-8697-79aff69a1094","scope":"LoadOrNewBlockchain","time":"2020-02-03T20:38:23.039876582Z"}
{"caller":"kernel.go:125","height":0,"log_channel":"Info","message":"Creating new application state from genesis","run_id":"1eedf0c6-46c5-11ea-8697-79aff69a1094","scope":"NewKernel()","time":"2020-02-03T20:38:23.042889707Z"}
{"caller":"kernel.go:136","height":0,"log_channel":"Info","message":"State loading successful","run_id":"1eedf0c6-46c5-11ea-8697-79aff69a1094","scope":"NewKernel()","time":"2020-02-03T20:38:23.046791685Z"}
{"caller":"service.go:138","component":"tendermint","height":0,"impl":"multiAppConn","log_channel":"Info","message":"Starting multiAppConn","module":"proxy","run_id":"1eedf0c6-46c5-11ea-8697-79aff69a1094","scope":"tendermint.NewNode","time":"2020-02-03T20:38:23.26226321Z"}
|
|
A test:
pi@raspberrypi:~/go/bin $ ./burrow accounts Account: 0000000000000000000000000000000000000000 Sequence: 0 Account: 13B9648F4115CBB6E8671AD12012877952B5A995 Sequence: 0
A reusable (not tested in any way for safety!!!) run seed cd ~/go/bin
Creating a reusable Genesis config file ./burrow spec -v1 | ./burrow configure -s- > startup.cfg
Running and rerunning that burrow , restoring the database: cat startup.cfg | ./burrow start -c-
If you'd rather want to run that as a background process: cat startup.cfg | ./burrow start -c- > ./burrow.log &
You can then check the log by executing tail -f ./burrow.log
Get info, from browser (replace with your Pi's IP). If you use chrome, install JSON viewer plugin. FF has a default viewer. http://192.168.1.10:26658
or from the linux prompt curl localhost:26658/status
Web3: Ethereum interface http://192.168.1.10:26660/ |
|
Tutorial: https://hyperledger.github.io/burrow/#/
Prereq: JSON processor: sudo apt-get install jq
When doing the Bonding example, check the errata in https://github.com/hyperledger/burrow/issues/1316 instead of burrow tx --config burrow001.toml formulate bond --amount 10000 | burrow tx commit
do this: burrow tx --config burrow001.toml formulate bond --amount 10000 > tx.json burrow tx --config burrow001.toml commit --file tx.json |
|
Trying to link 2, with a seeds node: https://github.com/silasdavis/burrow/blob/develop/docs/tutorials/6-seed-nodes.md
todo: show content
Restart with the 3 files after the seed substitution has been done once: killall burrow
rm -rf .burrow_node0 .burrow_node1 .burrow_node2 .burrow_seed_0
OLD_URL=$SEED_URL
burrow start --address=`basename .keys_seed/data/* .json` --config=.burrow_seed.toml > .burrow_seed.log 2>&1 &
SEED_URL=`curl -s 127.0.0.1:10001/network | jq -r '.result.ThisNode | [.ID, .ListenAddress] | join("@") | ascii_downcase'`
sed -i s%${OLD_URL}%${SEED_URL}% .burrow_val0.toml
sed -i s%${OLD_URL}%${SEED_URL}% .burrow_val1.toml
sed -i s%${OLD_URL}%${SEED_URL}% .burrow_val2.toml
burrow start -v=0 --config=.burrow_val0.toml > .burrow_val0.log 2>&1 &
burrow start -v=1 --config=.burrow_val1.toml > .burrow_val1.log 2>&1 &
burrow start -v=2 --config=.burrow_val2.toml > .burrow_val2.log 2>&1 &
curl -s 127.0.0.1:40001/network | jq -r '.result.peers[].node_info.moniker'
curl -s 127.0.0.1:10001/network | jq -r '.result.peers[].node_info.moniker'
curl -s 127.0.0.1:10001/consensus | jq -r '.result.round_state.height'
|
|
2. to see if I can write to my cardreader in linux
Detected when enumerating:
Ubuntu VM on Windows10
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=1.5 MxCh= 0 D: Ver= 1.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=4242 ProdID=e131 Rev=01.02 S: Manufacturer=EHUOYAN.COM S: Product=RfidLoginer C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
[ 1403.513744] usb 2-2: new low-speed USB device number 3 using ohci-pci [ 1403.833455] usb 2-2: New USB device found, idVendor=4242, idProduct=e131, bcdDevice= 1.02 [ 1403.833459] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 1403.833462] usb 2-2: Product: RfidLoginer [ 1403.833465] usb 2-2: Manufacturer: EHUOYAN.COM [ 1403.853390] input: EHUOYAN.COM RfidLoginer as /devices/pci0000:00/0000:00:06.0/usb2/2-2/2-2:1.0/0003:4242:E131.0002/input/input8 [ 1403.911931] hid-generic 0003:4242:E131.0002: input,hidraw1: USB HID v1.01 Keyboard [EHUOYAN.COM RfidLoginer] on usb-0000:00:06.0-2/input0
files generated (but doesn't output anyting) /dev/hidraw1 |
Readers advised by Infineon: https://ccid.apdu.fr/select_readers/?features=contactless
This will need rework because the reader I have will not do in its current form
3 SC/PC setup on Linux
The Infinione examples use a python library based on SC/PC.
This is a set of libraries and a service that support accessing card readers and talking to cards.
I have not been able to run this with a smart RFC card reader yet. It works with the ID card reader for Belgian id cards
Tested on Ubuntu VM on my windows 10 laptop
Software needed:
Instructions: https://github.com/Infineon/BlockchainSecurity2Go-Python-Library
sudo apt-get install swig pip3 install blocksec2go
install PCSC-lite.
service pcscd (start as sudo)
sboxes@osboxes:~/.local/bin$ python3 psycardtest
connecting to Generic Smart Card Reader Interface [Smart Card Reader Interface] sensored
Traceback (most recent call last):
File "psycardtest", line 78, in <module>
cardservice.connection.connect()
File "/home/osboxes/.local/lib/python3.7/site-packages/smartcard/CardConnectionDecorator.py", line 54, in connect
self.component.connect(protocol, mode, disposition)
File "/home/osboxes/.local/lib/python3.7/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 126, in connect
SCardGetErrorMessage(hresult))
smartcard.Exceptions.CardConnectionException: Unable to connect with protocol: T0 or T1. Card is unresponsive.
disconnecting from Generic Smart Card Reader Interface [Smart Card Reader Interface] sensored
disconnecting from Generic Smart Card Reader Interface [Smart Card Reader Interface] sensored
4a. (NO) See if hyperledger fabric can run on a raspberry pi
Prereqs: https://hyperledger-fabric.readthedocs.io/en/release-2.0/prereqs.html
(I had everything from installing Burrow, except the golang version. I had 1.11x and 1.13 or higher is needed
https://gist.github.com/nikhita/432436d570b89cab172dcf2894465753#gistcomment-2350191
nano ~/.profile
# 20200229 jc: set PATH so it includes GO PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
NPM and node.js needed
sudo apt-get install npm
pi@raspberrypi:~/go/bin $ node -v v10.15.2 pi@raspberrypi:~/go/bin $ npm -v 5.8.0
Proceed with Fabric: https://hyperledger-fabric.readthedocs.io/en/release-2.0/getting_started.html
clone the fabric_samples, then follow instructions in the readme https://github.com/hyperledger/fabric-samples
git clone https://github.com/hyperledger/fabric-samples.git
https://medium.com/swlh/hyperledger-chapter-7-installing-hyperledger-fabric-89430e61b7bb
git clone -b master https://github.com/hyperledger/fabric-samples.git
cd fabric-samples
git checkout 1.3.0-rc1
then stuck at the next command because the dowload folder is gone https://github.com/hyperledger/fabric/releases/download/
The best step guide I found is this one:
https://www.joemotacek.com/hyperledger-fabric-v1-0-on-a-raspberry-pi-docker-swarm-part-1/
unfortunately, hyperledger has just sunset their maven repos on nexus, and the scripts depend on them, so stuck. (https://www.joemotacek.com/hyperledger-fabric-v1-0-on-a-raspberry-pi-docker-swarm-part-2/#comment-16765 , under moderation)
4b. (YES) on a ubuntu VM
prereqs: git, wget, docker, docker-compose, go
I followed the instructions for version 2: https://hyperledger-fabric.readthedocs.io/en/release-2.0/getting_started.html
both prereqs and getting started
| raw dump of commands I used. I may clean this up - contains every typo and goof-up |
|---|
1 cd ~
2 pwd
3 set
4 exit
5 pwd
6 sudo -s -u hyperledger
7 su osboxes
8 sudo -s -u hyperledger
9 exit
10 sudo -s -u hyperledger
11 exit
12 set
13 echo $PATH
14 cd ~
15 whoami
16 mkdir huperledger
17 cd hyperledger
18 cd fabric
19 rm -fr huperledger
20 mkdir hyperledger
21 cd hyperledger
22 mkdir fabric
23 cd fabric
24 git clone https://github.com/hyperledger/fabric-samples.git
25 ls
26 cd fabric_samples
27 ls
28 cd fabric-samples
29 git tag
30 git checkout v1.4.1-rc1
31 curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0
32 cd
33 ls
34 cd
35 cd ~/hyperledger
36 ls
37 cd fabric
38 ls
39 rm -fr fabric_samples
40 python~
41 python3
42 sudo apt install -y --no-install-recommends docker-ce cgroupfs-mount
43 apt install -y --no-install-recommends docker-ce cgroupfs-mount
44 sudo apt install -y --no-install-recommends docker-ce cgroupfs-mount
45 sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
46 curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
47 # Add the Docker official repos
48 echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
49 $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
50 # Install Docker
51 # The aufs package, part of the "recommended" packages, won't install on Buster just yet, because of missing pre-compiled kernel modules.
52 # We can work around that issue by using "--no-install-recommends"
53 sudo apt update
54 sudo apt install -y --no-install-recommends docker-ce cgroupfs-mount
55 sudo apt-get remove docker docker-engine docker.io containerd runc
56 sudo apt-get update
57 sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
58 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
59 apt-key fingerprint 0EBFCD88
60 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
61 $(lsb_release -cs) \
62 stable"
63 sudo apt-get update
64 sudo apt-get install docker-ce docker-ce-cli containerd.io
65 docker --version
66 docker-composer --version
67 docker-compose --version
68 sudo systemctl start docker
69 sudo systemctl enable docker
70 sudo usermod -a -G docker hyperledger
71 docker-compose --version
72 sudo apt install docker-compose
73 docker-compose --version
74 go --version
75 whereis go
76 sudo add-apt-repository ppa:longsleep/golang-backports
77 sudo apt update
78 sudo apt install golang-go
79 go
80 whereis go
81 ls
82 cd
83 ls
84 ls -a
85 cd .local
86 lq
87 ls
88 cd ..
89 pwd
90 ls -l
91 nano .profile
92 . .profile
93 echo $GOPATH
94 npm
95 sudo apt install npm
96 node --version
97 nodejs --version
98 pwd
99 ls
100 cd hyperledger
101 ls
102 cd fabric
103 ls
104 cd fabric-samples
105 ls
106 git status
107 cd
108 ls
109 cd hyperledger
110 ls
111 cd fabric
112 ls
113 rm -fr fabric-samples
114 git clone https://github.com/hyperledger/fabric-samples.git
115 cd fabric-samples
116 git tag
117 git checkout v2.0.0-beta
118 ls
119 cd
120 rm -fr fabric-samples
121 curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.0.1 1.4.6 0.4.18
122 sudo curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.0.1 1.4.6 0.4.18
123 sudo groupadd docker
124 sudo usermod -aG docker ${USER}
125 su -s ${USER}
126 echo $USER
127 su -s hyperledger
128 exit
129 sudo -s -u hyperledger
130 exit
131 pwd
132 cd hyperledger
133 ls
134 cd fabric
135 docker run hello-world
136 cd fabric-samples
137 ls
138 curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.0.1 1.4.6 0.4.18
139 ls
140 cd bin
141 ls
142 nano .profile
143 n
144 nano .profile
145 nano ~/.profile
146 . ~/.profile
147 echo $PATH
148 cd /
149 cd fabric-samples/test-network
150 cd hyperledger
151 pwd
152 cd ~/hyperledger
153 cd fabric-samples/test-network
154 cd fabric
155 cd fabric-samples/test-network
156 ./network.sh -h
157 ./network.sh down
158 ./network.sh up
159 docker ps -a
160 ./network.sh createChannel
161 ./network.sh down
162 ./network.sh up createChannel
163 ./network.sh deployCC
164 export PATH=${PWD}/../bin:${PWD}:$PATH
165 export FABRIC_CFG_PATH=$PWD/../config/
166 export CORE_PEER_TLS_ENABLED=true
167 export CORE_PEER_LOCALMSPID="Org1MSP"
168 export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
169 export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
170 export CORE_PEER_ADDRESS=localhost:7051
171 peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
172 export CORE_PEER_TLS_ENABLED=true
173 export CORE_PEER_LOCALMSPID="Org2MSP"
174 export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org1.example.com/tls/ca.crt
175 export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org1.example.com/msp
176 export CORE_PEER_ADDRESS=localhost:9051
177 peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
178 cd organisations
179 ls
180 export CORE_PEER_TLS_ENABLED=true
181 export CORE_PEER_LOCALMSPID="Org2MSP"
182 export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt
183 export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
184 export CORE_PEER_ADDRESS=localhost:9051
185 peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
186 cd organizations
187 ls
188 cd peerOrganizations
189 ls
190 cd org2.example.com
191 cd peers
192 ls
193 cd peer0.org2.example.com
194 ls
195 cd tls
196 ls
197 cd ../../../..
198 cd ../..
199 export CORE_PEER_TLS_ENABLED=true
200 export CORE_PEER_LOCALMSPID="Org2MSP"
201 export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
202 export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
203 export CORE_PEER_ADDRESS=localhost:9051
204 peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
205 hystory > hystory.log
206 history > history.log
|
5: Run your own Ethereum full node on a Pi (4)Requires an SSD card
|
For my own memory: cards/keys with ropsten ether loaded:
| Card | Key |
|---|---|
| 1 | 1 |
| 2 | 1, 2 |