|
| 1 | +/* |
| 2 | + Copyright 2020 The Silkrpc Authors |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +#include "debug_api.hpp" |
| 18 | + |
| 19 | +#include <string> |
| 20 | + |
| 21 | +#include <silkworm/common/util.hpp> |
| 22 | + |
| 23 | +#include <silkrpc/common/constants.hpp> |
| 24 | +#include <silkrpc/common/log.hpp> |
| 25 | +#include <silkrpc/common/util.hpp> |
| 26 | +#include <silkrpc/ethdb/kv/transaction_database.hpp> |
| 27 | +#include <silkrpc/json/types.hpp> |
| 28 | + |
| 29 | +namespace silkrpc::commands { |
| 30 | + |
| 31 | +// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_accountrange |
| 32 | +asio::awaitable<void> DebugRpcApi::handle_debug_account_range(const nlohmann::json& request, nlohmann::json& reply) { |
| 33 | + auto tx = co_await database_->begin(); |
| 34 | + |
| 35 | + try { |
| 36 | + ethdb::kv::TransactionDatabase tx_database{*tx}; |
| 37 | + |
| 38 | + reply = make_json_error(request["id"], 500, "not yet implemented"); |
| 39 | + } catch (const std::exception& e) { |
| 40 | + SILKRPC_ERROR << "exception: " << e.what() << "\n"; |
| 41 | + reply = make_json_error(request["id"], 100, e.what()); |
| 42 | + } catch (...) { |
| 43 | + SILKRPC_ERROR << "unexpected exception\n"; |
| 44 | + reply = make_json_error(request["id"], 100, "unexpected exception"); |
| 45 | + } |
| 46 | + |
| 47 | + co_await tx->close(); // RAII not (yet) available with coroutines |
| 48 | + co_return; |
| 49 | +} |
| 50 | + |
| 51 | +// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_getmodifiedaccountsbynumber |
| 52 | +asio::awaitable<void> DebugRpcApi::handle_debug_get_modified_accounts_by_number(const nlohmann::json& request, nlohmann::json& reply) { |
| 53 | + auto tx = co_await database_->begin(); |
| 54 | + |
| 55 | + try { |
| 56 | + ethdb::kv::TransactionDatabase tx_database{*tx}; |
| 57 | + |
| 58 | + reply = make_json_error(request["id"], 500, "not yet implemented"); |
| 59 | + } catch (const std::exception& e) { |
| 60 | + SILKRPC_ERROR << "exception: " << e.what() << "\n"; |
| 61 | + reply = make_json_error(request["id"], 100, e.what()); |
| 62 | + } catch (...) { |
| 63 | + SILKRPC_ERROR << "unexpected exception\n"; |
| 64 | + reply = make_json_error(request["id"], 100, "unexpected exception"); |
| 65 | + } |
| 66 | + |
| 67 | + co_await tx->close(); // RAII not (yet) available with coroutines |
| 68 | + co_return; |
| 69 | +} |
| 70 | + |
| 71 | +// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_getmodifiedaccountsbyhash |
| 72 | +asio::awaitable<void> DebugRpcApi::handle_debug_get_modified_accounts_by_hash(const nlohmann::json& request, nlohmann::json& reply) { |
| 73 | + auto tx = co_await database_->begin(); |
| 74 | + |
| 75 | + try { |
| 76 | + ethdb::kv::TransactionDatabase tx_database{*tx}; |
| 77 | + |
| 78 | + reply = make_json_error(request["id"], 500, "not yet implemented"); |
| 79 | + } catch (const std::exception& e) { |
| 80 | + SILKRPC_ERROR << "exception: " << e.what() << "\n"; |
| 81 | + reply = make_json_error(request["id"], 100, e.what()); |
| 82 | + } catch (...) { |
| 83 | + SILKRPC_ERROR << "unexpected exception\n"; |
| 84 | + reply = make_json_error(request["id"], 100, "unexpected exception"); |
| 85 | + } |
| 86 | + |
| 87 | + co_await tx->close(); // RAII not (yet) available with coroutines |
| 88 | + co_return; |
| 89 | +} |
| 90 | + |
| 91 | +// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_storagerangeat |
| 92 | +asio::awaitable<void> DebugRpcApi::handle_debug_storage_range_at(const nlohmann::json& request, nlohmann::json& reply) { |
| 93 | + auto tx = co_await database_->begin(); |
| 94 | + |
| 95 | + try { |
| 96 | + ethdb::kv::TransactionDatabase tx_database{*tx}; |
| 97 | + |
| 98 | + reply = make_json_error(request["id"], 500, "not yet implemented"); |
| 99 | + } catch (const std::exception& e) { |
| 100 | + SILKRPC_ERROR << "exception: " << e.what() << "\n"; |
| 101 | + reply = make_json_error(request["id"], 100, e.what()); |
| 102 | + } catch (...) { |
| 103 | + SILKRPC_ERROR << "unexpected exception\n"; |
| 104 | + reply = make_json_error(request["id"], 100, "unexpected exception"); |
| 105 | + } |
| 106 | + |
| 107 | + co_await tx->close(); // RAII not (yet) available with coroutines |
| 108 | + co_return; |
| 109 | +} |
| 110 | + |
| 111 | +// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_tracetransaction |
| 112 | +asio::awaitable<void> DebugRpcApi::handle_debug_trace_transaction(const nlohmann::json& request, nlohmann::json& reply) { |
| 113 | + auto tx = co_await database_->begin(); |
| 114 | + |
| 115 | + try { |
| 116 | + ethdb::kv::TransactionDatabase tx_database{*tx}; |
| 117 | + |
| 118 | + reply = make_json_error(request["id"], 500, "not yet implemented"); |
| 119 | + } catch (const std::exception& e) { |
| 120 | + SILKRPC_ERROR << "exception: " << e.what() << "\n"; |
| 121 | + reply = make_json_error(request["id"], 100, e.what()); |
| 122 | + } catch (...) { |
| 123 | + SILKRPC_ERROR << "unexpected exception\n"; |
| 124 | + reply = make_json_error(request["id"], 100, "unexpected exception"); |
| 125 | + } |
| 126 | + |
| 127 | + co_await tx->close(); // RAII not (yet) available with coroutines |
| 128 | + co_return; |
| 129 | +} |
| 130 | + |
| 131 | +// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_tracecall |
| 132 | +asio::awaitable<void> DebugRpcApi::handle_debug_trace_call(const nlohmann::json& request, nlohmann::json& reply) { |
| 133 | + auto tx = co_await database_->begin(); |
| 134 | + |
| 135 | + try { |
| 136 | + ethdb::kv::TransactionDatabase tx_database{*tx}; |
| 137 | + |
| 138 | + reply = make_json_error(request["id"], 500, "not yet implemented"); |
| 139 | + } catch (const std::exception& e) { |
| 140 | + SILKRPC_ERROR << "exception: " << e.what() << "\n"; |
| 141 | + reply = make_json_error(request["id"], 100, e.what()); |
| 142 | + } catch (...) { |
| 143 | + SILKRPC_ERROR << "unexpected exception\n"; |
| 144 | + reply = make_json_error(request["id"], 100, "unexpected exception"); |
| 145 | + } |
| 146 | + |
| 147 | + co_await tx->close(); // RAII not (yet) available with coroutines |
| 148 | + co_return; |
| 149 | +} |
| 150 | + |
| 151 | +} // namespace silkrpc::commands |
0 commit comments