Unverified Commit efb304a3 authored by Oleh Nikolaiev's avatar Oleh Nikolaiev Committed by GitHub

Merge branch 'develop' into enhancement/update-healthcheck-documentation

parents 636454cf ec396cb7
......@@ -17,10 +17,10 @@ jobs:
- name: submodule update
run: git submodule update --init --recursive
- name: build and deploy docker image
if: |
if: |
contains(github.ref, 'develop') || contains(github.ref, 'beta') ||
contains(github.ref, 'master') || contains(github.ref, 'stable') ||
contains(github.ref, 'SECURE_ENCLAVE_CHANGES')
contains(github.ref, 'SECURE_ENCLAVE_CHANGES')
run : |
export BRANCH=${GITHUB_REF##*/}
echo "Branch $BRANCH"
......
......@@ -19,5 +19,5 @@ RUN rm /opt/intel/sgxsdk/lib64/*_sim.so
RUN rm /usr/src/sdk/secure_enclave/secure_enclave*.so
RUN cd /usr/src/sdk/secure_enclave && \
curl --output secure_enclave.signed.so \
https://raw.githubusercontent.com/skalenetwork/signed_sgx_enclaves/master/secure_enclave_signed.so.1
https://raw.githubusercontent.com/skalenetwork/signed_sgx_enclaves/master/secure_enclave_signed.so.3
ENTRYPOINT ["/usr/src/sdk/start.sh"]
......@@ -81,9 +81,19 @@ static uint64_t __COUNT__ = 0; \
__COUNT__++; \
if (__COUNT__ % 1000 == 0) { \
spdlog::info(string(__FUNCTION__) + " processed " + to_string(__COUNT__) + " requests"); \
struct sysinfo memInfo; \
sysinfo (&memInfo); \
long long totalPhysMem = memInfo.totalram; \
/*Multiply in next statement to avoid int overflow on right hand side...*/ \
totalPhysMem *= memInfo.mem_unit; \
int usedByCurrentProcess = getValue(); \
if ( 0.5 * totalPhysMem < usedByCurrentProcess ) { \
exit(-103); \
} \
}
// if uknown error, the error is 10000 + line number
......
# sgxwallet: SKALE SGX-based hardware crypto wallet
# sgxwallet: SKALE SGX-based hardware crypto wallet
<!-- SPDX-License-Identifier: (AGPL-3.0-only OR CC-BY-4.0) -->
......
......@@ -31,6 +31,11 @@ using namespace std;
#include <iostream>
#include <map>
#include <memory>
#include <sys/types.h>
#include <sys/sysinfo.h>
#include <string.h>
#include <vector>
#include <boost/throw_exception.hpp>
......@@ -68,6 +73,32 @@ inline void print_stack(int _line) {
backtrace_symbols_fd(array, size, STDERR_FILENO);
}
inline int parseLine(char* line) {
// This assumes that a digit will be found and the line ends in " Kb".
int i = strlen(line);
const char* p = line;
while (*p <'0' || *p > '9') p++;
line[i-3] = '\0';
i = atoi(p);
return i;
}
inline int getValue() { //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];
while (fgets(line, 128, file) != NULL){
if (strncmp(line, "VmRSS:", 6) == 0){
result = parseLine(line);
break;
}
}
fclose(file);
return result;
}
#define CHECK_STATE(_EXPRESSION_) \
if (!(_EXPRESSION_)) { \
......@@ -133,23 +164,5 @@ extern uint64_t initTime;
#define WRITE_LOCK(__X__) std::unique_lock<std::shared_timed_mutex> __LOCK__(__X__);
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
// max of 200 threads can call enclave at a time
extern boost::interprocess::interprocess_semaphore enclaveSemaphore;
class semaphore_guard {
boost::interprocess::interprocess_semaphore &sem;
public:
semaphore_guard(boost::interprocess::interprocess_semaphore &_semaphore) : sem(_semaphore) {
sem.wait();
}
~semaphore_guard() {
sem.post();
}
};
#endif //SGXWALLET_COMMON_H
......@@ -90,12 +90,11 @@ make
make install
cd ..
#tar -xzf ./pre_downloaded/libjson-rpc-cpp.tar.gz
git clone https://github.com/skalenetwork/libjson-rpc-cpp.git --recursive
cd libjson-rpc-cpp
git checkout hotfix/comment-ssl-certificates
git checkout develop
git pull
rn -rf build || true
rm -rf build || true
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=$TOP_CMAKE_BUILD_TYPE \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment