Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/output unification v2 #254

Merged
merged 4 commits into from
Jul 29, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cartesi-machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/dependencies
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/dependencies.sha256
Original file line number Diff line number Diff line change
@@ -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
12 changes: 7 additions & 5 deletions tests/lua/cartesi/tests/data.lua
Original file line number Diff line number Diff line change
@@ -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",

Expand Down
26 changes: 3 additions & 23 deletions tests/lua/cmio-test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading