Skip to content

Commit

Permalink
Partial build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSuprunenko committed May 23, 2019
1 parent 30f6534 commit 479d652
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 72 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ ExternalProject_Add(
STAMP_DIR ${PROJECT_BINARY_DIR}/STAMP/cryptonode
TMP_DIR ${PROJECT_BINARY_DIR}/TMP/cryptonode
INSTALL_DIR ${PROJECT_BINARY_DIR}/BUILD
CMAKE_ARGS ${ExternalProjectCMakeArgs} -DSTATIC=ON -DARCH=x86-64 -DHAVE_EVP_MD_CTX_NEW=YES -DENABLE_SYSLOG=${ENABLE_SYSLOG} -DCMAKE_ROOT_SOURCE_DIR="\"${CMAKE_ROOT_SOURCE_DIR}\""
# CMAKE_ARGS ${ExternalProjectCMakeArgs} -DSTATIC=ON -DARCH=x86-64 -DHAVE_EVP_MD_CTX_NEW=YES -DENABLE_SYSLOG=${ENABLE_SYSLOG} -DCMAKE_ROOT_SOURCE_DIR="\"${CMAKE_ROOT_SOURCE_DIR}\""
CMAKE_ARGS ${ExternalProjectCMakeArgs} -DARCH=x86-64 -DHAVE_EVP_MD_CTX_NEW=YES -DENABLE_SYSLOG=${ENABLE_SYSLOG} -DCMAKE_ROOT_SOURCE_DIR="\"${CMAKE_ROOT_SOURCE_DIR}\""
)

set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -174,7 +175,7 @@ endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
# cryptonode dependencies
# TODO: modify cryptonode CMakeLists.txt so it installs all required headers/libs
include_directories(${CRYPTONODE_INCLUDE_DIRS} "${CMAKE_BINARY_DIR}/version")
include_directories("${CMAKE_BINARY_DIR}/version" ${CRYPTONODE_INCLUDE_DIRS})
link_directories(${CRYPTONODE_LIB_DIRS})

### graftlet_lib
Expand Down
8 changes: 4 additions & 4 deletions graftlets/WalletAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include "rta/supernode.h"
#include "lib/graft/graft_exception.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_protocol/blobdatatype.h"
#include "file_io_utils.h"
#include "cryptonote_basic/blobdatatype.h"
#include "string_tools.h"

#include<cassert>

Expand Down Expand Up @@ -70,14 +70,14 @@ graft::Status WalletAddress::getWalletAddressHandler(const graft::Router::vars_t

if (ctx.local.getLastStatus() != graft::Status::None) {
graft::supernode::request::GetWalletAddressErrorResponse err;
err.error = string("internal error: wrong status: " + to_string((int)ctx.local.getLastStatus()));
err.error = std::string("internal error: wrong status: " + std::to_string((int)ctx.local.getLastStatus()));
return graft::Status::Error;
}

graft::SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, graft::SupernodePtr());
if (!supernode) {
graft::supernode::request::GetWalletAddressErrorResponse err;
err.error = string("supernode was not setup correctly");
err.error = std::string("supernode was not setup correctly");
return graft::Status::Error;
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/graft/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "lib/graft/sys_info.h"
#include "lib/graft/graft_exception.h"

#include <boost/uuid/uuid_io.hpp>

#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "supernode.connection"

Expand Down
4 changes: 3 additions & 1 deletion src/lib/graft/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "lib/graft/sys_info.h"
#include "lib/graft/common/utils.h"

#include <boost/uuid/uuid_io.hpp>

#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "supernode.task"

Expand Down Expand Up @@ -722,7 +724,7 @@ void TaskManager::postponeTask(BaseTaskPtr bt)
assert(res.second.getInputPtr());
bt->getParams().input = *res.second.getInputPtr();
m_readyToResume.push_back(bt);
LOG_PRINT_RQS_BT(2,bt,"for the task with uuid '" << uuid << "' an answer found; it will be resumed.");
LOG_PRINT_RQS_BT(2,bt,"for the task with uuid '" << boost::uuids::to_string(uuid) << "' an answer found; it will be resumed.");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/rta/fullsupernodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <utils/sample_generator.h>
#include <wallet/api/wallet_manager.h>
#include <cryptonote_basic/cryptonote_basic_impl.h>
#include <cryptonote_protocol/blobdatatype.h>
#include <cryptonote_basic/blobdatatype.h>
#include <misc_log_ex.h>

#include <boost/multiprecision/cpp_int.hpp>
Expand Down
6 changes: 3 additions & 3 deletions src/rta/supernode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,17 @@ bool Supernode::saveKeys(const string &filename, bool force)
return true;
}

const public_key &Supernode::idKey() const
const crypto::public_key &Supernode::idKey() const
{
return m_id_key;
}

const secret_key &Supernode::secretKey() const
const crypto::secret_key &Supernode::secretKey() const
{
return m_secret_key;
}

string Supernode::idKeyAsString() const
std::string Supernode::idKeyAsString() const
{
return epee::string_tools::pod_to_hex(m_id_key);
}
Expand Down
2 changes: 1 addition & 1 deletion src/supernode/requests/auth_sample_disqualificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class AuthSDisqualificatorImpl : public AuthSDisqualificator, public BBLDisquali
//create wallet
std::string addr = ctx.global["cryptonode_rpc_address"];
bool testnet = ctx.global["testnet"];
tools::wallet2 wallet(testnet);
tools::wallet2 wallet(testnet? cryptonote::TESTNET : cryptonote::MAINNET );
wallet.init(addr);
wallet.set_refresh_from_block_height(coll.di.item.block_height);
wallet.set_seed_language("English");
Expand Down
46 changes: 23 additions & 23 deletions src/supernode/requests/authorize_rta_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void putRtaSignaturesToTx(cryptonote::transaction &tx, const std::vector<Superno
bool signAuthResponse(AuthorizeRtaTxResponse &arg, const SupernodePtr &supernode)
{
crypto::signature sign;
supernode->signMessage(arg.tx_id + ":" + to_string(arg.result), sign);
supernode->signMessage(arg.tx_id + ":" + std::to_string(arg.result), sign);
arg.signature.result_signature = epee::string_tools::pod_to_hex(sign);
crypto::hash tx_id;
epee::string_tools::hex_to_pod(arg.tx_id, tx_id);
Expand Down Expand Up @@ -177,7 +177,7 @@ bool validateAuthResponse(const AuthorizeRtaTxResponse &arg, const SupernodePtr



std::string msg = arg.tx_id + ":" + to_string(arg.result);
std::string msg = arg.tx_id + ":" + std::to_string(arg.result);
crypto::public_key id_key;
epee::string_tools::hex_to_pod(arg.signature.id_key, id_key);
bool r1 = supernode->verifySignature(msg, id_key, sign_result);
Expand All @@ -195,7 +195,7 @@ Status storeRequestAndReplyOk(const Router::vars_t& vars, const graft::Input& in
// here request parsed for the logging purposes. normally we don't need to parse it here;
MulticastRequestJsonRpc req;
if (!input.get(req)) { // can't parse request
return errorCustomError(string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output);
return errorCustomError(std::string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output);
}

SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr());
Expand Down Expand Up @@ -240,12 +240,12 @@ Status handleTxAuthRequest(const Router::vars_t& vars, const graft::Input& /*inp
}

graft::Input input;
string body = ctx.local["request"];
std::string body = ctx.local["request"];
input.body = body;

MulticastRequestJsonRpc req;
if (!input.get(req)) { // can't parse request
return errorCustomError(string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output);
return errorCustomError(std::string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output);
}

SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr());
Expand Down Expand Up @@ -273,7 +273,7 @@ Status handleTxAuthRequest(const Router::vars_t& vars, const graft::Input& /*inp
return errorInvalidTransaction(authReq.tx_hex, output);
}

string tx_id_str = epee::string_tools::pod_to_hex(tx_hash);
std::string tx_id_str = epee::string_tools::pod_to_hex(tx_hash);
MDEBUG("incoming auth req for payment: " << authReq.payment_id
<< ", tx_id: " << tx_id_str);
// check if we already processed this tx
Expand Down Expand Up @@ -350,7 +350,7 @@ Status handleCryptonodeMulticastStatus(const Router::vars_t& vars, const graft::
if (!input.get(resp) || resp.error.code != 0 || resp.result.status != STATUS_OK) {
return errorInternalError("Error multicasting request", output);
}
string payment_id_local = ctx.local["payment_id"];
std::string payment_id_local = ctx.local["payment_id"];
MDEBUG("tx auth response multicast ask received for payment: " << payment_id_local);

AuthorizeRtaTxRequestJsonRpcResponse out;
Expand Down Expand Up @@ -379,7 +379,7 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I

if (!input.get(req)) { // can't parse request
LOG_ERROR("failed to parse request: " + input.data());
return errorCustomError(string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output);
return errorCustomError(std::string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output);
}

// TODO: check if our address is listed in "receiver_addresses"
Expand All @@ -403,13 +403,13 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I
}


string ctx_payment_id_key = rtaAuthResp.tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID;
std::string ctx_payment_id_key = rtaAuthResp.tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID;

if (!ctx.global.hasKey(ctx_payment_id_key)) {
LOG_ERROR("no payment_id for tx: " << rtaAuthResp.tx_id);
return errorCustomError(string("unknown tx: ") + rtaAuthResp.tx_id, ERROR_INTERNAL_ERROR, output);
return errorCustomError(std::string("unknown tx: ") + rtaAuthResp.tx_id, ERROR_INTERNAL_ERROR, output);
}
string payment_id = ctx.global.get(ctx_payment_id_key, std::string());
std::string payment_id = ctx.global.get(ctx_payment_id_key, std::string());
MDEBUG("incoming tx auth response payment: " << payment_id
<< ", tx_id: " << rtaAuthResp.tx_id
<< ", from: " << rtaAuthResp.signature.id_key
Expand All @@ -421,22 +421,22 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I
// validate signature
bool signOk = validateAuthResponse(rtaAuthResp, supernode);
if (!signOk) {
string msg = "failed to validate signature for rta auth response";
std::string msg = "failed to validate signature for rta auth response";
LOG_ERROR(msg);
return errorCustomError(msg,
ERROR_RTA_SIGNATURE_FAILED,
output);
}
// stop handling it if we already processed response
RtaAuthResult authResult;
string ctx_tx_to_auth_resp = rtaAuthResp.tx_id + CONTEXT_KEY_AUTH_RESULT_BY_TXID;
std::string ctx_tx_to_auth_resp = rtaAuthResp.tx_id + CONTEXT_KEY_AUTH_RESULT_BY_TXID;
if (ctx.global.hasKey(ctx_tx_to_auth_resp)) {
authResult = ctx.global.get(ctx_tx_to_auth_resp, authResult);
}

if (authResult.alreadyApproved(rtaAuthResp.signature.id_key)
|| authResult.alreadyRejected(rtaAuthResp.signature.id_key)) {
return errorCustomError(string("supernode: ") + rtaAuthResp.signature.id_key + " already processed",
return errorCustomError(std::string("supernode: ") + rtaAuthResp.signature.id_key + " already processed",
ERROR_ADDRESS_INVALID, output);
}

Expand All @@ -452,7 +452,7 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I
// store result in context
ctx.global.set(ctx_tx_to_auth_resp, authResult, RTA_TX_TTL);
if (!ctx.global.hasKey(rtaAuthResp.tx_id + CONTEXT_KEY_AMOUNT_BY_TX_ID)) {
string msg = string("no amount found for tx id: ") + rtaAuthResp.tx_id;
std::string msg = std::string("no amount found for tx id: ") + rtaAuthResp.tx_id;
LOG_ERROR(msg);
return errorCustomError(msg, ERROR_INTERNAL_ERROR, output);
}
Expand All @@ -468,7 +468,7 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I


if (!ctx.global.hasKey(rtaAuthResp.tx_id + CONTEXT_KEY_TX_BY_TXID)) {
string msg = string("rta auth response processed but no tx found for tx id: ") + rtaAuthResp.tx_id;
std::string msg = std::string("rta auth response processed but no tx found for tx id: ") + rtaAuthResp.tx_id;
LOG_ERROR(msg);
return errorCustomError(msg, ERROR_INTERNAL_ERROR, output);
}
Expand Down Expand Up @@ -528,11 +528,11 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I

} catch (const std::exception &e) {
LOG_ERROR("std::exception catched: " << e.what());
return errorInternalError(string("exception in cryptonode/authorize_rta_tx_response handler: ") + e.what(),
return errorInternalError(std::string("exception in cryptonode/authorize_rta_tx_response handler: ") + e.what(),
output);
} catch (...) {
LOG_ERROR("unhandled exception");
return errorInternalError(string("unknown exception in cryptonode/authorize_rta_tx_response handler"),
return errorInternalError(std::string("unknown exception in cryptonode/authorize_rta_tx_response handler"),
output);
}
}
Expand All @@ -544,20 +544,20 @@ Status handleCryptonodeTxPushResponse(const Router::vars_t& vars, const graft::I
{

MDEBUG(__FUNCTION__ << " begin for task: " << boost::uuids::to_string(ctx.getId()));
string payment_id_local = ctx.local["payment_id"];
std::string payment_id_local = ctx.local["payment_id"];
MDEBUG("processing sendrawtransaction reply for payment: " << payment_id_local);

SendRawTxResponse resp;
// check if we have tx_id in local context
string tx_id = ctx.local[CONTEXT_TX_ID];
std::string tx_id = ctx.local[CONTEXT_TX_ID];

if (tx_id.empty()) {
LOG_ERROR("internal erorr, tx_id key not found in local context");
abort();
}

// obtain payment id for given tx_id
string payment_id = ctx.global.get(tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID, std::string());
std::string payment_id = ctx.global.get(tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID, std::string());
if (payment_id.empty()) {
LOG_ERROR("Internal error, payment id not found for tx id: " << tx_id);
}
Expand Down Expand Up @@ -611,7 +611,7 @@ Status handleStatusBroadcastResponse(const Router::vars_t& vars, const graft::In
{
// TODO: check if cryptonode broadcasted status
MDEBUG(__FUNCTION__ << " begin");
string payment_id_local = ctx.local["payment_id"];
std::string payment_id_local = ctx.local["payment_id"];
MDEBUG("received status broadcasting result for payment: " << payment_id_local);
BroadcastResponseFromCryptonodeJsonRpc in;
JsonRpcErrorResponse error;
Expand Down Expand Up @@ -654,7 +654,7 @@ Status authorizeRtaTxRequestHandler(const Router::vars_t& vars, const graft::Inp
MDEBUG("cyptonode reply, payload: " << input.data());
return handleCryptonodeMulticastStatus(vars, input, ctx, output);
default: // internal error
return errorInternalError(string("authorize_rta_tx_request: unhandled state: ") + to_string(int(state)),
return errorInternalError(std::string("authorize_rta_tx_request: unhandled state: ") + std::to_string(int(state)),
output);
};
} catch (const std::exception &e) {
Expand Down
2 changes: 1 addition & 1 deletion src/supernode/requests/blockchain_based_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ class BBLDisqualificator : public BBLDisqualificatorBase
//create wallet
std::string addr = ctx.global["cryptonode_rpc_address"];
bool testnet = ctx.global["testnet"];
tools::wallet2 wallet(testnet);
tools::wallet2 wallet(testnet? cryptonote::TESTNET : cryptonote::MAINNET);
wallet.init(addr);
wallet.set_refresh_from_block_height(m_block_height);
wallet.set_seed_language("English");
Expand Down
2 changes: 1 addition & 1 deletion src/supernode/requests/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "rta/fullsupernodelist.h"

#include <misc_log_ex.h>
#include <cryptonote_protocol/blobdatatype.h>
#include <cryptonote_basic/blobdatatype.h>
#include <cryptonote_basic/cryptonote_format_utils.h>

#include <string>
Expand Down
8 changes: 4 additions & 4 deletions src/supernode/requests/pay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "rta/fullsupernodelist.h"

#include <misc_log_ex.h>
#include <cryptonote_protocol/blobdatatype.h>
#include <cryptonote_basic/blobdatatype.h>
#include <cryptonote_basic/cryptonote_format_utils.h>

#undef MONERO_DEFAULT_LOG_CATEGORY
Expand Down Expand Up @@ -127,7 +127,7 @@ Status handleClientPayRequest(const Router::vars_t& vars, const graft::Input& in
return errorBuildAuthSample(output);
}

string tx_hex;
std::string tx_hex;
if (in.Transactions.empty()) {
if (in.Account.empty()) {
return errorInvalidTransaction("tx empty", output);
Expand Down Expand Up @@ -198,7 +198,7 @@ Status handleWaitingTxReply(const Router::vars_t& vars, const graft::Input& inpu
PayRequest payData = ctx.local[scPayClientHandlerKey];

// TODO: !implement tx vector in every interface!
string tx_hex = res.Transactions[0];
std::string tx_hex = res.Transactions[0];

SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr());
FullSupernodeListPtr fsl = ctx.global.get(CONTEXT_KEY_FULLSUPERNODELIST, FullSupernodeListPtr());
Expand Down Expand Up @@ -273,7 +273,7 @@ Status handleStatusBroadcastReply(const Router::vars_t& vars, const graft::Input
}

// prepare reply to the client
string payment_id = ctx.local["payment_id"];
std::string payment_id = ctx.local["payment_id"];
MDEBUG("status broadcast ask received for payment: " << payment_id);
PayResponseJsonRpc out;
out.result.Result = STATUS_OK;
Expand Down
6 changes: 3 additions & 3 deletions src/supernode/requests/sale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ GRAFT_DEFINE_IO_STRUCT(SaleDataMulticast,
(SaleData, sale_data),
(std::string, paymentId),
(int, status),
(string, details)
(std::string, details)
);

enum class SaleHandlerState : int
Expand Down Expand Up @@ -144,7 +144,7 @@ Status handleSaleMulticastReply(const Router::vars_t& vars, const graft::Input&

SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr());

string payment_id = ctx.local["payment_id"];
std::string payment_id = ctx.local["payment_id"];
int status = ctx.global.get(payment_id + CONTEXT_KEY_STATUS, static_cast<int>((RTAStatus::Waiting)));

buildBroadcastSaleStatusOutput(payment_id, status, supernode, output);
Expand All @@ -170,7 +170,7 @@ Status handleSaleStatusBroadcastReply(const Router::vars_t& vars, const graft::I

// prepare reply to the client
SaleData data = ctx.local["sale_data"];
string payment_id = ctx.local["payment_id"];
std::string payment_id = ctx.local["payment_id"];
SaleResponseJsonRpc out;
out.result.BlockNumber = data.BlockNumber;
out.result.PaymentID = payment_id;
Expand Down
Loading

0 comments on commit 479d652

Please sign in to comment.