You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@resilientdb.apache.org by da...@apache.org on 2025/08/24 19:50:47 UTC

(incubator-resilientdb) 01/01: first commit for ari

This is an automated email from the ASF dual-hosted git repository.

dakaikang pushed a commit to branch ari
in repository https://gitbox.apache.org/repos/asf/incubator-resilientdb.git

commit 017890b48bd14110e0b6271cd22b936b9ef69ae9
Author: DakaiKang <49...@qq.com>
AuthorDate: Sun Aug 24 19:50:32 2025 +0000

    first commit for ari
---
 .github/workflows/build-push.yml                   |   45 -
 .gitignore                                         |    4 +-
 CHANGELOG.md                                       |  129 --
 INSTALL.sh                                         |    2 +
 MODULE.bazel                                       |    6 +
 MODULE.bazel.lock                                  | 1632 ++++++++++++++++++++
 README.md                                          |  336 +---
 benchmark/protocols/hs/kv_server_performance.cpp   |    2 +-
 benchmark/protocols/hs1/BUILD                      |   16 +
 .../{hs => hs1}/kv_server_performance.cpp          |    8 +-
 benchmark/protocols/hs2/BUILD                      |   16 +
 .../{hs => hs2}/kv_server_performance.cpp          |    8 +-
 benchmark/protocols/slot_hs1/BUILD                 |   16 +
 .../{hs => slot_hs1}/kv_server_performance.cpp     |    8 +-
 benchmark/protocols/zzy/BUILD                      |   16 +
 .../{hs => zzy}/kv_server_performance.cpp          |   13 +-
 common/crypto/hash.cpp                             |    2 +-
 common/crypto/hash.h                               |    2 +-
 common/crypto/hash_test.cpp                        |    2 +-
 common/crypto/key_generator.cpp                    |    2 +-
 common/crypto/key_generator.h                      |    2 +-
 common/crypto/mock_signature_verifier.h            |    2 +-
 common/crypto/signature_utils.cpp                  |    2 +-
 common/crypto/signature_utils.h                    |    2 +-
 common/crypto/signature_verifier.cpp               |    2 +-
 common/crypto/signature_verifier.h                 |    2 +-
 common/crypto/signature_verifier_interface.cpp     |    2 +-
 common/crypto/signature_verifier_interface.h       |    2 +-
 common/crypto/signature_verifier_test.cpp          |    2 +-
 common/test/json_test.cpp                          |    2 +-
 common/test/test_macros.h                          |    2 +-
 common/utils/utils.cpp                             |    2 +-
 common/utils/utils.h                               |    2 +-
 executor/common/BUILD                              |   25 +
 executor/common/tpcc_executor.cpp                  |  961 ++++++++++++
 executor/common/tpcc_executor.h                    |   56 +
 executor/common/transaction_manager.cpp            |   29 +-
 executor/common/transaction_manager.h              |    6 +
 hotstuff1-extended-version.pdf                     |  Bin 0 -> 802950 bytes
 platform/common/queue/lock_free_queue.h            |    4 +-
 platform/config/resdb_config.cpp                   |   64 +
 platform/config/resdb_config.h                     |   36 +-
 .../consensus/execution/transaction_executor.cpp   |   20 +-
 .../consensus/execution/transaction_executor.h     |    2 +-
 .../ordering/common/algorithm/protocol_base.cpp    |   24 +
 .../ordering/common/algorithm/protocol_base.h      |   17 +
 platform/consensus/ordering/common/framework/BUILD |   20 +
 .../ordering/common/framework/consensus.cpp        |   17 +-
 .../ordering/common/framework/consensus.h          |    3 +-
 .../common/framework/performance_manager.cpp       |   89 +-
 .../common/framework/performance_manager.h         |   38 +-
 .../ordering/common/framework/response_manager.cpp |    2 +-
 .../ordering/common/framework/response_manager.h   |    2 +-
 .../consensus/ordering/common/framework/tpcc.cpp   |  184 +++
 .../consensus/ordering/common/framework/tpcc.h     |  104 ++
 .../common/framework/transaction_utils.cpp         |    2 +-
 .../ordering/common/framework/transaction_utils.h  |    3 +-
 platform/consensus/ordering/hs/algorithm/BUILD     |   15 +-
 platform/consensus/ordering/hs/algorithm/hs.cpp    |   76 +-
 platform/consensus/ordering/hs/algorithm/hs.h      |   14 +-
 .../ordering/hs/algorithm/proposal_manager.cpp     |   45 +-
 .../ordering/hs/algorithm/proposal_manager.h       |   12 +-
 platform/consensus/ordering/hs/framework/BUILD     |   10 +-
 .../consensus/ordering/hs/framework/consensus.cpp  |   13 +-
 .../consensus/ordering/hs/framework/consensus.h    |    7 +-
 .../ordering/hs/framework/performance_manager.cpp  |  132 ++
 .../ordering/hs/framework/performance_manager.h    |   28 +-
 .../consensus/ordering/hs/proto/proposal.proto     |    2 +
 platform/consensus/ordering/hs1/algorithm/BUILD    |   30 +
 platform/consensus/ordering/hs1/algorithm/hs1.cpp  |  253 +++
 .../{hs/algorithm/hs.h => hs1/algorithm/hs1.h}     |   25 +-
 .../{hs => hs1}/algorithm/proposal_manager.cpp     |  103 +-
 .../{hs => hs1}/algorithm/proposal_manager.h       |   20 +-
 .../consensus/ordering/{hs => hs1}/framework/BUILD |   12 +-
 .../ordering/{hs => hs1}/framework/consensus.cpp   |   27 +-
 .../ordering/{hs => hs1}/framework/consensus.h     |   13 +-
 .../ordering/hs1/framework/performance_manager.cpp |  183 +++
 .../ordering/hs1/framework/performance_manager.h   |   33 +-
 platform/consensus/ordering/hs1/proto/BUILD        |   16 +
 .../ordering/{hs => hs1}/proto/proposal.proto      |    5 +-
 platform/consensus/ordering/hs2/algorithm/BUILD    |   30 +
 .../{hs/algorithm/hs.cpp => hs2/algorithm/hs2.cpp} |  107 +-
 .../{hs/algorithm/hs.h => hs2/algorithm/hs2.h}     |   25 +-
 .../{hs => hs2}/algorithm/proposal_manager.cpp     |   55 +-
 .../{hs => hs2}/algorithm/proposal_manager.h       |   18 +-
 .../consensus/ordering/{hs => hs2}/framework/BUILD |   11 +-
 .../ordering/{hs => hs2}/framework/consensus.cpp   |   24 +-
 .../ordering/{hs => hs2}/framework/consensus.h     |   13 +-
 .../ordering/hs2/framework/performance_manager.cpp |  120 ++
 .../ordering/hs2/framework/performance_manager.h   |   26 +-
 platform/consensus/ordering/hs2/proto/BUILD        |   16 +
 .../ordering/{hs => hs2}/proto/proposal.proto      |    4 +-
 platform/consensus/ordering/pbft/commitment.cpp    |    6 +
 .../ordering/pbft/performance_manager.cpp          |   30 +-
 .../consensus/ordering/pbft/performance_manager.h  |    2 +-
 .../consensus/ordering/pbft/viewchange_manager.cpp |   10 +-
 .../consensus/ordering/slot_hs1/algorithm/BUILD    |   28 +
 .../slot_hs1/algorithm/proposal_manager.cpp        |  221 +++
 .../{hs => slot_hs1}/algorithm/proposal_manager.h  |   23 +-
 .../ordering/slot_hs1/algorithm/slot_hs1.cpp       |  295 ++++
 .../hs.h => slot_hs1/algorithm/slot_hs1.h}         |   32 +-
 .../ordering/{hs => slot_hs1}/framework/BUILD      |   12 +-
 .../{hs => slot_hs1}/framework/consensus.cpp       |   32 +-
 .../{hs => slot_hs1}/framework/consensus.h         |   15 +-
 .../slot_hs1/framework/performance_manager.cpp     |  203 +++
 .../framework/performance_manager.h}               |   42 +-
 platform/consensus/ordering/slot_hs1/proto/BUILD   |   16 +
 .../ordering/{hs => slot_hs1}/proto/proposal.proto |   13 +-
 platform/consensus/ordering/zzy/algorithm/BUILD    |   16 +
 platform/consensus/ordering/zzy/algorithm/zzy.cpp  |  206 +++
 platform/consensus/ordering/zzy/algorithm/zzy.h    |   61 +
 platform/consensus/ordering/zzy/framework/BUILD    |   27 +
 .../consensus/ordering/zzy/framework/consensus.cpp |  186 +++
 .../ordering/{hs => zzy}/framework/consensus.h     |   28 +-
 .../ordering/zzy/framework/consensus_test.cpp      |  179 +++
 .../ordering/zzy/framework/performance_manager.cpp |  236 +++
 .../ordering/zzy/framework/performance_manager.h   |   75 +
 platform/consensus/ordering/zzy/proto/BUILD        |   18 +
 .../consensus/ordering/zzy/proto/proposal.proto    |   47 +
 platform/networkstrate/BUILD                       |    3 +
 platform/networkstrate/async_replica_client.cpp    |    5 +
 platform/networkstrate/consensus_manager.cpp       |    1 +
 platform/networkstrate/replica_communicator.cpp    |    7 +-
 platform/networkstrate/service_network.cpp         |    2 +-
 platform/proto/BUILD                               |   15 +
 platform/proto/replica_info.proto                  |   14 +-
 platform/proto/resdb.proto                         |    8 +
 platform/proto/tpcc.proto                          |   77 +
 platform/statistic/stats.cpp                       |   95 +-
 platform/statistic/stats.h                         |    9 +
 resilientdb_tpcc.db                                |  Bin 0 -> 90861568 bytes
 scripts/deploy/config/hs.config                    |   13 +-
 scripts/deploy/config/hs1.config                   |   16 +
 scripts/deploy/config/hs2.config                   |   15 +
 scripts/deploy/config/key_example.conf             |    2 +-
 scripts/deploy/config/kv_performance_server.conf   |   77 +-
 scripts/deploy/config/slot_hs1.config              |   16 +
 scripts/deploy/config/template.config              |    4 +-
 scripts/deploy/config/zzy.config                   |   18 +
 scripts/deploy/performance/calculate_result.py     |  106 +-
 scripts/deploy/performance/hs1_performance.sh      |    4 +
 scripts/deploy/performance/hs2_performance.sh      |    4 +
 scripts/deploy/performance/hs_performance.sh       |    1 +
 scripts/deploy/performance/run_performance.sh      |   37 +-
 scripts/deploy/performance/slot_hs1_performance.sh |    4 +
 scripts/deploy/performance/zzy_performance.sh      |    4 +
 scripts/deploy/poe_performance.sh                  |    4 +-
 scripts/deploy/script/copy_local_db.sh             |   26 +
 scripts/deploy/script/copy_tpcc_db_file.sh         |   37 +
 scripts/deploy/script/deploy.sh                    |   28 +-
 scripts/null                                       |    2 +-
 service/tools/utxo/wallet_tool/cpp/addr_utils.cpp  |    2 +-
 service/tools/utxo/wallet_tool/cpp/addr_utils.h    |    2 +-
 service/tools/utxo/wallet_tool/cpp/key_utils.cpp   |    2 +-
 service/tools/utxo/wallet_tool/cpp/key_utils.h     |    2 +-
 .../utxo/wallet_tool/pybind/wallet_tools_py.cpp    |    2 +-
 tpcc_initialization.cpp                            |  587 +++++++
 157 files changed, 7858 insertions(+), 974 deletions(-)

diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml
index 0a1c9239..e69de29b 100644
--- a/.github/workflows/build-push.yml
+++ b/.github/workflows/build-push.yml
@@ -1,45 +0,0 @@
-name: ci    
-
-on:
-  push:
-    branches:
-      - 'master'
-
-jobs:
-  docker:
-    runs-on: ubuntu-latest
-    steps:
-      -
-        name: Checkout
-        uses: actions/checkout@v3
-      -
-        name: Set up QEMU
-        uses: docker/setup-qemu-action@v3
-      -
-        name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v3
-      -
-        name: Login to Docker Hub
-        uses: docker/login-action@v3
-        with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
-          password: ${{ secrets.DOCKERHUB_TOKEN }}
-      -
-        name: Build and push Dockerfile
-        uses: docker/build-push-action@v5
-        with:
-          file: ./Docker/Dockerfile
-          context: .
-          platforms: linux/amd64
-          push: true
-          tags: expolab/resdb:amd64
-
-      -
-        name: Build and push Dockerfile mac
-        uses: docker/build-push-action@v5
-        with:
-          file: ./Docker/Dockerfile_mac
-          context: .
-          platforms: linux/arm64
-          push: true
-          tags: expolab/resdb:arm64
diff --git a/.gitignore b/.gitignore
index 6f0b3f2b..d6dc6e11 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,6 @@
 deps/*/
 scripts/deploy/config/key.conf
 scripts/deploy/config_out/
-scripts/deploy/result_*
-scripts/deploy/local_ordering_*
-scripts/deploy/final_ordering_*
 deploy/kv_server/output/
 .idea/
 .vscode/
@@ -14,3 +11,4 @@ bazel-*
 venv
 sdk_validator/venv
 __pycache__
+scripts/deploy/result_*_log
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b470773d..e69de29b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,129 +0,0 @@
-# Change Log
-
-### NexRes v1.9.0 ([2023-11-29](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.9.0))
-
-Support Multi-version Key-Value Interface. ([Junchao Chen](https://github.com/cjcchen))
-
-* Get and Set need to provide a version number to fetch the correct version of the data (if exists) or write to the correct version of data (if not overwritten already), respectively.
-* Provide interfaces to obtain historical data with a specific version or a range of versions.
-
-
-### NexRes v1.8.0 ([2023-08-21](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.8.0))
-
-**Implemented Enhancements:** The view-change recovery protocol was extensively expanded to support the following Byzantine failures through primary/leader replacement and replica recovery. ([Dakai Kang](https://github.com/DakaiKang))
-
-* Byzantine primary becomes non-responsive, stopping proposing any new Pre-Prepare messages.
-* Byzantine primary equivocates, proposing two different client requests to two subsets of replicas.
-* Byzantine replicas try to keep some non-faulty replicas in the dark.
-* Byzantine new primary becomes non-responsive, refusing to broadcast New-View messages.
-
-### NexRes v1.7.0 ([2023-08-04](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.7.0))
-
-**Implemented Enhancements:** For each replica local recovery from durable storage upon system restart was added.([Junchao Chen](https://github.com/cjcchen))
-
-
-### NexRes v1.6.0 ([2023-05-30](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.6.0))
-
-**Implemented Enhancements:** Refactoring and enhancement of the codebase to highlight the entire software stack of ResilientDB consisting of the following layers ([Junchao Chen](https://github.com/cjcchen))
-
-* SDK Layer (C++, Python, Go, Solidity)
-* Interface Layer (key-value, smart contract, UTXO)
-* ResilientDB Database Connectivity (RDBC) API
-* Platform Layer (consensus, chain, network, notary)
-* Transaction Layer (execution runtime and in-memory chain state)
-* Storage Layer (chain and chain state durability)
-
-
-### NexRes v1.5.0 ([2023-04-04](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.5.0))
-
-**Implemented Enhancements:** 
-* A complete refactoring of the codebase such that (1) the core engine code is now moved to the platform folder, including the formwork architectures and protocols implementations; (2) the API/interface-related code is moved to the service folder, including UTXO, smart contract, and key-value interface;  (3) the python SDK code is moved to a different repository [here](https://github.com/resilientdb/sdk) ([Junchao Chen](https://github.com/cjcchen)).
-
-### NexRes v1.4.0 ([2023-02-28](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v.1.4.0))
-Major Changes
-* Support of UTXO model and wallet integration: [Detailed Documentation](https://blog.resilientdb.com/2023/02/12/GettingStartedOnUtxo.html) ([Junchao Chen](https://github.com/cjcchen))
-
-
-### NexRes v1.3.0 ([2023-02-22](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.3.0))
-
-**Implemented Enhancements:** 
-* Added Python SDK that supports UTXO-like transactions such as asset creation, transfer, and multi-party validations. ([Arindaam Roy](https://github.com/royari), [Glenn Chen](https://github.com/glenn-chen), and [Julieta Duarte](https://github.com/juduarte00))
-* Added REST CROW endpoints to interface with the on-chain KV service. ([Glenn Chen](https://github.com/glenn-chen) and [Julieta Duarte](https://github.com/juduarte00))
-* Extended KV service range queries. ([Glenn Chen](https://github.com/glenn-chen) and [Julieta Duarte](https://github.com/juduarte00))
-
-**Fixed Bugs:**
-* Fixed KV service queries on all values retrieving empty placeholder values ([Glenn Chen](https://github.com/glenn-chen))
-
-### NexRes v1.2.0 ([2023-01-29](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.2.0))
-
-**Implemented Enhancements:** 
-* Support smart contract compiled from Solidity. ([Junchao Chen](https://github.com/cjcchen)) 
-* Use eEVM as a back-end service to execute the contract functions. ([Junchao Chen](https://github.com/cjcchen))
-
-### NexRes v1.1.0 ([2023-01-03](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.1.0))
-
-**Implemented Enhancements:** 
-
-* Added Geo-Scale Byzantine Fault-tolerant consensus protocol, referred to as GeoBFT. It is designed for excellent scalability by using a topological-aware grouping of replicas in local clusters, giving rise to parallelization of consensus at the local level and by minimizing communication between clusters. ([WayneWang](https://github.com/WayneJa))
-
-ResilientDB: Global Scale Resilient Blockchain Fabric, VLDB 2020
-
-### NexRes v1.0.1 ([2022-10-13](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.0.1))
-
-**Implemented Enhancements:** 
-
-* Add node manager backend for resilientdb.com to launch NexRes locally. ([Vishnu](https://github.com/sheshavpd) and [Junchao Chen](https://github.com/cjcchen))
-
-### NexRes v1.0.0 ([2022-09-30](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.0.0))
-
-**Implemented Enhancements:** 
-
-* Release the next generation of RelisientDB referred to as NexRes. ([Junchao Chen](https://github.com/cjcchen))
-* NexRes supports PBFT as the default core protocol and provides a KV-Server as a service. ([Junchao Chen](https://github.com/cjcchen))
-* NexRes also supports LevelDB and RocksDB as the durable storage layer. ([Junchao Chen](https://github.com/cjcchen))
-* Add SDK endpoints. ([Junchao Chen](https://github.com/cjcchen))
-* Add implementation of Dashboard. ([Jianxio](https://github.com/jyu25utk))
-* Add the recovery protocol and checkpoint on PBFT. ([Junchao Chen](https://github.com/cjcchen) and [Vishnu](https://github.com/sheshavpd))
-
-
-### NexRes v1.0.0-alpha ([2022-09-22](https://github.com/resilientdb/resilientdb/releases/tag/nexres-alpha))
-
-**Implemented Enhancements:** 
-* Release the next generation of RelisientDB, a complete rewrite and re-architecting, referred to as NexRes. ([Junchao Chen](https://github.com/cjcchen))
-* NexRes supports PBFT as the default core protocol and provides a KV-Server as a service. ([Junchao Chen](https://github.com/cjcchen))
-* NexRes also supports LevelDB and RocksDB as the durable storage layer. ([Glenn Chen](https://github.com/glenn-chen), [Julieta Duarte](https://github.com/juduarte00), and [Junchao Chen](https://github.com/cjcchen))
-
-
-### v3.0 ([2021-09-30](https://github.com/resilientdb/resilientdb/releases/tag/v3.0))
-
-**Implemented Enhancements:** 
-* GeoBFT Protocol Added ([Sajjad Rahnama](https://github.com/sajjadrahnama))
-* Work Queue structure changed ([Sajjad Rahnama](https://github.com/sajjadrahnama))
-* Refactoring, and added Statistics and Scripts ([Sajjad Rahnama](https://github.com/sajjadrahnama))
-
-
-### v2.0 ([2020-02-29](https://github.com/resilientdb/resilientdb/releases/tag/v2.0))
-
-**Implemented Enhancements:** 
-* A GUI display for ResilientDB to ease user interaction and analysis. [#9](https://github.com/resilientdb/resilientdb/issues/9) ([Sajjad Rahnama](https://github.com/sajjadrahnama) and [RohanSogani](https://github.com/RohanSogani))
-* Added support for Smart Contracts with a Banking use case. [#7](https://github.com/resilientdb/resilientdb/issues/7) ([Sajjad Rahnama](https://github.com/sajjadrahnama))
-* Monitoring results for visualizing graphs using influxdb. [#8](https://github.com/resilientdb/resilientdb/issues/8) ([Sajjad Rahnama](https://github.com/sajjadrahnama), [Dhruv Krishnan](https://github.com/DhruvKrish) and [Priya Holani](https://github.com/Holani))
-* Added support for SQLite and provided a new representation for in-memory storage. [#6](https://github.com/resilientdb/resilientdb/issues/6) ([Sajjad Rahnama](https://github.com/sajjadrahnama))
-
-**Fixed Bugs:**
-* Bug in the Chain Initialization [#5](https://github.com/resilientdb/resilientdb/issues/5) ([Sajjad Rahnama](https://github.com/sajjadrahnama))
-
-
-### v1.1 ([2019-12-05](https://github.com/resilientdb/resilientdb/releases/tag/v1.1)) 
-
-**Implemented Enhancements:**
-* Defined class to represent ledger. [6b0fdc5](https://github.com/resilientdb/resilientdb/commit/56f500fe5e4749c45f57dc8e62d12bc7a218ce69) ([Suyash Gupta](https://github.com/gupta-suyash))
-
-**Fixed Bugs:**
-* Docker script fails to run for multiple client [#1](https://github.com/resilientdb/resilientdb/issues/1) ([RohanSogani](https://github.com/RohanSogani))	
-
-### v1.0 ([2019-11-24](https://github.com/resilientdb/resilientdb/releases/tag/v1.0)) 
-
-Launched ResilientDB ([Suyash Gupta](https://github.com/gupta-suyash) and [Sajjad Rahnama](https://github.com/sajjadrahnama))
-
-
diff --git a/INSTALL.sh b/INSTALL.sh
index d9079d58..bd3aa9f0 100755
--- a/INSTALL.sh
+++ b/INSTALL.sh
@@ -40,3 +40,5 @@ bazel build @com_github_bazelbuild_buildtools//buildifier:buildifier
 
 sudo apt-get install python3.10-dev -y
 sudo apt-get install python3-dev -y
+
+sudo apt-get install -y libsqlite3-dev
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 00000000..00bb1836
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,6 @@
+###############################################################################
+# Bazel now uses Bzlmod by default to manage external dependencies.
+# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
+#
+# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
+###############################################################################
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
new file mode 100644
index 00000000..11bf37a4
--- /dev/null
+++ b/MODULE.bazel.lock
@@ -0,0 +1,1632 @@
+{
+  "lockFileVersion": 6,
+  "moduleFileHash": "0e3e315145ac7ee7a4e0ac825e1c5e03c068ec1254dd42c3caaecb27e921dc4d",
+  "flags": {
+    "cmdRegistries": [
+      "https://bcr.bazel.build/"
+    ],
+    "cmdModuleOverrides": {},
+    "allowedYankedVersions": [],
+    "envVarAllowedYankedVersions": "",
+    "ignoreDevDependency": false,
+    "directDependenciesMode": "WARNING",
+    "compatibilityMode": "ERROR"
+  },
+  "localOverrideHashes": {
+    "bazel_tools": "1ae69322ac3823527337acf02016e8ee95813d8d356f47060255b8956fa642f0"
+  },
+  "moduleDepGraph": {
+    "<root>": {
+      "name": "",
+      "version": "",
+      "key": "<root>",
+      "repoName": "",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      }
+    },
+    "bazel_tools@_": {
+      "name": "bazel_tools",
+      "version": "",
+      "key": "bazel_tools@_",
+      "repoName": "bazel_tools",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [
+        "@local_config_cc_toolchains//:all",
+        "@local_config_sh//:local_sh_toolchain"
+      ],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@bazel_tools//tools/cpp:cc_configure.bzl",
+          "extensionName": "cc_configure_extension",
+          "usingModule": "bazel_tools@_",
+          "location": {
+            "file": "@@bazel_tools//:MODULE.bazel",
+            "line": 18,
+            "column": 29
+          },
+          "imports": {
+            "local_config_cc": "local_config_cc",
+            "local_config_cc_toolchains": "local_config_cc_toolchains"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@bazel_tools//tools/osx:xcode_configure.bzl",
+          "extensionName": "xcode_configure_extension",
+          "usingModule": "bazel_tools@_",
+          "location": {
+            "file": "@@bazel_tools//:MODULE.bazel",
+            "line": 22,
+            "column": 32
+          },
+          "imports": {
+            "local_config_xcode": "local_config_xcode"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@rules_java//java:extensions.bzl",
+          "extensionName": "toolchains",
+          "usingModule": "bazel_tools@_",
+          "location": {
+            "file": "@@bazel_tools//:MODULE.bazel",
+            "line": 25,
+            "column": 32
+          },
+          "imports": {
+            "local_jdk": "local_jdk",
+            "remote_java_tools": "remote_java_tools",
+            "remote_java_tools_linux": "remote_java_tools_linux",
+            "remote_java_tools_windows": "remote_java_tools_windows",
+            "remote_java_tools_darwin_x86_64": "remote_java_tools_darwin_x86_64",
+            "remote_java_tools_darwin_arm64": "remote_java_tools_darwin_arm64"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@bazel_tools//tools/sh:sh_configure.bzl",
+          "extensionName": "sh_configure_extension",
+          "usingModule": "bazel_tools@_",
+          "location": {
+            "file": "@@bazel_tools//:MODULE.bazel",
+            "line": 36,
+            "column": 39
+          },
+          "imports": {
+            "local_config_sh": "local_config_sh"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@bazel_tools//tools/test:extensions.bzl",
+          "extensionName": "remote_coverage_tools_extension",
+          "usingModule": "bazel_tools@_",
+          "location": {
+            "file": "@@bazel_tools//:MODULE.bazel",
+            "line": 40,
+            "column": 48
+          },
+          "imports": {
+            "remote_coverage_tools": "remote_coverage_tools"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@bazel_tools//tools/android:android_extensions.bzl",
+          "extensionName": "remote_android_tools_extensions",
+          "usingModule": "bazel_tools@_",
+          "location": {
+            "file": "@@bazel_tools//:MODULE.bazel",
+            "line": 43,
+            "column": 42
+          },
+          "imports": {
+            "android_gmaven_r8": "android_gmaven_r8",
+            "android_tools": "android_tools"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@buildozer//:buildozer_binary.bzl",
+          "extensionName": "buildozer_binary",
+          "usingModule": "bazel_tools@_",
+          "location": {
+            "file": "@@bazel_tools//:MODULE.bazel",
+            "line": 47,
+            "column": 33
+          },
+          "imports": {
+            "buildozer_binary": "buildozer_binary"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "rules_cc": "rules_cc@0.0.9",
+        "rules_java": "rules_java@7.4.0",
+        "rules_license": "rules_license@0.0.7",
+        "rules_proto": "rules_proto@5.3.0-21.7",
+        "rules_python": "rules_python@0.22.1",
+        "buildozer": "buildozer@6.4.0.2",
+        "platforms": "platforms@0.0.7",
+        "com_google_protobuf": "protobuf@21.7",
+        "zlib": "zlib@1.3",
+        "build_bazel_apple_support": "apple_support@1.5.0",
+        "local_config_platform": "local_config_platform@_"
+      }
+    },
+    "local_config_platform@_": {
+      "name": "local_config_platform",
+      "version": "",
+      "key": "local_config_platform@_",
+      "repoName": "local_config_platform",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "platforms": "platforms@0.0.7",
+        "bazel_tools": "bazel_tools@_"
+      }
+    },
+    "rules_cc@0.0.9": {
+      "name": "rules_cc",
+      "version": "0.0.9",
+      "key": "rules_cc@0.0.9",
+      "repoName": "rules_cc",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [
+        "@local_config_cc_toolchains//:all"
+      ],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@bazel_tools//tools/cpp:cc_configure.bzl",
+          "extensionName": "cc_configure_extension",
+          "usingModule": "rules_cc@0.0.9",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel",
+            "line": 9,
+            "column": 29
+          },
+          "imports": {
+            "local_config_cc_toolchains": "local_config_cc_toolchains"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "platforms": "platforms@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"
+          ],
+          "integrity": "sha256-IDeHW5pEVtzkp50RKorohbvEqtlo5lh9ym5k86CQDN8=",
+          "strip_prefix": "rules_cc-0.0.9",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/rules_cc/0.0.9/patches/module_dot_bazel_version.patch": "sha256-mM+qzOI0SgAdaJBlWOSMwMPKpaA9b7R37Hj/tp5bb4g="
+          },
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "rules_java@7.4.0": {
+      "name": "rules_java",
+      "version": "7.4.0",
+      "key": "rules_java@7.4.0",
+      "repoName": "rules_java",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [
+        "//toolchains:all",
+        "@local_jdk//:runtime_toolchain_definition",
+        "@local_jdk//:bootstrap_runtime_toolchain_definition",
+        "@remotejdk11_linux_toolchain_config_repo//:all",
+        "@remotejdk11_linux_aarch64_toolchain_config_repo//:all",
+        "@remotejdk11_linux_ppc64le_toolchain_config_repo//:all",
+        "@remotejdk11_linux_s390x_toolchain_config_repo//:all",
+        "@remotejdk11_macos_toolchain_config_repo//:all",
+        "@remotejdk11_macos_aarch64_toolchain_config_repo//:all",
+        "@remotejdk11_win_toolchain_config_repo//:all",
+        "@remotejdk11_win_arm64_toolchain_config_repo//:all",
+        "@remotejdk17_linux_toolchain_config_repo//:all",
+        "@remotejdk17_linux_aarch64_toolchain_config_repo//:all",
+        "@remotejdk17_linux_ppc64le_toolchain_config_repo//:all",
+        "@remotejdk17_linux_s390x_toolchain_config_repo//:all",
+        "@remotejdk17_macos_toolchain_config_repo//:all",
+        "@remotejdk17_macos_aarch64_toolchain_config_repo//:all",
+        "@remotejdk17_win_toolchain_config_repo//:all",
+        "@remotejdk17_win_arm64_toolchain_config_repo//:all",
+        "@remotejdk21_linux_toolchain_config_repo//:all",
+        "@remotejdk21_linux_aarch64_toolchain_config_repo//:all",
+        "@remotejdk21_macos_toolchain_config_repo//:all",
+        "@remotejdk21_macos_aarch64_toolchain_config_repo//:all",
+        "@remotejdk21_win_toolchain_config_repo//:all"
+      ],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@rules_java//java:extensions.bzl",
+          "extensionName": "toolchains",
+          "usingModule": "rules_java@7.4.0",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/rules_java/7.4.0/MODULE.bazel",
+            "line": 19,
+            "column": 27
+          },
+          "imports": {
+            "remote_java_tools": "remote_java_tools",
+            "remote_java_tools_linux": "remote_java_tools_linux",
+            "remote_java_tools_windows": "remote_java_tools_windows",
+            "remote_java_tools_darwin_x86_64": "remote_java_tools_darwin_x86_64",
+            "remote_java_tools_darwin_arm64": "remote_java_tools_darwin_arm64",
+            "local_jdk": "local_jdk",
+            "remotejdk11_linux_toolchain_config_repo": "remotejdk11_linux_toolchain_config_repo",
+            "remotejdk11_linux_aarch64_toolchain_config_repo": "remotejdk11_linux_aarch64_toolchain_config_repo",
+            "remotejdk11_linux_ppc64le_toolchain_config_repo": "remotejdk11_linux_ppc64le_toolchain_config_repo",
+            "remotejdk11_linux_s390x_toolchain_config_repo": "remotejdk11_linux_s390x_toolchain_config_repo",
+            "remotejdk11_macos_toolchain_config_repo": "remotejdk11_macos_toolchain_config_repo",
+            "remotejdk11_macos_aarch64_toolchain_config_repo": "remotejdk11_macos_aarch64_toolchain_config_repo",
+            "remotejdk11_win_toolchain_config_repo": "remotejdk11_win_toolchain_config_repo",
+            "remotejdk11_win_arm64_toolchain_config_repo": "remotejdk11_win_arm64_toolchain_config_repo",
+            "remotejdk17_linux_toolchain_config_repo": "remotejdk17_linux_toolchain_config_repo",
+            "remotejdk17_linux_aarch64_toolchain_config_repo": "remotejdk17_linux_aarch64_toolchain_config_repo",
+            "remotejdk17_linux_ppc64le_toolchain_config_repo": "remotejdk17_linux_ppc64le_toolchain_config_repo",
+            "remotejdk17_linux_s390x_toolchain_config_repo": "remotejdk17_linux_s390x_toolchain_config_repo",
+            "remotejdk17_macos_toolchain_config_repo": "remotejdk17_macos_toolchain_config_repo",
+            "remotejdk17_macos_aarch64_toolchain_config_repo": "remotejdk17_macos_aarch64_toolchain_config_repo",
+            "remotejdk17_win_toolchain_config_repo": "remotejdk17_win_toolchain_config_repo",
+            "remotejdk17_win_arm64_toolchain_config_repo": "remotejdk17_win_arm64_toolchain_config_repo",
+            "remotejdk21_linux_toolchain_config_repo": "remotejdk21_linux_toolchain_config_repo",
+            "remotejdk21_linux_aarch64_toolchain_config_repo": "remotejdk21_linux_aarch64_toolchain_config_repo",
+            "remotejdk21_macos_toolchain_config_repo": "remotejdk21_macos_toolchain_config_repo",
+            "remotejdk21_macos_aarch64_toolchain_config_repo": "remotejdk21_macos_aarch64_toolchain_config_repo",
+            "remotejdk21_win_toolchain_config_repo": "remotejdk21_win_toolchain_config_repo"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "platforms": "platforms@0.0.7",
+        "rules_cc": "rules_cc@0.0.9",
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "rules_proto": "rules_proto@5.3.0-21.7",
+        "rules_license": "rules_license@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/rules_java/releases/download/7.4.0/rules_java-7.4.0.tar.gz"
+          ],
+          "integrity": "sha256-l27wi0nJKXQfIBeQ5Z44B8cq2B9CjIvJU82+/1/tFes=",
+          "strip_prefix": "",
+          "remote_patches": {},
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "rules_license@0.0.7": {
+      "name": "rules_license",
+      "version": "0.0.7",
+      "key": "rules_license@0.0.7",
+      "repoName": "rules_license",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz"
+          ],
+          "integrity": "sha256-RTHezLkTY5ww5cdRKgVNXYdWmNrrddjPkPKEN1/nw2A=",
+          "strip_prefix": "",
+          "remote_patches": {},
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "rules_proto@5.3.0-21.7": {
+      "name": "rules_proto",
+      "version": "5.3.0-21.7",
+      "key": "rules_proto@5.3.0-21.7",
+      "repoName": "rules_proto",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "com_google_protobuf": "protobuf@21.7",
+        "rules_cc": "rules_cc@0.0.9",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz"
+          ],
+          "integrity": "sha256-3D+yBqLLNEG0heseQjFlsjEjWh6psDG0Qzz3vB+kYN0=",
+          "strip_prefix": "rules_proto-5.3.0-21.7",
+          "remote_patches": {},
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "rules_python@0.22.1": {
+      "name": "rules_python",
+      "version": "0.22.1",
+      "key": "rules_python@0.22.1",
+      "repoName": "rules_python",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [
+        "@bazel_tools//tools/python:autodetecting_toolchain"
+      ],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@rules_python//python/extensions/private:internal_deps.bzl",
+          "extensionName": "internal_deps",
+          "usingModule": "rules_python@0.22.1",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel",
+            "line": 14,
+            "column": 30
+          },
+          "imports": {
+            "pypi__build": "pypi__build",
+            "pypi__click": "pypi__click",
+            "pypi__colorama": "pypi__colorama",
+            "pypi__importlib_metadata": "pypi__importlib_metadata",
+            "pypi__installer": "pypi__installer",
+            "pypi__more_itertools": "pypi__more_itertools",
+            "pypi__packaging": "pypi__packaging",
+            "pypi__pep517": "pypi__pep517",
+            "pypi__pip": "pypi__pip",
+            "pypi__pip_tools": "pypi__pip_tools",
+            "pypi__setuptools": "pypi__setuptools",
+            "pypi__tomli": "pypi__tomli",
+            "pypi__wheel": "pypi__wheel",
+            "pypi__zipp": "pypi__zipp",
+            "pypi__coverage_cp310_aarch64-apple-darwin": "pypi__coverage_cp310_aarch64-apple-darwin",
+            "pypi__coverage_cp310_aarch64-unknown-linux-gnu": "pypi__coverage_cp310_aarch64-unknown-linux-gnu",
+            "pypi__coverage_cp310_x86_64-apple-darwin": "pypi__coverage_cp310_x86_64-apple-darwin",
+            "pypi__coverage_cp310_x86_64-unknown-linux-gnu": "pypi__coverage_cp310_x86_64-unknown-linux-gnu",
+            "pypi__coverage_cp311_aarch64-unknown-linux-gnu": "pypi__coverage_cp311_aarch64-unknown-linux-gnu",
+            "pypi__coverage_cp311_x86_64-apple-darwin": "pypi__coverage_cp311_x86_64-apple-darwin",
+            "pypi__coverage_cp311_x86_64-unknown-linux-gnu": "pypi__coverage_cp311_x86_64-unknown-linux-gnu",
+            "pypi__coverage_cp38_aarch64-apple-darwin": "pypi__coverage_cp38_aarch64-apple-darwin",
+            "pypi__coverage_cp38_aarch64-unknown-linux-gnu": "pypi__coverage_cp38_aarch64-unknown-linux-gnu",
+            "pypi__coverage_cp38_x86_64-apple-darwin": "pypi__coverage_cp38_x86_64-apple-darwin",
+            "pypi__coverage_cp38_x86_64-unknown-linux-gnu": "pypi__coverage_cp38_x86_64-unknown-linux-gnu",
+            "pypi__coverage_cp39_aarch64-apple-darwin": "pypi__coverage_cp39_aarch64-apple-darwin",
+            "pypi__coverage_cp39_aarch64-unknown-linux-gnu": "pypi__coverage_cp39_aarch64-unknown-linux-gnu",
+            "pypi__coverage_cp39_x86_64-apple-darwin": "pypi__coverage_cp39_x86_64-apple-darwin",
+            "pypi__coverage_cp39_x86_64-unknown-linux-gnu": "pypi__coverage_cp39_x86_64-unknown-linux-gnu"
+          },
+          "devImports": [],
+          "tags": [
+            {
+              "tagName": "install",
+              "attributeValues": {},
+              "devDependency": false,
+              "location": {
+                "file": "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel",
+                "line": 15,
+                "column": 22
+              }
+            }
+          ],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@rules_python//python/extensions:python.bzl",
+          "extensionName": "python",
+          "usingModule": "rules_python@0.22.1",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel",
+            "line": 50,
+            "column": 23
+          },
+          "imports": {
+            "pythons_hub": "pythons_hub"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "platforms": "platforms@0.0.7",
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "rules_proto": "rules_proto@5.3.0-21.7",
+        "com_google_protobuf": "protobuf@21.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/rules_python/releases/download/0.22.1/rules_python-0.22.1.tar.gz"
+          ],
+          "integrity": "sha256-pWQP3dS+sD6MH95e1xYMC6a9R359BIZhwwwGk2om/WM=",
+          "strip_prefix": "rules_python-0.22.1",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/rules_python/0.22.1/patches/module_dot_bazel_version.patch": "sha256-3+VLDH9gYDzNI4eOW7mABC/LKxh1xqF6NhacLbNTucs="
+          },
+          "remote_patch_strip": 1
+        }
+      }
+    },
+    "buildozer@6.4.0.2": {
+      "name": "buildozer",
+      "version": "6.4.0.2",
+      "key": "buildozer@6.4.0.2",
+      "repoName": "buildozer",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@buildozer//:buildozer_binary.bzl",
+          "extensionName": "buildozer_binary",
+          "usingModule": "buildozer@6.4.0.2",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/buildozer/6.4.0.2/MODULE.bazel",
+            "line": 7,
+            "column": 33
+          },
+          "imports": {
+            "buildozer_binary": "buildozer_binary"
+          },
+          "devImports": [],
+          "tags": [
+            {
+              "tagName": "buildozer",
+              "attributeValues": {
+                "sha256": {
+                  "darwin-amd64": "d29e347ecd6b5673d72cb1a8de05bf1b06178dd229ff5eb67fad5100c840cc8e",
+                  "darwin-arm64": "9b9e71bdbec5e7223871e913b65d12f6d8fa026684daf991f00e52ed36a6978d",
+                  "linux-amd64": "8dfd6345da4e9042daa738d7fdf34f699c5dfce4632f7207956fceedd8494119",
+                  "linux-arm64": "6559558fded658c8fa7432a9d011f7c4dcbac6b738feae73d2d5c352e5f605fa",
+                  "windows-amd64": "e7f05bf847f7c3689dd28926460ce6e1097ae97380ac8e6ae7147b7b706ba19b"
+                },
+                "version": "6.4.0"
+              },
+              "devDependency": false,
+              "location": {
+                "file": "https://bcr.bazel.build/modules/buildozer/6.4.0.2/MODULE.bazel",
+                "line": 8,
+                "column": 27
+              }
+            }
+          ],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/fmeum/buildozer/releases/download/v6.4.0.2/buildozer-v6.4.0.2.tar.gz"
+          ],
+          "integrity": "sha256-k7tFKQMR2AygxpmZfH0yEPnQmF3efFgD9rBPkj+Yz/8=",
+          "strip_prefix": "buildozer-6.4.0.2",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/buildozer/6.4.0.2/patches/module_dot_bazel_version.patch": "sha256-gKANF2HMilj7bWmuXs4lbBIAAansuWC4IhWGB/CerjU="
+          },
+          "remote_patch_strip": 1
+        }
+      }
+    },
+    "platforms@0.0.7": {
+      "name": "platforms",
+      "version": "0.0.7",
+      "key": "platforms@0.0.7",
+      "repoName": "platforms",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "rules_license": "rules_license@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz"
+          ],
+          "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=",
+          "strip_prefix": "",
+          "remote_patches": {},
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "protobuf@21.7": {
+      "name": "protobuf",
+      "version": "21.7",
+      "key": "protobuf@21.7",
+      "repoName": "protobuf",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@rules_jvm_external//:extensions.bzl",
+          "extensionName": "maven",
+          "usingModule": "protobuf@21.7",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel",
+            "line": 22,
+            "column": 22
+          },
+          "imports": {
+            "maven": "maven"
+          },
+          "devImports": [],
+          "tags": [
+            {
+              "tagName": "install",
+              "attributeValues": {
+                "name": "maven",
+                "artifacts": [
+                  "com.google.code.findbugs:jsr305:3.0.2",
+                  "com.google.code.gson:gson:2.8.9",
+                  "com.google.errorprone:error_prone_annotations:2.3.2",
+                  "com.google.j2objc:j2objc-annotations:1.3",
+                  "com.google.guava:guava:31.1-jre",
+                  "com.google.guava:guava-testlib:31.1-jre",
+                  "com.google.truth:truth:1.1.2",
+                  "junit:junit:4.13.2",
+                  "org.mockito:mockito-core:4.3.1"
+                ]
+              },
+              "devDependency": false,
+              "location": {
+                "file": "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel",
+                "line": 24,
+                "column": 14
+              }
+            }
+          ],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "rules_python": "rules_python@0.22.1",
+        "rules_cc": "rules_cc@0.0.9",
+        "rules_proto": "rules_proto@5.3.0-21.7",
+        "rules_java": "rules_java@7.4.0",
+        "rules_pkg": "rules_pkg@0.7.0",
+        "com_google_abseil": "abseil-cpp@20211102.0",
+        "zlib": "zlib@1.3",
+        "upb": "upb@0.0.0-20220923-a547704",
+        "rules_jvm_external": "rules_jvm_external@4.4.2",
+        "com_google_googletest": "googletest@1.11.0",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/protocolbuffers/protobuf/releases/download/v21.7/protobuf-all-21.7.zip"
+          ],
+          "integrity": "sha256-VJOiH17T/FAuZv7GuUScBqVRztYwAvpIkDxA36jeeko=",
+          "strip_prefix": "protobuf-21.7",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/protobuf/21.7/patches/add_module_dot_bazel.patch": "sha256-q3V2+eq0v2XF0z8z+V+QF4cynD6JvHI1y3kI/+rzl5s=",
+            "https://bcr.bazel.build/modules/protobuf/21.7/patches/add_module_dot_bazel_for_examples.patch": "sha256-O7YP6s3lo/1opUiO0jqXYORNHdZ/2q3hjz1QGy8QdIU=",
+            "https://bcr.bazel.build/modules/protobuf/21.7/patches/relative_repo_names.patch": "sha256-RK9RjW8T5UJNG7flIrnFiNE9vKwWB+8uWWtJqXYT0w4=",
+            "https://bcr.bazel.build/modules/protobuf/21.7/patches/add_missing_files.patch": "sha256-Hyne4DG2u5bXcWHNxNMirA2QFAe/2Cl8oMm1XJdkQIY="
+          },
+          "remote_patch_strip": 1
+        }
+      }
+    },
+    "zlib@1.3": {
+      "name": "zlib",
+      "version": "1.3",
+      "key": "zlib@1.3",
+      "repoName": "zlib",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "platforms": "platforms@0.0.7",
+        "rules_cc": "rules_cc@0.0.9",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz"
+          ],
+          "integrity": "sha256-/wukwpIBPbwnUws6geH5qBPNOd4Byl4Pi/NVcC76WT4=",
+          "strip_prefix": "zlib-1.3",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/zlib/1.3/patches/add_build_file.patch": "sha256-Ei+FYaaOo7A3jTKunMEodTI0Uw5NXQyZEcboMC8JskY=",
+            "https://bcr.bazel.build/modules/zlib/1.3/patches/module_dot_bazel.patch": "sha256-fPWLM+2xaF/kuy+kZc1YTfW6hNjrkG400Ho7gckuyJk="
+          },
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "apple_support@1.5.0": {
+      "name": "apple_support",
+      "version": "1.5.0",
+      "key": "apple_support@1.5.0",
+      "repoName": "build_bazel_apple_support",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [
+        "@local_config_apple_cc_toolchains//:all"
+      ],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@build_bazel_apple_support//crosstool:setup.bzl",
+          "extensionName": "apple_cc_configure_extension",
+          "usingModule": "apple_support@1.5.0",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel",
+            "line": 17,
+            "column": 35
+          },
+          "imports": {
+            "local_config_apple_cc": "local_config_apple_cc",
+            "local_config_apple_cc_toolchains": "local_config_apple_cc_toolchains"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "platforms": "platforms@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/apple_support/releases/download/1.5.0/apple_support.1.5.0.tar.gz"
+          ],
+          "integrity": "sha256-miM41vja0yRPgj8txghKA+TQ+7J8qJLclw5okNW0gYQ=",
+          "strip_prefix": "",
+          "remote_patches": {},
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "bazel_skylib@1.3.0": {
+      "name": "bazel_skylib",
+      "version": "1.3.0",
+      "key": "bazel_skylib@1.3.0",
+      "repoName": "bazel_skylib",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [
+        "//toolchains/unittest:cmd_toolchain",
+        "//toolchains/unittest:bash_toolchain"
+      ],
+      "extensionUsages": [],
+      "deps": {
+        "platforms": "platforms@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz"
+          ],
+          "integrity": "sha256-dNVE2W9KW7Yw1GXKi7z+Ix41lOWq5X4e2/F6brPKJQY=",
+          "strip_prefix": "",
+          "remote_patches": {},
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "rules_pkg@0.7.0": {
+      "name": "rules_pkg",
+      "version": "0.7.0",
+      "key": "rules_pkg@0.7.0",
+      "repoName": "rules_pkg",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "rules_python": "rules_python@0.22.1",
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "rules_license": "rules_license@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz"
+          ],
+          "integrity": "sha256-iimOgydi7aGDBZfWT+fbWBeKqEzVkm121bdE1lWJQcI=",
+          "strip_prefix": "",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/rules_pkg/0.7.0/patches/module_dot_bazel.patch": "sha256-4OaEPZwYF6iC71ZTDg6MJ7LLqX7ZA0/kK4mT+4xKqiE="
+          },
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "abseil-cpp@20211102.0": {
+      "name": "abseil-cpp",
+      "version": "20211102.0",
+      "key": "abseil-cpp@20211102.0",
+      "repoName": "abseil-cpp",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "rules_cc": "rules_cc@0.0.9",
+        "platforms": "platforms@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz"
+          ],
+          "integrity": "sha256-3PcbnLqNwMqZQMSzFqDHlr6Pq0KwcLtrfKtitI8OZsQ=",
+          "strip_prefix": "abseil-cpp-20211102.0",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/patches/module_dot_bazel.patch": "sha256-4izqopgGCey4jVZzl/w3M2GVPNohjh2B5TmbThZNvPY="
+          },
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "upb@0.0.0-20220923-a547704": {
+      "name": "upb",
+      "version": "0.0.0-20220923-a547704",
+      "key": "upb@0.0.0-20220923-a547704",
+      "repoName": "upb",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "rules_proto": "rules_proto@5.3.0-21.7",
+        "com_google_protobuf": "protobuf@21.7",
+        "com_google_absl": "abseil-cpp@20211102.0",
+        "platforms": "platforms@0.0.7",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/protocolbuffers/upb/archive/a5477045acaa34586420942098f5fecd3570f577.tar.gz"
+          ],
+          "integrity": "sha256-z39x6v+QskwaKLSWRan/A6mmwecTQpHOcJActj5zZLU=",
+          "strip_prefix": "upb-a5477045acaa34586420942098f5fecd3570f577",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/patches/module_dot_bazel.patch": "sha256-wH4mNS6ZYy+8uC0HoAft/c7SDsq2Kxf+J8dUakXhaB0="
+          },
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "rules_jvm_external@4.4.2": {
+      "name": "rules_jvm_external",
+      "version": "4.4.2",
+      "key": "rules_jvm_external@4.4.2",
+      "repoName": "rules_jvm_external",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [
+        {
+          "extensionBzlFile": "@rules_jvm_external//:non-module-deps.bzl",
+          "extensionName": "non_module_deps",
+          "usingModule": "rules_jvm_external@4.4.2",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel",
+            "line": 9,
+            "column": 32
+          },
+          "imports": {
+            "io_bazel_rules_kotlin": "io_bazel_rules_kotlin"
+          },
+          "devImports": [],
+          "tags": [],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        },
+        {
+          "extensionBzlFile": "@rules_jvm_external//:extensions.bzl",
+          "extensionName": "maven",
+          "usingModule": "rules_jvm_external@4.4.2",
+          "location": {
+            "file": "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel",
+            "line": 16,
+            "column": 22
+          },
+          "imports": {
+            "rules_jvm_external_deps": "rules_jvm_external_deps"
+          },
+          "devImports": [],
+          "tags": [
+            {
+              "tagName": "install",
+              "attributeValues": {
+                "name": "rules_jvm_external_deps",
+                "artifacts": [
+                  "com.google.cloud:google-cloud-core:1.93.10",
+                  "com.google.cloud:google-cloud-storage:1.113.4",
+                  "com.google.code.gson:gson:2.9.0",
+                  "org.apache.maven:maven-artifact:3.8.6",
+                  "software.amazon.awssdk:s3:2.17.183"
+                ],
+                "lock_file": "@rules_jvm_external//:rules_jvm_external_deps_install.json"
+              },
+              "devDependency": false,
+              "location": {
+                "file": "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel",
+                "line": 18,
+                "column": 14
+              }
+            }
+          ],
+          "hasDevUseExtension": false,
+          "hasNonDevUseExtension": true
+        }
+      ],
+      "deps": {
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "io_bazel_stardoc": "stardoc@0.5.1",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/rules_jvm_external/archive/refs/tags/4.4.2.zip"
+          ],
+          "integrity": "sha256-c1YC9QgT6y6pPKP15DsZWb2AshO4NqB6YqKddXZwt3s=",
+          "strip_prefix": "rules_jvm_external-4.4.2",
+          "remote_patches": {},
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "googletest@1.11.0": {
+      "name": "googletest",
+      "version": "1.11.0",
+      "key": "googletest@1.11.0",
+      "repoName": "googletest",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "com_google_absl": "abseil-cpp@20211102.0",
+        "platforms": "platforms@0.0.7",
+        "rules_cc": "rules_cc@0.0.9",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz"
+          ],
+          "integrity": "sha256-tIcL8SH/d5W6INILzdhie44Ijy0dqymaAxwQNO3ck9U=",
+          "strip_prefix": "googletest-release-1.11.0",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/googletest/1.11.0/patches/module_dot_bazel.patch": "sha256-HuahEdI/n8KCI071sN3CEziX+7qP/Ec77IWayYunLP0="
+          },
+          "remote_patch_strip": 0
+        }
+      }
+    },
+    "stardoc@0.5.1": {
+      "name": "stardoc",
+      "version": "0.5.1",
+      "key": "stardoc@0.5.1",
+      "repoName": "stardoc",
+      "executionPlatformsToRegister": [],
+      "toolchainsToRegister": [],
+      "extensionUsages": [],
+      "deps": {
+        "bazel_skylib": "bazel_skylib@1.3.0",
+        "rules_java": "rules_java@7.4.0",
+        "bazel_tools": "bazel_tools@_",
+        "local_config_platform": "local_config_platform@_"
+      },
+      "repoSpec": {
+        "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+        "ruleClassName": "http_archive",
+        "attributes": {
+          "urls": [
+            "https://github.com/bazelbuild/stardoc/releases/download/0.5.1/stardoc-0.5.1.tar.gz"
+          ],
+          "integrity": "sha256-qoFNrgrEALurLoiB+ZFcb0fElmS/CHxAmhX5BDjSwj4=",
+          "strip_prefix": "",
+          "remote_patches": {
+            "https://bcr.bazel.build/modules/stardoc/0.5.1/patches/module_dot_bazel.patch": "sha256-UAULCuTpJE7SG0YrR9XLjMfxMRmbP+za3uW9ONZ5rjI="
+          },
+          "remote_patch_strip": 0
+        }
+      }
+    }
+  },
+  "moduleExtensions": {
+    "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": {
+      "general": {
+        "bzlTransitiveDigest": "pMLFCYaRPkgXPQ8vtuNkMfiHfPmRBy6QJfnid4sWfv0=",
+        "recordedFileInputs": {},
+        "recordedDirentsInputs": {},
+        "envVariables": {},
+        "generatedRepoSpecs": {
+          "local_config_apple_cc": {
+            "bzlFile": "@@apple_support~//crosstool:setup.bzl",
+            "ruleClassName": "_apple_cc_autoconf",
+            "attributes": {}
+          },
+          "local_config_apple_cc_toolchains": {
+            "bzlFile": "@@apple_support~//crosstool:setup.bzl",
+            "ruleClassName": "_apple_cc_autoconf_toolchains",
+            "attributes": {}
+          }
+        },
+        "recordedRepoMappingEntries": [
+          [
+            "apple_support~",
+            "bazel_tools",
+            "bazel_tools"
+          ]
+        ]
+      }
+    },
+    "@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": {
+      "general": {
+        "bzlTransitiveDigest": "PHpT2yqMGms2U4L3E/aZ+WcQalmZWm+ILdP3yiLsDhA=",
+        "recordedFileInputs": {},
+        "recordedDirentsInputs": {},
+        "envVariables": {},
+        "generatedRepoSpecs": {
+          "local_config_cc": {
+            "bzlFile": "@@bazel_tools//tools/cpp:cc_configure.bzl",
+            "ruleClassName": "cc_autoconf",
+            "attributes": {}
+          },
+          "local_config_cc_toolchains": {
+            "bzlFile": "@@bazel_tools//tools/cpp:cc_configure.bzl",
+            "ruleClassName": "cc_autoconf_toolchains",
+            "attributes": {}
+          }
+        },
+        "recordedRepoMappingEntries": [
+          [
+            "bazel_tools",
+            "bazel_tools",
+            "bazel_tools"
+          ]
+        ]
+      }
+    },
+    "@@bazel_tools//tools/osx:xcode_configure.bzl%xcode_configure_extension": {
+      "general": {
+        "bzlTransitiveDigest": "Qh2bWTU6QW6wkrd87qrU4YeY+SG37Nvw3A0PR4Y0L2Y=",
+        "recordedFileInputs": {},
+        "recordedDirentsInputs": {},
+        "envVariables": {},
+        "generatedRepoSpecs": {
+          "local_config_xcode": {
+            "bzlFile": "@@bazel_tools//tools/osx:xcode_configure.bzl",
+            "ruleClassName": "xcode_autoconf",
+            "attributes": {
+              "xcode_locator": "@bazel_tools//tools/osx:xcode_locator.m",
+              "remote_xcode": ""
+            }
+          }
+        },
+        "recordedRepoMappingEntries": []
+      }
+    },
+    "@@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": {
+      "general": {
+        "bzlTransitiveDigest": "hp4NgmNjEg5+xgvzfh6L83bt9/aiiWETuNpwNuF1MSU=",
+        "recordedFileInputs": {},
+        "recordedDirentsInputs": {},
+        "envVariables": {},
+        "generatedRepoSpecs": {
+          "local_config_sh": {
+            "bzlFile": "@@bazel_tools//tools/sh:sh_configure.bzl",
+            "ruleClassName": "sh_config",
+            "attributes": {}
+          }
+        },
+        "recordedRepoMappingEntries": []
+      }
+    },
+    "@@rules_java~//java:extensions.bzl%toolchains": {
+      "general": {
+        "bzlTransitiveDigest": "tJHbmWnq7m+9eUBnUdv7jZziQ26FmcGL9C5/hU3Q9UQ=",
+        "recordedFileInputs": {},
+        "recordedDirentsInputs": {},
+        "envVariables": {},
+        "generatedRepoSpecs": {
+          "remotejdk21_linux_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_21\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"21\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_linux_s390x_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_macos_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk21_macos_aarch64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_21\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"21\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_linux_aarch64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk21_macos_aarch64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "e8260516de8b60661422a725f1df2c36ef888f6fb35393566b00e7325db3d04e",
+              "strip_prefix": "zulu21.32.17-ca-jdk21.0.2-macosx_aarch64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_aarch64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_aarch64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk17_linux_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_macos_aarch64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "314b04568ec0ae9b36ba03c9cbd42adc9e1265f74678923b19297d66eb84dcca",
+              "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz"
+              ]
+            }
+          },
+          "remote_java_tools_windows": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "sha256": "fe2f88169696d6c6fc6e90ba61bb46be7d0ae3693cbafdf336041bf56679e8d1",
+              "urls": [
+                "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.4/java_tools_windows-v13.4.zip",
+                "https://github.com/bazelbuild/java_tools/releases/download/java_v13.4/java_tools_windows-v13.4.zip"
+              ]
+            }
+          },
+          "remotejdk11_win": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "43408193ce2fa0862819495b5ae8541085b95660153f2adcf91a52d3a1710e83",
+              "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-win_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip",
+                "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip"
+              ]
+            }
+          },
+          "remotejdk11_win_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_linux_aarch64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "54174439f2b3fddd11f1048c397fe7bb45d4c9d66d452d6889b013d04d21c4de",
+              "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_aarch64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk17_linux": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "b9482f2304a1a68a614dfacddcf29569a72f0fac32e6c74f83dc1b9a157b8340",
+              "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-linux_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk11_linux_s390x_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_linux_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_macos": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "bcaab11cfe586fae7583c6d9d311c64384354fb2638eb9a012eca4c3f1a1d9fd",
+              "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk11_win_arm64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2",
+              "strip_prefix": "jdk-11.0.13+8",
+              "urls": [
+                "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip"
+              ]
+            }
+          },
+          "remotejdk17_macos": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "640453e8afe8ffe0fb4dceb4535fb50db9c283c64665eebb0ba68b19e65f4b1f",
+              "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-macosx_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk21_macos": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "3ad8fe288eb57d975c2786ae453a036aa46e47ab2ac3d81538ebae2a54d3c025",
+              "strip_prefix": "zulu21.32.17-ca-jdk21.0.2-macosx_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_x64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_x64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk21_macos_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_21\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"21\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_macos_aarch64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_win": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "192f2afca57701de6ec496234f7e45d971bf623ff66b8ee4a5c81582054e5637",
+              "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-win_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip",
+                "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip"
+              ]
+            }
+          },
+          "remotejdk11_macos_aarch64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_linux_ppc64le_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk21_linux": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "5ad730fbee6bb49bfff10bf39e84392e728d89103d3474a7e5def0fd134b300a",
+              "strip_prefix": "zulu21.32.17-ca-jdk21.0.2-linux_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_x64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_x64.tar.gz"
+              ]
+            }
+          },
+          "remote_java_tools_linux": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "sha256": "ba10f09a138cf185d04cbc807d67a3da42ab13d618c5d1ce20d776e199c33a39",
+              "urls": [
+                "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.4/java_tools_linux-v13.4.zip",
+                "https://github.com/bazelbuild/java_tools/releases/download/java_v13.4/java_tools_linux-v13.4.zip"
+              ]
+            }
+          },
+          "remotejdk21_win": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "f7cc15ca17295e69c907402dfe8db240db446e75d3b150da7bf67243cded93de",
+              "strip_prefix": "zulu21.32.17-ca-jdk21.0.2-win_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-win_x64.zip",
+                "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-win_x64.zip"
+              ]
+            }
+          },
+          "remotejdk21_linux_aarch64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "ce7df1af5d44a9f455617c4b8891443fbe3e4b269c777d8b82ed66f77167cfe0",
+              "strip_prefix": "zulu21.32.17-ca-jdk21.0.2-linux_aarch64",
+              "urls": [
+                "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz",
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk11_linux_aarch64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_linux_s390x": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b",
+              "strip_prefix": "jdk-11.0.15+10",
+              "urls": [
+                "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz",
+                "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz"
+              ]
+            }
+          },
+          "remotejdk17_linux_aarch64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "6531cef61e416d5a7b691555c8cf2bdff689201b8a001ff45ab6740062b44313",
+              "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk17_win_arm64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_linux": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "a34b404f87a08a61148b38e1416d837189e1df7a040d949e743633daf4695a3c",
+              "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_x64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk11_macos_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_linux_ppc64le_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk17_win_arm64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "6802c99eae0d788e21f52d03cab2e2b3bf42bc334ca03cbf19f71eb70ee19f85",
+              "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-win_aarch64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip",
+                "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip"
+              ]
+            }
+          },
+          "remote_java_tools_darwin_arm64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "sha256": "076a7e198ad077f8c7d997986ef5102427fae6bbfce7a7852d2e080ed8767528",
+              "urls": [
+                "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.4/java_tools_darwin_arm64-v13.4.zip",
+                "https://github.com/bazelbuild/java_tools/releases/download/java_v13.4/java_tools_darwin_arm64-v13.4.zip"
+              ]
+            }
+          },
+          "remotejdk17_linux_ppc64le": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "00a4c07603d0218cd678461b5b3b7e25b3253102da4022d31fc35907f21a2efd",
+              "strip_prefix": "jdk-17.0.8.1+1",
+              "urls": [
+                "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz",
+                "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz"
+              ]
+            }
+          },
+          "remotejdk21_linux_aarch64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_21\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"21\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_win_arm64_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_11\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"11\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "local_jdk": {
+            "bzlFile": "@@rules_java~//toolchains:local_java_repository.bzl",
+            "ruleClassName": "_local_java_repository_rule",
+            "attributes": {
+              "java_home": "",
+              "version": "",
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+            }
+          },
+          "remote_java_tools_darwin_x86_64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "sha256": "4523aec4d09c587091a2dae6f5c9bc6922c220f3b6030e5aba9c8f015913cc65",
+              "urls": [
+                "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.4/java_tools_darwin_x86_64-v13.4.zip",
+                "https://github.com/bazelbuild/java_tools/releases/download/java_v13.4/java_tools_darwin_x86_64-v13.4.zip"
+              ]
+            }
+          },
+          "remote_java_tools": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "sha256": "e025fd260ac39b47c111f5212d64ec0d00d85dec16e49368aae82fc626a940cf",
+              "urls": [
+                "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.4/java_tools-v13.4.zip",
+                "https://github.com/bazelbuild/java_tools/releases/download/java_v13.4/java_tools-v13.4.zip"
+              ]
+            }
+          },
+          "remotejdk17_linux_s390x": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "ffacba69c6843d7ca70d572489d6cc7ab7ae52c60f0852cedf4cf0d248b6fc37",
+              "strip_prefix": "jdk-17.0.8.1+1",
+              "urls": [
+                "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz",
+                "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz"
+              ]
+            }
+          },
+          "remotejdk17_win_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_17\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"17\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          },
+          "remotejdk11_linux_ppc64le": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f",
+              "strip_prefix": "jdk-11.0.15+10",
+              "urls": [
+                "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz",
+                "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz"
+              ]
+            }
+          },
+          "remotejdk11_macos_aarch64": {
+            "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl",
+            "ruleClassName": "http_archive",
+            "attributes": {
+              "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n    name = \"jre\",\n    srcs = glob(\n        [\n            \"jre/bin/**\",\n            \"jre/lib/**\",\n        ],\n        allow_empty = True,\n        # In some configurations, Java browser plugin is considered harmful and\n        # common antivirus software blocks ac [...]
+              "sha256": "7632bc29f8a4b7d492b93f3bc75a7b61630894db85d136456035ab2a24d38885",
+              "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_aarch64",
+              "urls": [
+                "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz",
+                "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz"
+              ]
+            }
+          },
+          "remotejdk21_win_toolchain_config_repo": {
+            "bzlFile": "@@rules_java~//toolchains:remote_java_repository.bzl",
+            "ruleClassName": "_toolchain_config",
+            "attributes": {
+              "build_file": "\nconfig_setting(\n    name = \"prefix_version_setting\",\n    values = {\"java_runtime_version\": \"remotejdk_21\"},\n    visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n    name = \"version_setting\",\n    values = {\"java_runtime_version\": \"21\"},\n    visibility = [\"//visibility:private\"],\n)\nalias(\n    name = \"version_or_prefix_version_setting\",\n    actual = select({\n        \":version_setting\": \":version_setting\",\n        \"/ [...]
+            }
+          }
+        },
+        "recordedRepoMappingEntries": [
+          [
+            "rules_java~",
+            "bazel_tools",
+            "bazel_tools"
+          ],
+          [
+            "rules_java~",
+            "remote_java_tools",
+            "rules_java~~toolchains~remote_java_tools"
+          ]
+        ]
+      }
+    }
+  }
+}
diff --git a/README.md b/README.md
index 9e14458a..21d0b2d0 100644
--- a/README.md
+++ b/README.md
@@ -1,63 +1,4 @@
-![](https://img.shields.io/github/v/release/resilientdb/resilientdb)
-![](https://img.shields.io/badge/language-c++-orange.svg)
-![](https://img.shields.io/badge/platform-Ubuntu20.0+-lightgrey.svg)
-![GitHub](https://img.shields.io/github/license/resilientdb/resilientdb)
-![Generated Button](https://raw.githubusercontent.com/resilientdb/resilientdb/image-data/badge.svg)
-![build](https://github.com/resilientdb/resilientdb/workflows/bazel-build%20CI/badge.svg)
-![build](https://github.com/resilientdb/resilientdb/workflows/Unite%20Test/badge.svg)
-
-
-
-# ResilientDB: Global-Scale Sustainable Blockchain Fabric
-
-**[ResilientDB](https://resilientdb.com/)** is a **High Throughput Yielding Permissioned Blockchain Fabric** founded by **[ExpoLab](https://expolab.org/)** at **[UC Davis](https://www.ucdavis.edu/)** in 2018. ResilientDB advocates a **system-centric** design by adopting a **multi-threaded architecture** that encompasses **deep pipelines**. Further, ResilientDB **separates** the ordering of client transactions from their execution, which allows it to **process messages out-of-order**.
-
-### Quick Facts on ResilientDB
-1. ResilientDB orders client transactions through a highly optimized implementation of the  **[PBFT](https://pmg.csail.mit.edu/papers/osdi99.pdf)** [Castro and Liskov, 1998] protocol, which helps to achieve consensus among its replicas. ResilientDB also supports deploying other state-of-the-art consensus protocols *[release are planned]* such as **[GeoBFT](http://www.vldb.org/pvldb/vol13/p868-gupta.pdf)** [**[blog](https://blog.resilientdb.com/2023/03/07/GeoBFT.html), [released](https:// [...]
-2. ResilientDB requires deploying at least **3f+1** replicas, where **f (f > 0)** is the maximum number of arbitrary (or malicious) replicas.
-3. ResilientDB supports primary-backup architecture, which designates one of the replicas as the **primary** (replica with identifier **0**). The primary replica initiates consensus on a client transaction, while backups agree to follow a non-malicious primary.
-4. ResilientDB exposes a wide range of interfaces such as a **Key-Value** store, **Smart Contracts**, **UTXO**, and **Python SDK**. Following are some of the decentralized applications (DApps) built on top of ResilientDB: **[NFT Marketplace](https://nft.resilientdb.com/)** and **[Debitable](https://debitable.resilientdb.com/)**.
-5. To persist blockchain, chain state, and metadata, ResilientDB provides durability through  **LevelDB** and **RocksDB**.
-6. ResilientDB provides access to a seamless **GUI display** for deployment and maintenance, and supports  **Grafana** for plotting monitoring data. 
-7. **[Historial Facts]** The ResilientDB project was founded by **[Mohammad Sadoghi](https://expolab.org/)** along with his students ([Suyash Gupta](https://gupta-suyash.github.io/index.html) as the lead Architect, [Sajjad Rahnama](https://sajjadrahnama.com/) as the lead System Designer, and [Jelle Hellings](https://www.jhellings.nl/)) at **[UC Davis](https://www.ucdavis.edu/)** in 2018 and was open-sourced in late 2019. On September 30, 2021, we released ResilientDB v-3.0. In 2022, Resi [...]
-
-<div align = "center">
-<img src="./img/resdb-v2.png" width="220">
-<img src="./img/apache-resdb.png" width="80">
-<img src="./img/apache-incubator.png" width="250">
-</div>
-
----
-
-
-## Online Documentation:
-
-The latest ResilientDB documentation, including a programming guide, is available on our **[blog repository](https://blog.resilientdb.com/archive.html?tag=NexRes)**. This README file provides basic setup instructions.
-
-#### Table of Contents
-1. Software Stack Architecture 
-   - SDK, Interface/API, Platform, Execution, and Chain Layers 
-   - Detailed API Documentation: **[Core](https://api.resilientdb.com/)** and **[SDK](https://sdk.resilientdb.com/)**
-2. **SDK Layer:** **[Python SDK](https://blog.resilientdb.com/2023/02/01/UsingPythonSDK.html)** and **[Wallet - ResVault](https://blog.resilientdb.com/2023/09/21/ResVault.html)**
-3. **Interface Layer:** **[Key-Value](https://blog.resilientdb.com/2022/09/28/GettingStartedNexRes.html)**, **[Solidity Smart Contract](https://blog.resilientdb.com/2023/01/15/GettingStartedSmartContract.html)**, **[Unspent Transaction Output (UTXO) Model](https://blog.resilientdb.com/2023/02/12/UtxoOnNexres.html)**, ResilientDB Database Connectivity (RDBC) API
-4. **Platform Layer:** **[Consensus Manager Architecture (ordering, recovery, network, chain management)](https://blog.resilientdb.com/2022/09/27/What_Is_NexRes.html)**
-   - **[Recovery & Checkpoint Design](https://blog.resilientdb.com/2023/08/22/ViewChangeInNexRes.html)**
-5. **Execution Layer:** Transaction Manager Design (Runtime) 
-6. **Chain Layer:** Chain State & Storage Manager Design (**[durability](https://blog.resilientdb.com/2023/02/15/NexResDurabilityLayer.html)**) 
-7. **[Installing & Deploying ResilientDB](https://blog.resilientdb.com/2022/09/28/GettingStartedNexRes.html)**
-   - Build Your First Application: **[KV Service](https://blog.resilientdb.com/2022/09/28/StartYourApplication.html)**, **[UTXO](https://blog.resilientdb.com/2023/02/12/GettingStartedOnUtxo.html)**
-   - Dashboard: **[Monitoring](https://blog.resilientdb.com/2022/12/06/NexResGrafanaDashboardInstallation.html)**, **[Deployment](https://blog.resilientdb.com/2022/12/06/DeployGrafanaDashboardOnOracleCloud.html)**, **[Data Pipeline](https://blog.resilientdb.com/2022/12/12/NexResGrafanaDashboardPipeline.html)**
-   - System Parameters & Configuration   
-   - Continuous Integration & Testing 
-
-<div align = "center">
-<img src="./img/nexres.png" width="600">
-</div>
-
-## OS Requirements
-Ubuntu 20+
-
----
+# Usage
 
 ## Build and Deploy ResilientDB
 
@@ -77,260 +18,57 @@ Run ResilientDB (Providing a Key-Value Service):
 Build Interactive Tools:
 
     bazel build service/tools/kv/api_tools/kv_service_tools
+    
 
-## Functions ##
-ResilientDB supports two types of functions: version-based and non-version-based.
-Version-based functions will leverage versions to protect each update, versions must be obtained before updating a key.
-
-***Note***: Version-based functions are not compatible with non-version-based functions. Do not use both in your applications.
-
-We show the functions below and show how to use [kv_service_tools](service/tools/kv/api_tools/kv_service_tools.cpp) to test the function.
-
-### Version-Based Functions ###
-#### Get ####
-Obtain the value of `key` with a specific version `v`.
-
-      kv_service_tools --config config_file --cmd get_with_version --key key --version v
-
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | get_with_version |
-| key  | the key you want to obtain |
-| version | the version you want to obtain. (If the `v` is 0, it will return the latest version |
-
-
-Example:
-
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_with_version --key key1 --version 0
-
-Results:
-> get key = key1, value = value: "v2"
-> version: 2
-
-#### Set ####
-Set `value` to the key `key` based on version `v`.
-
-      kv_service_tools --config config_file --cmd set_with_version --key key --version v --value value
-
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | set_with_version |
-| key  | the key you want to set |
-| version | the version you have obtained. (If the version has been changed during the update, the transaction will be ignored) |
-| value | the new value |
-
-Example:
-
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd set_with_version --key key1 --version 0 --value v1
-
-Results:
-> set key = key1, value = v3, version = 2 done, ret = 0
-> 
-> current value = value: "v3"
-> version: 3
-
-#### Get Key History ####
-Obtain the update history of key `key` within the versions [`v1`, `v2`].
-
-      kv_service_tools --config config_file --cmd get_history --key key --min_version v1 --max_version v2
-
-
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | get_history |
-| key  | the key you want to obtain |
-| min_version | the minimum version you want to obtain |
-| max_version | the maximum version you want to obtain |
-
-Example:
-
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_history --key key1 --min_version 1 --max_version 2
-
-Results:
-
-> get history key = key1, min version = 1, max version = 2 <br>
->  value = <br>
-> item { <br>
->  &ensp; key: "key1" <br>
->  &ensp; value_info { <br>
->  &ensp;&ensp; value: "v1" <br>
->  &ensp;&ensp; version: 2 <br>
-> &ensp;} <br>
-> } <br>
-> item { <br>
-> &ensp; key: "key1" <br>
-> &ensp; value_info { <br>
-> &ensp;&ensp; value: "v0" <br>
-> &ensp;&ensp; version: 1 <br>
-> &ensp;} <br>
-> } 
-
-#### Get Top ####
-Obtain the recent `top_number` history of the key `key`.
-
-      kv_service_tools --config config_path --cmd get_top --key key --top top_number
-
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | get_top |
-| key  | the key you want to obtain |
-| top | the number of the recent updates |
-
-Example:
-
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_top --key key1 --top 1
-
-Results:
-
->key = key1, top 1 <br>
-> value = <br>
-> item { <br>
->&ensp;key: "key1" <br>
->  &ensp;value_info { <br>
->  &ensp;&ensp;  value: "v2" <br>
->  &ensp;&ensp;  version: 3 <br>
->  &ensp;} <br>
->}
-
-#### Get Key Range ####
-Obtain the values of the keys in the ranges [`key1`, `key2`]. Do not use this function in your practice code
-
-      kv_service_tools --config config_file --cmd get_key_range_with_version --min_key key1 --max_key key2
-
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | get_key_range_with_version |
-| min_key  | the minimum key  |
-| max_key | the maximum key |
-
-Example:
-
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_key_range_with_version --min_key key1 --max_key key3
-
-Results:
-
->min key = key1 max key = key2 <br>
-> getrange value = <br>
-> item { <br>
-> &ensp; key: "key1" <br>
-> &ensp; value_info { <br>
-> &ensp;&ensp;   value: "v0" <br>
-> &ensp;&ensp;   version: 1 <br>
-> &ensp; } <br>
-> } <br>
-> item { <br>
-> &ensp; key: "key2" <br>
-> &ensp; value_info { <br>
-> &ensp;&ensp;   value: "v1" <br>
-> &ensp;&ensp;   version: 1 <br>
-> &ensp; } <br>
->}
-
-
-### Non-Version-Based Function ###
-#### Set #####
-Set `value` to the key `key`.
-
-      kv_service_tools --config config_file --cmd set --key key --value value
-
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | set |
-| key  | the key you want to set |
-| value | the new value |
-
-Example:
-
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd set --key key1 --value value1
-
-Results:
-> set key = key1, value = v1, done, ret = 0
-
-#### Get ####
-Obtain the value of `key`.
-
-      kv_service_tools --config config_file --cmd get --key key
-
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | get |
-| key  | the key you want to obtain |
-
-Example:
-
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get --key key1
-
-Results:
-> get key = key1, value = "v2"
-
-
-#### Get Key Range ####
-Obtain the values of the keys in the ranges [`key1`, `key2`]. Do not use this function in your practice code
-
-      kv_service_tools --config config_path --cmd get_key_range --min_key key1 --max_key key2
+## Test Performance
 
-|  parameters   |  descriptions |
-|  ----  | ----  |
-| config  | the path of the client config which points to the db entrance |
-| cmd  | get_key_range |
-| min_key  | the minimum key  |
-| max_key | the maximum key |
+Add the IP addresses of the machines where you wish to deploy ResilientDB replicas and client proxy in the file [scripts/deploy/config/kv_performance_server.conf](scripts/deploy/config/kv_performance_server.conf). 
 
-Example:
+We recommend using private IP addresses of each machine.
 
-      bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_key_range --min_key key1 --max_key key3
+* If you do not require any SSH key to log in to a machine, then you would need to update the scripts.
+* In these scripts, we assume that the ``root`` is ``ubuntu`` and the current working directory is located at ``/home/ubuntu/``. If this is not the case for your machines, you would need to update the scripts.
+* If you have changed the path for the binary, then you would need to update the path stated in the scripts.
 
-Results:
-> getrange min key = key1, max key = key3 <br>
-> value = [v3,v2,v1]
+Our benchmark is based on the Key-Value service.
 
+Before running, place the private IP addresses of your machines in the file ``scripts/deploy/config/kv_performance_server.conf``.
+Also, please create the ssh key file in the config "config/key.conf" and put your ssh key there (See the [scripts/deploy/config/key_example.conf](scripts/deploy/config/key_example.conf) as an example). 
 
-## Deployment Script
+Enter the path for performance test:
+   cd scripts/deploy
 
-We also provide access to a [deployment script](https://github.com/resilientdb/resilientdb/tree/master/scripts/deploy) that allows deployment on distinct machines.
+Run the script to copy tpcc database file:
 
-## Deploy via Docker
+    ./script/copy_tpcc_db_file.sh
 
-1. **Install Docker**  
-   Before getting started, make sure you have Docker installed on your system. If you don't have Docker already, you can download and install it from the official [Docker website](https://www.docker.com/products/docker-desktop/).
+Run the script for HotStuff-1:
+   
+	./performance/hs1_performance.sh config/kv_performance_server.conf
 
-2. **Pull the Latest ResilientDB Image**  
-   Choose the appropriate [ResilientDB image](https://hub.docker.com/repository/docker/expolab/resdb/general) for your machine's architecture:
+Run the script for HotStuff:
+   
+	./performance/hs_performance.sh config/kv_performance_server.conf
 
-   - For amd architecture, run:
-     ```shell
-     docker pull expolab/resdb:amd64
-     ```
+Run the script for HotStuff-2:
+   
+	./performance/hs2_performance.sh config/kv_performance_server.conf
 
-   - For Apple Silicon (M1/M2) architecture, run:
-     ```shell
-     docker pull expolab/resdb:arm64
-     ```
+Run the script for HotStuff-1 with Slotting (To achieve the best performance of HotStuff-1 with Slotting, please uncomment Line 10 in [platform/networkstrate/async_replica_client.cpp](platform/networkstrate/async_replica_client.cpp)):
+   
+	./performance/slot_hs1_performance.sh config/kv_performance_server.conf
 
-3. **Run a Container with the Pulled Image**  
-   Launch a Docker container using the ResilientDB image you just pulled:
+Results will be saved locally and be shown on the screen as well after running for 60 seconds.
 
-   - For amd architecture, run:
-     ```shell
-     docker run -d --name myserver expolab/resdb:amd64
-     ```
+You can test different parameters by editing the config files in "[scripts/deploy/config/](scripts/deploy/config/)". For example, [hs1.config](scripts/deploy/config/hs1.config) is the config file of HotStuff-1.
 
-   - For Apple Silicon (M1/M2) architecture, run:
-     ```shell
-     docker run -d --name myserver expolab/resdb:arm64
-     ```
 
-4. **Test with Set and Get Commands**
-   Exec into the running server:
-   ```shell
-   docker exec -it myserver bash
-   ```
+Below are the parameters that are related to our experiments:
 
-   Verify the functionality of the service by performing set and get operations provided above [functions](README.md#functions).
+"clientBatchNum": Batch Size,
+"non_responsive_num": Number of slow leaders,
+"fork_tail_num": Number of faulty leader that conduct tail-forking attack,
+"rollback_num": Number of faulty leader that conduct rollback attack,
+"tpcc_enabled": Use TPC-C benchmark,
+"network_delay_num": Turn on Network Delay Test,
+"mean_network_delay": The avearge value (us) of injected message delay.
diff --git a/benchmark/protocols/hs/kv_server_performance.cpp b/benchmark/protocols/hs/kv_server_performance.cpp
index bffa725f..05689208 100644
--- a/benchmark/protocols/hs/kv_server_performance.cpp
+++ b/benchmark/protocols/hs/kv_server_performance.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/benchmark/protocols/hs1/BUILD b/benchmark/protocols/hs1/BUILD
new file mode 100644
index 00000000..a6e6d853
--- /dev/null
+++ b/benchmark/protocols/hs1/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//visibility:private"])
+
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
+
+cc_binary(
+    name = "kv_server_performance",
+    srcs = ["kv_server_performance.cpp"],
+    deps = [
+        "//chain/storage:memory_db",
+        "//executor/kv:kv_executor",
+        "//platform/config:resdb_config_utils",
+        "//platform/consensus/ordering/hs1/framework:consensus",
+        "//service/utils:server_factory",
+    ],
+)
+
diff --git a/benchmark/protocols/hs/kv_server_performance.cpp b/benchmark/protocols/hs1/kv_server_performance.cpp
similarity index 93%
copy from benchmark/protocols/hs/kv_server_performance.cpp
copy to benchmark/protocols/hs1/kv_server_performance.cpp
index bffa725f..5a66198e 100644
--- a/benchmark/protocols/hs/kv_server_performance.cpp
+++ b/benchmark/protocols/hs1/kv_server_performance.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -28,13 +28,13 @@
 #include "chain/storage/memory_db.h"
 #include "executor/kv/kv_executor.h"
 #include "platform/config/resdb_config_utils.h"
-#include "platform/consensus/ordering/hs/framework/consensus.h"
+#include "platform/consensus/ordering/hs1/framework/consensus.h"
 #include "platform/networkstrate/service_network.h"
 #include "platform/statistic/stats.h"
 #include "proto/kv/kv.pb.h"
 
 using namespace resdb;
-using namespace resdb::hs;
+using namespace resdb::hs1;
 using namespace resdb::storage;
 
 void ShowUsage() {
@@ -70,7 +70,7 @@ int main(int argc, char** argv) {
 
   config->RunningPerformance(true);
 
-  auto performance_consens = std::make_unique<hs::Consensus>(
+  auto performance_consens = std::make_unique<hs1::Consensus>(
       *config, std::make_unique<KVExecutor>(std::make_unique<MemoryDB>()));
   performance_consens->SetupPerformanceDataFunc([]() {
     KVRequest request;
diff --git a/benchmark/protocols/hs2/BUILD b/benchmark/protocols/hs2/BUILD
new file mode 100644
index 00000000..795a4c93
--- /dev/null
+++ b/benchmark/protocols/hs2/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//visibility:private"])
+
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
+
+cc_binary(
+    name = "kv_server_performance",
+    srcs = ["kv_server_performance.cpp"],
+    deps = [
+        "//chain/storage:memory_db",
+        "//executor/kv:kv_executor",
+        "//platform/config:resdb_config_utils",
+        "//platform/consensus/ordering/hs2/framework:consensus",
+        "//service/utils:server_factory",
+    ],
+)
+
diff --git a/benchmark/protocols/hs/kv_server_performance.cpp b/benchmark/protocols/hs2/kv_server_performance.cpp
similarity index 93%
copy from benchmark/protocols/hs/kv_server_performance.cpp
copy to benchmark/protocols/hs2/kv_server_performance.cpp
index bffa725f..44cf0d5f 100644
--- a/benchmark/protocols/hs/kv_server_performance.cpp
+++ b/benchmark/protocols/hs2/kv_server_performance.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -28,13 +28,13 @@
 #include "chain/storage/memory_db.h"
 #include "executor/kv/kv_executor.h"
 #include "platform/config/resdb_config_utils.h"
-#include "platform/consensus/ordering/hs/framework/consensus.h"
+#include "platform/consensus/ordering/hs2/framework/consensus.h"
 #include "platform/networkstrate/service_network.h"
 #include "platform/statistic/stats.h"
 #include "proto/kv/kv.pb.h"
 
 using namespace resdb;
-using namespace resdb::hs;
+using namespace resdb::hs2;
 using namespace resdb::storage;
 
 void ShowUsage() {
@@ -70,7 +70,7 @@ int main(int argc, char** argv) {
 
   config->RunningPerformance(true);
 
-  auto performance_consens = std::make_unique<hs::Consensus>(
+  auto performance_consens = std::make_unique<hs2::Consensus>(
       *config, std::make_unique<KVExecutor>(std::make_unique<MemoryDB>()));
   performance_consens->SetupPerformanceDataFunc([]() {
     KVRequest request;
diff --git a/benchmark/protocols/slot_hs1/BUILD b/benchmark/protocols/slot_hs1/BUILD
new file mode 100644
index 00000000..5f6fca0c
--- /dev/null
+++ b/benchmark/protocols/slot_hs1/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//visibility:private"])
+
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
+
+cc_binary(
+    name = "kv_server_performance",
+    srcs = ["kv_server_performance.cpp"],
+    deps = [
+        "//chain/storage:memory_db",
+        "//executor/kv:kv_executor",
+        "//platform/config:resdb_config_utils",
+        "//platform/consensus/ordering/slot_hs1/framework:consensus",
+        "//service/utils:server_factory",
+    ],
+)
+
diff --git a/benchmark/protocols/hs/kv_server_performance.cpp b/benchmark/protocols/slot_hs1/kv_server_performance.cpp
similarity index 93%
copy from benchmark/protocols/hs/kv_server_performance.cpp
copy to benchmark/protocols/slot_hs1/kv_server_performance.cpp
index bffa725f..a53d5554 100644
--- a/benchmark/protocols/hs/kv_server_performance.cpp
+++ b/benchmark/protocols/slot_hs1/kv_server_performance.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -28,13 +28,13 @@
 #include "chain/storage/memory_db.h"
 #include "executor/kv/kv_executor.h"
 #include "platform/config/resdb_config_utils.h"
-#include "platform/consensus/ordering/hs/framework/consensus.h"
+#include "platform/consensus/ordering/slot_hs1/framework/consensus.h"
 #include "platform/networkstrate/service_network.h"
 #include "platform/statistic/stats.h"
 #include "proto/kv/kv.pb.h"
 
 using namespace resdb;
-using namespace resdb::hs;
+using namespace resdb::slot_hs1;
 using namespace resdb::storage;
 
 void ShowUsage() {
@@ -70,7 +70,7 @@ int main(int argc, char** argv) {
 
   config->RunningPerformance(true);
 
-  auto performance_consens = std::make_unique<hs::Consensus>(
+  auto performance_consens = std::make_unique<slot_hs1::Consensus>(
       *config, std::make_unique<KVExecutor>(std::make_unique<MemoryDB>()));
   performance_consens->SetupPerformanceDataFunc([]() {
     KVRequest request;
diff --git a/benchmark/protocols/zzy/BUILD b/benchmark/protocols/zzy/BUILD
new file mode 100644
index 00000000..9a349028
--- /dev/null
+++ b/benchmark/protocols/zzy/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//visibility:private"])
+
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
+
+cc_binary(
+    name = "kv_server_performance",
+    srcs = ["kv_server_performance.cpp"],
+    deps = [
+        "//chain/storage:memory_db",
+        "//executor/kv:kv_executor",
+        "//platform/config:resdb_config_utils",
+        "//platform/consensus/ordering/zzy/framework:consensus",
+        "//service/utils:server_factory",
+    ],
+)
+
diff --git a/benchmark/protocols/hs/kv_server_performance.cpp b/benchmark/protocols/zzy/kv_server_performance.cpp
similarity index 91%
copy from benchmark/protocols/hs/kv_server_performance.cpp
copy to benchmark/protocols/zzy/kv_server_performance.cpp
index bffa725f..3b2a4ede 100644
--- a/benchmark/protocols/hs/kv_server_performance.cpp
+++ b/benchmark/protocols/zzy/kv_server_performance.cpp
@@ -1,5 +1,4 @@
 /*
- * 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
@@ -28,13 +27,13 @@
 #include "chain/storage/memory_db.h"
 #include "executor/kv/kv_executor.h"
 #include "platform/config/resdb_config_utils.h"
-#include "platform/consensus/ordering/hs/framework/consensus.h"
+#include "platform/consensus/ordering/zzy/framework/consensus.h"
 #include "platform/networkstrate/service_network.h"
 #include "platform/statistic/stats.h"
 #include "proto/kv/kv.pb.h"
 
 using namespace resdb;
-using namespace resdb::hs;
+using namespace resdb::zzy;
 using namespace resdb::storage;
 
 void ShowUsage() {
@@ -69,20 +68,20 @@ int main(int argc, char** argv) {
       GenerateResDBConfig(config_file, private_key_file, cert_file);
 
   config->RunningPerformance(true);
+  ResConfigData config_data = config->GetConfigData();
 
-  auto performance_consens = std::make_unique<hs::Consensus>(
+  auto performance_consens = std::make_unique<Consensus>(
       *config, std::make_unique<KVExecutor>(std::make_unique<MemoryDB>()));
   performance_consens->SetupPerformanceDataFunc([]() {
     KVRequest request;
     request.set_cmd(KVRequest::SET);
     request.set_key(GetRandomKey());
-    request.set_value("helloworld");
+    request.set_value("helloword");
     std::string request_data;
     request.SerializeToString(&request_data);
     return request_data;
   });
-
   auto server =
       std::make_unique<ServiceNetwork>(*config, std::move(performance_consens));
   server->Run();
-}
+}
\ No newline at end of file
diff --git a/common/crypto/hash.cpp b/common/crypto/hash.cpp
index 8173109d..e16ed032 100644
--- a/common/crypto/hash.cpp
+++ b/common/crypto/hash.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/hash.h b/common/crypto/hash.h
index 10d028cb..d65a1785 100644
--- a/common/crypto/hash.h
+++ b/common/crypto/hash.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/hash_test.cpp b/common/crypto/hash_test.cpp
index 258d4a64..efcf8203 100644
--- a/common/crypto/hash_test.cpp
+++ b/common/crypto/hash_test.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/key_generator.cpp b/common/crypto/key_generator.cpp
index 89ec6971..fd1d33f9 100644
--- a/common/crypto/key_generator.cpp
+++ b/common/crypto/key_generator.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/key_generator.h b/common/crypto/key_generator.h
index 846039ff..ff3b6bd8 100644
--- a/common/crypto/key_generator.h
+++ b/common/crypto/key_generator.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/mock_signature_verifier.h b/common/crypto/mock_signature_verifier.h
index 1bf88628..7967efa3 100644
--- a/common/crypto/mock_signature_verifier.h
+++ b/common/crypto/mock_signature_verifier.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/signature_utils.cpp b/common/crypto/signature_utils.cpp
index e86f99b1..ef386307 100644
--- a/common/crypto/signature_utils.cpp
+++ b/common/crypto/signature_utils.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/signature_utils.h b/common/crypto/signature_utils.h
index 18415eaa..666b0ab4 100644
--- a/common/crypto/signature_utils.h
+++ b/common/crypto/signature_utils.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/signature_verifier.cpp b/common/crypto/signature_verifier.cpp
index 09e81985..29f50b35 100644
--- a/common/crypto/signature_verifier.cpp
+++ b/common/crypto/signature_verifier.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/signature_verifier.h b/common/crypto/signature_verifier.h
index 619908ea..db88321e 100644
--- a/common/crypto/signature_verifier.h
+++ b/common/crypto/signature_verifier.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/signature_verifier_interface.cpp b/common/crypto/signature_verifier_interface.cpp
index 07bed5cc..e680a279 100644
--- a/common/crypto/signature_verifier_interface.cpp
+++ b/common/crypto/signature_verifier_interface.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/signature_verifier_interface.h b/common/crypto/signature_verifier_interface.h
index eea1b410..09ca318b 100644
--- a/common/crypto/signature_verifier_interface.h
+++ b/common/crypto/signature_verifier_interface.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/crypto/signature_verifier_test.cpp b/common/crypto/signature_verifier_test.cpp
index b7453bb9..fbb26d9b 100644
--- a/common/crypto/signature_verifier_test.cpp
+++ b/common/crypto/signature_verifier_test.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/test/json_test.cpp b/common/test/json_test.cpp
index ccc28680..50c83429 100644
--- a/common/test/json_test.cpp
+++ b/common/test/json_test.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/test/test_macros.h b/common/test/test_macros.h
index 6a991ed4..6b3b8399 100644
--- a/common/test/test_macros.h
+++ b/common/test/test_macros.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/utils/utils.cpp b/common/utils/utils.cpp
index d4707fc5..164a7133 100644
--- a/common/utils/utils.cpp
+++ b/common/utils/utils.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/common/utils/utils.h b/common/utils/utils.h
index bc57af07..b66236c3 100644
--- a/common/utils/utils.h
+++ b/common/utils/utils.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/executor/common/BUILD b/executor/common/BUILD
index 0e0d8ee5..e3886fff 100644
--- a/executor/common/BUILD
+++ b/executor/common/BUILD
@@ -1,10 +1,35 @@
 package(default_visibility = ["//visibility:public"])
 
+cc_library(
+    name = "glog",
+    deps = [
+        "@com_github_google_glog//:glog",
+    ],
+)
+
+cc_library(
+    name = "tpcc_executor",
+    srcs = ["tpcc_executor.cpp"],
+    hdrs = ["tpcc_executor.h"], 
+    deps = [
+        ":glog",
+        "//platform/proto:resdb_cc_proto",
+    ],
+    copts = [
+        "-I/usr/include",  # Include path for SQLite3 headers
+    ],
+    linkopts = [
+        "-L/usr/lib",  # Library path for linking
+        "-lsqlite3",   # Link against the SQLite3 library
+    ],
+)
+
 cc_library(
     name = "transaction_manager",
     srcs = ["transaction_manager.cpp"],
     hdrs = ["transaction_manager.h"],
     deps = [
+        ":tpcc_executor",
         "//chain/storage",
         "//common:comm",
         "//platform/proto:resdb_cc_proto",
diff --git a/executor/common/tpcc_executor.cpp b/executor/common/tpcc_executor.cpp
new file mode 100644
index 00000000..db2036c9
--- /dev/null
+++ b/executor/common/tpcc_executor.cpp
@@ -0,0 +1,961 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+#include "executor/common/tpcc_executor.h"
+#include <iostream>
+#include <iomanip>
+#include <glog/logging.h>
+
+namespace resdb {
+
+TpccExecutor::TpccExecutor() {
+    db = loadDatabaseIntoMemory();
+    if (!db) {
+        LOG(ERROR) << "Fail to Load Database Into Memory";
+        assert(false);
+    }
+}
+
+TpccExecutor::~TpccExecutor() {
+    sqlite3_close(db);
+}
+
+sqlite3* TpccExecutor::loadDatabaseIntoMemory() {
+    sqlite3* diskDb = nullptr;
+    sqlite3* memoryDb = nullptr;
+
+    // Open the database file
+    if (sqlite3_open(dbFilePath.c_str(), &diskDb) != SQLITE_OK) {
+        LOG(ERROR) << "Failed to open disk database: " << sqlite3_errmsg(diskDb) << std::endl;
+        return nullptr;
+    }
+
+    // Create an in-memory database
+    if (sqlite3_open(":memory:", &memoryDb) != SQLITE_OK) {
+        LOG(ERROR) << "Failed to create in-memory database: " << sqlite3_errmsg(memoryDb) << std::endl;
+        sqlite3_close(diskDb);
+        return nullptr;
+    }
+
+    // Use SQLite Backup API to copy data from disk to memory
+    sqlite3_backup* backup = sqlite3_backup_init(memoryDb, "main", diskDb, "main");
+    if (backup) {
+        sqlite3_backup_step(backup, -1); // Copy all pages
+        sqlite3_backup_finish(backup);
+    } else {
+        LOG(ERROR) << "Failed to initialize backup: " << sqlite3_errmsg(memoryDb) << std::endl;
+    }
+
+    sqlite3_close(diskDb);
+
+    return memoryDb;
+}
+
+
+std::unique_ptr<std::string> TpccExecutor::ExecuteTransaction(TpccTransaction* tpcc_txn) {
+    switch (tpcc_txn->type()) {
+        case TpccTransaction::TPCC_TYPE_NEWORDER: 
+            return std::make_unique<std::string>(ExecuteNewOrderTransaction(tpcc_txn->mutable_new_order()));
+
+        case TpccTransaction::TPCC_TYPE_PAYMENT: 
+            return std::make_unique<std::string>(ExecutePaymentTransaction(tpcc_txn->mutable_payment()));
+
+        case TpccTransaction::TPCC_TYPE_ORDERSTATUS: 
+            return std::make_unique<std::string>(ExecuteOrderStatusTransaction(tpcc_txn->mutable_order_status()));
+
+        case TpccTransaction::TPCC_TYPE_DELIVERY: 
+            return std::make_unique<std::string>(ExecuteDeliveryTransaction(tpcc_txn->mutable_delivery()));
+
+        case TpccTransaction::TPCC_TYPE_STOCKLEVEL: 
+            return std::make_unique<std::string>(ExecuteStockLevelTransaction(tpcc_txn->mutable_stock_level()));
+
+        default:
+            LOG(ERROR) << "WRONG TPCC TRANSACTION TYPE" << std::endl;
+            assert(false);
+            return nullptr;
+    }
+}
+
+std::string TpccExecutor::ExecuteNewOrderTransaction(NewOrderTransaction* tpcc_txn) {
+    int W_ID = tpcc_txn->w_id();
+    int D_ID = tpcc_txn->d_id();
+    int C_ID = tpcc_txn->c_id();
+    int O_OL_CNT = tpcc_txn->o_ol_cnt();
+    std::string DATETIME = tpcc_txn->date_time();
+    std::vector<int> SUPWARE, ITEMID, QTY;
+    SUPWARE.resize(O_OL_CNT);
+    ITEMID.resize(O_OL_CNT);
+    QTY.resize(O_OL_CNT);
+
+    for (int i = 0; i < tpcc_txn->items_size(); ++i) {
+        auto& item = tpcc_txn->items(i);
+        // Access fields of OrderItem (example fields: ITEM_ID, SUPWARE, QTY)
+        ITEMID[i] = item.i_id();     // Assuming OrderItem has an ITEM_ID field
+        SUPWARE[i] = item.sup_w_id();     // Assuming OrderItem has a SUPWARE field
+        QTY[i] = item.qty();             // Assuming OrderItem has a QTY field
+    }
+
+    return SQLITE3_NEW_ORDER(db, W_ID, D_ID, C_ID, O_OL_CNT, SUPWARE, ITEMID, QTY, DATETIME);
+}
+
+std::string TpccExecutor::ExecutePaymentTransaction(PaymentTransaction* tpcc_txn) {
+    int W_ID = tpcc_txn->w_id(); 
+    int D_ID = tpcc_txn->d_id(); 
+    int C_W_ID = tpcc_txn->c_w_id(); 
+    int C_D_ID = tpcc_txn->c_d_id(); 
+    int C_ID = tpcc_txn->c_id(); 
+    double H_AMOUNT = tpcc_txn->h_amount(); 
+    std::string H_DATE = tpcc_txn->h_date(); 
+    std::string C_LAST = tpcc_txn->c_last();  
+    bool BYNAME = tpcc_txn->byname();  
+    return SQLITE3_PAYMENT(db, W_ID, D_ID, C_W_ID, C_D_ID, C_ID, H_AMOUNT, H_DATE, C_LAST, BYNAME);
+}
+
+std::string TpccExecutor::ExecuteOrderStatusTransaction(OrderStatusTransaction* tpcc_txn) {
+    int W_ID = tpcc_txn->w_id();
+    int D_ID = tpcc_txn->d_id();
+    int C_ID = tpcc_txn->c_id(); 
+    std::string C_LAST = tpcc_txn->c_last();
+    bool BYNAME = tpcc_txn->byname();
+    return SQLITE3_ORDER_STATUS(db, W_ID, D_ID, C_ID, C_LAST, BYNAME);
+}
+
+std::string TpccExecutor::ExecuteDeliveryTransaction(DeliveryTransaction* tpcc_txn) {
+    int W_ID = tpcc_txn->w_id();
+    int CARRIER_ID = tpcc_txn->carrier_id();    // Carrier ID
+    std::string DATE_TIME = tpcc_txn->date_time(); // Date and Tim
+    return SQLITE3_DELIVERY(db, W_ID, CARRIER_ID, DATE_TIME);
+}
+
+std::string TpccExecutor::ExecuteStockLevelTransaction(StockLevelTransaction* tpcc_txn) {
+    int W_ID = tpcc_txn->w_id();
+    int D_ID = tpcc_txn->d_id();
+    int THRESHOLD = tpcc_txn->threshold();
+    return SQLITE3_STOCK_LEVEL(db, W_ID, D_ID, THRESHOLD);
+}
+
+std::string TpccExecutor::SQLITE3_NEW_ORDER(
+    sqlite3* db, int W_ID, int D_ID, int C_ID, int O_OL_CNT,
+    std::vector<int>& SUPWARE, std::vector<int>& ITEMID, std::vector<int>& QTY, std::string DATETIME
+) {
+    try {
+        int O_ALL_LOCAL = 1;
+        std::vector<double> PRICE;
+        std::vector<std::string> INAME;
+        std::vector<int> STOCK;
+        std::vector<char> BG;
+        std::vector<double> AMT; 
+        double TOTAL;
+        PRICE.resize(O_OL_CNT);
+        INAME.resize(O_OL_CNT);
+        STOCK.resize(O_OL_CNT);
+        BG.resize(O_OL_CNT);
+        AMT.resize(O_OL_CNT);
+
+        sqlite3_stmt* stmt = nullptr;
+        std::string query;
+        double C_DISCOUNT, W_TAX, D_TAX;
+        int D_NEXT_O_ID, O_ID;
+        std::string C_LAST, C_CREDIT;
+        double OL_AMOUNT, I_PRICE;
+        std::string I_NAME, I_DATA, S_DATA;
+        int OL_SUPPLY_W_ID, OL_I_ID, OL_QUANTITY, S_QUANTITY;
+
+        // Start the transaction
+        if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            return "Error: Failed to begin transaction.";
+        }
+
+        // Fetch customer and warehouse details
+        query = "SELECT C_DISCOUNT, C_LAST, C_CREDIT, W_TAX FROM CUSTOMER, WAREHOUSE "
+                "WHERE W_ID = ? AND C_W_ID = W_ID AND C_D_ID = ? AND C_ID = ?;";
+        if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+            throw "SQL Error: Failed to prepare customer and warehouse details query.";
+        }
+        sqlite3_bind_int(stmt, 1, W_ID);
+        sqlite3_bind_int(stmt, 2, D_ID);
+        sqlite3_bind_int(stmt, 3, C_ID);
+
+        if (sqlite3_step(stmt) == SQLITE_ROW) {
+            C_DISCOUNT = sqlite3_column_double(stmt, 0);
+            C_LAST = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+            C_CREDIT = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+            W_TAX = sqlite3_column_double(stmt, 3);
+        } else {
+            LOG(ERROR) << "W_ID: " << W_ID << " D_ID: " << D_ID << " C_ID: " << C_ID;
+            throw "SQL Error: Unable to fetch customer and warehouse details.";
+        }
+        sqlite3_finalize(stmt);
+
+        // Fetch district details
+        query = "SELECT D_NEXT_O_ID, D_TAX FROM DISTRICT WHERE D_ID = ? AND D_W_ID = ?;";
+        if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+            throw "SQL Error: Failed to prepare district details query.";
+        }
+        sqlite3_bind_int(stmt, 1, D_ID);
+        sqlite3_bind_int(stmt, 2, W_ID);
+
+        if (sqlite3_step(stmt) == SQLITE_ROW) {
+            D_NEXT_O_ID = sqlite3_column_int(stmt, 0);
+            D_TAX = sqlite3_column_double(stmt, 1);
+        } else {
+            throw "SQL Error: Unable to fetch district details.";
+        }
+        sqlite3_finalize(stmt);
+
+        // Update district next order ID
+        O_ID = D_NEXT_O_ID;
+        query = "UPDATE DISTRICT SET D_NEXT_O_ID = ? WHERE D_ID = ? AND D_W_ID = ?;";
+        if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+            throw "SQL Error: Failed to prepare update district next order ID query.";
+        }
+        sqlite3_bind_int(stmt, 1, D_NEXT_O_ID + 1);
+        sqlite3_bind_int(stmt, 2, D_ID);
+        sqlite3_bind_int(stmt, 3, W_ID);
+
+        if (sqlite3_step(stmt) != SQLITE_DONE) {
+            throw "SQL Error: Failed to update district next order ID.";
+        }
+        sqlite3_finalize(stmt);
+
+        // Process each order line
+        TOTAL = 0;
+
+        for (int OL_NUMBER = 1; OL_NUMBER <= O_OL_CNT; OL_NUMBER++) {
+            OL_SUPPLY_W_ID = SUPWARE[OL_NUMBER - 1];
+            if (OL_SUPPLY_W_ID != W_ID) O_ALL_LOCAL = 0;
+
+            OL_I_ID = ITEMID[OL_NUMBER - 1];
+            OL_QUANTITY = QTY[OL_NUMBER - 1];
+
+            // Fetch item details
+            query = "SELECT I_PRICE, I_NAME, I_DATA FROM ITEM WHERE I_ID = ?;";
+            if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+                throw "SQL Error: Failed to prepare item details query.";
+            }
+            sqlite3_bind_int(stmt, 1, OL_I_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                I_PRICE = sqlite3_column_double(stmt, 0);
+                I_NAME = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+                I_DATA = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+            } else {
+                throw "SQL Error: Invalid item ID.";
+            }
+            sqlite3_finalize(stmt);
+
+            PRICE[OL_NUMBER - 1] = I_PRICE;
+            INAME[OL_NUMBER - 1] = I_NAME;
+
+            // Fetch stock details
+            query = "SELECT S_QUANTITY, S_DATA FROM STOCK WHERE S_I_ID = ? AND S_W_ID = ?;";
+            if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+                throw "SQL Error: Failed to prepare stock details query.";
+            }
+            sqlite3_bind_int(stmt, 1, OL_I_ID);
+            sqlite3_bind_int(stmt, 2, OL_SUPPLY_W_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                S_QUANTITY = sqlite3_column_int(stmt, 0);
+                S_DATA = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+            } else {
+                throw "SQL Error: Unable to fetch stock details.";
+            }
+            sqlite3_finalize(stmt);
+
+            STOCK[OL_NUMBER - 1] = S_QUANTITY;
+            BG[OL_NUMBER - 1] = (I_DATA.find("original") != std::string::npos && S_DATA.find("original") != std::string::npos) ? 'B' : 'G';
+
+            if (S_QUANTITY > OL_QUANTITY) {
+                S_QUANTITY -= OL_QUANTITY;
+            } else {
+                S_QUANTITY = S_QUANTITY - OL_QUANTITY + 91;
+            }
+
+            // Update stock quantity
+            query = "UPDATE STOCK SET S_QUANTITY = ? WHERE S_I_ID = ? AND S_W_ID = ?;";
+            if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+                throw "SQL Error: Failed to prepare update stock quantity query.";
+            }
+            sqlite3_bind_int(stmt, 1, S_QUANTITY);
+            sqlite3_bind_int(stmt, 2, OL_I_ID);
+            sqlite3_bind_int(stmt, 3, OL_SUPPLY_W_ID);
+
+            if (sqlite3_step(stmt) != SQLITE_DONE) {
+                throw "SQL Error: Failed to update stock quantity.";
+            }
+            sqlite3_finalize(stmt);
+
+            OL_AMOUNT = OL_QUANTITY * I_PRICE * (1 + W_TAX + D_TAX) * (1 - C_DISCOUNT);
+            AMT[OL_NUMBER - 1] = OL_AMOUNT;
+            TOTAL += OL_AMOUNT;
+
+            // Insert into ORDER_LINE
+            query = "INSERT INTO ORDER_LINE (OL_O_ID, OL_D_ID, OL_W_ID, OL_NUMBER, OL_I_ID, OL_SUPPLY_W_ID, OL_QUANTITY, OL_AMOUNT, OL_DELIVERY_D) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 'null');";
+            if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+                throw "SQL Error: Failed to prepare insert into ORDER_LINE query.";
+            }
+            sqlite3_bind_int(stmt, 1, O_ID);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+            sqlite3_bind_int(stmt, 4, OL_NUMBER);
+            sqlite3_bind_int(stmt, 5, OL_I_ID);
+            sqlite3_bind_int(stmt, 6, OL_SUPPLY_W_ID);
+            sqlite3_bind_int(stmt, 7, OL_QUANTITY);
+            sqlite3_bind_double(stmt, 8, OL_AMOUNT);
+
+            if (sqlite3_step(stmt) != SQLITE_DONE) {
+                throw "SQL Error: Failed to insert into ORDER_LINE.";
+            }
+            sqlite3_finalize(stmt);
+        }
+
+        // Insert into ORDERS
+        query = "INSERT INTO ORDERS (O_ID, O_D_ID, O_W_ID, O_C_ID, O_ENTRY_D, O_OL_CNT, O_ALL_LOCAL) VALUES (?, ?, ?, ?, ?, ?, ?);";
+        if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+            throw "SQL Error: Failed to prepare insert into ORDERS query.";
+        }
+        sqlite3_bind_int(stmt, 1, O_ID);
+        sqlite3_bind_int(stmt, 2, D_ID);
+        sqlite3_bind_int(stmt, 3, W_ID);
+        sqlite3_bind_int(stmt, 4, C_ID);
+        sqlite3_bind_text(stmt, 5, DATETIME.c_str(), -1, SQLITE_STATIC);
+        sqlite3_bind_int(stmt, 6, O_OL_CNT);
+        sqlite3_bind_int(stmt, 7, O_ALL_LOCAL);
+
+        if (sqlite3_step(stmt) != SQLITE_DONE) {
+            throw "SQL Error: Failed to insert into ORDERS.";
+        }
+        sqlite3_finalize(stmt);
+
+        // Insert into NEW_ORDER
+        query = "INSERT INTO NEW_ORDER (NO_O_ID, NO_D_ID, NO_W_ID) VALUES (?, ?, ?);";
+        if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+            throw "SQL Error: Failed to prepare insert into NEW_ORDER query.";
+        }
+        sqlite3_bind_int(stmt, 1, O_ID);
+        sqlite3_bind_int(stmt, 2, D_ID);
+        sqlite3_bind_int(stmt, 3, W_ID);
+
+        if (sqlite3_step(stmt) != SQLITE_DONE) {
+            throw "SQL Error: Failed to insert into NEW_ORDER.";
+        }
+        sqlite3_finalize(stmt);
+
+        // Commit transaction
+        if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            throw "SQL Error: Failed to commit transaction.";
+        }
+
+        // Prepare the result string
+        std::ostringstream result;
+        result << "Order Summary:\n";
+        result << "O_ID: " << O_ID << "\n";
+        result << "DATETIME: " << DATETIME << "\n";
+        result << "O_ALL_LOCAL: " << O_ALL_LOCAL << "\n";
+        result << "Line Items:\n";
+        for (int i = 0; i < O_OL_CNT; ++i) {
+            result << "  Item " << (i + 1) << ":\n";
+            result << "    SUPWARE: " << SUPWARE[i] << "\n";
+            result << "    ITEMID: " << ITEMID[i] << "\n";
+            result << "    QTY: " << QTY[i] << "\n";
+            result << "    PRICE: " << std::fixed << std::setprecision(2) << PRICE[i] << "\n";
+            result << "    INAME: " << INAME[i] << "\n";
+            result << "    BG: " << BG[i] << "\n";
+            result << "    OL_AMOUNT: " << std::fixed << std::setprecision(2) << AMT[i] << "\n";
+        }
+        result << "TOTAL: " << std::fixed << std::setprecision(2) << TOTAL << "\n";
+
+        return result.str();
+    } catch (const char* msg) {
+        std::cerr << msg << std::endl;
+        sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+        return std::string("Error: ") + msg;
+    }
+}
+
+
+std::string TpccExecutor::SQLITE3_PAYMENT(sqlite3* db, int W_ID, int D_ID, int C_W_ID, int C_D_ID, int C_ID, double H_AMOUNT, std::string H_DATE, std::string C_LAST, bool BYNAME) {
+    try {
+        // Start the transaction
+        if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            std::string error_msg = "Failed to begin transaction: " + std::string(sqlite3_errmsg(db));
+            return error_msg;
+        }
+
+        sqlite3_stmt* stmt;
+        int NAMECNT = 0;
+
+        // Update WAREHOUSE
+        std::string query = "UPDATE WAREHOUSE SET W_YTD = W_YTD + ? WHERE W_ID = ?;";
+        sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_double(stmt, 1, H_AMOUNT);
+        sqlite3_bind_int(stmt, 2, W_ID);
+
+        if (sqlite3_step(stmt) != SQLITE_DONE) {
+            std::string error_msg = "SQL Error: Unable to update warehouse. " + std::string(sqlite3_errmsg(db));
+            sqlite3_finalize(stmt);
+            return error_msg;
+        }
+        sqlite3_finalize(stmt);
+
+        // Fetch WAREHOUSE DATA
+        std::string W_STREET_1, W_STREET_2, W_CITY, W_STATE, W_ZIP, W_NAME;
+        query = "SELECT W_STREET_1, W_STREET_2, W_CITY, W_STATE, W_ZIP, W_NAME FROM WAREHOUSE WHERE W_ID = ?;";
+        sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_int(stmt, 1, W_ID);
+
+        if (sqlite3_step(stmt) == SQLITE_ROW) {
+            W_STREET_1 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
+            W_STREET_2 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+            W_CITY = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+            W_STATE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
+            W_ZIP = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 4));
+            W_NAME = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 5));
+        } else {
+            sqlite3_finalize(stmt);
+            return "SQL Error: Failed to fetch WAREHOUSE data.";
+        }
+        sqlite3_finalize(stmt);
+
+        // Update DISTRICT
+        query = "UPDATE DISTRICT SET D_YTD = D_YTD + ? WHERE D_W_ID = ? AND D_ID = ?;";
+        sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_double(stmt, 1, H_AMOUNT);
+        sqlite3_bind_int(stmt, 2, W_ID);
+        sqlite3_bind_int(stmt, 3, D_ID);
+
+        if (sqlite3_step(stmt) != SQLITE_DONE) {
+            std::string error_msg = "SQL Error: Unable to update district. " + std::string(sqlite3_errmsg(db));
+            sqlite3_finalize(stmt);
+            return error_msg;
+        }
+        sqlite3_finalize(stmt);
+
+        // Fetch DISTRICT DATA
+        std::string D_STREET_1, D_STREET_2, D_CITY, D_STATE, D_ZIP, D_NAME;
+        query = "SELECT D_STREET_1, D_STREET_2, D_CITY, D_STATE, D_ZIP, D_NAME FROM DISTRICT WHERE D_W_ID = ? AND D_ID=?;";
+        sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_int(stmt, 1, W_ID);
+        sqlite3_bind_int(stmt, 2, D_ID);
+
+        if (sqlite3_step(stmt) == SQLITE_ROW) {
+            D_STREET_1 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
+            D_STREET_2 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+            D_CITY = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+            D_STATE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
+            D_ZIP = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 4));
+            D_NAME = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 5));
+        } else {
+            fflush(stdout);
+            throw "SQL Error: Payment(): Fail to Fetch WAREHOUSE DATA.";
+        }
+        sqlite3_finalize(stmt);
+
+        std::string C_FIRST, C_MIDDLE, C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, C_PHONE, C_CREDIT, C_SINCE;
+        double C_CREDIT_LIM, C_DISCOUNT, C_BALANCE;
+
+        if (BYNAME) {
+            // Step 1: Get the number of customers with the same last name
+            query = "SELECT COUNT(C_ID) FROM CUSTOMER WHERE C_LAST = ? AND C_D_ID = ? AND C_W_ID = ?;";
+            sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_text(stmt, 1, C_LAST.c_str(), -1, SQLITE_TRANSIENT);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                NAMECNT = sqlite3_column_int(stmt, 0);
+            } else {
+                throw std::runtime_error("SQL Error: Unable to fetch customer count.");
+            }
+            sqlite3_finalize(stmt);
+
+            // Step 2: Fetch midpoint customer details
+            query = "SELECT C_ID, C_FIRST, C_MIDDLE, C_LAST, C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, C_PHONE, C_CREDIT, C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_SINCE FROM CUSTOMER WHERE C_LAST = ? AND C_D_ID = ? AND C_W_ID = ? ORDER BY C_FIRST;";
+            sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_text(stmt, 1, C_LAST.c_str(), -1, SQLITE_TRANSIENT);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+
+            if (NAMECNT % 2 == 1) NAMECNT++;
+            for (int N = 0; N < NAMECNT / 2; ++N) {
+                if (sqlite3_step(stmt) == SQLITE_ROW) {
+                C_ID = sqlite3_column_int(stmt, 0);
+                C_FIRST = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+                C_MIDDLE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+                C_LAST = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
+                C_STREET_1 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 4));
+                C_STREET_2 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 5));
+                C_CITY = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 6));
+                C_STATE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 7));
+                C_ZIP = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 8));
+                C_PHONE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 9));
+                C_CREDIT = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 10));
+                C_CREDIT_LIM = sqlite3_column_double(stmt, 11);
+                C_DISCOUNT = sqlite3_column_double(stmt, 12);
+                C_BALANCE = sqlite3_column_double(stmt, 13);
+                C_SINCE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 14));
+                } else {
+                    throw std::runtime_error("SQL Error: Unable to fetch customer details.");
+                }
+            }
+            sqlite3_finalize(stmt);
+        } 
+        else {
+            query = "SELECT C_FIRST, C_MIDDLE, C_LAST, C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, C_PHONE, C_CREDIT, C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_SINCE FROM CUSTOMER WHERE C_W_ID = ? AND C_D_ID = ? AND C_ID = ?";
+            sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_int(stmt, 1, C_W_ID);
+            sqlite3_bind_int(stmt, 2, C_D_ID);
+            sqlite3_bind_int(stmt, 3, C_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                C_FIRST = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
+                C_MIDDLE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+                C_LAST = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+                C_STREET_1 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
+                C_STREET_2 = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 4));
+                C_CITY = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 5));
+                C_STATE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 6));
+                C_ZIP = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 7));
+                C_PHONE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 8));
+                C_CREDIT = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 9));
+                C_CREDIT_LIM = sqlite3_column_double(stmt, 10);
+                C_DISCOUNT = sqlite3_column_double(stmt, 11);
+                C_BALANCE = sqlite3_column_double(stmt, 12);
+                C_SINCE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 13));
+            } else {
+                std::cerr << "No midpoint customer found." << std::endl;
+            }
+
+            sqlite3_finalize(stmt);
+        }
+
+        if (C_CREDIT == "BC") {
+            std::string C_DATA;
+            query = "SELECT C_DATA FROM CUSTOMER WHERE C_W_ID = ? AND C_D_ID = ? AND C_ID = ?;";
+            sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_int(stmt, 1, C_W_ID);
+            sqlite3_bind_int(stmt, 2, C_D_ID);
+            sqlite3_bind_int(stmt, 3, C_ID);
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                C_DATA = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
+            } else {
+                std::cerr << "Fail to find c_data with C_ID " << C_ID  << std::endl;
+            }
+            sqlite3_finalize(stmt);
+            std::string C_NEW_DATA = createNewData(C_ID, C_D_ID, C_W_ID, D_ID, W_ID, H_AMOUNT, C_DATA);
+
+            // Update CUSTOMER balance
+            query = "UPDATE CUSTOMER SET C_BALANCE = C_BALANCE + ? , C_DATA = ? WHERE C_W_ID = ? AND C_D_ID = ? AND C_ID = ?;";
+            sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_double(stmt, 1, H_AMOUNT);
+            sqlite3_bind_text(stmt, 2, C_NEW_DATA.c_str(), -1, SQLITE_STATIC);
+            sqlite3_bind_int(stmt, 3, W_ID);
+            sqlite3_bind_int(stmt, 4, D_ID);
+            sqlite3_bind_int(stmt, 5, C_ID);
+        } else {
+            // Update CUSTOMER balance
+            query = "UPDATE CUSTOMER SET C_BALANCE = C_BALANCE + ? WHERE C_W_ID = ? AND C_D_ID = ? AND C_ID = ?;";
+            sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_double(stmt, 1, H_AMOUNT);
+            sqlite3_bind_int(stmt, 2, C_W_ID);
+            sqlite3_bind_int(stmt, 3, C_D_ID);
+            sqlite3_bind_int(stmt, 4, C_ID);
+        }
+
+        if (sqlite3_step(stmt) != SQLITE_DONE) {
+            throw std::runtime_error("SQL Error: Unable to update customer balance.");
+        }
+        sqlite3_finalize(stmt);
+
+        // Insert into HISTORY
+        query = "INSERT INTO HISTORY (H_C_D_ID, H_C_W_ID, H_C_ID, H_D_ID, H_W_ID, H_DATE, H_AMOUNT, H_DATA) VALUES (?, ?, ?, ?, ?, ?, ?, 'Payment');";
+        std::string H_DATA = W_NAME + "\0" + D_NAME + "    ";
+        sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_int(stmt, 1, C_D_ID);
+        sqlite3_bind_int(stmt, 2, C_W_ID);
+        sqlite3_bind_int(stmt, 3, C_ID);
+        sqlite3_bind_int(stmt, 4, D_ID);
+        sqlite3_bind_int(stmt, 5, W_ID);
+        sqlite3_bind_text(stmt, 6, H_DATE.c_str(), -1, SQLITE_STATIC);
+        sqlite3_bind_double(stmt, 7, H_AMOUNT);
+        sqlite3_bind_text(stmt, 8, H_DATA.c_str(), -1, SQLITE_STATIC);
+
+        if (sqlite3_step(stmt) != SQLITE_DONE) {
+            throw std::runtime_error("SQL Error: Unable to insert into history.");
+        }
+        sqlite3_finalize(stmt);
+
+        // Commit transaction
+        if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            std::string error_msg = "SQL Error: Failed to commit transaction. " + std::string(sqlite3_errmsg(db));
+            return error_msg;
+        }
+        // Success message
+        return "Payment processed successfully for Customer " + std::to_string(C_ID) + ": " + C_LAST + ".\n";  
+    } catch (const std::exception& e) {
+        // Rollback transaction on error
+        sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+        return "Error: " + std::string(e.what());  // Return the error message
+    }
+}
+
+
+
+std::string TpccExecutor::SQLITE3_ORDER_STATUS(sqlite3* db, int W_ID, int D_ID, int C_ID, const std::string& C_LAST, bool BYNAME) {
+    std::ostringstream result;
+    try {
+        // Start the transaction
+        if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            throw std::runtime_error("Failed to begin transaction: " + std::string(sqlite3_errmsg(db)));
+        }
+
+        sqlite3_stmt* stmt = nullptr;
+        int NAMECNT = 0;
+        double C_BALANCE = 0.0;
+        std::string C_FIRST, C_MIDDLE;
+        int O_ID = 0, O_CARRIER_ID = 0;
+        std::string ENTDATE;
+        std::vector<int> OL_I_ID, OL_SUPPLY_W_ID, OL_QUANTITY;
+        std::vector<double> OL_AMOUNT;
+        std::vector<std::string> OL_DELIVERY_D;
+
+        if (BYNAME) {
+            // Step 1: Get the count of customers with the same last name
+            const std::string query_count = "SELECT COUNT(C_ID) FROM CUSTOMER WHERE C_LAST = ? AND C_D_ID = ? AND C_W_ID = ?;";
+            if (sqlite3_prepare_v2(db, query_count.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+                throw std::runtime_error("SQL Error: Failed to prepare query_count.");
+            }
+            sqlite3_bind_text(stmt, 1, C_LAST.c_str(), -1, SQLITE_TRANSIENT);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                NAMECNT = sqlite3_column_int(stmt, 0);
+            } else {
+                throw std::runtime_error("SQL Error: Unable to fetch customer count.");
+            }
+            sqlite3_finalize(stmt);
+
+            if (NAMECNT == 0) return "No customers found with the given last name.";
+
+            // Step 2: Fetch the midpoint customer
+            int midpoint = (NAMECNT - 1) / 2; // Midpoint (0-indexed)
+            const std::string query_customer = "SELECT C_BALANCE, C_FIRST, C_MIDDLE, C_ID FROM CUSTOMER WHERE C_LAST = ? AND C_D_ID = ? AND C_W_ID = ? ORDER BY C_FIRST LIMIT 1 OFFSET ?;";
+            sqlite3_prepare_v2(db, query_customer.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_text(stmt, 1, C_LAST.c_str(), -1, SQLITE_TRANSIENT);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+            sqlite3_bind_int(stmt, 4, midpoint);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                C_BALANCE = sqlite3_column_double(stmt, 0);
+                C_FIRST = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+                C_MIDDLE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+                C_ID = sqlite3_column_int(stmt, 3);
+            } else {
+                throw std::runtime_error("SQL Error: Unable to fetch midpoint customer.");
+            }
+            sqlite3_finalize(stmt);
+        } else {
+            // Fetch customer details by C_ID
+            const std::string query_customer_by_id = "SELECT C_BALANCE, C_FIRST, C_MIDDLE FROM CUSTOMER WHERE C_ID = ? AND C_D_ID = ? AND C_W_ID = ?;";
+            sqlite3_prepare_v2(db, query_customer_by_id.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_int(stmt, 1, C_ID);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                C_BALANCE = sqlite3_column_double(stmt, 0);
+                C_FIRST = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
+                C_MIDDLE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+            } else {
+                throw std::runtime_error("SQL Error: Unable to fetch customer details.");
+            }
+            sqlite3_finalize(stmt);
+        }
+
+        result << "Customer: " << C_FIRST << " " << C_MIDDLE << " " << C_LAST
+               << "\nBalance: " << C_BALANCE << "\n";
+
+        // Step 3: Get the most recent order
+        const std::string query_order = "SELECT O_ID, O_CARRIER_ID, O_ENTRY_D FROM ORDERS WHERE O_D_ID = ? AND O_W_ID = ? AND O_C_ID = ? ORDER BY O_ID DESC LIMIT 1;";
+        sqlite3_prepare_v2(db, query_order.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_int(stmt, 1, D_ID);
+        sqlite3_bind_int(stmt, 2, W_ID);
+        sqlite3_bind_int(stmt, 3, C_ID);
+
+        if (sqlite3_step(stmt) == SQLITE_ROW) {
+            O_ID = sqlite3_column_int(stmt, 0);
+            O_CARRIER_ID = sqlite3_column_int(stmt, 1);
+            ENTDATE = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
+        } else {
+            throw std::runtime_error("SQL Error: Unable to fetch most recent order.");
+        }
+        sqlite3_finalize(stmt);
+
+        result << "Most Recent Order: " << O_ID
+               << "\nCarrier ID: " << O_CARRIER_ID
+               << "\nEntry Date: " << ENTDATE << "\n";
+
+        // Step 4: Get order line details
+        const std::string query_order_line = "SELECT OL_I_ID, OL_SUPPLY_W_ID, OL_QUANTITY, OL_AMOUNT, OL_DELIVERY_D FROM ORDER_LINE WHERE OL_O_ID = ? AND OL_D_ID = ? AND OL_W_ID = ?;";
+        sqlite3_prepare_v2(db, query_order_line.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_int(stmt, 1, O_ID);
+        sqlite3_bind_int(stmt, 2, D_ID);
+        sqlite3_bind_int(stmt, 3, W_ID);
+
+        result << "Order Lines:\n";
+        while (sqlite3_step(stmt) == SQLITE_ROW) {
+            result << "  Item ID: " << sqlite3_column_int(stmt, 0)
+                   << ", Supply W_ID: " << sqlite3_column_int(stmt, 1)
+                   << ", Quantity: " << sqlite3_column_int(stmt, 2)
+                   << ", Amount: " << sqlite3_column_double(stmt, 3)
+                   << ", Delivery Date: " << reinterpret_cast<const char*>(sqlite3_column_text(stmt, 4)) << "\n";
+        }
+        sqlite3_finalize(stmt);
+
+        // Commit transaction
+        sqlite3_exec(db, "COMMIT;", nullptr, nullptr, nullptr);
+    } catch (const std::exception& E) {
+        sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+        return std::string("Error: ") + E.what();
+    }
+
+    return result.str();
+}
+
+
+
+std::string TpccExecutor::SQLITE3_DELIVERY(sqlite3* db, int W_ID, int O_CARRIER_ID, const std::string& DATETIME) {
+    try {
+        // Start the transaction
+        if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            return std::string("Failed to begin transaction: ") + sqlite3_errmsg(db);
+        }
+
+        sqlite3_stmt* stmt = nullptr;
+        int D_ID, NO_O_ID, C_ID;
+        double OL_TOTAL;
+
+        for (D_ID = 1; D_ID <= 10; ++D_ID) {
+            // Step 1: Find the oldest unprocessed order
+            const std::string query1 = "SELECT NO_O_ID FROM NEW_ORDER WHERE NO_D_ID = ? AND NO_W_ID = ? ORDER BY NO_O_ID ASC LIMIT 1;";
+            if (sqlite3_prepare_v2(db, query1.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
+                return std::string("SQL Error: Unable to prepare query1.");
+            }
+            sqlite3_bind_int(stmt, 1, D_ID);
+            sqlite3_bind_int(stmt, 2, W_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                NO_O_ID = sqlite3_column_int(stmt, 0);
+            } else {
+                sqlite3_finalize(stmt);
+                continue;  // No new orders in this district
+            }
+            sqlite3_finalize(stmt);
+
+            // Step 2: Delete the new order
+            const std::string query2 = "DELETE FROM NEW_ORDER WHERE NO_O_ID = ? AND NO_D_ID = ? AND NO_W_ID = ?;";
+            sqlite3_prepare_v2(db, query2.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_int(stmt, 1, NO_O_ID);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+            if (sqlite3_step(stmt) != SQLITE_DONE) {
+                sqlite3_finalize(stmt);
+                return std::string("SQL Error: Failed to delete from NEW_ORDER.");
+            }
+            sqlite3_finalize(stmt);
+
+            // Step 3: Get the customer ID from the order
+            const std::string query3 = "SELECT O_C_ID FROM ORDERS WHERE O_ID = ? AND O_D_ID = ? AND O_W_ID = ?;";
+            sqlite3_prepare_v2(db, query3.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_int(stmt, 1, NO_O_ID);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                C_ID = sqlite3_column_int(stmt, 0);
+            } else {
+                sqlite3_finalize(stmt);
+                return std::string("SQL Error: Unable to fetch customer ID.");
+            }
+            sqlite3_finalize(stmt);
+
+            // Step 4: Update the order with the carrier ID
+            const std::string query4 = "UPDATE ORDERS SET O_CARRIER_ID = ? WHERE O_ID = ? AND O_D_ID = ? AND O_W_ID = ?;";
+            sqlite3_prepare_v2(db, query4.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_int(stmt, 1, O_CARRIER_ID);
+            sqlite3_bind_int(stmt, 2, NO_O_ID);
+            sqlite3_bind_int(stmt, 3, D_ID);
+            sqlite3_bind_int(stmt, 4, W_ID);
+            if (sqlite3_step(stmt) != SQLITE_DONE) {
+                sqlite3_finalize(stmt);
+                return std::string("SQL Error: Failed to update carrier ID.");
+            }
+            sqlite3_finalize(stmt);
+
+            // Step 5: Update order line with delivery date
+            const std::string query5 = "UPDATE ORDER_LINE SET OL_DELIVERY_D = ? WHERE OL_O_ID = ? AND OL_D_ID = ? AND OL_W_ID = ?;";
+            sqlite3_prepare_v2(db, query5.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_text(stmt, 1, DATETIME.c_str(), -1, SQLITE_TRANSIENT);
+            sqlite3_bind_int(stmt, 2, NO_O_ID);
+            sqlite3_bind_int(stmt, 3, D_ID);
+            sqlite3_bind_int(stmt, 4, W_ID);
+            if (sqlite3_step(stmt) != SQLITE_DONE) {
+                sqlite3_finalize(stmt);
+                return std::string("SQL Error: Failed to update delivery date.");
+            }
+            sqlite3_finalize(stmt);
+
+            // Step 6: Calculate total order line amount
+            const std::string query6 = "SELECT SUM(OL_AMOUNT) FROM ORDER_LINE WHERE OL_O_ID = ? AND OL_D_ID = ? AND OL_W_ID = ?;";
+            sqlite3_prepare_v2(db, query6.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_int(stmt, 1, NO_O_ID);
+            sqlite3_bind_int(stmt, 2, D_ID);
+            sqlite3_bind_int(stmt, 3, W_ID);
+
+            if (sqlite3_step(stmt) == SQLITE_ROW) {
+                OL_TOTAL = sqlite3_column_double(stmt, 0);
+            } else {
+                sqlite3_finalize(stmt);
+                return std::string("SQL Error: Unable to calculate total.");
+            }
+            sqlite3_finalize(stmt);
+
+            // Step 7: Update the customer's balance
+            const std::string query7 = "UPDATE CUSTOMER SET C_BALANCE = C_BALANCE + ? WHERE C_ID = ? AND C_D_ID = ? AND C_W_ID = ?;";
+            sqlite3_prepare_v2(db, query7.c_str(), -1, &stmt, nullptr);
+            sqlite3_bind_double(stmt, 1, OL_TOTAL);
+            sqlite3_bind_int(stmt, 2, C_ID);
+            sqlite3_bind_int(stmt, 3, D_ID);
+            sqlite3_bind_int(stmt, 4, W_ID);
+            if (sqlite3_step(stmt) != SQLITE_DONE) {
+                sqlite3_finalize(stmt);
+                return std::string("SQL Error: Failed to update customer balance.");
+            }
+            sqlite3_finalize(stmt);
+        }
+
+        // Commit transaction
+        if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            return std::string("SQL Error: Failed to commit transaction.");
+        }
+
+        return "DELIVERY by CARRIER " + std::to_string(O_CARRIER_ID) + " is completed successfully.";
+
+    } catch (const std::exception& E) {
+        sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+        return std::string("Error: ") + E.what();
+    }
+}
+
+
+
+std::string TpccExecutor::SQLITE3_STOCK_LEVEL(sqlite3* db, int W_ID, int D_ID, int THRESHOLD) {
+    try {
+        // Start the transaction
+        if (sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            throw std::runtime_error(std::string("Failed to begin transaction: ") + sqlite3_errmsg(db));
+        }
+
+        sqlite3_stmt* stmt;
+        int O_ID;
+        int STOCK_COUNT;
+
+        // Step 1: Retrieve the next order ID from the district
+        std::string query = "SELECT D_NEXT_O_ID FROM DISTRICT WHERE D_W_ID = ? AND D_ID = ?;";
+        sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_int(stmt, 1, W_ID);
+        sqlite3_bind_int(stmt, 2, D_ID);
+
+        if (sqlite3_step(stmt) == SQLITE_ROW) {
+            O_ID = sqlite3_column_int(stmt, 0);
+        } else {
+            sqlite3_finalize(stmt);
+            throw std::runtime_error("SQL Error: Unable to fetch next order ID.");
+        }
+        sqlite3_finalize(stmt);
+
+        // Step 2: Count distinct stock items below the threshold
+        query = "SELECT COUNT(DISTINCT S_I_ID) "
+                "FROM ORDER_LINE, STOCK "
+                "WHERE OL_W_ID = ? AND OL_D_ID = ? "
+                "AND OL_O_ID < ? AND OL_O_ID >= ? "
+                "AND S_W_ID = ? AND S_I_ID = OL_I_ID "
+                "AND S_QUANTITY < ?;";
+        sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, nullptr);
+        sqlite3_bind_int(stmt, 1, W_ID);
+        sqlite3_bind_int(stmt, 2, D_ID);
+        sqlite3_bind_int(stmt, 3, O_ID);
+        sqlite3_bind_int(stmt, 4, O_ID - 20); // Use calculated range
+        sqlite3_bind_int(stmt, 5, W_ID);
+        sqlite3_bind_int(stmt, 6, THRESHOLD);
+
+        if (sqlite3_step(stmt) == SQLITE_ROW) {
+            STOCK_COUNT = sqlite3_column_int(stmt, 0);
+        } else {
+            sqlite3_finalize(stmt);
+            throw std::runtime_error("SQL Error: Unable to count stock items below threshold.");
+        }
+        sqlite3_finalize(stmt);
+
+        // Commit transaction
+        if (sqlite3_exec(db, "COMMIT;", nullptr, nullptr, nullptr) != SQLITE_OK) {
+            throw std::runtime_error("SQL Error: Failed to commit transaction.");
+        }
+
+        // Return the stock count as a string
+        return "Stock Level: " + std::to_string(STOCK_COUNT);
+
+    } catch (const std::exception& E) {
+        // Rollback transaction on error
+        sqlite3_exec(db, "ROLLBACK;", nullptr, nullptr, nullptr);
+        // Return the error message as a string
+        return std::string("Error: ") + E.what();
+    }
+}
+
+
+std::string TpccExecutor::createNewData(int c_id, int c_d_id, int c_w_id, int d_id, int w_id, 
+                   double h_amount, const std::string& c_data) {
+    // Using std::ostringstream for formatted strings
+    std::ostringstream oss;
+    oss << "| " 
+        << std::setw(4) << c_id << " "
+        << std::setw(2) << c_d_id << " "
+        << std::setw(4) << c_w_id << " "
+        << std::setw(2) << d_id << " "
+        << std::setw(4) << w_id << " $"
+        << std::fixed << std::setprecision(2) << std::setw(7) << h_amount << " ";
+
+    std::string c_new_data = oss.str();
+
+    // Ensure the length of c_new_data does not exceed 500 after concatenation
+    if (c_new_data.length() < 500) {
+        c_new_data += c_data.substr(0, 500 - c_new_data.length());
+    }
+
+    return c_new_data;
+}
+
+
+
+}
\ No newline at end of file
diff --git a/executor/common/tpcc_executor.h b/executor/common/tpcc_executor.h
new file mode 100644
index 00000000..dbb6db64
--- /dev/null
+++ b/executor/common/tpcc_executor.h
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include "sqlite3.h"
+#include "platform/proto/resdb.pb.h"
+
+namespace resdb {
+    
+class TpccExecutor {
+    public:
+        TpccExecutor();
+        ~TpccExecutor();
+        std::unique_ptr<std::string> ExecuteTransaction(TpccTransaction* tpcc_txn);
+
+    private:
+        sqlite3* loadDatabaseIntoMemory();
+
+        std::string ExecuteNewOrderTransaction(NewOrderTransaction* tpcc_txn);
+        std::string ExecutePaymentTransaction(PaymentTransaction* tpcc_txn);
+        std::string ExecuteOrderStatusTransaction(OrderStatusTransaction* tpcc_txn);
+        std::string ExecuteDeliveryTransaction(DeliveryTransaction* tpcc_txn);
+        std::string ExecuteStockLevelTransaction(StockLevelTransaction* tpcc_txn);
+
+        std::string SQLITE3_NEW_ORDER(sqlite3* db, int W_ID, int D_ID, int C_ID, int O_OL_CNT, std::vector<int>& SUPWARE, std::vector<int>& ITEMID, std::vector<int>& QTY, std::string DATETIME);
+        std::string SQLITE3_PAYMENT(sqlite3* db, int W_ID, int D_ID, int C_W_ID, int C_D_ID, int C_ID, double H_AMOUNT, std::string H_DATE, std::string C_LAST, bool BYNAME);
+        std::string SQLITE3_ORDER_STATUS(sqlite3* db, int W_ID, int D_ID, int C_ID, const std::string& C_LAST, bool BYNAME);
+        std::string SQLITE3_DELIVERY(sqlite3* db, int W_ID, int O_CARRIER_ID, const std::string& DATETIME);
+        std::string SQLITE3_STOCK_LEVEL(sqlite3* db, int W_ID, int D_ID, int THRESHOLD);
+
+        std::string createNewData(int c_id, int c_d_id, int c_w_id, int d_id, int w_id, 
+                   double h_amount, const std::string& c_data);
+
+        sqlite3* db = nullptr;
+        const std::string& dbFilePath = "./tpcc.db";
+};
+
+}
+
diff --git a/executor/common/transaction_manager.cpp b/executor/common/transaction_manager.cpp
index 74df05c9..0f5f4fc1 100644
--- a/executor/common/transaction_manager.cpp
+++ b/executor/common/transaction_manager.cpp
@@ -24,7 +24,9 @@
 namespace resdb {
 
 TransactionManager::TransactionManager(bool is_out_of_order, bool need_response)
-    : is_out_of_order_(is_out_of_order), need_response_(need_response) {}
+    : is_out_of_order_(is_out_of_order), need_response_(need_response) {
+      // tpcc_executor_ = std::make_unique<TpccExecutor>();
+    }
 
 bool TransactionManager::IsOutOfOrder() { return is_out_of_order_; }
 
@@ -84,8 +86,7 @@ std::unique_ptr<BatchUserResponse> TransactionManager::ExecuteBatch(
   std::unique_ptr<BatchUserResponse> batch_response =
       std::make_unique<BatchUserResponse>();
   for (auto& sub_request : request.user_requests()) {
-    std::unique_ptr<std::string> response =
-        ExecuteData(sub_request.request().data());
+    std::unique_ptr<std::string> response = ExecuteData(sub_request.request().data());
     if (response == nullptr) {
       response = std::make_unique<std::string>();
     }
@@ -95,4 +96,26 @@ std::unique_ptr<BatchUserResponse> TransactionManager::ExecuteBatch(
   return batch_response;
 }
 
+
+std::unique_ptr<BatchUserResponse> TransactionManager::ExecuteTPCCBatch(
+    BatchUserRequest& request) {
+  std::unique_ptr<BatchUserResponse> batch_response =
+      std::make_unique<BatchUserResponse>();
+  for (auto& sub_request : request.user_requests()) {
+    std::unique_ptr<std::string> response = nullptr;
+    if (sub_request.request().has_tpcc_txn()) {
+      auto non_const_request = sub_request.request();
+      response = tpcc_executor_->ExecuteTransaction(non_const_request.mutable_tpcc_txn());
+      // LOG(ERROR) << *response;
+    } 
+    if (response == nullptr) {
+      response = std::make_unique<std::string>();
+    }
+    batch_response->add_response()->swap(*response);
+  }
+
+  return batch_response;
+}
+
+
 }  // namespace resdb
diff --git a/executor/common/transaction_manager.h b/executor/common/transaction_manager.h
index b1d564ac..c61ee2e8 100644
--- a/executor/common/transaction_manager.h
+++ b/executor/common/transaction_manager.h
@@ -24,6 +24,8 @@
 #include "chain/storage/storage.h"
 #include "platform/proto/resdb.pb.h"
 
+#include "executor/common/tpcc_executor.h"
+
 namespace resdb {
 
 /*
@@ -39,6 +41,9 @@ class TransactionManager {
 
   virtual std::unique_ptr<BatchUserResponse> ExecuteBatch(
       const BatchUserRequest& request);
+  
+  virtual std::unique_ptr<BatchUserResponse> ExecuteTPCCBatch(
+        BatchUserRequest& request);
 
   std::unique_ptr<std::vector<std::unique_ptr<google::protobuf::Message>>>
   Prepare(const BatchUserRequest& request);
@@ -61,6 +66,7 @@ class TransactionManager {
  private:
   bool is_out_of_order_ = false;
   bool need_response_ = true;
+  std::unique_ptr<TpccExecutor> tpcc_executor_ = nullptr;
 };
 
 }  // namespace resdb
diff --git a/hotstuff1-extended-version.pdf b/hotstuff1-extended-version.pdf
new file mode 100644
index 00000000..611944b2
Binary files /dev/null and b/hotstuff1-extended-version.pdf differ
diff --git a/platform/common/queue/lock_free_queue.h b/platform/common/queue/lock_free_queue.h
index 1bbfe249..5a84edd9 100644
--- a/platform/common/queue/lock_free_queue.h
+++ b/platform/common/queue/lock_free_queue.h
@@ -49,10 +49,12 @@ class LockFreeQueue {
     }
   }
 
-  std::unique_ptr<T> Pop(int timeout_ms = 100) {
+  std::unique_ptr<T> Pop(int timeout_ms = 100, bool flag = false) {
     T* ret = nullptr;
     if (!queue_.pop(ret)) {
       if (timeout_ms > 0) {
+        if(flag)
+          LOG(ERROR) << "empty";
         std::unique_lock<std::mutex> lk(mutex_);
         need_notify_ = true;
         cv_.wait_for(lk, std::chrono::milliseconds(timeout_ms),
diff --git a/platform/config/resdb_config.cpp b/platform/config/resdb_config.cpp
index 08c011ab..1da5eaf3 100644
--- a/platform/config/resdb_config.cpp
+++ b/platform/config/resdb_config.cpp
@@ -253,4 +253,68 @@ void ResDBConfig::SetViewchangeCommitTimeout(uint64_t timeout_ms) {
   config_data_.set_view_change_timeout_ms(timeout_ms);
 }
 
+uint32_t ResDBConfig::GetSlotNum() const {
+  return config_data_.slot_num();
+}
+
+void ResDBConfig::SetSlotNum(uint64_t slot_num) {
+  config_data_.set_slot_num(slot_num);
+}
+
+uint32_t ResDBConfig::GetNonResponsiveNum() const {
+  return config_data_.non_responsive_num();
+}
+
+void ResDBConfig::SetNonResponsiveNum(uint64_t value) {
+  config_data_.set_non_responsive_num(value);
+}
+
+uint32_t ResDBConfig::GetForkTailNum() const {
+  return config_data_.fork_tail_num();
+}
+
+void ResDBConfig::SetForkTailNum(uint64_t value) {
+  config_data_.set_fork_tail_num(value);
+}
+
+uint32_t ResDBConfig::GetRollBackNum() const {
+  return config_data_.rollback_num();
+}
+
+void ResDBConfig::SetRollBackNum(uint64_t value) {
+  config_data_.set_rollback_num(value);
+}
+
+bool ResDBConfig::IsTpccEnabled() const {
+  return config_data_.tpcc_enabled();
+}
+
+void ResDBConfig::SetTpccEnabled(bool value) {
+  config_data_.set_tpcc_enabled(value);
+}
+
+int32_t ResDBConfig::NetworkDelayNum() const {
+  return config_data_.network_delay_num();
+}
+
+void ResDBConfig::SetNetworkDelayNum(int32_t value) {
+  config_data_.set_network_delay_num(value);
+}
+
+double ResDBConfig::MeanNetworkDelay() const {
+  return config_data_.mean_network_delay();
+}
+
+void ResDBConfig::SetMeanNetworkDelay(double value) {
+  config_data_.set_mean_network_delay(value);
+}
+
+uint32_t ResDBConfig::GetCrashNum() const {
+  return config_data_.crash_num();
+}
+
+void ResDBConfig::SetCrashNum(uint64_t value) {
+  config_data_.set_crash_num(value);
+}
+
 }  // namespace resdb
diff --git a/platform/config/resdb_config.h b/platform/config/resdb_config.h
index 0284ae9a..c7b5d5c7 100644
--- a/platform/config/resdb_config.h
+++ b/platform/config/resdb_config.h
@@ -121,6 +121,38 @@ class ResDBConfig {
   uint32_t GetViewchangeCommitTimeout() const;
   void SetViewchangeCommitTimeout(uint64_t timeout_ms);
 
+  // SlotHotStuff1 SlotNum
+  uint32_t GetSlotNum() const;
+  void SetSlotNum(uint64_t slot_num);
+
+  // SlotHotStuff1 Non Responsive Number
+  uint32_t GetNonResponsiveNum() const;
+  void SetNonResponsiveNum(uint64_t value);
+
+  // SlotHotStuff1 Fork-Tail Attack Number
+  uint32_t GetForkTailNum() const;
+  void SetForkTailNum(uint64_t value);
+
+  // SlotHotStuff1 RollBack Attack Number
+  uint32_t GetRollBackNum() const;
+  void SetRollBackNum(uint64_t value);
+
+  // If Tpcc Transaction is Enabled
+  bool IsTpccEnabled() const;
+  void SetTpccEnabled(bool value);
+
+  // If Network Delay Test is Enabled
+  int32_t NetworkDelayNum() const;
+  void SetNetworkDelayNum(int32_t value);
+
+  // Mean Network Delay
+  double MeanNetworkDelay() const;
+  void SetMeanNetworkDelay(double value);
+
+  // SlotHotStuff1 Crash Number
+  uint32_t GetCrashNum() const;
+  void SetCrashNum(uint64_t value);
+
  private:
   ResConfigData config_data_;
   std::vector<ReplicaInfo> replicas_;
@@ -135,14 +167,14 @@ class ResDBConfig {
   bool signature_verifier_enabled_ = true;
   bool is_performance_running_ = false;
   bool is_test_mode_ = false;
-  uint32_t client_batch_wait_time_ms_ = 100;  // milliseconds, 0.1s
+  uint32_t client_batch_wait_time_ms_ = 100;  // milliseconds, 1ms
   uint64_t viewchange_commit_timeout_ms_ =
       60000;  // default 60s to change viewchange
 
 
   // This is the default settings.
   // change these parameters in the configuration.
-  uint32_t max_process_txn_ = 64;
+  uint32_t max_process_txn_ = 0;
   uint32_t worker_num_ = 16;
   uint32_t input_worker_num_ = 5;
   uint32_t output_worker_num_ = 5;
diff --git a/platform/consensus/execution/transaction_executor.cpp b/platform/consensus/execution/transaction_executor.cpp
index a5ff4b12..f042ecaf 100644
--- a/platform/consensus/execution/transaction_executor.cpp
+++ b/platform/consensus/execution/transaction_executor.cpp
@@ -144,8 +144,7 @@ bool TransactionExecutor::NeedResponse() {
 int TransactionExecutor::Commit(std::unique_ptr<Request> message) {
   global_stats_->IncPendingExecute();
   if (transaction_manager_ && transaction_manager_->IsOutOfOrder()) {
-    // LOG(ERROR)<<"add out of order exe:"<<message->seq()<<" from
-    // proxy:"<<message->proxy_id();
+    // LOG(ERROR)<<"add out of order exe:"<<message->seq()<<" from proxy:"<<message->proxy_id();
     std::unique_ptr<Request> msg = std::make_unique<Request>(*message);
     execute_OOO_queue_.Push(std::move(message));
     commit_queue_.Push(std::move(msg));
@@ -178,8 +177,7 @@ void TransactionExecutor::OrderMessage() {
       global_stats_->IncExecute();
       uint64_t seq = message->seq();
       if (next_execute_seq_ > seq) {
-        // LOG(INFO) << "request seq:" << seq << " has been executed"
-        // << " next seq:" << next_execute_seq_;
+        // LOG(INFO) << "request seq:" << seq << " has been executed" << " next seq:" << next_execute_seq_;
         continue;
       }
 
@@ -202,7 +200,6 @@ void TransactionExecutor::OrderMessage() {
 }
 
 void TransactionExecutor::AddExecuteMessage(std::unique_ptr<Request> message) {
-    // LOG(ERROR) << "[AEM]";
     global_stats_->IncCommit();
     message->set_commit_time(GetCurrentTime());
     execute_queue_.Push(std::move(message));
@@ -339,7 +336,8 @@ void TransactionExecutor::Execute(std::unique_ptr<Request> request,
   }
   assert(batch_request_p);
 
-  // LOG(ERROR)<<"execute seq:"<<batch_request->seq()<<" proxy id:"<<request->proxy_id()<<" local id:"<<batch_request->local_id();
+  // LOG(ERROR)<<"execute seq:"<<batch_request->seq()<<" proxy
+  // id:"<<request->proxy_id()<<" local id:"<<batch_request->local_id();
 
   // LOG(INFO) << " get request batch size:"
   // << batch_request.user_requests_size()<<" proxy id:"
@@ -349,7 +347,11 @@ void TransactionExecutor::Execute(std::unique_ptr<Request> request,
   // need_execute = false;
   if (transaction_manager_ && need_execute) {
     if (execute_thread_num_ == 1) {
-      response = transaction_manager_->ExecuteBatch(*batch_request_p);
+      if (config_.IsTpccEnabled()) {
+        response = transaction_manager_->ExecuteTPCCBatch(*batch_request_p);
+      } else {
+        response = transaction_manager_->ExecuteBatch(*batch_request_p);
+      }
     } else {
       std::vector<std::unique_ptr<std::string>> response_v;
 
@@ -398,6 +400,10 @@ void TransactionExecutor::Execute(std::unique_ptr<Request> request,
   //LOG(ERROR)<<" proxy id:"<<batch_request_p->proxy_id()<<" local id:"<<batch_request_p->local_id()<<" latency:"<<GetCurrentTime()- response->createtime();
 
   response->set_seq(request->seq());
+  response->set_primary_id(request->primary_id());
+  response->set_next_primary(request->next_primary());
+
+  response->set_commit_time(request->commit_time());
 
   if (post_exec_func_) {
     post_exec_func_(std::move(request), std::move(response));
diff --git a/platform/consensus/execution/transaction_executor.h b/platform/consensus/execution/transaction_executor.h
index cbd31c60..f2b890c8 100644
--- a/platform/consensus/execution/transaction_executor.h
+++ b/platform/consensus/execution/transaction_executor.h
@@ -114,7 +114,7 @@ class TransactionExecutor {
   std::atomic<bool> stop_;
   Stats* global_stats_ = nullptr;
   DuplicateManager* duplicate_manager_;
-  int execute_thread_num_ = 10;
+  int execute_thread_num_ = 1;
   static const int blucket_num_ = 1024;
   int blucket_[blucket_num_];
   std::condition_variable cv_;
diff --git a/platform/consensus/ordering/common/algorithm/protocol_base.cpp b/platform/consensus/ordering/common/algorithm/protocol_base.cpp
index 3c6c2fc3..3294ff4f 100644
--- a/platform/consensus/ordering/common/algorithm/protocol_base.cpp
+++ b/platform/consensus/ordering/common/algorithm/protocol_base.cpp
@@ -36,12 +36,27 @@ void ProtocolBase::Stop(){
 bool ProtocolBase::IsStop(){
   return stop_;
 }
+
+bool ProtocolBase::IsSlowReplica(int node_id) {
+  return node_id <= network_delay_num_;
+}
     
 int ProtocolBase::SendMessage(int msg_type, const google::protobuf::Message& msg, int node_id) {
+  if (IsSlowReplica(id_)) {
+    // 1000, 5000, 50000, 500000
+    usleep(GetRandomDelay());
+  }
+  if (IsSlowReplica(node_id)) {
+    usleep(GetRandomDelay());
+  }
   return single_call_(msg_type, msg, node_id);
 }
 
 int ProtocolBase::Broadcast(int msg_type, const google::protobuf::Message& msg) {
+  if (IsSlowReplica(id_)) {
+    // 1000, 5000, 50000, 500000
+    usleep(GetRandomDelay());
+  }
   return broadcast_call_(msg_type, msg);
 }
 
@@ -49,5 +64,14 @@ int ProtocolBase::Commit(const google::protobuf::Message& msg) {
   return commit_(msg);
 }
 
+void ProtocolBase::SetNetworkDelayGenerator(int32_t network_delay_num, double mean_network_delay) {
+  network_delay_num_ = network_delay_num;
+  mean_network_delay_ = mean_network_delay;
+
+  sigma_ = 0.2 * mean_network_delay_;  // Standard deviation
+  gen_ = std::mt19937(rd_()); // Mersenne Twister engine
+  dist_ = std::normal_distribution<>(mean_network_delay_, sigma_);
+}
+
 }  // namespace protocol
 }  // namespace resdb
diff --git a/platform/consensus/ordering/common/algorithm/protocol_base.h b/platform/consensus/ordering/common/algorithm/protocol_base.h
index a93be822..8dcdad37 100644
--- a/platform/consensus/ordering/common/algorithm/protocol_base.h
+++ b/platform/consensus/ordering/common/algorithm/protocol_base.h
@@ -2,6 +2,7 @@
 
 #include <functional>
 #include <google/protobuf/message.h>
+#include <random>
 #include "common/crypto/signature_verifier.h"
 
 namespace resdb {
@@ -29,6 +30,8 @@ class ProtocolBase {
 
   void Stop();
 
+  void SetNetworkDelayGenerator(int32_t network_delay_num, double mean_network_delay);
+
   inline
   void SetSingleCallFunc(SingleCallFuncType single_call) { single_call_ = single_call; }
   
@@ -41,7 +44,14 @@ class ProtocolBase {
   inline 
   void SetSignatureVerifier(SignatureVerifier* verifier) { verifier_ = verifier;}
 
+  inline
+  uint64_t GetRandomDelay() { 
+    // return (uint64_t)(dist_(gen_));
+    return (uint64_t)(mean_network_delay_);
+  }
+
   protected:
+    bool IsSlowReplica(int node_id);
     int SendMessage(int msg_type, const google::protobuf::Message& msg, int node_id);
     int Broadcast(int msg_type, const google::protobuf::Message& msg);
     int Commit(const google::protobuf::Message& msg);
@@ -58,6 +68,13 @@ class ProtocolBase {
   std::atomic<bool> stop_;
 
   SignatureVerifier* verifier_;
+
+  int32_t network_delay_num_; 
+  double mean_network_delay_;  // Mean
+  double sigma_;  // Standard deviation
+  std::random_device rd_;  // Seed
+  std::mt19937 gen_; // Mersenne Twister engine
+  std::normal_distribution<> dist_;
 };
 
 }  // namespace protocol
diff --git a/platform/consensus/ordering/common/framework/BUILD b/platform/consensus/ordering/common/framework/BUILD
index 82e03a0f..678334c7 100644
--- a/platform/consensus/ordering/common/framework/BUILD
+++ b/platform/consensus/ordering/common/framework/BUILD
@@ -1,5 +1,12 @@
 package(default_visibility = ["//platform/consensus/ordering:__subpackages__"])
 
+cc_library(
+    name = "glog",
+    deps = [
+        "@com_github_google_glog//:glog",
+    ],
+)
+
 cc_library(
     name = "consensus",
     srcs = ["consensus.cpp"],
@@ -23,6 +30,7 @@ cc_library(
         ":transaction_utils",
         "//platform/networkstrate:replica_communicator",
         "//platform/networkstrate:server_comm",
+        ":tpcc",
     ],
 )
 
@@ -47,3 +55,15 @@ cc_library(
         "//platform/proto:resdb_cc_proto",
     ],
 )
+
+cc_library(
+    name = "tpcc",
+    srcs = ["tpcc.cpp"],
+    hdrs = ["tpcc.h"],
+    visibility = ["//visibility:public"],
+    deps = [
+        "//platform/proto:resdb_cc_proto",
+        ":glog",
+    ],
+)
+
diff --git a/platform/consensus/ordering/common/framework/consensus.cpp b/platform/consensus/ordering/common/framework/consensus.cpp
index 9c1603b2..69fc1257 100644
--- a/platform/consensus/ordering/common/framework/consensus.cpp
+++ b/platform/consensus/ordering/common/framework/consensus.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -76,6 +76,10 @@ void Consensus::Init(){
 void Consensus::InitProtocol(ProtocolBase * protocol){
   //protocol->SetSignatureVerifier(GetSignatureVerifier());
 
+  if (config_.NetworkDelayNum() > 0) {
+    protocol->SetNetworkDelayGenerator(config_.NetworkDelayNum(), config_.MeanNetworkDelay());
+  }
+
   protocol->SetSingleCallFunc(
       [&](int type, const google::protobuf::Message& msg, int node_id) {
       return SendMsg(type, msg, node_id);
@@ -180,21 +184,12 @@ int Consensus::ResponseMsg(const BatchUserResponse& batch_resp) {
     request.set_type(Request::TYPE_RESPONSE);
     request.set_sender_id(config_.GetSelfInfo().id());
     request.set_proxy_id(batch_resp.proxy_id());
+    request.set_primary_id(batch_resp.primary_id());
     batch_resp.SerializeToString(request.mutable_data());
     //global_stats_->AddResponseDelay(GetCurrentTime()- batch_resp.createtime());
     replica_communicator_->SendMessage(request, request.proxy_id());
   return 0;
 }
-
-void Consensus::SendFail(const int proxy_id, const std::string& hash){
-  Request request;
-  request.set_type(Request::TYPE_RESPONSE);
-  request.set_sender_id(config_.GetSelfInfo().id());
-  request.set_proxy_id(proxy_id);
-  request.set_ret(-2);
-  request.set_hash(hash);
-  replica_communicator_->SendMessage(request, request.proxy_id());
-}
 /*
 int Consensus::ResponseMsg(const BatchUserResponse& batch_resp) {
   if (batch_resp.proxy_id() == 0) {
diff --git a/platform/consensus/ordering/common/framework/consensus.h b/platform/consensus/ordering/common/framework/consensus.h
index 160db807..bd61d827 100644
--- a/platform/consensus/ordering/common/framework/consensus.h
+++ b/platform/consensus/ordering/common/framework/consensus.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -55,7 +55,6 @@ class Consensus : public ConsensusManager {
     virtual int ProcessCustomConsensus(std::unique_ptr<Request> request);
     virtual int ProcessNewTransaction(std::unique_ptr<Request> request);
     virtual int CommitMsg(const google::protobuf::Message& msg);
-    void SendFail(const int proxy_id, const std::string& hash);
 
  protected:
   int SendMsg(int type, const google::protobuf::Message& msg, int node_id);
diff --git a/platform/consensus/ordering/common/framework/performance_manager.cpp b/platform/consensus/ordering/common/framework/performance_manager.cpp
index 1f5aa9f4..d999e6fc 100644
--- a/platform/consensus/ordering/common/framework/performance_manager.cpp
+++ b/platform/consensus/ordering/common/framework/performance_manager.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -44,6 +44,7 @@ PerformanceManager::PerformanceManager(
   stop_ = false;
   eval_started_ = false;
   eval_ready_future_ = eval_ready_promise_.get_future();
+  tpcc_txn_generator_ = new TpccTransactionGenerator();
   if (config_.GetPublicKeyCertificateInfo()
           .public_key()
           .public_key_info()
@@ -62,6 +63,11 @@ PerformanceManager::PerformanceManager(
   if (primary_ == 0) primary_ = replica_num_;
   local_id_ = 1;
   sum_ = 0;
+  client_num_ = 1;
+  slot_num_ = 1;
+  counter_ = slot_num_ * primary_;
+  inflight_.resize(replica_num_ + 1);
+  inflight_limit_ = 20;
 }
 
 PerformanceManager::~PerformanceManager() {
@@ -73,7 +79,12 @@ PerformanceManager::~PerformanceManager() {
   }
 }
 
-int PerformanceManager::GetPrimary() { return primary_; }
+// int PerformanceManager::GetPrimary() { return primary_; }
+
+int PerformanceManager::GetPrimary() { 
+  LOG(ERROR) << "SEND to " << primary_;
+  return primary_;
+}
 
 std::unique_ptr<Request> PerformanceManager::GenerateUserRequest() {
   std::unique_ptr<Request> request = std::make_unique<Request>();
@@ -90,13 +101,17 @@ int PerformanceManager::StartEval() {
     return 0;
   }
   eval_started_ = true;
-  for (int i = 0; i < 5000000; ++i) {
+  int max_num = config_.IsTpccEnabled() ? 100000 : 10000000;
+  for (int i = 0; i < max_num; ++i) {
     // for (int i = 0; i < 60000000000; ++i) {
     std::unique_ptr<QueueItem> queue_item = std::make_unique<QueueItem>();
     queue_item->context = nullptr;
     queue_item->user_request = GenerateUserRequest();
+    if (config_.IsTpccEnabled()) {
+      tpcc_txn_generator_->fillTpccTransaction(queue_item->user_request.get());
+    }
     batch_queue_.Push(std::move(queue_item));
-    if (i == 200000) {
+    if (i == 2000) {
       eval_ready_promise_.set_value(true);
     }
   }
@@ -119,7 +134,7 @@ int PerformanceManager::ProcessResponseMsg(std::unique_ptr<Context> context,
     return 0;
   }
 
-  //LOG(INFO) << "get response:" << request->seq() << " sender:"<<request->sender_id();
+  LOG(INFO) << "get response:" << request->seq() << " sender:"<<request->sender_id();
   std::unique_ptr<BatchUserResponse> batch_response = nullptr;
   CollectorResultCode ret =
       AddResponseMsg(std::move(request), [&](std::unique_ptr<BatchUserResponse> request) {
@@ -127,10 +142,29 @@ int PerformanceManager::ProcessResponseMsg(std::unique_ptr<Context> context,
         return;
       });
 
-  if (ret == CollectorResultCode::STATE_CHANGED) {
-    LOG(ERROR) << "[DK] RSP";
-    assert(batch_response);
+  if (config_.NetworkDelayNum() > 0) {
+    if (ret == CollectorResultCode::FIRST_RESPONSE) {
+      assert(batch_response);
+      int primary_id = batch_response->primary_id();
+      // LOG(ERROR) << "here: " << primary_id;
+      inflight_[primary_id]--;
+      last_response_ = primary_id;
+      send_num_--;
+    } 
+    if (ret == CollectorResultCode::STATE_CHANGED) {
+      assert(batch_response);
+      SendResponseToClient(*batch_response);
+    }
+  }
+  else {
+    if (ret == CollectorResultCode::STATE_CHANGED) {
+      assert(batch_response);
+      int primary_id = batch_response->primary_id();
+      // LOG(ERROR) << "primary_id: " << primary_id;
+      inflight_[primary_id]--;
+      last_response_ = primary_id;
       SendResponseToClient(*batch_response);
+    }
   }
   return ret == CollectorResultCode::INVALID ? -2 : 0;
 }
@@ -151,7 +185,7 @@ CollectorResultCode PerformanceManager::AddResponseMsg(
   }
 
   uint64_t seq = batch_response->local_id();
-  // LOG(ERROR)<<"receive seq:"<<seq;
+  //LOG(ERROR)<<"receive seq:"<<seq;
 
   bool done = false;
   {
@@ -162,7 +196,7 @@ CollectorResultCode PerformanceManager::AddResponseMsg(
       return CollectorResultCode::OK;
     }
     response_[idx][seq]++;
-    // LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" send:"<<send_num_;
+    //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" send:"<<send_num_;
     if (response_[idx][seq] >= config_.GetMinClientReceiveNum()) {
       //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" done:"<<send_num_;
       response_[idx].erase(response_[idx].find(seq));
@@ -181,12 +215,21 @@ void PerformanceManager::SendResponseToClient(
   uint64_t create_time = batch_response.createtime();
   if (create_time > 0) {
     uint64_t run_time = GetCurrentTime() - create_time;
-    //LOG(ERROR)<<"receive current:"<<GetCurrentTime()<<" create time:"<<create_time<<" run time:"<<run_time<<" local id:"<<batch_response.local_id();
+    // LOG(ERROR) << "create time: " << create_time;
+    // LOG(ERROR)<<"receive current:"<<GetCurrentTime()<<" create time:"<<create_time<<" run time:"<<run_time<<" local id:"<<batch_response.local_id();
+    // LOG(ERROR) << "Add Latency: " << run_time;
+    // LOG(ERROR) << "Add ReplyLatency: " << GetCurrentTime() - batch_response.commit_time();
+    if (config_.NetworkDelayNum() == replica_num_) {
+      run_time += config_.MeanNetworkDelay();
+    }
     global_stats_->AddLatency(run_time);
+    global_stats_->AddReplyLatency(GetCurrentTime() - batch_response.commit_time());
   } else {
   }
   //send_num_-=10;
-  send_num_--;
+  if (config_.NetworkDelayNum() == 0) {
+    send_num_--;
+  }
 }
 
 // =================== request ========================
@@ -198,9 +241,9 @@ int PerformanceManager::BatchProposeMsg() {
   eval_ready_future_.get();
   bool start = false;
   while (!stop_) {
-    if (send_num_ > config_.GetMaxProcessTxn()) {
-      // LOG(ERROR)<<"wait send num:"<<send_num_;
-      usleep(1000);
+    if (send_num_ > 0 && send_num_ >= config_.GetMaxProcessTxn()) {
+      // LOG(ERROR)<<"wait send num:"<<send_num_ << " and " << config_.GetMaxProcessTxn();
+      usleep(100);
       continue;
     }
     if (batch_req.size() < config_.ClientBatchNum()) {
@@ -217,6 +260,11 @@ int PerformanceManager::BatchProposeMsg() {
         continue;
       }
     }
+    // while (send_num_ > config_.GetMaxProcessTxn()) {
+    //   // LOG(ERROR)<<"wait send num:"<<send_num_;
+    //   usleep(100);
+    //   // continue;
+    // }
     start = true;
     for(int i = 0; i < 1;++i){
       int ret = DoBatch(batch_req);
@@ -241,12 +289,13 @@ int PerformanceManager::DoBatch(
     req->set_id(i);
   }
 
+
   batch_request.set_local_id(local_id_++);
 
   {
     int idx = batch_request.local_id() % response_set_size_;
     std::unique_lock<std::mutex> lk(response_lock_[idx]);
-    response_[idx][batch_request.local_id()]++;
+    response_[idx][batch_request.local_id()] = 0; // [DK] Why do we increase the value by 1 here?
   }
 
   batch_request.set_proxy_id(config_.GetSelfInfo().id());
@@ -270,7 +319,7 @@ int PerformanceManager::DoBatch(
   global_stats_->BroadCastMsg();
   send_num_++;
   sum_ += batch_req.size();
-  //LOG(ERROR)<<"send num:"<<send_num_<<" total num:"<<total_num_<<" sum:"<<sum_<<" to:"<<GetPrimary();
+  // LOG(ERROR)<<"send num:"<<send_num_<<" total num:"<<total_num_<<" sum:"<<sum_<<" to:"<<GetPrimary();
   if (total_num_++ == 1000000) {
     stop_ = true;
     LOG(WARNING) << "total num is done:" << total_num_;
@@ -283,7 +332,11 @@ int PerformanceManager::DoBatch(
 }
 
 void PerformanceManager::SendMessage(const Request& request){
-  replica_communicator_->SendMessage(request, GetPrimary());
+  int primary = GetPrimary();
+  // LOG(ERROR) << "[X]send to: " <<  primary << " at " << GetCurrentTime() - last_send_time_ << " " << GetCurrentTime();
+  last_send_time_ = GetCurrentTime();
+  replica_communicator_->SendMessage(request, primary);
+  
 }
 
 }  // namespace common
diff --git a/platform/consensus/ordering/common/framework/performance_manager.h b/platform/consensus/ordering/common/framework/performance_manager.h
index ba2fc666..7087f3c7 100644
--- a/platform/consensus/ordering/common/framework/performance_manager.h
+++ b/platform/consensus/ordering/common/framework/performance_manager.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -32,6 +32,7 @@
 #include "platform/networkstrate/replica_communicator.h"
 #include "platform/networkstrate/server_comm.h"
 #include "platform/statistic/stats.h"
+#include "platform/consensus/ordering/common/framework/tpcc.h"
 
 namespace resdb {
 namespace common {
@@ -46,20 +47,21 @@ class PerformanceManager {
 
   int StartEval();
 
-  int ProcessResponseMsg(std::unique_ptr<Context> context,
+  virtual int ProcessResponseMsg(std::unique_ptr<Context> context,
                          std::unique_ptr<Request> request);
   void SetDataFunc(std::function<std::string()> func);
 
   protected:
   virtual void SendMessage(const Request& request);
+  
 
- private:
+ protected:
   // Add response messages which will be sent back to the caller
   // if there are f+1 same messages.
-  comm::CollectorResultCode AddResponseMsg(
+  virtual comm::CollectorResultCode AddResponseMsg(
       std::unique_ptr<Request> request,
       std::function<void(std::unique_ptr<BatchUserResponse>)> call_back);
-  void SendResponseToClient(const BatchUserResponse& batch_response);
+  virtual void SendResponseToClient(const BatchUserResponse& batch_response);
 
   struct QueueItem {
     std::unique_ptr<Context> context;
@@ -67,15 +69,17 @@ class PerformanceManager {
   };
   int DoBatch(const std::vector<std::unique_ptr<QueueItem>>& batch_req);
   int BatchProposeMsg();
-  int GetPrimary();
+  virtual int GetPrimary();
+  int GetPrimaryMulti();
+  int GetPrimarySlotHotStuff1();
+  int GetPrimarySlot();
   std::unique_ptr<Request> GenerateUserRequest();
 
  protected:
   ResDBConfig config_;
   ReplicaCommunicator* replica_communicator_;
-  int replica_num_;
 
- private:
+//  private:
   LockFreeQueue<QueueItem> batch_queue_;
   std::thread user_req_thread_[16];
   std::atomic<bool> stop_;
@@ -93,10 +97,26 @@ class PerformanceManager {
   static const int response_set_size_ = 6000000;
   std::map<int64_t, int> response_[response_set_size_];
   std::mutex response_lock_[response_set_size_];
+ 
+ protected:
+  int replica_num_;
   int id_;
-  int primary_;
+  // int primary_;
+  std::atomic<int> primary_;
   std::atomic<int> local_id_;
   std::atomic<int> sum_;
+  std::atomic<uint64_t> counter_;
+  int client_num_;
+  int slot_num_;
+
+  std::vector<int> inflight_;
+  int inflight_limit_;
+  std::atomic<uint64_t> last_response_ = 0;
+
+  uint64_t last_send_time_ = 0;
+
+  TpccTransactionGenerator* tpcc_txn_generator_;
+
 };
 
 }  // namespace common
diff --git a/platform/consensus/ordering/common/framework/response_manager.cpp b/platform/consensus/ordering/common/framework/response_manager.cpp
index ae6b55cc..394f3f5d 100644
--- a/platform/consensus/ordering/common/framework/response_manager.cpp
+++ b/platform/consensus/ordering/common/framework/response_manager.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/platform/consensus/ordering/common/framework/response_manager.h b/platform/consensus/ordering/common/framework/response_manager.h
index 1c704396..f9bf6de8 100644
--- a/platform/consensus/ordering/common/framework/response_manager.h
+++ b/platform/consensus/ordering/common/framework/response_manager.h
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/platform/consensus/ordering/common/framework/tpcc.cpp b/platform/consensus/ordering/common/framework/tpcc.cpp
new file mode 100644
index 00000000..844c03a5
--- /dev/null
+++ b/platform/consensus/ordering/common/framework/tpcc.cpp
@@ -0,0 +1,184 @@
+#include "platform/consensus/ordering/common/framework/tpcc.h"
+#include <glog/logging.h>
+namespace resdb {
+namespace common {
+
+TpccTransactionGenerator::TpccTransactionGenerator() {
+    // Initialize random seed
+    std::srand(std::time(nullptr)); // Seed with current time
+    gen = std::mt19937(rd());
+}
+    
+int TpccTransactionGenerator::fillTpccTransaction(Request* request) {
+    int x = generateRandomInt(1, 100);
+    if (x <= 45) {
+        // std::cout << "NEWORDER\n";
+        request->mutable_tpcc_txn()->set_type(TpccTransaction::TPCC_TYPE_NEWORDER);
+        auto* new_order = request->mutable_tpcc_txn()->mutable_new_order();
+        int value = fillNewOrderTransaction(new_order);
+        // LOG(ERROR) << "W_ID: " << request->tpcc_txn().new_order().w_id();
+        return 0 + value;
+    }
+    else if (x <= 45 + 43) {
+        // std::cout << "PAYMENT\n";
+        request->mutable_tpcc_txn()->set_type(TpccTransaction::TPCC_TYPE_PAYMENT);
+        auto* payment = request->mutable_tpcc_txn()->mutable_payment();
+        // LOG(ERROR) << "TYPE4: " << request->type();
+        return -10 + fillPaymentTransaction(payment);
+    }
+    else if (x <= 45 + 43 + 4) {
+        // std::cout << "ORDER_STATUS\n";
+        request->mutable_tpcc_txn()->set_type(TpccTransaction::TPCC_TYPE_ORDERSTATUS);
+        auto* order_status = request->mutable_tpcc_txn()->mutable_order_status();
+        return -20 + fillOrderStatusTransaction(order_status);
+    }
+    else if (x <= 45 + 43 + 4 + 4) {
+        // std::cout << "DELIVERY\n";
+        request->mutable_tpcc_txn()->set_type(TpccTransaction::TPCC_TYPE_DELIVERY);
+        auto* delivery = request->mutable_tpcc_txn()->mutable_delivery();
+        return -30 + fillDeliveryTransaction(delivery);
+    }
+    else if (x <= 100) {
+        // std::cout << "STOCK_LEVEL\n";
+        request->mutable_tpcc_txn()->set_type(TpccTransaction::TPCC_TYPE_STOCKLEVEL);
+        auto* stock_level = request->mutable_tpcc_txn()->mutable_stock_level();
+        return -40 + fillStockLevelTransaction(stock_level);
+    }
+    return 0;
+}
+
+int TpccTransactionGenerator::fillNewOrderTransaction(resdb::NewOrderTransaction* txn) {
+    int W_ID = 1;
+    int D_ID = generateRandomInt(1, 10);
+    int C_ID = generateRandomInt(1, 3000);
+    int O_OL_CNT = generateRandomInt(5, 15);
+    std::string DATETIME = getCurrentTimestamp();
+
+    std::vector<int> SUPWARE; 
+    std::vector<int> ITEMID;
+    std::vector<int> QTY;
+    SUPWARE.resize(O_OL_CNT);
+    ITEMID.resize(O_OL_CNT);
+    QTY.resize(O_OL_CNT);
+
+    txn->set_w_id(W_ID); // Random warehouse ID
+    txn->set_d_id(D_ID); // Random district ID
+    txn->set_c_id(C_ID); // Random customer ID
+    txn->set_o_ol_cnt(O_OL_CNT); // Random customer ID
+    txn->set_date_time(DATETIME); // Random customer ID
+
+    for(int i = 0; i < O_OL_CNT; i++) {
+        SUPWARE[i] = generateRandomInt(1, 100) > 1 ? W_ID : 1;
+        ITEMID[i] = NURand (8191,1,100000);
+        QTY[i] = generateRandomInt(1, 10);
+    }
+
+    // Add some random items
+    for (int i = 0; i < O_OL_CNT; ++i) {
+        auto* item = txn->add_items();
+        item->set_i_id(ITEMID[i]); // Random item ID
+        item->set_sup_w_id(SUPWARE[i]); // Random supplier warehouse ID
+        item->set_qty(QTY[i]); // Random quantity
+    }
+
+    return 0;
+}
+
+int TpccTransactionGenerator::fillPaymentTransaction(resdb::PaymentTransaction* txn) {
+    int C_W_ID, C_D_ID, W_ID, D_ID, C_ID;
+    std::string C_LAST, H_DATE;
+    bool BYNAME;
+    double H_AMOUNT;
+
+    C_ID = 0;
+    C_LAST = "";
+    C_W_ID = W_ID = 1;
+
+    int x = generateRandomInt(1, 100);
+    int y = generateRandomInt(1, 100);
+    D_ID = generateRandomInt(1, 10);
+
+    if (x > 85) {
+        C_D_ID = generateRandomInt(1, 10);
+    } else {
+        C_D_ID = D_ID;
+    }
+
+    if (y <= 60) {
+        BYNAME = true;
+        C_LAST = generateCustomerLastName(NURand(255,0,999));
+    } else {
+        BYNAME = false;
+        C_ID = NURand(1023,1,3000);
+    }
+    H_DATE = getCurrentTimestamp();
+    H_AMOUNT = generateRandomDouble(1, 5000);
+
+    
+    txn->set_w_id(W_ID);
+    txn->set_d_id(D_ID);
+    txn->set_c_w_id(C_W_ID);
+    txn->set_c_d_id(C_D_ID);
+    txn->set_c_id(C_ID);
+    txn->set_h_amount(H_AMOUNT); 
+    txn->set_h_date(H_DATE);
+    txn->set_c_last(C_LAST); 
+    txn->set_byname(BYNAME); 
+
+    return 0;
+}
+
+int TpccTransactionGenerator::fillOrderStatusTransaction(resdb::OrderStatusTransaction* txn) {
+    int W_ID, D_ID, C_ID;
+    std::string C_LAST;
+    bool BYNAME;
+    C_ID = 0;
+    C_LAST = "LAST";
+    int y = generateRandomInt(1, 100);
+    W_ID = 1;
+    D_ID = generateRandomInt(1, 10);
+
+    if (y <= 60) {
+        BYNAME = true;
+        C_LAST = generateCustomerLastName(NURand(255,0,999));
+    } else {
+        BYNAME = false;
+        C_ID = NURand(1023,1,3000);
+    }
+
+    txn->set_w_id(W_ID);
+    txn->set_d_id(D_ID);
+    txn->set_c_id(C_ID);
+    txn->set_c_last(C_LAST); 
+    txn->set_byname(BYNAME); 
+
+    return 0;
+}
+
+int TpccTransactionGenerator::fillDeliveryTransaction(resdb::DeliveryTransaction* txn) {
+    int W_ID = 1;
+    int O_CARRIER_ID = generateRandomInt(1, 10);
+    std::string DATETIME = getCurrentTimestamp(); 
+
+    txn->set_w_id(W_ID);
+    txn->set_carrier_id(O_CARRIER_ID);
+    txn->set_date_time(DATETIME);
+
+    return 0;
+}
+
+
+int TpccTransactionGenerator::fillStockLevelTransaction(resdb::StockLevelTransaction* txn) {
+    int W_ID = 1;
+    int D_ID = generateRandomInt(1, 10);
+    int THRESHOLD = generateRandomInt(10, 20);
+
+    txn->set_w_id(W_ID);
+    txn->set_d_id(D_ID);
+    txn->set_threshold(THRESHOLD); // Random stock level threshold
+
+    return 0;
+}
+   
+} // common
+}  // namespace resdb
diff --git a/platform/consensus/ordering/common/framework/tpcc.h b/platform/consensus/ordering/common/framework/tpcc.h
new file mode 100644
index 00000000..ebccf998
--- /dev/null
+++ b/platform/consensus/ordering/common/framework/tpcc.h
@@ -0,0 +1,104 @@
+#pragma once
+
+#include <iostream>
+#include <cstring>
+#include <cstdlib>
+#include <vector>
+#include <string>
+#include <chrono>
+#include <iomanip>
+#include <sstream>
+#include <ctime>
+#include <random>
+#include <algorithm>
+#include <atomic>
+#include "platform/proto/resdb.pb.h"
+
+namespace resdb {
+namespace common  {
+
+class TpccTransactionGenerator {
+    
+    public:
+        TpccTransactionGenerator ();
+        int fillTpccTransaction(Request* request);
+    
+    private:
+        int fillNewOrderTransaction (resdb::NewOrderTransaction* txn);
+        int fillPaymentTransaction(resdb::PaymentTransaction* txn);
+        int fillOrderStatusTransaction(resdb::OrderStatusTransaction* txn);
+        int fillDeliveryTransaction(resdb::DeliveryTransaction* txn);
+        int fillStockLevelTransaction(resdb::StockLevelTransaction* txn);
+
+        // Function to generate a non-uniform random number (NURand)
+        inline int NURand(int A, int x, int y) {
+            static std::uniform_int_distribution<> disC(0, 999); // Range for C
+            static int C = disC(gen); // C is a constant per execution
+
+            std::uniform_int_distribution<> disA(0, A - 1);       // Range for A
+            std::uniform_int_distribution<> disXY(x, y);         // Range for x to y
+            return (((disA(gen) | disXY(gen)) + C) % (y - x + 1)) + x;
+        }
+
+        // Function to generate a random double between [low, high]
+        inline double generateRandomDouble(double low, double high) {
+            // Generate a random integer and scale it to [low, hight]
+            static std::uniform_int_distribution<> disDouble(0, 10000); // Range for C
+            return low + static_cast<double>(disDouble(gen)) / 10000 * (high - low);
+        }
+
+        // Function to generate a random int between [low, high]
+        inline int generateRandomInt(int low, int high) {
+            std::uniform_int_distribution<int> dis(low, high); // Define the range
+            return dis(gen); // Generate a random integer between low and high
+        }
+
+        inline std::string getCurrentTimestamp() {
+            // Get the current time as a time_point
+            auto now = std::chrono::system_clock::now();
+
+            // Convert to time_t to format the time
+            std::time_t now_time_t = std::chrono::system_clock::to_time_t(now);
+
+            // Convert to tm structure
+            std::tm now_tm = *std::localtime(&now_time_t);
+
+            // Format the time as a string
+            std::ostringstream oss;
+            oss << std::put_time(&now_tm, "%Y-%m-%d %H:%M:%S");
+            return oss.str();
+        }
+
+        // Function to generate C_LAST based on a number between 0 and 999
+        inline std::string generateCustomerLastName(int number) {
+            if (number >= 1000) {
+                number  = NURand(255, 0, 999);
+            }
+
+            // List of syllables
+            const std::vector<std::string> syllables = {
+                "BAR", "OUGHT", "ABLE", "PRI", "PRES", "ESE", 
+                "ANTI", "CALLY", "ATION", "EING"
+            };
+
+            // Extract the digits
+            int hundreds = number / 100;
+            int tens = (number / 10) % 10;
+            int ones = number % 10;
+
+            // Construct the last name
+            std::string lastName = syllables[hundreds] + syllables[tens] + syllables[ones];
+
+            return lastName;
+        }
+
+        // Use a random number generator
+        std::random_device rd; // Obtain a random seed
+        std::mt19937 gen; // Seed the generator
+};
+
+
+
+} // common
+}  // namespace resdb
+
diff --git a/platform/consensus/ordering/common/framework/transaction_utils.cpp b/platform/consensus/ordering/common/framework/transaction_utils.cpp
index 08a8e544..a1564e69 100644
--- a/platform/consensus/ordering/common/framework/transaction_utils.cpp
+++ b/platform/consensus/ordering/common/framework/transaction_utils.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/platform/consensus/ordering/common/framework/transaction_utils.h b/platform/consensus/ordering/common/framework/transaction_utils.h
index 3055cf44..e105f2ea 100644
--- a/platform/consensus/ordering/common/framework/transaction_utils.h
+++ b/platform/consensus/ordering/common/framework/transaction_utils.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -34,6 +34,7 @@ enum CollectorResultCode {
   INVALID = -2,
   OK = 0,
   STATE_CHANGED = 1,
+  FIRST_RESPONSE = 2,
 };
 
 std::unique_ptr<Request> NewRequest(Request::Type type, const Request& request,
diff --git a/platform/consensus/ordering/hs/algorithm/BUILD b/platform/consensus/ordering/hs/algorithm/BUILD
index 976e8400..d3ea2eae 100644
--- a/platform/consensus/ordering/hs/algorithm/BUILD
+++ b/platform/consensus/ordering/hs/algorithm/BUILD
@@ -9,6 +9,7 @@ cc_library(
         "//common/crypto:signature_verifier",
         "//common/utils",
         "//platform/consensus/ordering/hs/proto:proposal_cc_proto",
+        "//platform/statistic:stats",
     ],
 )
 
@@ -21,19 +22,9 @@ cc_library(
         "//common:comm",
         "//platform/common/queue:lock_free_queue",
         "//platform/consensus/ordering/common/algorithm:protocol_base",
+        "//platform/statistic:stats",
     ],
 )
 
-cc_library(
-    name = "tusk",
-    srcs = ["tusk.cpp"],
-    hdrs = ["tusk.h"],
-    deps = [
-        ":proposal_manager",
-        "//common/crypto:signature_verifier",
-        "//common:comm",
-        "//platform/common/queue:lock_free_queue",
-        "//platform/consensus/ordering/common/algorithm:protocol_base",
-    ],
-)
+
 
diff --git a/platform/consensus/ordering/hs/algorithm/hs.cpp b/platform/consensus/ordering/hs/algorithm/hs.cpp
index 0af553ac..3dcec6f3 100644
--- a/platform/consensus/ordering/hs/algorithm/hs.cpp
+++ b/platform/consensus/ordering/hs/algorithm/hs.cpp
@@ -7,16 +7,19 @@
 namespace resdb {
 namespace hs {
 
-HotStuff::HotStuff(int id, int f, int total_num, SignatureVerifier * verifier)
-  : ProtocolBase(id, f, total_num), verifier_(verifier){
+HotStuff::HotStuff(int id, int f, int total_num, SignatureVerifier * verifier, int non_responsive_num, int fork_tail_num)
+  : ProtocolBase(id, f, total_num), verifier_(verifier), non_responsive_num_(non_responsive_num), fork_tail_num_(fork_tail_num){
 
     LOG(ERROR)<<"id:"<<id<<" f:"<<f<<" total:"<<total_num_;
 
-  proposal_manager_ = std::make_unique<ProposalManager>(id, 2*f_+1, verifier);
+  global_stats_ = Stats::GetGlobalStats();
+  proposal_manager_ = std::make_unique<ProposalManager>(id, 2*f_+1, verifier, total_num, non_responsive_num, fork_tail_num);
   has_sent_ = false;
     send_thread_ = std::thread(&HotStuff::AsyncSend, this);
     commit_thread_ = std::thread(&HotStuff::AsyncCommit, this);
-    batch_size_ = 64;
+    batch_size_ = 1;
+  timer_length_ = 10000;
+  qc_formed_ = proposal_received_ = false;
 }
 
 HotStuff::~HotStuff() {
@@ -54,7 +57,6 @@ void HotStuff::AsyncSend() {
       std::unique_lock<std::mutex> lk(n_mutex_);
       vote_cv_.wait_for(lk, std::chrono::microseconds(1000),
           [&] { return Ready(); });
-
       if(Ready()){
         break;
       }
@@ -74,6 +76,10 @@ void HotStuff::AsyncSend() {
       txns.push_back(std::move(txn));
     }
 
+    if (id_ < 3 * non_responsive_num_ && id_ % 3 == 1) {
+      usleep(timer_length_);
+    }
+
     std::unique_ptr<Proposal> proposal =  nullptr;
     {
       std::unique_lock<std::mutex> lk(mutex_);
@@ -92,7 +98,8 @@ void HotStuff::AsyncCommit() {
     if(p == nullptr){
       continue;
     }
-
+    global_stats_->AddConsensusLatency(GetCurrentTime()-p->createtime());
+    // LOG(ERROR) << "create time: " << p->createtime();
     for(Transaction& txn : *p->mutable_transactions()){
       txn.set_id(seq++);
       Commit(txn);
@@ -103,17 +110,26 @@ void HotStuff::AsyncCommit() {
 
 bool HotStuff::ReceiveTransaction(std::unique_ptr<Transaction> txn) {
   //  std::unique_lock<std::mutex> lk(txn_mutex_);
+  txn->set_reception_time(GetCurrentTime());
   txn->set_proposer(id_);
   txns_.Push(std::move(txn));
   return true;
 }
 
 bool HotStuff::ReceiveProposal(std::unique_ptr<Proposal> proposal) {
+  if (IsSlowReplica(id_)) {
+    usleep(GetRandomDelay());
+  }
     int view = proposal->header().view();
     std::unique_ptr<Certificate> cert = nullptr;
   {
-    //LOG(ERROR)<<"RECEIVE proposer view:"<<proposal->header().view();
+    LOG(ERROR)<<"RECEIVE proposer view:"<<proposal->header().view() << " from: " << proposal->sender();
     std::unique_lock<std::mutex> lk(mutex_);
+
+    if (id_ == NextLeader(view)) {
+      proposal_received_ = true;
+    }
+
     if(!proposal_manager_->Verify(*proposal)){
       LOG(ERROR)<<" proposal invalid";
       return false;
@@ -122,22 +138,44 @@ bool HotStuff::ReceiveProposal(std::unique_ptr<Proposal> proposal) {
     cert = GenerateCertificate(*proposal);
     assert(cert != nullptr);
 
-    std::unique_ptr<Proposal> committed_p = proposal_manager_->AddProposal(std::move(proposal));
-    if(committed_p != nullptr){
-      CommitProposal(std::move(committed_p));
+    std::vector<std::unique_ptr<Proposal>> committed_p_list = proposal_manager_->AddProposal(std::move(proposal));
+    for (int i=committed_p_list.size()-1; i>=0; i--) {
+      LOG(ERROR) << "commit view: " << committed_p_list[i]->header().view();
+      CommitProposal(std::move(committed_p_list[i]));
     }
 
     //LOG(ERROR)<<"send cert view:"<<view<<" to:"<<NextLeader(view);
+    if (qc_formed_) {
+      // LOG(ERROR) << "after proposal recieeved";
+      proposal_manager_->AddQC(std::move(formed_qc_));
+      StartNewRound();
+      qc_formed_ = proposal_received_ = false;
+    }
   }
 
-  SendMessage(MessageType::Vote, *cert, NextLeader(view));
+  auto next_leader = proposal_manager_->GetLeader(view+1);
+
+  SendMessage(MessageType::Vote, *cert, next_leader);
+
+  if (next_leader % 3 == 1 && next_leader <= 3 * crash_num_) {
+    int next_next_leader = proposal_manager_->GetLeader(view+2);
+    if (id_ == next_next_leader) {
+      proposal_received_ = true;
+    }
+    cert->set_view(view+1);
+    usleep(timer_length_);
+    SendMessage(MessageType::Vote, *cert, next_next_leader);
+  }
 
   return true;
 }
 
 bool HotStuff::ReceiveCertificate(std::unique_ptr<Certificate> cert) {
 
-  //LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
+  if (id_ % 3 == 1 && id_ <= 3*crash_num_) {
+    return true;
+  }
+
   std::unique_lock<std::mutex> lk(mutex_);
   //LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
   bool valid = proposal_manager_->VerifyCert(*cert);
@@ -161,10 +199,16 @@ bool HotStuff::ReceiveCertificate(std::unique_ptr<Certificate> cert) {
       *qc->add_signatures() = it.second->sign();
     }
 
-    //LOG(ERROR)<<"add qc view:"<<view;
-    proposal_manager_->AddQC(std::move(qc));
+    qc_formed_ = true;
+    if (proposal_received_) {
+      // LOG(ERROR) << "after qc formed";
+      proposal_manager_->AddQC(std::move(qc));
+      StartNewRound();
+      qc_formed_ = proposal_received_ = false;
+    } else {
+      formed_qc_ = std::move(qc);
+    }
 
-    StartNewRound();
   }
   return true;
 }
@@ -189,5 +233,5 @@ std::unique_ptr<Certificate> HotStuff::GenerateCertificate(const Proposal& propo
   return cert;
 }
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/hs.h b/platform/consensus/ordering/hs/algorithm/hs.h
index 04148a37..737a2d08 100644
--- a/platform/consensus/ordering/hs/algorithm/hs.h
+++ b/platform/consensus/ordering/hs/algorithm/hs.h
@@ -6,13 +6,14 @@
 #include "platform/consensus/ordering/hs/algorithm/proposal_manager.h"
 #include "platform/consensus/ordering/hs/proto/proposal.pb.h"
 #include "platform/consensus/ordering/common/algorithm/protocol_base.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
 namespace hs {
 
 class HotStuff: public common::ProtocolBase {
  public:
-  HotStuff(int id, int f, int total_num, SignatureVerifier* verifier );
+  HotStuff(int id, int f, int total_num, SignatureVerifier* verifier, int non_responsive_num, int fork_tail_num );
   ~HotStuff();
 
   //  recv txn -> send block with links -> rec block ack -> send block with certs
@@ -51,8 +52,17 @@ class HotStuff: public common::ProtocolBase {
   //[view][hash][signer][cert]
   //std::map<std::string, std::map<int, std::unique_ptr<Certificate>> >  receive_[1024];
   std::map<int,  std::map<std::string, std::map<int, std::unique_ptr<Certificate>> > > receive_;
+  Stats* global_stats_ = nullptr;
 
+  int non_responsive_num_;
+  int fork_tail_num_;
+  uint64_t timer_length_;
+
+  bool qc_formed_, proposal_received_;
+  std::unique_ptr<QC> formed_qc_;
+
+  uint64_t crash_num_ = 10;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp b/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp
index 72287e43..f687493d 100644
--- a/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp
+++ b/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp
@@ -7,9 +7,10 @@
 namespace resdb {
 namespace hs {
 
-ProposalManager::ProposalManager(int32_t id, int limit_count, SignatureVerifier* verifier)
-    : id_(id), limit_count_(limit_count), verifier_(verifier) {
+ProposalManager::ProposalManager(int32_t id, int limit_count, SignatureVerifier* verifier, int total_num, int non_responsive_num, int fork_tail_num)
+    : id_(id), limit_count_(limit_count), verifier_(verifier), total_num_(total_num), non_responsive_num_(non_responsive_num), fork_tail_num_(fork_tail_num) {
     round_ = 1;
+    global_stats_ = Stats::GetGlobalStats();
     assert(verifier_ != nullptr);
 }
 
@@ -84,6 +85,7 @@ std::unique_ptr<Proposal> ProposalManager::GenerateProposal(
   {
     std::unique_lock<std::mutex> lk(txn_mutex_);
     for(const auto& txn: txns){
+      global_stats_->AddProposeLatency(GetCurrentTime() - txn->reception_time());
       *proposal->add_transactions() = *txn;
     }
     if(!generic_qc_.hash().empty()){
@@ -95,7 +97,7 @@ std::unique_ptr<Proposal> ProposalManager::GenerateProposal(
     proposal->mutable_header()->set_view(round_);
     proposal->set_sender(id_);
   }
-
+  proposal->set_createtime(GetCurrentTime());
   proposal->set_hash(GetHash(*proposal));
   return proposal;
 }
@@ -107,38 +109,45 @@ int ProposalManager::CurrentView(){
 void ProposalManager::AddQC(std::unique_ptr<QC> qc){
   std::unique_lock<std::mutex> lk(txn_mutex_);
   if(generic_qc_.view() == 0 || generic_qc_.view() < qc->view()){
-    generic_qc_ = *qc;
-    round_ = generic_qc_.view()+1;
+    int leader = GetLeader(qc->view());
+    if(!(leader < 3 * fork_tail_num_ && leader % 3 ==1)) {
+      generic_qc_ = *qc;
+    } 
+    round_ = qc->view()+1;
   //  LOG(ERROR)<<"get new round:"<<round_;
   }
 }
 
-std::unique_ptr<Proposal> ProposalManager::AddProposal(std::unique_ptr<Proposal> proposal){
+std::vector<std::unique_ptr<Proposal>> ProposalManager::AddProposal(std::unique_ptr<Proposal> proposal){
   //LOG(ERROR)<<"ADD PROPOSAL";
   std::unique_lock<std::mutex> lk(txn_mutex_);
   if(generic_qc_.view() < proposal->header().qc().view()){
     generic_qc_ = proposal->header().qc();
   }
 
-  std::unique_ptr<Proposal> commit_ready_proposal_ = nullptr;
+  std::vector<std::unique_ptr<Proposal>> commit_ready_proposals_;
   const Proposal * father = nullptr, * fafather = nullptr, * fafafather = nullptr;
   father = GetProposal(proposal->header().prehash());
   if(father != nullptr){
     //LOG(ERROR)<<"get father view:"<<father->header().view();
     fafather = GetProposal(father->header().prehash());
     lock_qc_ = father->header().qc();
-    if(fafather != nullptr){
+    if(fafather != nullptr && fafather->header().view() == father->header().view() - 1){
      // LOG(ERROR)<<"get fafather view:"<<fafather->header().view();
       fafafather = GetProposal(fafather->header().prehash());
-      if(fafafather != nullptr){
-        //commit;
+      if(fafafather != nullptr && fafafather->header().view() == fafather->header().view() - 1){
       //  LOG(ERROR)<<"commit fafafather view:"<<fafafather->header().view();
-        commit_ready_proposal_ = FetchProposal(fafather->header().prehash());
+        auto fetched_proposal = FetchProposal(fafather->header().prehash());
+          while (fetched_proposal) {
+            auto got_proposal = fetched_proposal.get();
+            commit_ready_proposals_.push_back(std::move(fetched_proposal));
+            fetched_proposal = FetchProposal(got_proposal->header().prehash());
+        }
       }
     }
   }
   local_block_[proposal->hash()] = std::move(proposal);
-  return commit_ready_proposal_;
+  return commit_ready_proposals_;
 }
 
 const Proposal * ProposalManager::GetProposal(const std::string& hash){
@@ -151,11 +160,19 @@ const Proposal * ProposalManager::GetProposal(const std::string& hash){
 
 std::unique_ptr<Proposal> ProposalManager::FetchProposal(const std::string& hash){
   auto it = local_block_.find(hash);
-  assert(it != local_block_.end());
+  // assert(it != local_block_.end());
+  if (it == local_block_.end()) {
+    return nullptr;
+  }
   std::unique_ptr<Proposal> ret = std::move(it->second);
   local_block_.erase(it);
   return ret;
 }
 
-}  // namespace tusk
+int ProposalManager::GetLeader(int view){
+  //LOG(ERROR)<<" view:"<<view<<" next leader:"<<(view+1)%total_num_ + 1;
+  return view % total_num_ + 1;
+}
+
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/proposal_manager.h b/platform/consensus/ordering/hs/algorithm/proposal_manager.h
index 48957435..0e9523a2 100644
--- a/platform/consensus/ordering/hs/algorithm/proposal_manager.h
+++ b/platform/consensus/ordering/hs/algorithm/proposal_manager.h
@@ -2,13 +2,14 @@
 
 #include "platform/consensus/ordering/hs/proto/proposal.pb.h"
 #include "common/crypto/signature_verifier.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
 namespace hs {
 
 class ProposalManager {
  public:
-  ProposalManager(int32_t id, int limit_count, SignatureVerifier * verifier);
+  ProposalManager(int32_t id, int limit_count, SignatureVerifier * verifier, int total_num, int non_responsive_num, int fork_tail_num);
 
   std::unique_ptr<Proposal> GenerateProposal(const std::vector<std::unique_ptr<Transaction>>& txns);
   bool Verify(const Proposal& proposal);
@@ -17,9 +18,10 @@ class ProposalManager {
   int CurrentView();
 
   void AddQC(std::unique_ptr<QC> qc);
-  std::unique_ptr<Proposal> AddProposal(std::unique_ptr<Proposal> proposal);
+  std::vector<std::unique_ptr<Proposal>> AddProposal(std::unique_ptr<Proposal> proposal);
   const Proposal * GetProposal(const std::string& hash);
 
+  int GetLeader(int view);
 
   protected:
     std::string GetHash(const Proposal& proposal);
@@ -33,13 +35,17 @@ class ProposalManager {
   int32_t id_;
   int round_;
   int limit_count_;
+  int total_num_;
+  int non_responsive_num_;
+  int fork_tail_num_;
 
   std::mutex txn_mutex_;
   std::map<std::string, std::unique_ptr<Proposal> > local_block_;
 
   QC generic_qc_, lock_qc_;
   SignatureVerifier* verifier_;
+  Stats* global_stats_ = nullptr;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/framework/BUILD b/platform/consensus/ordering/hs/framework/BUILD
index cd052cc7..7c8b136d 100644
--- a/platform/consensus/ordering/hs/framework/BUILD
+++ b/platform/consensus/ordering/hs/framework/BUILD
@@ -8,6 +8,7 @@ cc_library(
         "//visibility:public",
     ],
     deps = [
+        ":performance_manager",
         "//common/utils",
         "//executor/common:transaction_manager",
         "//platform/consensus/ordering/common/framework:consensus",
@@ -17,4 +18,11 @@ cc_library(
     ],
 )
 
-
+cc_library(
+    name = "performance_manager",
+    srcs = ["performance_manager.cpp"],
+    hdrs = ["performance_manager.h"],
+    deps = [
+        "//platform/consensus/ordering/common/framework:performance_manager",
+    ],
+)
diff --git a/platform/consensus/ordering/hs/framework/consensus.cpp b/platform/consensus/ordering/hs/framework/consensus.cpp
index 80974721..54a70051 100644
--- a/platform/consensus/ordering/hs/framework/consensus.cpp
+++ b/platform/consensus/ordering/hs/framework/consensus.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -33,10 +33,19 @@
 namespace resdb {
 namespace hs {
 
+std::unique_ptr<HotStuffPerformanceManager> Consensus::GetPerformanceManager() {
+        return config_.IsPerformanceRunning()
+        ? std::make_unique<HotStuffPerformanceManager>(
+          config_, GetBroadCastClient(), GetSignatureVerifier())
+        : nullptr;
+}
+
 Consensus::Consensus(const ResDBConfig& config,
                      std::unique_ptr<TransactionManager> executor)
     : common::Consensus(config, std::move(executor)) {
 
+  SetPerformanceManager(GetPerformanceManager());
+
   Init();
 
   int total_replicas = config_.GetReplicaNum();
@@ -46,7 +55,7 @@ Consensus::Consensus(const ResDBConfig& config,
           .public_key()
           .public_key_info()
           .type() != CertificateKeyInfo::CLIENT) {
-    hs_= std::make_unique<HotStuff>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier());
+    hs_= std::make_unique<HotStuff>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier(), config_.GetNonResponsiveNum(), config_.GetForkTailNum());
     InitProtocol(hs_.get());
   }
 }
diff --git a/platform/consensus/ordering/hs/framework/consensus.h b/platform/consensus/ordering/hs/framework/consensus.h
index 8650b8f3..b8c39d17 100644
--- a/platform/consensus/ordering/hs/framework/consensus.h
+++ b/platform/consensus/ordering/hs/framework/consensus.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -29,6 +29,7 @@
 #include "platform/consensus/execution/transaction_executor.h"
 #include "platform/consensus/ordering/hs/algorithm/hs.h"
 #include "platform/consensus/ordering/common/framework/consensus.h"
+#include "platform/consensus/ordering/hs/framework/performance_manager.h"
 #include "platform/networkstrate/consensus_manager.h"
 
 namespace resdb {
@@ -45,9 +46,11 @@ class Consensus : public common::Consensus{
   int CommitMsg(const google::protobuf::Message& msg) override;
   int CommitMsgInternal(const Transaction& txn);
 
+  std::unique_ptr<HotStuffPerformanceManager> GetPerformanceManager();
+
   private:
     std::unique_ptr<HotStuff> hs_;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/framework/performance_manager.cpp b/platform/consensus/ordering/hs/framework/performance_manager.cpp
new file mode 100644
index 00000000..709be19c
--- /dev/null
+++ b/platform/consensus/ordering/hs/framework/performance_manager.cpp
@@ -0,0 +1,132 @@
+/*
+
+ *
+ * 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 "platform/consensus/ordering/hs/framework/performance_manager.h"
+
+#include <glog/logging.h>
+
+#include "common/utils/utils.h"
+
+namespace resdb {
+namespace hs {
+
+using comm::CollectorResultCode;
+
+HotStuffPerformanceManager::HotStuffPerformanceManager(
+    const ResDBConfig& config, ReplicaCommunicator* replica_communicator,
+    SignatureVerifier* verifier)
+    : PerformanceManager(config, replica_communicator, verifier){
+  client_num_ = 1;
+  primary_ = id_ % replica_num_;
+}
+
+int HotStuffPerformanceManager::GetPrimary(){
+  int view, value;
+  uint64_t crash_num_ = 10;
+  while (true) {
+    view = primary_;
+    primary_ += client_num_;
+    value = view % replica_num_ + 1;
+    int next_leader = (view+1) % replica_num_ + 1;
+    if (crash_num_ > 0) {
+      if (next_leader % 3 == 1 && next_leader < 3 * crash_num_) {
+        send_num_-=2;
+      }
+      if (value % 3 == 1 && value < 3 * crash_num_) {
+        count_++;
+        send_num_--;
+      }
+      if ((replica_num_ == 3*crash_num_ + 1 && value == 2) || (value == 3*crash_num_ + 2)) {
+        send_num_ += 2*count_;
+        count_ = 0;
+      }
+    }
+
+    if (value % 3 == 1 && value < 3 * config_.GetForkTailNum()) {
+      send_num_--;
+    }
+    LOG(ERROR) << "Send to "<< value << " with send_num_: " << send_num_ << " count: " << count_; 
+    return value;
+  } 
+}
+
+
+CollectorResultCode HotStuffPerformanceManager::AddResponseMsg(
+    std::unique_ptr<Request> request,
+    std::function<void(std::unique_ptr<BatchUserResponse>)> response_call_back) {
+  if (request == nullptr) {
+    return CollectorResultCode::INVALID;
+  }
+
+  //uint64_t seq = request->seq();
+
+  std::unique_ptr<BatchUserResponse> batch_response = std::make_unique<BatchUserResponse>();
+  if (!batch_response->ParseFromString(request->data())) {
+    LOG(ERROR) << "parse response fail:"<<request->data().size()
+    <<" seq:"<<request->seq(); return CollectorResultCode::INVALID;
+  }
+
+  uint64_t seq = batch_response->local_id();
+  //LOG(ERROR)<<"receive seq:"<<seq;
+
+  bool first = false;
+  bool done = false;
+  {
+    int idx = seq % response_set_size_;
+    std::unique_lock<std::mutex> lk(response_lock_[idx]);
+    if (response_[idx].find(seq) == response_[idx].end()) {
+      // LOG(ERROR)<<"has done local seq:"<<seq<<" global seq:"<<request->seq();
+      return CollectorResultCode::OK;
+    }
+    response_[idx][seq]++;
+    // LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" send:"<<send_num_;
+
+    if (response_[idx][seq] == 1) {
+      first = true;
+    }
+
+    if (response_[idx][seq] >= config_.GetMinClientReceiveNum()) {
+      //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" done:"<<send_num_;
+      response_[idx].erase(response_[idx].find(seq));
+      done = true;
+    }
+  }
+
+  if (first) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::FIRST_RESPONSE;
+  }
+
+  if (done) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::STATE_CHANGED;
+  }
+  return CollectorResultCode::OK;
+}
+
+
+
+}  // namespace hs
+}  // namespace resdb
\ No newline at end of file
diff --git a/common/crypto/signature_verifier_interface.h b/platform/consensus/ordering/hs/framework/performance_manager.h
similarity index 64%
copy from common/crypto/signature_verifier_interface.h
copy to platform/consensus/ordering/hs/framework/performance_manager.h
index eea1b410..047b52a6 100644
--- a/common/crypto/signature_verifier_interface.h
+++ b/platform/consensus/ordering/hs/framework/performance_manager.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -25,19 +25,27 @@
 
 #pragma once
 
-#include "absl/status/statusor.h"
-#include "common/proto/signature_info.pb.h"
+#include <future>
+
+#include "platform/consensus/ordering/common/framework/performance_manager.h"
 
 namespace resdb {
+namespace hs {
 
-// SignatureVerifier base class, provide an interface for communication.
-class SignatureVerifierInterface {
+class HotStuffPerformanceManager : public common::PerformanceManager {
  public:
-  SignatureVerifierInterface() = default;
-  virtual ~SignatureVerifierInterface() = default;
+  HotStuffPerformanceManager(const ResDBConfig& config,
+                     ReplicaCommunicator* replica_communicator,
+                     SignatureVerifier* verifier);
+
+protected:
+  comm::CollectorResultCode AddResponseMsg(
+      std::unique_ptr<Request> request,
+      std::function<void(std::unique_ptr<BatchUserResponse>)> call_back) override;
+  int GetPrimary() override;
 
-  // Sign messages using the private key.
-  virtual absl::StatusOr<SignatureInfo> SignMessage(const std::string& message);
+  int count_ = 0;
 };
 
-}  // namespace resdb
+}  // namespace hs
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/proto/proposal.proto b/platform/consensus/ordering/hs/proto/proposal.proto
index a5079050..ccb0d5e5 100644
--- a/platform/consensus/ordering/hs/proto/proposal.proto
+++ b/platform/consensus/ordering/hs/proto/proposal.proto
@@ -19,6 +19,7 @@ message Transaction{
   int32 proposer = 5;
   uint64 timestamp = 6;
   int64 user_seq = 7;
+  uint64 reception_time = 8;
 }
 
 enum ProposalType{
@@ -49,6 +50,7 @@ message Proposal {
   repeated Transaction transactions = 2;
   int32 sender = 3;
   bytes hash = 4;
+  uint64 createtime = 5;
 };
 
 enum MessageType {
diff --git a/platform/consensus/ordering/hs1/algorithm/BUILD b/platform/consensus/ordering/hs1/algorithm/BUILD
new file mode 100644
index 00000000..444c0fe1
--- /dev/null
+++ b/platform/consensus/ordering/hs1/algorithm/BUILD
@@ -0,0 +1,30 @@
+package(default_visibility = ["//platform/consensus/ordering/hs1:__subpackages__"])
+
+cc_library(
+    name = "proposal_manager",
+    srcs = ["proposal_manager.cpp"],
+    hdrs = ["proposal_manager.h"],
+    deps = [
+        "//common:comm",
+        "//common/crypto:signature_verifier",
+        "//common/utils",
+        "//platform/consensus/ordering/hs1/proto:proposal_cc_proto",
+        "//platform/statistic:stats",
+    ],
+)
+
+cc_library(
+    name = "hs1",
+    srcs = ["hs1.cpp"],
+    hdrs = ["hs1.h"],
+    deps = [
+        ":proposal_manager",
+        "//common:comm",
+        "//platform/common/queue:lock_free_queue",
+        "//platform/consensus/ordering/common/algorithm:protocol_base",
+        "//platform/statistic:stats",
+    ],
+)
+
+
+
diff --git a/platform/consensus/ordering/hs1/algorithm/hs1.cpp b/platform/consensus/ordering/hs1/algorithm/hs1.cpp
new file mode 100644
index 00000000..60248316
--- /dev/null
+++ b/platform/consensus/ordering/hs1/algorithm/hs1.cpp
@@ -0,0 +1,253 @@
+#include "platform/consensus/ordering/hs1/algorithm/hs1.h"
+
+#include <glog/logging.h>
+#include "common/utils/utils.h"
+
+
+namespace resdb {
+namespace hs1 {
+
+HotStuff1::HotStuff1(int id, int f, int total_num, SignatureVerifier * verifier, int non_responsive_num, int fork_tail_num, int rollback_num)
+  : ProtocolBase(id, f, total_num), verifier_(verifier), non_responsive_num_(non_responsive_num), fork_tail_num_(fork_tail_num), rollback_num_(rollback_num){
+
+    LOG(ERROR)<<"id:"<<id<<" f:"<<f<<" total:"<<total_num_;
+
+  global_stats_ = Stats::GetGlobalStats();
+  proposal_manager_ = std::make_unique<ProposalManager>(id, 2*f_+1, verifier, total_num, non_responsive_num, fork_tail_num, rollback_num);
+  has_sent_ = false;
+    send_thread_ = std::thread(&HotStuff1::AsyncSend, this);
+    commit_thread_ = std::thread(&HotStuff1::AsyncCommit, this);
+    batch_size_ = 1;
+  qc_formed_ = proposal_received_ = false;
+  timer_length_ = 10000;
+}
+
+HotStuff1::~HotStuff1() {
+}
+
+int HotStuff1::NextLeader(int view){
+  //LOG(ERROR)<<" view:"<<view<<" next leader:"<<(view+1)%total_num_ + 1;
+  return (view+1)%total_num_ + 1;
+}
+
+bool HotStuff1::IsLeader(int view){
+  return (view % total_num_)+1 == id_;
+}
+
+bool HotStuff1::Ready() {
+  int view = proposal_manager_->CurrentView();
+  return IsLeader(view) && !has_sent_;
+}
+
+void HotStuff1::StartNewRound() {
+  std::unique_lock<std::mutex> lk(n_mutex_);
+  has_sent_ = false;
+  vote_cv_.notify_one();
+  LOG(ERROR)<<" start new round";
+}
+
+void HotStuff1::AsyncSend() {
+  while (!IsStop()) {
+    auto txn = txns_.Pop();
+    if(txn == nullptr){
+      continue;
+    }
+
+    while(!IsStop()){
+      std::unique_lock<std::mutex> lk(n_mutex_);
+      vote_cv_.wait_for(lk, std::chrono::microseconds(1000),
+          [&] { return Ready(); });
+
+      if(Ready()){
+        break;
+      }
+    }
+    if(IsStop()){
+      return;
+    }
+
+    std::vector<std::unique_ptr<Transaction> > txns;
+    txns.push_back(std::move(txn));
+    for(int i = 1; i < batch_size_; ++i){
+      auto txn = txns_.Pop();
+      if(txn == nullptr){
+        continue;
+        //break;
+      }
+      txns.push_back(std::move(txn));
+    }
+
+    if (id_ < 3 * non_responsive_num_ && id_ % 3 == 1) {
+      usleep(timer_length_);
+    }
+
+    std::unique_ptr<Proposal> proposal = nullptr;
+    std::unique_ptr<Proposal> proposal2 = nullptr;
+    {
+      std::unique_lock<std::mutex> lk(mutex_);
+      proposal = proposal_manager_ -> GenerateProposal(txns);
+      if(id_ < 3 * rollback_num_ && id_ % 3 ==1) {
+        proposal2 = proposal_manager_ -> GenerateFakeProposal(txns);
+      } 
+      //LOG(ERROR)<<"propose view:"<<proposal->header().view();
+    }
+    has_sent_ = true;
+    if (proposal2 != nullptr) {
+      // LOG(ERROR) << "Rollbakc Attack Done by " << id_;
+      for(int i = 1; i <= total_num_; i++) {
+        if (i % 3 == 0 && i <= 3 * f_) {
+          SendMessage(MessageType::NewProposal, *proposal2, i);
+        } else {
+          SendMessage(MessageType::NewProposal, *proposal, i);
+        }
+      }
+    } else {
+      broadcast_call_(MessageType::NewProposal, *proposal);
+    }
+  }
+}
+
+void HotStuff1::AsyncCommit() {
+  int seq = 1;
+  while (!IsStop()) {
+    auto p = commit_q_.Pop();
+    if(p == nullptr){
+      continue;
+    }
+    global_stats_->AddConsensusLatency(GetCurrentTime()-p->createtime());
+    for(Transaction& txn : *p->mutable_transactions()){
+      txn.set_id(seq++);
+      Commit(txn);
+    }
+  }
+}
+
+
+bool HotStuff1::ReceiveTransaction(std::unique_ptr<Transaction> txn) {
+  //  std::unique_lock<std::mutex> lk(txn_mutex_);
+  txn->set_reception_time(GetCurrentTime());
+  txn->set_proposer(id_);
+  txns_.Push(std::move(txn));
+  return true;
+}
+
+bool HotStuff1::ReceiveProposal(std::unique_ptr<Proposal> proposal) {
+  if (IsSlowReplica(id_)) {
+    usleep(GetRandomDelay());
+  }
+    int view = proposal->header().view();
+    std::unique_ptr<Certificate> cert = nullptr;
+  {
+    LOG(ERROR)<<"[X]process proposer view:"<<view<< " at " << (GetCurrentTime() - last_time_) << " " << GetCurrentTime();
+    last_time_ = GetCurrentTime();
+    //LOG(ERROR)<<"RECEIVE proposer view:"<<proposal->header().view();
+    std::unique_lock<std::mutex> lk(mutex_);
+    if (id_ == NextLeader(view)) {
+      proposal_received_ = true;
+    }
+    if(!proposal_manager_->Verify(*proposal)){
+      LOG(ERROR)<<" proposal invalid";
+      return false;
+    }
+
+    cert = GenerateCertificate(*proposal);
+    assert(cert != nullptr);
+
+    std::vector<std::unique_ptr<Proposal>> committed_p_list = proposal_manager_->AddProposal(std::move(proposal));
+    for (int i=committed_p_list.size()-1; i>=0; i--) {
+      CommitProposal(std::move(committed_p_list[i]));
+    }
+
+    //LOG(ERROR)<<"send cert view:"<<view<<" to:"<<NextLeader(view);
+    if (qc_formed_) {
+      // LOG(ERROR) << "after proposal recieeved";
+      proposal_manager_->AddQC(std::move(formed_qc_));
+      StartNewRound();
+      qc_formed_ = proposal_received_ = false;
+    }
+  }
+
+  int next_leader = proposal_manager_->GetLeader(view+1);
+
+  SendMessage(MessageType::Vote, *cert, next_leader);
+
+  if (next_leader % 3 == 1 && next_leader <= 3 * crash_num_) {
+    int next_next_leader = proposal_manager_->GetLeader(view+2);
+    if (id_ == next_next_leader) {
+      proposal_received_ = true;
+    }
+    cert->set_view(view+1);
+    usleep(timer_length_);
+    SendMessage(MessageType::Vote, *cert, next_next_leader);
+  }
+
+  return true;
+}
+
+bool HotStuff1::ReceiveCertificate(std::unique_ptr<Certificate> cert) {
+
+  if (id_ % 3 == 1 && id_ <= 3*crash_num_) {
+    return true;
+  }
+
+  LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
+  std::unique_lock<std::mutex> lk(mutex_);
+  //LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
+  bool valid = proposal_manager_->VerifyCert(*cert);
+  if(!valid){
+    LOG(ERROR) << "Verify message fail";
+    assert(1==0);
+    return false;
+  }
+
+  int view = cert->view();
+  std::string hash = cert->hash();
+  receive_[view][hash].insert(std::make_pair(cert->signer(), std::move(cert)));
+
+  // LOG(ERROR)<<"RECEIVE proposer cert :"<<view<<" size:"<<receive_[view][hash].size();
+  if(receive_[view][hash].size() == 2*f_+1){
+    std::unique_ptr<QC> qc = std::make_unique<QC>();
+    qc->set_hash(hash);
+    qc->set_view(view);
+
+    for(auto & it: receive_[view][hash]){
+      *qc->add_signatures() = it.second->sign();
+    }
+
+    qc_formed_ = true;
+    if (proposal_received_) {
+      LOG(ERROR) << "after qc formed";
+      proposal_manager_->AddQC(std::move(qc));
+      StartNewRound();
+      qc_formed_ = proposal_received_ = false;
+    } else {
+      formed_qc_ = std::move(qc);
+    }
+    //LOG(ERROR)<<"add qc view:"<<view;
+  }
+  // LOG(ERROR) << "done";
+  return true;
+}
+
+void HotStuff1::CommitProposal(std::unique_ptr<Proposal> p){
+  commit_q_.Push(std::move(p));
+}
+
+std::unique_ptr<Certificate> HotStuff1::GenerateCertificate(const Proposal& proposal) {
+  std::unique_ptr<Certificate> cert = std::make_unique<Certificate>();
+  cert->set_hash(proposal.hash());
+  cert->set_view(proposal.header().view());
+  cert->set_signer(id_);
+
+  std::string data_str = proposal.hash();
+  auto hash_signature_or = verifier_->SignMessage(data_str);
+  if (!hash_signature_or.ok()) {
+    LOG(ERROR) << "Sign message fail";
+    return nullptr;
+  }
+  *cert->mutable_sign()=*hash_signature_or;
+  return cert;
+}
+
+}  // namespace hs
+}  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/hs.h b/platform/consensus/ordering/hs1/algorithm/hs1.h
similarity index 67%
copy from platform/consensus/ordering/hs/algorithm/hs.h
copy to platform/consensus/ordering/hs1/algorithm/hs1.h
index 04148a37..38063ee6 100644
--- a/platform/consensus/ordering/hs/algorithm/hs.h
+++ b/platform/consensus/ordering/hs1/algorithm/hs1.h
@@ -3,17 +3,18 @@
 #include <thread>
 
 #include "platform/common/queue/lock_free_queue.h"
-#include "platform/consensus/ordering/hs/algorithm/proposal_manager.h"
-#include "platform/consensus/ordering/hs/proto/proposal.pb.h"
+#include "platform/consensus/ordering/hs1/algorithm/proposal_manager.h"
+#include "platform/consensus/ordering/hs1/proto/proposal.pb.h"
 #include "platform/consensus/ordering/common/algorithm/protocol_base.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
-namespace hs {
+namespace hs1 {
 
-class HotStuff: public common::ProtocolBase {
+class HotStuff1: public common::ProtocolBase {
  public:
-  HotStuff(int id, int f, int total_num, SignatureVerifier* verifier );
-  ~HotStuff();
+  HotStuff1(int id, int f, int total_num, SignatureVerifier* verifier, int non_responsive_num, int fork_tail_num, int rollback_num);
+  ~HotStuff1();
 
   //  recv txn -> send block with links -> rec block ack -> send block with certs
   bool ReceiveTransaction(std::unique_ptr<Transaction> txn);
@@ -51,8 +52,18 @@ class HotStuff: public common::ProtocolBase {
   //[view][hash][signer][cert]
   //std::map<std::string, std::map<int, std::unique_ptr<Certificate>> >  receive_[1024];
   std::map<int,  std::map<std::string, std::map<int, std::unique_ptr<Certificate>> > > receive_;
+  Stats* global_stats_ = nullptr;
 
+  int non_responsive_num_, fork_tail_num_, rollback_num_;
+  uint64_t timer_length_;
+
+  uint64_t last_time_ = 0;
+
+  bool qc_formed_, proposal_received_;
+  std::unique_ptr<QC> formed_qc_;
+
+  uint64_t crash_num_ = 0;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp b/platform/consensus/ordering/hs1/algorithm/proposal_manager.cpp
similarity index 51%
copy from platform/consensus/ordering/hs/algorithm/proposal_manager.cpp
copy to platform/consensus/ordering/hs1/algorithm/proposal_manager.cpp
index 72287e43..0e9a70dd 100644
--- a/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp
+++ b/platform/consensus/ordering/hs1/algorithm/proposal_manager.cpp
@@ -1,15 +1,17 @@
-#include "platform/consensus/ordering/hs/algorithm/proposal_manager.h"
+#include "platform/consensus/ordering/hs1/algorithm/proposal_manager.h"
 
 #include <glog/logging.h>
 #include "common/utils/utils.h"
 #include "common/crypto/signature_verifier.h"
 
 namespace resdb {
-namespace hs {
+namespace hs1 {
 
-ProposalManager::ProposalManager(int32_t id, int limit_count, SignatureVerifier* verifier)
-    : id_(id), limit_count_(limit_count), verifier_(verifier) {
+ProposalManager::ProposalManager(int32_t id, int limit_count, SignatureVerifier* verifier, int total_num, int non_responsive_num, int fork_tail_num, int rollback_num)
+    : id_(id), limit_count_(limit_count), verifier_(verifier), total_num_(total_num), non_responsive_num_(non_responsive_num), fork_tail_num_(fork_tail_num), rollback_num_(rollback_num) {
     round_ = 1;
+    timer_length = 10000;
+    global_stats_ = Stats::GetGlobalStats();
     assert(verifier_ != nullptr);
 }
 
@@ -84,6 +86,7 @@ std::unique_ptr<Proposal> ProposalManager::GenerateProposal(
   {
     std::unique_lock<std::mutex> lk(txn_mutex_);
     for(const auto& txn: txns){
+      global_stats_->AddProposeLatency(GetCurrentTime() - txn->reception_time());
       *proposal->add_transactions() = *txn;
     }
     if(!generic_qc_.hash().empty()){
@@ -95,7 +98,31 @@ std::unique_ptr<Proposal> ProposalManager::GenerateProposal(
     proposal->mutable_header()->set_view(round_);
     proposal->set_sender(id_);
   }
+  proposal->set_createtime(GetCurrentTime());
+  proposal->set_hash(GetHash(*proposal));
+  proposal->set_primary_id(id_);
+  return proposal;
+}
+
+std::unique_ptr<Proposal> ProposalManager::GenerateFakeProposal(
+    const std::vector<std::unique_ptr<Transaction>>& txns) {
+  std::unique_ptr<Proposal> proposal = std::make_unique<Proposal>();
+  {
+    std::unique_lock<std::mutex> lk(txn_mutex_);
+    for(const auto& txn: txns){
+      global_stats_->AddProposeLatency(GetCurrentTime() - txn->reception_time());
+      *proposal->add_transactions() = *txn;
+    }
+    if(!fake_generic_qc_.hash().empty()){
+     //LOG(ERROR)<<" add qc:"<<generic_qc_.view();
+      proposal->mutable_header()->set_prehash(fake_generic_qc_.hash());
+      *proposal->mutable_header()->mutable_qc() = fake_generic_qc_;
+    }
 
+    proposal->mutable_header()->set_view(round_);
+    proposal->set_sender(id_);
+  }
+  proposal->set_createtime(GetCurrentTime());
   proposal->set_hash(GetHash(*proposal));
   return proposal;
 }
@@ -107,38 +134,64 @@ int ProposalManager::CurrentView(){
 void ProposalManager::AddQC(std::unique_ptr<QC> qc){
   std::unique_lock<std::mutex> lk(txn_mutex_);
   if(generic_qc_.view() == 0 || generic_qc_.view() < qc->view()){
-    generic_qc_ = *qc;
-    round_ = generic_qc_.view()+1;
+    int leader = GetLeader(qc->view());
+    if (fork_tail_num_) {
+      // IGNORE the QC for the victim proposal
+      if(!(leader < 3 * fork_tail_num_ && leader % 3 ==1)) {
+        generic_qc_ = *qc;
+      } 
+    } else if (rollback_num_) {
+      if(id_ < 3 * rollback_num_ && id_ % 3 ==1) {
+        fake_generic_qc_ = *qc;
+      } else {
+        generic_qc_ = *qc;
+      }
+    } else {
+      generic_qc_ = *qc;
+    }
+    
+    round_ = qc->view()+1;
   //  LOG(ERROR)<<"get new round:"<<round_;
   }
 }
 
-std::unique_ptr<Proposal> ProposalManager::AddProposal(std::unique_ptr<Proposal> proposal){
+std::vector<std::unique_ptr<Proposal>> ProposalManager::AddProposal(std::unique_ptr<Proposal> proposal){
   //LOG(ERROR)<<"ADD PROPOSAL";
   std::unique_lock<std::mutex> lk(txn_mutex_);
   if(generic_qc_.view() < proposal->header().qc().view()){
     generic_qc_ = proposal->header().qc();
   }
 
-  std::unique_ptr<Proposal> commit_ready_proposal_ = nullptr;
-  const Proposal * father = nullptr, * fafather = nullptr, * fafafather = nullptr;
+  std::vector<std::unique_ptr<Proposal>> commit_ready_proposals_;
+  const Proposal * father = nullptr;
+  const Proposal * fafather = nullptr;
   father = GetProposal(proposal->header().prehash());
-  if(father != nullptr){
+  if(father != nullptr){ // Attempt to Speculate on father
     //LOG(ERROR)<<"get father view:"<<father->header().view();
-    fafather = GetProposal(father->header().prehash());
     lock_qc_ = father->header().qc();
-    if(fafather != nullptr){
-     // LOG(ERROR)<<"get fafather view:"<<fafather->header().view();
-      fafafather = GetProposal(fafather->header().prehash());
-      if(fafafather != nullptr){
-        //commit;
-      //  LOG(ERROR)<<"commit fafafather view:"<<fafafather->header().view();
-        commit_ready_proposal_ = FetchProposal(fafather->header().prehash());
+    fafather = GetProposal(father->header().prehash());
+    if (father->header().view() == proposal->header().view() - 1) { // No-Gap Rule
+      if (fafather == nullptr || fafather->header().view() == father->header().view() - 1) {  // Prefix Speculation Rule
+        auto fetched_proposal = FetchProposal(proposal->header().prehash());
+        while (fetched_proposal) {
+          auto got_proposal = fetched_proposal.get();
+          commit_ready_proposals_.push_back(std::move(fetched_proposal));
+          fetched_proposal = FetchProposal(got_proposal->header().prehash());
+        }
+      }
+    } else {  // Attempt to Commit fafather
+      if (fafather != nullptr && fafather->header().view() == father->header().view() - 1) {
+        auto fetched_proposal = FetchProposal(father->header().prehash());
+        while (fetched_proposal) {
+          auto got_proposal = fetched_proposal.get();
+          commit_ready_proposals_.push_back(std::move(fetched_proposal));
+          fetched_proposal = FetchProposal(got_proposal->header().prehash());
+        }
       }
     }
   }
   local_block_[proposal->hash()] = std::move(proposal);
-  return commit_ready_proposal_;
+  return commit_ready_proposals_;
 }
 
 const Proposal * ProposalManager::GetProposal(const std::string& hash){
@@ -151,11 +204,19 @@ const Proposal * ProposalManager::GetProposal(const std::string& hash){
 
 std::unique_ptr<Proposal> ProposalManager::FetchProposal(const std::string& hash){
   auto it = local_block_.find(hash);
-  assert(it != local_block_.end());
+  // assert(it != local_block_.end());
+  if (it == local_block_.end()) {
+    return nullptr;
+  }
   std::unique_ptr<Proposal> ret = std::move(it->second);
   local_block_.erase(it);
   return ret;
 }
 
-}  // namespace tusk
+int ProposalManager::GetLeader(int view){
+  //LOG(ERROR)<<" view:"<<view<<" next leader:"<<(view+1)%total_num_ + 1;
+  return view % total_num_ + 1;
+}
+
+}  // namespace hs1
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/proposal_manager.h b/platform/consensus/ordering/hs1/algorithm/proposal_manager.h
similarity index 61%
copy from platform/consensus/ordering/hs/algorithm/proposal_manager.h
copy to platform/consensus/ordering/hs1/algorithm/proposal_manager.h
index 48957435..631f8626 100644
--- a/platform/consensus/ordering/hs/algorithm/proposal_manager.h
+++ b/platform/consensus/ordering/hs1/algorithm/proposal_manager.h
@@ -1,25 +1,28 @@
 #pragma once
 
-#include "platform/consensus/ordering/hs/proto/proposal.pb.h"
+#include "platform/consensus/ordering/hs1/proto/proposal.pb.h"
 #include "common/crypto/signature_verifier.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
-namespace hs {
+namespace hs1 {
 
 class ProposalManager {
  public:
-  ProposalManager(int32_t id, int limit_count, SignatureVerifier * verifier);
+  ProposalManager(int32_t id, int limit_count, SignatureVerifier * verifier, int total_num, int non_responsive_num, int fork_tail_num, int rollback_num);
 
   std::unique_ptr<Proposal> GenerateProposal(const std::vector<std::unique_ptr<Transaction>>& txns);
+  std::unique_ptr<Proposal> GenerateFakeProposal(const std::vector<std::unique_ptr<Transaction>>& txns);
   bool Verify(const Proposal& proposal);
   bool VerifyCert(const Certificate& cert);
 
   int CurrentView();
 
   void AddQC(std::unique_ptr<QC> qc);
-  std::unique_ptr<Proposal> AddProposal(std::unique_ptr<Proposal> proposal);
+  std::vector<std::unique_ptr<Proposal>> AddProposal(std::unique_ptr<Proposal> proposal);
   const Proposal * GetProposal(const std::string& hash);
 
+  int GetLeader(int view);
 
   protected:
     std::string GetHash(const Proposal& proposal);
@@ -37,9 +40,14 @@ class ProposalManager {
   std::mutex txn_mutex_;
   std::map<std::string, std::unique_ptr<Proposal> > local_block_;
 
-  QC generic_qc_, lock_qc_;
+  QC generic_qc_, lock_qc_, fake_generic_qc_;
   SignatureVerifier* verifier_;
+
+  int timer_length;
+  int total_num_;
+  int non_responsive_num_, fork_tail_num_, rollback_num_;
+  Stats* global_stats_ = nullptr;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/framework/BUILD b/platform/consensus/ordering/hs1/framework/BUILD
similarity index 60%
copy from platform/consensus/ordering/hs/framework/BUILD
copy to platform/consensus/ordering/hs1/framework/BUILD
index cd052cc7..4f8275cd 100644
--- a/platform/consensus/ordering/hs/framework/BUILD
+++ b/platform/consensus/ordering/hs1/framework/BUILD
@@ -8,13 +8,21 @@ cc_library(
         "//visibility:public",
     ],
     deps = [
+        ":performance_manager",
         "//common/utils",
         "//executor/common:transaction_manager",
         "//platform/consensus/ordering/common/framework:consensus",
         "//platform/consensus/execution:transaction_executor",
-        "//platform/consensus/ordering/hs/algorithm:hs",
+        "//platform/consensus/ordering/hs1/algorithm:hs1",
         "//platform/networkstrate:consensus_manager",
     ],
 )
 
-
+cc_library(
+    name = "performance_manager",
+    srcs = ["performance_manager.cpp"],
+    hdrs = ["performance_manager.h"],
+    deps = [
+        "//platform/consensus/ordering/common/framework:performance_manager",
+    ],
+)
diff --git a/platform/consensus/ordering/hs/framework/consensus.cpp b/platform/consensus/ordering/hs1/framework/consensus.cpp
similarity index 79%
copy from platform/consensus/ordering/hs/framework/consensus.cpp
copy to platform/consensus/ordering/hs1/framework/consensus.cpp
index 80974721..b88359ab 100644
--- a/platform/consensus/ordering/hs/framework/consensus.cpp
+++ b/platform/consensus/ordering/hs1/framework/consensus.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -23,7 +23,7 @@
  *
  */
 
-#include "platform/consensus/ordering/hs/framework/consensus.h"
+#include "platform/consensus/ordering/hs1/framework/consensus.h"
 
 #include <glog/logging.h>
 #include <unistd.h>
@@ -31,12 +31,22 @@
 #include "common/utils/utils.h"
 
 namespace resdb {
-namespace hs {
+namespace hs1 {
+
+std::unique_ptr<HotStuff1PerformanceManager> Consensus::GetPerformanceManager() {
+        return config_.IsPerformanceRunning()
+        ? std::make_unique<HotStuff1PerformanceManager>(
+          config_, GetBroadCastClient(), GetSignatureVerifier())
+        : nullptr;
+}
+
 
 Consensus::Consensus(const ResDBConfig& config,
                      std::unique_ptr<TransactionManager> executor)
     : common::Consensus(config, std::move(executor)) {
 
+  SetPerformanceManager(GetPerformanceManager());
+
   Init();
 
   int total_replicas = config_.GetReplicaNum();
@@ -46,8 +56,8 @@ Consensus::Consensus(const ResDBConfig& config,
           .public_key()
           .public_key_info()
           .type() != CertificateKeyInfo::CLIENT) {
-    hs_= std::make_unique<HotStuff>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier());
-    InitProtocol(hs_.get());
+    hs1_= std::make_unique<HotStuff1>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier(), config_.GetNonResponsiveNum(), config_.GetForkTailNum(), config_.GetRollBackNum());
+    InitProtocol(hs1_.get());
   }
 }
 
@@ -62,7 +72,7 @@ int Consensus::ProcessCustomConsensus(std::unique_ptr<Request> request) {
       assert(1 == 0);
       return -1;
     }
-    hs_->ReceiveProposal(std::move(p));
+    hs1_->ReceiveProposal(std::move(p));
   }
   else if(request->user_type() == MessageType::Vote) {
     std::unique_ptr<Certificate> cert = std::make_unique<Certificate>();
@@ -71,7 +81,7 @@ int Consensus::ProcessCustomConsensus(std::unique_ptr<Request> request) {
       assert(1 == 0);
       return -1;
     }
-    hs_->ReceiveCertificate(std::move(cert));
+    hs1_->ReceiveCertificate(std::move(cert));
   }
   return 0;
 }
@@ -82,7 +92,7 @@ int Consensus::ProcessNewTransaction(std::unique_ptr<Request> request) {
   txn->set_hash(request->hash());
   txn->set_proxy_id(request->proxy_id());
   txn->set_user_seq(request->user_seq());
-  return hs_->ReceiveTransaction(std::move(txn));
+  return hs1_->ReceiveTransaction(std::move(txn));
 }
 
 int Consensus::CommitMsg(const google::protobuf::Message& msg) {
@@ -95,6 +105,7 @@ int Consensus::CommitMsgInternal(const Transaction& txn) {
   request->set_data(txn.data());
   request->set_seq(txn.id());
   request->set_proxy_id(txn.proxy_id());
+  request->set_primary_id(txn.proposer());
   transaction_executor_->AddExecuteMessage(std::move(request));
   return 0;
 }
diff --git a/platform/consensus/ordering/hs/framework/consensus.h b/platform/consensus/ordering/hs1/framework/consensus.h
similarity index 86%
copy from platform/consensus/ordering/hs/framework/consensus.h
copy to platform/consensus/ordering/hs1/framework/consensus.h
index 8650b8f3..537adc37 100644
--- a/platform/consensus/ordering/hs/framework/consensus.h
+++ b/platform/consensus/ordering/hs1/framework/consensus.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -27,12 +27,13 @@
 
 #include "executor/common/transaction_manager.h"
 #include "platform/consensus/execution/transaction_executor.h"
-#include "platform/consensus/ordering/hs/algorithm/hs.h"
+#include "platform/consensus/ordering/hs1/algorithm/hs1.h"
 #include "platform/consensus/ordering/common/framework/consensus.h"
+#include "platform/consensus/ordering/hs1/framework/performance_manager.h"
 #include "platform/networkstrate/consensus_manager.h"
 
 namespace resdb {
-namespace hs {
+namespace hs1 {
 
 class Consensus : public common::Consensus{
  public:
@@ -45,9 +46,11 @@ class Consensus : public common::Consensus{
   int CommitMsg(const google::protobuf::Message& msg) override;
   int CommitMsgInternal(const Transaction& txn);
 
+  std::unique_ptr<HotStuff1PerformanceManager> GetPerformanceManager();
+
   private:
-    std::unique_ptr<HotStuff> hs_;
+    std::unique_ptr<HotStuff1> hs1_;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs1/framework/performance_manager.cpp b/platform/consensus/ordering/hs1/framework/performance_manager.cpp
new file mode 100644
index 00000000..10bbf059
--- /dev/null
+++ b/platform/consensus/ordering/hs1/framework/performance_manager.cpp
@@ -0,0 +1,183 @@
+/*
+
+ *
+ * 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 "platform/consensus/ordering/hs1/framework/performance_manager.h"
+
+#include <glog/logging.h>
+
+#include "common/utils/utils.h"
+
+namespace resdb {
+namespace hs1 {
+
+using comm::CollectorResultCode;
+
+HotStuff1PerformanceManager::HotStuff1PerformanceManager(
+    const ResDBConfig& config, ReplicaCommunicator* replica_communicator,
+    SignatureVerifier* verifier)
+    : PerformanceManager(config, replica_communicator, verifier){
+  client_num_ = 1;
+  primary_ = id_ % replica_num_;
+}
+
+
+CollectorResultCode HotStuff1PerformanceManager::AddResponseMsg(
+    std::unique_ptr<Request> request,
+    std::function<void(std::unique_ptr<BatchUserResponse>)> response_call_back) {
+  if (request == nullptr) {
+    return CollectorResultCode::INVALID;
+  }
+
+  //uint64_t seq = request->seq();
+
+  std::unique_ptr<BatchUserResponse> batch_response = std::make_unique<BatchUserResponse>();
+  if (!batch_response->ParseFromString(request->data())) {
+    LOG(ERROR) << "parse response fail:"<<request->data().size()
+    <<" seq:"<<request->seq(); return CollectorResultCode::INVALID;
+  }
+
+  uint64_t seq = batch_response->local_id();
+  //LOG(ERROR)<<"receive seq:"<<seq;
+
+  bool first = false;
+  bool done = false;
+  {
+    int idx = seq % response_set_size_;
+    std::unique_lock<std::mutex> lk(response_lock_[idx]);
+    if (response_[idx].find(seq) == response_[idx].end()) {
+      //LOG(ERROR)<<"has done local seq:"<<seq<<" global seq:"<<request->seq();
+      return CollectorResultCode::OK;
+    }
+    response_[idx][seq]++;
+    //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" send:"<<send_num_;
+
+    if (response_[idx][seq] == 1) {
+      first = true;
+    }
+
+    if (response_[idx][seq] >= config_.GetMinDataReceiveNum()) {
+      //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" done:"<<send_num_;
+      response_[idx].erase(response_[idx].find(seq));
+      done = true;
+    }
+  }
+
+  if (first) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::FIRST_RESPONSE;
+  }
+
+  if (done) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::STATE_CHANGED;
+  }
+  return CollectorResultCode::OK;
+}
+
+int HotStuff1PerformanceManager::GetPrimary(){
+  int view, value;
+  while (true) {
+    view = primary_;
+    // if (view == 1) {
+    //    send_num_ -= 1;
+    // }
+    primary_ += client_num_;
+    value = view % replica_num_ + 1;
+    if (value % 3 == 1 && value < 3 * crash_num_) {
+      send_num_ --;
+    }
+    if (crash_num_ > 0) {
+      if (value == 3 * crash_num_ + 1) {
+        send_num_ ++;
+      }
+      if (value == replica_num_) {
+        send_num_ --;
+      }
+    }
+
+    if (value % 3 == 1 && value < 3 * config_.GetForkTailNum()) {
+      send_num_--;
+    }
+    if (value % 3 == 1 && value < 3 * config_.GetRollBackNum()) {
+      send_num_--;
+    }
+    LOG(ERROR) << "Send to "<< value << " with send_num_: " << send_num_; 
+    return value;
+  } 
+}
+
+// =================== response ========================
+// handle the response message. If receive f+1 commit messages, send back to the
+// user.
+int HotStuff1PerformanceManager::ProcessResponseMsg(std::unique_ptr<Context> context,
+                                           std::unique_ptr<Request> request) {
+  std::unique_ptr<Request> response;
+  // Add the response message, and use the call back to collect the received
+  // messages.
+  // The callback will be triggered if it received f+1 messages.
+  if (request->ret() == -2) {
+    // LOG(INFO) << "get response fail:" << request->ret();
+    send_num_--;
+    return 0;
+  }
+
+  LOG(INFO) << "get response:" << request->seq() << " sender:"<<request->sender_id();
+  std::unique_ptr<BatchUserResponse> batch_response = nullptr;
+  CollectorResultCode ret =
+      AddResponseMsg(std::move(request), [&](std::unique_ptr<BatchUserResponse> request) {
+        batch_response = std::move(request);
+        return;
+      });
+
+  if (config_.NetworkDelayNum() > 0) {
+    if (ret == CollectorResultCode::FIRST_RESPONSE) {
+      assert(batch_response);
+      int primary_id = batch_response->primary_id();
+      // LOG(ERROR) << "here: " << primary_id;
+      inflight_[primary_id]--;
+      last_response_ = primary_id;
+      send_num_--;
+
+    } 
+    if (ret == CollectorResultCode::STATE_CHANGED) {
+      assert(batch_response);
+      SendResponseToClient(*batch_response);
+    }
+  }
+  else {
+    if (ret == CollectorResultCode::STATE_CHANGED) {
+      assert(batch_response);
+      int primary_id = batch_response->primary_id();
+      LOG(ERROR) << "primary_id: " << primary_id;
+      inflight_[primary_id]--;
+      last_response_ = primary_id;
+      SendResponseToClient(*batch_response);
+    }
+  }
+  return ret == CollectorResultCode::INVALID ? -2 : 0;
+}
+
+}  // namespace hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/common/crypto/signature_verifier_interface.h b/platform/consensus/ordering/hs1/framework/performance_manager.h
similarity index 57%
copy from common/crypto/signature_verifier_interface.h
copy to platform/consensus/ordering/hs1/framework/performance_manager.h
index eea1b410..c97f5548 100644
--- a/common/crypto/signature_verifier_interface.h
+++ b/platform/consensus/ordering/hs1/framework/performance_manager.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -25,19 +25,32 @@
 
 #pragma once
 
-#include "absl/status/statusor.h"
-#include "common/proto/signature_info.pb.h"
+#include <future>
+
+#include "platform/config/resdb_config.h"
+#include "platform/consensus/ordering/common/framework/performance_manager.h"
 
 namespace resdb {
+namespace hs1 {
 
-// SignatureVerifier base class, provide an interface for communication.
-class SignatureVerifierInterface {
+class HotStuff1PerformanceManager : public common::PerformanceManager {
  public:
-  SignatureVerifierInterface() = default;
-  virtual ~SignatureVerifierInterface() = default;
+  HotStuff1PerformanceManager(const ResDBConfig& config,
+                     ReplicaCommunicator* replica_communicator,
+                     SignatureVerifier* verifier);
+
+  int ProcessResponseMsg(std::unique_ptr<Context> context,
+                                           std::unique_ptr<Request> request) override;
+
+protected:
+  comm::CollectorResultCode AddResponseMsg(
+      std::unique_ptr<Request> request,
+      std::function<void(std::unique_ptr<BatchUserResponse>)> call_back) override;
+  int GetPrimary() override;
 
-  // Sign messages using the private key.
-  virtual absl::StatusOr<SignatureInfo> SignMessage(const std::string& message);
+private:
+  int crash_num_ = 0;
 };
 
-}  // namespace resdb
+}  // namespace hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs1/proto/BUILD b/platform/consensus/ordering/hs1/proto/BUILD
new file mode 100644
index 00000000..84cf9f9d
--- /dev/null
+++ b/platform/consensus/ordering/hs1/proto/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//platform/consensus/ordering/hs1:__subpackages__"])
+
+load("@rules_cc//cc:defs.bzl", "cc_proto_library")
+load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
+
+proto_library(
+    name = "proposal_proto",
+    srcs = ["proposal.proto"],
+    deps = ["//common/proto:signature_info_proto"],
+)
+
+cc_proto_library(
+    name = "proposal_cc_proto",
+    deps = [":proposal_proto"],
+)
diff --git a/platform/consensus/ordering/hs/proto/proposal.proto b/platform/consensus/ordering/hs1/proto/proposal.proto
similarity index 90%
copy from platform/consensus/ordering/hs/proto/proposal.proto
copy to platform/consensus/ordering/hs1/proto/proposal.proto
index a5079050..cc2a36a2 100644
--- a/platform/consensus/ordering/hs/proto/proposal.proto
+++ b/platform/consensus/ordering/hs1/proto/proposal.proto
@@ -1,7 +1,7 @@
 syntax = "proto3";
 import "common/proto/signature_info.proto";
 
-package resdb.hs;
+package resdb.hs1;
 
 message Certificate {
   SignatureInfo sign = 1;
@@ -19,6 +19,7 @@ message Transaction{
   int32 proposer = 5;
   uint64 timestamp = 6;
   int64 user_seq = 7;
+  uint64 reception_time = 8;
 }
 
 enum ProposalType{
@@ -49,6 +50,8 @@ message Proposal {
   repeated Transaction transactions = 2;
   int32 sender = 3;
   bytes hash = 4;
+  uint64 createtime = 5;
+  int32 primary_id = 6;
 };
 
 enum MessageType {
diff --git a/platform/consensus/ordering/hs2/algorithm/BUILD b/platform/consensus/ordering/hs2/algorithm/BUILD
new file mode 100644
index 00000000..d8a436cb
--- /dev/null
+++ b/platform/consensus/ordering/hs2/algorithm/BUILD
@@ -0,0 +1,30 @@
+package(default_visibility = ["//platform/consensus/ordering/hs2:__subpackages__"])
+
+cc_library(
+    name = "proposal_manager",
+    srcs = ["proposal_manager.cpp"],
+    hdrs = ["proposal_manager.h"],
+    deps = [
+        "//common:comm",
+        "//common/crypto:signature_verifier",
+        "//common/utils",
+        "//platform/consensus/ordering/hs2/proto:proposal_cc_proto",
+        "//platform/statistic:stats",
+    ],
+)
+
+cc_library(
+    name = "hs2",
+    srcs = ["hs2.cpp"],
+    hdrs = ["hs2.h"],
+    deps = [
+        ":proposal_manager",
+        "//common:comm",
+        "//platform/common/queue:lock_free_queue",
+        "//platform/consensus/ordering/common/algorithm:protocol_base",
+        "//platform/statistic:stats",
+    ],
+)
+
+
+
diff --git a/platform/consensus/ordering/hs/algorithm/hs.cpp b/platform/consensus/ordering/hs2/algorithm/hs2.cpp
similarity index 55%
copy from platform/consensus/ordering/hs/algorithm/hs.cpp
copy to platform/consensus/ordering/hs2/algorithm/hs2.cpp
index 0af553ac..68a5c260 100644
--- a/platform/consensus/ordering/hs/algorithm/hs.cpp
+++ b/platform/consensus/ordering/hs2/algorithm/hs2.cpp
@@ -1,49 +1,53 @@
-#include "platform/consensus/ordering/hs/algorithm/hs.h"
+#include "platform/consensus/ordering/hs2/algorithm/hs2.h"
 
 #include <glog/logging.h>
 #include "common/utils/utils.h"
 
 
+
 namespace resdb {
-namespace hs {
+namespace hs2 {
 
-HotStuff::HotStuff(int id, int f, int total_num, SignatureVerifier * verifier)
-  : ProtocolBase(id, f, total_num), verifier_(verifier){
+HotStuff2::HotStuff2(int id, int f, int total_num, SignatureVerifier * verifier, int non_responsive_num, int fork_tail_num)
+  : ProtocolBase(id, f, total_num), verifier_(verifier), non_responsive_num_(non_responsive_num), fork_tail_num_(fork_tail_num){
 
     LOG(ERROR)<<"id:"<<id<<" f:"<<f<<" total:"<<total_num_;
 
-  proposal_manager_ = std::make_unique<ProposalManager>(id, 2*f_+1, verifier);
+  global_stats_ = Stats::GetGlobalStats();
+  proposal_manager_ = std::make_unique<ProposalManager>(id, 2*f_+1, verifier, total_num, non_responsive_num, fork_tail_num);
   has_sent_ = false;
-    send_thread_ = std::thread(&HotStuff::AsyncSend, this);
-    commit_thread_ = std::thread(&HotStuff::AsyncCommit, this);
-    batch_size_ = 64;
+    send_thread_ = std::thread(&HotStuff2::AsyncSend, this);
+    commit_thread_ = std::thread(&HotStuff2::AsyncCommit, this);
+    batch_size_ = 1;
+    timer_length_ = 10000;
+    qc_formed_ = proposal_received_ = false;
 }
 
-HotStuff::~HotStuff() {
+HotStuff2::~HotStuff2() {
 }
 
-int HotStuff::NextLeader(int view){
+int HotStuff2::NextLeader(int view){
   //LOG(ERROR)<<" view:"<<view<<" next leader:"<<(view+1)%total_num_ + 1;
   return (view+1)%total_num_ + 1;
 }
 
-bool HotStuff::IsLeader(int view){
+bool HotStuff2::IsLeader(int view){
   return (view % total_num_)+1 == id_;
 }
 
-bool HotStuff::Ready() {
+bool HotStuff2::Ready() {
   int view = proposal_manager_->CurrentView();
   return IsLeader(view) && !has_sent_;
 }
 
-void HotStuff::StartNewRound() {
+void HotStuff2::StartNewRound() {
   std::unique_lock<std::mutex> lk(n_mutex_);
   has_sent_ = false;
   vote_cv_.notify_one();
   //LOG(ERROR)<<" start new round";
 }
 
-void HotStuff::AsyncSend() {
+void HotStuff2::AsyncSend() {
   while (!IsStop()) {
     auto txn = txns_.Pop();
     if(txn == nullptr){
@@ -74,6 +78,10 @@ void HotStuff::AsyncSend() {
       txns.push_back(std::move(txn));
     }
 
+    if (id_ < 3 * non_responsive_num_ && id_ % 3 == 1) {
+      usleep(timer_length_);
+    }
+
     std::unique_ptr<Proposal> proposal =  nullptr;
     {
       std::unique_lock<std::mutex> lk(mutex_);
@@ -85,14 +93,14 @@ void HotStuff::AsyncSend() {
   }
 }
 
-void HotStuff::AsyncCommit() {
+void HotStuff2::AsyncCommit() {
   int seq = 1;
   while (!IsStop()) {
     auto p = commit_q_.Pop();
     if(p == nullptr){
       continue;
     }
-
+    global_stats_->AddConsensusLatency(GetCurrentTime()-p->createtime());
     for(Transaction& txn : *p->mutable_transactions()){
       txn.set_id(seq++);
       Commit(txn);
@@ -101,19 +109,28 @@ void HotStuff::AsyncCommit() {
 }
 
 
-bool HotStuff::ReceiveTransaction(std::unique_ptr<Transaction> txn) {
+bool HotStuff2::ReceiveTransaction(std::unique_ptr<Transaction> txn) {
   //  std::unique_lock<std::mutex> lk(txn_mutex_);
+  txn->set_reception_time(GetCurrentTime());
   txn->set_proposer(id_);
   txns_.Push(std::move(txn));
   return true;
 }
 
-bool HotStuff::ReceiveProposal(std::unique_ptr<Proposal> proposal) {
+bool HotStuff2::ReceiveProposal(std::unique_ptr<Proposal> proposal) {
+  if (IsSlowReplica(id_)) {
+    usleep(GetRandomDelay());
+  }
     int view = proposal->header().view();
     std::unique_ptr<Certificate> cert = nullptr;
   {
     //LOG(ERROR)<<"RECEIVE proposer view:"<<proposal->header().view();
     std::unique_lock<std::mutex> lk(mutex_);
+
+    if (id_ == NextLeader(view)) {
+      proposal_received_ = true;
+    }
+    
     if(!proposal_manager_->Verify(*proposal)){
       LOG(ERROR)<<" proposal invalid";
       return false;
@@ -122,22 +139,45 @@ bool HotStuff::ReceiveProposal(std::unique_ptr<Proposal> proposal) {
     cert = GenerateCertificate(*proposal);
     assert(cert != nullptr);
 
-    std::unique_ptr<Proposal> committed_p = proposal_manager_->AddProposal(std::move(proposal));
-    if(committed_p != nullptr){
-      CommitProposal(std::move(committed_p));
+    std::vector<std::unique_ptr<Proposal>> committed_p_list = proposal_manager_->AddProposal(std::move(proposal));
+    for (int i=committed_p_list.size()-1; i>=0; i--) {
+      CommitProposal(std::move(committed_p_list[i]));
+    }
+
+    if (qc_formed_) {
+      // LOG(ERROR) << "after proposal recieeved";
+      proposal_manager_->AddQC(std::move(formed_qc_));
+      StartNewRound();
+      qc_formed_ = proposal_received_ = false;
     }
 
     //LOG(ERROR)<<"send cert view:"<<view<<" to:"<<NextLeader(view);
   }
 
-  SendMessage(MessageType::Vote, *cert, NextLeader(view));
+  int next_leader = proposal_manager_->GetLeader(view+1);
+
+  SendMessage(MessageType::Vote, *cert, next_leader);
+
+  if (next_leader % 3 == 1 && next_leader <= 3 * crash_num_) {
+    int next_next_leader = proposal_manager_->GetLeader(view+2);
+    if (id_ == next_next_leader) {
+      proposal_received_ = true;
+    }
+    cert->set_view(view+1);
+    usleep(timer_length_);
+    SendMessage(MessageType::Vote, *cert, next_next_leader);
+  }
 
   return true;
 }
 
-bool HotStuff::ReceiveCertificate(std::unique_ptr<Certificate> cert) {
+bool HotStuff2::ReceiveCertificate(std::unique_ptr<Certificate> cert) {
 
-  //LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
+  if (id_ % 3 == 1 && id_ <= 3*crash_num_) {
+    return true;
+  }
+
+  // LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
   std::unique_lock<std::mutex> lk(mutex_);
   //LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
   bool valid = proposal_manager_->VerifyCert(*cert);
@@ -161,19 +201,24 @@ bool HotStuff::ReceiveCertificate(std::unique_ptr<Certificate> cert) {
       *qc->add_signatures() = it.second->sign();
     }
 
-    //LOG(ERROR)<<"add qc view:"<<view;
-    proposal_manager_->AddQC(std::move(qc));
-
-    StartNewRound();
+    qc_formed_ = true;
+    if (proposal_received_) {
+      // LOG(ERROR) << "after qc formed";
+      proposal_manager_->AddQC(std::move(qc));
+      StartNewRound();
+      qc_formed_ = proposal_received_ = false;
+    } else {
+      formed_qc_ = std::move(qc);
+    }
   }
   return true;
 }
 
-void HotStuff::CommitProposal(std::unique_ptr<Proposal> p){
+void HotStuff2::CommitProposal(std::unique_ptr<Proposal> p){
   commit_q_.Push(std::move(p));
 }
 
-std::unique_ptr<Certificate> HotStuff::GenerateCertificate(const Proposal& proposal) {
+std::unique_ptr<Certificate> HotStuff2::GenerateCertificate(const Proposal& proposal) {
   std::unique_ptr<Certificate> cert = std::make_unique<Certificate>();
   cert->set_hash(proposal.hash());
   cert->set_view(proposal.header().view());
@@ -189,5 +234,5 @@ std::unique_ptr<Certificate> HotStuff::GenerateCertificate(const Proposal& propo
   return cert;
 }
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/hs.h b/platform/consensus/ordering/hs2/algorithm/hs2.h
similarity index 69%
copy from platform/consensus/ordering/hs/algorithm/hs.h
copy to platform/consensus/ordering/hs2/algorithm/hs2.h
index 04148a37..75e6b8b4 100644
--- a/platform/consensus/ordering/hs/algorithm/hs.h
+++ b/platform/consensus/ordering/hs2/algorithm/hs2.h
@@ -3,17 +3,18 @@
 #include <thread>
 
 #include "platform/common/queue/lock_free_queue.h"
-#include "platform/consensus/ordering/hs/algorithm/proposal_manager.h"
-#include "platform/consensus/ordering/hs/proto/proposal.pb.h"
+#include "platform/consensus/ordering/hs2/algorithm/proposal_manager.h"
+#include "platform/consensus/ordering/hs2/proto/proposal.pb.h"
 #include "platform/consensus/ordering/common/algorithm/protocol_base.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
-namespace hs {
+namespace hs2 {
 
-class HotStuff: public common::ProtocolBase {
+class HotStuff2: public common::ProtocolBase {
  public:
-  HotStuff(int id, int f, int total_num, SignatureVerifier* verifier );
-  ~HotStuff();
+  HotStuff2(int id, int f, int total_num, SignatureVerifier* verifier, int non_responsive_num, int fork_tail_num );
+  ~HotStuff2();
 
   //  recv txn -> send block with links -> rec block ack -> send block with certs
   bool ReceiveTransaction(std::unique_ptr<Transaction> txn);
@@ -51,8 +52,16 @@ class HotStuff: public common::ProtocolBase {
   //[view][hash][signer][cert]
   //std::map<std::string, std::map<int, std::unique_ptr<Certificate>> >  receive_[1024];
   std::map<int,  std::map<std::string, std::map<int, std::unique_ptr<Certificate>> > > receive_;
-
+  Stats* global_stats_ = nullptr;
+
+  int non_responsive_num_;
+  int fork_tail_num_;
+  uint64_t timer_length_;
+  bool qc_formed_, proposal_received_;
+  std::unique_ptr<QC> formed_qc_;
+  
+  uint64_t crash_num_ = 0;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp b/platform/consensus/ordering/hs2/algorithm/proposal_manager.cpp
similarity index 70%
copy from platform/consensus/ordering/hs/algorithm/proposal_manager.cpp
copy to platform/consensus/ordering/hs2/algorithm/proposal_manager.cpp
index 72287e43..a98d0634 100644
--- a/platform/consensus/ordering/hs/algorithm/proposal_manager.cpp
+++ b/platform/consensus/ordering/hs2/algorithm/proposal_manager.cpp
@@ -1,15 +1,19 @@
-#include "platform/consensus/ordering/hs/algorithm/proposal_manager.h"
+#include "platform/consensus/ordering/hs2/algorithm/proposal_manager.h"
 
 #include <glog/logging.h>
 #include "common/utils/utils.h"
 #include "common/crypto/signature_verifier.h"
 
 namespace resdb {
-namespace hs {
+namespace hs2 {
 
-ProposalManager::ProposalManager(int32_t id, int limit_count, SignatureVerifier* verifier)
-    : id_(id), limit_count_(limit_count), verifier_(verifier) {
+ProposalManager::ProposalManager(int32_t id, int limit_count, SignatureVerifier* verifier, 
+                                  int total_num, int non_responsive_num, int fork_tail_num)
+: id_(id), limit_count_(limit_count), verifier_(verifier), total_num_(total_num), non_responsive_num_(non_responsive_num), fork_tail_num_(fork_tail_num) 
+{
     round_ = 1;
+    timer_length = 10000;
+    global_stats_ = Stats::GetGlobalStats();
     assert(verifier_ != nullptr);
 }
 
@@ -84,6 +88,7 @@ std::unique_ptr<Proposal> ProposalManager::GenerateProposal(
   {
     std::unique_lock<std::mutex> lk(txn_mutex_);
     for(const auto& txn: txns){
+      global_stats_->AddProposeLatency(GetCurrentTime() - txn->reception_time());
       *proposal->add_transactions() = *txn;
     }
     if(!generic_qc_.hash().empty()){
@@ -95,7 +100,7 @@ std::unique_ptr<Proposal> ProposalManager::GenerateProposal(
     proposal->mutable_header()->set_view(round_);
     proposal->set_sender(id_);
   }
-
+  proposal->set_createtime(GetCurrentTime());
   proposal->set_hash(GetHash(*proposal));
   return proposal;
 }
@@ -107,38 +112,41 @@ int ProposalManager::CurrentView(){
 void ProposalManager::AddQC(std::unique_ptr<QC> qc){
   std::unique_lock<std::mutex> lk(txn_mutex_);
   if(generic_qc_.view() == 0 || generic_qc_.view() < qc->view()){
-    generic_qc_ = *qc;
-    round_ = generic_qc_.view()+1;
+    int leader = GetLeader(qc->view());
+    if(!(leader < 3 * fork_tail_num_ && leader % 3 ==1)) {
+      generic_qc_ = *qc;
+    } 
+    round_ = qc->view()+1;
+    int next_leader = GetLeader(round_);
   //  LOG(ERROR)<<"get new round:"<<round_;
   }
 }
 
-std::unique_ptr<Proposal> ProposalManager::AddProposal(std::unique_ptr<Proposal> proposal){
+std::vector<std::unique_ptr<Proposal>> ProposalManager::AddProposal(std::unique_ptr<Proposal> proposal){
   //LOG(ERROR)<<"ADD PROPOSAL";
   std::unique_lock<std::mutex> lk(txn_mutex_);
   if(generic_qc_.view() < proposal->header().qc().view()){
     generic_qc_ = proposal->header().qc();
   }
 
-  std::unique_ptr<Proposal> commit_ready_proposal_ = nullptr;
+  std::vector<std::unique_ptr<Proposal>> commit_ready_proposals_;
   const Proposal * father = nullptr, * fafather = nullptr, * fafafather = nullptr;
   father = GetProposal(proposal->header().prehash());
   if(father != nullptr){
     //LOG(ERROR)<<"get father view:"<<father->header().view();
     fafather = GetProposal(father->header().prehash());
     lock_qc_ = father->header().qc();
-    if(fafather != nullptr){
-     // LOG(ERROR)<<"get fafather view:"<<fafather->header().view();
-      fafafather = GetProposal(fafather->header().prehash());
-      if(fafafather != nullptr){
-        //commit;
-      //  LOG(ERROR)<<"commit fafafather view:"<<fafafather->header().view();
-        commit_ready_proposal_ = FetchProposal(fafather->header().prehash());
+    if(fafather != nullptr && fafather->header().view() == father->header().view() - 1){
+      auto fetched_proposal = FetchProposal(father->header().prehash());
+      while (fetched_proposal) {
+        auto got_proposal = fetched_proposal.get();
+        commit_ready_proposals_.push_back(std::move(fetched_proposal));
+        fetched_proposal = FetchProposal(got_proposal->header().prehash());
       }
     }
   }
   local_block_[proposal->hash()] = std::move(proposal);
-  return commit_ready_proposal_;
+  return commit_ready_proposals_;
 }
 
 const Proposal * ProposalManager::GetProposal(const std::string& hash){
@@ -151,11 +159,20 @@ const Proposal * ProposalManager::GetProposal(const std::string& hash){
 
 std::unique_ptr<Proposal> ProposalManager::FetchProposal(const std::string& hash){
   auto it = local_block_.find(hash);
-  assert(it != local_block_.end());
+  // assert(it != local_block_.end());
+  if (it == local_block_.end()) {
+    return nullptr;
+  }
   std::unique_ptr<Proposal> ret = std::move(it->second);
   local_block_.erase(it);
   return ret;
 }
 
-}  // namespace tusk
+int ProposalManager::GetLeader(int view){
+  //LOG(ERROR)<<" view:"<<view<<" next leader:"<<(view+1)%total_num_ + 1;
+  return view % total_num_ + 1;
+}
+
+
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/algorithm/proposal_manager.h b/platform/consensus/ordering/hs2/algorithm/proposal_manager.h
similarity index 69%
copy from platform/consensus/ordering/hs/algorithm/proposal_manager.h
copy to platform/consensus/ordering/hs2/algorithm/proposal_manager.h
index 48957435..423fe13d 100644
--- a/platform/consensus/ordering/hs/algorithm/proposal_manager.h
+++ b/platform/consensus/ordering/hs2/algorithm/proposal_manager.h
@@ -1,14 +1,15 @@
 #pragma once
 
-#include "platform/consensus/ordering/hs/proto/proposal.pb.h"
+#include "platform/consensus/ordering/hs2/proto/proposal.pb.h"
 #include "common/crypto/signature_verifier.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
-namespace hs {
+namespace hs2 {
 
 class ProposalManager {
  public:
-  ProposalManager(int32_t id, int limit_count, SignatureVerifier * verifier);
+  ProposalManager(int32_t id, int limit_count, SignatureVerifier * verifier, int total_num, int non_responsive_num, int fork_tail_num);
 
   std::unique_ptr<Proposal> GenerateProposal(const std::vector<std::unique_ptr<Transaction>>& txns);
   bool Verify(const Proposal& proposal);
@@ -17,9 +18,10 @@ class ProposalManager {
   int CurrentView();
 
   void AddQC(std::unique_ptr<QC> qc);
-  std::unique_ptr<Proposal> AddProposal(std::unique_ptr<Proposal> proposal);
+  std::vector<std::unique_ptr<Proposal>> AddProposal(std::unique_ptr<Proposal> proposal);
   const Proposal * GetProposal(const std::string& hash);
 
+  int GetLeader(int view);
 
   protected:
     std::string GetHash(const Proposal& proposal);
@@ -39,7 +41,13 @@ class ProposalManager {
 
   QC generic_qc_, lock_qc_;
   SignatureVerifier* verifier_;
+
+  int timer_length;
+  int total_num_;
+  int non_responsive_num_;
+  int fork_tail_num_;
+  Stats* global_stats_ = nullptr;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs/framework/BUILD b/platform/consensus/ordering/hs2/framework/BUILD
similarity index 60%
copy from platform/consensus/ordering/hs/framework/BUILD
copy to platform/consensus/ordering/hs2/framework/BUILD
index cd052cc7..8abdfa12 100644
--- a/platform/consensus/ordering/hs/framework/BUILD
+++ b/platform/consensus/ordering/hs2/framework/BUILD
@@ -8,13 +8,22 @@ cc_library(
         "//visibility:public",
     ],
     deps = [
+        ":performance_manager",
         "//common/utils",
         "//executor/common:transaction_manager",
         "//platform/consensus/ordering/common/framework:consensus",
         "//platform/consensus/execution:transaction_executor",
-        "//platform/consensus/ordering/hs/algorithm:hs",
+        "//platform/consensus/ordering/hs2/algorithm:hs2",
         "//platform/networkstrate:consensus_manager",
     ],
 )
 
 
+cc_library(
+    name = "performance_manager",
+    srcs = ["performance_manager.cpp"],
+    hdrs = ["performance_manager.h"],
+    deps = [
+        "//platform/consensus/ordering/common/framework:performance_manager",
+    ],
+)
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/framework/consensus.cpp b/platform/consensus/ordering/hs2/framework/consensus.cpp
similarity index 81%
copy from platform/consensus/ordering/hs/framework/consensus.cpp
copy to platform/consensus/ordering/hs2/framework/consensus.cpp
index 80974721..f088c1ff 100644
--- a/platform/consensus/ordering/hs/framework/consensus.cpp
+++ b/platform/consensus/ordering/hs2/framework/consensus.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -23,7 +23,7 @@
  *
  */
 
-#include "platform/consensus/ordering/hs/framework/consensus.h"
+#include "platform/consensus/ordering/hs2/framework/consensus.h"
 
 #include <glog/logging.h>
 #include <unistd.h>
@@ -31,12 +31,20 @@
 #include "common/utils/utils.h"
 
 namespace resdb {
-namespace hs {
+namespace hs2 {
+
+std::unique_ptr<HotStuff2PerformanceManager> Consensus::GetPerformanceManager() {
+        return config_.IsPerformanceRunning()
+        ? std::make_unique<HotStuff2PerformanceManager>(
+          config_, GetBroadCastClient(), GetSignatureVerifier())
+        : nullptr;
+}
 
 Consensus::Consensus(const ResDBConfig& config,
                      std::unique_ptr<TransactionManager> executor)
     : common::Consensus(config, std::move(executor)) {
 
+  SetPerformanceManager(GetPerformanceManager());
   Init();
 
   int total_replicas = config_.GetReplicaNum();
@@ -46,8 +54,8 @@ Consensus::Consensus(const ResDBConfig& config,
           .public_key()
           .public_key_info()
           .type() != CertificateKeyInfo::CLIENT) {
-    hs_= std::make_unique<HotStuff>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier());
-    InitProtocol(hs_.get());
+    hs2_= std::make_unique<HotStuff2>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier(), config_.GetNonResponsiveNum(), config_.GetForkTailNum());
+    InitProtocol(hs2_.get());
   }
 }
 
@@ -62,7 +70,7 @@ int Consensus::ProcessCustomConsensus(std::unique_ptr<Request> request) {
       assert(1 == 0);
       return -1;
     }
-    hs_->ReceiveProposal(std::move(p));
+    hs2_->ReceiveProposal(std::move(p));
   }
   else if(request->user_type() == MessageType::Vote) {
     std::unique_ptr<Certificate> cert = std::make_unique<Certificate>();
@@ -71,7 +79,7 @@ int Consensus::ProcessCustomConsensus(std::unique_ptr<Request> request) {
       assert(1 == 0);
       return -1;
     }
-    hs_->ReceiveCertificate(std::move(cert));
+    hs2_->ReceiveCertificate(std::move(cert));
   }
   return 0;
 }
@@ -82,7 +90,7 @@ int Consensus::ProcessNewTransaction(std::unique_ptr<Request> request) {
   txn->set_hash(request->hash());
   txn->set_proxy_id(request->proxy_id());
   txn->set_user_seq(request->user_seq());
-  return hs_->ReceiveTransaction(std::move(txn));
+  return hs2_->ReceiveTransaction(std::move(txn));
 }
 
 int Consensus::CommitMsg(const google::protobuf::Message& msg) {
diff --git a/platform/consensus/ordering/hs/framework/consensus.h b/platform/consensus/ordering/hs2/framework/consensus.h
similarity index 86%
copy from platform/consensus/ordering/hs/framework/consensus.h
copy to platform/consensus/ordering/hs2/framework/consensus.h
index 8650b8f3..aa9cdb79 100644
--- a/platform/consensus/ordering/hs/framework/consensus.h
+++ b/platform/consensus/ordering/hs2/framework/consensus.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -27,12 +27,13 @@
 
 #include "executor/common/transaction_manager.h"
 #include "platform/consensus/execution/transaction_executor.h"
-#include "platform/consensus/ordering/hs/algorithm/hs.h"
+#include "platform/consensus/ordering/hs2/algorithm/hs2.h"
 #include "platform/consensus/ordering/common/framework/consensus.h"
+#include "platform/consensus/ordering/hs2/framework/performance_manager.h"
 #include "platform/networkstrate/consensus_manager.h"
 
 namespace resdb {
-namespace hs {
+namespace hs2 {
 
 class Consensus : public common::Consensus{
  public:
@@ -45,9 +46,11 @@ class Consensus : public common::Consensus{
   int CommitMsg(const google::protobuf::Message& msg) override;
   int CommitMsgInternal(const Transaction& txn);
 
+  std::unique_ptr<HotStuff2PerformanceManager> GetPerformanceManager();
+
   private:
-    std::unique_ptr<HotStuff> hs_;
+    std::unique_ptr<HotStuff2> hs2_;
 };
 
-}  // namespace tusk
+}  // namespace hs
 }  // namespace resdb
diff --git a/platform/consensus/ordering/hs2/framework/performance_manager.cpp b/platform/consensus/ordering/hs2/framework/performance_manager.cpp
new file mode 100644
index 00000000..960adcb8
--- /dev/null
+++ b/platform/consensus/ordering/hs2/framework/performance_manager.cpp
@@ -0,0 +1,120 @@
+/*
+
+ *
+ * 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 "platform/consensus/ordering/hs2/framework/performance_manager.h"
+
+#include <glog/logging.h>
+
+#include "common/utils/utils.h"
+
+namespace resdb {
+namespace hs2 {
+
+using comm::CollectorResultCode;
+
+HotStuff2PerformanceManager::HotStuff2PerformanceManager(
+    const ResDBConfig& config, ReplicaCommunicator* replica_communicator,
+    SignatureVerifier* verifier)
+    : PerformanceManager(config, replica_communicator, verifier){
+  client_num_ = 1;
+  primary_ = id_ % replica_num_;
+}
+
+int HotStuff2PerformanceManager::GetPrimary(){
+  int view, value;
+  int crash_num_ = 0;
+  while (true) {
+    view = primary_;
+    primary_ += client_num_;
+    value = view % replica_num_ + 1;
+    if (value % 3 == 1 && value < 3 * crash_num_) {
+      send_num_--;
+    }
+    if (value % 3 == 1 && value < 3 * config_.GetForkTailNum()) {
+      send_num_--;
+    }
+    // LOG(ERROR) << "Send to "<< value << " with send_num_: " << send_num_; 
+    return value;
+  } 
+}
+
+
+CollectorResultCode HotStuff2PerformanceManager::AddResponseMsg(
+    std::unique_ptr<Request> request,
+    std::function<void(std::unique_ptr<BatchUserResponse>)> response_call_back) {
+  if (request == nullptr) {
+    return CollectorResultCode::INVALID;
+  }
+
+  //uint64_t seq = request->seq();
+
+  std::unique_ptr<BatchUserResponse> batch_response = std::make_unique<BatchUserResponse>();
+  if (!batch_response->ParseFromString(request->data())) {
+    LOG(ERROR) << "parse response fail:"<<request->data().size()
+    <<" seq:"<<request->seq(); return CollectorResultCode::INVALID;
+  }
+
+  uint64_t seq = batch_response->local_id();
+  //LOG(ERROR)<<"receive seq:"<<seq;
+
+  bool first = false;
+  bool done = false;
+  {
+    int idx = seq % response_set_size_;
+    std::unique_lock<std::mutex> lk(response_lock_[idx]);
+    if (response_[idx].find(seq) == response_[idx].end()) {
+      // LOG(ERROR)<<"has done local seq:"<<seq<<" global seq:"<<request->seq();
+      return CollectorResultCode::OK;
+    }
+    response_[idx][seq]++;
+    // LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" send:"<<send_num_;
+
+    if (response_[idx][seq] == 1) {
+      first = true;
+    }
+
+    if (response_[idx][seq] >= config_.GetMinClientReceiveNum()) {
+      //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" done:"<<send_num_;
+      response_[idx].erase(response_[idx].find(seq));
+      done = true;
+    }
+  }
+
+  if (first) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::FIRST_RESPONSE;
+  }
+
+  if (done) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::STATE_CHANGED;
+  }
+  return CollectorResultCode::OK;
+}
+
+
+
+}  // namespace hs2
+}  // namespace resdb
\ No newline at end of file
diff --git a/common/crypto/signature_verifier_interface.h b/platform/consensus/ordering/hs2/framework/performance_manager.h
similarity index 65%
copy from common/crypto/signature_verifier_interface.h
copy to platform/consensus/ordering/hs2/framework/performance_manager.h
index eea1b410..0993e219 100644
--- a/common/crypto/signature_verifier_interface.h
+++ b/platform/consensus/ordering/hs2/framework/performance_manager.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -25,19 +25,25 @@
 
 #pragma once
 
-#include "absl/status/statusor.h"
-#include "common/proto/signature_info.pb.h"
+#include <future>
+
+#include "platform/consensus/ordering/common/framework/performance_manager.h"
 
 namespace resdb {
+namespace hs2 {
 
-// SignatureVerifier base class, provide an interface for communication.
-class SignatureVerifierInterface {
+class HotStuff2PerformanceManager : public common::PerformanceManager {
  public:
-  SignatureVerifierInterface() = default;
-  virtual ~SignatureVerifierInterface() = default;
+  HotStuff2PerformanceManager(const ResDBConfig& config,
+                     ReplicaCommunicator* replica_communicator,
+                     SignatureVerifier* verifier);
 
-  // Sign messages using the private key.
-  virtual absl::StatusOr<SignatureInfo> SignMessage(const std::string& message);
+protected:
+  comm::CollectorResultCode AddResponseMsg(
+      std::unique_ptr<Request> request,
+      std::function<void(std::unique_ptr<BatchUserResponse>)> call_back) override;
+  int GetPrimary() override;
 };
 
-}  // namespace resdb
+}  // namespace hs2
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs2/proto/BUILD b/platform/consensus/ordering/hs2/proto/BUILD
new file mode 100644
index 00000000..d9eb4091
--- /dev/null
+++ b/platform/consensus/ordering/hs2/proto/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//platform/consensus/ordering/hs2:__subpackages__"])
+
+load("@rules_cc//cc:defs.bzl", "cc_proto_library")
+load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
+
+proto_library(
+    name = "proposal_proto",
+    srcs = ["proposal.proto"],
+    deps = ["//common/proto:signature_info_proto"],
+)
+
+cc_proto_library(
+    name = "proposal_cc_proto",
+    deps = [":proposal_proto"],
+)
diff --git a/platform/consensus/ordering/hs/proto/proposal.proto b/platform/consensus/ordering/hs2/proto/proposal.proto
similarity index 92%
copy from platform/consensus/ordering/hs/proto/proposal.proto
copy to platform/consensus/ordering/hs2/proto/proposal.proto
index a5079050..f47d6234 100644
--- a/platform/consensus/ordering/hs/proto/proposal.proto
+++ b/platform/consensus/ordering/hs2/proto/proposal.proto
@@ -1,7 +1,7 @@
 syntax = "proto3";
 import "common/proto/signature_info.proto";
 
-package resdb.hs;
+package resdb.hs2;
 
 message Certificate {
   SignatureInfo sign = 1;
@@ -19,6 +19,7 @@ message Transaction{
   int32 proposer = 5;
   uint64 timestamp = 6;
   int64 user_seq = 7;
+  uint64 reception_time = 8;
 }
 
 enum ProposalType{
@@ -49,6 +50,7 @@ message Proposal {
   repeated Transaction transactions = 2;
   int32 sender = 3;
   bytes hash = 4;
+  uint64 createtime = 5;
 };
 
 enum MessageType {
diff --git a/platform/consensus/ordering/pbft/commitment.cpp b/platform/consensus/ordering/pbft/commitment.cpp
index c2e84b14..c3a73266 100644
--- a/platform/consensus/ordering/pbft/commitment.cpp
+++ b/platform/consensus/ordering/pbft/commitment.cpp
@@ -130,6 +130,12 @@ int Commitment::ProcessNewRequest(std::unique_ptr<Context> context,
     request.set_ret(-2);
     request.set_hash(user_request->hash());
 
+    BatchUserRequest batch_request;
+    if (!batch_request.ParseFromString(user_request->data())) {
+      LOG(ERROR) << "parse data fail";
+    }
+    request.set_seq(batch_request.local_id());
+
     replica_communicator_->SendMessage(request, request.proxy_id());
     return -2;
   }
diff --git a/platform/consensus/ordering/pbft/performance_manager.cpp b/platform/consensus/ordering/pbft/performance_manager.cpp
index a5ba979f..41df081f 100644
--- a/platform/consensus/ordering/pbft/performance_manager.cpp
+++ b/platform/consensus/ordering/pbft/performance_manager.cpp
@@ -107,12 +107,12 @@ int PerformanceManager::StartEval() {
     return 0;
   }
   eval_started_ = true;
-  for (int i = 0; i < 60000000000; ++i) {
+  for (int i = 0; i < 60000000; ++i) {
     std::unique_ptr<QueueItem> queue_item = std::make_unique<QueueItem>();
     queue_item->context = nullptr;
     queue_item->user_request = GenerateUserRequest();
     batch_queue_.Push(std::move(queue_item));
-    if (i == 20000000) {
+    if (i == 20000) {
       eval_ready_promise_.set_value(true);
     }
   }
@@ -133,12 +133,18 @@ int PerformanceManager::ProcessResponseMsg(std::unique_ptr<Context> context,
   // messages.
   // The callback will be triggered if it received f+1 messages.
   if (request->ret() == -2) {
-    // LOG(INFO) << "get response fail:" << request->ret();
+    //LOG(INFO) << "get response fail:" << request->ret()<<" send num:"<<send_num_[primary_id]<< " primary:"<<primary_id<<" here:"<<GetPrimary()<<" seq:"<<request->seq();
     // send_num_--;
+    if (send_num_[GetPrimary()] > 0) {
+      send_num_[GetPrimary()]--;
+    }
+    collector_pool_->Update(request->seq());
+
     RemoveWaitingResponseRequest(hash);
     return 0;
   }
-  CollectorResultCode ret =
+
+    CollectorResultCode ret =
       AddResponseMsg(context->signature, std::move(request),
                      [&](const Request& request,
                          const TransactionCollector::CollectorDataType*) {
@@ -192,7 +198,17 @@ CollectorResultCode PerformanceManager::AddResponseMsg(
   }
 
   int type = request->type();
-  uint64_t seq = request->seq();
+
+
+  std::unique_ptr<BatchUserResponse> batch_response = std::make_unique<BatchUserResponse>();
+  if (!batch_response->ParseFromString(request->data())) {
+    LOG(ERROR) << "parse response fail:"<<request->data().size()
+    <<" seq:"<<request->seq(); return CollectorResultCode::INVALID;
+  }
+
+  uint64_t seq = batch_response->local_id();
+
+  request->set_seq(seq);
   int resp_received_count = 0;
   int ret = collector_pool_->GetCollector(seq)->AddRequest(
       std::move(request), signature, false,
@@ -245,6 +261,7 @@ int PerformanceManager::BatchProposeMsg() {
   eval_ready_future_.get();
   while (!stop_) {
     // std::lock_guard<std::mutex> lk(mutex_);
+    // LOG(ERROR)<<" batch send num:"<<send_num_[GetPrimary()]<<" max pross:"<<config_.GetMaxProcessTxn();
     if (send_num_[GetPrimary()] >= config_.GetMaxProcessTxn()) {
       usleep(100000);
       continue;
@@ -298,6 +315,7 @@ int PerformanceManager::DoBatch(
     req->set_id(i);
   }
 
+  batch_request.set_local_id(local_id_++);
   batch_request.set_createtime(GetCurrentTime());
   batch_request.SerializeToString(new_request->mutable_data());
   if (verifier_) {
@@ -320,7 +338,7 @@ int PerformanceManager::DoBatch(
     LOG(WARNING) << "total num is done:" << total_num_;
   }
   if (total_num_ % 10000 == 0) {
-    LOG(WARNING) << "total num is :" << total_num_;
+    LOG(WARNING) << "total num is :" << total_num_<<" send num:"<<send_num_[GetPrimary()];
   }
   global_stats_->IncClientCall();
   AddWaitingResponseRequest(std::move(new_request));
diff --git a/platform/consensus/ordering/pbft/performance_manager.h b/platform/consensus/ordering/pbft/performance_manager.h
index 7fc6e596..e7a19b09 100644
--- a/platform/consensus/ordering/pbft/performance_manager.h
+++ b/platform/consensus/ordering/pbft/performance_manager.h
@@ -91,7 +91,7 @@ class PerformanceManager {
   LockFreeQueue<QueueItem> batch_queue_;
   std::thread user_req_thread_[16];
   std::atomic<bool> stop_;
-  uint64_t local_id_ = 0;
+  uint64_t local_id_ = 1;
   Stats* global_stats_;
   std::vector<int> send_num_;
   std::mutex mutex_;
diff --git a/platform/consensus/ordering/pbft/viewchange_manager.cpp b/platform/consensus/ordering/pbft/viewchange_manager.cpp
index 7033801b..509b4831 100644
--- a/platform/consensus/ordering/pbft/viewchange_manager.cpp
+++ b/platform/consensus/ordering/pbft/viewchange_manager.cpp
@@ -521,7 +521,7 @@ void ViewChangeManager::AddComplaintTimer(uint64_t proxy_id, std::string hash) {
 
 void ViewChangeManager::MonitoringViewChangeTimeOut() {
   while (!stop_) {
-    // [DK3] After timer is out, the client will check if the corresponding
+    // [XX3] After timer is out, the client will check if the corresponding
     // client request has recevied sufficient valid responses
     sem_wait(&viewchange_timer_signal_);
     vc_mutex_.lock();
@@ -544,12 +544,12 @@ void ViewChangeManager::MonitoringViewChangeTimeOut() {
     if (viewchange_timeout->timeout_time > current_time) {
       usleep(viewchange_timeout->timeout_time - current_time);
     }
-    // [DK3] if not enough responses are received, the client broadcasts the
+    // [XX3] if not enough responses are received, the client broadcasts the
     // client request to all replicas
     if (viewchange_timeout->type == ViewChangeTimerType::TYPE_NEWVIEW) {
       if (status_ == ViewChangeStatus::READY_NEW_VIEW &&
           viewchange_timeout->view == system_info_->GetCurrentView()) {
-        // [DK12] if the replicas cannot receive a newview message in a timely
+        // [XX12] if the replicas cannot receive a newview message in a timely
         // manner, they will enter the next view and starts a new round of
         // viewchange. SetCurrentViewAndNewPrimary(viewchange_timeout->view +
         // 1);
@@ -558,7 +558,7 @@ void ViewChangeManager::MonitoringViewChangeTimeOut() {
       }
     } else if (viewchange_timeout->type ==
                ViewChangeTimerType::TYPE_VIEWCHANGE) {
-      // [DK9] if the primary cannot get enough viewchange messages before the
+      // [XX9] if the primary cannot get enough viewchange messages before the
       // timer is out, then it broadcasts its viewchanges messages and starts
       // the timer again.
       if (status_ == ViewChangeStatus::READY_VIEW_CHANGE &&
@@ -569,7 +569,7 @@ void ViewChangeManager::MonitoringViewChangeTimeOut() {
       }
     } else if (viewchange_timeout->type ==
                ViewChangeTimerType::TYPE_COMPLAINT) {
-      // [DK7] if the primary does not broadcast the request in a timely manner,
+      // [XX7] if the primary does not broadcast the request in a timely manner,
       // the replica starts a viewchange
       if (complaining_clients_[viewchange_timeout->proxy_id]
               .CountViewChangeTimeout(viewchange_timeout->hash)) {
diff --git a/platform/consensus/ordering/slot_hs1/algorithm/BUILD b/platform/consensus/ordering/slot_hs1/algorithm/BUILD
new file mode 100644
index 00000000..35b9135a
--- /dev/null
+++ b/platform/consensus/ordering/slot_hs1/algorithm/BUILD
@@ -0,0 +1,28 @@
+package(default_visibility = ["//platform/consensus/ordering/slot_hs1:__subpackages__"])
+
+cc_library(
+    name = "proposal_manager",
+    srcs = ["proposal_manager.cpp"],
+    hdrs = ["proposal_manager.h"],
+    deps = [
+        "//common:comm",
+        "//common/crypto:signature_verifier",
+        "//common/utils",
+        "//platform/consensus/ordering/slot_hs1/proto:proposal_cc_proto",
+        "//platform/statistic:stats",
+    ],
+)
+
+cc_library(
+    name = "slot_hs1",
+    srcs = ["slot_hs1.cpp"],
+    hdrs = ["slot_hs1.h"],
+    deps = [
+        ":proposal_manager",
+        "//common:comm",
+        "//platform/common/queue:lock_free_queue",
+        "//platform/consensus/ordering/common/algorithm:protocol_base",
+        "//platform/statistic:stats",
+    ],
+)
+
diff --git a/platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.cpp b/platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.cpp
new file mode 100644
index 00000000..d3aa908c
--- /dev/null
+++ b/platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.cpp
@@ -0,0 +1,221 @@
+#include "platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.h"
+
+#include <glog/logging.h>
+#include "common/utils/utils.h"
+#include "common/crypto/signature_verifier.h"
+
+namespace resdb {
+namespace slot_hs1 {
+
+ProposalManager::ProposalManager(int32_t id, int limit_count, int slot_num, SignatureVerifier* verifier, int total_num, int fork_tail_num, int rollback_num)
+    : id_(id), limit_count_(limit_count), slot_num_(slot_num), verifier_(verifier), total_num_(total_num), fork_tail_num_(fork_tail_num), rollback_num_(rollback_num) {
+    round_ = 1;
+    global_stats_ = Stats::GetGlobalStats();
+    assert(verifier_ != nullptr);
+}
+
+
+std::string ProposalManager::GetHash(const Proposal& proposal){
+  std::string data;
+  for(const auto& txn: proposal.transactions()){
+    std::string tmp;
+    txn.SerializeToString(&tmp);
+    data += tmp;
+  }
+
+  std::string header_data;
+  proposal.header().SerializeToString(&header_data);
+  data +=  header_data;
+
+  //LOG(ERROR)<<"get hash";
+  return SignatureVerifier::CalculateHash(data);
+}
+
+bool ProposalManager::VerifyHash(const Proposal& proposal) {
+  return  GetHash(proposal) == proposal.hash();
+}
+
+bool ProposalManager::VerifyCert(const Certificate& cert) {
+  return verifier_->VerifyMessage(cert.hash(), cert.sign());
+}
+
+
+bool ProposalManager::VerifyQC(const QC& qc) {
+  if(qc.signatures_size() < limit_count_){
+    LOG(ERROR)<<"qc size:"<<qc.signatures_size()<<" not enought, limit:"<<limit_count_;
+    return false;
+  }
+  for(const auto& sign : qc.signatures()){
+    bool valid = verifier_->VerifyMessage(qc.hash(), sign);
+    if(!valid){
+      LOG(ERROR) << "Verify message fail";
+      return false;
+    }
+  }
+  return  true;
+}
+
+bool ProposalManager::SafeNode(const Proposal& proposal){
+  if(proposal.header().qc().view() > lock_qc_.view()){
+    return true;
+  } else if (proposal.header().qc().view() == lock_qc_.view() 
+            && proposal.header().qc().slot() >= lock_qc_.slot()){
+    return true;
+  }
+  LOG(ERROR)<<"qc view:"<<proposal.header().qc().view()<<" lock view:"<<lock_qc_.view()<<" safe fail";
+   LOG(ERROR)<<"qc slot:"<<proposal.header().qc().slot()<<" lock slot:"<<lock_qc_.slot()<<" safe fail";
+  return false; 
+}
+
+bool ProposalManager::Verify(const Proposal& proposal) {
+  if(!VerifyHash(proposal)){
+    LOG(ERROR)<<"hash not match:";
+    return false;
+  }
+
+  if(proposal.header().view() == 1){
+    return true;
+  }
+
+  if(!SafeNode(proposal)){
+    return false;
+  }
+  return VerifyQC(proposal.header().qc());
+}
+
+std::unique_ptr<Proposal> ProposalManager::GenerateFakeProposal(
+    const std::vector<std::unique_ptr<Transaction>>& txns, int slot, bool is_final) {
+  std::unique_ptr<Proposal> proposal = std::make_unique<Proposal>();
+  {
+    std::unique_lock<std::mutex> lk(txn_mutex_);
+    for(const auto& txn: txns){
+      global_stats_->AddProposeLatency(GetCurrentTime() - txn->reception_time());
+      *proposal->add_transactions() = *txn;
+    }
+    if(!fake_generic_qc_.hash().empty()){
+     //LOG(ERROR)<<" add qc:"<<generic_qc_.view();
+      proposal->mutable_header()->set_prehash(fake_generic_qc_.hash());
+      *proposal->mutable_header()->mutable_qc() = fake_generic_qc_;
+    }
+    proposal->mutable_header()->set_view(round_);
+    proposal->set_sender(id_);
+  }
+  proposal->set_createtime(GetCurrentTime());
+  proposal->mutable_header()->set_slot(slot);
+  proposal->mutable_header()->set_is_final(is_final);
+  proposal->set_hash(GetHash(*proposal));
+  return proposal;
+}
+
+std::unique_ptr<Proposal> ProposalManager::GenerateProposal(
+    const std::vector<std::unique_ptr<Transaction>>& txns, int slot, bool is_final) {
+  std::unique_ptr<Proposal> proposal = std::make_unique<Proposal>();
+  {
+    std::unique_lock<std::mutex> lk(txn_mutex_);
+    for(const auto& txn: txns){
+      global_stats_->AddProposeLatency(GetCurrentTime() - txn->reception_time());
+      *proposal->add_transactions() = *txn;
+    }
+    if(!generic_qc_.hash().empty()){
+    //  LOG(ERROR)<<" add qc view:"<<generic_qc_.view() << " slot:" << generic_qc_.slot();
+      proposal->mutable_header()->set_prehash(generic_qc_.hash());
+      *proposal->mutable_header()->mutable_qc() = generic_qc_;
+    }
+
+    proposal->mutable_header()->set_view(round_);
+    proposal->set_sender(id_);
+  }
+  proposal->set_createtime(GetCurrentTime());
+  proposal->mutable_header()->set_slot(slot);
+  proposal->mutable_header()->set_is_final(is_final);
+  proposal->set_hash(GetHash(*proposal));
+  return proposal;
+}
+
+int ProposalManager::CurrentView(){
+  return round_;
+}
+
+void ProposalManager::AddQC(std::unique_ptr<QC> qc){
+  std::unique_lock<std::mutex> lk(txn_mutex_);
+  if(generic_qc_.view() == 0 || generic_qc_.view() < qc->view() || (generic_qc_.view() == qc->view() && generic_qc_.slot() < qc->slot())){
+    int leader = GetLeader(qc->view());
+    if(!(leader < 3 * fork_tail_num_ && leader % 3 == 1 && qc->is_final())) {
+      generic_qc_ = *qc;
+    } 
+
+    if (fork_tail_num_) {
+      // IGNORE the QC for the victim proposal
+      if(!(leader < 3 * fork_tail_num_ && leader % 3 ==1 && qc->is_final())) {
+        generic_qc_ = *qc;
+      } 
+    } else if (rollback_num_) {
+      if(id_ < 3 * rollback_num_ && id_ % 3 ==1 && qc->is_final()) {
+        fake_generic_qc_ = *qc;
+      } else {
+        generic_qc_ = *qc;
+      }
+    } else {
+      generic_qc_ = *qc;
+    } 
+
+    if(qc->is_final()){
+      round_ = qc->view()+1;
+    }
+  //  LOG(ERROR)<<"get new round:"<<round_;
+  }
+}
+
+std::unique_ptr<Proposal> ProposalManager::AddProposal(std::unique_ptr<Proposal> proposal){
+  //LOG(ERROR)<<"ADD PROPOSAL";
+  std::unique_lock<std::mutex> lk(txn_mutex_);
+  if(generic_qc_.view() < proposal->header().qc().view() || 
+      generic_qc_.view() == proposal->header().qc().view() && generic_qc_.slot() <= proposal->header().qc().slot()){
+    generic_qc_ = proposal->header().qc();
+    lock_qc_ = proposal->header().qc();
+  }
+
+  std::unique_ptr<Proposal> commit_ready_proposal_ = nullptr;
+  const Proposal * father = nullptr;
+  father = GetProposal(proposal->header().prehash());
+  if(father != nullptr){
+    //LOG(ERROR)<<"get father view:"<<father->header().view();
+    // fafather = GetProposal(father->header().prehash());
+    // if(father != nullptr){
+     // LOG(ERROR)<<"get fafather view:"<<fafather->header().view();
+      // fafafather = GetProposal(fafather->header().prehash());
+      commit_ready_proposal_ = FetchProposal(proposal->header().prehash());
+      // if(fafafather != nullptr){
+      //   //commit;
+      // //  LOG(ERROR)<<"commit fafafather view:"<<fafafather->header().view();
+      //   commit_ready_proposal_ = FetchProposal(fafather->header().prehash());
+      // }
+    // }
+  }
+  local_block_[proposal->hash()] = std::move(proposal);
+  return commit_ready_proposal_;
+}
+
+const Proposal * ProposalManager::GetProposal(const std::string& hash){
+  auto it = local_block_.find(hash);
+  if(it == local_block_.end()){
+    return nullptr;
+  }
+  return it->second.get();
+}
+
+std::unique_ptr<Proposal> ProposalManager::FetchProposal(const std::string& hash){
+  auto it = local_block_.find(hash);
+  assert(it != local_block_.end());
+  std::unique_ptr<Proposal> ret = std::move(it->second);
+  local_block_.erase(it);
+  return ret;
+}
+
+int ProposalManager::GetLeader(int view){
+  //LOG(ERROR)<<" view:"<<view<<" next leader:"<<(view+1)%total_num_ + 1;
+  return view % total_num_ + 1;
+}
+
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/algorithm/proposal_manager.h b/platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.h
similarity index 57%
copy from platform/consensus/ordering/hs/algorithm/proposal_manager.h
copy to platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.h
index 48957435..04ad343b 100644
--- a/platform/consensus/ordering/hs/algorithm/proposal_manager.h
+++ b/platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.h
@@ -1,16 +1,18 @@
 #pragma once
 
-#include "platform/consensus/ordering/hs/proto/proposal.pb.h"
+#include "platform/consensus/ordering/slot_hs1/proto/proposal.pb.h"
 #include "common/crypto/signature_verifier.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
-namespace hs {
+namespace slot_hs1 {
 
 class ProposalManager {
  public:
-  ProposalManager(int32_t id, int limit_count, SignatureVerifier * verifier);
+  ProposalManager(int32_t id, int limit_count, int slot_num, SignatureVerifier * verifier, int total_num, int fork_tail_num, int rollback_num);
 
-  std::unique_ptr<Proposal> GenerateProposal(const std::vector<std::unique_ptr<Transaction>>& txns);
+  std::unique_ptr<Proposal> GenerateFakeProposal(const std::vector<std::unique_ptr<Transaction>>& txns, int slot, bool is_final);
+  std::unique_ptr<Proposal> GenerateProposal(const std::vector<std::unique_ptr<Transaction>>& txns, int slot, bool is_final);
   bool Verify(const Proposal& proposal);
   bool VerifyCert(const Certificate& cert);
 
@@ -20,6 +22,7 @@ class ProposalManager {
   std::unique_ptr<Proposal> AddProposal(std::unique_ptr<Proposal> proposal);
   const Proposal * GetProposal(const std::string& hash);
 
+  int GetLeader(int view);
 
   protected:
     std::string GetHash(const Proposal& proposal);
@@ -33,13 +36,19 @@ class ProposalManager {
   int32_t id_;
   int round_;
   int limit_count_;
+  int slot_num_;
 
   std::mutex txn_mutex_;
   std::map<std::string, std::unique_ptr<Proposal> > local_block_;
 
-  QC generic_qc_, lock_qc_;
+  QC generic_qc_, lock_qc_, fake_generic_qc_;;
   SignatureVerifier* verifier_;
+
+  int total_num_;
+  int fork_tail_num_, rollback_num_;
+
+  Stats* global_stats_ = nullptr;
 };
 
-}  // namespace tusk
-}  // namespace resdb
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.cpp b/platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.cpp
new file mode 100644
index 00000000..edff07a7
--- /dev/null
+++ b/platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.cpp
@@ -0,0 +1,295 @@
+#include "platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.h"
+
+#include <glog/logging.h>
+#include "common/utils/utils.h"
+
+
+namespace resdb {
+namespace slot_hs1 {
+
+SlotHotStuff1::SlotHotStuff1(int id, int f, int total_num, SignatureVerifier * verifier, int non_responsive_num, int fork_tail_num, int rollback_num)
+  : ProtocolBase(id, f, total_num), verifier_(verifier), non_responsive_num_(non_responsive_num), fork_tail_num_(fork_tail_num), rollback_num_(rollback_num){
+
+    LOG(ERROR)<<"id:"<<id<<" f:"<<f<<" total:"<<total_num_ << " non_responsive_num_: " << non_responsive_num_;
+
+  global_stats_ = Stats::GetGlobalStats();
+  proposal_manager_ = std::make_unique<ProposalManager>(id, 2*f_+1, slot_num_, verifier, total_num_, fork_tail_num_, rollback_num);
+  has_sent_ = false;
+  batch_size_ = 1;
+  timer_length_ = 1000000;
+  qc_formed_ = proposal_received_ = false;
+  
+  ready_ = IsLeader(1);
+    send_thread_ = std::thread(&SlotHotStuff1::AsyncSend, this);
+    commit_thread_ = std::thread(&SlotHotStuff1::AsyncCommit, this);
+   
+}
+
+SlotHotStuff1::~SlotHotStuff1() {
+}
+
+int SlotHotStuff1::NextLeader(int view){
+  //LOG(ERROR)<<" view:"<<view<<" next leader:"<<(view+1)%total_num_ + 1;
+  return (view+1)%total_num_ + 1;
+}
+
+bool SlotHotStuff1::IsLeader(int view){
+  return (view % total_num_)+1 == id_;
+}
+
+bool SlotHotStuff1::Ready() {
+  int view = proposal_manager_->CurrentView();
+  // return IsLeader(view) && !has_sent_ && ready_;
+  return IsLeader(view) && ready_;
+}
+
+void SlotHotStuff1::StartNewRound() {
+  std::unique_lock<std::mutex> lk(n_mutex_);
+  has_sent_ = false;
+  vote_cv_.notify_one();
+  //LOG(ERROR)<<" start new round";
+}
+
+void SlotHotStuff1::AsyncSend() {
+  int slot = 0;
+  bool popped = true;
+  uint64_t start_time = GetCurrentTime();
+  while (!IsStop()) {
+    auto txn = txns_.Pop();
+    if(txn == nullptr){
+      continue;
+    }
+
+    while(!IsStop()){
+      std::unique_lock<std::mutex> lk(n_mutex_);
+      vote_cv_.wait_for(lk, std::chrono::microseconds(1000),
+          [&] { return Ready(); });
+
+      if(Ready()){
+        if (slot == 0) {
+          start_time = GetCurrentTime();
+          if (id_ % 3 == 1 && id_ < non_responsive_num_ * 3) {
+            usleep(timer_length_);
+          }
+        }
+        break;
+      }
+    }
+    if(IsStop()){
+      return;
+    }
+
+    // if (slot == 0 && proposal_manager_->CurrentView() > total_num_) {
+    //   popped = false;
+    // }
+    // if (popped == false && !txns_.Empty()) {
+    //   txn = txns_.Pop();
+    //   popped = true;
+    // }
+
+    if (slot == 0 && proposal_manager_->CurrentView() > total_num_) {
+      while (true) {
+        txn = txns_.Pop();
+        if (txn != nullptr) {
+          break;
+        }
+        // count ++;
+      }
+    }
+    
+
+    std::vector<std::unique_ptr<Transaction> > txns;
+    txns.push_back(std::move(txn));
+
+    for(int i = 1; i < batch_size_; ++i){
+      auto txn = txns_.Pop();
+      if(txn == nullptr){
+        continue;
+        //break;
+      }
+      txns.push_back(std::move(txn));
+    }
+
+    std::unique_ptr<Proposal> proposal =  nullptr;
+    std::unique_ptr<Proposal> proposal2 = nullptr;
+    {
+      std::unique_lock<std::mutex> lk(mutex_);
+      // LOG(ERROR) << "LOCK1" << GetCurrentTime();
+      bool is_final = GetCurrentTime() - start_time >= timer_length_ ? true : false;
+      // bool is_final = false;
+      proposal = proposal_manager_ -> GenerateProposal(txns, slot, is_final);
+      if(id_ < 3 * rollback_num_ && id_ % 3 ==1 && slot == 0) {
+        proposal2 = proposal_manager_ -> GenerateFakeProposal(txns, slot, is_final);
+      } 
+      // LOG(ERROR)<<"[X]propose view:"<<proposal->header().view() << " slot: " << slot << " " <<GetCurrentTime();
+      slot = is_final ? 0 : slot + 1;
+    }
+    
+    ready_ = false;
+    if (proposal2 != nullptr) {
+      LOG(ERROR) << "Rollbakc Attack Done by " << id_;
+      for(int i = 1; i <= total_num_; i++) {
+        if (i % 3 == 0 && i <= 3 * f_) {
+          SendMessage(MessageType::NewProposal, *proposal2, i);
+        } else {
+          SendMessage(MessageType::NewProposal, *proposal, i);
+        }
+      }
+    } else {
+      broadcast_call_(MessageType::NewProposal, *proposal);
+    }
+  }
+}
+
+void SlotHotStuff1::AsyncCommit() {
+  int seq = 1;
+  while (!IsStop()) {
+    auto p = commit_q_.Pop();
+    if(p == nullptr){
+      continue;
+    }
+    // LOG(ERROR)<<"[X]commit proposal view: "<<p->header().view()<<" slot: "<<p->header().slot();
+    // if (p->header().slot() > 0) {
+      global_stats_->AddConsensusLatency(GetCurrentTime()-p->createtime());
+    // }
+    for(Transaction& txn : *p->mutable_transactions()){
+      txn.set_id(seq++);
+      Commit(txn);
+    }
+  }
+}
+
+
+bool SlotHotStuff1::ReceiveTransaction(std::unique_ptr<Transaction> txn) {
+  //  std::unique_lock<std::mutex> lk(txn_mutex_);
+  txn->set_reception_time(GetCurrentTime());
+  txn->set_proposer(id_);
+  txns_.Push(std::move(txn));
+  return true;
+}
+
+bool SlotHotStuff1::ReceiveProposal(std::unique_ptr<Proposal> proposal) {
+  if (IsSlowReplica(id_)) {
+    usleep(GetRandomDelay());
+  }
+    int view = proposal->header().view();
+    int slot = proposal->header().slot();
+    bool is_final = proposal->header().is_final();
+    int sender = proposal->sender();
+    std::unique_ptr<Certificate> cert = nullptr;
+  {
+    // LOG(ERROR)<<"[X]process proposer view:"<<view<<" slot:"<<slot << " is_final: " << is_final << " at " << (GetCurrentTime() - last_time_) << " " << GetCurrentTime();
+    last_time_ = GetCurrentTime();
+
+    // LOG(ERROR)<<"RECEIVE proposer view:"<<proposal->header().view() << " slot: " << proposal->header().slot();
+    std::unique_lock<std::mutex> lk(mutex_);
+    if(!proposal_manager_->Verify(*proposal)){
+      LOG(ERROR)<<" proposal invalid";
+      return false;
+    }
+
+    cert = GenerateCertificate(*proposal);
+    assert(cert != nullptr);
+    
+    std::unique_ptr<Proposal> committed_p = proposal_manager_->AddProposal(std::move(proposal));
+    if(committed_p != nullptr){
+      if (is_final) {
+        for(Transaction& txn : *committed_p->mutable_transactions()){
+          txn.set_next_primary(sender % total_num_ + 1);
+        }
+      }
+      CommitProposal(std::move(committed_p));
+    }
+
+    //LOG(ERROR)<<"send cert view:"<<view<<" to:"<<NextLeader(view);
+  }
+
+  if (is_final) {
+    SendMessage(MessageType::Vote, *cert, NextLeader(view));
+  } else {
+    SendMessage(MessageType::Vote, *cert, sender);
+  }
+
+  return true;
+}
+
+bool SlotHotStuff1::ReceiveCertificate(std::unique_ptr<Certificate> cert) {
+  // LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->view()<<" from:"<<cert->signer();
+  int view = cert->view();
+  std::string hash = cert->hash();
+  int slot = cert->slot();
+  bool is_final = cert->is_final();
+  int signer = cert->signer();
+  {
+    std::unique_lock<std::mutex> lk(rec_mutex2_);
+    if(cert_count_ >= 2*f_+1 || view < min_view_ || (view == min_view_ && slot <= min_slot_)) {
+      return false;
+    }
+    cert_count_++;
+  }
+  bool valid = proposal_manager_->VerifyCert(*cert);
+  if(!valid){
+    LOG(ERROR) << "Verify message fail";
+    assert(1==0);
+    return false;
+  }
+  
+  // LOG(ERROR)<<"RECEIVE proposer cert :"<<cert->slot()<<" from:"<<cert->signer() << " " << (GetCurrentTime() & (uint64_t)0xFFFFFF);
+  uint64_t x = GetCurrentTime();
+  std::unique_lock<std::mutex> lk(rec_mutex_);
+  receive_[view][hash].insert(std::make_pair(cert->signer(), std::move(cert)));
+
+  //LOG(ERROR)<<"RECEIVE proposer cert :"<<view<<" size:"<<receive_[view][hash].size();
+  if(receive_[view][hash].size() == 2*f_+1){
+    {
+      std::unique_lock<std::mutex> lk(rec_mutex2_);
+      min_view_ = view;
+      min_slot_ = slot;
+      cert_count_ = 0;
+    }
+
+    // LOG(ERROR) << "ENOUGH RESPONSE " << GetCurrentTime();
+    std::unique_ptr<QC> qc = std::make_unique<QC>();
+    qc->set_hash(hash);
+    qc->set_view(view);
+    qc->set_slot(slot);
+    qc->set_is_final(is_final);
+
+    for(auto & it: receive_[view][hash]){
+      *qc->add_signatures() = it.second->sign();
+    }
+
+    //LOG(ERROR)<<"add qc view:"<<view;
+    proposal_manager_->AddQC(std::move(qc));
+    ready_ = true;
+
+    StartNewRound();
+  }
+  // LOG(ERROR)<< "cert :"<<slot<<" from:"<<signer << " " << GetCurrentTime() - x;
+  return true;
+}
+
+void SlotHotStuff1::CommitProposal(std::unique_ptr<Proposal> p){
+  commit_q_.Push(std::move(p));
+}
+
+std::unique_ptr<Certificate> SlotHotStuff1::GenerateCertificate(const Proposal& proposal) {
+  std::unique_ptr<Certificate> cert = std::make_unique<Certificate>();
+  cert->set_hash(proposal.hash());
+  cert->set_view(proposal.header().view());
+  cert->set_slot(proposal.header().slot());
+  cert->set_is_final(proposal.header().is_final());
+  cert->set_signer(id_);
+
+  std::string data_str = proposal.hash();
+  auto hash_signature_or = verifier_->SignMessage(data_str);
+  if (!hash_signature_or.ok()) {
+    LOG(ERROR) << "Sign message fail";
+    return nullptr;
+  }
+  *cert->mutable_sign()=*hash_signature_or;
+  return cert;
+}
+
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/algorithm/hs.h b/platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.h
similarity index 61%
copy from platform/consensus/ordering/hs/algorithm/hs.h
copy to platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.h
index 04148a37..2c56a5e0 100644
--- a/platform/consensus/ordering/hs/algorithm/hs.h
+++ b/platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.h
@@ -3,17 +3,18 @@
 #include <thread>
 
 #include "platform/common/queue/lock_free_queue.h"
-#include "platform/consensus/ordering/hs/algorithm/proposal_manager.h"
-#include "platform/consensus/ordering/hs/proto/proposal.pb.h"
+#include "platform/consensus/ordering/slot_hs1/algorithm/proposal_manager.h"
+#include "platform/consensus/ordering/slot_hs1/proto/proposal.pb.h"
 #include "platform/consensus/ordering/common/algorithm/protocol_base.h"
+#include "platform/statistic/stats.h"
 
 namespace resdb {
-namespace hs {
+namespace slot_hs1 {
 
-class HotStuff: public common::ProtocolBase {
+class SlotHotStuff1: public common::ProtocolBase {
  public:
-  HotStuff(int id, int f, int total_num, SignatureVerifier* verifier );
-  ~HotStuff();
+  SlotHotStuff1(int id, int f, int total_num, SignatureVerifier* verifier, int non_responsive_num, int fork_tail_num, int rollback_num);
+  ~SlotHotStuff1();
 
   //  recv txn -> send block with links -> rec block ack -> send block with certs
   bool ReceiveTransaction(std::unique_ptr<Transaction> txn);
@@ -38,7 +39,7 @@ class HotStuff: public common::ProtocolBase {
   LockFreeQueue<Transaction> txns_;
   LockFreeQueue<Proposal> commit_q_;
 
-  std::mutex mutex_, n_mutex_, pmutex_[1024];
+  std::mutex mutex_, rec_mutex_, rec_mutex2_, n_mutex_, pmutex_[1024];
   //std::mutex mutex_, n_mutex_;
   std::condition_variable vote_cv_;
   std::unique_ptr<ProposalManager> proposal_manager_;
@@ -51,8 +52,21 @@ class HotStuff: public common::ProtocolBase {
   //[view][hash][signer][cert]
   //std::map<std::string, std::map<int, std::unique_ptr<Certificate>> >  receive_[1024];
   std::map<int,  std::map<std::string, std::map<int, std::unique_ptr<Certificate>> > > receive_;
+  Stats* global_stats_ = nullptr;
 
+  bool ready_;
+  int slot_num_;
+  uint64_t timer_length_;
+
+  int non_responsive_num_, fork_tail_num_, rollback_num_;
+
+  uint64_t last_time_ = 0;
+  uint64_t min_view_ = 0;
+  uint64_t min_slot_ = 0;
+  uint64_t cert_count_ = 0;
+
+  bool qc_formed_, proposal_received_;
 };
 
-}  // namespace tusk
-}  // namespace resdb
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/framework/BUILD b/platform/consensus/ordering/slot_hs1/framework/BUILD
similarity index 60%
copy from platform/consensus/ordering/hs/framework/BUILD
copy to platform/consensus/ordering/slot_hs1/framework/BUILD
index cd052cc7..93219e75 100644
--- a/platform/consensus/ordering/hs/framework/BUILD
+++ b/platform/consensus/ordering/slot_hs1/framework/BUILD
@@ -8,13 +8,21 @@ cc_library(
         "//visibility:public",
     ],
     deps = [
+        "performance_manager",
         "//common/utils",
         "//executor/common:transaction_manager",
         "//platform/consensus/ordering/common/framework:consensus",
         "//platform/consensus/execution:transaction_executor",
-        "//platform/consensus/ordering/hs/algorithm:hs",
+        "//platform/consensus/ordering/slot_hs1/algorithm:slot_hs1",
         "//platform/networkstrate:consensus_manager",
     ],
 )
 
-
+cc_library(
+    name = "performance_manager",
+    srcs = ["performance_manager.cpp"],
+    hdrs = ["performance_manager.h"],
+    deps = [
+        "//platform/consensus/ordering/common/framework:performance_manager",
+    ],
+)
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/framework/consensus.cpp b/platform/consensus/ordering/slot_hs1/framework/consensus.cpp
similarity index 75%
copy from platform/consensus/ordering/hs/framework/consensus.cpp
copy to platform/consensus/ordering/slot_hs1/framework/consensus.cpp
index 80974721..76a54693 100644
--- a/platform/consensus/ordering/hs/framework/consensus.cpp
+++ b/platform/consensus/ordering/slot_hs1/framework/consensus.cpp
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -23,7 +23,7 @@
  *
  */
 
-#include "platform/consensus/ordering/hs/framework/consensus.h"
+#include "platform/consensus/ordering/slot_hs1/framework/consensus.h"
 
 #include <glog/logging.h>
 #include <unistd.h>
@@ -31,12 +31,21 @@
 #include "common/utils/utils.h"
 
 namespace resdb {
-namespace hs {
+namespace slot_hs1 {
+
+std::unique_ptr<SlotHotStuff1PerformanceManager> Consensus::GetPerformanceManager() {
+        return config_.IsPerformanceRunning()
+        ? std::make_unique<SlotHotStuff1PerformanceManager>(
+          config_, GetBroadCastClient(), GetSignatureVerifier())
+        : nullptr;
+}
 
 Consensus::Consensus(const ResDBConfig& config,
                      std::unique_ptr<TransactionManager> executor)
     : common::Consensus(config, std::move(executor)) {
 
+  SetPerformanceManager(GetPerformanceManager());
+
   Init();
 
   int total_replicas = config_.GetReplicaNum();
@@ -46,8 +55,8 @@ Consensus::Consensus(const ResDBConfig& config,
           .public_key()
           .public_key_info()
           .type() != CertificateKeyInfo::CLIENT) {
-    hs_= std::make_unique<HotStuff>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier());
-    InitProtocol(hs_.get());
+    slot_hs1_= std::make_unique<SlotHotStuff1>(config_.GetSelfInfo().id(), f, total_replicas, GetSignatureVerifier(), config_.GetNonResponsiveNum(), config_.GetForkTailNum(), config_.GetRollBackNum());
+    InitProtocol(slot_hs1_.get());
   }
 }
 
@@ -62,7 +71,7 @@ int Consensus::ProcessCustomConsensus(std::unique_ptr<Request> request) {
       assert(1 == 0);
       return -1;
     }
-    hs_->ReceiveProposal(std::move(p));
+    slot_hs1_->ReceiveProposal(std::move(p));
   }
   else if(request->user_type() == MessageType::Vote) {
     std::unique_ptr<Certificate> cert = std::make_unique<Certificate>();
@@ -71,7 +80,7 @@ int Consensus::ProcessCustomConsensus(std::unique_ptr<Request> request) {
       assert(1 == 0);
       return -1;
     }
-    hs_->ReceiveCertificate(std::move(cert));
+    slot_hs1_->ReceiveCertificate(std::move(cert));
   }
   return 0;
 }
@@ -82,7 +91,7 @@ int Consensus::ProcessNewTransaction(std::unique_ptr<Request> request) {
   txn->set_hash(request->hash());
   txn->set_proxy_id(request->proxy_id());
   txn->set_user_seq(request->user_seq());
-  return hs_->ReceiveTransaction(std::move(txn));
+  return slot_hs1_->ReceiveTransaction(std::move(txn));
 }
 
 int Consensus::CommitMsg(const google::protobuf::Message& msg) {
@@ -95,10 +104,13 @@ int Consensus::CommitMsgInternal(const Transaction& txn) {
   request->set_data(txn.data());
   request->set_seq(txn.id());
   request->set_proxy_id(txn.proxy_id());
+  request->set_primary_id(txn.proposer());
+  request->set_next_primary(txn.next_primary());
+  // LOG(ERROR) << "primary: " << txn.proposer();
   transaction_executor_->AddExecuteMessage(std::move(request));
   return 0;
 }
 
 
-}  // namespace fairdag
-}  // namespace resdb
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/framework/consensus.h b/platform/consensus/ordering/slot_hs1/framework/consensus.h
similarity index 84%
copy from platform/consensus/ordering/hs/framework/consensus.h
copy to platform/consensus/ordering/slot_hs1/framework/consensus.h
index 8650b8f3..b7f98d64 100644
--- a/platform/consensus/ordering/hs/framework/consensus.h
+++ b/platform/consensus/ordering/slot_hs1/framework/consensus.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -27,12 +27,13 @@
 
 #include "executor/common/transaction_manager.h"
 #include "platform/consensus/execution/transaction_executor.h"
-#include "platform/consensus/ordering/hs/algorithm/hs.h"
+#include "platform/consensus/ordering/slot_hs1/algorithm/slot_hs1.h"
 #include "platform/consensus/ordering/common/framework/consensus.h"
+#include "platform/consensus/ordering/slot_hs1/framework/performance_manager.h"
 #include "platform/networkstrate/consensus_manager.h"
 
 namespace resdb {
-namespace hs {
+namespace slot_hs1 {
 
 class Consensus : public common::Consensus{
  public:
@@ -45,9 +46,11 @@ class Consensus : public common::Consensus{
   int CommitMsg(const google::protobuf::Message& msg) override;
   int CommitMsgInternal(const Transaction& txn);
 
+  std::unique_ptr<SlotHotStuff1PerformanceManager> GetPerformanceManager();
+
   private:
-    std::unique_ptr<HotStuff> hs_;
+    std::unique_ptr<SlotHotStuff1> slot_hs1_;
 };
 
-}  // namespace tusk
-}  // namespace resdb
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/slot_hs1/framework/performance_manager.cpp b/platform/consensus/ordering/slot_hs1/framework/performance_manager.cpp
new file mode 100644
index 00000000..a80ebd15
--- /dev/null
+++ b/platform/consensus/ordering/slot_hs1/framework/performance_manager.cpp
@@ -0,0 +1,203 @@
+/*
+
+ *
+ * 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 "platform/consensus/ordering/slot_hs1/framework/performance_manager.h"
+
+#include <glog/logging.h>
+
+#include "common/utils/utils.h"
+
+namespace resdb {
+namespace slot_hs1 {
+
+using comm::CollectorResultCode;
+
+SlotHotStuff1PerformanceManager::SlotHotStuff1PerformanceManager(
+    const ResDBConfig& config, ReplicaCommunicator* replica_communicator,
+    SignatureVerifier* verifier)
+    : PerformanceManager(config, replica_communicator, verifier){
+  client_num_ = 1;
+  primary_ = 2;
+  slot_num_ = config_.GetSlotNum();
+  last_response_ = 2;
+  inflight_limit_ = 20;
+}
+
+
+CollectorResultCode SlotHotStuff1PerformanceManager::AddResponseMsg(
+    std::unique_ptr<Request> request,
+    std::function<void(std::unique_ptr<BatchUserResponse>)> response_call_back) {
+  if (request == nullptr) {
+    return CollectorResultCode::INVALID;
+  }
+
+  //uint64_t seq = request->seq();
+
+  std::unique_ptr<BatchUserResponse> batch_response = std::make_unique<BatchUserResponse>();
+  if (!batch_response->ParseFromString(request->data())) {
+    LOG(ERROR) << "parse response fail:"<<request->data().size()
+    <<" seq:"<<request->seq(); return CollectorResultCode::INVALID;
+  }
+
+  uint64_t seq = batch_response->local_id();
+  //LOG(ERROR)<<"receive seq:"<<seq;
+
+  bool first = false;
+  bool done = false;
+  {
+    int idx = seq % response_set_size_;
+    std::unique_lock<std::mutex> lk(response_lock_[idx]);
+    if (response_[idx].find(seq) == response_[idx].end()) {
+      //LOG(ERROR)<<"has done local seq:"<<seq<<" global seq:"<<request->seq();
+      return CollectorResultCode::OK;
+    }
+    response_[idx][seq]++;
+    //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" send:"<<send_num_;
+
+    if (response_[idx][seq] == 1) {
+      first = true;
+    }
+
+    if (response_[idx][seq] >= config_.GetMinDataReceiveNum()) {
+      //LOG(ERROR)<<"get seq :"<<request->seq()<<" local id:"<<seq<<" num:"<<response_[idx][seq]<<" done:"<<send_num_;
+      response_[idx].erase(response_[idx].find(seq));
+      done = true;
+    }
+  }
+
+  if (first) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::FIRST_RESPONSE;
+  }
+
+  if (done) {
+    response_call_back(std::move(batch_response));
+    return CollectorResultCode::STATE_CHANGED;
+  }
+  return CollectorResultCode::OK;
+}
+
+
+int SlotHotStuff1PerformanceManager::ProcessResponseMsg(std::unique_ptr<Context> context,
+                                           std::unique_ptr<Request> request) {
+  std::unique_ptr<Request> response;
+  // Add the response message, and use the call back to collect the received
+  // messages.
+  // The callback will be triggered if it received f+1 messages.
+  if (request->ret() == -2) {
+    // LOG(INFO) << "get response fail:" << request->ret();
+    send_num_--;
+    return 0;
+  }
+
+  //LOG(INFO) << "get response:" << request->seq() << " sender:"<<request->sender_id();
+  std::unique_ptr<BatchUserResponse> batch_response = nullptr;
+  CollectorResultCode ret =
+      AddResponseMsg(std::move(request), [&](std::unique_ptr<BatchUserResponse> request) {
+        batch_response = std::move(request);
+        return;
+      });
+
+  if (ret == CollectorResultCode::STATE_CHANGED) {
+    // LOG(ERROR) << "[X]STATE_CHANGED " << GetCurrentTime() - last_send_time_; 
+    assert(batch_response);
+    int next_primary = batch_response->next_primary();
+    if (next_primary) {
+      // One slot of the primary would get skipped.
+      bool update = false;
+      if (next_primary != primary_) {
+        if (primary_ % 3 == 1 && primary_ < 3 * config_.GetForkTailNum()) {
+          send_num_--;
+          inflight_[primary_]--;
+        }
+        update = true;
+      }
+      primary_ = next_primary;
+      if (update) {
+        send_num_--;
+        // first_slot_ = true;
+      }
+    }
+    int primary_id = batch_response->primary_id();
+    inflight_[primary_id]--;
+    // LOG(ERROR) << "primary_id: " << primary_;
+    SendResponseToClient(*batch_response);
+  }
+  return ret == CollectorResultCode::INVALID ? -2 : 0;
+}
+
+
+// int SlotHotStuff1PerformanceManager::GetPrimary(){
+//   int view = counter_++ / slot_num_;
+//   if (counter_ % slot_num_ == 0) {
+//     counter_ += (client_num_ - 1) * slot_num_;
+//   }
+//   return view % replica_num_ + 1; 
+// }
+
+// int SlotHotStuff1PerformanceManager::GetPrimary() {
+//   while (true) {
+//     if (last_response_ != 0) {
+//       break;
+//     }
+//   }
+//   int value = last_response_;
+//   while (true) {
+//     if (inflight_[value] < inflight_limit_) {
+//       inflight_[value]++;
+//       break;
+//     }
+//     value = value % replica_num_ + 1;
+//   }
+//   return value;
+// }
+
+int SlotHotStuff1PerformanceManager::GetPrimary() {
+  // LOG(ERROR) << "send to: " << primary_ << " send_num_:" << send_num_;
+  // if (primary_ % 3 == 1 && primary_ < 3 * config_.GetRollBackNum() && first_slot_) {
+  //   send_num_--;
+  //   first_slot_ = false;
+  // }
+  //  LOG(ERROR) << "send to: " << primary_ << " send_num_:" << send_num_;
+  return primary_;
+}
+
+void SlotHotStuff1PerformanceManager::SendResponseToClient(const BatchUserResponse& batch_response) {
+  uint64_t create_time = batch_response.createtime();
+  uint64_t primary_id = batch_response.primary_id();
+  if (create_time > 0 && last_primary_id_ == primary_id) {
+  // if (create_time > 0) {
+    uint64_t run_time = GetCurrentTime() - create_time;
+    // LOG(ERROR)<<"receive current:"<<GetCurrentTime()<<" create time:"<<create_time<<" run time:"<<run_time<<" local id:"<<batch_response.local_id();
+    global_stats_->AddLatency(run_time);
+  } else {
+  }
+  last_primary_id_ = primary_id;
+  //send_num_-=10;
+  send_num_--;
+}
+
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/framework/consensus.h b/platform/consensus/ordering/slot_hs1/framework/performance_manager.h
similarity index 55%
copy from platform/consensus/ordering/hs/framework/consensus.h
copy to platform/consensus/ordering/slot_hs1/framework/performance_manager.h
index 8650b8f3..1865623d 100644
--- a/platform/consensus/ordering/hs/framework/consensus.h
+++ b/platform/consensus/ordering/slot_hs1/framework/performance_manager.h
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -25,29 +25,33 @@
 
 #pragma once
 
-#include "executor/common/transaction_manager.h"
-#include "platform/consensus/execution/transaction_executor.h"
-#include "platform/consensus/ordering/hs/algorithm/hs.h"
-#include "platform/consensus/ordering/common/framework/consensus.h"
-#include "platform/networkstrate/consensus_manager.h"
+#include <future>
+
+#include "platform/consensus/ordering/common/framework/performance_manager.h"
 
 namespace resdb {
-namespace hs {
+namespace slot_hs1 {
 
-class Consensus : public common::Consensus{
+class SlotHotStuff1PerformanceManager : public common::PerformanceManager {
  public:
-  Consensus(const ResDBConfig& config,
-            std::unique_ptr<TransactionManager> transaction_manager);
+  SlotHotStuff1PerformanceManager(const ResDBConfig& config,
+                     ReplicaCommunicator* replica_communicator,
+                     SignatureVerifier* verifier);
+
+protected:
+  int ProcessResponseMsg(std::unique_ptr<Context> context,
+                                           std::unique_ptr<Request> request) override;
+  comm::CollectorResultCode AddResponseMsg(
+      std::unique_ptr<Request> request,
+      std::function<void(std::unique_ptr<BatchUserResponse>)> call_back) override;
+
+  int GetPrimary() override;
 
-  protected:
-  int ProcessCustomConsensus(std::unique_ptr<Request> request) override;
-  int ProcessNewTransaction(std::unique_ptr<Request> request) override;
-  int CommitMsg(const google::protobuf::Message& msg) override;
-  int CommitMsgInternal(const Transaction& txn);
+  void SendResponseToClient(const BatchUserResponse& batch_response) override;
 
-  private:
-    std::unique_ptr<HotStuff> hs_;
+  int last_primary_id_ = 2;
+  bool first_slot_ = false;
 };
 
-}  // namespace tusk
-}  // namespace resdb
+}  // namespace slot_hs1
+}  // namespace resdb
\ No newline at end of file
diff --git a/platform/consensus/ordering/slot_hs1/proto/BUILD b/platform/consensus/ordering/slot_hs1/proto/BUILD
new file mode 100644
index 00000000..41ac7036
--- /dev/null
+++ b/platform/consensus/ordering/slot_hs1/proto/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//platform/consensus/ordering/slot_hs1:__subpackages__"])
+
+load("@rules_cc//cc:defs.bzl", "cc_proto_library")
+load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
+
+proto_library(
+    name = "proposal_proto",
+    srcs = ["proposal.proto"],
+    deps = ["//common/proto:signature_info_proto"],
+)
+
+cc_proto_library(
+    name = "proposal_cc_proto",
+    deps = [":proposal_proto"],
+)
\ No newline at end of file
diff --git a/platform/consensus/ordering/hs/proto/proposal.proto b/platform/consensus/ordering/slot_hs1/proto/proposal.proto
similarity index 82%
copy from platform/consensus/ordering/hs/proto/proposal.proto
copy to platform/consensus/ordering/slot_hs1/proto/proposal.proto
index a5079050..8680e3f4 100644
--- a/platform/consensus/ordering/hs/proto/proposal.proto
+++ b/platform/consensus/ordering/slot_hs1/proto/proposal.proto
@@ -1,14 +1,15 @@
 syntax = "proto3";
 import "common/proto/signature_info.proto";
 
-package resdb.hs;
+package resdb.slot_hs1;
 
 message Certificate {
   SignatureInfo sign = 1;
   int32 view = 2;
   int32 signer = 3;
   bytes hash = 4;
-  int32 slot = 6;
+  int32 slot = 5;
+  bool is_final = 6;
 }
 
 message Transaction{
@@ -19,6 +20,8 @@ message Transaction{
   int32 proposer = 5;
   uint64 timestamp = 6;
   int64 user_seq = 7;
+  int32 next_primary = 8;
+  uint64 reception_time = 9;
 }
 
 enum ProposalType{
@@ -33,6 +36,7 @@ message QC {
   int32 view = 2;
   bytes hash = 3;
   int32 slot = 4;
+  bool is_final = 5;
 }
 
 message Header {
@@ -42,6 +46,7 @@ message Header {
   QC qc = 4;
   bytes prehash = 5;
   int32 slot = 6;
+  bool is_final = 7;
 }
 
 message Proposal {
@@ -49,10 +54,10 @@ message Proposal {
   repeated Transaction transactions = 2;
   int32 sender = 3;
   bytes hash = 4;
+  uint64 createtime = 5;
 };
 
 enum MessageType {
   NewProposal = 0;
   Vote = 1;
-};
-
+};
\ No newline at end of file
diff --git a/platform/consensus/ordering/zzy/algorithm/BUILD b/platform/consensus/ordering/zzy/algorithm/BUILD
new file mode 100644
index 00000000..73def881
--- /dev/null
+++ b/platform/consensus/ordering/zzy/algorithm/BUILD
@@ -0,0 +1,16 @@
+package(default_visibility = ["//platform/consensus/ordering/zzy:__subpackages__"])
+
+cc_library(
+    name = "zzy",
+    srcs = ["zzy.cpp"],
+    hdrs = ["zzy.h"],
+    deps = [
+        "//platform/statistic:stats",
+        "//common:comm",
+        "//platform/consensus/ordering/zzy/proto:proposal_cc_proto",
+        "//common/crypto:signature_verifier",
+        "//platform/common/queue:lock_free_queue",
+        "//platform/config:resdb_config",
+      "//platform/consensus/ordering/common/algorithm:protocol_base",
+    ],
+)
diff --git a/platform/consensus/ordering/zzy/algorithm/zzy.cpp b/platform/consensus/ordering/zzy/algorithm/zzy.cpp
new file mode 100644
index 00000000..4a7046a1
--- /dev/null
+++ b/platform/consensus/ordering/zzy/algorithm/zzy.cpp
@@ -0,0 +1,206 @@
+#include "platform/consensus/ordering/zzy/algorithm/zzy.h"
+
+#include <glog/logging.h>
+
+#include "common/crypto/signature_verifier.h"
+#include "common/utils/utils.h"
+
+namespace resdb {
+namespace zzy {
+
+ZZY::ZZY(const ResDBConfig& config, int id, int f, int total_num, SignatureVerifier* verifier)
+    : ProtocolBase(id, f, total_num), config_(config), verifier_(verifier) {
+
+  id_ = id;
+  total_num_ = total_num;
+  f_ = f;
+  is_stop_ = false;
+  seq_ = 1;
+  commit_seq_ = 0;
+
+  commit_thread_ = std::thread(&ZZY::AsyncCommit, this);
+}
+
+ZZY::~ZZY() {
+  is_stop_ = true;
+}
+
+bool ZZY::IsStop() { return is_stop_; }
+
+void ZZY::SetFailFunc(std::function<void(const Transaction& txn)> func) {
+  fail_func_ = func;
+}
+
+void ZZY::SendFail(const Transaction& txn) {
+  fail_func_(txn);
+}
+
+void ZZY::AsyncCommit() {
+  while (!IsStop()) {
+    auto proposal = commit_q_.Pop();
+    if(proposal == nullptr) {
+      continue;
+    }
+    int64_t seq = proposal->seq();
+
+    std::unique_ptr<Transaction> txn = nullptr;
+    while(txn == nullptr) {
+      std::unique_lock<std::mutex> lk(mutex_[seq%1000]);
+      auto it = data_[seq%1000].find(proposal->hash());
+      if(it != data_[seq%1000].end()){
+        txn = std::move(it->second);
+        data_[seq%1000].erase(it);
+      }
+    }
+    assert(txn != nullptr);
+    commit_(*txn);
+    {
+      std::unique_lock<std::mutex> lk(commit_mutex_[seq%1000]);
+      committed_[seq%1000].insert(txn->hash());
+      //LOG(ERROR)<<"receive commit:"<<" seq:"<<seq<<" txn hash:"<<txn->hash().size();
+    }
+  }
+}
+
+
+bool ZZY::ReceiveTransaction(std::unique_ptr<Transaction> txn) {
+
+  int water_mark = config_.GetConfigData().water_mark();
+  // LOG(ERROR)<<" get water mark:"<<water_mark<<" seq:"<<seq_<<" commit :"<<commit_seq_;
+  if(water_mark >0) {
+    if(seq_ - commit_seq_ > water_mark) {
+      //LOG(ERROR)<<" seq:"<<seq_<<" commit seq:"<<commit_seq_<<" gap fail";
+      return false;
+    }
+  }
+
+  txn->set_create_time(GetCurrentTime());
+  txn->set_seq(seq_++);
+  txn->set_proposer(id_);
+
+  Broadcast(MessageType::Propose, *txn);
+  
+  return true;
+}
+
+bool ZZY::ReceivePropose(std::unique_ptr<Transaction> txn) {
+  if (id_ % 3 == 2 && id_ <= 3 * config_.GetConfigData().crash_num()) {
+    return true;
+  }
+  std::string hash = txn->hash();
+  int64_t seq = txn->seq();
+  int proposer = txn->proposer();
+  int client = txn->proxy_id();
+  // LOG(ERROR)<<"recv proposal from:"<<proposer<<" id:"<<seq<<" client:"<<client;
+  {
+    // LOG(ERROR)<<"recv proposal";
+    //LOG(ERROR)<<"recv txn from:"<<txn->proposer()<<" id:"<<txn->seq();
+    std::unique_lock<std::mutex> lk(mutex_[seq%1000]);
+    data_[seq%1000][txn->hash()]=std::move(txn);
+  }
+
+  {
+    std::unique_ptr<Proposal> comit_proposal = std::make_unique<Proposal>();
+    comit_proposal->set_hash(hash);
+    comit_proposal->set_seq(seq);
+    commit_q_.Push(std::move(comit_proposal));
+    commit_seq_++;
+  }
+
+  return true;
+}
+
+bool ZZY::ReceiveACK(std::unique_ptr<Proposal> proposal) {
+  int64_t seq = proposal->seq();
+  int proposer = proposal->proposer();
+  //LOG(ERROR)<<" client receive seq:"<<seq<<" proposer:"<<proposer;
+  return true;
+}
+
+bool ZZY::Verify(const Proposal& proposal) {
+
+/*
+  if(proposal.qc().qc_size() < 2*f_+1) {
+    LOG(ERROR)<<" qc not enough:"<<proposal.qc().qc_size();
+    assert(proposal.qc().qc_size() >= 2*f_+1);
+    return false;
+  }
+  */
+
+  for(const auto& qc : proposal.qc().qc()) {
+    std::string data_hash = qc.data_hash();
+
+    bool valid =
+        verifier_->VerifyMessage(data_hash, qc.sign());
+    if (!valid) {
+      LOG(ERROR)<<" sign not valid, hash size:"<<data_hash.size();
+      return false;
+    }
+  }
+  return true;
+}
+
+bool ZZY::ReceiveCommit(std::unique_ptr<Proposal> proposal) {
+  if (id_ % 3 == 2 && id_ <= 3 * config_.GetConfigData().crash_num()) {
+    return true;
+  }
+  int64_t seq = proposal->seq();
+  int proposer = proposal->proposer();
+  int64_t local_id = proposal->local_id();
+  std::string hash = proposal->hash();
+  LOG(ERROR)<<" client commit seq:"<<seq<<" proposer:"<<proposer<<" hash size:"<<hash.size()<<" local_id:"<<local_id;
+    assert(Verify(*proposal));
+
+    std::unique_lock<std::mutex> lk(commit_mutex_[seq%1000]);
+    if(committed_[seq%1000].find(hash) == committed_[seq%1000].end()){
+      // LOG(ERROR)<<"recv proposal";
+      //LOG(ERROR)<<"recv txn from:"<<txn->proposer()<<" id:"<<txn->seq();
+      std::unique_lock<std::mutex> lk(mutex_[seq%1000]);
+      if(data_[seq%1000].find(hash) != data_[seq%1000].end()){
+        {
+          std::unique_ptr<Proposal> comit_proposal = std::make_unique<Proposal>();
+          comit_proposal->set_hash(hash);
+          comit_proposal->set_seq(seq);
+          commit_q_.Push(std::move(comit_proposal));
+          commit_seq_++;
+        }
+      }
+    }
+    else {
+    assert(committed_[seq%1000].find(hash) != committed_[seq%1000].end());
+    }
+
+  /*
+  {
+    // LOG(ERROR)<<"recv proposal";
+    //LOG(ERROR)<<"recv txn from:"<<txn->proposer()<<" id:"<<txn->seq();
+    std::unique_lock<std::mutex> lk(mutex_[seq%1000]);
+    if(data_[seq%1000].find(txn->hash()) != data_[seq%1000].end()){
+
+      {
+        std::unique_ptr<Proposal> comit_proposal = std::make_unique<Proposal>();
+        comit_proposal->set_hash(hash);
+        comit_proposal->set_seq(seq);
+        commit_q_.Push(std::move(comit_proposal));
+        commit_seq_++;
+      }
+    }
+  }
+  */
+
+
+  {
+    Proposal proposal;
+    proposal.set_hash(hash);
+    proposal.set_seq(seq);
+    proposal.set_proposer(id_);
+    proposal.set_local_id(local_id);
+
+    SendMessage(MessageType::CommitACK, proposal, proposer);
+  }
+
+  return true;
+}
+
+}  // namespace zzy
+}  // namespace resdb
diff --git a/platform/consensus/ordering/zzy/algorithm/zzy.h b/platform/consensus/ordering/zzy/algorithm/zzy.h
new file mode 100644
index 00000000..2723661f
--- /dev/null
+++ b/platform/consensus/ordering/zzy/algorithm/zzy.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <deque>
+#include <map>
+#include <queue>
+#include <thread>
+
+#include "platform/config/resdb_config.h"
+#include "platform/common/queue/lock_free_queue.h"
+#include "platform/consensus/ordering/common/algorithm/protocol_base.h"
+#include "platform/consensus/ordering/zzy/proto/proposal.pb.h"
+#include "platform/statistic/stats.h"
+
+namespace resdb {
+namespace zzy {
+
+class ZZY: public common::ProtocolBase {
+ public:
+  ZZY(const ResDBConfig& config, int id, int f, int total_num, SignatureVerifier* verifier);
+  ~ZZY();
+
+  bool ReceiveTransaction(std::unique_ptr<Transaction> txn);
+  bool ReceivePropose(std::unique_ptr<Transaction> txn);
+  bool ReceivePrepare(std::unique_ptr<Proposal> proposal);
+  bool ReceiveCommit(std::unique_ptr<Proposal> proposal) ;
+  void SetFailFunc(std::function<void(const Transaction& txn)> func);
+  void SendFail(const Transaction& txn);
+  void AsyncCommit();
+
+  bool ReceiveACK(std::unique_ptr<Proposal> proposal);
+
+ private:
+  bool IsStop();
+  bool Verify(const Proposal& proposal);
+
+ private:
+  bool linear_ = false;
+  std::mutex mutex_[1000], commit_mutex_[1000], smutex_[1000];
+  std::map<int64_t, std::set<int32_t> > commit_received_[1000];
+  std::map<int64_t, std::set<int32_t> > received_[1000];
+  std::map<int64_t, std::vector<std::unique_ptr<Proposal>> > support_received_[1000];
+  //std::map<std::string, std::set<int32_t> > received_, commit_received_;
+  std::map<std::string, std::unique_ptr<Transaction> > data_[1000];
+  std::set<std::string> committed_[1000];
+
+  std::thread send_thread_, commit_thread_;
+
+  std::atomic<int64_t> seq_;
+  bool is_stop_;
+  const ResDBConfig& config_;
+  SignatureVerifier* verifier_;
+  Stats* global_stats_;
+  std::atomic<int> commit_seq_;
+
+  LockFreeQueue<Transaction> txns_;
+  LockFreeQueue<Proposal>  commit_q_;
+  std::function<void(const Transaction& txn)> fail_func_;
+};
+
+}  // namespace cassandra
+}  // namespace resdb
diff --git a/platform/consensus/ordering/zzy/framework/BUILD b/platform/consensus/ordering/zzy/framework/BUILD
new file mode 100644
index 00000000..a6d10629
--- /dev/null
+++ b/platform/consensus/ordering/zzy/framework/BUILD
@@ -0,0 +1,27 @@
+package(default_visibility = ["//visibility:private"])
+
+cc_library(
+    name = "consensus",
+    srcs = ["consensus.cpp"],
+    hdrs = ["consensus.h"],
+    visibility = [
+        "//visibility:public",
+    ],
+    deps = [
+        ":performance_manager",
+        "//common/utils",
+        "//platform/consensus/ordering/common/framework:consensus",
+        "//platform/consensus/ordering/zzy/algorithm:zzy",
+    ],
+)
+
+cc_library(
+    name = "performance_manager",
+    srcs = ["performance_manager.cpp"],
+    hdrs = ["performance_manager.h"],
+    deps = [
+        "//platform/consensus/ordering/common/framework:performance_manager",
+        "//platform/consensus/ordering/zzy/proto:proposal_cc_proto",
+    ],
+)
+
diff --git a/platform/consensus/ordering/zzy/framework/consensus.cpp b/platform/consensus/ordering/zzy/framework/consensus.cpp
new file mode 100644
index 00000000..dc7d595d
--- /dev/null
+++ b/platform/consensus/ordering/zzy/framework/consensus.cpp
@@ -0,0 +1,186 @@
+/*
+ * 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 "platform/consensus/ordering/zzy/framework/consensus.h"
+
+#include <glog/logging.h>
+#include <unistd.h>
+
+#include "common/utils/utils.h"
+
+namespace resdb {
+namespace zzy {
+
+std::unique_ptr<ZZYPerformanceManager> Consensus::GetPerformanceManager() {
+        return config_.IsPerformanceRunning()
+        ? std::make_unique<ZZYPerformanceManager>(
+          config_, GetBroadCastClient(), GetSignatureVerifier())
+        : nullptr;
+}
+
+
+Consensus::Consensus(const ResDBConfig& config,
+    std::unique_ptr<TransactionManager> executor)
+  : common::Consensus(config, nullptr)
+  {
+
+    transaction_executor_ = std::make_unique<TransactionExecutor>(
+          config,
+          [&](std::unique_ptr<Request> request,
+              std::unique_ptr<BatchUserResponse> resp_msg) {
+            ResponseMsg(*request, *resp_msg);
+          },
+          nullptr, std::move(executor));
+
+    int total_replicas = config_.GetReplicaNum();
+    int f = (total_replicas - 1) / 3;
+
+    if (config_.GetPublicKeyCertificateInfo()
+        .public_key()
+        .public_key_info()
+        .type() == CertificateKeyInfo::CLIENT) {
+      SetPerformanceManager(GetPerformanceManager());
+    }
+
+    Init();
+
+    start_ = 0;
+
+    if (config_.GetPublicKeyCertificateInfo()
+        .public_key()
+        .public_key_info()
+        .type() != CertificateKeyInfo::CLIENT) {
+      zzy_ = std::make_unique<ZZY>(
+          config_, config_.GetSelfInfo().id(), f,
+          total_replicas, GetSignatureVerifier());
+      InitProtocol(zzy_.get());
+      // zzy_->SetFailFunc([&](const Transaction& txn) {
+      //     SendFail(txn.proxy_id(), txn.hash());
+      //   });
+    }
+  }
+
+int Consensus::ProcessCustomConsensus(std::unique_ptr<Request> request) {
+  if (request->user_type() == MessageType::Propose) {
+    std::unique_ptr<Transaction> txn = std::make_unique<Transaction>();
+    if (!txn->ParseFromString(request->data())) {
+      assert(1 == 0);
+      LOG(ERROR) << "parse proposal fail";
+      return -1;
+    }
+    zzy_->ReceivePropose(std::move(txn));
+    return 0;
+  }
+  else if (request->user_type() == MessageType::CommitACK) {
+    std::unique_ptr<Proposal> proposal = std::make_unique<Proposal>();
+    if (!proposal->ParseFromString(request->data())) {
+      LOG(ERROR) << "parse proposal fail";
+      assert(1 == 0);
+      return -1;
+    }
+    dynamic_cast<ZZYPerformanceManager*>(performance_manager_.get())->ReceiveCommitACK(std::move(proposal));
+  }
+  else if (request->user_type() == MessageType::Commit) {
+    std::unique_ptr<Proposal> proposal = std::make_unique<Proposal>();
+    if (!proposal->ParseFromString(request->data())) {
+      LOG(ERROR) << "parse proposal fail";
+      assert(1 == 0);
+      return -1;
+    }
+    zzy_->ReceiveCommit(std::move(proposal));
+  }
+  return 0;
+}
+
+int Consensus::ProcessNewTransaction(std::unique_ptr<Request> request) {
+
+  
+  std::unique_ptr<Transaction> txn = std::make_unique<Transaction>();
+  txn->set_data(request->data());
+  txn->set_hash(request->hash());
+  txn->set_proxy_id(request->proxy_id());
+  txn->set_uid(request->uid());
+  int proxy_id = txn->proxy_id();
+  std::string hash = txn->hash();
+  // LOG(ERROR)<<"receive txn";
+  bool ret = zzy_->ReceiveTransaction(std::move(txn));
+  if(!ret){
+  //   SendFail(proxy_id, hash);
+    assert(false);
+  }
+  return ret;
+}
+
+int Consensus::CommitMsg(const google::protobuf::Message& msg) {
+  return CommitMsgInternal(dynamic_cast<const Transaction&>(msg));
+}
+
+int Consensus::CommitMsgInternal(const Transaction& txn) {
+  //LOG(ERROR)<<"commit txn:"<<txn.seq()<<" proxy id:"<<txn.proxy_id()<<" uid:"<<txn.uid();
+  std::unique_ptr<Request> request = std::make_unique<Request>();
+  request->set_data(txn.data());
+  request->set_seq(txn.seq());
+  request->set_uid(txn.uid());
+  request->set_proxy_id(txn.proxy_id());
+  request->set_hash(txn.hash());
+
+  transaction_executor_->Commit(std::move(request));
+  return 0;
+}
+
+int Consensus::ResponseMsg(const Request &request, const BatchUserResponse& batch_resp){
+  if(config_.GetSelfInfo().id() == 2 && batch_resp.local_id() > 10) {
+  //  return true;
+  }
+    Request resp_request;
+    resp_request.set_seq(batch_resp.seq());
+    resp_request.set_type(Request::TYPE_RESPONSE);
+    resp_request.set_sender_id(config_.GetSelfInfo().id());
+    resp_request.set_proxy_id(batch_resp.proxy_id());
+    resp_request.set_hash(request.hash());
+
+    batch_resp.SerializeToString(resp_request.mutable_data());
+
+
+    if (verifier_) {
+       resp_request.set_data_hash(SignatureVerifier::CalculateHash(request.data()));
+      auto signature_or = verifier_->SignMessage(resp_request.data_hash());
+      if (!signature_or.ok()) {
+        LOG(ERROR) << "Sign message fail";
+        return -2;
+      }
+      *resp_request.mutable_data_signature() = *signature_or;
+      // LOG(ERROR)<<" sign:";
+    }
+
+    //LOG(ERROR)<<" send back to proxy:"<<request.proxy_id();
+    //global_stats_->AddResponseDelay(GetCurrentTime()- batch_resp.createtime());
+    replica_communicator_->SendMessage(resp_request, resp_request.proxy_id());
+  return 0;
+}
+
+
+}  // namespace zzy
+}  // namespace resdb
diff --git a/platform/consensus/ordering/hs/framework/consensus.h b/platform/consensus/ordering/zzy/framework/consensus.h
similarity index 72%
copy from platform/consensus/ordering/hs/framework/consensus.h
copy to platform/consensus/ordering/zzy/framework/consensus.h
index 8650b8f3..02b94629 100644
--- a/platform/consensus/ordering/hs/framework/consensus.h
+++ b/platform/consensus/ordering/zzy/framework/consensus.h
@@ -26,28 +26,40 @@
 #pragma once
 
 #include "executor/common/transaction_manager.h"
-#include "platform/consensus/execution/transaction_executor.h"
-#include "platform/consensus/ordering/hs/algorithm/hs.h"
 #include "platform/consensus/ordering/common/framework/consensus.h"
+#include "platform/consensus/ordering/zzy/framework/performance_manager.h"
+#include "platform/consensus/ordering/zzy/algorithm/zzy.h"
 #include "platform/networkstrate/consensus_manager.h"
 
 namespace resdb {
-namespace hs {
+namespace zzy {
 
-class Consensus : public common::Consensus{
+class Consensus : public common::Consensus {
  public:
   Consensus(const ResDBConfig& config,
             std::unique_ptr<TransactionManager> transaction_manager);
+  virtual ~Consensus() = default;
 
-  protected:
+ private:
   int ProcessCustomConsensus(std::unique_ptr<Request> request) override;
   int ProcessNewTransaction(std::unique_ptr<Request> request) override;
   int CommitMsg(const google::protobuf::Message& msg) override;
   int CommitMsgInternal(const Transaction& txn);
+  //int ResponseMsg(const BatchUserResponse& batch_resp) override;
+  int ResponseMsg(const Request &request, const BatchUserResponse& batch_resp);
 
-  private:
-    std::unique_ptr<HotStuff> hs_;
+  int Prepare(const Transaction& txn);
+
+
+  std::unique_ptr<ZZYPerformanceManager> GetPerformanceManager();
+
+ protected:
+  std::unique_ptr<ZZY> zzy_;
+  Stats* global_stats_;
+  int64_t start_;
+  std::mutex mutex_;
+  int send_num_[200];
 };
 
-}  // namespace tusk
+}  // namespace cassandra
 }  // namespace resdb
diff --git a/platform/consensus/ordering/zzy/framework/consensus_test.cpp b/platform/consensus/ordering/zzy/framework/consensus_test.cpp
new file mode 100644
index 00000000..2c8834a8
--- /dev/null
+++ b/platform/consensus/ordering/zzy/framework/consensus_test.cpp
@@ -0,0 +1,179 @@
+/*
+ * 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 "platform/consensus/ordering/cassandra/framework/consensus.h"
+
+#include <glog/logging.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <future>
+
+#include "common/test/test_macros.h"
+#include "executor/common/mock_transaction_manager.h"
+#include "platform/config/resdb_config_utils.h"
+#include "platform/networkstrate/mock_replica_communicator.h"
+
+namespace resdb {
+namespace cassandra {
+namespace {
+
+using ::resdb::testing::EqualsProto;
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Test;
+
+ResDBConfig GetConfig() {
+  ResDBConfig config({GenerateReplicaInfo(1, "127.0.0.1", 1234),
+                      GenerateReplicaInfo(2, "127.0.0.1", 1235),
+                      GenerateReplicaInfo(3, "127.0.0.1", 1236),
+                      GenerateReplicaInfo(4, "127.0.0.1", 1237)},
+                     GenerateReplicaInfo(1, "127.0.0.1", 1234));
+  return config;
+}
+
+class ConsensusTest : public Test {
+ public:
+  ConsensusTest() : config_(GetConfig()) {
+    auto transaction_manager =
+        std::make_unique<MockTransactionExecutorDataImpl>();
+    mock_transaction_manager_ = transaction_manager.get();
+    consensus_ =
+        std::make_unique<Consensus>(config_, std::move(transaction_manager));
+    consensus_->SetCommunicator(&replica_communicator_);
+  }
+
+  void AddTransaction(const std::string& data) {
+    auto request = std::make_unique<Request>();
+    request->set_type(Request::TYPE_NEW_TXNS);
+
+    Transaction txn;
+
+    BatchUserRequest batch_request;
+    auto req = batch_request.add_user_requests();
+    req->mutable_request()->set_data(data);
+
+    batch_request.set_local_id(1);
+    batch_request.SerializeToString(txn.mutable_data());
+
+    txn.SerializeToString(request->mutable_data());
+
+    EXPECT_EQ(consensus_->ConsensusCommit(nullptr, std::move(request)), 0);
+  }
+
+ protected:
+  ResDBConfig config_;
+  MockTransactionExecutorDataImpl* mock_transaction_manager_;
+  MockReplicaCommunicator replica_communicator_;
+  std::unique_ptr<TransactionManager> transaction_manager_;
+  std::unique_ptr<Consensus> consensus_;
+};
+
+TEST_F(ConsensusTest, NormalCase) {
+  std::promise<bool> commit_done;
+  std::future<bool> commit_done_future = commit_done.get_future();
+
+  EXPECT_CALL(replica_communicator_, BroadCast)
+      .WillRepeatedly(Invoke([&](const google::protobuf::Message& msg) {
+        Request request = *dynamic_cast<const Request*>(&msg);
+
+        if (request.user_type() == MessageType::NewProposal) {
+          LOG(ERROR) << "bc new proposal";
+          consensus_->ConsensusCommit(nullptr,
+                                      std::make_unique<Request>(request));
+          LOG(ERROR) << "recv proposal done";
+        }
+        if (request.user_type() == MessageType::Vote) {
+          LOG(ERROR) << "bc vote";
+
+          VoteMessage ack_msg;
+          assert(ack_msg.ParseFromString(request.data()));
+          for (int i = 1; i <= 3; ++i) {
+            ack_msg.set_proposer_id(i);
+            auto new_req = std::make_unique<Request>(request);
+            ack_msg.SerializeToString(new_req->mutable_data());
+
+            consensus_->ConsensusCommit(nullptr, std::move(new_req));
+          }
+        }
+        // LOG(ERROR)<<"bc type:"<<request->type()<<" user
+        // type:"<<request->user_type();
+        if (request.user_type() == MessageType::Prepare) {
+          LOG(ERROR) << "bc prepare";
+
+          VoteMessage ack_msg;
+          assert(ack_msg.ParseFromString(request.data()));
+          for (int i = 1; i <= 3; ++i) {
+            ack_msg.set_proposer_id(i);
+            auto new_req = std::make_unique<Request>(request);
+            ack_msg.SerializeToString(new_req->mutable_data());
+
+            consensus_->ConsensusCommit(nullptr, std::move(new_req));
+          }
+        }
+        if (request.user_type() == MessageType::Voteprep) {
+          LOG(ERROR) << "bc voterep:";
+
+          VoteMessage ack_msg;
+          assert(ack_msg.ParseFromString(request.data()));
+          for (int i = 1; i <= 3; ++i) {
+            ack_msg.set_proposer_id(i);
+            auto new_req = std::make_unique<Request>(request);
+            ack_msg.SerializeToString(new_req->mutable_data());
+            LOG(ERROR) << "new request type:" << new_req->user_type();
+
+            consensus_->ConsensusCommit(nullptr, std::move(new_req));
+          }
+        }
+        LOG(ERROR) << "done";
+        return 0;
+      }));
+
+  EXPECT_CALL(*mock_transaction_manager_, ExecuteData)
+      .WillOnce(Invoke([&](const std::string& msg) {
+        LOG(ERROR) << "execute txn:" << msg;
+        EXPECT_EQ(msg, "transaction1");
+        return nullptr;
+      }));
+
+  EXPECT_CALL(replica_communicator_, SendMessage(_, 0))
+      .WillRepeatedly(
+          Invoke([&](const google::protobuf::Message& msg, int64_t) {
+            Request request = *dynamic_cast<const Request*>(&msg);
+            if (request.type() == Request::TYPE_RESPONSE) {
+              LOG(ERROR) << "get response";
+              commit_done.set_value(true);
+            }
+            return;
+          }));
+
+  AddTransaction("transaction1");
+
+  commit_done_future.get();
+}
+
+}  // namespace
+}  // namespace cassandra
+}  // namespace resdb
diff --git a/platform/consensus/ordering/zzy/framework/performance_manager.cpp b/platform/consensus/ordering/zzy/framework/performance_manager.cpp
new file mode 100644
index 00000000..9531ce7d
--- /dev/null
+++ b/platform/consensus/ordering/zzy/framework/performance_manager.cpp
@@ -0,0 +1,236 @@
+/*
+ * 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 "platform/consensus/ordering/zzy/framework/performance_manager.h"
+
+#include <glog/logging.h>
+
+#include "common/utils/utils.h"
+
+namespace resdb {
+namespace zzy {
+
+using comm::CollectorResultCode;
+
+int ZZYPerformanceManager::Broadcast(int type, const google::protobuf::Message& msg) {
+  Request request;
+  msg.SerializeToString(request.mutable_data());
+  request.set_type(Request::TYPE_CUSTOM_CONSENSUS);
+  request.set_user_type(type);
+  request.set_sender_id(config_.GetSelfInfo().id());
+
+  replica_communicator_->BroadCast(request);
+  return 0;
+}
+
+ZZYPerformanceManager::ZZYPerformanceManager(
+    const ResDBConfig& config, ReplicaCommunicator* replica_communicator,
+    SignatureVerifier* verifier)
+    : PerformanceManager(config, replica_communicator, verifier){
+  
+      total_replicas_ = config_.GetReplicaNum();
+      f_ = (total_replicas_ - 1) / 3;
+  start_seq_ = 1;
+  time_limit_ = 5000;
+  ready_thread_ = std::thread(&ZZYPerformanceManager::WaitComplete, this);
+}
+
+void ZZYPerformanceManager::AddPkg(int64_t local_id, std::unique_ptr<BatchUserResponse> resp) {
+      std::unique_lock<std::mutex> lk(n_mutex_);
+  if(done_.find(local_id) != done_.end() || local_id < start_seq_){
+    return;
+  }
+  done_[local_id] = GetCurrentTime();
+  std::unique_lock<std::mutex> rlk(resp_mutex_[local_id%1000]);
+  resp_[local_id%1000][local_id] = std::move(resp);
+  //LOG(ERROR)<<" add resp:"<<local_id;
+}
+
+void ZZYPerformanceManager::PkgDone(int local_id) {
+  if(local_id < start_seq_) {
+    return;
+  }
+  done_[local_id] = 0;
+}
+
+bool ZZYPerformanceManager::IsTimeout() {
+  if(done_.begin()->second == 0) {
+    return false;
+  }
+  return GetCurrentTime() - done_.begin()->second > time_limit_;
+}
+
+bool ZZYPerformanceManager::TimeoutLeft() {
+  return time_limit_ - GetCurrentTime() - done_.begin()->second > time_limit_;
+}
+
+
+
+bool ZZYPerformanceManager::Ready() {
+  if (done_.empty()) {
+    // LOG(ERROR) << "empty";
+  } else {
+    LOG(ERROR) << "done begin " <<done_.begin()->first << " start_seq_: " << start_seq_;
+  }
+  if(done_.empty() || done_.begin()->first != start_seq_){
+    return false;
+  }
+  if(done_.begin()->second == 0 || IsTimeout()){
+    return true;
+  }
+  return false;
+}
... 2114 lines suppressed ...