Skip to content

Commit

Permalink
feat!: dave-rollups work
Browse files Browse the repository at this point in the history
- rename `offchain` to `rollups-node`
- rename `input-reader` to `blockchain-reader`
- rewrite `machine-runner` to adapt `machine-emulator 0.17.0`
- rewrite `StateManager` to use sqlite
- add `start` signatures (no body)
  • Loading branch information
stephenctw committed May 22, 2024
1 parent 61b7bbc commit bf7c855
Show file tree
Hide file tree
Showing 45 changed files with 886 additions and 7,302 deletions.
432 changes: 432 additions & 0 deletions machine-bindings/Cargo.lock

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions machine-bindings/cartesi-machine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub mod log;
pub mod proof;

use cartesi_machine_sys::{cm_machine_runtime_config, cm_memory_range_config};
use configuration::{free_cm_memory_range_config_cstr};
use configuration::{RuntimeConfig};
use configuration::free_cm_memory_range_config_cstr;
use configuration::RuntimeConfig;
use errors::{ErrorCollector, MachineError};

macro_rules! read_csr {
Expand Down Expand Up @@ -155,6 +155,11 @@ pub enum UarchBreakReason {
UarchHalted,
}

pub enum HtifYieldReason {
HtifYieldReasonAdvanceState = 0,
HtifYieldReasonInspectState = 1,
}

/// Machine instance handle
pub struct Machine {
machine: *mut cartesi_machine_sys::cm_machine,
Expand Down Expand Up @@ -526,13 +531,17 @@ impl Machine {
}

/// Write a CMIO response
pub fn send_cmio_response(&mut self, reason: u16, data: &[u8]) -> Result<(), MachineError> {
pub fn send_cmio_response(
&mut self,
reason: HtifYieldReason,
data: &[u8],
) -> Result<(), MachineError> {
let mut error_collector = ErrorCollector::new();

unsafe {
let result = cartesi_machine_sys::cm_send_cmio_response(
self.machine,
reason,
reason as u16,
data.as_ptr(),
data.len(),
&mut error_collector.as_mut_ptr(),
Expand Down
Loading

0 comments on commit bf7c855

Please sign in to comment.