Skip to content
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
2 changes: 1 addition & 1 deletion .github/actions/cartesi-machine/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
version:
description: 'Version of Cartesi Machine to install'
required: false
default: 0.19.0
default: 0.20.0
suffix-version:
description: 'Suffix of Cartesi Machine to install'
required: false
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Cartesi Machine
uses: ./.github/actions/cartesi-machine
with:
version: 0.19.0
version: 0.20.0
suffix-version: ""

- name: Setup env
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Install Cartesi Machine
uses: ./.github/actions/cartesi-machine
with:
version: 0.19.0
version: 0.20.0
- name: Download PRT contracts
working-directory: ./prt/contracts
run: |
Expand Down Expand Up @@ -138,8 +138,8 @@ jobs:
working-directory: ./machine/emulator
run: |
make bundle-boost
wget -O add-generated-files.diff https://github.com/cartesi/machine-emulator/releases/download/v0.19.0/add-generated-files.diff
echo "a892e2d9f5c331f5e80bcb5db4133e7db625aa4d14ffdf9467b75c4c34d1744f add-generated-files.diff" | sha256sum -c
wget -O add-generated-files.diff https://github.com/cartesi/machine-emulator/releases/download/v0.20.0/add-generated-files.diff
echo "d9c2afcefc2759e7cd37bbedc83d54c81515f0fddb671103b489b8789aee33bb add-generated-files.diff" | sha256sum -c
git apply add-generated-files.diff
rm add-generated-files.diff
make
Expand Down
2 changes: 1 addition & 1 deletion cartesi-rollups/contracts/src/DaveConsensus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ contract DaveConsensus is IDaveConsensus, ERC165, ApplicationChecker {

require(proof.length == Memory.LOG2_MAX_SIZE, InvalidOutputsMerkleRootProofSize(proof.length));
bytes32 allegedStateHash = proof.merkleRootAfterReplacement(
EmulatorConstants.PMA_CMIO_TX_BUFFER_START >> EmulatorConstants.TREE_LOG2_WORD_SIZE,
EmulatorConstants.AR_CMIO_TX_BUFFER_START >> EmulatorConstants.HASH_TREE_LOG2_WORD_SIZE,
keccak256(abi.encode(outputsMerkleRoot)),
LibKeccak256.hashPair
);
Expand Down
2 changes: 1 addition & 1 deletion cartesi-rollups/contracts/test/DaveAppFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract DaveAppFactoryTest is Test {

bytes32[] memory outputsMerkleRootProof = _randomProof(Memory.LOG2_MAX_SIZE);
bytes32 machineMerkleRoot = outputsMerkleRootProof.merkleRootAfterReplacement(
EmulatorConstants.PMA_CMIO_TX_BUFFER_START >> EmulatorConstants.TREE_LOG2_WORD_SIZE,
EmulatorConstants.AR_CMIO_TX_BUFFER_START >> EmulatorConstants.HASH_TREE_LOG2_WORD_SIZE,
keccak256(abi.encode(outputsMerkleRoot))
);

Expand Down
5 changes: 4 additions & 1 deletion cartesi-rollups/node/blockchain-reader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,10 @@ mod blockchain_reader_tests {
let mut machine = Machine::create(
&MachineConfig::new_with_ram(RAMConfig {
length: 134217728,
image_filename: "../../../test/programs/linux.bin".into(),
backing_store: cartesi_machine::config::machine::BackingStoreConfig {
data_filename: "../../../test/programs/linux.bin".into(),
..Default::default()
},
}),
&RuntimeConfig::default(),
)
Expand Down
26 changes: 15 additions & 11 deletions cartesi-rollups/node/blockchain-reader/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ use alloy::{
signers::{Signer, local::PrivateKeySigner},
};
use cartesi_dave_contracts::i_dave_app_factory::IDaveAppFactory::{self, WithdrawalConfig};
use cartesi_machine::{Machine, config::runtime::RuntimeConfig};
use cartesi_rollups_contracts::i_input_box::IInputBox;
use serde::Deserialize;
use std::{
fs::{self, File},
io::Read,
path::PathBuf,
};
use std::{fs, path::PathBuf};

type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

Expand Down Expand Up @@ -76,12 +73,19 @@ pub async fn spawn_anvil_and_provider() -> Result<(AnvilInstance, DynProvider, A
let input_box = deployment_address("InputBox");
let dave_app_factory = deployment_address("DaveAppFactory");

let initial_hash = {
// $ xxd -p -c32 test/programs/echo/machine-image/hash
let mut file = File::open(program_path.join("machine-image").join("hash")).unwrap();
let mut buffer = [0u8; 32];
file.read_exact(&mut buffer).unwrap();
buffer
// Load the stored machine through the emulator and ask it for the root
// hash, rather than reading the internal `hash_tree.sht` file directly.
// The file layout is an emulator implementation detail; going through
// `cm_load_new` + `cm_get_root_hash` is the only stable API.
let initial_hash: [u8; 32] = {
let mut machine = Machine::load(
&program_path.join("machine-image"),
&RuntimeConfig::quiet_console(),
)
.expect("failed to load stored machine");
machine
.root_hash()
.expect("failed to read machine root hash")
};

let withdrawal_config = WithdrawalConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ mod tests {
let mut machine = Machine::create(
&MachineConfig::new_with_ram(RAMConfig {
length: 134217728,
image_filename: "../../../test/programs/linux.bin".into(),
backing_store: cartesi_machine::config::machine::BackingStoreConfig {
data_filename: "../../../test/programs/linux.bin".into(),
..Default::default()
},
}),
&RuntimeConfig::default(),
)
Expand Down
18 changes: 6 additions & 12 deletions cartesi-rollups/node/state-manager/src/rollups_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
use std::path::{Path, PathBuf};

use cartesi_prt_core::machine::constants::{
LOG2_BARCH_SPAN_TO_INPUT, LOG2_INPUT_SPAN_TO_EPOCH, LOG2_UARCH_SPAN_TO_BARCH,
CHECKPOINT_ADDRESS, LOG2_BARCH_SPAN_TO_INPUT, LOG2_INPUT_SPAN_TO_EPOCH,
LOG2_UARCH_SPAN_TO_BARCH,
};

use crate::{CommitmentLeaf, Proof};
use cartesi_machine::{
config::runtime::{HTIFRuntimeConfig, RuntimeConfig},
constants::{break_reason, pma::TX_START},
config::runtime::RuntimeConfig,
constants::{ar::TX_START, break_reason, machine::HASH_TREE_LOG2_ROOT_SIZE},
error::{MachineError, MachineResult},
machine::Machine,
types::{
Expand Down Expand Up @@ -45,8 +46,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 All @@ -59,12 +58,7 @@ impl RollupsMachine {
epoch_number: u64,
next_input_index_in_epoch: u64,
) -> MachineResult<Self> {
let runtime_config = RuntimeConfig {
htif: Some(HTIFRuntimeConfig {
no_console_putchar: Some(true),
}),
..Default::default()
};
let runtime_config = RuntimeConfig::quiet_console();
let machine = Machine::load(path, &runtime_config)?;

Ok(Self {
Expand All @@ -88,7 +82,7 @@ impl RollupsMachine {
}

pub fn outputs_proof(&mut self) -> MachineResult<(Hash, Proof)> {
let proof = self.machine.proof(TX_START, 5)?;
let proof = self.machine.proof(TX_START, 5, HASH_TREE_LOG2_ROOT_SIZE)?;
let siblings = Proof::new(proof.sibling_hashes);
let output_merkle = self.machine.read_memory(TX_START, 32)?;

Expand Down
5 changes: 4 additions & 1 deletion cartesi-rollups/node/state-manager/src/sql/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ pub fn setup_db() -> (TempDir, Connection) {
let mut machine = Machine::create(
&MachineConfig::new_with_ram(RAMConfig {
length: 134217728,
image_filename: "../../../test/programs/linux.bin".into(),
backing_store: cartesi_machine::config::machine::BackingStoreConfig {
data_filename: "../../../test/programs/linux.bin".into(),
..Default::default()
},
}),
&RuntimeConfig::default(),
)
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
update-submodules:
git submodule update --recursive --init

apply-generated-files-diff VERSION="v0.19.0" FILEHASH="a892e2d9f5c331f5e80bcb5db4133e7db625aa4d14ffdf9467b75c4c34d1744f":
apply-generated-files-diff VERSION="v0.20.0" FILEHASH="d9c2afcefc2759e7cd37bbedc83d54c81515f0fddb671103b489b8789aee33bb":
cd machine/emulator && \
(wget -O add-generated-files.diff https://github.com/cartesi/machine-emulator/releases/download/{{VERSION}}/add-generated-files.diff && \
(echo "{{FILEHASH}} add-generated-files.diff" | sha256sum -c) && \
Expand All @@ -18,7 +18,7 @@ clean-contracts: clean-consensus-contracts clean-prt-contracts clean-bindings cl
make -C machine/emulator clean depclean distclean

setup: update-submodules clean-emulator clean-contracts bundle-boost apply-generated-files-diff
make -C machine/emulator # Requires docker, necessary for machine bindings
make -C machine/emulator -j8 # Requires docker, necessary for machine bindings

# Run this once after cloning, if using a docker environment
setup-docker: setup build-docker-image
Expand Down
2 changes: 1 addition & 1 deletion machine/emulator
Submodule emulator updated 366 files
2 changes: 1 addition & 1 deletion machine/rust-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [


[workspace.package]
version = "0.19.0"
version = "0.20.0"
edition = "2021"

license = "Apache-2.0"
Expand Down
24 changes: 23 additions & 1 deletion machine/rust-bindings/cartesi-machine-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ fn main() {
}
}

// OpenMP linker configuration (cross-platform)
if cfg!(target_os = "macos") {
// macOS: Try Homebrew first, then MacPorts
let homebrew_libomp = PathBuf::from("/opt/homebrew/opt/libomp");
if homebrew_libomp.exists() {
println!("cargo:rustc-link-search={}/lib", homebrew_libomp.display());
println!("cargo:rustc-link-lib=omp");
} else {
let macports_libomp = PathBuf::from("/opt/local/lib/libomp");
if macports_libomp.exists() {
println!("cargo:rustc-link-search=/opt/local/lib/libomp");
println!("cargo:rustc-link-lib=gomp");
} else {
// Fallback: let system linker find it
println!("cargo:rustc-link-lib=omp");
}
Comment thread
mpolitzer marked this conversation as resolved.
}
} else {
// Linux and other Unix-like systems: libgomp comes with GCC
println!("cargo:rustc-link-lib=gomp");
Comment thread
mpolitzer marked this conversation as resolved.
}

//
// Generate bindings
//
Expand Down Expand Up @@ -197,7 +219,7 @@ mod build_cm {
process::{Command, Stdio},
};

const VERSION_STRING: &str = "v0.19.0";
const VERSION_STRING: &str = "v0.20.0";

pub fn download(machine_dir_path: &Path) {
let patch_file = machine_dir_path.join("add-generated-files.diff");
Expand Down
Loading
Loading