From 2aa300b463a0446a973250f74076a1a3483cf1d9 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 27 Feb 2023 01:55:55 +0000 Subject: [PATCH] fix build kvserver --- README.md | 4 ++++ WORKSPACE | 4 ++-- example/start_kv_server.sh | 2 +- kv_server/BUILD | 30 ++++++++++++++---------------- kv_server/kv_server_executor.cpp | 3 --- kv_server/py_verificator.cpp | 1 + 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 9208ffc22..1f4312d15 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,11 @@ You will see the following result if successful: client getvalues value = [test_value] +## Enable SDK +If you want to enable sdk verification, add a flag to the command + + ./example/start_kv_server.sh --define enable_sdk=True ## FAQ diff --git a/WORKSPACE b/WORKSPACE index f812dea0e..f2fe7132f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -285,8 +285,8 @@ http_archive( http_archive( name = "pybind11", build_file = "@pybind11_bazel//:pybind11.BUILD", - strip_prefix = "pybind11-2.10.3", - urls = ["https://github.com/pybind/pybind11/archive/v2.10.3.tar.gz"], + strip_prefix = "pybind11-2.6.2", + urls = ["https://github.com/pybind/pybind11/archive/v2.6.2.tar.gz"], ) load("@pybind11_bazel//:python_configure.bzl", "python_configure") diff --git a/example/start_kv_server.sh b/example/start_kv_server.sh index 786fb578e..72482f70d 100755 --- a/example/start_kv_server.sh +++ b/example/start_kv_server.sh @@ -4,7 +4,7 @@ SERVER_PATH=./bazel-bin/kv_server/kv_server SERVER_CONFIG=example/kv_config.config WORK_PATH=$PWD -bazel build kv_server:kv_server --define enable_sdk=True +bazel build kv_server:kv_server $@ nohup $SERVER_PATH $SERVER_CONFIG $WORK_PATH/cert/node1.key.pri $WORK_PATH/cert/cert_1.cert > server0.log & nohup $SERVER_PATH $SERVER_CONFIG $WORK_PATH/cert/node2.key.pri $WORK_PATH/cert/cert_2.cert > server1.log & nohup $SERVER_PATH $SERVER_CONFIG $WORK_PATH/cert/node3.key.pri $WORK_PATH/cert/cert_3.cert > server2.log & diff --git a/kv_server/BUILD b/kv_server/BUILD index 3afc28733..a51d49850 100644 --- a/kv_server/BUILD +++ b/kv_server/BUILD @@ -1,20 +1,17 @@ package(default_visibility = ["//visibility:public"]) -load( - "@bazel_skylib//rules:common_settings.bzl", - "bool_flag", -) +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") bool_flag( name = "enable_sdk", build_setting_default = False, - # This visibility is working, however the config_setting is in same package. - visibility = ["//visibility:private"] + visibility = ["//visibility:private"], ) config_setting( - name = "custom", - values = {"define": "enable_sdk=True"}, + name = "custom", + values = {"define": "enable_sdk=True"}, + visibility = ["//visibility:private"], ) cc_library( @@ -23,14 +20,15 @@ cc_library( hdrs = ["py_verificator.h"], deps = [ "//common:comm", - "@pybind11" , - "@pybind11//:pybind11_embed", + "@pybind11", + "@pybind11//:pybind11_embed", ], ) cc_test( name = "py_verificator_test", srcs = ["py_verificator_test.cpp"], + tags = ["manual"], deps = [ ":py_verificator", "//common/test:test_main", @@ -41,6 +39,10 @@ cc_library( name = "kv_server_executor", srcs = ["kv_server_executor.cpp"], hdrs = ["kv_server_executor.h"], + copts = select({ + ":custom": ["-DENABLED_SDK"], + "//conditions:default": [], + }), deps = [ "//common:comm", "//config:resdb_config_utils", @@ -49,13 +51,9 @@ cc_library( "//execution:transaction_executor_impl", "//proto:kv_server_cc_proto", ] + select({ - ":custom":[":py_verificator"], - "//conditions:default": [], + ":custom": [":py_verificator"], + "//conditions:default": [], }), - copts = select({ - ":custom":["-DENABLED_SDK"], - "//conditions:default": [], - }) ) cc_test( diff --git a/kv_server/kv_server_executor.cpp b/kv_server/kv_server_executor.cpp index 16bc29880..b6f5f38d9 100644 --- a/kv_server/kv_server_executor.cpp +++ b/kv_server/kv_server_executor.cpp @@ -39,9 +39,7 @@ KVServerExecutor::KVServerExecutor(const ResConfigData& config_data, equip_leveldb_ = config_data.leveldb_info().enable_leveldb(); #ifdef ENABLED_SDK - LOG(ERROR)<<"here?"; require_txn_validation_ = config_data.require_txn_validation(); - require_txn_validation_ = true; if (require_txn_validation_) { py_verificator_ = std::make_unique(); } @@ -80,7 +78,6 @@ std::unique_ptr KVServerExecutor::ExecuteData( void KVServerExecutor::Set(const std::string& key, const std::string& value) { #ifdef ENABLED_SDK - LOG(ERROR)<<"here?"; if (require_txn_validation_) { bool is_valid = py_verificator_->Validate(value); if (!is_valid) { diff --git a/kv_server/py_verificator.cpp b/kv_server/py_verificator.cpp index 19136deb8..5c4305a31 100644 --- a/kv_server/py_verificator.cpp +++ b/kv_server/py_verificator.cpp @@ -42,6 +42,7 @@ PYVerificator::PYVerificator() { // Validate transactions committed by the Python SDK bool PYVerificator::Validate(const std::string& transaction) { + LOG(ERROR) << "validate"; auto locals = py::dict("transaction"_a = transaction); py::exec(R"(