Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/simplify #298

Merged
merged 4 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/clua-cartesi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ CM_API int luaopen_cartesi(lua_State *L) {
clua_setintegerfield(L, CM_VERSION_MINOR, "VERSION_MINOR", -1);
clua_setintegerfield(L, CM_VERSION_PATCH, "VERSION_PATCH", -1);
clua_setintegerfield(L, CM_HASH_SIZE, "HASH_SIZE", -1);
clua_setintegerfield(L, CM_REG_COUNT, "REG_COUNT", -1);
clua_setintegerfield(L, CM_TREE_LOG2_WORD_SIZE, "TREE_LOG2_WORD_SIZE", -1);
clua_setintegerfield(L, CM_TREE_LOG2_PAGE_SIZE, "TREE_LOG2_PAGE_SIZE", -1);
clua_setintegerfield(L, CM_TREE_LOG2_ROOT_SIZE, "TREE_LOG2_ROOT_SIZE", -1);
Expand Down
7 changes: 5 additions & 2 deletions src/clua-i-virtual-machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ cm_reg clua_check_cm_proc_reg(lua_State *L, int idx) try {
{"uarch_pc", CM_REG_UARCH_PC},
{"uarch_cycle", CM_REG_UARCH_CYCLE},
{"uarch_halt_flag", CM_REG_UARCH_HALT_FLAG},
{"unknown_", CM_REG_UNKNOWN_},
{"first_", CM_REG_FIRST_},
{"last_", CM_REG_LAST_},
// clang-format on
};
const char *name = luaL_checkstring(L, idx);
Expand All @@ -216,10 +219,10 @@ cm_reg clua_check_cm_proc_reg(lua_State *L, int idx) try {
return got->second;
} catch (const std::exception &e) {
luaL_error(L, "%s", e.what());
return CM_REG_UNKNOWN; // will not be reached
return CM_REG_UNKNOWN_; // will not be reached
} catch (...) {
luaL_error(L, "unknown error with register type conversion");
return CM_REG_UNKNOWN; // will not be reached
return CM_REG_UNKNOWN_; // will not be reached
}

void clua_check_cm_hash(lua_State *L, int idx, cm_hash *c_hash) {
Expand Down
2 changes: 1 addition & 1 deletion src/i-virtual-machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace cartesi {
class i_virtual_machine {
public:
using hash_type = machine_merkle_tree::hash_type;
using reg = machine::reg;
using reg = machine_reg;

/// \brief Constructor
i_virtual_machine() = default;
Expand Down
102 changes: 50 additions & 52 deletions src/jsonrpc-virtual-machine.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/jsonrpc-virtual-machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class jsonrpc_virtual_machine final : public i_virtual_machine {
bool do_is_jsonrpc_virtual_machine() const override;

void check_server_version() const;
template <typename R, typename... Ts>
void request(const std::string &method, const std::tuple<Ts...> &tp, R &result, bool keep_alive = true) const;

mutable std::unique_ptr<boost::asio::io_context> m_ioc; // The io_context is required for all I/O
mutable std::unique_ptr<boost::beast::tcp_stream> m_stream; // TCP stream for keep alive connections
Expand Down
Loading
Loading