From f411c510874e5a874460f0b8391c1db64799b86f Mon Sep 17 00:00:00 2001 From: Marcelo Politzer <251334+mpolitzer@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:40:53 -0300 Subject: [PATCH 1/4] feat: update test data due to prev_randao field --- tests/lua/cartesi/tests/data.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/lua/cartesi/tests/data.lua b/tests/lua/cartesi/tests/data.lua index 098e109a2..36cd50a51 100644 --- a/tests/lua/cartesi/tests/data.lua +++ b/tests/lua/cartesi/tests/data.lua @@ -1,21 +1,23 @@ -- luacheck: push no max line length local M = { - -- cast calldata "EvmAdvance(uint256,address,address,uint256,uint256,uint256,bytes)" \ + -- cast calldata "EvmAdvance(uint256,address,address,uint256,uint256,uint256,uint256,bytes)" \ -- 0x0000000000000000000000000000000000000001 \ -- 0x0000000000000000000000000000000000000002 \ -- 0x0000000000000000000000000000000000000003 \ -- 0x0000000000000000000000000000000000000004 \ -- 0x0000000000000000000000000000000000000005 \ - -- 0x0000000000000000000000000000000000000000 \ + -- 0x0000000000000000000000000000000000000006 \ + -- 0x0000000000000000000000000000000000000007 \ -- 0x`echo -en "advance-0" | xxd -p -c0` | sed -e 's#0x##g;s#\(..\)#\\x\1#g' - valid_advance = "\xcc\x7d\xee\x1f\z + valid_advance = "\x41\x5b\xf3\x63\z \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\z \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\z \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\z \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\z \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\z - \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\z - \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\z + \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\z + \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\z + \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\z \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\z \x61\x64\x76\x61\x6e\x63\x65\x2d\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", From e4d5ee69362ed3dc8557957fac7fcfe2bc749ff7 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer <251334+mpolitzer@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:41:49 -0300 Subject: [PATCH 2/4] feat: output unification v2 Outputs root hash merkle tree is the same for all inputs, we stop resetting it for each input (v1). With that the tree will grow indefinetely and thus we also increased its depth to 2^63 leafs. --- src/cartesi-machine.lua | 2 +- tests/lua/cmio-test.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cartesi-machine.lua b/src/cartesi-machine.lua index 667832dda..b8c7f9db7 100755 --- a/src/cartesi-machine.lua +++ b/src/cartesi-machine.lua @@ -2053,7 +2053,7 @@ end local function check_outputs_root_hash(root_hash, hashes) local z = string.rep("\0", 32) if #hashes == 0 then hashes = { z } end - for _ = 1, 16 do + for _ = 1, 63 do local parent_output_hashes = {} local child = 1 local parent = 1 diff --git a/tests/lua/cmio-test.lua b/tests/lua/cmio-test.lua index 7acc9905a..0754c8b82 100755 --- a/tests/lua/cmio-test.lua +++ b/tests/lua/cmio-test.lua @@ -193,7 +193,7 @@ end local function check_outputs_root_hash(root_hash, output_hashes) local z = string.rep("\0", 32) if #output_hashes == 0 then output_hashes = { z } end - for _ = 1, 16 do + for _ = 1, 63 do local parent_output_hashes = {} local child = 1 local parent = 1 @@ -271,11 +271,11 @@ for _, dapp in pairs({ "ioctl", "http" }) do local suffix = "-" .. dapp local desc = " (" .. machine_type .. "," .. dapp .. ")" do_test( - "merkle tree state must match and reset for each advance" .. desc, + "merkle tree state must match and not reset for each advance" .. desc, "advance-state-machine" .. suffix, function(machine) + local hashes = {} for _ = 1, 2 do - local hashes = {} setup_advance(machine, test_data.valid_advance) -- 2 vouchers From 839d7892e0433f390c310fb4b7f1f6107142fe64 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer <251334+mpolitzer@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:42:59 -0300 Subject: [PATCH 3/4] fix: remove invalid test case The machine itself does not take any steps to restore its state, the the emulator driver / controller does. As such we cannot expect the machine to reset its own state and thus this test case makes no sense. --- tests/lua/cmio-test.lua | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tests/lua/cmio-test.lua b/tests/lua/cmio-test.lua index 0754c8b82..b3db889b7 100755 --- a/tests/lua/cmio-test.lua +++ b/tests/lua/cmio-test.lua @@ -319,26 +319,6 @@ for _, dapp in pairs({ "ioctl", "http" }) do return 0 end, 0) - do_test( - "merkle tree is pristine when input is rejected" .. desc, - "advance-rejecting-machine" .. suffix, - function(machine) - local hashes = {} - setup_advance(machine, test_data.valid_advance) - - -- 1 reports - machine:run(MAX_MCYCLE) - check_report(machine, test_data.valid_advance_report_reply) - - -- finish - machine:run(MAX_MCYCLE) - check_finish(machine, hashes, cartesi.machine.HTIF_YIELD_MANUAL_REASON_RX_REJECTED) - - return 0 - end, - 0 - ) - do_test("the other case" .. desc, "inspect-rejecting-machine" .. suffix, function(machine) local hashes = {} setup_inspect(machine, test_data.valid_inspect) From c64854f558596a26460d42a38ba7918df2e2b8a7 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer <251334+mpolitzer@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:20:00 -0300 Subject: [PATCH 4/4] chore: update rootfs version --- CHANGELOG.md | 3 +++ tests/Makefile | 2 +- tests/dependencies | 2 +- tests/dependencies.sha256 | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b7a5c0ce..8ebf76612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Update test rootfs to 0.16.0 +- Update outputs merkle height (for output unification v2) ### Added - Makefile target `create-generated-files-patch` to generate `add-generated-files.diff` patch diff --git a/tests/Makefile b/tests/Makefile index 537c0a11e..d72f32ae5 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -121,7 +121,7 @@ $(BUILDDIR)/%: $(CARTESI_IMAGES): | $(CARTESI_IMAGES_PATH) @wget -nc -i dependencies -P $(CARTESI_IMAGES_PATH) @shasum -ca 256 dependencies.sha256 - @cd $(CARTESI_IMAGES_PATH) && ln -s rootfs-tools-v0.15.0.ext2 rootfs.ext2 + @cd $(CARTESI_IMAGES_PATH) && ln -s rootfs-tools-v0.16.0.ext2 rootfs.ext2 @cd $(CARTESI_IMAGES_PATH) && ln -s linux-6.5.13-ctsi-1-v0.20.0.bin linux.bin images: | $(CARTESI_IMAGES) diff --git a/tests/dependencies b/tests/dependencies index ed059863e..7c547ed8a 100644 --- a/tests/dependencies +++ b/tests/dependencies @@ -1,2 +1,2 @@ -https://github.com/cartesi/machine-emulator-tools/releases/download/v0.15.0/rootfs-tools-v0.15.0.ext2 +https://github.com/cartesi/machine-emulator-tools/releases/download/v0.16.0/rootfs-tools-v0.16.0.ext2 https://github.com/cartesi/image-kernel/releases/download/v0.20.0/linux-6.5.13-ctsi-1-v0.20.0.bin diff --git a/tests/dependencies.sha256 b/tests/dependencies.sha256 index 510661e3f..6afcdf241 100644 --- a/tests/dependencies.sha256 +++ b/tests/dependencies.sha256 @@ -1,2 +1,2 @@ 65dd100ff6204346ac2f50f772721358b5c1451450ceb39a154542ee27b4c947 build/images/linux-6.5.13-ctsi-1-v0.20.0.bin -dee8f9b739814f0076cd629f1de98fd71a4b5bc57a417678f80422dc9ef85550 build/images/rootfs-tools-v0.15.0.ext2 +9bb25541c3e42e329d83cca40066772ac3d51491300bb32100127e04e4e6c531 build/images/rootfs-tools-v0.16.0.ext2