Open mhdirkse opened 5 years ago
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
by dirkse
The aim is to learn how to program and deploy smart contracts. Creating the relevant contracts for Alexandria is not part of this user story.
I needed the Golang SDK. I did the instructions given in: https://sawtooth.hyperledger.org/docs/core/nightly/master/app_developers_guide/go_sdk_import.html
The last command, "go generate" required a lot of dependencies before it worked. I am not sure whether I have all of them, but here are some:
C++ installation of Google Protocol Buffers: https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
Python libraries: https://grpc.io/docs/quickstart/python.html
Installing Go support for protocol buffers: https://github.com/golang/protobuf/blob/master/README.md
Installing GO mocking framework: https://github.com/golang/mock
Installing GO interface for ZMQ 4: https://github.com/pebbe/zmq4
Install UUID package for Go: https://github.com/satori/go.uuid
As a simple example, I am writing a smart contract that manages a crypto currency. No payment is implemented yet; everyone can create coin out of thin air.
I have coded a transaction processor with unit tests. The unit tests work.
I am coding the client now. I have the skeleton of a console application. The skeleton support sub-commands and can produce a help screen.
One of the sub-commands is generating keys. To make that possible, I needed a dependency:
go get -u github.com/btcsuite/btcd/btcec
Installed ZMQ on Frodo, according to this link:
martijn@N750WU:~/go/src/github.com/mhdirkse/sawtooth-currency/client$ ./client Client tool for sawtoot-currency blockchain Set environment variable CURRENCY_SAWTOOTH_REST_IP_PORT before use
Subcommands:
addCoin : addCoin
goroutine 1 [running]:
main.runAddCoin(0xc0000b4060, 0x2, 0x2)
/home/martijn/go/src/github.com/mhdirkse/sawtooth-currency/client/client.go:188 +0x12ef
main.handleSubCommand(0x77632f, 0x7, 0x784d9a, 0x35, 0x8adee8, 0xc0000b4060, 0x2, 0x2)
/home/martijn/go/src/github.com/mhdirkse/sawtooth-currency/client/client.go:91 +0x44
main.main()
/home/martijn/go/src/github.com/mhdirkse/sawtooth-currency/client/client.go:62 +0x21c
martijn@N750WU:~/go/src/github.com/mhdirkse/sawtooth-currency/client$ ./client addCoin mdi3.pub mdi3.priv 2
Connecting to http://77.93.70.138:8008/batchesResponse: &{202 Accepted 202 HTTP/1.1 1 1 map[Content-Type:[application/json; charset=utf-8] Content-Length:[187] Date:[Wed, 20 Mar 2019 18:28:32 GMT] Server:[Python/3.5 aiohttp/2.3.2]] 0xc0004a2100 187 [] false false map[] 0xc000446000
Saldo is 2 martijn@N750WU:~/go/src/github.com/mhdirkse/sawtooth-currency/client$
I am reinstalling my development PC. I emptied my disk and I am installing everything anew.
When installing ZMQ, I chose to install version 4.3.1. This should not require libsodium. I had to install package pkg-config to make the installation succeed.
The earlier comments do not make explicit that ZMQ has to be installed explicitly. It is a dependency of pebbe/zmq4.
sudo -H python3 -m pip install grpcio
sudo -H python3 -m pip install grpcio-tools
Very important: sudo apt-get install libssl-dev
When running the Alexandria processor for the first time, I got a version conflict. It said:
mdi@frodo:~/hyperledger-sawtooth/singleNode$ ./processor panic: Failed to create ZMQ context: zmq4 was installed with ZeroMQ version 4.3.1, but the application links with version 4.2.1
goroutine 1 [running]: github.com/hyperledger/sawtooth-sdk-go/processor.(*TransactionProcessor).Start(0xc00009a1e0, 0xc000086cc0, 0x2) /home/martijn/go/src/github.com/hyperledger/sawtooth-sdk-go/processor/processor.go:87 +0x118 main.main() /home/martijn/go/src/gitlab.bbinfra.net/3estack/alexandria/processor/processor.go:21 +0x1f8 mdi@frodo:~/hyperledger-sawtooth/singleNode$
I could not upgrade ZMQ on the Frodo, because apt did not know version 4.3.1 of libzmq3-dev. Therefore I downgraded on my development PC to 4.2.1. ZMQ was built from source code on my development PC. I went to the ~/Downloads/zeromq-4.3.1 directory and did "sudo make uninstall". Then I downloaded a tarball for 4.2.1 and installed it with autogen.sh, configure, etc. I did ldconfig after installing.
I still got the same error. I am investigating further now.
I checked whether the downgrade to ZMQ 4.2.1 on my development PC was successful. It was, as I saw with the following C++ program:
int main() { printf("ZMQ version: %d.%d.%d\n", ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH); }
This code was saved in a file main.cpp. I compiled this C++ code using the following Makefile:
printZmqVersion: main.cpp gcc -lzmq main.cpp
When copy/pasting this, please make the second line start with a TAB character. Then build using the command "make". An executable file a.out results.
I fixed the issue. I made an example GO program that only makes a Context object from pebbe/zmq4. That reproduced the error:
zmq4 was installed with ZeroMQ version 4.3.1, but the application links with version 4.2.1
Then in my pebbe checkout, I checked out a version tagged v1.0.0. That version is a few commits before master.
[AX-4] created by mdi