diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_eth.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_eth.cpp index f3fcabb5..f940dc16 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_eth.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_eth.cpp @@ -131,7 +131,9 @@ void eth_rpc_client::on_fail(websocketpp::connection_hdl hdl) { } void eth_rpc_client::on_open(websocketpp::connection_hdl hdl) { - m_endpoint.send(hdl, "{\"jsonrpc\":\"2.0\",\"method\":\"eth_chainId\",\"params\":[],\"id\":84}", websocketpp::frame::opcode::text); + std::string str = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_chainId\",\"params\":[],\"id\":84}"; + ilog("on_open: ${str}", ("str", str)); + m_endpoint.send(hdl, str.c_str(), websocketpp::frame::opcode::text); vector owner_addresses; std::string private_key = ""; @@ -205,6 +207,7 @@ void eth_rpc_client::on_close(websocketpp::connection_hdl) { uint64_t eth_rpc_client::get_chain_id() { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\":\"eth_chainId\",\"params\":[],\"id\":%1%}") % t_id); + ilog("get_chain_id: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_CHAIN_ID; return t_id++; @@ -212,6 +215,7 @@ uint64_t eth_rpc_client::get_chain_id() { uint64_t eth_rpc_client::eth_getTransactionReceipt(const std::string& tx_id) { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionReceipt\",\"params\":[\"%1%\"],\"id\":%2%}") % tx_id.c_str() % t_id); + ilog("eth_getTransactionReceipt: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_GET_TRANSACTION_RECEIPT; return t_id++; @@ -219,6 +223,7 @@ uint64_t eth_rpc_client::eth_getTransactionReceipt(const std::string& tx_id) { uint64_t eth_rpc_client::eth_call(const std::string& to, const std::string& data) { std::string req = str(boost::format("{\"jsonrpc\": \"2.0\", \"method\": \"eth_call\", \"params\": [{\"to\": \"%1%\", \"data\": \"%2%\"}, \"latest\"], \"id\": %3%}") % to.c_str() % data.c_str() % t_id); + ilog("eth_call: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_CALL; @@ -227,6 +232,7 @@ uint64_t eth_rpc_client::eth_call(const std::string& to, const std::string& data uint64_t eth_rpc_client::eth_sendTransaction(const std::string& from, const std::string& to, const std::string& data) { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\": \"eth_sendTransaction\", \"params\": [{\"from\": \"%1%\", \"to\": \"%2%\", \"data\": \"%3%\"}], \"id\": %4%}") % from.c_str() % to.c_str() % data.c_str() % t_id); + ilog("eth_sendTransaction: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_SEND_TRANSACTION; @@ -235,6 +241,7 @@ uint64_t eth_rpc_client::eth_sendTransaction(const std::string& from, const std: uint64_t eth_rpc_client::eth_sendRawTransaction(const std::string& params) { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\":\"eth_sendRawTransaction\",\"params\":[\"%1%\"],\"id\":%2%}") % params.c_str() % t_id); + ilog("eth_sendRawTransaction: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_SEND_RAW_TRANSACTION; @@ -243,6 +250,7 @@ uint64_t eth_rpc_client::eth_sendRawTransaction(const std::string& params) { uint64_t eth_rpc_client::eth_getCode(const std::string& addr) { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\": \"eth_getCode\", \"params\": [\"%1%\",\"latest\"], \"id\": %2%}") % addr.c_str() % t_id); + ilog("eth_getCode: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_GET_CODE; return t_id++; @@ -250,6 +258,7 @@ uint64_t eth_rpc_client::eth_getCode(const std::string& addr) { uint64_t eth_rpc_client::eth_getBalance(const std::string& addr) { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\": \"eth_getBalance\", \"params\": [\"%1%\",\"latest\"], \"id\": %2%}") % addr.c_str() % t_id); + ilog("eth_getBalance: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_GET_BALANCE; return t_id++; @@ -257,6 +266,7 @@ uint64_t eth_rpc_client::eth_getBalance(const std::string& addr) { uint64_t eth_rpc_client::eth_sign(const string& addr, const string& message) { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\": \"eth_sign\", \"params\": [\"%1%\",\"%2%\"], \"id\": %2%}") % addr.c_str() % message.c_str() % t_id); + ilog("eth_sign: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_SIGN; @@ -265,6 +275,7 @@ uint64_t eth_rpc_client::eth_sign(const string& addr, const string& message) { uint64_t eth_rpc_client::eth_coinbase() { std::string req = str(boost::format("{\"jsonrpc\":\"2.0\",\"method\":\"eth_coinbase\",\"params\":[],\"id\":%1%}") % t_id); + ilog("eth_coinbase: ${req}", ("req", req.c_str())); m_endpoint.send(m_hdl, req.c_str(), websocketpp::frame::opcode::text); m_requests[t_id] = req_t::ETH_COINBASE; return t_id++; @@ -340,6 +351,8 @@ std::string eth_rpc_client::combinepsbt(const vector &psbts) { } uint64_t eth_rpc_client::createmultisig(const uint32_t nrequired, const std::vector owner_addresses, const std::string &private_key) { + ilog("createmultisig: ${key}", ("key", private_key.c_str())); + //That's will create //0x5FbBb31BE52608D2F52247E8400B7fCaA9E0bC12 //0x76ce31BD03f601c3fC13732deF921c5Bac282676 @@ -776,6 +789,8 @@ bool sidechain_net_handler_eth::process_proposal(const proposal_object &po) { } void sidechain_net_handler_eth::process_primary_wallet() { + ilog("### process_primary_wallet:"); + const auto &swi = database.get_index_type().indices().get(); const auto &active_sw = swi.rbegin(); if (active_sw != swi.rend()) { @@ -908,6 +923,7 @@ void sidechain_net_handler_eth::process_sidechain_addresses() { } bool sidechain_net_handler_eth::process_deposit(const son_wallet_deposit_object &swdo) { + ilog("### process_deposit:"); if (proposal_exists(chain::operation::tag::value, swdo.id)) { return false; @@ -952,6 +968,7 @@ bool sidechain_net_handler_eth::process_deposit(const son_wallet_deposit_object } bool sidechain_net_handler_eth::process_withdrawal(const son_wallet_withdraw_object &swwo) { + ilog("### process_withdrawal:"); if (proposal_exists(chain::operation::tag::value, swwo.id)) { return false; @@ -996,10 +1013,12 @@ bool sidechain_net_handler_eth::process_withdrawal(const son_wallet_withdraw_obj } std::string sidechain_net_handler_eth::process_sidechain_transaction(const sidechain_transaction_object &sto) { + ilog("### process_sidechain_transaction: "); return sign_transaction(sto); } std::string sidechain_net_handler_eth::send_sidechain_transaction(const sidechain_transaction_object &sto) { + ilog("### send_sidechain_transaction: "); return send_transaction(sto); } @@ -1055,6 +1074,8 @@ std::string sidechain_net_handler_eth::create_transaction() { } std::string sidechain_net_handler_eth::sign_transaction(const sidechain_transaction_object &sto) { + ilog("### sign_transaction: "); + std::stringstream ss_trx(boost::algorithm::unhex(sto.transaction)); ethereum::signed_transaction htrx; fc::raw::unpack(ss_trx, htrx, 1000); @@ -1092,6 +1113,8 @@ std::vector sidechain_net_handler_eth::extract_info_from_block(con } void sidechain_net_handler_eth::on_changed_objects(const vector &ids, const flat_set &accounts) { + ilog("### on_changed_objects: "); + fc::time_point now = fc::time_point::now(); int64_t time_to_next_changed_objects_processing = 5000;