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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.15.0-test1] - 2026-07-23

### Changed
- Updated machine-emulator version to v0.21.0-test7
- Updated test artifact parsing for `0x`-prefixed hexadecimal values
- Changed microarchitecture cycle overflow into a state-preserving fixed point derived from `uarch.cycle`
- Changed microarchitecture cycle overflow to take precedence over halt

Expand Down Expand Up @@ -123,7 +127,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [0.2.0]
- [0.1.0]

[Unreleased]: https://github.com/cartesi/machine-solidity-step/compare/v0.14.0...HEAD
[Unreleased]: https://github.com/cartesi/machine-solidity-step/compare/v0.15.0-test1...HEAD
[0.15.0-test1]: https://github.com/cartesi/machine-solidity-step/releases/tag/v0.15.0-test1
[0.14.0]: https://github.com/cartesi/machine-solidity-step/releases/tag/v0.14.0
[0.13.0]: https://github.com/cartesi/machine-solidity-step/releases/tag/v0.13.0
[0.12.1]: https://github.com/cartesi/machine-solidity-step/releases/tag/v0.12.1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DOWNLOADDIR := downloads
SRC_DIR := src

EMULATOR_VERSION ?= v0.21.0
EMULATOR_TAG ?= -test5
EMULATOR_TAG ?= -test7

SOLIDITY_VERSION ?= 0.8.30

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cartesi/machine-solidity-step",
"version": "0.14.0",
"version": "0.15.0-test1",
"description": "Machine Solidity UArch Interpret",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions shasum-download
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
182c7a57481daa4076a488b1c3f0b8ba01d0271c267f79c9f5ecb947cac6bd50 downloads/machine-emulator-tests-data.deb
79e0797c4a30c6a3f2523353006db0b8b99b6a6cdf17670634c6befa024905bf downloads/uarch-riscv-tests-json-logs.tar.gz
12c934f783c6e5e706befe4986fa66f2329c97e2486dab4a5ff817bf412e1a5e downloads/machine-emulator-tests-data.deb
b0860e8e87da7b7226ece35f3baa5ccb6e543654919af4a390df72a59ec3c866 downloads/uarch-riscv-tests-json-logs.tar.gz
2 changes: 0 additions & 2 deletions src/EmulatorConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ library EmulatorConstants {
uint64 constant REVERT_ROOT_HASH_ADDRESS = 0xfe0;
// END OF AUTO-GENERATED CODE

uint64 constant LOG2_CYCLES_TO_RESET = 10;

uint64 constant TLB_SLOT_LENGTH = 32;
uint64 constant TLB_SET_SIZE = 256;
uint64 constant TLB_SET_LENGTH = TLB_SET_SIZE * TLB_SLOT_LENGTH;
Expand Down
14 changes: 11 additions & 3 deletions src/MetaStep.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ library MetaStep {
using AccessLogs for AccessLogs.Context;

/// @notice Run meta-step
/// @param counter Number of meta-steps performed, counting this one.
/// It is also the index of the state this meta-step produces, since the
/// initial state has index zero and is not a leaf of the computation
/// hash. The uarch reset runs on meta-steps whose counter is a multiple
/// of the uarch span, which produce the last leaf of each span. Callers
/// that instead number transitions by their source state must pass
/// counter as that number plus one.
function step(uint256 counter, AccessLogs.Context memory accessLogs)
internal
pure
Expand All @@ -36,10 +43,11 @@ library MetaStep {

if (
counter
== (counter >> EmulatorConstants.LOG2_CYCLES_TO_RESET)
<< EmulatorConstants.LOG2_CYCLES_TO_RESET
== (counter
>> EmulatorConstants.ROLLUP_LOG2_MAX_UARCH_CYCLES_PER_MCYCLE)
<< EmulatorConstants.ROLLUP_LOG2_MAX_UARCH_CYCLES_PER_MCYCLE
) {
// if counter is a multiple of (1 << EmulatorConstants.LOG2_CYCLES_TO_RESET), run uarch reset
// if counter is a multiple of (1 << EmulatorConstants.ROLLUP_LOG2_MAX_UARCH_CYCLES_PER_MCYCLE), run uarch reset
UArchReset.reset(accessLogs);
machineState = accessLogs.currentRootHash;
}
Expand Down
2 changes: 0 additions & 2 deletions templates/EmulatorConstants.sol.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ library EmulatorConstants {
// START OF AUTO-GENERATED CODE
// END OF AUTO-GENERATED CODE

uint64 constant LOG2_CYCLES_TO_RESET = 10;

uint64 constant TLB_SLOT_LENGTH = 32;
uint64 constant TLB_SET_SIZE = 256;
uint64 constant TLB_SET_LENGTH = TLB_SET_SIZE * TLB_SLOT_LENGTH;
Expand Down
8 changes: 3 additions & 5 deletions templates/UArchReplay.t.sol.template
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ contract UArchReplay_@X@_Test is AccessLogJsonParse {
string memory rj =
loadJsonLog(string.concat(JSON_PATH, catalog[i].logFilename));

bytes32 initialRootHash = vm.parseBytes32(
string.concat("0x", catalog[i].initialRootHash)
);
bytes32 finalRootHash =
vm.parseBytes32(string.concat("0x", catalog[i].finalRootHash));
bytes32 initialRootHash =
vm.parseBytes32(catalog[i].initialRootHash);
bytes32 finalRootHash = vm.parseBytes32(catalog[i].finalRootHash);
for (uint256 j = 0; j < catalog[i].steps; j++) {
console.log("Replaying step %d ...", j);
// load json log
Expand Down
8 changes: 1 addition & 7 deletions test/AccessLogJsonParse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ abstract contract AccessLogJsonParse is Test {
if (b.length == 0) {
return bytes32(0);
}
if (
b.length >= 2 && b[0] == bytes1("0")
&& (b[1] == bytes1("x") || b[1] == bytes1("X"))
) {
return vm.parseBytes32(s);
}
return vm.parseBytes32(string.concat("0x", s));
return vm.parseBytes32(s);
}
}
16 changes: 6 additions & 10 deletions test/SendCmioResponse.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ contract SendCmioResponse_Test is AccessLogJsonParse {

string memory rj = loadJsonLog(resetLog);

bytes32 initialRootHash = vm.parseBytes32(
string.concat("0x", catalog[i].initialRootHash)
);
bytes32 finalRootHash =
vm.parseBytes32(string.concat("0x", catalog[i].finalRootHash));
bytes32 initialRootHash =
vm.parseBytes32(catalog[i].initialRootHash);
bytes32 finalRootHash = vm.parseBytes32(catalog[i].finalRootHash);

loadBufferFromRawJson(buffer, rj);

Expand Down Expand Up @@ -144,11 +142,9 @@ contract SendCmioResponse_Test is AccessLogJsonParse {

string memory rj = loadJsonLog(noopLog);

bytes32 initialRootHash = vm.parseBytes32(
string.concat("0x", catalog[i].initialRootHash)
);
bytes32 finalRootHash =
vm.parseBytes32(string.concat("0x", catalog[i].finalRootHash));
bytes32 initialRootHash =
vm.parseBytes32(catalog[i].initialRootHash);
bytes32 finalRootHash = vm.parseBytes32(catalog[i].finalRootHash);
// the log was taken from a machine that yielded manual with reason
// rx-rejected, so the advance-state response must be a no-op
assertEq(
Expand Down
7 changes: 4 additions & 3 deletions test/UArchInterpret.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//
import "forge-std/console.sol";
import "forge-std/Test.sol";
import "forge-std/StdJson.sol";

import "./UArchInterpret.sol";
import "src/EmulatorConstants.sol";
Expand All @@ -33,7 +32,6 @@ library ExternalUArchInterpret {
}

contract UArchInterpretTest is Test {
using stdJson for string;
using Memory for uint64;
using AccessLogs for AccessLogs.Context;

Expand All @@ -52,6 +50,8 @@ contract UArchInterpretTest is Test {
string constant CATALOG_PATH = "catalog.json";
string constant JSON_PATH = "./test/uarch-log/";
string constant BINARIES_PATH = "./test/uarch-bin/";
string constant ENTRY_TYPE_DESCRIPTION =
"Entry(string binaryFilename,string finalRootHash,string initialRootHash,string logFilename,uint256 steps)";

function testBinaries() public {
Entry[] memory catalog =
Expand Down Expand Up @@ -216,7 +216,8 @@ contract UArchInterpretTest is Test {
returns (Entry[] memory)
{
string memory json = vm.readFile(path);
bytes memory raw = json.parseRaw("");
bytes memory raw =
vm.parseJsonTypeArray(json, ".", ENTRY_TYPE_DESCRIPTION);
Entry[] memory catalog = abi.decode(raw, (Entry[]));

return catalog;
Expand Down
8 changes: 3 additions & 5 deletions test/UArchReset.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ contract UArchReset_Test is AccessLogJsonParse {
string memory rj =
loadJsonLog(string.concat(JSON_PATH, catalog[i].logFilename));

bytes32 initialRootHash = vm.parseBytes32(
string.concat("0x", catalog[i].initialRootHash)
);
bytes32 finalRootHash =
vm.parseBytes32(string.concat("0x", catalog[i].finalRootHash));
bytes32 initialRootHash =
vm.parseBytes32(catalog[i].initialRootHash);
bytes32 finalRootHash = vm.parseBytes32(catalog[i].finalRootHash);

loadBufferFromRawJson(buffer, rj);

Expand Down
Loading