From 4370edd546e277a3a6d5ba7fbc9730ea518c06b3 Mon Sep 17 00:00:00 2001 From: Chalith Desaman Date: Thu, 3 Aug 2023 17:01:24 +0530 Subject: [PATCH] Support implementation and version updates for contract execution timeout (#274) --- .gitignore | 3 ++- dependencies/hp.cfg | 5 +++-- mb-xrpl/lib/appenv.js | 2 +- src/hp_manager.cpp | 6 +++++- src/msg/json/msg_json.cpp | 3 +++ src/msg/msg_common.hpp | 2 ++ src/version.hpp | 2 +- test/docker/Dockerfile.ubt.20.04 | 2 +- test/docker/Dockerfile.ubt.20.04-njs | 2 +- test/docker/build.sh | 4 ++-- 10 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 3e5706d..3819cee 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ build **/Makefile **/CMakeCache.txt **/cmake_install.cmake -**/CMakeFiles \ No newline at end of file +**/CMakeFiles +.vscode \ No newline at end of file diff --git a/dependencies/hp.cfg b/dependencies/hp.cfg index fc67c5a..a711a7f 100644 --- a/dependencies/hp.cfg +++ b/dependencies/hp.cfg @@ -1,5 +1,5 @@ { - "hp_version": "0.6.0", + "hp_version": "0.6.3", "node": { "public_key": "", "private_key": "", @@ -40,7 +40,8 @@ "npl_output_bytes": 0, "proc_cpu_seconds": 0, "proc_mem_bytes": 0, - "proc_ofd_count": 0 + "proc_ofd_count": 0, + "exec_timeout": 300000 } }, "mesh": { diff --git a/mb-xrpl/lib/appenv.js b/mb-xrpl/lib/appenv.js index c2228d6..cd0188b 100644 --- a/mb-xrpl/lib/appenv.js +++ b/mb-xrpl/lib/appenv.js @@ -28,7 +28,7 @@ appenv = { ORPHAN_PRUNE_SCHEDULER_INTERVAL_HOURS: 4, SASHIMONO_SCHEDULER_INTERVAL_SECONDS: 2, SASHI_CLI_PATH: appenv.IS_DEV_MODE ? "../build/sashi" : "/usr/bin/sashi", - MB_VERSION: '0.6.4', + MB_VERSION: '0.6.5', TOS_HASH: '757A0237B44D8B2BBB04AE2BAD5813858E0AECD2F0B217075E27E0630BA74314' // This is the sha256 hash of TOS text. } Object.freeze(appenv); diff --git a/src/hp_manager.cpp b/src/hp_manager.cpp index 380bdc9..5a7403c 100644 --- a/src/hp_manager.cpp +++ b/src/hp_manager.cpp @@ -488,7 +488,8 @@ namespace hp vacant_ports.push_back(info.assigned_ports); // Remove user after destroying. - if (uninstall_user(info.username, info.assigned_ports, container_name) == -1) { + if (uninstall_user(info.username, info.assigned_ports, container_name) == -1) + { error_msg = USER_UNINSTALL_ERROR; return -1; } @@ -737,6 +738,9 @@ namespace hp if (config.contract.round_limits.proc_ofd_count.has_value()) d["contract"]["round_limits"]["proc_ofd_count"] = config.contract.round_limits.proc_ofd_count.value(); + if (config.contract.round_limits.exec_timeout.has_value()) + d["contract"]["round_limits"]["exec_timeout"] = config.contract.round_limits.exec_timeout.value(); + if (config.contract.log.max_mbytes_per_file.has_value()) d["contract"]["log"]["max_mbytes_per_file"] = config.contract.log.max_mbytes_per_file.value(); diff --git a/src/msg/json/msg_json.cpp b/src/msg/json/msg_json.cpp index ecd87a4..0f21c8a 100644 --- a/src/msg/json/msg_json.cpp +++ b/src/msg/json/msg_json.cpp @@ -365,6 +365,9 @@ namespace msg::json if (round_limits.contains(msg::FLD_PROC_OFD_COUNT)) msg.config.contract.round_limits.proc_ofd_count = round_limits[msg::FLD_PROC_OFD_COUNT].as(); + + if (round_limits.contains(msg::FLD_EXEC_TIMEOUT)) + msg.config.contract.round_limits.exec_timeout = round_limits[msg::FLD_EXEC_TIMEOUT].as(); } if (contract.contains(msg::FLD_LOG)) diff --git a/src/msg/msg_common.hpp b/src/msg/msg_common.hpp index 672afdc..02948aa 100644 --- a/src/msg/msg_common.hpp +++ b/src/msg/msg_common.hpp @@ -56,6 +56,7 @@ namespace msg std::optional proc_cpu_seconds; std::optional proc_mem_bytes; std::optional proc_ofd_count; + std::optional exec_timeout; }; struct contract_config @@ -190,6 +191,7 @@ namespace msg constexpr const char *FLD_PROC_CPU_SECS = "proc_cpu_seconds"; constexpr const char *FLD_PROC_MEM_BYTES = "proc_mem_bytes"; constexpr const char *FLD_PROC_OFD_COUNT = "proc_ofd_count"; + constexpr const char *FLD_EXEC_TIMEOUT = "exec_timeout"; constexpr const char *FLD_LOG = "log"; constexpr const char *FLD_LOG_LEVEL = "log_level"; constexpr const char *FLD_ENABLE = "enable"; diff --git a/src/version.hpp b/src/version.hpp index 468c3cd..72c9775 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -6,7 +6,7 @@ namespace version { // Sashimono agent version. Written to new configs. - constexpr const char *AGENT_VERSION = "0.6.4"; + constexpr const char *AGENT_VERSION = "0.6.5"; // Minimum compatible config version (this will be used to validate configs). constexpr const char *MIN_CONFIG_VERSION = "0.5.0"; diff --git a/test/docker/Dockerfile.ubt.20.04 b/test/docker/Dockerfile.ubt.20.04 index 2d7b9ea..9c6f875 100644 --- a/test/docker/Dockerfile.ubt.20.04 +++ b/test/docker/Dockerfile.ubt.20.04 @@ -1,4 +1,4 @@ -FROM evernodedev/hotpocket:0.6.2-ubt.20.04 +FROM evernodedev/hotpocket:0.6.3-ubt.20.04 RUN apt-get update \ && apt-get install --no-install-recommends -y unzip jq \ diff --git a/test/docker/Dockerfile.ubt.20.04-njs b/test/docker/Dockerfile.ubt.20.04-njs index b0a0ff7..8ec3adf 100644 --- a/test/docker/Dockerfile.ubt.20.04-njs +++ b/test/docker/Dockerfile.ubt.20.04-njs @@ -1,4 +1,4 @@ -FROM evernodedev/hotpocket:0.6.2-ubt.20.04-njs.20 +FROM evernodedev/hotpocket:0.6.3-ubt.20.04-njs.20 RUN apt-get update \ && apt-get install --no-install-recommends -y unzip jq \ diff --git a/test/docker/build.sh b/test/docker/build.sh index 19a246e..fe58359 100755 --- a/test/docker/build.sh +++ b/test/docker/build.sh @@ -2,5 +2,5 @@ img=evernodedev/sashimono -docker build -t $img:hp.latest-ubt.20.04 -t $img:hp.0.6.2-ubt.20.04 -f ./Dockerfile.ubt.20.04 . -docker build -t $img:hp.latest-ubt.20.04-njs.20 -t $img:hp.0.6.2-ubt.20.04-njs.20 -f ./Dockerfile.ubt.20.04-njs . \ No newline at end of file +docker build -t $img:hp.latest-ubt.20.04 -t $img:hp.0.6.3-ubt.20.04 -f ./Dockerfile.ubt.20.04 . +docker build -t $img:hp.latest-ubt.20.04-njs.20 -t $img:hp.0.6.3-ubt.20.04-njs.20 -f ./Dockerfile.ubt.20.04-njs .