* Removing const keyword from send function definition in comm_session class. * Rearchitecture outgoing messages. * Removed concurrentqueue.h file out of the project. * Updated ReadMe file. * Minor comment reformattings. * Readme update with concurrent queue github link. * Removed should_stop_messaging_threads variable. * Updated ReadMe file * Updated and Changed the formatting of the Blake3 build script in ReadMe. * Resolved review comment. Co-authored-by: Savinda Senevirathne <savindadilsara@gmail.com>
Hot Pocket Consensus Engine
What's here?
In development
A C++ version of hotpocket designed for production envrionments, original prototype here: https://github.com/codetsunami/hotpocket
Libraries
- Crypto - Libsodium https://github.com/jedisct1/libsodium
- Websockets - Server: Websocketd (forked) | Client: Websocat | Pipe: netcat (OpenBSD)
- jsoncons (for JSON and BSON) - https://github.com/danielaparker/jsoncons
- P2P Protocol - https://google.github.io/flatbuffers
- Fuse filesystem - https://github.com/libfuse/libfuse
- Boost - https://www.boost.org
- Reader Writer Queue - https://github.com/cameron314/readerwriterqueue
- Concurrent Queue - https://github.com/cameron314/concurrentqueue
Steps to setup Hot Pocket (For Ubuntu/Debian)
Install CMAKE 3.16
- Download and extract cmake-3.16.0-rc3-Linux-x86_64.tar.gz
- Navigate into the extracted directory in a terminal.
- Run
sudo cp -r bin/* /usr/local/bin/ - Run
sudo cp -r share/* /usr/local/share/
Install Libsodium
Instructions are based on this.
- Download and extract Libsodium 1.0.18 from here.
- Navigate to the extracted libsodium directory in a terminal.
- Run
./configure && make && make check - Run
sudo make install
Install blake3
- Clone blake3 library repository
- Navigate into the directory in a terminal.
cd cto navigate to the C implementation foldergcc -shared -fPIC -O3 -o libblake3.so blake3.c blake3_dispatch.c blake3_portable.c blake3_sse2_x86-64_unix.S blake3_sse41_x86-64_unix.S blake3_avx2_x86-64_unix.S blake3_avx512_x86-64_unix.Ssudo cp blake3.h /usr/local/include/sudo cp libblake3.so /usr/local/lib/
Install Boost
Following Instructions are based on Boost getting started
- Download and extract boost 1.71 package from here.
- Navigate to the extracted boost directory in a terminal.
- Run
./bootstrap.sh - Run
sudo ./b2 install(This will compile and install boost libraries into your/usr/local/lib)
Install jsoncons
- Download and extract jsoncons v0.153.3 source from here.
- Navigate to the extracted directory.
- Run
sudo cp -r include/jsoncons /usr/local/include/ - Run
sudo mkdir -p /usr/local/include/jsoncons_ext/ && sudo cp -r include/jsoncons_ext/bson /usr/local/include/jsoncons_ext/
Install FlatBuffers
Instructions are based on this.
- Clone the git respository into a new directory from here.
- Build with CMake
git clone https://github.com/google/flatbuffers.git
cd flatbuffers
cmake -G "Unix Makefiles"
make
- Run
sudo cp -r include/flatbuffers /usr/local/include/ - Run
sudo snap install flatbuffers --edge
Compiling FlatBuffers message definitions
Example: When you make a change to p2pmsg_content_.fbc defnition file, you need to run this:
flatc -o src/msg/fbuf/ --gen-mutable --cpp src/msg/fbuf/p2pmsg_content.fbs
Install libfuse
sudo apt-get install -y meson ninja-build pkg-config- Download libfuse 3.8 and extract.
mkdir build; cd buildmeson .. && ninjasudo ninja install
Install reader-writer queue
- Download readerwritequeue 1.0.3 and extract.
mkdir build; cd buildcmake ..sudo make install
Install concurrent queue
- Download concurrentqueue 1.0.2 and extract.
- Run
sudo cp concurrentqueue.h /usr/local/include/
Run ldconfig
sudo ldconfig
This will update your linker library cache and avoid potential issues when running your compiled C++ program which links to newly installed libraries.
Build and run Hot Pocket
- Navigate to hotpocket repo root.
- Run
cmake .(You only have to do this once) - Run
make(Hot Pocket binary will be created as./build/hpcore) - Refer to Running Hot Pocket in the Wiki.
Refer to Hot Pocket Wiki for more info.
Code structure
Code is divided into subsystems via namespaces.
conf:: Handles contract configuration. Loads and holds the central configuration object. Used by most of the subsystems.
crypto:: Handles cryptographic activities. Wraps libsodium and offers convenience functions.
sc:: Handles smart contract process execution and managing user/SC I/O and npl I/O. Makes use of usr, p2p and hpfs.
usr:: Handles user connections. Makes use of crypto and comm.
p2p:: Handles peer-to-peer connections and message exchange between nodes. Makes use of crypto and comm.
cons:: Handles consensus and proposal rounds. Makes use of usr, p2p and sc
comm:: Handles generic web sockets communication functionality. Mainly acts as a wrapper for websocketd/websocat.
util:: Contains shared data structures/helper functions used by multiple subsystems.
hpfs:: hpfs state management client helpers.