From 8bd1b590247b0de948f5b1e6bda8e1290a074bb7 Mon Sep 17 00:00:00 2001
From: Diego Nehab <1635557+diegonehab@users.noreply.github.com>
Date: Wed, 8 Jan 2025 14:23:33 +0000
Subject: [PATCH] refactor: rename send_cmio_response state accesses
---
src/machine.cpp | 8 +++---
...cess.h => record-send-cmio-state-access.h} | 26 +++++++++----------
...cess.h => replay-send-cmio-state-access.h} | 22 ++++++++--------
src/send-cmio-response.cpp | 8 +++---
4 files changed, 32 insertions(+), 32 deletions(-)
rename src/{record-state-access.h => record-send-cmio-state-access.h} (93%)
rename src/{replay-state-access.h => replay-send-cmio-state-access.h} (95%)
diff --git a/src/machine.cpp b/src/machine.cpp
index 73db1a88..96cb4a85 100644
--- a/src/machine.cpp
+++ b/src/machine.cpp
@@ -48,9 +48,9 @@
#include "pma-constants.h"
#include "pma-defines.h"
#include "pma.h"
-#include "record-state-access.h"
+#include "record-send-cmio-state-access.h"
#include "record-step-state-access.h"
-#include "replay-state-access.h"
+#include "replay-send-cmio-state-access.h"
#include "replay-step-state-access.h"
#include "riscv-constants.h"
#include "send-cmio-response.h"
@@ -2112,7 +2112,7 @@ access_log machine::log_send_cmio_response(uint16_t reason, const unsigned char
hash_type root_hash_before;
get_root_hash(root_hash_before);
// Call send_cmio_response with the recording state accessor
- record_state_access a(*this, log_type);
+ record_send_cmio_state_access a(*this, log_type);
a.push_bracket(bracket_type::begin, "send cmio response");
cartesi::send_cmio_response(a, reason, data, length);
a.push_bracket(bracket_type::end, "send cmio response");
@@ -2132,7 +2132,7 @@ void machine::verify_send_cmio_response(uint16_t reason, const unsigned char *da
}
// Verify all intermediate state transitions
- replay_state_access a(log, root_hash_before);
+ replay_send_cmio_state_access a(log, root_hash_before);
cartesi::send_cmio_response(a, reason, data, length);
a.finish();
diff --git a/src/record-state-access.h b/src/record-send-cmio-state-access.h
similarity index 93%
rename from src/record-state-access.h
rename to src/record-send-cmio-state-access.h
index 7df3b90b..aee38f5a 100644
--- a/src/record-state-access.h
+++ b/src/record-send-cmio-state-access.h
@@ -14,8 +14,8 @@
// with this program (see COPYING). If not, see .
//
-#ifndef RECORD_STATE_ACCESS_H
-#define RECORD_STATE_ACCESS_H
+#ifndef RECORD_SEND_CMIO_STATE_ACCESS_H
+#define RECORD_SEND_CMIO_STATE_ACCESS_H
/// \file
/// \brief State access implementation that records state accesses to an access log.
@@ -38,10 +38,10 @@
namespace cartesi {
-/// \class record_state_access
-/// \details This ....
-/// access to the machine state. No logs are kept.
-class record_state_access : public i_state_access {
+/// \class record_send_cmio_state_access
+/// \details This records all state accesses that happen during the execution of
+/// a machine::send_cmio_response() function call
+class record_send_cmio_state_access : public i_state_access {
using hasher_type = machine_merkle_tree::hasher_type;
using hash_type = machine_merkle_tree::hash_type;
// NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
@@ -58,7 +58,7 @@ class record_state_access : public i_state_access(log_type)) {
@@ -66,15 +66,15 @@ class record_state_access : public i_state_access get_log() const {
@@ -193,7 +193,7 @@ class record_state_access : public i_state_access;
+ friend i_state_access;
void do_push_bracket(bracket_type &type, const char *text) {
m_log->push_bracket(type, text);
diff --git a/src/replay-state-access.h b/src/replay-send-cmio-state-access.h
similarity index 95%
rename from src/replay-state-access.h
rename to src/replay-send-cmio-state-access.h
index 43c28cb3..56cc135b 100644
--- a/src/replay-state-access.h
+++ b/src/replay-send-cmio-state-access.h
@@ -14,8 +14,8 @@
// with this program (see COPYING). If not, see .
//
-#ifndef REPLAY_STATE_ACCESS_H
-#define REPLAY_STATE_ACCESS_H
+#ifndef REPLAY_SEND_CMIO_STATE_ACCESS_H
+#define REPLAY_SEND_CMIO_STATE_ACCESS_H
/// \file
/// \brief State access implementation that replays recorded state accesses
@@ -41,8 +41,8 @@
namespace cartesi {
-/// \brief Allows replaying a uarch reset operation from an access log.
-class replay_state_access : public i_state_access {
+/// \brief Allows replaying a machine::send_cmio_response() from an access log.
+class replay_send_cmio_state_access : public i_state_access {
using tree_type = machine_merkle_tree;
using hash_type = tree_type::hash_type;
using hasher_type = tree_type::hasher_type;
@@ -61,7 +61,7 @@ class replay_state_access : public i_state_access;
+ friend i_state_access;
std::string access_to_report() const {
auto index = m_next_access + 1;
diff --git a/src/send-cmio-response.cpp b/src/send-cmio-response.cpp
index 48567e92..009c5cfc 100644
--- a/src/send-cmio-response.cpp
+++ b/src/send-cmio-response.cpp
@@ -19,8 +19,8 @@
// NOLINTBEGIN(google-readability-casting,misc-const-correctness,modernize-use-auto,hicpp-use-auto)
-#include "record-state-access.h"
-#include "replay-state-access.h"
+#include "record-send-cmio-state-access.h"
+#include "replay-send-cmio-state-access.h"
#include "state-access.h"
#include "send-cmio-response.h"
@@ -64,10 +64,10 @@ void send_cmio_response(STATE_ACCESS &a, uint16 reason, bytes data, uint32 dataL
template void send_cmio_response(state_access &a, uint16_t reason, const unsigned char *data, uint32 length);
// Explicit instantiation for record_state_access
-template void send_cmio_response(record_state_access &a, uint16_t reason, const unsigned char *data, uint32 length);
+template void send_cmio_response(record_send_cmio_state_access &a, uint16_t reason, const unsigned char *data, uint32 length);
// Explicit instantiation for replay_state_access
-template void send_cmio_response(replay_state_access &a, uint16_t reason, const unsigned char *data, uint32 length);
+template void send_cmio_response(replay_send_cmio_state_access &a, uint16_t reason, const unsigned char *data, uint32 length);
} // namespace cartesi
// NOLINTEND(google-readability-casting,misc-const-correctness,modernize-use-auto,hicpp-use-auto)