-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from resilientdb/geo_pbft
Geo pbft and Copyright
- Loading branch information
Showing
217 changed files
with
7,561 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ make( | |
cc_library( | ||
name = "cryptopp_lib", | ||
deps = [ | ||
":cryptopp", | ||
":cryptopp", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
# Next Generation ResilientDB (NexRes): A High-throughput yielding Permissioned Blockchain Fabric. | ||
# ResilientDB: A High-throughput yielding Permissioned Blockchain Fabric. | ||
|
||
Nexres aims at *Making Permissioned Blockchain Systems Fast Again*. Nexres makes *system-centric* design decisions by adopting a *multi-thread architecture* that encompasses *deep-pipelines*. Further, we *separate* the ordering of client transactions from their execution, which allows us to perform *out-of-order processing of messages*. | ||
|
||
ResilientDB aims at *Making Permissioned Blockchain Systems Fast Again*. ResilientDB makes *system-centric* design decisions by adopting a *multi-thread architecture* that encompasses *deep-pipelines*. Further, we *separate* the ordering of client transactions from their execution, which allows us to perform *out-of-order processing of messages*. | ||
|
||
### Release Notes Version alpha of NexRes | ||
1. **PBFT** [Castro and Liskov, 1998] protocol is used to achieve consensus among the replicas. | ||
2. NexRes expects minimum **3f+1** replicas, where **f** is the maximum number of byzantine (or malicious) replicas. | ||
3. NexRes uses coroutine as its network infrastructure. | ||
4. The main implementation of NexRes including the network and pbft protocol are lock free by using boost::lockfreequeue. | ||
5. NexRes designates one of its replicas as the **primary**, which is also responsible for initiating the consensus. | ||
6. To facilitate data storage and persistence, NexRes provides support for an **in-memory key-value store**, Rocksdb and LevelDB and expose SDKs to store key-value pairs. | ||
7. We also provide prometheus metrics to display the performance and latency. | ||
8. We support docker environment with ubuntu for **MacOS M1** and source code for native ubuntu. NexRes can only run on **ubuntu 20.04**. | ||
|
||
## System Design: | ||
|
||
High Level Design: | ||
|
||
## Docs | ||
[NexRes Introduction](https://docs.google.com/presentation/d/1QurZA4w_PTxAtb_5FpuXJhsQVAIA2t5kvx1X2ETIl7w/edit#slide=id.p) | ||
[ResDBServer](https://docs.google.com/presentation/d/1i5sKocV4LQrngwNVLTTLRtshVIKICt3_tqMH4e5QgYQ/edit#slide=id.p) | ||
|
||
[ConsensusService-PBFT](https://docs.google.com/presentation/d/1HjXVlCGbjkSzs6d7o4bT_wT-cllSCx1RkvVUskTaZJA/edit#slide=id.p) | ||
|
||
[Full Design Doc](https://docs.google.com/document/d/1YA-vIMhSUnq6necRPY3t3thh4Zc2OuP9_GUwwuzSo-w/edit#) | ||
|
||
## User Development guide | ||
https://docs.google.com/presentation/d/1YIX6dG6cuc5EhXdytrJXoxMhGLP2BxLCmnVMhiC4WBc/edit#slide=id.p | ||
|
||
--- | ||
|
||
## Steps to Run KVServer | ||
|
||
Install dependences. | ||
|
||
sh INSTALL.sh | ||
sh INSTALL | ||
|
||
|
||
Start local KVServers: | ||
|
@@ -41,7 +40,7 @@ Run tools to get value by key(for example, get the value with key "test"): | |
|
||
You will see this if success: | ||
|
||
client get value = | ||
client get value = xxx | ||
|
||
Run tools to set value by key(for example, set the value with key "test" and value "test_value"): | ||
|
||
|
@@ -51,72 +50,61 @@ You will see this if success: | |
|
||
client set ret = 0 | ||
|
||
## Run on MacOS | ||
## Steps to Run KVServer on Multiple Machines | ||
|
||
Install docker: See more [here](https://docs.docker.com/desktop/mac/apple-silicon/) | ||
We illustrate the steps with an example of running PBFT KVservers on 4 replicas and 2 clients | ||
|
||
    Download the [binary](https://desktop.docker.com/mac/main/arm64/Docker.dmg?utm_source=docker&utm_medium=webreferral&utm_campaign=docs-driven-download-mac-arm64) | ||
First, copy the IP addresses of the machines to ./oracle_script/iplist.txt | ||
|
||
Open your terminal and install requirements: | ||
|
||
softwareupdate --install-rosetta | ||
172.31.14.56 | ||
172.31.5.62 | ||
172.31.8.207 | ||
172.31.12.105 | ||
172.31.3.13 | ||
172.31.7.148 | ||
|
||
Build a docker image if first time and launch the docker image (you can change the name (nexres) as you want): | ||
set the number of client on ./oracle_script/generate_config.sh #L12 | ||
|
||
cd docker | ||
docker build . -f DockerfileForMac -t=nexres | ||
docker run -it --name nexres nexres /bin/bash | ||
exit | ||
|
||
|
||
Once the docker images starts, get your image id: | ||
CLIENT_NUM=2 | ||
|
||
docker ps -a | ||
Build the tools for generating config | ||
|
||
Start the docker images and login (fcbe927b4242 is the image id I got from the last command): | ||
bazel build //tools:certificate_tools | ||
|
||
docker start fcbe927b4242 | ||
docker exec -it fcbe927b4242 /bin/bash | ||
Generate svr_list.txt, cli_list.txt and certificates and then copy them into ./oracle_scripts/pbft/rep_4 (./oracle_scripts/{protocol}/rep_{replica_num}). | ||
|
||
Change to user to ubuntu and clone the repo. **(Please fork your own one)** | ||
cd oracle_script | ||
./generate_config.sh | ||
cp ./iplist.txt ./pbft/rep_4/iplist.txt | ||
cp ./svr_list.txt ./pbft/rep_4/svr_list.txt | ||
cp ./cli_list.txt ./pbft/rep_4/cli_list.txt | ||
cp -r ./cert ./pbft/rep_4/ | ||
|
||
su - ubuntu | ||
git clone https://github.com/resilientdb/resilientdb.git | ||
git checkout -b nexres remotes/origin/nexres | ||
|
||
Run the install script: | ||
Generate configuration and executable file | ||
|
||
cd resilientdb/ | ||
sh INSTALL_MAC.sh | ||
cd pbft/rep_4 | ||
sh ./run_svr.sh | ||
sh ./run_cli.sh | ||
|
||
Start the example server and run the client commands: | ||
In ./oracle_script/pbft/rep_4/killall.sh, substistue the ssh private key file with the private key file for your machines. | ||
|
||
sh example/start_kv_server.sh | ||
bazel build example/kv_server_tools | ||
bazel-bin/example/kv_server_tools example/kv_client_config.config get test | ||
|
||
|
||
|
||
--- | ||
For example, Dakai uses dakai_dev.pem for his machines. Then Dakai replace '.ssh/ssh-2022-03-24.key' with '.ssh/dakai_dev.pem', which has been copied to his host machine in advance. | ||
|
||
Deploy the configuration and executable file to the machines, and run the KVServers. | ||
|
||
./killall.sh | ||
|
||
### Key Parameters of "resdb_config.h" | ||
<pre> | ||
|
||
* max_process_txn Water mark that number of replicas inflight, default = 2048; | ||
* client_batch_num Batch size of the client transactions. Before sending to the primary replica, we will collect client_batch_num of transactions from all the users. default = 100; | ||
* is_enable_checkpoint Enable checkpoint which will create stable checkpoint periodically. | ||
* viewchange_commit_timeout_ms The commitment timeout which will trigger viewchange default = 60s. Only for is_enable_checkpoint is true. | ||
* worker_num The number of worker threads to address the requests, default = 96. | ||
* input_worker_num The number of coroutine workers to handler incomming messages from the network, default = 1. | ||
* output_worker_num The number of coroutine workers to handler outcomming messages to the network, default = 1. | ||
|
||
All the parameters will be migrated into ResConfigData.proto in the future. | ||
</pre> | ||
|
||
### Key Parameters of "ResConfigData.proto" | ||
<pre> | ||
* self_region_id The region id of the replica, default is 0, all the replicas will run in the same region. | ||
* region A list of regions containing all the information of the replicas in different regions. | ||
* enable_viewchange If true, will trigger viewchange check per "viewchange_commit_timeout_ms". | ||
</pre> | ||
Open another terminal to make the clients start working. | ||
|
||
ubuntu@hostmachine:~/nexres$ ./bazel-bin/example/kv_server_tools oracle_script/pbft/rep_4/client.config get key | ||
|
||
Open another terminal to monitor server log. | ||
|
||
ssh -i ~/.ssh/dakai_dev.pem [email protected] | ||
tail -f server1.log | ||
|
||
Restart all KVServers after recording the performance numbers to prevent memory overflow in clients. | ||
|
||
./killall.sh | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_binary( | ||
name = "geo_pbft_server", | ||
srcs = ["geo_pbft_server.cpp"], | ||
deps = [ | ||
":geo_pbft_executor_impl", | ||
"//config:resdb_config_utils", | ||
"//ordering/geo_pbft:consensus_service_geo_pbft", | ||
"//server:resdb_server", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "geo_pbft_executor_impl", | ||
srcs = ["geo_pbft_executor_impl.cpp"], | ||
hdrs = ["geo_pbft_executor_impl.h"], | ||
deps = [ | ||
"//application/geo_pbft/proto:geo_pbft_cc_proto", | ||
"//common:comm", | ||
"//execution:transaction_executor_impl", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "geo_pbft_client", | ||
srcs = ["geo_pbft_client.cpp"], | ||
hdrs = ["geo_pbft_client.h"], | ||
deps = [ | ||
"//application/geo_pbft/proto:geo_pbft_cc_proto", | ||
"//client:resdb_user_client", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "geo_pbft_client_main", | ||
srcs = ["geo_pbft_client_main.cpp"], | ||
deps = [ | ||
":geo_pbft_client", | ||
"//config:resdb_config_utils", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "geo_pbft_server_performance", | ||
srcs = ["geo_pbft_server_performance.cpp"], | ||
deps = [ | ||
":geo_pbft_executor_impl", | ||
"//config:resdb_config_utils", | ||
"//kv_server:kv_server_executor", | ||
"//ordering/geo_pbft:consensus_service_geo_pbft", | ||
"//server:resdb_server", | ||
"//statistic:stats", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "kv_server_performance", | ||
srcs = ["kv_server_performance.cpp"], | ||
deps = [ | ||
"//application/kv_server_executor", | ||
"//application/utils:server_factory", | ||
"//config:resdb_config_utils", | ||
"//ordering/geo_pbft:consensus_service_geo_pbft", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
region : { | ||
replica_info : { | ||
id:1, | ||
ip:"127.0.0.1", | ||
port: 10001, | ||
}, | ||
replica_info : { | ||
id:2, | ||
ip:"127.0.0.1", | ||
port: 10002, | ||
}, | ||
replica_info : { | ||
id:3, | ||
ip:"127.0.0.1", | ||
port: 10003, | ||
}, | ||
replica_info : { | ||
id:4, | ||
ip:"127.0.0.1", | ||
port: 10004, | ||
}, | ||
region_id: 1, | ||
}, | ||
self_region_id:1, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5 127.0.0.1 10005 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2019-2022 ExpoLab, UC Davis | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
#include "application/geo_pbft/geo_pbft_client.h" | ||
|
||
#include "application/geo_pbft/proto/geo_pbft.pb.h" | ||
|
||
namespace resdb { | ||
|
||
GeoPBFTClient::GeoPBFTClient(const ResDBConfig& config) | ||
: ResDBUserClient(config) {} | ||
|
||
int GeoPBFTClient::Set(const std::string& key, const std::string& data) { | ||
KVRequest request; | ||
request.set_cmd(KVRequest::SET); | ||
request.set_key(key); | ||
request.set_value(data); | ||
return SendRequest(request); | ||
} | ||
|
||
} // namespace resdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2019-2022 ExpoLab, UC Davis | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "client/resdb_user_client.h" | ||
|
||
namespace resdb { | ||
|
||
class GeoPBFTClient : public ResDBUserClient { | ||
public: | ||
GeoPBFTClient(const ResDBConfig& config); | ||
int Set(const std::string& key, const std::string& data); | ||
}; | ||
|
||
} // namespace resdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
13 127.0.0.1 10013 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
14 127.0.0.1 10014 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
15 127.0.0.1 10015 |
Oops, something went wrong.