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] 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