Skip to content
Open
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
17 changes: 9 additions & 8 deletions cartesi-rollups/node/state-manager/src/rollups_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use cartesi_prt_core::machine::constants::{
use crate::{CommitmentLeaf, Proof};
use cartesi_machine::{
config::runtime::{HTIFRuntimeConfig, RuntimeConfig},
constants::{break_reason, pma::TX_START},
constants::{
break_reason,
pma::{SHADOW_REVERT_ROOT_HASH_START, TX_START},
},
error::{MachineError, MachineResult},
machine::Machine,
types::{
Expand Down Expand Up @@ -45,8 +48,6 @@ pub const STRIDE_COUNT_IN_EPOCH: u64 = 1
<< (LOG2_INPUT_SPAN_TO_EPOCH + LOG2_BARCH_SPAN_TO_INPUT + LOG2_UARCH_SPAN_TO_BARCH
- LOG2_STRIDE);

pub const CHECKPOINT_ADDRESS: u64 = 0x7ffff000;

pub struct RollupsMachine {
machine: Machine,
epoch_number: u64,
Expand Down Expand Up @@ -110,8 +111,8 @@ impl RollupsMachine {
CmioRequest::Manual(ManualReason::RxAccepted { .. })
));

let checkpoint_hash = self.machine.root_hash()?;
self.feed_input(data, &checkpoint_hash)?;
let revert_root_hash = self.machine.root_hash()?;
self.feed_input(data, &revert_root_hash)?;
self.run_machine(BIG_STEPS_IN_STRIDE)?;

let mut state_hashes = Vec::with_capacity(1 << 20);
Expand Down Expand Up @@ -143,7 +144,7 @@ impl RollupsMachine {

CmioRequest::Manual(reason) => {
state_hashes.push(CommitmentLeaf {
hash: checkpoint_hash,
hash: revert_root_hash,
repetitions: STRIDE_COUNT_IN_INPUT - i,
});

Expand All @@ -155,9 +156,9 @@ impl RollupsMachine {
}
}

fn feed_input(&mut self, input: &[u8], checkpoint_hash: &Hash) -> MachineResult<()> {
fn feed_input(&mut self, input: &[u8], revert_root_hash: &Hash) -> MachineResult<()> {
self.machine
.write_memory(CHECKPOINT_ADDRESS, checkpoint_hash)?;
.write_memory(SHADOW_REVERT_ROOT_HASH_START, revert_root_hash)?;
self.machine
.send_cmio_response(CmioResponseReason::Advance, input)
}
Expand Down
1 change: 1 addition & 0 deletions machine/rust-bindings/cartesi-machine/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod pma {
pub const TX_START: u64 = CM_AR_CMIO_TX_BUFFER_START as u64;
pub const TX_LOG2_SIZE: u64 = CM_AR_CMIO_TX_BUFFER_LOG2_SIZE as u64;
pub const RAM_START: u64 = CM_AR_RAM_START as u64;
pub const SHADOW_REVERT_ROOT_HASH_START: u64 = CM_AR_SHADOW_REVERT_ROOT_HASH_START as u64;
}

pub mod break_reason {
Expand Down
2 changes: 1 addition & 1 deletion prt/client-rs/core/src/machine/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct MachineInstance {
pub snapshot_path: PathBuf,
}

const CHECKPOINT_ADDRESS: u64 = 0x7ffff000;
const CHECKPOINT_ADDRESS: u64 = 0xfe0;
impl MachineInstance {
pub fn new_from_path(path: &str) -> Result<Self> {
let runtime_config = RuntimeConfig {
Expand Down
Loading