Unverified Commit 77cc66e6 authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #126 from skalenetwork/SKALE-2871-reduce-sgx-logs

Skale 2871 reduce sgx logs
parents 7fa76e24 9e446bdf
......@@ -53,7 +53,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
throw SGXException(NULL_DATABASE, "Null db");
}
spdlog::info("key to read from db: {}",_key );
spdlog::debug("key to read from db: {}",_key );
auto status = db->Get(readOptions, _key, &*result);
......
......@@ -29,6 +29,8 @@
#include <stdio.h>
#include "sgxwallet_common.h"
#include "sgxwallet.h"
#include "SGXException.h"
#include "LevelDB.h"
......@@ -50,27 +52,30 @@
#include "Log.h"
void setFullOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys) {
if (_printDebugInfo)
spdlog::set_level(spdlog::level::debug);
else if (_printTraceInfo) {
using namespace std;
void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _encryptKeys) {
CHECK_STATE(_logLevel <= 2)
if (_logLevel == L_TRACE) {
spdlog::set_level(spdlog::level::trace);
} else if (_printTraceInfo) {
} else if (_logLevel == L_DEBUG) {
spdlog::set_level(spdlog::level::debug);
} else {
spdlog::set_level(spdlog::level::info);
}
useHTTPS = _useHTTPS;
spdlog::info("useHTTPS set to " + std::to_string(_useHTTPS));
spdlog::info("useHTTPS set to " + to_string(_useHTTPS));
autoconfirm = _autoconfirm;
spdlog::info("autoconfirm set to " + std::to_string(autoconfirm));
spdlog::info("autoconfirm set to " + to_string(autoconfirm));
encryptKeys = _encryptKeys;
spdlog::info("encryptKeys set to " + std::to_string(encryptKeys));
spdlog::info("encryptKeys set to " + to_string(encryptKeys));
}
void setOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm) {
setFullOptions(_printDebugInfo,
_printTraceInfo, _useHTTPS, _autoconfirm, false);
void setOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm) {
setFullOptions(_logLevel, _useHTTPS, _autoconfirm, false);
}
bool isStringDec(const string &_str) {
......
......@@ -30,11 +30,9 @@
#define EXTERNC
#endif
EXTERNC void setFullOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm);
EXTERNC void setOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm);
#endif //SGXWALLET_SGXWALLETSERVER_H
......@@ -16,5 +16,5 @@ services:
max-size: "10m"
max-file: "4"
restart: unless-stopped
command: -s -y -d
command: -s -y
......@@ -90,7 +90,7 @@ void trustedEnclaveInit(uint32_t _logLevel) {
enclave_init();
LOG_DEBUG("SUCCESS");
LOG_INFO("Successfully inited enclave");
}
void free_function(void *ptr, size_t sz) {
......@@ -1034,8 +1034,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
int status = AES_decrypt(encryptedPrivateKey, enc_len, skey);
skey[enc_len - SGX_AESGCM_MAC_SIZE - SGX_AESGCM_IV_SIZE] = '\0';
LOG_INFO("ENCRYPTED SKEY");
LOG_INFO(skey);
LOG_TRACE("ENCRYPTED SKEY");
LOG_TRACE(skey);
if (status != 0) {
snprintf(errString, BUF_LEN, "AES_decrypt failed with status %d", status);
......@@ -1059,17 +1059,17 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
return;
}
LOG_INFO("SET STR SUCCESS");
LOG_TRACE("SET STR SUCCESS");
//Public key
point Pkey = point_init();
signature_extract_public_key(Pkey, privateKeyMpz, curve);
LOG_INFO("SIGNATURE EXTRACT PK SUCCESS");
LOG_TRACE("SIGNATURE EXTRACT PK SUCCESS");
point Pkey_test = point_init();
point_multiplication(Pkey_test, privateKeyMpz, curve->G, curve);
LOG_INFO("POINT MULTIPLICATION SUCCESS");
LOG_TRACE("POINT MULTIPLICATION SUCCESS");
if (!point_cmp(Pkey, Pkey_test)) {
snprintf(errString, BUF_LEN, "Points are not equal");
......@@ -1082,14 +1082,14 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
return;
}
LOG_INFO("POINTS CMP SUCCESS");
LOG_TRACE("POINTS CMP SUCCESS");
int len = mpz_sizeinbase(Pkey->x, ECDSA_SKEY_BASE) + 2;
char arr_x[len];
mpz_get_str(arr_x, ECDSA_SKEY_BASE, Pkey->x);
LOG_INFO("GET STR X SUCCESS");
LOG_INFO(arr_x);
LOG_TRACE("GET STR X SUCCESS");
LOG_TRACE(arr_x);
int n_zeroes = 64 - strlen(arr_x);
for (int i = 0; i < n_zeroes; i++) {
......@@ -1100,8 +1100,8 @@ void trustedGetPublicEcdsaKeyAES(int *errStatus, char *errString,
char arr_y[mpz_sizeinbase(Pkey->y, ECDSA_SKEY_BASE) + 2];
mpz_get_str(arr_y, ECDSA_SKEY_BASE, Pkey->y);
LOG_INFO("GET STR Y SUCCESS");
LOG_INFO(arr_y);
LOG_TRACE("GET STR Y SUCCESS");
LOG_TRACE(arr_y);
n_zeroes = 64 - strlen(arr_y);
for (int i = 0; i < n_zeroes; i++) {
pub_key_y[i] = '0';
......
......@@ -56,7 +56,7 @@ void SGXWallet::printUsage() {
cerr << "-T Generate test keys \n";
}
enum log_level {L_TRACE = 0, L_DEBUG = 1, L_INFO = 2,L_WARNING = 3, L_ERROR = 4 };
void SGXWallet::serializeKeys(const vector<string>& _ecdsaKeyNames, const vector<string>& _blsKeyNames, const string& _fileName) {
Json::Value top(Json::objectValue);
......@@ -149,14 +149,26 @@ int main(int argc, char *argv[]) {
}
}
setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
uint64_t logLevel = L_INFO;
if (printDebugInfoOption) {
logLevel = L_DEBUG;
}
if (printTraceInfoOption) {
logLevel = L_TRACE;
}
setFullOptions(logLevel, useHTTPSOption, autoconfirmOption, encryptKeysOption);
uint32_t enclaveLogLevel = L_INFO;
if (printDebugInfoOption) {
enclaveLogLevel = L_DEBUG;
}
if (printTraceInfoOption) {
enclaveLogLevel = L_TRACE;
} else if (printDebugInfoOption) {
enclaveLogLevel = L_DEBUG;
}
initAll(enclaveLogLevel, checkClientCertOption, autoSignClientCertOption);
......
......@@ -51,4 +51,6 @@ extern sgx_status_t status;
#define ENCLAVE_NAME "secure_enclave.signed.so"
enum log_level {L_TRACE = 0, L_DEBUG = 1, L_INFO = 2,L_WARNING = 3, L_ERROR = 4 };
#endif //SGXWALLET_SGXWALLET_H
......@@ -70,8 +70,8 @@ class TestFixture {
public:
TestFixture() {
TestUtils::resetDB();
setOptions(false, false, false, true);
initAll(2, false, true);
setOptions(L_INFO, false, true);
initAll(L_INFO, false, true);
}
~TestFixture() {
......@@ -83,7 +83,7 @@ class TestFixtureHTTPS {
public:
TestFixtureHTTPS() {
TestUtils::resetDB();
setOptions(false, false, true, true);
setOptions(L_INFO, true, true);
initAll(0, false, true);
}
......
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