This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add full RPC API skeletons to simplify development (#41)
Print local binding at startup Add executable version (--version switch) Update API documentation Update project README with activation information Update performance README with automation setup
- Loading branch information
Showing
21 changed files
with
1,833 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/* | ||
Copyright 2020 The Silkrpc Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#include "debug_api.hpp" | ||
|
||
#include <string> | ||
|
||
#include <silkworm/common/util.hpp> | ||
|
||
#include <silkrpc/common/constants.hpp> | ||
#include <silkrpc/common/log.hpp> | ||
#include <silkrpc/common/util.hpp> | ||
#include <silkrpc/ethdb/kv/transaction_database.hpp> | ||
#include <silkrpc/json/types.hpp> | ||
|
||
namespace silkrpc::commands { | ||
|
||
// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_accountrange | ||
asio::awaitable<void> DebugRpcApi::handle_debug_account_range(const nlohmann::json& request, nlohmann::json& reply) { | ||
auto tx = co_await database_->begin(); | ||
|
||
try { | ||
ethdb::kv::TransactionDatabase tx_database{*tx}; | ||
|
||
reply = make_json_error(request["id"], 500, "not yet implemented"); | ||
} catch (const std::exception& e) { | ||
SILKRPC_ERROR << "exception: " << e.what() << "\n"; | ||
reply = make_json_error(request["id"], 100, e.what()); | ||
} catch (...) { | ||
SILKRPC_ERROR << "unexpected exception\n"; | ||
reply = make_json_error(request["id"], 100, "unexpected exception"); | ||
} | ||
|
||
co_await tx->close(); // RAII not (yet) available with coroutines | ||
co_return; | ||
} | ||
|
||
// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_getmodifiedaccountsbynumber | ||
asio::awaitable<void> DebugRpcApi::handle_debug_get_modified_accounts_by_number(const nlohmann::json& request, nlohmann::json& reply) { | ||
auto tx = co_await database_->begin(); | ||
|
||
try { | ||
ethdb::kv::TransactionDatabase tx_database{*tx}; | ||
|
||
reply = make_json_error(request["id"], 500, "not yet implemented"); | ||
} catch (const std::exception& e) { | ||
SILKRPC_ERROR << "exception: " << e.what() << "\n"; | ||
reply = make_json_error(request["id"], 100, e.what()); | ||
} catch (...) { | ||
SILKRPC_ERROR << "unexpected exception\n"; | ||
reply = make_json_error(request["id"], 100, "unexpected exception"); | ||
} | ||
|
||
co_await tx->close(); // RAII not (yet) available with coroutines | ||
co_return; | ||
} | ||
|
||
// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_getmodifiedaccountsbyhash | ||
asio::awaitable<void> DebugRpcApi::handle_debug_get_modified_accounts_by_hash(const nlohmann::json& request, nlohmann::json& reply) { | ||
auto tx = co_await database_->begin(); | ||
|
||
try { | ||
ethdb::kv::TransactionDatabase tx_database{*tx}; | ||
|
||
reply = make_json_error(request["id"], 500, "not yet implemented"); | ||
} catch (const std::exception& e) { | ||
SILKRPC_ERROR << "exception: " << e.what() << "\n"; | ||
reply = make_json_error(request["id"], 100, e.what()); | ||
} catch (...) { | ||
SILKRPC_ERROR << "unexpected exception\n"; | ||
reply = make_json_error(request["id"], 100, "unexpected exception"); | ||
} | ||
|
||
co_await tx->close(); // RAII not (yet) available with coroutines | ||
co_return; | ||
} | ||
|
||
// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_storagerangeat | ||
asio::awaitable<void> DebugRpcApi::handle_debug_storage_range_at(const nlohmann::json& request, nlohmann::json& reply) { | ||
auto tx = co_await database_->begin(); | ||
|
||
try { | ||
ethdb::kv::TransactionDatabase tx_database{*tx}; | ||
|
||
reply = make_json_error(request["id"], 500, "not yet implemented"); | ||
} catch (const std::exception& e) { | ||
SILKRPC_ERROR << "exception: " << e.what() << "\n"; | ||
reply = make_json_error(request["id"], 100, e.what()); | ||
} catch (...) { | ||
SILKRPC_ERROR << "unexpected exception\n"; | ||
reply = make_json_error(request["id"], 100, "unexpected exception"); | ||
} | ||
|
||
co_await tx->close(); // RAII not (yet) available with coroutines | ||
co_return; | ||
} | ||
|
||
// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_tracetransaction | ||
asio::awaitable<void> DebugRpcApi::handle_debug_trace_transaction(const nlohmann::json& request, nlohmann::json& reply) { | ||
auto tx = co_await database_->begin(); | ||
|
||
try { | ||
ethdb::kv::TransactionDatabase tx_database{*tx}; | ||
|
||
reply = make_json_error(request["id"], 500, "not yet implemented"); | ||
} catch (const std::exception& e) { | ||
SILKRPC_ERROR << "exception: " << e.what() << "\n"; | ||
reply = make_json_error(request["id"], 100, e.what()); | ||
} catch (...) { | ||
SILKRPC_ERROR << "unexpected exception\n"; | ||
reply = make_json_error(request["id"], 100, "unexpected exception"); | ||
} | ||
|
||
co_await tx->close(); // RAII not (yet) available with coroutines | ||
co_return; | ||
} | ||
|
||
// https://github.com/ethereum/retesteth/wiki/RPC-Methods#debug_tracecall | ||
asio::awaitable<void> DebugRpcApi::handle_debug_trace_call(const nlohmann::json& request, nlohmann::json& reply) { | ||
auto tx = co_await database_->begin(); | ||
|
||
try { | ||
ethdb::kv::TransactionDatabase tx_database{*tx}; | ||
|
||
reply = make_json_error(request["id"], 500, "not yet implemented"); | ||
} catch (const std::exception& e) { | ||
SILKRPC_ERROR << "exception: " << e.what() << "\n"; | ||
reply = make_json_error(request["id"], 100, e.what()); | ||
} catch (...) { | ||
SILKRPC_ERROR << "unexpected exception\n"; | ||
reply = make_json_error(request["id"], 100, "unexpected exception"); | ||
} | ||
|
||
co_await tx->close(); // RAII not (yet) available with coroutines | ||
co_return; | ||
} | ||
|
||
} // namespace silkrpc::commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
Copyright 2020 The Silkrpc Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#ifndef SILKRPC_COMMANDS_DEBUG_API_HPP_ | ||
#define SILKRPC_COMMANDS_DEBUG_API_HPP_ | ||
|
||
#include <memory> | ||
|
||
#include <silkrpc/config.hpp> // NOLINT(build/include_order) | ||
|
||
#include <asio/awaitable.hpp> | ||
#include <nlohmann/json.hpp> | ||
|
||
#include <silkrpc/core/rawdb/accessors.hpp> | ||
#include <silkrpc/json/types.hpp> | ||
#include <silkrpc/ethdb/kv/database.hpp> | ||
|
||
namespace silkrpc::http { class RequestHandler; } | ||
|
||
namespace silkrpc::commands { | ||
|
||
class DebugRpcApi { | ||
public: | ||
explicit DebugRpcApi(std::unique_ptr<ethdb::kv::Database>& database) : database_(database) {} | ||
virtual ~DebugRpcApi() {} | ||
|
||
DebugRpcApi(const DebugRpcApi&) = delete; | ||
DebugRpcApi& operator=(const DebugRpcApi&) = delete; | ||
|
||
protected: | ||
asio::awaitable<void> handle_debug_account_range(const nlohmann::json& request, nlohmann::json& reply); | ||
asio::awaitable<void> handle_debug_get_modified_accounts_by_number(const nlohmann::json& request, nlohmann::json& reply); | ||
asio::awaitable<void> handle_debug_get_modified_accounts_by_hash(const nlohmann::json& request, nlohmann::json& reply); | ||
asio::awaitable<void> handle_debug_storage_range_at(const nlohmann::json& request, nlohmann::json& reply); | ||
asio::awaitable<void> handle_debug_trace_transaction(const nlohmann::json& request, nlohmann::json& reply); | ||
asio::awaitable<void> handle_debug_trace_call(const nlohmann::json& request, nlohmann::json& reply); | ||
|
||
private: | ||
std::unique_ptr<ethdb::kv::Database>& database_; | ||
|
||
friend class silkrpc::http::RequestHandler; | ||
}; | ||
|
||
} // namespace silkrpc::commands | ||
|
||
#endif // SILKRPC_COMMANDS_DEBUG_API_HPP_ |
Oops, something went wrong.