diff --git a/CHANGELOG.md b/CHANGELOG.md index 05141ed..9daa172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/Makefile b/Makefile index ab24582..324ff07 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/package.json b/package.json index 8d87789..a055d6d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/shasum-download b/shasum-download index fc39192..107f7cd 100644 --- a/shasum-download +++ b/shasum-download @@ -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 diff --git a/src/EmulatorConstants.sol b/src/EmulatorConstants.sol index 7c1aa1d..7567708 100644 --- a/src/EmulatorConstants.sol +++ b/src/EmulatorConstants.sol @@ -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; diff --git a/src/MetaStep.sol b/src/MetaStep.sol index 6438af9..d5197ce 100644 --- a/src/MetaStep.sol +++ b/src/MetaStep.sol @@ -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 @@ -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; } diff --git a/templates/EmulatorConstants.sol.template b/templates/EmulatorConstants.sol.template index 31ef6d8..6d839f5 100644 --- a/templates/EmulatorConstants.sol.template +++ b/templates/EmulatorConstants.sol.template @@ -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; diff --git a/templates/UArchReplay.t.sol.template b/templates/UArchReplay.t.sol.template index ccf5fb2..3c44374 100644 --- a/templates/UArchReplay.t.sol.template +++ b/templates/UArchReplay.t.sol.template @@ -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 diff --git a/test/AccessLogJsonParse.sol b/test/AccessLogJsonParse.sol index 93e09f7..dc987d6 100644 --- a/test/AccessLogJsonParse.sol +++ b/test/AccessLogJsonParse.sol @@ -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); } } diff --git a/test/SendCmioResponse.t.sol b/test/SendCmioResponse.t.sol index b038ebc..67900f9 100644 --- a/test/SendCmioResponse.t.sol +++ b/test/SendCmioResponse.t.sol @@ -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); @@ -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( diff --git a/test/UArchInterpret.t.sol b/test/UArchInterpret.t.sol index 2a1514f..4430dc8 100644 --- a/test/UArchInterpret.t.sol +++ b/test/UArchInterpret.t.sol @@ -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"; @@ -33,7 +32,6 @@ library ExternalUArchInterpret { } contract UArchInterpretTest is Test { - using stdJson for string; using Memory for uint64; using AccessLogs for AccessLogs.Context; @@ -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 = @@ -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; diff --git a/test/UArchReset.t.sol b/test/UArchReset.t.sol index b05356f..51c0d64 100644 --- a/test/UArchReset.t.sol +++ b/test/UArchReset.t.sol @@ -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);